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

Commit 2f85e4a4 authored by Danny Baumann's avatar Danny Baumann
Browse files

Factor out preference-in-storage check to overridable method.

Change-Id: I2fff3192802f8a180330fda66388eda394334a5a
parent f3e9f427
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -1312,10 +1312,18 @@ public class Preference implements Comparable<Preference>, OnDependencyChangeLis
        mDefaultValue = defaultValue;
    }
    
    /**
     * Returns whether the preference can be found in persistent storage
     * @hide
     */
    protected boolean isPersisted() {
        return getSharedPreferences().contains(mKey);
    }

    private void dispatchSetInitialValue() {
        // By now, we know if we are persistent.
        final boolean shouldPersist = shouldPersist();
        if (!shouldPersist || !getSharedPreferences().contains(mKey)) {
        if (!shouldPersist || !isPersisted()) {
            if (mDefaultValue != null) {
                onSetInitialValue(false, mDefaultValue);
            }