From f3ac84ef22bee6a584b6b9d29ca532a7260210d9 Mon Sep 17 00:00:00 2001 From: Santiago Mattiauda Date: Mon, 22 Apr 2024 14:47:13 -0300 Subject: [PATCH] [feature] start to publish --- gradle.properties | 9 ++- gradle/wrapper/gradle-wrapper.properties | 4 +- jetipack.yml | 2 + watcher/build.gradle.kts | 16 +++++ .../deeplink/watcher/DeeplinkWatcher.kt | 6 +- .../feature/detail/DeepLinkDetailActivity.kt | 63 ++++++++++++++++--- .../feature/detail/DeepLinkDetailUiState.kt | 6 +- .../feature/viewer/DeepLinksViewerActivity.kt | 18 +++++- .../viewer/components/DeeplinkCollection.kt | 3 +- .../navigation/LocalNavigationController.kt | 1 + .../navigation/NavigationController.kt | 2 +- watcher/src/main/res/values/strings.xml | 4 ++ 12 files changed, 113 insertions(+), 21 deletions(-) create mode 100644 jetipack.yml diff --git a/gradle.properties b/gradle.properties index 5c922db..11bef07 100644 --- a/gradle.properties +++ b/gradle.properties @@ -29,5 +29,12 @@ target_sdk_version=34 version_code=1 version_name=1.0 compose_compiler=1.5.11 + android.defaults.buildfeatures.buildconfig=true -android.nonFinalResIds=false \ No newline at end of file +android.nonFinalResIds=false +android.disableAutomaticComponentCreation=true + +# Lib +group_id=io.github.santimattius +artifact_id=deeplink-watcher +lib_version=0.0.1 \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 8bb0615..42b37b6 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Tue Dec 12 08:48:28 UYT 2023 +#Mon Apr 22 13:51:06 UYT 2024 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/jetipack.yml b/jetipack.yml new file mode 100644 index 0000000..efde7bf --- /dev/null +++ b/jetipack.yml @@ -0,0 +1,2 @@ +jdk: + - openjdk17 diff --git a/watcher/build.gradle.kts b/watcher/build.gradle.kts index 79ef4d1..d22d54a 100644 --- a/watcher/build.gradle.kts +++ b/watcher/build.gradle.kts @@ -3,6 +3,7 @@ plugins { alias(libs.plugins.android.library) alias(libs.plugins.kotlin) alias(libs.plugins.ksp) + id("maven-publish") } android { @@ -47,6 +48,21 @@ android { } } +publishing { + publications { + register("release") { + groupId = extraString("group_id") + artifactId = extraString("artifact_id") + version = extraString("lib_version") + + afterEvaluate { + from(components["release"]) + } + } + } +} + + dependencies { implementation(kotlin("reflect")) diff --git a/watcher/src/main/java/io/github/santimattius/android/deeplink/watcher/DeeplinkWatcher.kt b/watcher/src/main/java/io/github/santimattius/android/deeplink/watcher/DeeplinkWatcher.kt index 9de817a..345e66c 100644 --- a/watcher/src/main/java/io/github/santimattius/android/deeplink/watcher/DeeplinkWatcher.kt +++ b/watcher/src/main/java/io/github/santimattius/android/deeplink/watcher/DeeplinkWatcher.kt @@ -1,10 +1,8 @@ package io.github.santimattius.android.deeplink.watcher import android.content.Context -import android.content.Intent import io.github.santimattius.android.deeplink.watcher.internal.core.domain.DeepLinkCreatedEvent import io.github.santimattius.android.deeplink.watcher.internal.di.DependencyProvider -import io.github.santimattius.android.deeplink.watcher.internal.feature.viewer.DeepLinksViewerActivity import io.github.santimattius.android.deeplink.watcher.internal.initializer.DeeplinkWatcherInitializer import kotlinx.coroutines.CoroutineScope @@ -14,8 +12,8 @@ object DeeplinkWatcher { @JvmStatic fun showViewer(context: Context) { - val intent = Intent(context, DeepLinksViewerActivity::class.java) - context.startActivity(intent) + val navController = DependencyProvider.provideNavController(context) + navController.goToViewer() } @JvmStatic diff --git a/watcher/src/main/java/io/github/santimattius/android/deeplink/watcher/internal/feature/detail/DeepLinkDetailActivity.kt b/watcher/src/main/java/io/github/santimattius/android/deeplink/watcher/internal/feature/detail/DeepLinkDetailActivity.kt index 3504d5e..dd95423 100644 --- a/watcher/src/main/java/io/github/santimattius/android/deeplink/watcher/internal/feature/detail/DeepLinkDetailActivity.kt +++ b/watcher/src/main/java/io/github/santimattius/android/deeplink/watcher/internal/feature/detail/DeepLinkDetailActivity.kt @@ -11,6 +11,8 @@ import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.rememberScrollState +import androidx.compose.foundation.verticalScroll import androidx.compose.material.icons.Icons import androidx.compose.material.icons.automirrored.filled.ArrowBack import androidx.compose.material3.Card @@ -30,6 +32,7 @@ import androidx.compose.ui.platform.LocalClipboardManager import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.AnnotatedString +import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.lifecycle.compose.collectAsStateWithLifecycle import io.github.santimattius.android.deeplink.watcher.R @@ -41,6 +44,8 @@ import io.github.santimattius.android.deeplink.watcher.internal.core.ui.componen import io.github.santimattius.android.deeplink.watcher.internal.core.ui.components.DeeplinkWatcherContainer import io.github.santimattius.android.deeplink.watcher.internal.di.createDeepLinkDetailViewModel import io.github.santimattius.android.deeplink.watcher.internal.feature.detail.components.DetailRow +import java.util.Date +import java.util.UUID @ExcludeFromDeeplinkWatcher class DeepLinkDetailActivity : ComponentActivity() { @@ -53,7 +58,7 @@ class DeepLinkDetailActivity : ComponentActivity() { super.onCreate(savedInstanceState) setContent { DeeplinkWatcherContainer { - DeepLinkDetailScreen(viewModel = viewModel, onBack = { finish() }) + DeepLinkDetailRoute(viewModel = viewModel, onBack = { finish() }) } } } @@ -65,12 +70,25 @@ class DeepLinkDetailActivity : ComponentActivity() { } @Composable -private fun DeepLinkDetailScreen( +private fun DeepLinkDetailRoute( viewModel: DeepLinkDetailViewModel, onBack: () -> Unit = {} ) { val state by viewModel.uiState.collectAsStateWithLifecycle() val clipboardManager: ClipboardManager = LocalClipboardManager.current + DeepLinkDetailScreen( + state = state, + onCopy = { clipboardManager.setText(AnnotatedString(it)) }, + onBack = onBack + ) +} + +@Composable +private fun DeepLinkDetailScreen( + state: DeepLinkDetailUiState, + onCopy: (String) -> Unit = {}, + onBack: () -> Unit = {} +) { Scaffold( topBar = { AppBar( @@ -83,8 +101,11 @@ private fun DeepLinkDetailScreen( actions = { val deepLink = state.deepLink if (deepLink != null) { - IconButton(onClick = { clipboardManager.setText(AnnotatedString(deepLink.uri))}) { - Icon(painter = painterResource(id = R.drawable.ic_copy), contentDescription = stringResource(R.string.text_close_action)) + IconButton(onClick = { onCopy(deepLink.uri) }) { + Icon( + painter = painterResource(id = R.drawable.ic_copy), + contentDescription = stringResource(R.string.text_close_action) + ) } } } @@ -96,12 +117,14 @@ private fun DeepLinkDetailScreen( modifier = Modifier .fillMaxSize() .padding(padding) + .verticalScroll(rememberScrollState()), + contentAlignment = if (state.isDeepLinkAvailable) Alignment.TopCenter else Alignment.Center ) { when { state.isLoading -> CircularProgressIndicator() - state.withError || state.deepLink == null -> Text(text = "Ocurrio un error") + state.withError || state.deepLink == null -> Text(text = stringResource(R.string.text_message_unavailable_deeplink_detail)) else -> { - val deepLink = state.deepLink!! + val deepLink = state.deepLink DeepLinkDetailContent(deepLink) } } @@ -110,7 +133,10 @@ private fun DeepLinkDetailScreen( } @Composable -private fun DeepLinkDetailContent(deeplink: Deeplink, modifier: Modifier = Modifier) { +private fun DeepLinkDetailContent( + deeplink: Deeplink, + modifier: Modifier = Modifier +) { Card( modifier = modifier .fillMaxWidth() @@ -124,9 +150,26 @@ private fun DeepLinkDetailContent(deeplink: Deeplink, modifier: Modifier = Modif verticalArrangement = Arrangement.spacedBy(8.dp), horizontalAlignment = Alignment.CenterHorizontally ) { - DetailRow(label = "CreateAt", text = deeplink.createAt.format()) - DetailRow(label = "From", text = deeplink.referrer ?: "Undefined") - DetailRow(label = "Uri", text = deeplink.uri) + DetailRow(label = stringResource(R.string.label_create_at), text = deeplink.createAt.format()) + DetailRow(label = stringResource(R.string.label_from), text = deeplink.referrer ?: "Undefined") + DetailRow(label = stringResource(R.string.label_uri), text = deeplink.uri) } } +} + +@Preview(showSystemUi = true) +@Composable +private fun DeepLinkDetailContentPreview() { + DeeplinkWatcherContainer { + DeepLinkDetailScreen( + state = DeepLinkDetailUiState( + deepLink = Deeplink( + UUID.randomUUID().toString(), + "app://test", + referrer = null, + createAt = Date() + ) + ) + ) + } } \ No newline at end of file diff --git a/watcher/src/main/java/io/github/santimattius/android/deeplink/watcher/internal/feature/detail/DeepLinkDetailUiState.kt b/watcher/src/main/java/io/github/santimattius/android/deeplink/watcher/internal/feature/detail/DeepLinkDetailUiState.kt index 63b20c4..f00b561 100644 --- a/watcher/src/main/java/io/github/santimattius/android/deeplink/watcher/internal/feature/detail/DeepLinkDetailUiState.kt +++ b/watcher/src/main/java/io/github/santimattius/android/deeplink/watcher/internal/feature/detail/DeepLinkDetailUiState.kt @@ -6,4 +6,8 @@ internal data class DeepLinkDetailUiState( val isLoading: Boolean = false, val deepLink: Deeplink? = null, val withError: Boolean = false -) +) { + + val isDeepLinkAvailable: Boolean + get() = !isLoading && !withError && deepLink != null +} diff --git a/watcher/src/main/java/io/github/santimattius/android/deeplink/watcher/internal/feature/viewer/DeepLinksViewerActivity.kt b/watcher/src/main/java/io/github/santimattius/android/deeplink/watcher/internal/feature/viewer/DeepLinksViewerActivity.kt index a592afc..543f738 100644 --- a/watcher/src/main/java/io/github/santimattius/android/deeplink/watcher/internal/feature/viewer/DeepLinksViewerActivity.kt +++ b/watcher/src/main/java/io/github/santimattius/android/deeplink/watcher/internal/feature/viewer/DeepLinksViewerActivity.kt @@ -19,6 +19,7 @@ import androidx.compose.ui.tooling.preview.Preview import androidx.lifecycle.compose.collectAsStateWithLifecycle import io.github.santimattius.android.deeplink.watcher.R import io.github.santimattius.android.deeplink.watcher.annotations.ExcludeFromDeeplinkWatcher +import io.github.santimattius.android.deeplink.watcher.internal.core.domain.Deeplink import io.github.santimattius.android.deeplink.watcher.internal.core.ui.components.AppBar import io.github.santimattius.android.deeplink.watcher.internal.core.ui.components.AppBarIcon import io.github.santimattius.android.deeplink.watcher.internal.core.ui.components.AppBarIconModel @@ -124,7 +125,7 @@ private fun DeeplinkViewerContent( @Preview @Composable -fun DeeplinkContentPreview() { +fun DeeplinkEmptyContentPreview() { DeeplinkWatcherContainer { DeeplinkViewerContent( state = DeeplinkViewerUiState(), @@ -133,4 +134,19 @@ fun DeeplinkContentPreview() { onViewCollectionAction = {} ) } +} + +@Preview +@Composable +fun DeeplinkContentPreview() { + DeeplinkWatcherContainer { + DeeplinkViewerContent( + state = DeeplinkViewerUiState( + data = (1..10).map { Deeplink.create("app://test/${it}") } + ), + onTextChange = {}, + onSearch = {}, + onViewCollectionAction = {} + ) + } } \ No newline at end of file diff --git a/watcher/src/main/java/io/github/santimattius/android/deeplink/watcher/internal/feature/viewer/components/DeeplinkCollection.kt b/watcher/src/main/java/io/github/santimattius/android/deeplink/watcher/internal/feature/viewer/components/DeeplinkCollection.kt index a05a36a..63d4efb 100644 --- a/watcher/src/main/java/io/github/santimattius/android/deeplink/watcher/internal/feature/viewer/components/DeeplinkCollection.kt +++ b/watcher/src/main/java/io/github/santimattius/android/deeplink/watcher/internal/feature/viewer/components/DeeplinkCollection.kt @@ -116,7 +116,7 @@ private fun DeeplinkItem( .clickable { onClick(deeplink) } .padding(top = 4.dp, bottom = 4.dp), colors = CardDefaults.cardColors(containerColor = Color.White), - elevation = CardDefaults.cardElevation(defaultElevation = 2.dp), + elevation = CardDefaults.cardElevation(defaultElevation = 1.dp), ) { ListItem( colors = ListItemDefaults.colors( @@ -150,6 +150,7 @@ private fun DeeplinkItem( R.drawable.ic_phone } ), + tint = MaterialTheme.colorScheme.primary, contentDescription = null ) diff --git a/watcher/src/main/java/io/github/santimattius/android/deeplink/watcher/internal/navigation/LocalNavigationController.kt b/watcher/src/main/java/io/github/santimattius/android/deeplink/watcher/internal/navigation/LocalNavigationController.kt index 48bdc5f..4fe967c 100644 --- a/watcher/src/main/java/io/github/santimattius/android/deeplink/watcher/internal/navigation/LocalNavigationController.kt +++ b/watcher/src/main/java/io/github/santimattius/android/deeplink/watcher/internal/navigation/LocalNavigationController.kt @@ -19,6 +19,7 @@ internal class LocalNavigationController( override fun goToViewer() { val intent = Intent(context, DeepLinksViewerActivity::class.java) + intent.flags = FLAG_ACTIVITY_NEW_TASK context.startActivity(intent) } } \ No newline at end of file diff --git a/watcher/src/main/java/io/github/santimattius/android/deeplink/watcher/internal/navigation/NavigationController.kt b/watcher/src/main/java/io/github/santimattius/android/deeplink/watcher/internal/navigation/NavigationController.kt index 43349a5..bb2a693 100644 --- a/watcher/src/main/java/io/github/santimattius/android/deeplink/watcher/internal/navigation/NavigationController.kt +++ b/watcher/src/main/java/io/github/santimattius/android/deeplink/watcher/internal/navigation/NavigationController.kt @@ -1,6 +1,6 @@ package io.github.santimattius.android.deeplink.watcher.internal.navigation -interface NavigationController { +internal interface NavigationController { fun goToDetail(id: String) diff --git a/watcher/src/main/res/values/strings.xml b/watcher/src/main/res/values/strings.xml index 683eac2..3c536e8 100644 --- a/watcher/src/main/res/values/strings.xml +++ b/watcher/src/main/res/values/strings.xml @@ -5,4 +5,8 @@ Close Deeplink Viewer Content not available + CreateAt + From + Uri + Content not available \ No newline at end of file