Java Code Examples for android.content.RestrictionEntry#getKey()
The following examples show how to use
android.content.RestrictionEntry#getKey() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AppRestrictionSchemaFragment.java From enterprise-samples with Apache License 2.0 | 6 votes |
private void resolveRestrictions() { RestrictionsManager manager = (RestrictionsManager) getActivity().getSystemService(Context.RESTRICTIONS_SERVICE); Bundle restrictions = manager.getApplicationRestrictions(); List<RestrictionEntry> entries = manager.getManifestRestrictions( getActivity().getApplicationContext().getPackageName()); for (RestrictionEntry entry : entries) { String key = entry.getKey(); Log.d(TAG, "key: " + key); if (key.equals(KEY_CAN_SAY_HELLO)) { updateCanSayHello(entry, restrictions); } else if (key.equals(KEY_MESSAGE)) { updateMessage(entry, restrictions); } else if (key.equals(KEY_NUMBER)) { updateNumber(entry, restrictions); } else if (key.equals(KEY_RANK)) { updateRank(entry, restrictions); } else if (key.equals(KEY_APPROVALS)) { updateApprovals(entry, restrictions); } else if (key.equals(KEY_ITEMS)) { updateItems(restrictions); } } }
Example 2
Source File: AppRestrictionSchemaFragment.java From android-AppRestrictionSchema with Apache License 2.0 | 6 votes |
private void resolveRestrictions() { RestrictionsManager manager = (RestrictionsManager) getActivity().getSystemService(Context.RESTRICTIONS_SERVICE); Bundle restrictions = manager.getApplicationRestrictions(); List<RestrictionEntry> entries = manager.getManifestRestrictions( getActivity().getApplicationContext().getPackageName()); for (RestrictionEntry entry : entries) { String key = entry.getKey(); Log.d(TAG, "key: " + key); if (key.equals(KEY_CAN_SAY_HELLO)) { updateCanSayHello(entry, restrictions); } else if (key.equals(KEY_MESSAGE)) { updateMessage(entry, restrictions); } else if (key.equals(KEY_NUMBER)) { updateNumber(entry, restrictions); } else if (key.equals(KEY_RANK)) { updateRank(entry, restrictions); } else if (key.equals(KEY_APPROVALS)) { updateApprovals(entry, restrictions); } else if (key.equals(KEY_ITEMS)) { updateItems(restrictions); } } }
Example 3
Source File: AppRestrictionEnforcerFragment.java From enterprise-samples with Apache License 2.0 | 5 votes |
/** * Loads the restrictions for the AppRestrictionSchema sample. * * @param activity The activity */ private void loadRestrictions(Activity activity) { RestrictionsManager manager = (RestrictionsManager) activity.getSystemService(Context.RESTRICTIONS_SERVICE); List<RestrictionEntry> restrictions = manager.getManifestRestrictions(Constants.PACKAGE_NAME_APP_RESTRICTION_SCHEMA); SharedPreferences prefs = activity.getSharedPreferences(PREFS_KEY, Context.MODE_PRIVATE); for (RestrictionEntry restriction : restrictions) { String key = restriction.getKey(); if (RESTRICTION_KEY_SAY_HELLO.equals(key)) { updateCanSayHello(prefs.getBoolean(RESTRICTION_KEY_SAY_HELLO, restriction.getSelectedState())); } else if (RESTRICTION_KEY_MESSAGE.equals(key)) { updateMessage(prefs.getString(RESTRICTION_KEY_MESSAGE, restriction.getSelectedString())); } else if (RESTRICTION_KEY_NUMBER.equals(key)) { updateNumber(prefs.getInt(RESTRICTION_KEY_NUMBER, restriction.getIntValue())); } else if (RESTRICTION_KEY_RANK.equals(key)) { updateRank(activity, restriction.getChoiceValues(), prefs.getString(RESTRICTION_KEY_RANK, restriction.getSelectedString())); } else if (RESTRICTION_KEY_APPROVALS.equals(key)) { updateApprovals(activity, restriction.getChoiceValues(), TextUtils.split(prefs.getString(RESTRICTION_KEY_APPROVALS, TextUtils.join(DELIMETER, restriction.getAllSelectedStrings())), DELIMETER)); } else if (BUNDLE_SUPPORTED && RESTRICTION_KEY_ITEMS.equals(key)) { String itemsString = prefs.getString(RESTRICTION_KEY_ITEMS, ""); HashMap<String, String> items = new HashMap<>(); for (String itemString : TextUtils.split(itemsString, DELIMETER)) { String[] strings = itemString.split(SEPARATOR, 2); items.put(strings[0], strings[1]); } updateItems(activity, items); } } }
Example 4
Source File: AppRestrictionEnforcerFragment.java From android-AppRestrictionEnforcer with Apache License 2.0 | 5 votes |
/** * Loads the restrictions for the AppRestrictionSchema sample. * * @param activity The activity */ private void loadRestrictions(Activity activity) { RestrictionsManager manager = (RestrictionsManager) activity.getSystemService(Context.RESTRICTIONS_SERVICE); List<RestrictionEntry> restrictions = manager.getManifestRestrictions(Constants.PACKAGE_NAME_APP_RESTRICTION_SCHEMA); SharedPreferences prefs = activity.getSharedPreferences(PREFS_KEY, Context.MODE_PRIVATE); for (RestrictionEntry restriction : restrictions) { String key = restriction.getKey(); if (RESTRICTION_KEY_SAY_HELLO.equals(key)) { updateCanSayHello(prefs.getBoolean(RESTRICTION_KEY_SAY_HELLO, restriction.getSelectedState())); } else if (RESTRICTION_KEY_MESSAGE.equals(key)) { updateMessage(prefs.getString(RESTRICTION_KEY_MESSAGE, restriction.getSelectedString())); } else if (RESTRICTION_KEY_NUMBER.equals(key)) { updateNumber(prefs.getInt(RESTRICTION_KEY_NUMBER, restriction.getIntValue())); } else if (RESTRICTION_KEY_RANK.equals(key)) { updateRank(activity, restriction.getChoiceValues(), prefs.getString(RESTRICTION_KEY_RANK, restriction.getSelectedString())); } else if (RESTRICTION_KEY_APPROVALS.equals(key)) { updateApprovals(activity, restriction.getChoiceValues(), TextUtils.split(prefs.getString(RESTRICTION_KEY_APPROVALS, TextUtils.join(DELIMETER, restriction.getAllSelectedStrings())), DELIMETER)); } else if (BUNDLE_SUPPORTED && RESTRICTION_KEY_ITEMS.equals(key)) { String itemsString = prefs.getString(RESTRICTION_KEY_ITEMS, ""); HashMap<String, String> items = new HashMap<>(); for (String itemString : TextUtils.split(itemsString, DELIMETER)) { String[] strings = itemString.split(SEPARATOR, 2); items.put(strings[0], strings[1]); } updateItems(activity, items); } } }
Example 5
Source File: ManagedConfigurationsFragment.java From android-testdpc with Apache License 2.0 | 4 votes |
private void showEditDialog(final RestrictionEntry restrictionEntry) { mEditingRestrictionEntry = restrictionEntry; int type = KeyValuePairDialogFragment.DialogType.BOOL_TYPE; Object value = null; String key = ""; if (restrictionEntry != null) { key = restrictionEntry.getKey(); type = getTypeIndexFromRestrictionType(restrictionEntry.getType()); switch (restrictionEntry.getType()) { case RestrictionEntry.TYPE_BOOLEAN: value = restrictionEntry.getSelectedState(); break; case RestrictionEntry.TYPE_INTEGER: value = restrictionEntry.getIntValue(); break; case RestrictionEntry.TYPE_STRING: value = restrictionEntry.getSelectedString(); break; case RestrictionEntry.TYPE_MULTI_SELECT: value = restrictionEntry.getAllSelectedStrings(); break; case RestrictionEntry.TYPE_BUNDLE: value = RestrictionManagerCompat.convertRestrictionsToBundle(Arrays.asList( getRestrictionEntries(restrictionEntry))); break; case RestrictionEntry.TYPE_BUNDLE_ARRAY: RestrictionEntry[] restrictionEntries = getRestrictionEntries(restrictionEntry); Bundle[] bundles = new Bundle[restrictionEntries.length]; for (int i = 0; i < restrictionEntries.length; i++) { bundles[i] = RestrictionManagerCompat.convertRestrictionsToBundle(Arrays.asList( getRestrictionEntries(restrictionEntries[i]))); } value = bundles; break; } } int[] supportType = (Util.SDK_INT < VERSION_CODES.M) ? SUPPORTED_TYPES_PRE_M : SUPPORTED_TYPES; KeyValuePairDialogFragment dialogFragment = KeyValuePairDialogFragment.newInstance(type, true, key, value, supportType, getCurrentAppName()); dialogFragment.setTargetFragment(this, RESULT_CODE_EDIT_DIALOG); dialogFragment.show(getFragmentManager(), "dialog"); }
Example 6
Source File: ManagedConfigurationsFragment.java From android-testdpc with Apache License 2.0 | 4 votes |
@Override protected String getDisplayName(RestrictionEntry entry) { return entry.getKey(); }