Updated on 2026-08-14
This commit is contained in:
parent
299f10a1f6
commit
486f9a6c34
3 changed files with 31 additions and 1 deletions
|
|
@ -89,6 +89,7 @@ import kotlinx.coroutines.flow.*
|
|||
import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
import kotlin.coroutines.CoroutineContext
|
||||
import kotlin.time.Duration.Companion.seconds
|
||||
|
||||
lateinit var tangemSdkManager: TangemSdkManager
|
||||
lateinit var backupService: BackupService
|
||||
|
|
@ -314,7 +315,11 @@ class MainActivity : AppCompatActivity(), SnackbarHandler, ActivityResultCallbac
|
|||
|
||||
private fun installAppTheme() {
|
||||
appThemeModeFlow = createAppThemeModeFlow()
|
||||
val mode = runBlocking { appThemeModeFlow.first() }
|
||||
val mode = runBlocking {
|
||||
withTimeoutOrNull(APP_THEME_LOAD_TIMEOUT.seconds) {
|
||||
appThemeModeFlow.first()
|
||||
} ?: AppThemeMode.DEFAULT
|
||||
}
|
||||
|
||||
updateAppTheme(mode)
|
||||
}
|
||||
|
|
@ -581,4 +586,8 @@ class MainActivity : AppCompatActivity(), SnackbarHandler, ActivityResultCallbac
|
|||
.onRight { Timber.d("Submitting hashes succeeded") }
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val APP_THEME_LOAD_TIMEOUT = 2
|
||||
}
|
||||
}
|
||||
|
|
@ -10,6 +10,8 @@ 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.PreferencesKeys.APP_LOGS_KEY
|
||||
import com.tangem.datasource.local.preferences.utils.CleanupKeyMigration
|
||||
import com.tangem.datasource.local.preferences.utils.SharedPreferencesKeyMigration
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.SupervisorJob
|
||||
|
|
@ -77,6 +79,7 @@ internal object PreferencesDataStore {
|
|||
legacyKeyName = LEGACY_DEFAULT_KEY_NAME,
|
||||
keyName = PreferencesKeys.BALANCE_HIDING_SETTINGS_KEY.name,
|
||||
),
|
||||
CleanupKeyMigration(key = APP_LOGS_KEY),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
package com.tangem.datasource.local.preferences.utils
|
||||
|
||||
import androidx.datastore.core.DataMigration
|
||||
import androidx.datastore.preferences.core.Preferences
|
||||
|
||||
internal class CleanupKeyMigration<T>(private val key: Preferences.Key<T>) : DataMigration<Preferences> {
|
||||
|
||||
override suspend fun cleanUp() {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
override suspend fun shouldMigrate(currentData: Preferences): Boolean = currentData.contains(key)
|
||||
|
||||
override suspend fun migrate(currentData: Preferences): Preferences {
|
||||
currentData.toMutablePreferences().remove(key)
|
||||
return currentData
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue