mirror of
https://github.com/element-hq/element-android
synced 2024-11-24 18:35:40 +03:00
Merge pull request #2848 from vector-im/neilalexander/vectorpreferences
Add subscribeToChanges/unsubscribeToChanges to VectorPreferences
This commit is contained in:
commit
97cae9926b
1 changed files with 13 additions and 0 deletions
|
@ -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 a new issue