Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a3431940 authored by Jacky Wang's avatar Jacky Wang
Browse files

[Catalyst] Add PreferenceLifecycleContext.findPreference

The API will be helpful for interactions between preference widgets.

Bug: 332201912
Flag: EXEMPT library
Test: N/A
Change-Id: I3087cd2635daad6712d9a278551b81da38018767
parent d8fca48d
Loading
Loading
Loading
Loading
+3 −0
Original line number Original line Diff line number Diff line
@@ -133,6 +133,9 @@ interface PreferenceLifecycleProvider {
 */
 */
abstract class PreferenceLifecycleContext(context: Context) : ContextWrapper(context) {
abstract class PreferenceLifecycleContext(context: Context) : ContextWrapper(context) {


    /** Returns the preference widget object associated with given key. */
    abstract fun <T> findPreference(key: String): T?

    /** Notifies that preference state of given key is changed and updates preference widget UI. */
    /** Notifies that preference state of given key is changed and updates preference widget UI. */
    abstract fun notifyPreferenceChange(key: String)
    abstract fun notifyPreferenceChange(key: String)


+3 −0
Original line number Original line Diff line number Diff line
@@ -57,6 +57,9 @@ class PreferenceScreenBindingHelper(


    private val preferenceLifecycleContext =
    private val preferenceLifecycleContext =
        object : PreferenceLifecycleContext(context) {
        object : PreferenceLifecycleContext(context) {
            override fun <T> findPreference(key: String) =
                preferenceScreen.findPreference(key) as T?

            override fun notifyPreferenceChange(key: String) =
            override fun notifyPreferenceChange(key: String) =
                notifyChange(key, CHANGE_REASON_STATE)
                notifyChange(key, CHANGE_REASON_STATE)