From f737a1422c74d258ba98774e6a239a12a228d2d1 Mon Sep 17 00:00:00 2001 From: Tangem Date: Tue, 20 May 2025 12:41:07 +0500 Subject: [PATCH] Updated on 2026-08-14 --- app/src/main/AndroidManifest.xml | 22 ++++++++++++++++ .../tap/routing/utils/DeepLinkFactory.kt | 7 +++++ .../tap/routing/utils/DeepLinkFactoryTest.kt | 26 +++++++++++++++++++ .../tangem/common/routing/DeepLinkRoute.kt | 8 ++++++ .../notifications/models/NotificationType.kt | 13 ++++++++++ .../wallet/deeplink/WalletDeepLinkHandler.kt | 8 ++++++ .../deeplink/DefaultWalletDeepLinkHandler.kt | 13 ++++++++++ .../deeplink/di/WalletDeepLinkModule.kt | 18 +++++++++++++ 8 files changed, 115 insertions(+) create mode 100644 domain/notifications/models/src/main/java/com/tangem/domain/notifications/models/NotificationType.kt create mode 100644 features/wallet/api/src/main/kotlin/com/tangem/features/wallet/deeplink/WalletDeepLinkHandler.kt create mode 100644 features/wallet/impl/src/main/java/com/tangem/feature/wallet/deeplink/DefaultWalletDeepLinkHandler.kt create mode 100644 features/wallet/impl/src/main/java/com/tangem/feature/wallet/deeplink/di/WalletDeepLinkModule.kt diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 826b723d16..13f1801543 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -154,6 +154,28 @@ android:scheme="tangem" /> + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/java/com/tangem/tap/routing/utils/DeepLinkFactory.kt b/app/src/main/java/com/tangem/tap/routing/utils/DeepLinkFactory.kt index 4eb339d9e0..d749eabc93 100644 --- a/app/src/main/java/com/tangem/tap/routing/utils/DeepLinkFactory.kt +++ b/app/src/main/java/com/tangem/tap/routing/utils/DeepLinkFactory.kt @@ -8,6 +8,8 @@ import com.tangem.feature.referral.api.deeplink.ReferralDeepLinkHandler import com.tangem.features.onramp.deeplink.BuyDeepLinkHandler import com.tangem.features.onramp.deeplink.OnrampDeepLinkHandler import com.tangem.features.send.v2.api.deeplink.SellDeepLinkHandler +import com.tangem.features.tokendetails.deeplink.TokenDetailsDeepLinkHandler +import com.tangem.features.wallet.deeplink.WalletDeepLinkHandler import com.tangem.features.walletconnect.components.deeplink.WalletConnectDeepLinkHandler import com.tangem.utils.coroutines.JobHolder import com.tangem.utils.coroutines.saveIn @@ -20,6 +22,7 @@ import kotlinx.coroutines.flow.transformLatest import timber.log.Timber import javax.inject.Inject +@Suppress("LongParameterList") @ActivityScoped internal class DeepLinkFactory @Inject constructor( private val onrampDeepLink: OnrampDeepLinkHandler.Factory, @@ -27,6 +30,8 @@ internal class DeepLinkFactory @Inject constructor( private val buyDeepLink: BuyDeepLinkHandler.Factory, private val referralDeepLink: ReferralDeepLinkHandler.Factory, private val walletConnectDeepLink: WalletConnectDeepLinkHandler.Factory, + private val walletDeepLink: WalletDeepLinkHandler.Factory, + private val tokenDetailsDeepLink: TokenDetailsDeepLinkHandler.Factory, ) { private val permittedAppRoute = MutableStateFlow(false) @@ -94,6 +99,8 @@ internal class DeepLinkFactory @Inject constructor( DeepLinkRoute.Sell.host -> sellDeepLink.create(coroutineScope, params) DeepLinkRoute.Buy.host -> buyDeepLink.create(coroutineScope) DeepLinkRoute.Referral.host -> referralDeepLink.create() + DeepLinkRoute.Wallet.host -> walletDeepLink.create() + DeepLinkRoute.TokenDetails.host -> tokenDetailsDeepLink.create(coroutineScope, params) else -> { Timber.i( """ diff --git a/app/src/test/kotlin/com/tangem/tap/routing/utils/DeepLinkFactoryTest.kt b/app/src/test/kotlin/com/tangem/tap/routing/utils/DeepLinkFactoryTest.kt index 03badaf8ef..32be06bd2f 100644 --- a/app/src/test/kotlin/com/tangem/tap/routing/utils/DeepLinkFactoryTest.kt +++ b/app/src/test/kotlin/com/tangem/tap/routing/utils/DeepLinkFactoryTest.kt @@ -6,6 +6,8 @@ import com.tangem.feature.referral.api.deeplink.ReferralDeepLinkHandler import com.tangem.features.onramp.deeplink.BuyDeepLinkHandler import com.tangem.features.onramp.deeplink.OnrampDeepLinkHandler import com.tangem.features.send.v2.api.deeplink.SellDeepLinkHandler +import com.tangem.features.tokendetails.deeplink.TokenDetailsDeepLinkHandler +import com.tangem.features.wallet.deeplink.WalletDeepLinkHandler import com.tangem.features.walletconnect.components.deeplink.WalletConnectDeepLinkHandler import io.mockk.every import io.mockk.mockk @@ -37,6 +39,12 @@ class DeepLinkFactoryTest { private val walletConnectDeepLinkFactory = mockk(relaxed = true) { every { create(any()) } returns mockk() } + private val walletDeepLinkFactory = mockk(relaxed = true) { + every { create() } returns mockk() + } + private val tokenDetailsDeepLinkFactory = mockk(relaxed = true) { + every { create(any(), any()) } returns mockk() + } private val mockedUri = mockk(relaxed = true) @@ -49,6 +57,8 @@ class DeepLinkFactoryTest { buyDeepLinkFactory, referralDeepLinkFactory, walletConnectDeepLinkFactory, + walletDeepLinkFactory, + tokenDetailsDeepLinkFactory, ) @OptIn(ExperimentalCoroutinesApi::class) @@ -162,6 +172,8 @@ class DeepLinkFactoryTest { buyDeepLinkFactory.create(any()) referralDeepLinkFactory.create() walletConnectDeepLinkFactory.create(any()) + walletDeepLinkFactory.create() + tokenDetailsDeepLinkFactory.create(any(), any()) } } @@ -186,6 +198,12 @@ class DeepLinkFactoryTest { advanceUntilIdle() verify { sellDeepLinkFactory.create(eq(testScope), eq(mapOf("param" to "value"))) } + // Test Token Details + every { mockedUri.host } returns "token" + deepLinkFactory.handleDeeplink(mockedUri, testScope) + advanceUntilIdle() + verify { tokenDetailsDeepLinkFactory.create(eq(testScope), eq(mapOf("param" to "value"))) } + // Reset params every { mockedUri.queryParameterNames } returns emptySet() every { mockedUri.getQueryParameter(any()) } returns "" @@ -201,6 +219,12 @@ class DeepLinkFactoryTest { deepLinkFactory.handleDeeplink(mockedUri, testScope) advanceUntilIdle() verify { referralDeepLinkFactory.create() } + + // Test Wallet + every { mockedUri.host } returns "main" + deepLinkFactory.handleDeeplink(mockedUri, testScope) + advanceUntilIdle() + verify { walletDeepLinkFactory.create() } } @Test @@ -219,6 +243,8 @@ class DeepLinkFactoryTest { buyDeepLinkFactory.create(any()) referralDeepLinkFactory.create() walletConnectDeepLinkFactory.create(any()) + walletDeepLinkFactory.create() + tokenDetailsDeepLinkFactory.create(any(), any()) } } diff --git a/common/routing/src/main/kotlin/com/tangem/common/routing/DeepLinkRoute.kt b/common/routing/src/main/kotlin/com/tangem/common/routing/DeepLinkRoute.kt index 5eb9bafa87..c683a4136d 100644 --- a/common/routing/src/main/kotlin/com/tangem/common/routing/DeepLinkRoute.kt +++ b/common/routing/src/main/kotlin/com/tangem/common/routing/DeepLinkRoute.kt @@ -19,6 +19,14 @@ sealed class DeepLinkRoute { data object Referral : DeepLinkRoute() { override val host: String = "referral" } + + data object Wallet : DeepLinkRoute() { + override val host: String = "main" + } + + data object TokenDetails : DeepLinkRoute() { + override val host: String = "token" + } } enum class DeepLinkScheme(val scheme: String) { diff --git a/domain/notifications/models/src/main/java/com/tangem/domain/notifications/models/NotificationType.kt b/domain/notifications/models/src/main/java/com/tangem/domain/notifications/models/NotificationType.kt new file mode 100644 index 0000000000..ac0ce65b35 --- /dev/null +++ b/domain/notifications/models/src/main/java/com/tangem/domain/notifications/models/NotificationType.kt @@ -0,0 +1,13 @@ +package com.tangem.domain.notifications.models + +enum class NotificationType(val type: String) { + Promo("promo"), + Unknown("unknown"), + ; + + companion object { + fun getType(type: String?): NotificationType { + return entries.firstOrNull { it.type == type } ?: Unknown + } + } +} \ No newline at end of file diff --git a/features/wallet/api/src/main/kotlin/com/tangem/features/wallet/deeplink/WalletDeepLinkHandler.kt b/features/wallet/api/src/main/kotlin/com/tangem/features/wallet/deeplink/WalletDeepLinkHandler.kt new file mode 100644 index 0000000000..b798fcf1e4 --- /dev/null +++ b/features/wallet/api/src/main/kotlin/com/tangem/features/wallet/deeplink/WalletDeepLinkHandler.kt @@ -0,0 +1,8 @@ +package com.tangem.features.wallet.deeplink + +interface WalletDeepLinkHandler { + + interface Factory { + fun create(): WalletDeepLinkHandler + } +} \ No newline at end of file diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/deeplink/DefaultWalletDeepLinkHandler.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/deeplink/DefaultWalletDeepLinkHandler.kt new file mode 100644 index 0000000000..508333060f --- /dev/null +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/deeplink/DefaultWalletDeepLinkHandler.kt @@ -0,0 +1,13 @@ +package com.tangem.feature.wallet.deeplink + +import com.tangem.features.wallet.deeplink.WalletDeepLinkHandler +import dagger.assisted.AssistedFactory +import dagger.assisted.AssistedInject + +internal class DefaultWalletDeepLinkHandler @AssistedInject constructor() : WalletDeepLinkHandler { + + @AssistedFactory + interface Factory : WalletDeepLinkHandler.Factory { + override fun create(): DefaultWalletDeepLinkHandler + } +} \ No newline at end of file diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/deeplink/di/WalletDeepLinkModule.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/deeplink/di/WalletDeepLinkModule.kt new file mode 100644 index 0000000000..5b8b66deed --- /dev/null +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/deeplink/di/WalletDeepLinkModule.kt @@ -0,0 +1,18 @@ +package com.tangem.feature.wallet.deeplink.di + +import com.tangem.feature.wallet.deeplink.DefaultWalletDeepLinkHandler +import com.tangem.features.wallet.deeplink.WalletDeepLinkHandler +import dagger.Binds +import dagger.Module +import dagger.hilt.InstallIn +import dagger.hilt.components.SingletonComponent +import javax.inject.Singleton + +@Module +@InstallIn(SingletonComponent::class) +internal interface WalletDeepLinkModule { + + @Binds + @Singleton + fun bindWalletDeepLinkHandlerFactory(impl: DefaultWalletDeepLinkHandler.Factory): WalletDeepLinkHandler.Factory +} \ No newline at end of file