Updated on 2026-08-14

This commit is contained in:
Tangem 2025-09-17 15:16:22 +05:00
parent 64c7c64b3a
commit 713cad5fd7
26 changed files with 100 additions and 359 deletions

View file

@ -7,5 +7,5 @@ import android.content.Intent
*/
interface IntentHandler {
fun handleIntent(intent: Intent?, isFromForeground: Boolean): Boolean
fun handleIntent(intent: Intent?): Boolean
}

View file

@ -1,27 +0,0 @@
package com.tangem.tap.features.intentHandler
import android.content.Intent
import java.util.concurrent.CopyOnWriteArrayList
/**
[REDACTED_AUTHOR]
*/
// TODO: fixme: close it with the combined interfaces IntentHandler and IntentHandlerHolder
class IntentProcessor {
private val intentHandlers = CopyOnWriteArrayList<IntentHandler>()
fun addHandler(handler: IntentHandler) {
intentHandlers.add(handler)
}
fun removeAll() {
intentHandlers.clear()
}
fun handleIntent(intent: Intent?, isFromForeground: Boolean, skipNavigationHandlers: Boolean = false) {
intentHandlers
.filterNot { handler -> skipNavigationHandlers && handler is AffectsNavigation }
.forEach { handler -> handler.handleIntent(intent, isFromForeground) }
}
}

View file

@ -1,24 +0,0 @@
package com.tangem.tap.features.intentHandler.handlers
import android.content.Intent
import com.tangem.core.analytics.api.AnalyticsEventHandler
import com.tangem.tap.common.analytics.events.Push
import com.tangem.tap.features.intentHandler.IntentHandler
internal class OnPushClickedIntentHandler(val analyticsEventHandler: AnalyticsEventHandler) : IntentHandler {
override fun handleIntent(intent: Intent?, isFromForeground: Boolean): Boolean {
val fromPush = intent?.extras?.containsKey(OPENED_FROM_GCM_PUSH) ?: false
return if (fromPush) {
analyticsEventHandler.send(Push.PushNotificationOpened)
true
} else {
false
}
}
companion object {
const val OPENED_FROM_GCM_PUSH = "google.sent_time" // every bundle from FCM contains this key
}
}

View file

@ -28,7 +28,6 @@ import com.tangem.domain.models.wallet.UserWallet
import com.tangem.domain.notifications.GetApplicationIdUseCase
import com.tangem.domain.notifications.SendPushTokenUseCase
import com.tangem.domain.notifications.models.ApplicationId
import com.tangem.domain.onboarding.repository.OnboardingRepository
import com.tangem.domain.onramp.FetchHotCryptoUseCase
import com.tangem.domain.promo.GetStoryContentUseCase
import com.tangem.domain.promo.models.StoryContentIds
@ -43,12 +42,10 @@ import com.tangem.domain.wallets.usecase.GetSelectedWalletUseCase
import com.tangem.domain.wallets.usecase.UpdateRemoteWalletsInfoUseCase
import com.tangem.feature.swap.analytics.StoriesEvents
import com.tangem.tap.common.extensions.setContext
import com.tangem.tap.common.redux.global.GlobalAction
import com.tangem.tap.features.onboarding.products.wallet.redux.BackupDialog
import com.tangem.tap.network.exchangeServices.ExchangeService
import com.tangem.tap.network.exchangeServices.moonpay.MoonPayService
import com.tangem.tap.proxy.AppStateHolder
import com.tangem.tap.store
import com.tangem.tap.routing.configurator.AppRouterConfig
import com.tangem.utils.coroutines.CoroutineDispatcherProvider
import com.tangem.wallet.BuildConfig
import dagger.hilt.android.lifecycle.HiltViewModel
@ -78,7 +75,6 @@ internal class MainViewModel @Inject constructor(
private val getStoryContentUseCase: GetStoryContentUseCase,
private val imagePreloader: ImagePreloader,
private val fetchHotCryptoUseCase: FetchHotCryptoUseCase,
private val onboardingRepository: OnboardingRepository,
private val getApplicationIdUseCase: GetApplicationIdUseCase,
private val subscribeOnWalletsUseCase: GetSavedWalletsCountUseCase,
private val associateWalletsWithApplicationIdUseCase: AssociateWalletsWithApplicationIdUseCase,
@ -89,6 +85,7 @@ internal class MainViewModel @Inject constructor(
private val appStateHolder: AppStateHolder,
private val environmentConfigStorage: EnvironmentConfigStorage,
private val getSelectedWalletUseCase: GetSelectedWalletUseCase,
private val appRouterConfig: AppRouterConfig,
getBalanceHidingSettingsUseCase: GetBalanceHidingSettingsUseCase,
) : ViewModel() {
@ -139,13 +136,6 @@ internal class MainViewModel @Inject constructor(
multiQuoteUpdater.unsubscribe()
}
fun checkForUnfinishedBackup() {
viewModelScope.launch(dispatchers.main) {
val onboardingScanResponse = onboardingRepository.getUnfinishedFinalizeOnboarding() ?: return@launch
store.dispatch(GlobalAction.ShowDialog(BackupDialog.UnfinishedBackupFound(onboardingScanResponse)))
}
}
/** Loading the resources needed to run the application */
private fun loadApplicationResources() {
viewModelScope.launch {
@ -159,6 +149,9 @@ internal class MainViewModel @Inject constructor(
prepareSelectedWalletFeedback()
// await while initial route stack is initialized
appRouterConfig.isInitialized.first { it }
isSplashScreenShown = false
}
}

View file

@ -49,7 +49,7 @@ private fun handleBackupAction(appState: () -> AppState?, action: BackupAction)
is BackupAction.ResumeFoundUnfinishedBackup -> {
if (action.unfinishedBackupScanResponse != null) {
store.dispatchNavigationAction {
push(
replaceAll(
AppRoute.Onboarding(
scanResponse = action.unfinishedBackupScanResponse,
mode = AppRoute.Onboarding.Mode.ContinueFinalize,

View file

@ -1,7 +1,6 @@
package com.tangem.tap.features.welcome.component
import com.tangem.common.routing.entity.InitScreenLaunchMode
import com.tangem.common.routing.entity.SerializableIntent
import com.tangem.core.decompose.factory.ComponentFactory
import com.tangem.core.ui.decompose.ComposableContentComponent
@ -9,7 +8,6 @@ interface WelcomeComponent : ComposableContentComponent {
data class Params(
val launchMode: InitScreenLaunchMode,
val intent: SerializableIntent?,
)
interface Factory : ComponentFactory<Params, WelcomeComponent>

View file

@ -47,7 +47,7 @@ internal class WelcomeModel @Inject constructor(
val welcomeAction = when (params.launchMode) {
is InitScreenLaunchMode.WithCardScan -> WelcomeAction.ProceedWithCard
is InitScreenLaunchMode.Standard -> WelcomeAction.ProceedWithBiometrics(params.intent?.toIntent())
is InitScreenLaunchMode.Standard -> WelcomeAction.ProceedWithBiometrics
}
store.dispatch(welcomeAction)
@ -55,7 +55,7 @@ internal class WelcomeModel @Inject constructor(
private fun unlockWallets() {
Analytics.send(SignIn.ButtonBiometricSignIn())
store.dispatch(WelcomeAction.ProceedWithBiometrics())
store.dispatch(WelcomeAction.ProceedWithBiometrics)
}
private fun scanCard() {

View file

@ -1,12 +1,11 @@
package com.tangem.tap.features.welcome.redux
import android.content.Intent
import com.tangem.common.core.TangemError
import org.rekotlin.Action
internal sealed interface WelcomeAction : Action {
data class ProceedWithBiometrics(val afterUnlockIntent: Intent? = null) : WelcomeAction {
data object ProceedWithBiometrics : WelcomeAction {
object Success : WelcomeAction
data class Error(val error: TangemError) : WelcomeAction
}
@ -17,8 +16,6 @@ internal sealed interface WelcomeAction : Action {
data class ChangeProgress(val showProgress: Boolean) : WelcomeAction
}
data class ProceedWithIntent(val intent: Intent) : WelcomeAction
object CloseError : WelcomeAction
object ClearUserWallets : WelcomeAction

View file

@ -1,6 +1,5 @@
package com.tangem.tap.features.welcome.redux
import android.content.Intent
import com.tangem.common.core.TangemSdkError
import com.tangem.common.doOnFailure
import com.tangem.common.doOnResult
@ -41,7 +40,6 @@ internal class WelcomeMiddleware {
private fun handleAction(action: WelcomeAction) {
mainScope.launch {
when (action) {
is WelcomeAction.ProceedWithIntent -> proceedWithIntent(action.intent)
is WelcomeAction.ProceedWithBiometrics -> proceedWithBiometrics()
is WelcomeAction.ProceedWithCard -> proceedWithCard()
is WelcomeAction.ClearUserWallets -> disableUserWalletsSaving()
@ -50,26 +48,7 @@ internal class WelcomeMiddleware {
}
}
private suspend fun proceedWithIntent(initialIntent: Intent) {
Timber.d(
"""
Proceeding with intent
|- Intent: $initialIntent
""".trimIndent(),
)
val hasUncompletedBackup = backupService.hasIncompletedBackup
if (!hasUncompletedBackup) {
store.dispatchWithMain(WelcomeAction.ProceedWithBiometrics(initialIntent))
} else {
store.dispatchWithMain(WelcomeAction.ProceedWithCard)
}
}
private suspend fun proceedWithBiometrics() {
Timber.d("Proceeding with biometry")
val userWalletsListManager = store.inject(DaggerGraphState::generalUserWalletsListManager)
userWalletsListManager.unlockIfLockable(type = UnlockType.ANY)
.doOnFailure { error ->
@ -89,8 +68,6 @@ internal class WelcomeMiddleware {
}
private suspend fun proceedWithCard() {
Timber.d("Proceeding with card")
scanCardInternal { scanResponse ->
val userWalletBuilder = store.inject(DaggerGraphState::coldUserWalletBuilderFactory).create(scanResponse)

View file

@ -14,7 +14,6 @@ internal object WelcomeReducer {
private fun internalReduce(action: WelcomeAction, state: WelcomeState): WelcomeState {
return when (action) {
is WelcomeAction.ProceedWithIntent -> state.copy(intent = action.intent)
is WelcomeAction.ProceedWithBiometrics -> state.copy(isUnlockWithBiometricsInProgress = true)
is WelcomeAction.ProceedWithCard -> state.copy(isUnlockWithCardInProgress = true)
is WelcomeAction.ProceedWithBiometrics.Error -> state.copy(

View file

@ -1,12 +1,10 @@
package com.tangem.tap.features.welcome.redux
import android.content.Intent
import com.tangem.common.core.TangemError
import org.rekotlin.StateType
data class WelcomeState(
val isUnlockWithBiometricsInProgress: Boolean = false,
val isUnlockWithCardInProgress: Boolean = false,
val intent: Intent? = null,
val error: TangemError? = null,
) : StateType