aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ui/src/main/java/com/wireguard/android/util/UserKnobs.kt
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2021-05-06 16:55:29 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2021-05-06 17:02:28 +0200
commit94ecb13d2fd9f36a10b0209b2ddf161b4cc0a07f (patch)
treeddf5437289149c6151a572dca889d8e4ebc9f61a /ui/src/main/java/com/wireguard/android/util/UserKnobs.kt
parentui: remove hack for broken kotlin compiler (diff)
downloadwireguard-android-94ecb13d2fd9f36a10b0209b2ddf161b4cc0a07f.tar.xz
wireguard-android-94ecb13d2fd9f36a10b0209b2ddf161b4cc0a07f.zip
ui: update datastore and rework api
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'ui/src/main/java/com/wireguard/android/util/UserKnobs.kt')
-rw-r--r--ui/src/main/java/com/wireguard/android/util/UserKnobs.kt22
1 files changed, 11 insertions, 11 deletions
diff --git a/ui/src/main/java/com/wireguard/android/util/UserKnobs.kt b/ui/src/main/java/com/wireguard/android/util/UserKnobs.kt
index b0107ebf..a983bf5a 100644
--- a/ui/src/main/java/com/wireguard/android/util/UserKnobs.kt
+++ b/ui/src/main/java/com/wireguard/android/util/UserKnobs.kt
@@ -5,16 +5,16 @@
package com.wireguard.android.util
-import androidx.datastore.preferences.edit
-import androidx.datastore.preferences.preferencesKey
-import androidx.datastore.preferences.preferencesSetKey
-import androidx.datastore.preferences.remove
+import androidx.datastore.preferences.core.booleanPreferencesKey
+import androidx.datastore.preferences.core.edit
+import androidx.datastore.preferences.core.stringPreferencesKey
+import androidx.datastore.preferences.core.stringSetPreferencesKey
import com.wireguard.android.Application
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.map
object UserKnobs {
- private val DISABLE_KERNEL_MODULE = preferencesKey<Boolean>("disable_kernel_module")
+ private val DISABLE_KERNEL_MODULE = booleanPreferencesKey("disable_kernel_module")
val disableKernelModule: Flow<Boolean>
get() = Application.getPreferencesDataStore().data.map {
it[DISABLE_KERNEL_MODULE] ?: false
@@ -29,31 +29,31 @@ object UserKnobs {
}
}
- private val MULTIPLE_TUNNELS = preferencesKey<Boolean>("multiple_tunnels")
+ private val MULTIPLE_TUNNELS = booleanPreferencesKey("multiple_tunnels")
val multipleTunnels: Flow<Boolean>
get() = Application.getPreferencesDataStore().data.map {
it[MULTIPLE_TUNNELS] ?: false
}
- private val DARK_THEME = preferencesKey<Boolean>("dark_theme")
+ private val DARK_THEME = booleanPreferencesKey("dark_theme")
val darkTheme: Flow<Boolean>
get() = Application.getPreferencesDataStore().data.map {
it[DARK_THEME] ?: false
}
- private val ALLOW_REMOTE_CONTROL_INTENTS = preferencesKey<Boolean>("allow_remote_control_intents")
+ private val ALLOW_REMOTE_CONTROL_INTENTS = booleanPreferencesKey("allow_remote_control_intents")
val allowRemoteControlIntents: Flow<Boolean>
get() = Application.getPreferencesDataStore().data.map {
it[ALLOW_REMOTE_CONTROL_INTENTS] ?: false
}
- private val RESTORE_ON_BOOT = preferencesKey<Boolean>("restore_on_boot")
+ private val RESTORE_ON_BOOT = booleanPreferencesKey("restore_on_boot")
val restoreOnBoot: Flow<Boolean>
get() = Application.getPreferencesDataStore().data.map {
it[RESTORE_ON_BOOT] ?: false
}
- private val LAST_USED_TUNNEL = preferencesKey<String>("last_used_tunnel")
+ private val LAST_USED_TUNNEL = stringPreferencesKey("last_used_tunnel")
val lastUsedTunnel: Flow<String?>
get() = Application.getPreferencesDataStore().data.map {
it[LAST_USED_TUNNEL]
@@ -68,7 +68,7 @@ object UserKnobs {
}
}
- private val RUNNING_TUNNELS = preferencesSetKey<String>("enabled_configs")
+ private val RUNNING_TUNNELS = stringSetPreferencesKey("enabled_configs")
val runningTunnels: Flow<Set<String>>
get() = Application.getPreferencesDataStore().data.map {
it[RUNNING_TUNNELS] ?: emptySet()