diff --git a/vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt b/vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt index d3ef36a80b..a0fe525d3e 100755 --- a/vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt +++ b/vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt @@ -239,6 +239,20 @@ 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. + */ + + public fun subscribeToChanges(listener: SharedPreferences.OnSharedPreferenceChangeListener) { + defaultPrefs.registerOnSharedPreferenceChangeListener(listener) + } + + public fun unsubscribeToChanges(listener: SharedPreferences.OnSharedPreferenceChangeListener) { + defaultPrefs.unregisterOnSharedPreferenceChangeListener(listener) + } /** * Clear the preferences.