summaryrefslogtreecommitdiff
path: root/packages/SettingsLib/src/com/android/settingslib/RestrictedPreferenceHelper.java
diff options
context:
space:
mode:
authorSudheer Shanka <sudheersai@google.com>2016-01-13 19:57:11 +0000
committerSudheer Shanka <sudheersai@google.com>2016-01-14 16:25:56 +0000
commitea088af5c12e25995a3992413c8f413abc22eeab (patch)
tree7005609c93ea4429d7bc2c158dc13042115f3ae1 /packages/SettingsLib/src/com/android/settingslib/RestrictedPreferenceHelper.java
parent0c57596905977e7243a9e4bae9dbf7a18742ec54 (diff)
Made changes to padlock support for preferences.
- Currently, if a preference is disabled by admin, we add a padlock and disable the preference. And now if the preference is enabled in some other place, the padlock is not removed. Updated RestrictedPreference to fix this behavior. - Made RestrictedPreferenceHelper and RestrictedPreferenceHelper.onAttachedToHierarchy public so that preferences in Settings can use these. - Put a check for null to avoid NullPointerException. - Removed a redundant statement. Change-Id: Ie88a761dc38c58a680c62b3703d2081c67462079
Diffstat (limited to 'packages/SettingsLib/src/com/android/settingslib/RestrictedPreferenceHelper.java')
-rw-r--r--packages/SettingsLib/src/com/android/settingslib/RestrictedPreferenceHelper.java30
1 files changed, 15 insertions, 15 deletions
diff --git a/packages/SettingsLib/src/com/android/settingslib/RestrictedPreferenceHelper.java b/packages/SettingsLib/src/com/android/settingslib/RestrictedPreferenceHelper.java
index f04150460309..06aba968ea9e 100644
--- a/packages/SettingsLib/src/com/android/settingslib/RestrictedPreferenceHelper.java
+++ b/packages/SettingsLib/src/com/android/settingslib/RestrictedPreferenceHelper.java
@@ -45,7 +45,7 @@ public class RestrictedPreferenceHelper {
private EnforcedAdmin mEnforcedAdmin;
private String mAttrUserRestriction = null;
- RestrictedPreferenceHelper(Context context, Preference preference,
+ public RestrictedPreferenceHelper(Context context, Preference preference,
AttributeSet attrs) {
mContext = context;
mPreference = preference;
@@ -54,21 +54,21 @@ public class RestrictedPreferenceHelper {
mRestrictedPadlockPadding = mContext.getResources().getDimensionPixelSize(
R.dimen.restricted_lock_icon_padding);
- mAttrUserRestriction = attrs.getAttributeValue(
- R.styleable.RestrictedPreference_userRestriction);
- final TypedArray attributes = context.obtainStyledAttributes(attrs,
- R.styleable.RestrictedPreference);
- final TypedValue userRestriction =
- attributes.peekValue(R.styleable.RestrictedPreference_userRestriction);
- CharSequence data = null;
- if (userRestriction != null && userRestriction.type == TypedValue.TYPE_STRING) {
- if (userRestriction.resourceId != 0) {
- data = context.getText(userRestriction.resourceId);
- } else {
- data = userRestriction.string;
+ if (attrs != null) {
+ final TypedArray attributes = context.obtainStyledAttributes(attrs,
+ R.styleable.RestrictedPreference);
+ final TypedValue userRestriction =
+ attributes.peekValue(R.styleable.RestrictedPreference_userRestriction);
+ CharSequence data = null;
+ if (userRestriction != null && userRestriction.type == TypedValue.TYPE_STRING) {
+ if (userRestriction.resourceId != 0) {
+ data = context.getText(userRestriction.resourceId);
+ } else {
+ data = userRestriction.string;
+ }
}
+ mAttrUserRestriction = data == null ? null : data.toString();
}
- mAttrUserRestriction = data == null ? null : data.toString();
}
/**
@@ -100,7 +100,7 @@ public class RestrictedPreferenceHelper {
/**
* Disable / enable if we have been passed the restriction in the xml.
*/
- protected void onAttachedToHierarchy() {
+ public void onAttachedToHierarchy() {
if (mAttrUserRestriction != null) {
checkRestrictionAndSetDisabled(mAttrUserRestriction, UserHandle.myUserId());
}