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
This commit is contained in:
Michael Chan
2009-03-27 15:06:14 -07:00
committed by The Android Open Source Project
parent 88fb1069bf
commit e1e1cbfc41

View File

@@ -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();
}
}
/**