Updated on 2026-08-14

This commit is contained in:
Tangem 2025-01-16 11:53:02 +02:00
parent 0b367000c8
commit 5faed3ccac
5 changed files with 22 additions and 8 deletions

View file

@ -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,
)
}
}

View file

@ -0,0 +1,3 @@
package com.tangem.tap.features.intentHandler
interface AffectsNavigation

View file

@ -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) }
}
}

View file

@ -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,

View file

@ -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