Updated on 2026-08-14

This commit is contained in:
Tangem 2021-03-12 10:53:53 +00:00
commit d70fd6956c
3 changed files with 20 additions and 15 deletions

View file

@ -357,14 +357,14 @@ class MultipleAddressUiHelper {
return when (id) {
R.id.chip_default -> {
when (blockchain) {
Blockchain.Bitcoin -> BitcoinAddressType.Segwit
Blockchain.Bitcoin, Blockchain.BitcoinTestnet -> BitcoinAddressType.Segwit
Blockchain.CardanoShelley -> CardanoAddressType.Shelley
else -> null
}
}
R.id.chip_legacy -> {
when (blockchain) {
Blockchain.Bitcoin -> BitcoinAddressType.Legacy
Blockchain.Bitcoin, Blockchain.BitcoinTestnet -> BitcoinAddressType.Legacy
Blockchain.CardanoShelley -> CardanoAddressType.Byron
else -> null
}

View file

@ -86,12 +86,13 @@ class WarningMessageVH(val view: View) : RecyclerView.ViewHolder(view) {
}
view.btn_can_be_better.setOnClickListener {
FirebaseAnalyticsHandler.triggerEvent(AnalyticsEvent.APP_RATING_NEGATIVE)
store.dispatch(WalletAction.Warnings.AppRating.SetNeverToShow)
store.dispatch(GlobalAction.HideWarningMessage(warning))
store.dispatch(GlobalAction.SendFeedback(RateCanBeBetterEmail()))
}
store.dispatch(WalletAction.Warnings.AppRating.SetNeverToShow)
view.btn_really_cool.setOnClickListener {
FirebaseAnalyticsHandler.triggerEvent(AnalyticsEvent.APP_RATING_POSITIVE)
store.dispatch(WalletAction.Warnings.AppRating.SetNeverToShow)
val context = view.context
val reviewManager = ReviewManagerFactory.create(context)
val flow = reviewManager.requestReviewFlow()
@ -107,7 +108,6 @@ class WarningMessageVH(val view: View) : RecyclerView.ViewHolder(view) {
}
store.dispatch(GlobalAction.HideWarningMessage(warning))
}
store.dispatch(WalletAction.Warnings.AppRating.SetNeverToShow)
}
}
}

View file

@ -106,7 +106,8 @@ class AppRatingLaunchObserver(
private val launchCounts: Int,
) {
private val K_SHOW_RATING_AT_LAUNCH_COUNT = "showRatingDialogAtLaunchCount"
private val K_FUNDS_FOUND_DATE = "aFundsFoundDate"
private val K_FUNDS_FOUND_DATE = "fundsFoundDate"
private val K_USER_WAS_INTERACT_WITH_RATING = "userWasInteractWithRating"
private val deferShowing = 20
private val firstShowing = 3
@ -122,21 +123,23 @@ class AppRatingLaunchObserver(
fundsFoundDate = Calendar.getInstance()
preferences.edit().putLong(K_FUNDS_FOUND_DATE, fundsFoundDate!!.timeInMillis).apply()
updateNextShowing(launchCounts + firstShowing)
}
fun isReadyToShow(): Boolean {
val fundsDate = fundsFoundDate ?: return false
val diff = Calendar.getInstance().timeInMillis - fundsDate.timeInMillis
val diffInDays = diff / (100 * 60 * 60 * 24)
if (diffInDays >= firstShowing) return true
if (!userWasInteractWithRating()) {
val diff = Calendar.getInstance().timeInMillis - fundsDate.timeInMillis
val diffInDays = diff / (100 * 60 * 60 * 24)
if (diffInDays >= firstShowing) return true
}
return launchCounts >= getCounterOfNextShowing()
val nextShowing = getCounterOfNextShowing()
return launchCounts >= nextShowing
}
fun applyDelayedShowing() {
if (getCounterOfNextShowing() < launchCounts) updateNextShowing(launchCounts + deferShowing)
updateNextShowing(launchCounts + deferShowing)
}
fun setNeverToShow() {
@ -144,10 +147,12 @@ class AppRatingLaunchObserver(
}
private fun updateNextShowing(at: Int) {
preferences.edit().putInt(K_SHOW_RATING_AT_LAUNCH_COUNT, at).apply()
val editor = preferences.edit()
editor.putInt(K_SHOW_RATING_AT_LAUNCH_COUNT, at)
editor.putBoolean(K_USER_WAS_INTERACT_WITH_RATING, true)
editor.apply()
}
private fun getCounterOfNextShowing(): Int {
return preferences.getInt(K_SHOW_RATING_AT_LAUNCH_COUNT, firstShowing)
}
private fun userWasInteractWithRating(): Boolean = preferences.getBoolean(K_USER_WAS_INTERACT_WITH_RATING, false)
private fun getCounterOfNextShowing(): Int = preferences.getInt(K_SHOW_RATING_AT_LAUNCH_COUNT, firstShowing)
}