Add simplified sliding sync toggle to developer options
This commit is contained in:
parent
f2378ca6ea
commit
34015b337e
13 changed files with 98 additions and 3 deletions
|
|
@ -28,5 +28,8 @@ interface AppPreferencesStore {
|
|||
suspend fun setTheme(theme: String)
|
||||
fun getThemeFlow(): Flow<String?>
|
||||
|
||||
suspend fun setSimplifiedSlidingSyncEnabled(enabled: Boolean)
|
||||
fun isSimplifiedSlidingSyncEnabledFlow(): Flow<Boolean>
|
||||
|
||||
suspend fun reset()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ private val Context.dataStore: DataStore<Preferences> by preferencesDataStore(na
|
|||
private val developerModeKey = booleanPreferencesKey("developerMode")
|
||||
private val customElementCallBaseUrlKey = stringPreferencesKey("elementCallBaseUrl")
|
||||
private val themeKey = stringPreferencesKey("theme")
|
||||
private val simplifiedSlidingSyncKey = booleanPreferencesKey("useSimplifiedSlidingSync")
|
||||
|
||||
@ContributesBinding(AppScope::class)
|
||||
class DefaultAppPreferencesStore @Inject constructor(
|
||||
|
|
@ -87,6 +88,18 @@ class DefaultAppPreferencesStore @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
override suspend fun setSimplifiedSlidingSyncEnabled(enabled: Boolean) {
|
||||
store.edit { prefs ->
|
||||
prefs[simplifiedSlidingSyncKey] = enabled
|
||||
}
|
||||
}
|
||||
|
||||
override fun isSimplifiedSlidingSyncEnabledFlow(): Flow<Boolean> {
|
||||
return store.data.map { prefs ->
|
||||
prefs[simplifiedSlidingSyncKey] ?: false
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun reset() {
|
||||
store.edit { it.clear() }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,10 +24,12 @@ class InMemoryAppPreferencesStore(
|
|||
isDeveloperModeEnabled: Boolean = false,
|
||||
customElementCallBaseUrl: String? = null,
|
||||
theme: String? = null,
|
||||
simplifiedSlidingSyncEnabled: Boolean = false
|
||||
) : AppPreferencesStore {
|
||||
private val isDeveloperModeEnabled = MutableStateFlow(isDeveloperModeEnabled)
|
||||
private val customElementCallBaseUrl = MutableStateFlow(customElementCallBaseUrl)
|
||||
private val theme = MutableStateFlow(theme)
|
||||
private val simplifiedSlidingSyncEnabled = MutableStateFlow(simplifiedSlidingSyncEnabled)
|
||||
|
||||
override suspend fun setDeveloperModeEnabled(enabled: Boolean) {
|
||||
isDeveloperModeEnabled.value = enabled
|
||||
|
|
@ -53,6 +55,14 @@ class InMemoryAppPreferencesStore(
|
|||
return theme
|
||||
}
|
||||
|
||||
override suspend fun setSimplifiedSlidingSyncEnabled(enabled: Boolean) {
|
||||
simplifiedSlidingSyncEnabled.value = enabled
|
||||
}
|
||||
|
||||
override fun isSimplifiedSlidingSyncEnabledFlow(): Flow<Boolean> {
|
||||
return simplifiedSlidingSyncEnabled
|
||||
}
|
||||
|
||||
override suspend fun reset() {
|
||||
// No op
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue