Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AND-9064 Added events sending after app start from push #4006

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions app/src/main/java/com/tangem/tap/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ class MainActivity : AppCompatActivity(), SnackbarHandler, ActivityResultCallbac
super.onNewIntent(intent)

lifecycleScope.launch {
intentProcessor.handleIntent(intent, true)
intentProcessor.handleIntent(intent = intent, isFromForeground = true)
}

if (intent != null) {
Expand Down Expand Up @@ -651,6 +651,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()
Expand All @@ -663,7 +668,11 @@ class MainActivity : AppCompatActivity(), SnackbarHandler, ActivityResultCallbac
}

store.dispatchNavigationAction { replaceAll(route) }
intentProcessor.handleIntent(intentWhichStartedActivity, false)
intentProcessor.handleIntent(
intent = intentWhichStartedActivity,
isFromForeground = false,
skipNavigationHandlers = false,
)
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.tangem.tap.features.intentHandler

interface AffectsNavigation
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ 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

/**
* @author Anton Zhilenkov on 04.06.2023.
*/
class WalletConnectLinkIntentHandler : IntentHandler {
class WalletConnectLinkIntentHandler : IntentHandler, AffectsNavigation {

override fun handleIntent(intent: Intent?, isFromForeground: Boolean): Boolean {
val intentData = intent?.data ?: return false
Expand Down
Loading