use of android.support.v7.preference.ListPreference in project android_packages_apps_OmniGears by omnirom.
the class VolumeSteps method updateVolumeStepPrefs.
private void updateVolumeStepPrefs(Preference pref, int steps) {
if (pref == null || !(pref instanceof ListPreference)) {
return;
}
final ListPreference listPref = (ListPreference) pref;
listPref.setValue(String.valueOf(steps));
listPref.setSummary(listPref.getEntry());
}
use of android.support.v7.preference.ListPreference in project android_packages_apps_OmniGears by omnirom.
the class NetworkTraffic method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.network_traffic);
loadResources();
PreferenceScreen prefScreen = getPreferenceScreen();
ContentResolver resolver = getActivity().getContentResolver();
mNetTrafficState = (ListPreference) prefScreen.findPreference(NETWORK_TRAFFIC_STATE);
mNetTrafficUnit = (ListPreference) prefScreen.findPreference(NETWORK_TRAFFIC_UNIT);
mNetTrafficPeriod = (ListPreference) prefScreen.findPreference(NETWORK_TRAFFIC_PERIOD);
mNetTrafficAutohideThreshold = (SeekBarPreference) prefScreen.findPreference(NETWORK_TRAFFIC_AUTOHIDE_THRESHOLD);
// TrafficStats will return UNSUPPORTED if the device does not support it.
if (TrafficStats.getTotalTxBytes() != TrafficStats.UNSUPPORTED && TrafficStats.getTotalRxBytes() != TrafficStats.UNSUPPORTED) {
mNetTrafficVal = Settings.System.getInt(resolver, Settings.System.NETWORK_TRAFFIC_STATE, 0);
int intIndex = mNetTrafficVal & (MASK_UP + MASK_DOWN);
intIndex = mNetTrafficState.findIndexOfValue(String.valueOf(intIndex));
mNetTrafficState.setValueIndex(intIndex >= 0 ? intIndex : 0);
mNetTrafficState.setSummary(mNetTrafficState.getEntry());
mNetTrafficState.setOnPreferenceChangeListener(this);
mNetTrafficUnit.setValueIndex(getBit(mNetTrafficVal, MASK_UNIT) ? 1 : 0);
mNetTrafficUnit.setSummary(mNetTrafficUnit.getEntry());
mNetTrafficUnit.setOnPreferenceChangeListener(this);
int period = (mNetTrafficVal & MASK_PERIOD) >>> 16;
int periodIndex = mNetTrafficPeriod.findIndexOfValue(String.valueOf(period));
mNetTrafficPeriod.setValueIndex(periodIndex >= 0 ? periodIndex : 1);
mNetTrafficPeriod.setSummary(mNetTrafficPeriod.getEntry());
mNetTrafficPeriod.setOnPreferenceChangeListener(this);
int netTrafficAutohideThreshold = Settings.System.getInt(getContentResolver(), Settings.System.NETWORK_TRAFFIC_AUTOHIDE_THRESHOLD, 10);
mNetTrafficAutohideThreshold.setValue(netTrafficAutohideThreshold / 1);
mNetTrafficAutohideThreshold.setOnPreferenceChangeListener(this);
}
}
use of android.support.v7.preference.ListPreference in project android_packages_apps_OmniGears by omnirom.
the class StatusbarBatterySettings method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.statusbar_battery_settings);
PreferenceScreen prefScreen = getPreferenceScreen();
ContentResolver resolver = getActivity().getContentResolver();
mBatteryStyle = (ListPreference) findPreference(STATUSBAR_BATTERY_STYLE);
mBatteryStyleValue = Settings.System.getInt(resolver, Settings.System.STATUSBAR_BATTERY_STYLE, 0);
mBatteryStyle.setValue(Integer.toString(mBatteryStyleValue));
mBatteryStyle.setSummary(mBatteryStyle.getEntry());
mBatteryStyle.setOnPreferenceChangeListener(this);
mChargingColor = (ColorSelectPreference) prefScreen.findPreference(STATUSBAR_CHARGING_COLOR);
int chargingColor = Settings.System.getInt(resolver, Settings.System.STATUSBAR_BATTERY_CHARGING_COLOR, 0xFFFFFFFF);
mChargingColor.setColor(chargingColor);
String hexColor = String.format("#%08X", chargingColor);
mChargingColor.setSummary(hexColor);
mChargingColor.setOnPreferenceChangeListener(this);
mPercentInside = findPreference(STATUSBAR_BATTERY_PERCENT_INSIDE);
mBatteryPercent = (ListPreference) findPreference(STATUSBAR_BATTERY_PERCENT);
final int systemShowPercent = Settings.System.getInt(resolver, Settings.System.SHOW_BATTERY_PERCENT, 0);
int showPercent = Settings.System.getInt(resolver, Settings.System.STATUSBAR_BATTERY_PERCENT, systemShowPercent);
int forceShowPercent = Settings.System.getInt(resolver, Settings.System.STATUSBAR_BATTERY_FORCE_PERCENT, 0);
int batteryPercentValue = 0;
if (showPercent == 1) {
batteryPercentValue = 1;
} else if (forceShowPercent == 1) {
batteryPercentValue = 2;
}
mBatteryPercent.setValue(Integer.toString(batteryPercentValue));
mBatteryPercent.setSummary(mBatteryPercent.getEntry());
mBatteryPercent.setOnPreferenceChangeListener(this);
mShowBolt = findPreference(STATUSBAR_BATTERY_SHOW_BOLT);
// updateEnablement();
}
use of android.support.v7.preference.ListPreference in project android_packages_apps_OmniGears by omnirom.
the class OmniJawsSettings method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.omnijaws_settings);
final PreferenceScreen prefScreen = getPreferenceScreen();
mWeatherCategory = (PreferenceCategory) prefScreen.findPreference(CATEGORY_WEATHER);
if (mWeatherCategory != null && !isOmniJawsServiceInstalled()) {
prefScreen.removePreference(mWeatherCategory);
} else {
String settingHeaderPackage = Settings.System.getString(getContentResolver(), Settings.System.OMNIJAWS_WEATHER_ICON_PACK);
if (settingHeaderPackage == null) {
settingHeaderPackage = DEFAULT_WEATHER_ICON_PACKAGE + "." + DEFAULT_WEATHER_ICON_PREFIX;
}
mWeatherIconPack = (ListPreference) findPreference(WEATHER_ICON_PACK);
List<String> entries = new ArrayList<String>();
List<String> values = new ArrayList<String>();
getAvailableWeatherIconPacks(entries, values);
mWeatherIconPack.setEntries(entries.toArray(new String[entries.size()]));
mWeatherIconPack.setEntryValues(values.toArray(new String[values.size()]));
int valueIndex = mWeatherIconPack.findIndexOfValue(settingHeaderPackage);
if (valueIndex == -1) {
// no longer found
settingHeaderPackage = DEFAULT_WEATHER_ICON_PACKAGE + "." + DEFAULT_WEATHER_ICON_PREFIX;
Settings.System.putString(getContentResolver(), Settings.System.OMNIJAWS_WEATHER_ICON_PACK, settingHeaderPackage);
valueIndex = mWeatherIconPack.findIndexOfValue(settingHeaderPackage);
}
mWeatherIconPack.setValueIndex(valueIndex >= 0 ? valueIndex : 0);
mWeatherIconPack.setSummary(mWeatherIconPack.getEntry());
mWeatherIconPack.setOnPreferenceChangeListener(this);
}
}
use of android.support.v7.preference.ListPreference in project android_packages_apps_OmniGears by omnirom.
the class BarsSettings method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.bars_settings);
PreferenceScreen prefScreen = getPreferenceScreen();
mQuickPulldown = (ListPreference) findPreference(QUICK_PULLDOWN);
mQuickPulldown.setOnPreferenceChangeListener(this);
int quickPulldownValue = Settings.System.getInt(getContentResolver(), Settings.System.STATUS_BAR_QUICK_QS_PULLDOWN, 0);
mQuickPulldown.setValue(String.valueOf(quickPulldownValue));
updatePulldownSummary(quickPulldownValue);
// TrafficStats will return UNSUPPORTED if the device does not support it.
if (TrafficStats.getTotalTxBytes() == TrafficStats.UNSUPPORTED || TrafficStats.getTotalRxBytes() == TrafficStats.UNSUPPORTED) {
prefScreen.removePreference(findPreference(NETWORK_TRAFFIC_ROOT));
}
}
Aggregations