Updated on 2026-08-14
This commit is contained in:
commit
b6db9e390a
147 changed files with 3963 additions and 3570 deletions
|
|
@ -0,0 +1,25 @@
|
|||
package com.tangem.tap.persistence
|
||||
|
||||
import android.content.SharedPreferences
|
||||
import androidx.core.content.edit
|
||||
|
||||
/**
|
||||
[REDACTED_AUTHOR]
|
||||
*/
|
||||
class DisclaimerPrefStorage(
|
||||
private val preferences: SharedPreferences,
|
||||
) {
|
||||
|
||||
var hasTangemTosAccepted: Boolean
|
||||
get() = preferences.getBoolean(KEY_TANGEM_TOS, false)
|
||||
set(value) = preferences.edit { putBoolean(KEY_TANGEM_TOS, value) }
|
||||
|
||||
var hasSaltPayTosAccepted: Boolean
|
||||
get() = preferences.getBoolean(KEY_SALT_PAY_TOS, false)
|
||||
set(value) = preferences.edit { putBoolean(KEY_SALT_PAY_TOS, value) }
|
||||
|
||||
companion object {
|
||||
private const val KEY_TANGEM_TOS = "tangem_tos_accepted"
|
||||
private const val KEY_SALT_PAY_TOS = "saltPay_tos_accepted"
|
||||
}
|
||||
}
|
||||
|
|
@ -7,15 +7,15 @@ import androidx.core.content.edit
|
|||
import com.tangem.common.json.MoshiJsonConverter
|
||||
import java.util.*
|
||||
|
||||
|
||||
class PreferencesStorage(applicationContext: Application) {
|
||||
|
||||
private val preferences: SharedPreferences = applicationContext.getSharedPreferences(PREFERENCES_NAME, Context.MODE_PRIVATE)
|
||||
private val preferences: SharedPreferences =
|
||||
applicationContext.getSharedPreferences(PREFERENCES_NAME, Context.MODE_PRIVATE)
|
||||
|
||||
val appRatingLaunchObserver: AppRatingLaunchObserver
|
||||
val usedCardsPrefStorage: UsedCardsPrefStorage
|
||||
val fiatCurrenciesPrefStorage: FiatCurrenciesPrefStorage
|
||||
val saltPayRegistrationStorage: SaltPayRegistrationStorage
|
||||
val disclaimerPrefStorage: DisclaimerPrefStorage
|
||||
|
||||
init {
|
||||
incrementLaunchCounter()
|
||||
|
|
@ -24,7 +24,7 @@ class PreferencesStorage(applicationContext: Application) {
|
|||
usedCardsPrefStorage.migrate()
|
||||
fiatCurrenciesPrefStorage = FiatCurrenciesPrefStorage(preferences, MoshiJsonConverter.INSTANCE)
|
||||
fiatCurrenciesPrefStorage.migrate()
|
||||
saltPayRegistrationStorage = SaltPayRegistrationPrefStorage(applicationContext, MoshiJsonConverter.INSTANCE)
|
||||
disclaimerPrefStorage = DisclaimerPrefStorage(preferences)
|
||||
}
|
||||
|
||||
var chatFirstLaunchTime: Long?
|
||||
|
|
@ -56,12 +56,10 @@ class PreferencesStorage(applicationContext: Application) {
|
|||
|
||||
companion object {
|
||||
private const val PREFERENCES_NAME = "tapPrefs"
|
||||
private const val DISCLAIMER_ACCEPTED_KEY = "disclaimerAccepted"
|
||||
private const val TWINS_ONBOARDING_SHOWN_KEY = "twinsOnboardingShown"
|
||||
private const val APP_LAUNCH_COUNT_KEY = "launchCount"
|
||||
private const val CHAT_FIRST_LAUNCH_KEY = "chatFirstLaunchKey"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class AppRatingLaunchObserver(
|
||||
|
|
|
|||
|
|
@ -1,82 +0,0 @@
|
|||
package com.tangem.tap.persistence
|
||||
|
||||
import android.content.Context
|
||||
import androidx.core.content.edit
|
||||
import at.favre.lib.armadillo.ArmadilloSharedPreferences
|
||||
import com.tangem.common.json.MoshiJsonConverter
|
||||
import com.tangem.common.services.secure.SecureStorage
|
||||
import com.tangem.tangem_sdk_new.storage.createEncryptedSharedPreferences
|
||||
|
||||
/**
|
||||
[REDACTED_AUTHOR]
|
||||
*/
|
||||
interface SaltPayRegistrationStorage {
|
||||
var data: SaltPayRegistratorData
|
||||
|
||||
fun reset()
|
||||
|
||||
companion object {
|
||||
fun stub(): SaltPayRegistrationStorage = object : SaltPayRegistrationStorage {
|
||||
override var data: SaltPayRegistratorData = SaltPayRegistratorData()
|
||||
override fun reset() {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
data class SaltPayRegistratorData(
|
||||
val transactionsSent: Boolean = false,
|
||||
)
|
||||
|
||||
class SaltPayRegistrationPrefStorage(
|
||||
context: Context,
|
||||
private val converter: MoshiJsonConverter,
|
||||
) : SaltPayRegistrationStorage {
|
||||
|
||||
private val storage: ArmadilloSharedPreferences = SecureStorage.createEncryptedSharedPreferences(
|
||||
context = context,
|
||||
storageName = "saltpay",
|
||||
)
|
||||
|
||||
private var isFetching: Boolean = false
|
||||
|
||||
init {
|
||||
fetch()
|
||||
}
|
||||
|
||||
override var data: SaltPayRegistratorData = SaltPayRegistratorData()
|
||||
set(value) {
|
||||
field = value
|
||||
if (!isFetching) save()
|
||||
}
|
||||
|
||||
override fun reset() {
|
||||
storage.edit(true) {
|
||||
this.remove(REGISTRATION_DATA_KEY)
|
||||
data = SaltPayRegistratorData()
|
||||
}
|
||||
}
|
||||
|
||||
private fun save() {
|
||||
storage.edit(true) {
|
||||
putString(REGISTRATION_DATA_KEY, converter.toJson(data))
|
||||
}
|
||||
}
|
||||
|
||||
private fun fetch(): SaltPayRegistratorData {
|
||||
isFetching = true
|
||||
|
||||
val jsonData = storage.getString(REGISTRATION_DATA_KEY, null)
|
||||
data = if (jsonData == null) {
|
||||
SaltPayRegistratorData()
|
||||
} else {
|
||||
converter.fromJson<SaltPayRegistratorData>(jsonData) ?: SaltPayRegistratorData()
|
||||
}
|
||||
isFetching = false
|
||||
|
||||
return data
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val REGISTRATION_DATA_KEY = "saltpay_registration_data"
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue