Updated on 2026-08-14
This commit is contained in:
commit
f0af317c92
24 changed files with 225 additions and 134 deletions
|
|
@ -467,4 +467,20 @@ internal object WalletsDomainModule {
|
|||
yieldSupplyRepository = yieldSupplyRepository,
|
||||
)
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun provideGetWalletsForAutomaticallyPushEnablingUseCase(
|
||||
userWalletsListManager: UserWalletsListManager,
|
||||
userWalletsListRepository: UserWalletsListRepository,
|
||||
hotWalletFeatureToggles: HotWalletFeatureToggles,
|
||||
dispatcherProvider: CoroutineDispatcherProvider,
|
||||
): GetWalletsForAutomaticallyPushEnablingUseCase {
|
||||
return GetWalletsForAutomaticallyPushEnablingUseCase(
|
||||
userWalletsListManager = userWalletsListManager,
|
||||
userWalletsListRepository = userWalletsListRepository,
|
||||
shouldUseNewListRepository = hotWalletFeatureToggles.isHotWalletEnabled,
|
||||
dispatchers = dispatcherProvider,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -3,6 +3,7 @@ package com.tangem.common.ui.alerts
|
|||
import com.tangem.common.ui.alerts.models.AlertDemoModeUM
|
||||
import com.tangem.common.ui.alerts.models.AlertTransactionErrorUM
|
||||
import com.tangem.common.ui.alerts.models.AlertUM
|
||||
import com.tangem.core.ui.R
|
||||
import com.tangem.core.ui.extensions.resourceReference
|
||||
import com.tangem.core.ui.extensions.wrappedList
|
||||
import com.tangem.domain.transaction.error.SendTransactionError
|
||||
|
|
@ -43,6 +44,12 @@ class TransactionErrorAlertConverter(
|
|||
cause = value.ex?.localizedMessage,
|
||||
onConfirmClick = { onFailedTxEmailClick(value.ex?.localizedMessage.orEmpty()) },
|
||||
)
|
||||
is SendTransactionError.CreateAccountUnderfunded -> AlertTransactionErrorUM(
|
||||
code = "",
|
||||
cause = null,
|
||||
causeTextReference = resourceReference(R.string.no_account_polkadot, wrappedList(value.amount)),
|
||||
onConfirmClick = popBackStack,
|
||||
)
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ fun SendingText(footerText: TextReference, modifier: Modifier = Modifier) {
|
|||
color = TangemTheme.colors.text.tertiary,
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(16.dp)
|
||||
.padding(start = 16.dp, end = 16.dp, bottom = 16.dp)
|
||||
.testTag(SendConfirmScreenTestTags.SENDING_TEXT),
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,10 +44,12 @@ object NotificationsFactory {
|
|||
}
|
||||
}
|
||||
|
||||
@Suppress("LongParameterList")
|
||||
fun MutableList<NotificationUM>.addFeeUnreachableNotification(
|
||||
tokenStatus: CryptoCurrencyStatus,
|
||||
coinStatus: CryptoCurrencyStatus,
|
||||
feeError: GetFeeError?,
|
||||
dustValue: BigDecimal?,
|
||||
onReload: () -> Unit,
|
||||
onClick: (currency: CryptoCurrency) -> Unit,
|
||||
) {
|
||||
|
|
@ -70,7 +72,16 @@ object NotificationsFactory {
|
|||
)
|
||||
is GetFeeError.BlockchainErrors.SuiOneCoinRequired ->
|
||||
add(NotificationUM.Sui.NotEnoughCoinForTokenTransaction)
|
||||
is GetFeeError.DataError,
|
||||
is GetFeeError.DataError -> when (feeError.cause) {
|
||||
BlockchainSdkError.TransactionDustChangeError -> add(
|
||||
NotificationUM.Error.MinimumAmountError(
|
||||
amount = dustValue.format { crypto(tokenStatus.currency) },
|
||||
),
|
||||
)
|
||||
else -> add(
|
||||
NotificationUM.Warning.NetworkFeeUnreachable(onReload),
|
||||
)
|
||||
}
|
||||
is GetFeeError.UnknownError,
|
||||
-> add(
|
||||
NotificationUM.Warning.NetworkFeeUnreachable(onReload),
|
||||
|
|
@ -358,6 +369,11 @@ object NotificationsFactory {
|
|||
is BlockchainSdkError.Solana.DestinationRentExemption -> addRentExemptionDestinationNotification(
|
||||
rentExemptionAmount = validationError.rentAmount,
|
||||
)
|
||||
is BlockchainSdkError.TransactionDustChangeError -> add(
|
||||
NotificationUM.Error.MinimumAmountError(
|
||||
amount = dustValue.format { crypto(cryptoCurrency) },
|
||||
),
|
||||
)
|
||||
null,
|
||||
-> minAdaValue?.let {
|
||||
add(
|
||||
|
|
|
|||
|
|
@ -164,6 +164,9 @@ object PreferencesKeys {
|
|||
// region Permission
|
||||
fun getShouldShowPermission(permission: String) = booleanPreferencesKey("shouldShowPushPermission_$permission")
|
||||
|
||||
fun getShouldShowAskNotificationPermissionViaBs() =
|
||||
booleanPreferencesKey("ShouldShowAskNotificationPermissionViaBs")
|
||||
|
||||
fun getShouldShowInitialPermissionScreen(permission: String) =
|
||||
booleanPreferencesKey("shouldShowInitialPushPermissionScreen_$permission")
|
||||
// endregion
|
||||
|
|
|
|||
|
|
@ -504,7 +504,7 @@
|
|||
<string name="generic_error_code">エラーが発生しました。コード: %s 。</string>
|
||||
<string name="generic_requires_memo_error">メモが必要</string>
|
||||
<string name="give_permission_current_transaction">取引</string>
|
||||
<string name="give_permission_policy_type_footer">選択したトークンの承認制限を指定します</string>
|
||||
<string name="give_permission_policy_type_footer">承認すると、このスマートコントラクトが今後の取引でトークンを利用できるようになります。</string>
|
||||
<string name="give_permission_rows_amount">金額%s</string>
|
||||
<string name="give_permission_staking_footer">承認機能は、別のアドレスに特定の量のトークンを使用する許可を与えるために必要です。設計上スマートコントラクトは、承認しない限りトークンにアクセスできません。トークンを「ロック解除」すると、StakeKitスマート コントラクトがトークンを使用する権限が与えられます。ネットワークのマイナーは、このアクションをブロックチェーンに記録するためにガス料金(あなたが支払う)を受け取ります。承認後、トークンをステーキングできます。</string>
|
||||
<string name="give_permission_staking_subtitle">続行するには、Polygonスマートコントラクトが%sを使用することを許可する必要があります</string>
|
||||
|
|
@ -865,6 +865,7 @@
|
|||
<string name="onramp_currency_other">その他の通貨</string>
|
||||
<string name="onramp_currency_popular">人気の法定通貨</string>
|
||||
<string name="onramp_currency_search">通貨で検索</string>
|
||||
<string name="onramp_fetching_best_rates">最良のレートを取得しています...</string>
|
||||
<string name="onramp_instant_status">即時</string>
|
||||
<string name="onramp_legal">オンランプ機能を使用することにより、プロバイダの%1$sおよび%2$sに同意するものとします</string>
|
||||
<string name="onramp_legal_text">サービスは外部プロバイダーによって提供されます。 \nTangemは責任を負いません。</string>
|
||||
|
|
@ -894,6 +895,7 @@
|
|||
<item quantity="other">最大%d日</item>
|
||||
</plurals>
|
||||
<string name="onramp_timing_minutes">%s分</string>
|
||||
<string name="onramp_title_available_from___">下記より利用可能</string>
|
||||
<string name="onramp_title_you_get">以下が手に入ります。</string>
|
||||
<string name="onramp_tos_external_providers">サービスは外部プロバイダーによって提供されます。 \nTangemは責任を負いません。</string>
|
||||
<string name="onramp_transaction_status_footer_text">この画面を閉じて、トークンの詳細画面で取引状況を確認できます。</string>
|
||||
|
|
@ -1165,7 +1167,7 @@
|
|||
<string name="staking_notification_new_validator_funds_transfer">新しいバリデーターを使用して%1$sネットワークにステーキングすると、以前にステーキングされた資金がすべてこのバリデーターに自動的に転送されます。</string>
|
||||
<string name="staking_notification_restake_rewards_text">獲得した報酬をステーキングに再投資し、潜在的な収益を増やします。</string>
|
||||
<string name="staking_notification_restake_text">再ステーキングを使うと、ステーキングを解除することなく、あるバリデータから別のバリデータに資金を移動できます。</string>
|
||||
<string name="staking_notification_stake_entire_balance_text">残高のすべてをステーキングしようとしています。ステーキング解除や報酬請求にかかるネットワーク手数料をカバーするために、少額を残しておくことをお勧めします。</string>
|
||||
<string name="staking_notification_stake_entire_balance_text">ウォレットの残高をすべてステーキングすると、ステーキング解除時にネットワーク手数料の支払いが必要になります。そのため、少額をウォレットに残しておくことをおすすめします。</string>
|
||||
<string name="staking_notification_ton_account_initialization_message">ステーキングを始めるには、TONアカウントを1 TONの自己取引で有効化する必要があります。資金はウォレット内にそのまま残り、この手順でステーキング用にアカウントを有効化できます。</string>
|
||||
<string name="staking_notification_ton_account_initialization_title">アカウントの有効化</string>
|
||||
<string name="staking_notification_ton_activate_account">TONのステーキングを開始するには、まず自分のアドレスに少額の取引を送信します。これによりウォレットが有効になります。</string>
|
||||
|
|
@ -1275,6 +1277,8 @@
|
|||
<string name="swapping_token_not_available">利用不可</string>
|
||||
<string name="tangempay_card_details_error_text">データの読み込みに失敗しました。しばらくしてからもう一度お試しください。</string>
|
||||
<string name="tangempay_card_details_hide_text">非表示</string>
|
||||
<string name="tangempay_card_details_receive_error_description">技術的な問題が検出されました。しばらくしてからもう一度お試しいただくか、サポートにお問い合わせください。</string>
|
||||
<string name="tangempay_card_details_receive_error_title">現在、受け取りは利用できません</string>
|
||||
<string name="tangempay_card_details_reveal_text">表示</string>
|
||||
<string name="tangempay_card_details_title">カードの詳細</string>
|
||||
<string name="tangempay_issue_card_notification_title">アカウントを作成してカードを発行</string>
|
||||
|
|
@ -1700,7 +1704,7 @@
|
|||
<string name="xtz_withdrawal_message_reduce">%s XTZを減らす</string>
|
||||
<string name="xtz_withdrawal_message_warning">次回ウォレットにチャージするときに手数料の増加を避けるには、金額を%s XTZ減らしてください。</string>
|
||||
<string name="yield_module_alert_description">資産残高に関するテキスト [プレースホルダー]</string>
|
||||
<string name="yield_module_alert_title">%sはAaveに預け入れられています</string>
|
||||
<string name="yield_module_alert_title">%sはAaveに預けられています</string>
|
||||
<string name="yield_module_approve_needed_notification_cta">承認する</string>
|
||||
<string name="yield_module_approve_needed_notification_description">前回の承認に問題があったため、新しい承認が必要です。手続き方法を選択してください。</string>
|
||||
<string name="yield_module_approve_needed_notification_title">承認が必要</string>
|
||||
|
|
@ -1711,7 +1715,7 @@
|
|||
<string name="yield_module_balance_info_sheet_title">あなたの%sはAaveに預けられています</string>
|
||||
<string name="yield_module_chart_loading_error">チャートを読み込めません・・</string>
|
||||
<string name="yield_module_deposit_error_notification_title">受け取った金額%1$s %2$sはAaveに入金されませんでした。</string>
|
||||
<string name="yield_module_earn_badge">%1$s%% を獲得</string>
|
||||
<string name="yield_module_earn_badge">年利%1$s%%</string>
|
||||
<string name="yield_module_earn_sheet_available_title">利用可能</string>
|
||||
<string name="yield_module_earn_sheet_current_apy_title">現在のAPY</string>
|
||||
<string name="yield_module_earn_sheet_my_funds_title">私の資金</string>
|
||||
|
|
@ -1726,7 +1730,7 @@
|
|||
<string name="yield_module_fee_policy_sheet_max_fee_note">ネットワーク手数料が上限手数料を超えた場合、手数料が下がるまで取引は成立しません。この制限は後で変更できます。</string>
|
||||
<string name="yield_module_fee_policy_sheet_max_fee_title">最大手数料</string>
|
||||
<string name="yield_module_fee_policy_sheet_min_amount_note">取引手数料は、預入額の4%未満である必要があります。Tangemは、この条件を満たす十分な残高が貯まった時点で、Aaveへの資金移動を行います。</string>
|
||||
<string name="yield_module_fee_policy_sheet_min_amount_title">最低額</string>
|
||||
<string name="yield_module_fee_policy_sheet_min_amount_title">最低入金額</string>
|
||||
<string name="yield_module_fee_policy_sheet_title">手数料ポリシー</string>
|
||||
<string name="yield_module_fee_policy_tangem_service_fee_title">Tangemはまた、得られた利回りに対して3%のサービス手数料を差し引きます。</string>
|
||||
<string name="yield_module_high_fee_error">ネットワーク手数料が現在高すぎます。設定した上限を下回るまで待機しています。</string>
|
||||
|
|
@ -1738,9 +1742,9 @@
|
|||
<string name="yield_module_promo_screen_auto_balance_subtitle">アカウントへの入金はすべて自動的にAaveに貸し出されます。</string>
|
||||
<string name="yield_module_promo_screen_auto_balance_title">残高は自動的に計算されます</string>
|
||||
<string name="yield_module_promo_screen_cash_out_subtitle">いつでも、即座に資金を送信、交換、売却できます。</string>
|
||||
<string name="yield_module_promo_screen_cash_out_title">すぐに現金化</string>
|
||||
<string name="yield_module_promo_screen_cash_out_title">いつでも資金にアクセス可能</string>
|
||||
<string name="yield_module_promo_screen_how_it_works_button_title">使い方</string>
|
||||
<string name="yield_module_promo_screen_self_custodial_subtitle">Aaveは世界中で何百万人もの人々に信頼されています。総貸付額は104億ドルです。</string>
|
||||
<string name="yield_module_promo_screen_self_custodial_subtitle">Aaveは、総額819億ドル以上の資産を管理する分散型プロトコルです。</string>
|
||||
<string name="yield_module_promo_screen_self_custodial_title">分散型・自己管理型</string>
|
||||
<string name="yield_module_promo_screen_terms_disclaimer">サービスを利用することにより、プロバイダー\n %1$sおよび%2$sに同意したことになります</string>
|
||||
<string name="yield_module_promo_screen_title">年間%s%%の収益</string>
|
||||
|
|
@ -1752,10 +1756,10 @@
|
|||
<string name="yield_module_rate_info_sheet_powered_by">提供</string>
|
||||
<string name="yield_module_rate_info_sheet_title">金利は変動します</string>
|
||||
<string name="yield_module_receive_sheet_description">入金すると、資金は自動的にAaveに送金され、利息が付き始めます。取引手数料として%s相当の少額の手数料が差し引かれます。</string>
|
||||
<string name="yield_module_start_earning">利息の獲得を開始</string>
|
||||
<string name="yield_module_start_earning">資産を供給する</string>
|
||||
<string name="yield_module_start_earning_sheet_description">%sはAaveに供給され、すぐに利用可能になります</string>
|
||||
<string name="yield_module_start_earning_sheet_fee_policy">手数料ポリシーを見る</string>
|
||||
<string name="yield_module_start_earning_sheet_next_deposits">次回の入金は自動的にAaveに供給されます。</string>
|
||||
<string name="yield_module_start_earning_sheet_next_deposits">次回以降の入金は自動的にAaveに供給されます。</string>
|
||||
<string name="yield_module_status_active">アクティブ</string>
|
||||
<string name="yield_module_status_paused">停止中</string>
|
||||
<string name="yield_module_stop_earning">収益を停止する</string>
|
||||
|
|
@ -1765,7 +1769,7 @@
|
|||
<string name="yield_module_token_details_earn_notification_apy">APY</string>
|
||||
<string name="yield_module_token_details_earn_notification_description">あなたの資産を眠らせない — 残高を運用して利息を得ましょう。</string>
|
||||
<string name="yield_module_token_details_earn_notification_earning_on_your_balance_subtitle">利息は自動的に発生します</string>
|
||||
<string name="yield_module_token_details_earn_notification_earning_on_your_balance_title">Aaveレンディング</string>
|
||||
<string name="yield_module_token_details_earn_notification_earning_on_your_balance_title">Aaveの利回り</string>
|
||||
<string name="yield_module_token_details_earn_notification_processing">入金の処理中</string>
|
||||
<string name="yield_module_token_details_earn_notification_title">年間%1$s%%の収益</string>
|
||||
<string name="yield_module_transfer_mode_automatic">自動</string>
|
||||
|
|
|
|||
|
|
@ -275,6 +275,7 @@
|
|||
<string name="scan_card_settings_button">掃描卡片</string>
|
||||
<string name="scan_card_settings_message">掃描卡片以更改其設置。這些更改只會影響您掃描過的卡,不會影響綁定到您錢包的其他卡。</string>
|
||||
<string name="scan_card_settings_title">準備好您的卡!</string>
|
||||
<string name="security_alert_title">安全警示:</string>
|
||||
<string name="send_amount_label">數量</string>
|
||||
<string name="send_error_address_same_as_wallet">地址與錢包地址相同</string>
|
||||
<string name="send_error_dust_amount_format">最小數量是 %s</string>
|
||||
|
|
@ -338,6 +339,7 @@
|
|||
<string name="user_wallet_list_unlock_all_with">用 %s 解鎖全部</string>
|
||||
<string name="wallet_balance_blockchain_unreachable_try_later">區塊鍊無法使用。稍後再試</string>
|
||||
<string name="wallet_balance_missing_derivation">掃描卡片</string>
|
||||
<string name="wallet_been_activated_message">此钱包之前已被激活。\n如果不是您本人激活,请联系客服。\nTangem 绝不会出售附带预生成助记词的钱包。</string>
|
||||
<string name="wallet_connect_alert_sign_message">請求籤署消息。%s</string>
|
||||
<string name="wallet_connect_bnb_sign_message">Dapp %1$s,請求\n簽署 BNB 交易。\n%2$s</string>
|
||||
<string name="wallet_connect_bnb_trade_order_message">%1$s 的交易訂單\n價格: %2$s\n接收金額:%3$s\n支付數量: %4$s</string>
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@
|
|||
<string name="account_details_archive_description">You are archiving this account, but you can always get it back.</string>
|
||||
<string name="account_details_title">Account</string>
|
||||
<string name="account_edit_success_message">Account saved</string>
|
||||
<string name="account_for_rewards">Account for rewards</string>
|
||||
<string name="account_form_account_index">Account #%s — used for address derivation.</string>
|
||||
<string name="account_form_create_button">Add account</string>
|
||||
<string name="account_form_edit_button">Save</string>
|
||||
|
|
@ -512,7 +513,7 @@
|
|||
<string name="generic_error_code">An error occurred. Code: %s.</string>
|
||||
<string name="generic_requires_memo_error">Requires memo</string>
|
||||
<string name="give_permission_current_transaction">Transaction</string>
|
||||
<string name="give_permission_policy_type_footer">Specify the approve limit for the selected token</string>
|
||||
<string name="give_permission_policy_type_footer">By approving, you allow the smart contract to use your tokens in future transactions.</string>
|
||||
<string name="give_permission_rows_amount">Amount %s</string>
|
||||
<string name="give_permission_staking_footer">The Approve function is needed to grant permission to another address to use a specific amount of your tokens. By design, smart contracts can\'t access your tokens unless you approve. By \"unlocking\" your tokens, you authorize the StakeKit smart contract to use them. The network\'s miners receive a gas fee (paid by you) to record this action on the blockchain. You can stake your token after giving approval.</string>
|
||||
<string name="give_permission_staking_subtitle">To continue you need to allow Polygon smart contract to use your %s</string>
|
||||
|
|
@ -883,6 +884,7 @@
|
|||
<string name="onramp_currency_other">Other currencies</string>
|
||||
<string name="onramp_currency_popular">Popular Fiats</string>
|
||||
<string name="onramp_currency_search">Search by currency</string>
|
||||
<string name="onramp_fetching_best_rates">Fetching best rates...</string>
|
||||
<string name="onramp_instant_status">Instant</string>
|
||||
<string name="onramp_legal">By using onramp functionality, you agree with provider’s %1$s and %2$s</string>
|
||||
<string name="onramp_legal_text">Service is provided by an external provider.\nTangem is not responsible.</string>
|
||||
|
|
@ -914,6 +916,7 @@
|
|||
<item quantity="other">up to %d days</item>
|
||||
</plurals>
|
||||
<string name="onramp_timing_minutes">%s min</string>
|
||||
<string name="onramp_title_available_from___">Available from </string>
|
||||
<string name="onramp_title_you_get">You get</string>
|
||||
<string name="onramp_tos_external_providers">Service is provided by an external provider. \nTangem is not responsible.</string>
|
||||
<string name="onramp_transaction_status_footer_text">You can close this screen and check the transaction status on the token details screen.</string>
|
||||
|
|
@ -1188,7 +1191,7 @@
|
|||
<string name="staking_notification_new_validator_funds_transfer">Staking on the %1$s network with a new validator will automatically transfer all previously staked funds to this validator.</string>
|
||||
<string name="staking_notification_restake_rewards_text">Reinvests your earned rewards in your staked amount, increasing potential earnings.</string>
|
||||
<string name="staking_notification_restake_text">Restake lets you move your funds from one validator to another without the need to unstake</string>
|
||||
<string name="staking_notification_stake_entire_balance_text">You’re about to stake your entire balance. We recommend leaving a small amount to cover network fees for unstaking or claiming rewards.</string>
|
||||
<string name="staking_notification_stake_entire_balance_text">If you stake your entire balance, you’ll need to pay a network fee when you unstake. We recommend leaving a small amount in your wallet to cover network fees.</string>
|
||||
<string name="staking_notification_ton_account_initialization_message">To start staking, your TON account must be activated with a self-transaction of 1 TON. The funds stay in your wallet — this step only enables your account for staking.</string>
|
||||
<string name="staking_notification_ton_account_initialization_title">Account activation</string>
|
||||
<string name="staking_notification_ton_activate_account">To start staking in TON, first send a small transaction to your own address — this will activate your wallet.</string>
|
||||
|
|
@ -1775,6 +1778,7 @@
|
|||
<string name="xtz_withdrawal_message_warning">To avoid paying an increased commission the next time you top up your wallet, reduce the amount by %s XTZ</string>
|
||||
<string name="yield_module_alert_description">Text about your money in balance [PLACEHOLDER]</string>
|
||||
<string name="yield_module_alert_title">Your %s is deposited in Aave</string>
|
||||
<string name="yield_module_amount_not_transfered_to_aave_title">The amount received, %1$s %2$s was not deposited to Aave.</string>
|
||||
<string name="yield_module_approve_needed_notification_cta">Give Approve</string>
|
||||
<string name="yield_module_approve_needed_notification_description">Something went wrong with your previous approval, so we need a new one. Choose how you’d like to proceed.</string>
|
||||
<string name="yield_module_approve_needed_notification_title">Approve needed</string>
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ fun BottomFade(modifier: Modifier = Modifier, backgroundColor: Color = TangemThe
|
|||
fun Fade(
|
||||
modifier: Modifier = Modifier,
|
||||
backgroundColor: Color = TangemTheme.colors.background.secondary,
|
||||
height: Dp = 40.dp,
|
||||
height: Dp = 32.dp,
|
||||
) {
|
||||
Box(
|
||||
modifier = modifier
|
||||
|
|
@ -50,7 +50,6 @@ fun Fade(
|
|||
.height(height)
|
||||
.background(
|
||||
brush = Brush.verticalGradient(
|
||||
endY = 100f,
|
||||
colors = listOf(
|
||||
Color.Transparent,
|
||||
backgroundColor,
|
||||
|
|
|
|||
|
|
@ -2,11 +2,8 @@ package com.tangem.data.notifications
|
|||
|
||||
import com.tangem.datasource.local.preferences.AppPreferencesStore
|
||||
import com.tangem.datasource.local.preferences.PreferencesKeys
|
||||
import com.tangem.datasource.local.preferences.utils.get
|
||||
import com.tangem.datasource.local.preferences.utils.getObjectMapSync
|
||||
import com.tangem.datasource.local.preferences.utils.getSyncOrDefault
|
||||
import com.tangem.datasource.local.preferences.utils.getSyncOrNull
|
||||
import com.tangem.datasource.local.preferences.utils.store
|
||||
import com.tangem.datasource.local.preferences.PreferencesKeys.getShouldShowAskNotificationPermissionViaBs
|
||||
import com.tangem.datasource.local.preferences.utils.*
|
||||
import com.tangem.domain.notifications.repository.NotificationsRepository
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import javax.inject.Inject
|
||||
|
|
@ -77,4 +74,12 @@ class DefaultNotificationsRepository @Inject constructor(
|
|||
)
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun shouldAskNotificationPermissionsViaBs(): Boolean {
|
||||
return appPreferencesStore.getSyncOrDefault(getShouldShowAskNotificationPermissionViaBs(), false)
|
||||
}
|
||||
|
||||
override suspend fun setShouldAskNotificationPermissionsViaBs(shouldAsk: Boolean) {
|
||||
appPreferencesStore.store(key = getShouldShowAskNotificationPermissionViaBs(), value = shouldAsk)
|
||||
}
|
||||
}
|
||||
|
|
@ -56,4 +56,12 @@ interface NotificationsRepository {
|
|||
suspend fun getWalletAutomaticallyEnabledList(): List<String>
|
||||
|
||||
suspend fun setNotificationsWasEnabledAutomatically(userWalletId: String)
|
||||
|
||||
/**
|
||||
* By default it is false cause for the first try to show should be skipped. Only should be shown on second time
|
||||
* app launch.
|
||||
*/
|
||||
suspend fun shouldAskNotificationPermissionsViaBs(): Boolean
|
||||
|
||||
suspend fun setShouldAskNotificationPermissionsViaBs(shouldAsk: Boolean)
|
||||
}
|
||||
|
|
@ -1,27 +1,34 @@
|
|||
package com.tangem.domain.wallets.usecase
|
||||
|
||||
import com.tangem.domain.common.wallets.UserWalletsListRepository
|
||||
import com.tangem.domain.models.wallet.UserWalletId
|
||||
import com.tangem.domain.wallets.legacy.UserWalletsListManager
|
||||
import com.tangem.utils.coroutines.CoroutineDispatcherProvider
|
||||
import kotlinx.coroutines.withContext
|
||||
import javax.inject.Inject
|
||||
|
||||
/**
|
||||
* Use case for retrieving wallets where automatically enabling push notifications was not applied.
|
||||
* * This use case filters out wallets that have already had push notifications automatically enabled
|
||||
* from the complete list of user wallets, returning only those wallets that still need to have
|
||||
* push notifications automatically enabled.
|
||||
* * @property userWalletsListManager Manager for user wallets list operations
|
||||
* @property userWalletsListManager Manager for user wallets list operations
|
||||
* @property userWalletsListRepository Repository for user wallets list operations
|
||||
* @property dispatchers Coroutine dispatcher provider for background operations
|
||||
*/
|
||||
class GetWalletsForAutomaticallyPushEnablingUseCase @Inject constructor(
|
||||
class GetWalletsForAutomaticallyPushEnablingUseCase(
|
||||
private val userWalletsListManager: UserWalletsListManager,
|
||||
private val userWalletsListRepository: UserWalletsListRepository,
|
||||
private val shouldUseNewListRepository: Boolean,
|
||||
private val dispatchers: CoroutineDispatcherProvider,
|
||||
) {
|
||||
|
||||
suspend operator fun invoke(walletsListWherePushWasEnabled: List<UserWalletId>): List<UserWalletId> =
|
||||
withContext(dispatchers.default) {
|
||||
val allLocalWallets = userWalletsListManager.userWalletsSync.map { it.walletId }
|
||||
val allLocalWallets = if (shouldUseNewListRepository) {
|
||||
userWalletsListRepository.userWalletsSync().map { it.walletId }
|
||||
} else {
|
||||
userWalletsListManager.userWalletsSync.map { it.walletId }
|
||||
}
|
||||
allLocalWallets - walletsListWherePushWasEnabled.toSet()
|
||||
}
|
||||
}
|
||||
|
|
@ -3,7 +3,7 @@ package com.tangem.features.pushnotifications.impl.model
|
|||
internal interface PushNotificationsClickIntents {
|
||||
fun onAllowClick()
|
||||
|
||||
fun onLaterClick(isFromBs: Boolean)
|
||||
fun onLaterClick()
|
||||
|
||||
fun onAllowPermission()
|
||||
|
||||
|
|
|
|||
|
|
@ -49,18 +49,15 @@ internal class PushNotificationsModel @Inject constructor(
|
|||
analyticHandler.send(PushNotificationAnalyticEvents.ButtonAllow(source))
|
||||
}
|
||||
|
||||
override fun onLaterClick(isFromBs: Boolean) {
|
||||
modelScope.launch {
|
||||
notificationsRepository.setUserAllowToSubscribeOnPushNotifications(false)
|
||||
}
|
||||
override fun onLaterClick() {
|
||||
analyticHandler.send(PushNotificationAnalyticEvents.ButtonLater(source))
|
||||
modelScope.launch {
|
||||
if (isFromBs) {
|
||||
neverRequestPermissionUseCase(PUSH_PERMISSION)
|
||||
}
|
||||
neverRequestPermissionUseCase(PUSH_PERMISSION)
|
||||
neverToInitiallyAskPermissionUseCase(PUSH_PERMISSION)
|
||||
params.modelCallbacks.onDenySystemPermission()
|
||||
if (!params.isBottomSheet) {
|
||||
if (params.isBottomSheet) {
|
||||
notificationsRepository.setUserAllowToSubscribeOnPushNotifications(false)
|
||||
} else {
|
||||
params.nextRoute?.let { appRouter.push(it) }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ internal fun PushNotificationsBottomSheet(config: TangemBottomSheetConfig, conte
|
|||
@Composable
|
||||
internal fun PushNotificationsContent(
|
||||
onAllowClick: () -> Unit,
|
||||
onLaterClick: (isFromBs: Boolean) -> Unit,
|
||||
onLaterClick: () -> Unit,
|
||||
onAllowPermission: () -> Unit,
|
||||
onDenyPermission: () -> Unit,
|
||||
) {
|
||||
|
|
@ -77,9 +77,7 @@ internal fun PushNotificationsContent(
|
|||
requestPushPermission()
|
||||
},
|
||||
secondaryButtonText = resourceReference(R.string.common_later),
|
||||
onSecondaryClick = {
|
||||
onLaterClick(true)
|
||||
},
|
||||
onSecondaryClick = onLaterClick,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ import kotlinx.collections.immutable.persistentListOf
|
|||
@Composable
|
||||
internal fun PushNotificationsScreen(
|
||||
onAllowClick: () -> Unit,
|
||||
onLaterClick: (isFromBs: Boolean) -> Unit,
|
||||
onLaterClick: () -> Unit,
|
||||
onAllowPermission: () -> Unit,
|
||||
onDenyPermission: () -> Unit,
|
||||
) {
|
||||
|
|
@ -49,9 +49,7 @@ internal fun PushNotificationsScreen(
|
|||
),
|
||||
secondaryButton = ShowcaseButtonModel(
|
||||
buttonText = resourceReference(R.string.common_later),
|
||||
onClick = {
|
||||
onLaterClick(false)
|
||||
},
|
||||
onClick = onLaterClick,
|
||||
),
|
||||
modifier = Modifier.systemBarsPadding(),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -21,9 +21,10 @@ object FeeCalculationUtils {
|
|||
isAmountSubtractAvailable: Boolean,
|
||||
cryptoCurrencyStatus: CryptoCurrencyStatus,
|
||||
amountValue: BigDecimal,
|
||||
feeValue: BigDecimal,
|
||||
feeValue: BigDecimal?,
|
||||
reduceAmountBy: BigDecimal,
|
||||
): BigDecimal {
|
||||
if (feeValue == null || feeValue.isZero()) return amountValue
|
||||
val balance = cryptoCurrencyStatus.value.amount ?: return amountValue
|
||||
val isFeeCoverage = checkFeeCoverage(
|
||||
isSubtractAvailable = isAmountSubtractAvailable,
|
||||
|
|
|
|||
|
|
@ -161,6 +161,7 @@ internal class SendConfirmModel @Inject constructor(
|
|||
|
||||
fun updateState(state: SendUM) {
|
||||
_uiState.value = state
|
||||
onFeeReload()
|
||||
updateConfirmNotifications()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -120,46 +120,8 @@ internal class NotificationsModel @Inject constructor(
|
|||
buildNotifications()
|
||||
}
|
||||
|
||||
private suspend fun buildNotifications() {
|
||||
val notifications = buildList {
|
||||
addFeeUnreachableNotification(
|
||||
tokenStatus = cryptoCurrencyStatus,
|
||||
coinStatus = feeCryptoCurrencyStatus,
|
||||
feeError = notificationData.feeError,
|
||||
onReload = params.callback::onFeeReload,
|
||||
onClick = ::showTokenDetails,
|
||||
)
|
||||
addDomainNotifications()
|
||||
}
|
||||
|
||||
notificationsUpdateTrigger.callbackHasError(notifications.any { it is NotificationUM.Error })
|
||||
|
||||
_uiState.value = notifications.toImmutableList()
|
||||
}
|
||||
|
||||
private fun showTokenDetails(currency: CryptoCurrency) {
|
||||
appRouter.pop { isSuccess ->
|
||||
if (isSuccess) {
|
||||
appRouter.push(
|
||||
AppRoute.CurrencyDetails(
|
||||
userWalletId = userWalletId,
|
||||
currency = currency,
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun MutableList<NotificationUM>.addDomainNotifications() = with(notificationData) {
|
||||
val balance = cryptoCurrencyStatus.value.amount ?: return
|
||||
val feeValue = fee?.amount?.value ?: return
|
||||
val isFeeCoverage = checkFeeCoverage(
|
||||
isSubtractAvailable = isAmountSubtractAvailable,
|
||||
balance = balance,
|
||||
amountValue = amountValue,
|
||||
feeValue = feeValue,
|
||||
reduceAmountBy = reduceAmountBy,
|
||||
)
|
||||
private suspend fun buildNotifications() = with(notificationData) {
|
||||
val feeValue = fee?.amount?.value
|
||||
val sendingAmount = checkAndCalculateSubtractedAmount(
|
||||
isAmountSubtractAvailable = isAmountSubtractAvailable,
|
||||
cryptoCurrencyStatus = cryptoCurrencyStatus,
|
||||
|
|
@ -180,6 +142,50 @@ internal class NotificationsModel @Inject constructor(
|
|||
feeCurrencyBalanceAfterTransaction = feeCurrencyBalanceAfterTransaction,
|
||||
)
|
||||
|
||||
val notifications = buildList {
|
||||
addFeeUnreachableNotification(
|
||||
tokenStatus = cryptoCurrencyStatus,
|
||||
coinStatus = feeCryptoCurrencyStatus,
|
||||
feeError = notificationData.feeError,
|
||||
dustValue = currencyCheck.dustValue,
|
||||
onReload = params.callback::onFeeReload,
|
||||
onClick = ::showTokenDetails,
|
||||
)
|
||||
addDomainNotifications(currencyCheck = currencyCheck, sendingAmount = sendingAmount)
|
||||
}
|
||||
|
||||
notificationsUpdateTrigger.callbackHasError(notifications.any { it is NotificationUM.Error })
|
||||
|
||||
_uiState.value = notifications.toImmutableList()
|
||||
}
|
||||
|
||||
private fun showTokenDetails(currency: CryptoCurrency) {
|
||||
appRouter.pop { isSuccess ->
|
||||
if (isSuccess) {
|
||||
appRouter.push(
|
||||
AppRoute.CurrencyDetails(
|
||||
userWalletId = userWalletId,
|
||||
currency = currency,
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun MutableList<NotificationUM>.addDomainNotifications(
|
||||
currencyCheck: CryptoCurrencyCheck,
|
||||
sendingAmount: BigDecimal,
|
||||
) = with(notificationData) {
|
||||
val balance = cryptoCurrencyStatus.value.amount ?: return
|
||||
val feeValue = fee?.amount?.value ?: return
|
||||
val isFeeCoverage = checkFeeCoverage(
|
||||
isSubtractAvailable = isAmountSubtractAvailable,
|
||||
balance = balance,
|
||||
amountValue = amountValue,
|
||||
feeValue = feeValue,
|
||||
reduceAmountBy = reduceAmountBy,
|
||||
)
|
||||
|
||||
addErrorNotifications(
|
||||
sendingAmount = sendingAmount,
|
||||
feeValue = feeValue,
|
||||
|
|
@ -198,10 +204,10 @@ internal class NotificationsModel @Inject constructor(
|
|||
addInfoNotifications()
|
||||
}
|
||||
|
||||
private fun getFeeCurrencyBalanceAfterTx(sendingAmount: BigDecimal, feeValue: BigDecimal): BigDecimal? {
|
||||
private fun getFeeCurrencyBalanceAfterTx(sendingAmount: BigDecimal, feeValue: BigDecimal?): BigDecimal? {
|
||||
val sendingCurrencyBalance = cryptoCurrencyStatus.value as? CryptoCurrencyStatus.Loaded
|
||||
val feeCurrencyBalance = feeCryptoCurrencyStatus.value as? CryptoCurrencyStatus.Loaded
|
||||
if (feeCryptoCurrencyStatus.value !is CryptoCurrencyStatus.Loaded) return null
|
||||
if (feeCryptoCurrencyStatus.value !is CryptoCurrencyStatus.Loaded || feeValue == null) return null
|
||||
return when {
|
||||
feeCryptoCurrencyStatus == cryptoCurrencyStatus -> sendingCurrencyBalance?.let {
|
||||
it.amount - sendingAmount - feeValue
|
||||
|
|
|
|||
|
|
@ -16,12 +16,16 @@ import com.tangem.core.analytics.api.ParamsInterceptorHolder
|
|||
import com.tangem.core.decompose.di.ModelScoped
|
||||
import com.tangem.core.decompose.model.Model
|
||||
import com.tangem.core.decompose.model.ParamsContainer
|
||||
import com.tangem.core.decompose.ui.UiMessageSender
|
||||
import com.tangem.core.navigation.share.ShareManager
|
||||
import com.tangem.core.navigation.url.UrlOpener
|
||||
import com.tangem.core.ui.extensions.resourceReference
|
||||
import com.tangem.core.ui.format.bigdecimal.crypto
|
||||
import com.tangem.core.ui.format.bigdecimal.format
|
||||
import com.tangem.core.ui.haptic.TangemHapticEffect
|
||||
import com.tangem.core.ui.haptic.VibratorHapticManager
|
||||
import com.tangem.core.ui.message.DialogMessage
|
||||
import com.tangem.features.staking.impl.R
|
||||
import com.tangem.domain.appcurrency.GetSelectedAppCurrencyUseCase
|
||||
import com.tangem.domain.appcurrency.model.AppCurrency
|
||||
import com.tangem.domain.balancehiding.GetBalanceHidingSettingsUseCase
|
||||
|
|
@ -140,6 +144,7 @@ internal class StakingModel @Inject constructor(
|
|||
private val urlOpener: UrlOpener,
|
||||
@DelayedWork private val coroutineScope: CoroutineScope,
|
||||
private val innerRouter: InnerStakingRouter,
|
||||
private val messageSender: UiMessageSender,
|
||||
appRouter: AppRouter,
|
||||
) : Model(), StakingClickIntents {
|
||||
|
||||
|
|
@ -999,7 +1004,12 @@ internal class StakingModel @Inject constructor(
|
|||
network = cryptoCurrencyStatus.currency.network,
|
||||
).fold(
|
||||
ifLeft = {
|
||||
stateController.update(DismissBottomSheetStateTransformer)
|
||||
messageSender.send(
|
||||
DialogMessage(
|
||||
title = resourceReference(id = R.string.send_alert_transaction_failed_title),
|
||||
message = resourceReference(id = R.string.common_unknown_error),
|
||||
),
|
||||
)
|
||||
},
|
||||
ifRight = {
|
||||
stateController.update(CompleteInitializeBottomSheetTransformer(
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import com.tangem.features.staking.impl.presentation.state.StakingUiState
|
|||
import com.tangem.features.staking.impl.presentation.state.bottomsheet.TonInitializeAccountBottomSheetConfig
|
||||
import com.tangem.utils.transformer.Transformer
|
||||
import java.math.BigDecimal
|
||||
import java.math.RoundingMode
|
||||
|
||||
internal class CompleteInitializeBottomSheetTransformer(
|
||||
private val cryptoCurrencyStatus: CryptoCurrencyStatus,
|
||||
|
|
@ -21,8 +22,10 @@ internal class CompleteInitializeBottomSheetTransformer(
|
|||
val prevBottomSheetConfigContent =
|
||||
prevBottomSheetConfig.content as? TonInitializeAccountBottomSheetConfig ?: return prevState
|
||||
|
||||
val feeAmount = (prevBottomSheetConfigContent.feeState as? FeeState.Content)
|
||||
?.fee?.amount?.value?.multiply(BigDecimal(FEE_MULTIPLIER)) ?: return prevState
|
||||
val feeAmount = (prevBottomSheetConfigContent.feeState as? FeeState.Content)?.fee?.amount ?: return prevState
|
||||
|
||||
val multipliedFeeAmount = feeAmount.value?.multiply(BigDecimal(FEE_MULTIPLIER))
|
||||
?.setScale(feeAmount.decimals, RoundingMode.HALF_DOWN) ?: return prevState
|
||||
|
||||
val confirmationState = prevState.confirmationState as? StakingStates.ConfirmationState.Data ?: return prevState
|
||||
|
||||
|
|
@ -31,12 +34,12 @@ internal class CompleteInitializeBottomSheetTransformer(
|
|||
cryptoCurrencyStatus = cryptoCurrencyStatus,
|
||||
minimumTransactionAmount = minimumTransactionAmount,
|
||||
value = ReduceByData(
|
||||
feeAmount,
|
||||
feeAmount,
|
||||
multipliedFeeAmount,
|
||||
multipliedFeeAmount,
|
||||
),
|
||||
).transform(prevState.amountState),
|
||||
confirmationState = confirmationState.copy(
|
||||
reduceAmountBy = feeAmount,
|
||||
reduceAmountBy = multipliedFeeAmount,
|
||||
),
|
||||
bottomSheetConfig = prevBottomSheetConfig.copy(
|
||||
content = prevBottomSheetConfigContent.copy(
|
||||
|
|
|
|||
|
|
@ -41,7 +41,6 @@ import com.tangem.feature.wallet.presentation.wallet.utils.ScreenLifecycleProvid
|
|||
import com.tangem.features.biometry.AskBiometryComponent
|
||||
import com.tangem.features.hotwallet.HotWalletFeatureToggles
|
||||
import com.tangem.features.pushnotifications.api.PushNotificationsModelCallbacks
|
||||
import com.tangem.features.pushnotifications.api.utils.PUSH_PERMISSION
|
||||
import com.tangem.features.tangempay.TangemPayFeatureToggles
|
||||
import com.tangem.features.wallet.deeplink.WalletDeepLinkActionListener
|
||||
import com.tangem.features.yield.supply.api.YieldSupplyFeatureToggles
|
||||
|
|
@ -76,7 +75,6 @@ internal class WalletModel @Inject constructor(
|
|||
private val selectedWalletAnalyticsSender: SelectedWalletAnalyticsSender,
|
||||
private val walletNameMigrationUseCase: WalletNameMigrationUseCase,
|
||||
private val refreshMultiCurrencyWalletQuotesUseCase: RefreshMultiCurrencyWalletQuotesUseCase,
|
||||
private val shouldAskPermissionUseCase: ShouldAskPermissionUseCase,
|
||||
private val walletImageResolver: WalletImageResolver,
|
||||
private val tokenListStore: MultiWalletTokenListStore,
|
||||
private val onrampStatusFactory: OnrampStatusFactory,
|
||||
|
|
@ -238,19 +236,23 @@ internal class WalletModel @Inject constructor(
|
|||
|
||||
private fun subscribeOnPushNotificationsPermission() {
|
||||
modelScope.launch {
|
||||
val shouldAskPermission = shouldAskPermissionUseCase(PUSH_PERMISSION)
|
||||
val afterUpdate = notificationsRepository.shouldShowSubscribeOnNotificationsAfterUpdate()
|
||||
val shouldAskNotificationPermissionsViaBs = notificationsRepository.shouldAskNotificationPermissionsViaBs()
|
||||
val shouldShow = notificationsRepository.shouldShowSubscribeOnNotificationsAfterUpdate()
|
||||
val isBiometricsEnabled = shouldSaveUserWalletsSyncUseCase()
|
||||
val isHuaweiDevice = getIsHuaweiDeviceWithoutGoogleServicesUseCase()
|
||||
val shouldShowBottomSheet = shouldAskPermission || afterUpdate
|
||||
Timber.d(
|
||||
"push BS afterUpdate: $afterUpdate," +
|
||||
"shouldAskPermission $shouldAskPermission," +
|
||||
"push BS afterUpdate: $shouldShow," +
|
||||
"isBiometricsEnabled $isBiometricsEnabled," +
|
||||
"isHuaweiDevice $isHuaweiDevice",
|
||||
)
|
||||
if (!isBiometricsEnabled) return@launch
|
||||
if (!shouldShowBottomSheet) return@launch
|
||||
if (!shouldShow) {
|
||||
return@launch
|
||||
}
|
||||
if (!shouldAskNotificationPermissionsViaBs) {
|
||||
notificationsRepository.setShouldAskNotificationPermissionsViaBs(true)
|
||||
return@launch
|
||||
}
|
||||
|
||||
delay(timeMillis = 1_800)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package com.tangem.feature.wallet.child.wallet.model.intents
|
||||
|
||||
import android.os.Build
|
||||
import arrow.core.getOrElse
|
||||
import com.tangem.common.TangemBlogUrlBuilder
|
||||
import com.tangem.common.routing.AppRoute.*
|
||||
|
|
@ -32,16 +31,12 @@ import com.tangem.domain.promo.models.PromoId
|
|||
import com.tangem.domain.quotes.multi.MultiQuoteStatusFetcher
|
||||
import com.tangem.domain.settings.NeverToSuggestRateAppUseCase
|
||||
import com.tangem.domain.settings.RemindToRateAppLaterUseCase
|
||||
import com.tangem.domain.settings.repositories.PermissionRepository
|
||||
import com.tangem.domain.staking.StakingIdFactory
|
||||
import com.tangem.domain.staking.multi.MultiYieldBalanceFetcher
|
||||
import com.tangem.domain.tokens.model.analytics.TokenSwapPromoAnalyticsEvent
|
||||
import com.tangem.domain.wallets.legacy.UserWalletsListManager.Lockable.UnlockType
|
||||
import com.tangem.domain.wallets.models.UnlockWalletsError
|
||||
import com.tangem.domain.wallets.usecase.DerivePublicKeysUseCase
|
||||
import com.tangem.domain.wallets.usecase.GetUserWalletUseCase
|
||||
import com.tangem.domain.wallets.usecase.SeedPhraseNotificationUseCase
|
||||
import com.tangem.domain.wallets.usecase.UnlockWalletsUseCase
|
||||
import com.tangem.domain.wallets.usecase.*
|
||||
import com.tangem.feature.wallet.child.wallet.model.WalletActivationBannerType
|
||||
import com.tangem.feature.wallet.impl.R
|
||||
import com.tangem.feature.wallet.presentation.wallet.analytics.WalletScreenAnalyticsEvent
|
||||
|
|
@ -139,8 +134,9 @@ internal class WalletWarningsClickIntentsImplementor @Inject constructor(
|
|||
private val userWalletsListRepository: UserWalletsListRepository,
|
||||
private val setShouldShowNotificationUseCase: SetShouldShowNotificationUseCase,
|
||||
private val notificationsRepository: NotificationsRepository,
|
||||
private val permissionRepository: PermissionRepository,
|
||||
private val messageSender: UiMessageSender,
|
||||
private val setNotificationsEnabledUseCase: SetNotificationsEnabledUseCase,
|
||||
private val getWalletsListForEnablingUseCase: GetWalletsForAutomaticallyPushEnablingUseCase,
|
||||
) : BaseWalletClickIntents(), WalletWarningsClickIntents {
|
||||
|
||||
private val finalizeWalletSetupAlertBS
|
||||
|
|
@ -477,49 +473,42 @@ internal class WalletWarningsClickIntentsImplementor @Inject constructor(
|
|||
|
||||
override fun onAllowPermissions() {
|
||||
analyticsEventHandler.send(WalletScreenAnalyticsEvent.PushBannerPromo.ButtonAllowPush)
|
||||
if (isNotificationsPermissionGranted()) {
|
||||
updateSubscribeOnPushPermissions(true)
|
||||
} else {
|
||||
walletEventSender.send(
|
||||
event = WalletEvent.RequestPushPermissions(
|
||||
onAllow = {
|
||||
walletEventSender.send(
|
||||
event = WalletEvent.RequestPushPermissions(
|
||||
onAllow = {
|
||||
modelScope.launch {
|
||||
updateSubscribeOnPushPermissions(true)
|
||||
analyticsEventHandler.send(
|
||||
PushNotificationAnalyticEvents.PermissionStatus(isAllowed = true),
|
||||
)
|
||||
},
|
||||
onDeny = {
|
||||
enableNotificationsIfNeeded()
|
||||
}
|
||||
},
|
||||
onDeny = {
|
||||
modelScope.launch {
|
||||
updateSubscribeOnPushPermissions(false)
|
||||
analyticsEventHandler.send(
|
||||
PushNotificationAnalyticEvents.PermissionStatus(isAllowed = false),
|
||||
)
|
||||
},
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
},
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
override fun onDenyPermissions() {
|
||||
analyticsEventHandler.send(WalletScreenAnalyticsEvent.PushBannerPromo.ButtonLaterPush)
|
||||
updateSubscribeOnPushPermissions(false)
|
||||
}
|
||||
|
||||
private fun updateSubscribeOnPushPermissions(shouldAllow: Boolean) {
|
||||
modelScope.launch {
|
||||
notificationsRepository.setUserAllowToSubscribeOnPushNotifications(shouldAllow)
|
||||
setShouldShowNotificationUseCase(
|
||||
key = NotificationId.EnablePushesReminderNotification.key,
|
||||
value = false,
|
||||
)
|
||||
analyticsEventHandler.send(WalletScreenAnalyticsEvent.PushBannerPromo.ButtonLaterPush)
|
||||
updateSubscribeOnPushPermissions(false)
|
||||
}
|
||||
}
|
||||
|
||||
private fun isNotificationsPermissionGranted(): Boolean {
|
||||
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
permissionRepository.hasRuntimePermission(android.Manifest.permission.POST_NOTIFICATIONS)
|
||||
} else {
|
||||
true
|
||||
}
|
||||
private suspend fun updateSubscribeOnPushPermissions(shouldAllow: Boolean) {
|
||||
notificationsRepository.setUserAllowToSubscribeOnPushNotifications(shouldAllow)
|
||||
setShouldShowNotificationUseCase(
|
||||
key = NotificationId.EnablePushesReminderNotification.key,
|
||||
value = false,
|
||||
)
|
||||
}
|
||||
|
||||
private suspend fun fetchCryptoCurrencies(userWalletId: UserWalletId, currencies: List<CryptoCurrency>) {
|
||||
|
|
@ -572,4 +561,18 @@ internal class WalletWarningsClickIntentsImplementor @Inject constructor(
|
|||
null
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun enableNotificationsIfNeeded() {
|
||||
val alreadyEnabledWallets = notificationsRepository.getWalletAutomaticallyEnabledList().map {
|
||||
UserWalletId(it)
|
||||
}
|
||||
val walletsListWhichShouldBeEnabled = getWalletsListForEnablingUseCase(alreadyEnabledWallets)
|
||||
walletsListWhichShouldBeEnabled.forEach { userWalletId ->
|
||||
setNotificationsEnabledUseCase(userWalletId, true).onRight {
|
||||
notificationsRepository.setNotificationsWasEnabledAutomatically(userWalletId.stringValue)
|
||||
}.onLeft {
|
||||
Timber.e(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -71,6 +71,7 @@ internal class YieldSupplyNotificationsModel @Inject constructor(
|
|||
coinStatus = feeCryptoCurrencyStatus,
|
||||
feeError = data.feeError,
|
||||
onClick = ::openTokenDetails,
|
||||
dustValue = null,
|
||||
onReload = params.callback::onFeeReload,
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue