Commit 3d537b44 authored by Ricki Hirner's avatar Ricki Hirner 🐑

Settings: add force reload

parent 64c3ca96
......@@ -4,6 +4,8 @@ import at.bitfire.davdroid.settings.ISettingsObserver;
interface ISettings {
void forceReload();
boolean has(String key);
boolean getBoolean(String key, boolean defaultValue);
......
......@@ -33,6 +33,9 @@ open class DefaultsProvider(
override fun close() {
}
override fun forceReload() {
}
private fun hasKey(key: String) =
booleanDefaults.containsKey(key) ||
......
......@@ -12,6 +12,8 @@ import java.io.Closeable
interface Provider: Closeable {
fun forceReload()
fun has(key: String): Pair<Boolean, Boolean>
fun getBoolean(key: String): Pair<Boolean?, Boolean>
......
......@@ -51,6 +51,10 @@ class Settings: Service(), Provider.Observer {
}
fun forceReload() {
providers.forEach { it.forceReload() }
}
override fun onReload() {
observers.forEach {
Handler(Looper.getMainLooper()).post {
......@@ -149,6 +153,9 @@ class Settings: Service(), Provider.Observer {
val binder = object: ISettings.Stub() {
override fun forceReload() =
this@Settings.forceReload()
override fun has(key: String) =
this@Settings.has(key)
......
......@@ -39,6 +39,9 @@ class SharedPreferencesProvider(
override fun close() {
}
override fun forceReload() {
}
override fun has(key: String) =
Pair(preferences.contains(key), true)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment