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

Commit e1e1cbfc authored by Michael Chan's avatar Michael Chan Committed by The Android Open Source Project
Browse files

AI 143150: Fixed the problem where setEnabled(false) has no effect from onResume().

  The problem was that the Preference widget was reenabled when its dependency
  was in enabled state. The enabled field was basically overloaded.  The fix was
  to add an additional field to keep track of whether its dependencies were met.
  BUG=1653960

Automated import of CL 143150
parent 88fb1069
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -92,6 +92,7 @@ public class Preference implements Comparable<Preference>, OnDependencyChangeLis
    private boolean mPersistent = true;
    private String mDependencyKey;
    private Object mDefaultValue;
    private boolean mDependencyMet = true;
    
    /**
     * @see #setShouldDisableView(boolean)
@@ -594,7 +595,7 @@ public class Preference implements Comparable<Preference>, OnDependencyChangeLis
     * @return True if this Preference is enabled, false otherwise.
     */
    public boolean isEnabled() {
        return mEnabled;
        return mEnabled && mDependencyMet;
    }

    /**
@@ -1096,7 +1097,14 @@ public class Preference implements Comparable<Preference>, OnDependencyChangeLis
     * @param disableDependent Set true to disable this Preference.
     */
    public void onDependencyChanged(Preference dependency, boolean disableDependent) {
        setEnabled(!disableDependent);
        if (mDependencyMet == disableDependent) {
            mDependencyMet = !disableDependent;

            // Enabled state can change dependent preferences' states, so notify
            notifyDependencyChange(shouldDisableDependents());

            notifyChanged();
        }
    }
    
    /**