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

Commit d7a236b5 authored by Danny Baumann's avatar Danny Baumann Committed by Matt Garnes
Browse files

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

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

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