From 5faed3ccac4f5f6619729dceccf17de0893fda2b Mon Sep 17 00:00:00 2001 From: Tangem Date: Thu, 16 Jan 2025 11:53:02 +0200 Subject: [PATCH] Updated on 2026-08-14 --- app/src/main/java/com/tangem/tap/MainActivity.kt | 13 +++++++++++-- .../tap/features/intentHandler/AffectsNavigation.kt | 3 +++ .../tap/features/intentHandler/IntentProcessor.kt | 8 ++++---- .../handlers/BackgroundScanIntentHandler.kt | 3 ++- .../handlers/WalletConnectLinkIntentHandler.kt | 3 ++- 5 files changed, 22 insertions(+), 8 deletions(-) create mode 100644 app/src/main/java/com/tangem/tap/features/intentHandler/AffectsNavigation.kt diff --git a/app/src/main/java/com/tangem/tap/MainActivity.kt b/app/src/main/java/com/tangem/tap/MainActivity.kt index 5be8aec645..48f1917235 100644 --- a/app/src/main/java/com/tangem/tap/MainActivity.kt +++ b/app/src/main/java/com/tangem/tap/MainActivity.kt @@ -511,7 +511,7 @@ class MainActivity : AppCompatActivity(), SnackbarHandler, ActivityResultCallbac super.onNewIntent(intent) lifecycleScope.launch { - intentProcessor.handleIntent(intent, true) + intentProcessor.handleIntent(intent = intent, isFromForeground = true) } if (intent != null) { @@ -628,6 +628,11 @@ class MainActivity : AppCompatActivity(), SnackbarHandler, ActivityResultCallbac store.dispatchNavigationAction { replaceAll(AppRoute.Welcome(intentWhichStartedActivity?.let(::SerializableIntent))) } + intentProcessor.handleIntent( + intent = intentWhichStartedActivity, + isFromForeground = false, + skipNavigationHandlers = true, + ) } else { lifecycleScope.launch { val shouldShowTos = !cardRepository.isTangemTOSAccepted() @@ -640,7 +645,11 @@ class MainActivity : AppCompatActivity(), SnackbarHandler, ActivityResultCallbac } store.dispatchNavigationAction { replaceAll(route) } - intentProcessor.handleIntent(intentWhichStartedActivity, false) + intentProcessor.handleIntent( + intent = intentWhichStartedActivity, + isFromForeground = false, + skipNavigationHandlers = false, + ) } } diff --git a/app/src/main/java/com/tangem/tap/features/intentHandler/AffectsNavigation.kt b/app/src/main/java/com/tangem/tap/features/intentHandler/AffectsNavigation.kt new file mode 100644 index 0000000000..e6d38c381c --- /dev/null +++ b/app/src/main/java/com/tangem/tap/features/intentHandler/AffectsNavigation.kt @@ -0,0 +1,3 @@ +package com.tangem.tap.features.intentHandler + +interface AffectsNavigation \ No newline at end of file diff --git a/app/src/main/java/com/tangem/tap/features/intentHandler/IntentProcessor.kt b/app/src/main/java/com/tangem/tap/features/intentHandler/IntentProcessor.kt index 8ca7a84a1b..6883c38214 100644 --- a/app/src/main/java/com/tangem/tap/features/intentHandler/IntentProcessor.kt +++ b/app/src/main/java/com/tangem/tap/features/intentHandler/IntentProcessor.kt @@ -19,9 +19,9 @@ class IntentProcessor { intentHandlers.clear() } - fun handleIntent(intent: Intent?, isFromForeground: Boolean) { - intentHandlers.forEach { - it.handleIntent(intent, isFromForeground) - } + fun handleIntent(intent: Intent?, isFromForeground: Boolean, skipNavigationHandlers: Boolean = false) { + intentHandlers + .filterNot { handler -> skipNavigationHandlers && handler is AffectsNavigation } + .forEach { handler -> handler.handleIntent(intent, isFromForeground) } } } \ No newline at end of file diff --git a/app/src/main/java/com/tangem/tap/features/intentHandler/handlers/BackgroundScanIntentHandler.kt b/app/src/main/java/com/tangem/tap/features/intentHandler/handlers/BackgroundScanIntentHandler.kt index 14c831cc90..90ef042a6b 100644 --- a/app/src/main/java/com/tangem/tap/features/intentHandler/handlers/BackgroundScanIntentHandler.kt +++ b/app/src/main/java/com/tangem/tap/features/intentHandler/handlers/BackgroundScanIntentHandler.kt @@ -7,6 +7,7 @@ import android.os.Build import com.tangem.tap.common.extensions.dispatchOnMain import com.tangem.tap.features.home.redux.HomeAction import com.tangem.tap.features.intentHandler.IntentHandler +import com.tangem.tap.features.intentHandler.AffectsNavigation import com.tangem.tap.features.welcome.redux.WelcomeAction import com.tangem.tap.store import kotlinx.coroutines.CoroutineScope @@ -17,7 +18,7 @@ import kotlinx.coroutines.CoroutineScope class BackgroundScanIntentHandler( private val hasSavedUserWalletsProvider: () -> Boolean, private val scope: CoroutineScope, -) : IntentHandler { +) : IntentHandler, AffectsNavigation { private val nfcActions = arrayOf( NfcAdapter.ACTION_NDEF_DISCOVERED, diff --git a/app/src/main/java/com/tangem/tap/features/intentHandler/handlers/WalletConnectLinkIntentHandler.kt b/app/src/main/java/com/tangem/tap/features/intentHandler/handlers/WalletConnectLinkIntentHandler.kt index 273ca6d3b2..6f138c18e5 100644 --- a/app/src/main/java/com/tangem/tap/features/intentHandler/handlers/WalletConnectLinkIntentHandler.kt +++ b/app/src/main/java/com/tangem/tap/features/intentHandler/handlers/WalletConnectLinkIntentHandler.kt @@ -5,6 +5,7 @@ import com.tangem.tap.common.extensions.dispatchOnMain import com.tangem.tap.common.extensions.removePrefixOrNull import com.tangem.tap.features.details.redux.walletconnect.WalletConnectAction import com.tangem.tap.features.intentHandler.IntentHandler +import com.tangem.tap.features.intentHandler.AffectsNavigation import com.tangem.tap.store import timber.log.Timber import java.net.URLDecoder @@ -12,7 +13,7 @@ import java.net.URLDecoder /** [REDACTED_AUTHOR] */ -class WalletConnectLinkIntentHandler : IntentHandler { +class WalletConnectLinkIntentHandler : IntentHandler, AffectsNavigation { override fun handleIntent(intent: Intent?, isFromForeground: Boolean): Boolean { val intentData = intent?.data ?: return false