mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-01-18 04:26:02 +01:00
Merge pull request #2848 from vector-im/neilalexander/vectorpreferences
Add subscribeToChanges/unsubscribeToChanges to VectorPreferences
This commit is contained in:
commit
97cae9926b
@ -16,6 +16,7 @@
|
||||
package im.vector.app.features.settings
|
||||
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import android.media.RingtoneManager
|
||||
import android.net.Uri
|
||||
import android.provider.MediaStore
|
||||
@ -252,6 +253,18 @@ class VectorPreferences @Inject constructor(private val context: Context) {
|
||||
}
|
||||
|
||||
private val defaultPrefs = DefaultSharedPreferences.getInstance(context)
|
||||
|
||||
/**
|
||||
* Allow subscribing and unsubscribing to configuration changes. This is
|
||||
* particularly useful when you need to be notified of a configuration change
|
||||
* in a background service, e.g. for the P2P demos.
|
||||
*/
|
||||
fun subscribeToChanges(listener: SharedPreferences.OnSharedPreferenceChangeListener) {
|
||||
defaultPrefs.registerOnSharedPreferenceChangeListener(listener)
|
||||
}
|
||||
fun unsubscribeToChanges(listener: SharedPreferences.OnSharedPreferenceChangeListener) {
|
||||
defaultPrefs.unregisterOnSharedPreferenceChangeListener(listener)
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the preferences.
|
||||
|
Loading…
Reference in New Issue
Block a user