use of android.content.RestrictionEntry in project cw-omnibus by commonsguy.
the class RestrictionEntriesReceiver method onReceive.
@Override
public void onReceive(Context ctxt, Intent intent) {
Bundle current = (Bundle) intent.getParcelableExtra(Intent.EXTRA_RESTRICTIONS_BUNDLE);
ArrayList<RestrictionEntry> restrictions = new ArrayList<RestrictionEntry>();
restrictions.add(buildBooleanRestriction(ctxt, current));
restrictions.add(buildChoiceRestriction(ctxt, current));
restrictions.add(buildMultiSelectRestriction(ctxt, current));
Bundle result = new Bundle();
result.putParcelableArrayList(Intent.EXTRA_RESTRICTIONS_LIST, restrictions);
setResultExtras(result);
}
use of android.content.RestrictionEntry in project cw-omnibus by commonsguy.
the class RestrictionEntriesReceiver method buildChoiceRestriction.
private RestrictionEntry buildChoiceRestriction(Context ctxt, Bundle current) {
RestrictionEntry entry = new RestrictionEntry(RESTRICTION_CHOICE, current.getString(RESTRICTION_CHOICE));
entry.setTitle(ctxt.getString(R.string.choice_restriction_title));
entry.setChoiceEntries(ctxt, R.array.display_values);
entry.setChoiceValues(ctxt, R.array.restriction_values);
return (entry);
}
use of android.content.RestrictionEntry in project cw-omnibus by commonsguy.
the class RestrictionEntriesReceiver method buildMultiSelectRestriction.
private RestrictionEntry buildMultiSelectRestriction(Context ctxt, Bundle current) {
RestrictionEntry entry = new RestrictionEntry(RESTRICTION_MULTI, current.getStringArray(RESTRICTION_MULTI));
entry.setTitle("A Multi-Select Restriction");
entry.setChoiceEntries(ctxt, R.array.display_values);
entry.setChoiceValues(ctxt, R.array.restriction_values);
return (entry);
}
use of android.content.RestrictionEntry in project android_packages_apps_Settings by LineageOS.
the class AppRestrictionsFragment method addLocationAppRestrictionsPreference.
private void addLocationAppRestrictionsPreference(AppRestrictionsHelper.SelectableAppInfo app, AppRestrictionsPreference p) {
String packageName = app.packageName;
p.setIcon(R.drawable.ic_settings_location);
p.setKey(getKeyForPackage(packageName));
ArrayList<RestrictionEntry> restrictions = RestrictionUtils.getRestrictions(getActivity(), mUser);
RestrictionEntry locationRestriction = restrictions.get(0);
p.setTitle(locationRestriction.getTitle());
p.setRestrictions(restrictions);
p.setSummary(locationRestriction.getDescription());
p.setChecked(locationRestriction.getSelectedState());
p.setPersistent(false);
p.setOnPreferenceClickListener(this);
p.setOrder(MAX_APP_RESTRICTIONS);
mAppList.addPreference(p);
}
use of android.content.RestrictionEntry in project android_packages_apps_Settings by LineageOS.
the class AppRestrictionsFragment method onPreferenceChange.
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
String key = preference.getKey();
if (key != null && key.contains(DELIMITER)) {
StringTokenizer st = new StringTokenizer(key, DELIMITER);
final String packageName = st.nextToken();
final String restrictionKey = st.nextToken();
AppRestrictionsPreference appPref = (AppRestrictionsPreference) mAppList.findPreference(PKG_PREFIX + packageName);
ArrayList<RestrictionEntry> restrictions = appPref.getRestrictions();
if (restrictions != null) {
for (RestrictionEntry entry : restrictions) {
if (entry.getKey().equals(restrictionKey)) {
switch(entry.getType()) {
case RestrictionEntry.TYPE_BOOLEAN:
entry.setSelectedState((Boolean) newValue);
break;
case RestrictionEntry.TYPE_CHOICE:
case RestrictionEntry.TYPE_CHOICE_LEVEL:
ListPreference listPref = (ListPreference) preference;
entry.setSelectedString((String) newValue);
String readable = findInArray(entry.getChoiceEntries(), entry.getChoiceValues(), (String) newValue);
listPref.setSummary(readable);
break;
case RestrictionEntry.TYPE_MULTI_SELECT:
Set<String> set = (Set<String>) newValue;
String[] selectedValues = new String[set.size()];
set.toArray(selectedValues);
entry.setAllSelectedStrings(selectedValues);
break;
default:
continue;
}
mUserManager.setApplicationRestrictions(packageName, RestrictionsManager.convertRestrictionsToBundle(restrictions), mUser);
break;
}
}
}
return true;
}
return false;
}
Aggregations