use of android.support.v7.preference.ListPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class RecentsClearAll method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.rr_recents_clear_all_fragment);
final ContentResolver resolver = getContentResolver();
final PreferenceScreen prefSet = getPreferenceScreen();
final Resources res = getResources();
mRecentsClearAll = (SwitchPreference) prefSet.findPreference(SHOW_CLEAR_ALL_RECENTS);
mRecentsClearAll.setChecked(Settings.System.getIntForUser(resolver, Settings.System.SHOW_CLEAR_ALL_RECENTS, 1, UserHandle.USER_CURRENT) == 1);
mRecentsClearAll.setOnPreferenceChangeListener(this);
mRecentsClearAllLocation = (ListPreference) prefSet.findPreference(RECENTS_CLEAR_ALL_LOCATION);
int location = Settings.System.getIntForUser(resolver, Settings.System.RECENTS_CLEAR_ALL_LOCATION, 3, UserHandle.USER_CURRENT);
mRecentsClearAllLocation.setValue(String.valueOf(location));
mRecentsClearAllLocation.setSummary(mRecentsClearAllLocation.getEntry());
mRecentsClearAllLocation.setOnPreferenceChangeListener(this);
}
use of android.support.v7.preference.ListPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class QsPullDown method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.rr_qs_pulldown);
mContext = getActivity().getApplicationContext();
mContentRes = getActivity().getContentResolver();
final Resources res = getResources();
PreferenceScreen prefs = getPreferenceScreen();
ContentResolver resolver = getActivity().getContentResolver();
mSmartPulldown = (ListPreference) findPreference(PREF_SMART_PULLDOWN);
mSmartPulldown.setOnPreferenceChangeListener(this);
int smartPulldown = Settings.System.getInt(resolver, Settings.System.QS_SMART_PULLDOWN, 0);
mSmartPulldown.setValue(String.valueOf(smartPulldown));
updateSmartPulldownSummary(smartPulldown);
mQuickPulldown = (ListPreference) findPreference(STATUS_BAR_QUICK_QS_PULLDOWN);
int quickPulldown = CMSettings.System.getInt(resolver, CMSettings.System.STATUS_BAR_QUICK_QS_PULLDOWN, 0);
mQuickPulldown.setValue(String.valueOf(quickPulldown));
if (quickPulldown == 0) {
// quick pulldown deactivated
mQuickPulldown.setSummary(res.getString(R.string.status_bar_quick_qs_pulldown_off));
} else {
String direction = res.getString(quickPulldown == 2 ? R.string.status_bar_quick_qs_pulldown_left : R.string.status_bar_quick_qs_pulldown_right);
mQuickPulldown.setSummary(res.getString(R.string.status_bar_quick_qs_pulldown_summary, direction));
}
mQuickPulldown.setOnPreferenceChangeListener(this);
mQuickPulldownFp = (SystemSettingSwitchPreference) findPreference(PREF_QUICK_PULLDOWN_FP);
if (!getResources().getBoolean(com.android.internal.R.bool.config_supportSystemNavigationKeys)) {
getPreferenceScreen().removePreference(mQuickPulldownFp);
} else {
mQuickPulldownFp.setChecked((Settings.System.getInt(getContentResolver(), Settings.System.STATUS_BAR_QUICK_QS_PULLDOWN_FP, 0) == 1));
mQuickPulldownFp.setOnPreferenceChangeListener(this);
}
}
use of android.support.v7.preference.ListPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class AppRestrictionsFragment method onRestrictionsReceived.
private void onRestrictionsReceived(AppRestrictionsPreference preference, ArrayList<RestrictionEntry> restrictions) {
// Remove any earlier restrictions
removeRestrictionsForApp(preference);
// Non-custom-activity case - expand the restrictions in-place
int count = 1;
for (RestrictionEntry entry : restrictions) {
Preference p = null;
switch(entry.getType()) {
case RestrictionEntry.TYPE_BOOLEAN:
p = new SwitchPreference(getPrefContext());
p.setTitle(entry.getTitle());
p.setSummary(entry.getDescription());
((SwitchPreference) p).setChecked(entry.getSelectedState());
break;
case RestrictionEntry.TYPE_CHOICE:
case RestrictionEntry.TYPE_CHOICE_LEVEL:
p = new ListPreference(getPrefContext());
p.setTitle(entry.getTitle());
String value = entry.getSelectedString();
if (value == null) {
value = entry.getDescription();
}
p.setSummary(findInArray(entry.getChoiceEntries(), entry.getChoiceValues(), value));
((ListPreference) p).setEntryValues(entry.getChoiceValues());
((ListPreference) p).setEntries(entry.getChoiceEntries());
((ListPreference) p).setValue(value);
((ListPreference) p).setDialogTitle(entry.getTitle());
break;
case RestrictionEntry.TYPE_MULTI_SELECT:
p = new MultiSelectListPreference(getPrefContext());
p.setTitle(entry.getTitle());
((MultiSelectListPreference) p).setEntryValues(entry.getChoiceValues());
((MultiSelectListPreference) p).setEntries(entry.getChoiceEntries());
HashSet<String> set = new HashSet<>();
Collections.addAll(set, entry.getAllSelectedStrings());
((MultiSelectListPreference) p).setValues(set);
((MultiSelectListPreference) p).setDialogTitle(entry.getTitle());
break;
case RestrictionEntry.TYPE_NULL:
default:
}
if (p != null) {
p.setPersistent(false);
p.setOrder(preference.getOrder() + count);
// Store the restrictions key string as a key for the preference
p.setKey(preference.getKey().substring(PKG_PREFIX.length()) + DELIMITER + entry.getKey());
mAppList.addPreference(p);
p.setOnPreferenceChangeListener(AppRestrictionsFragment.this);
p.setIcon(R.drawable.empty_icon);
preference.mChildren.add(p);
count++;
}
}
preference.setRestrictions(restrictions);
if (// No visible restrictions
count == 1 && preference.isImmutable() && preference.isChecked()) {
// Special case of required app with no visible restrictions. Remove it
mAppList.removePreference(preference);
}
}
use of android.support.v7.preference.ListPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
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;
}
use of android.support.v7.preference.ListPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class RecentsUI method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.rr_recents_ui);
final ContentResolver resolver = getContentResolver();
final PreferenceScreen prefScreen = getPreferenceScreen();
final Resources res = getResources();
mImmersiveRecents = (ListPreference) findPreference(IMMERSIVE_RECENTS);
mImmersiveRecents.setValue(String.valueOf(Settings.System.getInt(getContentResolver(), Settings.System.IMMERSIVE_RECENTS, 0)));
mImmersiveRecents.setSummary(mImmersiveRecents.getEntry());
mImmersiveRecents.setOnPreferenceChangeListener(this);
}
Aggregations