Skip to content

Commit

Permalink
[feature] start to publish
Browse files Browse the repository at this point in the history
  • Loading branch information
santimattius committed Apr 22, 2024
1 parent ce7749b commit f3ac84e
Show file tree
Hide file tree
Showing 12 changed files with 113 additions and 21 deletions.
9 changes: 8 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
android.nonFinalResIds=false
android.disableAutomaticComponentCreation=true

# Lib
group_id=io.github.santimattius
artifact_id=deeplink-watcher
lib_version=0.0.1
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions jetipack.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
jdk:
- openjdk17
16 changes: 16 additions & 0 deletions watcher/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ plugins {
alias(libs.plugins.android.library)
alias(libs.plugins.kotlin)
alias(libs.plugins.ksp)
id("maven-publish")
}

android {
Expand Down Expand Up @@ -47,6 +48,21 @@ android {
}
}

publishing {
publications {
register<MavenPublication>("release") {
groupId = extraString("group_id")
artifactId = extraString("artifact_id")
version = extraString("lib_version")

afterEvaluate {
from(components["release"])
}
}
}
}


dependencies {

implementation(kotlin("reflect"))
Expand Down
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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() {
Expand All @@ -53,7 +58,7 @@ class DeepLinkDetailActivity : ComponentActivity() {
super.onCreate(savedInstanceState)
setContent {
DeeplinkWatcherContainer {
DeepLinkDetailScreen(viewModel = viewModel, onBack = { finish() })
DeepLinkDetailRoute(viewModel = viewModel, onBack = { finish() })
}
}
}
Expand All @@ -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(
Expand All @@ -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)
)
}
}
}
Expand All @@ -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)
}
}
Expand All @@ -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()
Expand All @@ -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()
)
)
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -124,7 +125,7 @@ private fun DeeplinkViewerContent(

@Preview
@Composable
fun DeeplinkContentPreview() {
fun DeeplinkEmptyContentPreview() {
DeeplinkWatcherContainer {
DeeplinkViewerContent(
state = DeeplinkViewerUiState(),
Expand All @@ -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 = {}
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -150,6 +150,7 @@ private fun DeeplinkItem(
R.drawable.ic_phone
}
),
tint = MaterialTheme.colorScheme.primary,
contentDescription = null
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.github.santimattius.android.deeplink.watcher.internal.navigation

interface NavigationController {
internal interface NavigationController {

fun goToDetail(id: String)

Expand Down
4 changes: 4 additions & 0 deletions watcher/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@
<string name="text_close_action">Close</string>
<string name="title_deeplink_viewer">Deeplink Viewer</string>
<string name="text_content_not_available">Content not available</string>
<string name="label_create_at">CreateAt</string>
<string name="label_from">From</string>
<string name="label_uri">Uri</string>
<string name="text_message_unavailable_deeplink_detail">Content not available</string>
</resources>

0 comments on commit f3ac84e

Please sign in to comment.