summaryrefslogtreecommitdiffstats
path: root/core/java/android/preference
diff options
context:
space:
mode:
authorMichael Chan <>2009-03-27 15:06:14 -0700
committerThe Android Open Source Project <initial-contribution@android.com>2009-03-27 15:06:14 -0700
commite1e1cbfc41c5c980b8d3f537afa1b9508625a10f (patch)
treec300c75005257e184ce84066a544c0f9da3931ad /core/java/android/preference
parent88fb1069bf254dc68c83546496592a9b5e739a07 (diff)
downloadframeworks_base-e1e1cbfc41c5c980b8d3f537afa1b9508625a10f.zip
frameworks_base-e1e1cbfc41c5c980b8d3f537afa1b9508625a10f.tar.gz
frameworks_base-e1e1cbfc41c5c980b8d3f537afa1b9508625a10f.tar.bz2
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
Diffstat (limited to 'core/java/android/preference')
-rw-r--r--core/java/android/preference/Preference.java12
1 files changed, 10 insertions, 2 deletions
diff --git a/core/java/android/preference/Preference.java b/core/java/android/preference/Preference.java
index a255438..fc39573 100644
--- a/core/java/android/preference/Preference.java
+++ b/core/java/android/preference/Preference.java
@@ -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();
+ }
}
/**