Updated on 2026-08-14

This commit is contained in:
Tangem 2023-11-21 11:05:15 +03:00
commit 6e20ef6027
57 changed files with 360 additions and 864 deletions

View file

@ -1,18 +1,11 @@
package com.tangem.datasource.di
import android.content.Context
import com.squareup.moshi.Moshi
import com.tangem.datasource.api.tangemTech.models.CurrenciesResponse
import com.tangem.datasource.local.appcurrency.AvailableAppCurrenciesStore
import com.tangem.datasource.local.appcurrency.SelectedAppCurrencyStore
import com.tangem.datasource.local.appcurrency.implementation.DefaultAvailableAppCurrenciesStore
import com.tangem.datasource.local.appcurrency.implementation.DefaultSelectedAppCurrencyStore
import com.tangem.datasource.local.datastore.JsonSharedPreferencesDataStore
import com.tangem.datasource.local.datastore.RuntimeDataStore
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton
@ -23,23 +16,6 @@ internal object AppCurrencyDataModule {
@Provides
@Singleton
fun provideAvailableAppCurrenciesStore(): AvailableAppCurrenciesStore {
return DefaultAvailableAppCurrenciesStore(
dataStore = RuntimeDataStore(),
)
}
@Provides
@Singleton
fun provideSelectedAppCurrencyStore(
@ApplicationContext context: Context,
@NetworkMoshi moshi: Moshi,
): SelectedAppCurrencyStore {
return DefaultSelectedAppCurrencyStore(
dataStore = JsonSharedPreferencesDataStore(
preferencesName = "selected_app_currency",
context = context,
adapter = moshi.adapter(CurrenciesResponse.Currency::class.java),
),
)
return DefaultAvailableAppCurrenciesStore(dataStore = RuntimeDataStore())
}
}

View file

@ -1,29 +0,0 @@
package com.tangem.datasource.di
import android.content.Context
import com.squareup.moshi.Moshi
import com.tangem.datasource.local.apptheme.AppThemeModeStore
import com.tangem.datasource.local.apptheme.DefaultAppThemeModeStore
import com.tangem.datasource.local.datastore.JsonSharedPreferencesDataStore
import com.tangem.domain.apptheme.model.AppThemeMode
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
@Module
@InstallIn(SingletonComponent::class)
internal object AppThemeModeDataModule {
@Provides
fun provideAppThemeModeStore(@ApplicationContext context: Context, @NetworkMoshi moshi: Moshi): AppThemeModeStore {
return DefaultAppThemeModeStore(
dataStore = JsonSharedPreferencesDataStore(
preferencesName = "app_theme",
context = context,
adapter = moshi.adapter(AppThemeMode::class.java),
),
)
}
}

View file

@ -1,34 +0,0 @@
package com.tangem.datasource.di
import android.content.Context
import com.squareup.moshi.Moshi
import com.squareup.moshi.Types
import com.tangem.datasource.local.card.DefaultUsedCardsStore
import com.tangem.datasource.local.card.UsedCardInfo
import com.tangem.datasource.local.card.UsedCardsStore
import com.tangem.datasource.local.datastore.JsonSharedPreferencesDataStore
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton
@Module
@InstallIn(SingletonComponent::class)
internal object CardDataModule {
@Provides
@Singleton
fun provideUsedCardsStore(@ApplicationContext context: Context, @NetworkMoshi moshi: Moshi): UsedCardsStore {
return DefaultUsedCardsStore(
store = JsonSharedPreferencesDataStore(
preferencesName = "tapPrefs",
context = context,
adapter = moshi.adapter(
Types.newParameterizedType(List::class.java, UsedCardInfo::class.java),
),
),
)
}
}

View file

@ -1,32 +0,0 @@
package com.tangem.datasource.di
import android.content.Context
import com.squareup.moshi.Moshi
import com.tangem.datasource.local.appcurrency.BalanceHidingSettingsStore
import com.tangem.datasource.local.appcurrency.implementation.BalanceStateHidingSettingsStore
import com.tangem.datasource.local.datastore.JsonSharedPreferencesDataStore
import com.tangem.domain.balancehiding.BalanceHidingSettings
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
@Module
@InstallIn(SingletonComponent::class)
internal object HiddenBalanceDataModule {
@Provides
fun provideHiddenBalanceStateStore(
@ApplicationContext context: Context,
@NetworkMoshi moshi: Moshi,
): BalanceHidingSettingsStore {
return BalanceStateHidingSettingsStore(
dataStore = JsonSharedPreferencesDataStore(
preferencesName = "balance_hiding_settings",
context = context,
adapter = moshi.adapter(BalanceHidingSettings::class.java),
),
)
}
}

View file

@ -1,50 +0,0 @@
package com.tangem.datasource.di
import android.content.Context
import com.tangem.datasource.local.datastore.BooleanSharedPreferencesDataStore
import com.tangem.datasource.local.datastore.IntSharedPreferencesDataStore
import com.tangem.datasource.local.datastore.LongSharedPreferencesDataStore
import com.tangem.datasource.local.settings.*
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton
@Module
@InstallIn(SingletonComponent::class)
internal object SettingsDataModule {
@Provides
@Singleton
fun provideAppLaunchCountStore(@ApplicationContext context: Context): AppLaunchCountStore {
return DefaultAppLaunchCountStore(
store = IntSharedPreferencesDataStore(preferencesName = "tapPrefs", context = context),
)
}
@Provides
@Singleton
fun provideAppRatingShowingCountStore(@ApplicationContext context: Context): AppRatingShowingCountStore {
return DefaultAppRatingShowingCountStore(
store = IntSharedPreferencesDataStore(preferencesName = "tapPrefs", context = context),
)
}
@Provides
@Singleton
fun provideFundsFoundDateInMillisStore(@ApplicationContext context: Context): FundsFoundDateInMillisStore {
return DefaultFundsFoundDateInMillisStore(
store = LongSharedPreferencesDataStore(preferencesName = "tapPrefs", context = context),
)
}
@Provides
@Singleton
fun provideUserInteractingStatusStore(@ApplicationContext context: Context): UserInteractingStatusStore {
return DefaultUserInteractingStatusStore(
store = BooleanSharedPreferencesDataStore(preferencesName = "tapPrefs", context = context),
)
}
}

View file

@ -1,26 +0,0 @@
package com.tangem.datasource.di
import android.content.Context
import com.tangem.datasource.local.datastore.BooleanSharedPreferencesDataStore
import com.tangem.datasource.local.settings.*
import com.tangem.datasource.local.userwallet.DefaultShouldSaveUserWalletStore
import com.tangem.datasource.local.userwallet.ShouldSaveUserWalletStore
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton
@Module
@InstallIn(SingletonComponent::class)
internal object WalletsDataModule {
@Provides
@Singleton
fun provideShouldSaveUserWalletsStore(@ApplicationContext context: Context): ShouldSaveUserWalletStore {
return DefaultShouldSaveUserWalletStore(
store = BooleanSharedPreferencesDataStore(preferencesName = "tapPrefs", context = context),
)
}
}

View file

@ -5,6 +5,7 @@ package com.tangem.datasource.local
*
[REDACTED_AUTHOR]
*/
@Deprecated(message = "Use AppPreferencesStore", level = DeprecationLevel.WARNING)
interface AppPreferenceStorage {
/** Json config with feature toggles 'ToggleName: String - Availability: Boolean' */

View file

@ -1,13 +0,0 @@
package com.tangem.datasource.local.appcurrency
import com.tangem.domain.balancehiding.BalanceHidingSettings
import kotlinx.coroutines.flow.Flow
interface BalanceHidingSettingsStore {
fun get(): Flow<BalanceHidingSettings>
suspend fun getSyncOrDefault(): BalanceHidingSettings
suspend fun store(settings: BalanceHidingSettings)
}

View file

@ -1,15 +0,0 @@
package com.tangem.datasource.local.appcurrency
import com.tangem.datasource.api.tangemTech.models.CurrenciesResponse
import kotlinx.coroutines.flow.Flow
interface SelectedAppCurrencyStore {
fun get(): Flow<CurrenciesResponse.Currency>
suspend fun getSyncOrNull(): CurrenciesResponse.Currency?
suspend fun store(item: CurrenciesResponse.Currency)
suspend fun isEmpty(): Boolean
}

View file

@ -1,19 +0,0 @@
package com.tangem.datasource.local.appcurrency.implementation
import com.tangem.datasource.local.appcurrency.BalanceHidingSettingsStore
import com.tangem.datasource.local.datastore.core.KeylessDataStoreDecorator
import com.tangem.datasource.local.datastore.core.StringKeyDataStore
import com.tangem.domain.balancehiding.BalanceHidingSettings
internal class BalanceStateHidingSettingsStore(
dataStore: StringKeyDataStore<BalanceHidingSettings>,
) : BalanceHidingSettingsStore, KeylessDataStoreDecorator<BalanceHidingSettings>(dataStore) {
override suspend fun getSyncOrDefault(): BalanceHidingSettings {
return getSyncOrNull() ?: BalanceHidingSettings(
isHidingEnabledInSettings = false,
isBalanceHidden = false,
isBalanceHidingNotificationEnabled = true,
)
}
}

View file

@ -1,10 +0,0 @@
package com.tangem.datasource.local.appcurrency.implementation
import com.tangem.datasource.api.tangemTech.models.CurrenciesResponse
import com.tangem.datasource.local.appcurrency.SelectedAppCurrencyStore
import com.tangem.datasource.local.datastore.core.KeylessDataStoreDecorator
import com.tangem.datasource.local.datastore.core.StringKeyDataStore
internal class DefaultSelectedAppCurrencyStore(
dataStore: StringKeyDataStore<CurrenciesResponse.Currency>,
) : SelectedAppCurrencyStore, KeylessDataStoreDecorator<CurrenciesResponse.Currency>(dataStore)

View file

@ -1,13 +0,0 @@
package com.tangem.datasource.local.apptheme
import com.tangem.domain.apptheme.model.AppThemeMode
import kotlinx.coroutines.flow.Flow
interface AppThemeModeStore {
fun get(): Flow<AppThemeMode>
suspend fun store(item: AppThemeMode)
suspend fun isEmpty(): Boolean
}

View file

@ -1,9 +0,0 @@
package com.tangem.datasource.local.apptheme
import com.tangem.datasource.local.datastore.core.KeylessDataStoreDecorator
import com.tangem.datasource.local.datastore.core.StringKeyDataStore
import com.tangem.domain.apptheme.model.AppThemeMode
internal class DefaultAppThemeModeStore(
dataStore: StringKeyDataStore<AppThemeMode>,
) : AppThemeModeStore, KeylessDataStoreDecorator<AppThemeMode>(dataStore)

View file

@ -1,21 +0,0 @@
package com.tangem.datasource.local.card
import com.tangem.datasource.local.datastore.SharedPreferencesDataStore
import com.tangem.datasource.local.datastore.core.KeylessDataStoreDecorator
import kotlinx.coroutines.flow.Flow
interface UsedCardsStore {
fun get(): Flow<List<UsedCardInfo>>
suspend fun getSyncOrNull(): List<UsedCardInfo>?
suspend fun store(item: List<UsedCardInfo>)
}
internal class DefaultUsedCardsStore(
store: SharedPreferencesDataStore<List<UsedCardInfo>>,
) : UsedCardsStore, KeylessDataStoreDecorator<List<UsedCardInfo>>(
wrappedDataStore = store,
key = "usedCardsInfo_v2",
)

View file

@ -1,16 +0,0 @@
package com.tangem.datasource.local.datastore
import android.content.Context
import androidx.core.content.edit
internal class BooleanSharedPreferencesDataStore(
preferencesName: String,
context: Context,
) : SharedPreferencesDataStore<Boolean>(preferencesName, context) {
override fun getByKey(key: String): Boolean = sharedPreferences.getBoolean(key, false)
override fun storeByKey(key: String, value: Boolean) {
sharedPreferences.edit { putBoolean(key, value) }
}
}

View file

@ -1,16 +0,0 @@
package com.tangem.datasource.local.datastore
import android.content.Context
import androidx.core.content.edit
internal class IntSharedPreferencesDataStore(
preferencesName: String,
context: Context,
) : SharedPreferencesDataStore<Int>(preferencesName, context) {
override fun getByKey(key: String): Int = sharedPreferences.getInt(key, 0)
override fun storeByKey(key: String, value: Int) {
sharedPreferences.edit { putInt(key, value) }
}
}

View file

@ -1,24 +0,0 @@
package com.tangem.datasource.local.datastore
import android.content.Context
import androidx.core.content.edit
import com.squareup.moshi.JsonAdapter
internal class JsonSharedPreferencesDataStore<Value : Any>(
preferencesName: String,
context: Context,
private val adapter: JsonAdapter<Value>,
) : SharedPreferencesDataStore<Value>(preferencesName, context) {
override fun getByKey(key: String): Value? {
val json = sharedPreferences.getString(key, null) ?: return null
return adapter.fromJson(json)
}
override fun storeByKey(key: String, value: Value) {
val json = adapter.toJson(value)
sharedPreferences.edit { putString(key, json) }
}
}

View file

@ -1,16 +0,0 @@
package com.tangem.datasource.local.datastore
import android.content.Context
import androidx.core.content.edit
internal class LongSharedPreferencesDataStore(
preferencesName: String,
context: Context,
) : SharedPreferencesDataStore<Long>(preferencesName, context) {
override fun getByKey(key: String): Long = sharedPreferences.getLong(key, 0)
override fun storeByKey(key: String, value: Long) {
sharedPreferences.edit { putLong(key, value) }
}
}

View file

@ -1,98 +0,0 @@
package com.tangem.datasource.local.datastore
import android.content.Context
import android.content.Context.MODE_PRIVATE
import android.content.SharedPreferences
import androidx.core.content.edit
import com.tangem.datasource.local.datastore.core.StringKeyDataStore
import com.tangem.datasource.local.datastore.utils.Trigger
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.mapNotNull
import timber.log.Timber
internal abstract class SharedPreferencesDataStore<Value : Any>(
preferencesName: String,
context: Context,
) : StringKeyDataStore<Value> {
protected val sharedPreferences: SharedPreferences by lazy {
context.getSharedPreferences(preferencesName, MODE_PRIVATE)
}
private val writeTrigger = Trigger()
abstract fun getByKey(key: String): Value?
abstract fun storeByKey(key: String, value: Value)
override suspend fun isEmpty(): Boolean {
return sharedPreferences.all.isEmpty()
}
override suspend fun contains(key: String): Boolean {
return sharedPreferences.contains(key)
}
override fun get(key: String): Flow<Value> {
return writeTrigger
.mapNotNull { getInternal(key) }
.distinctUntilChanged()
}
override fun getAll(): Flow<List<Value>> {
throw UnsupportedOperationException("Unknown key")
}
override suspend fun getSyncOrNull(key: String): Value? = getInternal(key)
override suspend fun getAllSyncOrNull(): List<Value> {
throw UnsupportedOperationException("Unknown key")
}
override suspend fun store(key: String, value: Value) {
try {
storeByKey(key, value)
writeTrigger.trigger()
} catch (e: Throwable) {
Timber.e(e, "Unable to edit preferences: $key")
}
}
override suspend fun store(values: Map<String, Value>) {
values.forEach { (key, item) ->
store(key, item)
}
}
override suspend fun remove(key: String) {
sharedPreferences.edit { remove(key) }
writeTrigger.trigger()
}
override suspend fun remove(keys: Collection<String>) {
sharedPreferences.edit {
keys.forEach { key ->
remove(key)
}
}
writeTrigger.trigger()
}
override suspend fun clear() {
sharedPreferences.edit { clear() }
writeTrigger.trigger()
}
private fun getInternal(key: String): Value? {
if (!sharedPreferences.contains(key)) return null
return try {
getByKey(key)
} catch (e: Throwable) {
Timber.e(e, "Unable to get value from preferences: $key")
null
}
}
}

View file

@ -4,11 +4,13 @@ import android.content.Context
import androidx.datastore.core.DataMigration
import androidx.datastore.core.DataStore
import androidx.datastore.core.handlers.ReplaceFileCorruptionHandler
import androidx.datastore.preferences.SharedPreferencesMigration
import androidx.datastore.preferences.core.PreferenceDataStoreFactory
import androidx.datastore.preferences.core.Preferences
import androidx.datastore.preferences.core.emptyPreferences
import androidx.datastore.preferences.preferencesDataStoreFile
import com.tangem.datasource.local.preferences.PreferencesDataStore.INSTANCE
import com.tangem.datasource.local.preferences.utils.SharedPreferencesKeyMigration
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.SupervisorJob
import timber.log.Timber
@ -23,6 +25,8 @@ import kotlin.coroutines.CoroutineContext
internal object PreferencesDataStore {
private const val PREFERENCES_FILE_NAME = "TAP_PREFS"
private const val LEGACY_TAP_PREFS_FILE_NAME = "tapPrefs"
private const val LEGACY_DEFAULT_KEY_NAME = "key"
private var INSTANCE: DataStore<Preferences>? = null
@ -33,7 +37,7 @@ internal object PreferencesDataStore {
private fun create(context: Context, dispatcher: CoroutineContext): DataStore<Preferences> {
return PreferenceDataStoreFactory.create(
corruptionHandler = createCorruptionHandler(),
migrations = createMigrations(),
migrations = createMigrations(context = context),
scope = CoroutineScope(context = dispatcher + SupervisorJob()),
produceFile = { context.preferencesDataStoreFile(name = PREFERENCES_FILE_NAME) },
)
@ -48,7 +52,31 @@ internal object PreferencesDataStore {
)
}
private fun createMigrations(): List<DataMigration<Preferences>> {
return listOf()
private fun createMigrations(context: Context): List<DataMigration<Preferences>> {
return listOf(
SharedPreferencesMigration(
context = context,
sharedPreferencesName = LEGACY_TAP_PREFS_FILE_NAME,
keysToMigrate = getTapPrefKeysToMigrate(),
),
SharedPreferencesKeyMigration(
context = context,
legacyPrefsName = "app_theme",
legacyKeyName = LEGACY_DEFAULT_KEY_NAME,
keyName = PreferencesKeys.APP_THEME_MODE_KEY.name,
),
SharedPreferencesKeyMigration(
context = context,
legacyPrefsName = "selected_app_currency",
legacyKeyName = LEGACY_DEFAULT_KEY_NAME,
keyName = PreferencesKeys.SELECTED_APP_CURRENCY_KEY.name,
),
SharedPreferencesKeyMigration(
context = context,
legacyPrefsName = "balance_hiding_settings",
legacyKeyName = LEGACY_DEFAULT_KEY_NAME,
keyName = PreferencesKeys.BALANCE_HIDING_SETTINGS_KEY.name,
),
)
}
}

View file

@ -1,13 +1,49 @@
package com.tangem.datasource.local.preferences
import androidx.datastore.preferences.core.*
import com.tangem.datasource.local.preferences.PreferencesKeys.APP_LAUNCH_COUNT_KEY
import com.tangem.datasource.local.preferences.PreferencesKeys.FUNDS_FOUND_DATE_KEY
import com.tangem.datasource.local.preferences.PreferencesKeys.SAVE_USER_WALLETS_KEY
import com.tangem.datasource.local.preferences.PreferencesKeys.SHOW_RATING_DIALOG_AT_LAUNCH_COUNT_KEY
import com.tangem.datasource.local.preferences.PreferencesKeys.USED_CARDS_INFO_KEY
import com.tangem.datasource.local.preferences.PreferencesKeys.USER_WAS_INTERACT_WITH_RATING_KEY
/**
* All preferences keys that DataStore<Preferences> is stored.
*
[REDACTED_AUTHOR]
*/
object PreferencesKeys
object PreferencesKeys {
val SAVE_USER_WALLETS_KEY by lazy { booleanPreferencesKey(name = "saveUserWallets") }
val APP_LAUNCH_COUNT_KEY by lazy { intPreferencesKey(name = "launchCount") }
val SHOW_RATING_DIALOG_AT_LAUNCH_COUNT_KEY by lazy { intPreferencesKey(name = "showRatingDialogAtLaunchCount") }
val FUNDS_FOUND_DATE_KEY by lazy { longPreferencesKey(name = "fundsFoundDate") }
val USER_WAS_INTERACT_WITH_RATING_KEY by lazy { booleanPreferencesKey(name = "userWasInteractWithRating") }
val USED_CARDS_INFO_KEY by lazy { stringPreferencesKey(name = "usedCardsInfo_v2") }
val APP_THEME_MODE_KEY by lazy { stringPreferencesKey(name = "appThemeMode") }
val SELECTED_APP_CURRENCY_KEY by lazy { stringPreferencesKey(name = "selectedAppCurrency") }
val BALANCE_HIDING_SETTINGS_KEY by lazy { stringPreferencesKey(name = "balanceHidingSettings") }
}
/** Preferences keys set that should be migrated from "PreferencesDataSource" to a new DataStore<Preferences> */
internal fun getTapPrefKeysToMigrate(): Set<String> {
return setOf()
return setOf(
SAVE_USER_WALLETS_KEY,
APP_LAUNCH_COUNT_KEY,
SHOW_RATING_DIALOG_AT_LAUNCH_COUNT_KEY,
FUNDS_FOUND_DATE_KEY,
USER_WAS_INTERACT_WITH_RATING_KEY,
USED_CARDS_INFO_KEY,
)
.map(Preferences.Key<*>::name)
.toSet()
}

View file

@ -30,6 +30,14 @@ internal class DefaultQuotesStore(
}
}
override suspend fun getSync(currenciesIds: Set<CryptoCurrency.ID>): Set<StoredQuote> {
return currenciesIds.mapNotNull { currencyId ->
currencyId.rawCurrencyId?.let {
dataStore.getSyncOrNull(it)
}
}.toSet()
}
override suspend fun store(response: QuotesResponse) {
val quotes = response.quotes.mapValues { (id, quote) ->
StoredQuote(id, quote)

View file

@ -9,5 +9,7 @@ interface QuotesStore {
fun get(currenciesIds: Set<CryptoCurrency.ID>): Flow<Set<StoredQuote>>
suspend fun getSync(currenciesIds: Set<CryptoCurrency.ID>): Set<StoredQuote>
suspend fun store(response: QuotesResponse)
}

View file

@ -1,21 +0,0 @@
package com.tangem.datasource.local.settings
import com.tangem.datasource.local.datastore.IntSharedPreferencesDataStore
import com.tangem.datasource.local.datastore.core.KeylessDataStoreDecorator
import kotlinx.coroutines.flow.Flow
interface AppLaunchCountStore {
fun get(): Flow<Int>
suspend fun getSyncOrNull(): Int?
suspend fun store(item: Int)
}
internal class DefaultAppLaunchCountStore(
store: IntSharedPreferencesDataStore,
) : AppLaunchCountStore, KeylessDataStoreDecorator<Int>(
wrappedDataStore = store,
key = "launchCount",
)

View file

@ -1,21 +0,0 @@
package com.tangem.datasource.local.settings
import com.tangem.datasource.local.datastore.IntSharedPreferencesDataStore
import com.tangem.datasource.local.datastore.core.KeylessDataStoreDecorator
import kotlinx.coroutines.flow.Flow
interface AppRatingShowingCountStore {
fun get(): Flow<Int>
suspend fun getSyncOrNull(): Int?
suspend fun store(item: Int)
}
internal class DefaultAppRatingShowingCountStore(
store: IntSharedPreferencesDataStore,
) : AppRatingShowingCountStore, KeylessDataStoreDecorator<Int>(
wrappedDataStore = store,
key = "showRatingDialogAtLaunchCount",
)

View file

@ -1,21 +0,0 @@
package com.tangem.datasource.local.settings
import com.tangem.datasource.local.datastore.LongSharedPreferencesDataStore
import com.tangem.datasource.local.datastore.core.KeylessDataStoreDecorator
import kotlinx.coroutines.flow.Flow
interface FundsFoundDateInMillisStore {
fun get(): Flow<Long>
suspend fun getSyncOrNull(): Long?
suspend fun store(item: Long)
}
internal class DefaultFundsFoundDateInMillisStore(
store: LongSharedPreferencesDataStore,
) : FundsFoundDateInMillisStore, KeylessDataStoreDecorator<Long>(
wrappedDataStore = store,
key = "fundsFoundDate",
)

View file

@ -1,21 +0,0 @@
package com.tangem.datasource.local.settings
import com.tangem.datasource.local.datastore.BooleanSharedPreferencesDataStore
import com.tangem.datasource.local.datastore.core.KeylessDataStoreDecorator
import kotlinx.coroutines.flow.Flow
interface UserInteractingStatusStore {
fun get(): Flow<Boolean>
suspend fun getSyncOrNull(): Boolean?
suspend fun store(item: Boolean)
}
internal class DefaultUserInteractingStatusStore(
store: BooleanSharedPreferencesDataStore,
) : UserInteractingStatusStore, KeylessDataStoreDecorator<Boolean>(
wrappedDataStore = store,
key = "userWasInteractWithRating",
)

View file

@ -1,24 +0,0 @@
package com.tangem.datasource.local.userwallet
import com.tangem.datasource.local.datastore.BooleanSharedPreferencesDataStore
import com.tangem.datasource.local.datastore.core.KeylessDataStoreDecorator
import kotlinx.coroutines.flow.Flow
/**
[REDACTED_AUTHOR]
*/
interface ShouldSaveUserWalletStore {
fun get(): Flow<Boolean>
suspend fun getSyncOrNull(): Boolean?
suspend fun store(item: Boolean)
}
internal class DefaultShouldSaveUserWalletStore(
store: BooleanSharedPreferencesDataStore,
) : ShouldSaveUserWalletStore, KeylessDataStoreDecorator<Boolean>(
wrappedDataStore = store,
key = "saveUserWallets",
)