use of android.support.v7.preference.ListPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class CarrierLabel method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.carrier_label);
PreferenceScreen prefSet = getPreferenceScreen();
ContentResolver resolver = getActivity().getContentResolver();
int intColor;
String hexColor;
mShowCarrierLabel = (ListPreference) findPreference(STATUS_BAR_CARRIER);
int showCarrierLabel = Settings.System.getInt(resolver, Settings.System.STATUS_BAR_SHOW_CARRIER, 1);
mShowCarrierLabel.setValue(String.valueOf(showCarrierLabel));
mShowCarrierLabel.setSummary(mShowCarrierLabel.getEntry());
mShowCarrierLabel.setOnPreferenceChangeListener(this);
mCustomCarrierLabel = (PreferenceScreen) prefSet.findPreference(CUSTOM_CARRIER_LABEL);
mCarrierColorPicker = (ColorPickerPreference) findPreference(STATUS_BAR_CARRIER_COLOR);
mCarrierColorPicker.setOnPreferenceChangeListener(this);
intColor = Settings.System.getInt(getContentResolver(), Settings.System.STATUS_BAR_CARRIER_COLOR, DEFAULT_STATUS_CARRIER_COLOR);
hexColor = String.format("#%08x", (0xffffffff & intColor));
mCarrierColorPicker.setSummary(hexColor);
mCarrierColorPicker.setNewPreviewColor(intColor);
mStatusBarCarrierFontStyle = (ListPreference) findPreference(STATUS_BAR_CARRIER_FONT_STYLE);
mStatusBarCarrierFontStyle.setOnPreferenceChangeListener(this);
mStatusBarCarrierFontStyle.setValue(Integer.toString(Settings.System.getInt(resolver, Settings.System.STATUS_BAR_CARRIER_FONT_STYLE, 0)));
mStatusBarCarrierFontStyle.setSummary(mStatusBarCarrierFontStyle.getEntry());
mStatusBarCarrierSize = (SeekBarPreference) findPreference(STATUS_BAR_CARRIER_FONT_SIZE);
mStatusBarCarrierSize.setValue(Settings.System.getInt(getActivity().getContentResolver(), Settings.System.STATUS_BAR_CARRIER_FONT_SIZE, 10));
mStatusBarCarrierSize.setOnPreferenceChangeListener(this);
mHideCarrierMaxNotification = (SeekBarPreference) findPreference(HIDE_CARRIER_MAX_NOTIFICATION);
mHideCarrierMaxNotification.setValue(Settings.System.getInt(resolver, Settings.System.HIDE_CARRIER_MAX_NOTIFICATION, 1));
mHideCarrierMaxNotification.setOnPreferenceChangeListener(this);
updatepreferences();
updateCustomLabelTextSummary();
}
use of android.support.v7.preference.ListPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class VolumeSteps method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.volume_steps_settings);
mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
PreferenceScreen prefScreen = getPreferenceScreen();
mAvailableKeys = volume_map.keySet();
// remove invalid audio stream prefs
boolean isPhone = TelephonyManager.getDefault().getCurrentPhoneType() != TelephonyManager.PHONE_TYPE_NONE;
if (!isPhone) {
// remove telephony keys from available set
mAvailableKeys.removeAll(telephony_set);
for (String key : telephony_set) {
Preference toRemove = prefScreen.findPreference(key);
if (toRemove != null) {
prefScreen.removePreference(toRemove);
}
}
}
// check prefs for initial run of this fragment
final boolean firstRun = checkForFirstRun();
// entries array isn't translatable ugh
final String defEntry = getString(R.string.volume_steps_reset);
// initialize prefs: set defaults if first run, set listeners and update values
for (String key : mAvailableKeys) {
Preference pref = prefScreen.findPreference(key);
if (pref == null || !(pref instanceof ListPreference)) {
continue;
}
final ListPreference listPref = (ListPreference) pref;
int steps = mAudioManager.getStreamMaxVolume(volume_map.get(key));
if (firstRun) {
saveDefaultSteps(listPref, steps);
}
final int defSteps = getDefaultSteps(listPref);
CharSequence[] entries = new CharSequence[listPref.getEntries().length + 1];
CharSequence[] values = new CharSequence[listPref.getEntryValues().length + 1];
for (int i = 0; i < entries.length; i++) {
if (i == 0) {
entries[i] = defEntry;
values[i] = String.valueOf(defSteps);
continue;
}
entries[i] = listPref.getEntries()[i - 1];
values[i] = listPref.getEntryValues()[i - 1];
}
listPref.setEntries(entries);
listPref.setEntryValues(values);
updateVolumeStepPrefs(listPref, steps);
listPref.setOnPreferenceChangeListener(this);
}
}
use of android.support.v7.preference.ListPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class LockScreenWeatherSettings method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.lock_screen_weather_settings);
mResolver = getActivity().getContentResolver();
PreferenceScreen prefs = getPreferenceScreen();
mHideWeather = (ListPreference) findPreference(PREF_HIDE_WEATHER);
int hideWeather = Settings.System.getInt(mResolver, Settings.System.LOCK_SCREEN_WEATHER_HIDE_PANEL, 0);
mHideWeather.setValue(String.valueOf(hideWeather));
mHideWeather.setOnPreferenceChangeListener(this);
mNumberOfNotifications = (SeekBarPreference) findPreference(PREF_NUMBER_OF_NOTIFICATIONS);
int numberOfNotifications = Settings.System.getInt(mResolver, Settings.System.LOCK_SCREEN_WEATHER_NUMBER_OF_NOTIFICATIONS, 4);
mNumberOfNotifications.setValue(numberOfNotifications);
mNumberOfNotifications.setOnPreferenceChangeListener(this);
updatePreference();
initweathercat();
}
use of android.support.v7.preference.ListPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class LogoSettings method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.rr_logo);
PreferenceScreen prefSet = getPreferenceScreen();
int intColor;
String hexColor;
// RR logo color
mRRLogoColor = (ColorPickerPreference) prefSet.findPreference(KEY_RR_LOGO_COLOR);
mRRLogoColor.setOnPreferenceChangeListener(this);
intColor = Settings.System.getInt(getContentResolver(), Settings.System.STATUS_BAR_RR_LOGO_COLOR, 0xffffffff);
hexColor = String.format("#%08x", (0xffffffff & intColor));
mRRLogoColor.setSummary(hexColor);
mRRLogoColor.setNewPreviewColor(intColor);
mRRLogoStyle = (ListPreference) findPreference(KEY_RR_LOGO_STYLE);
int rrLogoStyle = Settings.System.getIntForUser(getContentResolver(), Settings.System.STATUS_BAR_RR_LOGO_STYLE, 0, UserHandle.USER_CURRENT);
mRRLogoStyle.setValue(String.valueOf(rrLogoStyle));
mRRLogoStyle.setSummary(mRRLogoStyle.getEntry());
mRRLogoStyle.setOnPreferenceChangeListener(this);
}
use of android.support.v7.preference.ListPreference in project android_packages_apps_Settings by LineageOS.
the class AppOpsDetails method refreshUi.
private boolean refreshUi() {
if (mPackageInfo == null) {
return false;
}
mPreferenceScreen.removeAll();
setAppHeader(mPackageInfo);
AppOpsState.OpsTemplate[] allTemplates = getTemplates();
for (AppOpsState.OpsTemplate tpl : allTemplates) {
List<AppOpsState.AppOpEntry> entries = mState.buildState(tpl, mPackageInfo.applicationInfo.uid, mPackageInfo.packageName, true);
for (final AppOpsState.AppOpEntry entry : entries) {
String perm = null;
int op = 0;
// Find the first permission with a known name
for (int i = 0; i < entry.getNumOpEntry() && perm == null; i++) {
op = entry.getOpEntry(i).getOp();
perm = AppOpsManager.opToPermission(op);
}
Drawable icon = getIconByPermission(perm);
if (icon == null && op != 0 && OP_ICONS.containsKey(op)) {
icon = getActivity().getDrawable(OP_ICONS.get(op));
}
if (icon == null) {
Log.e(TAG, "Failed to retrieve icon for permission: " + perm);
} else {
icon.setTint(Utils.getColorAttr(getActivity(), android.R.attr.colorControlNormal));
}
final AppOpsManager.OpEntry firstOp = entry.getOpEntry(0);
final int switchOp = AppOpsManager.opToSwitch(firstOp.getOp());
// ListPreference for 3 states: ask, allow, deny
if (AppOpsManager.isStrictOp(switchOp)) {
ListPreference listPref = getListPrefForEntry(entry, icon);
mPreferenceScreen.addPreference(listPref);
} else {
SwitchPreference switchPref = getSwitchPrefForEntry(entry, icon);
mPreferenceScreen.addPreference(switchPref);
}
}
}
if (mPreferenceScreen.getPreferenceCount() == 0) {
Preference noBlockablePermissionsPref = getNoBlockablePermissionsPref();
mPreferenceScreen.addPreference(noBlockablePermissionsPref);
}
return true;
}
Aggregations