diff --git a/app/src/main/java/com/tangem/tap/MainActivity.kt b/app/src/main/java/com/tangem/tap/MainActivity.kt index f073431daa..d0b2bf34d6 100644 --- a/app/src/main/java/com/tangem/tap/MainActivity.kt +++ b/app/src/main/java/com/tangem/tap/MainActivity.kt @@ -52,7 +52,6 @@ import com.tangem.domain.tokens.GetPolkadotCheckHasImmortalUseCase import com.tangem.domain.tokens.GetPolkadotCheckHasResetUseCase import com.tangem.domain.wallets.legacy.UserWalletsListManager import com.tangem.feature.wallet.presentation.wallet.analytics.WalletScreenAnalyticsEvent -import com.tangem.features.pushnotifications.api.utils.PUSH_PERMISSION import com.tangem.features.walletconnect.components.WalletConnectFeatureToggles import com.tangem.google.GoogleServicesHelper import com.tangem.operations.backup.BackupService @@ -464,12 +463,11 @@ class MainActivity : AppCompatActivity(), ActivityResultCallbackHolder { } else { lifecycleScope.launch { val shouldShowTos = !cardRepository.isTangemTOSAccepted() - val shouldShowInitialPush = shouldInitiallyAskPermissionUseCase(PUSH_PERMISSION).getOrElse { false } - val route = when { - shouldShowTos -> AppRoute.Disclaimer(isTosAccepted = false) - shouldShowInitialPush -> AppRoute.PushNotification - else -> AppRoute.Home + val route = if (shouldShowTos) { + AppRoute.Disclaimer(isTosAccepted = false) + } else { + AppRoute.Home } store.dispatchNavigationAction { replaceAll(route) } diff --git a/domain/notifications/src/main/java/com/tangem/domain/notifications/ShouldShowHuaweiWarningUseCase.kt b/domain/notifications/src/main/java/com/tangem/domain/notifications/GetIsHuaweiDeviceWithoutGoogleServicesUseCase.kt similarity index 86% rename from domain/notifications/src/main/java/com/tangem/domain/notifications/ShouldShowHuaweiWarningUseCase.kt rename to domain/notifications/src/main/java/com/tangem/domain/notifications/GetIsHuaweiDeviceWithoutGoogleServicesUseCase.kt index 2e7c8ffbde..50dee4a7a0 100644 --- a/domain/notifications/src/main/java/com/tangem/domain/notifications/ShouldShowHuaweiWarningUseCase.kt +++ b/domain/notifications/src/main/java/com/tangem/domain/notifications/GetIsHuaweiDeviceWithoutGoogleServicesUseCase.kt @@ -4,7 +4,7 @@ import com.tangem.utils.info.AppInfoProvider import com.tangem.utils.notifications.PushNotificationsTokenProvider import javax.inject.Inject -class ShouldShowHuaweiWarningUseCase @Inject constructor( +class GetIsHuaweiDeviceWithoutGoogleServicesUseCase @Inject constructor( private val appInfoProvider: AppInfoProvider, private val pushNotificationsTokenProvider: PushNotificationsTokenProvider, ) { diff --git a/domain/wallets/src/main/java/com/tangem/domain/wallets/usecase/GetIsBiometricsEnabledUseCase.kt b/domain/wallets/src/main/java/com/tangem/domain/wallets/usecase/GetIsBiometricsEnabledUseCase.kt new file mode 100644 index 0000000000..4b04c0e690 --- /dev/null +++ b/domain/wallets/src/main/java/com/tangem/domain/wallets/usecase/GetIsBiometricsEnabledUseCase.kt @@ -0,0 +1,11 @@ +package com.tangem.domain.wallets.usecase + +import com.tangem.domain.wallets.legacy.UserWalletsListManager +import javax.inject.Inject + +class GetIsBiometricsEnabledUseCase @Inject constructor( + private val userWalletsListManager: UserWalletsListManager, +) { + + operator fun invoke(): Boolean = userWalletsListManager as? UserWalletsListManager.Lockable != null +} \ No newline at end of file diff --git a/features/disclaimer/impl/src/main/java/com/tangem/features/disclaimer/impl/model/DisclaimerModel.kt b/features/disclaimer/impl/src/main/java/com/tangem/features/disclaimer/impl/model/DisclaimerModel.kt index 39b9bde62b..2c45bfb510 100644 --- a/features/disclaimer/impl/src/main/java/com/tangem/features/disclaimer/impl/model/DisclaimerModel.kt +++ b/features/disclaimer/impl/src/main/java/com/tangem/features/disclaimer/impl/model/DisclaimerModel.kt @@ -7,6 +7,7 @@ import com.tangem.core.decompose.model.ParamsContainer import com.tangem.core.decompose.navigation.Router import com.tangem.core.navigation.finisher.AppFinisher import com.tangem.domain.card.repository.CardRepository +import com.tangem.domain.notifications.GetIsHuaweiDeviceWithoutGoogleServicesUseCase import com.tangem.domain.notifications.repository.NotificationsRepository import com.tangem.domain.settings.NeverRequestPermissionUseCase import com.tangem.domain.settings.NeverToInitiallyAskPermissionUseCase @@ -28,6 +29,8 @@ internal class DisclaimerModel @Inject constructor( private val neverRequestPermissionUseCase: NeverRequestPermissionUseCase, private val appFinisher: AppFinisher, private val notificationsRepository: NotificationsRepository, + private val getIsHuaweiDeviceWithoutGoogleServicesUseCase: GetIsHuaweiDeviceWithoutGoogleServicesUseCase, + paramsContainer: ParamsContainer, ) : Model() { @@ -48,7 +51,8 @@ internal class DisclaimerModel @Inject constructor( } else { cardRepository.acceptTangemTOS() val shouldAskPushPermission = notificationsRepository.shouldShowSubscribeOnNotificationsAfterUpdate() - if (shouldAskPushPermission) { + val isHuaweiDevice = getIsHuaweiDeviceWithoutGoogleServicesUseCase() + if (shouldAskPushPermission && !isHuaweiDevice) { router.push(AppRoute.PushNotification) } else { neverToInitiallyAskPermissionUseCase(PUSH_PERMISSION) diff --git a/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/model/WalletSettingsModel.kt b/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/model/WalletSettingsModel.kt index f2ca439c51..8e507b166e 100644 --- a/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/model/WalletSettingsModel.kt +++ b/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/model/WalletSettingsModel.kt @@ -24,7 +24,7 @@ import com.tangem.domain.models.scan.ScanResponse import com.tangem.domain.nft.DisableWalletNFTUseCase import com.tangem.domain.nft.EnableWalletNFTUseCase import com.tangem.domain.nft.GetWalletNFTEnabledUseCase -import com.tangem.domain.notifications.ShouldShowHuaweiWarningUseCase +import com.tangem.domain.notifications.GetIsHuaweiDeviceWithoutGoogleServicesUseCase import com.tangem.domain.notifications.repository.NotificationsRepository import com.tangem.domain.notifications.toggles.NotificationsFeatureToggles import com.tangem.domain.settings.repositories.PermissionRepository @@ -75,7 +75,7 @@ internal class WalletSettingsModel @Inject constructor( private val settingsManager: SettingsManager, private val permissionsRepository: PermissionRepository, private val notificationsRepository: NotificationsRepository, - private val shouldShowHuaweiWarningUseCase: ShouldShowHuaweiWarningUseCase, + private val getIsHuaweiDeviceWithoutGoogleServicesUseCase: GetIsHuaweiDeviceWithoutGoogleServicesUseCase, ) : Model() { val params: WalletSettingsComponent.Params = paramsContainer.require() @@ -99,6 +99,8 @@ internal class WalletSettingsModel @Inject constructor( ) { maybeWallet, nftEnabled, notificationsEnabled -> val wallet = maybeWallet.getOrNull() ?: return@combine val isRenameWalletAvailable = getShouldSaveUserWalletsSyncUseCase() + val isNeedShowNotifications = notificationsToggles.isNotificationsEnabled && + !getIsHuaweiDeviceWithoutGoogleServicesUseCase() state.update { value -> value.copy( items = buildItems( @@ -108,7 +110,7 @@ internal class WalletSettingsModel @Inject constructor( isNFTFeatureEnabled = nftFeatureToggles.isNFTEnabled, isNFTEnabled = nftEnabled, isNotificationsEnabled = notificationsEnabled, - isNotificationsFeatureEnabled = notificationsToggles.isNotificationsEnabled, + isNotificationsFeatureEnabled = isNeedShowNotifications, isNotificationsPermissionGranted = isNotificationsPermissionGranted(), ), ) @@ -232,7 +234,7 @@ internal class WalletSettingsModel @Inject constructor( private fun onCheckedNotificationsChange(isChecked: Boolean) { modelScope.launch { if (isChecked) { - if (shouldShowHuaweiWarningUseCase()) { + if (getIsHuaweiDeviceWithoutGoogleServicesUseCase()) { showHuaweiDialog() return@launch } diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/child/wallet/model/WalletModel.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/child/wallet/model/WalletModel.kt index ed54e43c1b..f8702271da 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/child/wallet/model/WalletModel.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/child/wallet/model/WalletModel.kt @@ -17,6 +17,7 @@ import com.tangem.core.deeplink.global.ReferralDeepLink import com.tangem.domain.balancehiding.GetBalanceHidingSettingsUseCase import com.tangem.domain.common.util.cardTypesResolver import com.tangem.domain.nft.ObserveAndClearNFTCacheIfNeedUseCase +import com.tangem.domain.notifications.GetIsHuaweiDeviceWithoutGoogleServicesUseCase import com.tangem.domain.notifications.repository.NotificationsRepository import com.tangem.domain.notifications.toggles.NotificationsFeatureToggles import com.tangem.domain.settings.* @@ -25,10 +26,7 @@ import com.tangem.domain.tokens.RefreshMultiCurrencyWalletQuotesUseCase import com.tangem.domain.wallets.models.UserWallet import com.tangem.domain.wallets.models.UserWalletId import com.tangem.domain.wallets.models.isMultiCurrency -import com.tangem.domain.wallets.usecase.GetSelectedWalletUseCase -import com.tangem.domain.wallets.usecase.GetWalletsUseCase -import com.tangem.domain.wallets.usecase.GetWalletsForAutomaticallyPushEnablingUseCase -import com.tangem.domain.wallets.usecase.SetNotificationsEnabledUseCase +import com.tangem.domain.wallets.usecase.* import com.tangem.feature.wallet.child.wallet.model.intents.WalletClickIntents import com.tangem.feature.wallet.presentation.deeplink.WalletDeepLinksHandler import com.tangem.feature.wallet.presentation.router.InnerWalletRouter @@ -50,7 +48,6 @@ import com.tangem.feature.wallet.presentation.wallet.utils.ScreenLifecycleProvid import com.tangem.features.biometry.AskBiometryComponent import com.tangem.features.pushnotifications.api.PushNotificationsModelCallbacks import com.tangem.features.pushnotifications.api.utils.PUSH_PERMISSION -import com.tangem.features.pushnotifications.api.utils.getPushPermissionOrNull import com.tangem.utils.Provider import com.tangem.utils.coroutines.* import kotlinx.coroutines.* @@ -94,6 +91,8 @@ internal class WalletModel @Inject constructor( private val getWalletsListForEnablingUseCase: GetWalletsForAutomaticallyPushEnablingUseCase, private val setNotificationsEnabledUseCase: SetNotificationsEnabledUseCase, private val notificationsFeatureToggles: NotificationsFeatureToggles, + private val getIsBiometryIsEnabledUseCase: GetIsBiometricsEnabledUseCase, + private val getIsHuaweiDeviceWithoutGoogleServicesUseCase: GetIsHuaweiDeviceWithoutGoogleServicesUseCase, val screenLifecycleProvider: ScreenLifecycleProvider, val innerWalletRouter: InnerWalletRouter, ) : Model() { @@ -208,12 +207,11 @@ internal class WalletModel @Inject constructor( modelScope.launch { val shouldAskPermission = shouldAskPermissionUseCase(PUSH_PERMISSION) val afterUpdate = notificationsRepository.shouldShowSubscribeOnNotificationsAfterUpdate() - val shouldShowBottomSheet = if (notificationsFeatureToggles.isNotificationsEnabled) { - (shouldAskPermission || afterUpdate) && !shouldShowSaveWalletScreenUseCase() - } else { - val isPushPermissionAvailable = getPushPermissionOrNull() != null - shouldAskPermission && isPushPermissionAvailable - } + val isBiometryIsEnabled = getIsBiometryIsEnabledUseCase() + val isHuaweiDevice = getIsHuaweiDeviceWithoutGoogleServicesUseCase() + val shouldShowBottomSheet = shouldAskPermission || afterUpdate + if (!isBiometryIsEnabled) return@launch + if (isHuaweiDevice) return@launch if (!shouldShowBottomSheet) return@launch delay(timeMillis = 1_800)