Don't show Restrictions item if it has been disabled for the user.

Also don't show actual Restrictions content if the fragment was launched
through a different entry point.

Change-Id: I70cb76ca6f68a382e68219053e6f69e7f1fa0150
This commit is contained in:
Amith Yamasani
2013-07-22 16:51:39 -07:00
parent a28787a1cb
commit d5b1a291eb
2 changed files with 15 additions and 6 deletions

View File

@@ -488,7 +488,8 @@ public class Settings extends PreferenceActivity
target.remove(i);
}
} else if (id == R.id.restriction_settings) {
if (um.isLinkedUser()) {
if (um.isLinkedUser()
|| um.hasUserRestriction(UserManager.DISALLOW_APP_RESTRICTIONS)) {
target.remove(i);
}
}

View File

@@ -46,10 +46,15 @@ public class RestrictionSettings extends AppRestrictionsFragment {
private boolean mChallengeSucceeded;
private boolean mChallengeRequested;
private boolean mDisableSelf;
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
if (UserManager.get(getActivity()).hasUserRestriction(
UserManager.DISALLOW_APP_RESTRICTIONS)) {
mDisableSelf = true;
return;
}
init(icicle);
if (icicle != null) {
mChallengeSucceeded = icicle.getBoolean(KEY_CHALLENGE_SUCCEEDED, false);
@@ -60,7 +65,9 @@ public class RestrictionSettings extends AppRestrictionsFragment {
public void onResume() {
super.onResume();
ensurePin();
if (!mDisableSelf) {
ensurePin();
}
}
private void ensurePin() {
@@ -122,9 +129,10 @@ public class RestrictionSettings extends AppRestrictionsFragment {
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
menu.add(0, MENU_RESET, 0, R.string.restriction_menu_reset);
menu.add(0, MENU_CHANGE_PIN, 0, R.string.restriction_menu_change_pin);
if (!mDisableSelf) {
menu.add(0, MENU_RESET, 0, R.string.restriction_menu_reset);
menu.add(0, MENU_CHANGE_PIN, 0, R.string.restriction_menu_change_pin);
}
super.onCreateOptionsMenu(menu, inflater);
}