Skip to content

Commit bf9676a

Browse files
committed
code cleanup, removed deeplink to route mapping as we can directly navigate
1 parent d583033 commit bf9676a

File tree

8 files changed

+24
-30
lines changed

8 files changed

+24
-30
lines changed

app/src/main/java/pseudoankit/droid/tasky/MainActivity.kt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import kotlinx.coroutines.flow.firstOrNull
2929
import kotlinx.coroutines.runBlocking
3030
import org.koin.android.ext.android.inject
3131
import pseudoankit.droid.core.deeplink.TaskyDeeplink
32-
import pseudoankit.droid.core.logger.TaskyLogger
32+
import pseudoankit.droid.core.logger.logInfo
3333
import pseudoankit.droid.coreui.deeplink.navigateViaDeepLink
3434
import pseudoankit.droid.coreui.util.extension.clearStack
3535
import pseudoankit.droid.navigation.navgraph.mainNavGraph
@@ -107,7 +107,7 @@ internal class MainActivity : ComponentActivity() {
107107

108108
val launcher = rememberPermissionState(permission = Manifest.permission.POST_NOTIFICATIONS)
109109

110-
TaskyLogger.info("Notification Permission Status", launcher.taskyStatus.name)
110+
logInfo("Notification Permission Status", launcher.taskyStatus.name)
111111

112112
LaunchedEffect(key1 = Unit) {
113113
launcher.launchPermissionRequest()
@@ -127,8 +127,4 @@ internal class MainActivity : ComponentActivity() {
127127
}
128128
}
129129
}
130-
131-
override fun onDestroy() {
132-
super.onDestroy()
133-
}
134130
}

core/core-ui/src/main/java/pseudoankit/droid/coreui/deeplink/DeepLinkReciever.kt

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
package pseudoankit.droid.coreui.deeplink
22

3+
import android.net.Uri
34
import androidx.navigation.NavController
4-
import pseudoankit.droid.core.deeplink.TaskyDeeplink
5-
import pseudoankit.droid.core.logger.TaskyLogger
5+
import pseudoankit.droid.core.logger.logError
66

7-
fun NavController.navigateViaDeepLink(deepLink: String) = try {
8-
val internalRoute = TaskyDeeplink.mapToInternalRoute(deepLink)
9-
navigate(internalRoute)
7+
fun NavController.navigateViaDeepLink(deepLink: String) {
8+
navigateViaDeepLink(Uri.parse(deepLink))
9+
}
10+
11+
fun NavController.navigateViaDeepLink(uri: Uri) = try {
12+
navigate(uri)
1013
} catch (e: IllegalArgumentException) {
1114
e.printStackTrace()
12-
TaskyLogger.error("deeplink [$deepLink] failed with error msg = ${e.message}")
15+
logError("deeplink [${uri}] failed with error msg ${e.message}")
1316
}
14-

core/core-ui/src/main/java/pseudoankit/droid/coreui/util/extension/ContextExtension.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,14 @@ import android.content.Intent
77
import android.net.Uri
88
import android.provider.Settings
99
import android.widget.Toast
10+
import pseudoankit.droid.core.deeplink.DeepLinkUtil
1011
import pseudoankit.droid.core.util.TextResource
1112
import pseudoankit.droid.core.util.TextResource.Companion.asString
1213

14+
fun Context.openDeeplink(deeplink: String) {
15+
startActivity(DeepLinkUtil.createDeeplinkIntent(deeplink))
16+
}
17+
1318
fun Context.finish() {
1419
(this as? Activity)?.finish()
1520
}

core/core/src/main/java/pseudoankit/droid/core/coroutine/CoroutineUtil.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import kotlinx.coroutines.Job
66
import kotlinx.coroutines.launch
77
import kotlin.coroutines.CoroutineContext
88

9-
fun launch(
9+
fun launchCoroutine(
1010
dispatcher: CoroutineContext = Dispatchers.IO,
1111
block: suspend CoroutineScope.() -> Unit
1212
): Job {

core/core/src/main/java/pseudoankit/droid/core/deeplink/TaskyDeeplink.kt

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,4 @@ object TaskyDeeplink {
2626
const val home = "${SCHEME}${Host.home}"
2727
const val reminder = "${SCHEME}${Host.reminder}/${Path.Reminder.action}"
2828
const val agendaSelection = "${SCHEME}${Host.agendaSelection}"
29-
30-
fun mapToInternalRoute(externalLink: String) = externalLink.run {
31-
when {
32-
contains(Host.home) -> "home_screen"
33-
contains(Host.login) -> "login_screen"
34-
contains(Host.reminder) -> {
35-
replace(SCHEME + Host.reminder, "reminder_screen")
36-
}
37-
contains(Host.agendaSelection) -> "agenda_items_screen"
38-
contains(Host.registration) -> "registration_screen"
39-
else -> ""
40-
}
41-
}
4229
}

core/core/src/main/java/pseudoankit/droid/core/logger/TaskyLogger.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,7 @@ object TaskyLogger {
1818
fun logInfo(vararg value: Any, tag: String = "") {
1919
TaskyLogger.info(*value, tag)
2020
}
21+
22+
fun logError(vararg value: Any, tag: String = "") {
23+
TaskyLogger.error(*value, tag)
24+
}

core/core/src/main/java/pseudoankit/droid/core/util/extension/CollectionExtension.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,5 @@ import kotlinx.collections.immutable.ImmutableList
44
import kotlinx.collections.immutable.toImmutableList
55

66
inline fun <T, R> Iterable<T>.mapToImmutableList(transform: (T) -> R): ImmutableList<R> {
7-
return map {
8-
transform(it)
9-
}.toImmutableList()
7+
return map(transform).toImmutableList()
108
}

core/preferences-manager/src/main/java/pseudoankit/droid/preferencesmanager/BasePreference.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import androidx.datastore.preferences.core.edit
66
import androidx.datastore.preferences.core.emptyPreferences
77
import kotlinx.coroutines.flow.Flow
88
import kotlinx.coroutines.flow.catch
9+
import kotlinx.coroutines.flow.distinctUntilChanged
910
import kotlinx.coroutines.flow.firstOrNull
1011
import kotlinx.coroutines.flow.map
1112

@@ -31,5 +32,6 @@ abstract class BasePreference(
3132
.map { prefs ->
3233
prefs[key]
3334
}
35+
.distinctUntilChanged()
3436
}
3537
}

0 commit comments

Comments
 (0)