mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-02 21:32:34 +00:00
Add simplified sliding sync toggle to developer options
This commit is contained in:
+3
@@ -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()
|
||||
}
|
||||
|
||||
+13
@@ -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() }
|
||||
}
|
||||
|
||||
+10
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user