use of android.support.v7.preference.ListPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class BatterySettings method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.rr_battery);
final ContentResolver resolver = getContentResolver();
final PreferenceScreen prefScreen = getPreferenceScreen();
final Resources res = getResources();
int intColor;
String hexColor;
int defaultColor = 0xffffffff;
int highColor = 0xff99CC00;
int lowColor = 0xffff4444;
mBatteryBar = (ListPreference) findPreference(PREF_BATT_BAR);
mBatteryBar.setOnPreferenceChangeListener(this);
mBatteryBar.setValue((Settings.System.getInt(resolver, Settings.System.STATUSBAR_BATTERY_BAR, 0)) + "");
mTextChargingSymbol = (ListPreference) findPreference(TEXT_CHARGING_SYMBOL);
mTextChargingSymbolValue = Settings.Secure.getInt(resolver, Settings.Secure.TEXT_CHARGING_SYMBOL, 0);
mTextChargingSymbol.setValue(Integer.toString(mTextChargingSymbolValue));
mTextChargingSymbol.setSummary(mTextChargingSymbol.getEntry());
mTextChargingSymbol.setOnPreferenceChangeListener(this);
mBatteryBarStyle = (ListPreference) findPreference(PREF_BATT_BAR_STYLE);
mBatteryBarStyle.setOnPreferenceChangeListener(this);
mBatteryBarStyle.setValue((Settings.System.getInt(resolver, Settings.System.STATUSBAR_BATTERY_BAR_STYLE, 0)) + "");
mBatteryBarColor = (ColorPickerPreference) findPreference(PREF_BATT_BAR_COLOR);
mBatteryBarColor.setOnPreferenceChangeListener(this);
intColor = Settings.System.getInt(getActivity().getContentResolver(), Settings.System.STATUSBAR_BATTERY_BAR_COLOR, defaultColor);
hexColor = String.format("#%08x", (0xffffffff & intColor));
mBatteryBarColor.setSummary(hexColor);
mBatteryBarColor.setNewPreviewColor(intColor);
mBatteryBarChargingAnimation = (SwitchPreference) findPreference(PREF_BATT_ANIMATE);
mBatteryBarChargingAnimation.setChecked(Settings.System.getInt(resolver, Settings.System.STATUSBAR_BATTERY_BAR_ANIMATE, 0) == 1);
mBatteryBarThickness = (SeekBarPreference) findPreference(PREF_BATT_BAR_WIDTH);
int thick = (Settings.System.getInt(resolver, Settings.System.STATUSBAR_BATTERY_BAR_THICKNESS, 1));
mBatteryBarThickness.setValue(thick / 1);
mBatteryBarThickness.setOnPreferenceChangeListener(this);
mStatusBarBattery = (ListPreference) findPreference(STATUS_BAR_BATTERY_STYLE);
mStatusBarBatteryShowPercent = (ListPreference) findPreference(STATUS_BAR_SHOW_BATTERY_PERCENT);
int batteryStyle = CMSettings.System.getInt(resolver, CMSettings.System.STATUS_BAR_BATTERY_STYLE, 0);
mStatusBarBattery.setValue(String.valueOf(batteryStyle));
mStatusBarBattery.setSummary(mStatusBarBattery.getEntry());
mStatusBarBattery.setOnPreferenceChangeListener(this);
int batteryShowPercent = CMSettings.System.getInt(resolver, CMSettings.System.STATUS_BAR_SHOW_BATTERY_PERCENT, 0);
mStatusBarBatteryShowPercent.setValue(String.valueOf(batteryShowPercent));
mStatusBarBatteryShowPercent.setSummary(mStatusBarBatteryShowPercent.getEntry());
enableStatusBarBatteryDependents(batteryStyle);
mStatusBarBatteryShowPercent.setOnPreferenceChangeListener(this);
mBatteryBarChargingColor = (ColorPickerPreference) findPreference(PREF_BATT_BAR_CHARGING_COLOR);
mBatteryBarChargingColor.setOnPreferenceChangeListener(this);
intColor = Settings.System.getInt(getActivity().getContentResolver(), Settings.System.STATUSBAR_BATTERY_BAR_CHARGING_COLOR, defaultColor);
hexColor = String.format("#%08x", (0xffffffff & intColor));
mBatteryBarChargingColor.setSummary(hexColor);
mBatteryBarChargingColor.setNewPreviewColor(intColor);
mBatteryBarBatteryLowColor = (ColorPickerPreference) findPreference(STATUS_BAR_BAR_LOW_COLOR);
mBatteryBarBatteryLowColor.setOnPreferenceChangeListener(this);
intColor = Settings.System.getInt(getActivity().getContentResolver(), Settings.System.STATUSBAR_BATTERY_BAR_LOW_COLOR, defaultColor);
hexColor = String.format("#%08x", (0xffffffff & intColor));
mBatteryBarBatteryLowColor.setSummary(hexColor);
mBatteryBarBatteryLowColor.setNewPreviewColor(intColor);
mBatteryBarBatteryHighColor = (ColorPickerPreference) findPreference(STATUS_BAR_BAR_HIGH_COLOR);
mBatteryBarBatteryHighColor.setOnPreferenceChangeListener(this);
intColor = Settings.System.getInt(resolver, Settings.System.STATUSBAR_BATTERY_BAR_HIGH_COLOR, highColor);
hexColor = String.format("#%08x", (0xff99CC00 & intColor));
mBatteryBarBatteryHighColor.setSummary(hexColor);
mBatteryBarBatteryHighColor.setNewPreviewColor(intColor);
int chargeColor = Settings.Secure.getInt(resolver, Settings.Secure.STATUS_BAR_CHARGE_COLOR, Color.WHITE);
mChargeColor = (ColorPickerPreference) findPreference("status_bar_charge_color");
mChargeColor.setNewPreviewColor(chargeColor);
mChargeColor.setOnPreferenceChangeListener(this);
mBatteryBarBatteryLowColorWarn = (ColorPickerPreference) findPreference(STATUS_BAR_BATTERY_LOW_COLOR_WARNING);
mBatteryBarBatteryLowColorWarn.setOnPreferenceChangeListener(this);
intColor = Settings.System.getInt(resolver, Settings.System.STATUSBAR_BATTERY_BAR_BATTERY_LOW_COLOR_WARNING, defaultColor);
hexColor = String.format("#%08x", (0xffffffff & intColor));
mBatteryBarBatteryLowColorWarn.setSummary(hexColor);
mBatteryBarBatteryLowColorWarn.setNewPreviewColor(intColor);
mBatteryBarUseGradient = (SwitchPreference) findPreference(STATUS_BAR_USE_GRADIENT_COLOR);
mBatteryBarUseGradient.setChecked(Settings.System.getInt(resolver, Settings.System.STATUSBAR_BATTERY_BAR_USE_GRADIENT_COLOR, 0) == 1);
}
use of android.support.v7.preference.ListPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class AdvancedWifiSettings method initPreferences.
private void initPreferences() {
final Context context = getActivity();
Intent intent = new Intent(Credentials.INSTALL_AS_USER_ACTION);
intent.setClassName("com.android.certinstaller", "com.android.certinstaller.CertInstallerMain");
intent.putExtra(Credentials.EXTRA_INSTALL_AS_UID, android.os.Process.WIFI_UID);
Preference pref = findPreference(KEY_INSTALL_CREDENTIALS);
pref.setIntent(intent);
SwitchPreference enableHs2 = (SwitchPreference) findPreference(KEY_ENABLE_HS2);
if (enableHs2 != null && getResources().getBoolean(com.android.internal.R.bool.config_passpoint_setting_on)) {
enableHs2.setOnPreferenceClickListener(new OnPreferenceClickListener() {
public boolean onPreferenceClick(Preference preference) {
String key = preference.getKey();
if (KEY_ENABLE_HS2.equals(key)) {
Settings.Global.putInt(getContentResolver(), Settings.Global.WIFI_HOTSPOT2_ENABLED, ((SwitchPreference) preference).isChecked() ? 1 : 0);
}
return true;
}
});
enableHs2.setChecked(Settings.Global.getInt(getContentResolver(), Settings.Global.WIFI_HOTSPOT2_ENABLED, WIFI_HS2_DISABLED) == WIFI_HS2_ENABLED);
} else {
if (enableHs2 != null) {
getPreferenceScreen().removePreference(enableHs2);
}
}
Intent wifiDirectIntent = new Intent(context, com.android.settings.Settings.WifiP2pSettingsActivity.class);
Preference wifiDirectPref = findPreference(KEY_WIFI_DIRECT);
wifiDirectPref.setIntent(wifiDirectIntent);
// WpsDialog: Create the dialog like WifiSettings does.
Preference wpsPushPref = findPreference(KEY_WPS_PUSH);
wpsPushPref.setOnPreferenceClickListener(new OnPreferenceClickListener() {
public boolean onPreferenceClick(Preference arg0) {
WpsFragment wpsFragment = new WpsFragment(WpsInfo.PBC);
wpsFragment.show(getFragmentManager(), KEY_WPS_PUSH);
return true;
}
});
// WpsDialog: Create the dialog like WifiSettings does.
Preference wpsPinPref = findPreference(KEY_WPS_PIN);
wpsPinPref.setOnPreferenceClickListener(new OnPreferenceClickListener() {
public boolean onPreferenceClick(Preference arg0) {
WpsFragment wpsFragment = new WpsFragment(WpsInfo.DISPLAY);
wpsFragment.show(getFragmentManager(), KEY_WPS_PIN);
return true;
}
});
// Wifi extension requirement
Preference prioritySettingPref = findPreference(KEY_PRIORITY_SETTINGS);
if (prioritySettingPref != null) {
if (!getResources().getBoolean(R.bool.set_wifi_priority)) {
getPreferenceScreen().removePreference(prioritySettingPref);
}
} else {
Log.d(TAG, "Fail to get priority pref...");
}
ListPreference ccodePref = (ListPreference) findPreference(KEY_COUNTRY_CODE);
if (ccodePref != null) {
boolean hideWifiRegion = getResources().getBoolean(R.bool.config_hideWifiRegionCode);
if (hideWifiRegion) {
removePreference(KEY_COUNTRY_CODE);
} else {
ccodePref.setOnPreferenceChangeListener(this);
String value = mWifiManager.getCountryCode();
if (value != null) {
ccodePref.setValue(value);
} else {
Log.e(TAG, "Failed to fetch country code");
}
}
}
mAutoConnectEnablePref = (CheckBoxPreference) findPreference(KEY_AUTO_CONNECT_ENABLE);
if (mAutoConnectEnablePref != null) {
if (getResources().getBoolean(R.bool.config_auto_connect_wifi_enabled)) {
mAutoConnectEnablePref.setChecked(isAutoConnectEnabled());
mAutoConnectEnablePref.setOnPreferenceChangeListener(this);
} else {
getPreferenceScreen().removePreference(mAutoConnectEnablePref);
}
}
mCellularToWlanPref = (ListPreference) findPreference(KEY_CELLULAR_TO_WLAN);
if (mCellularToWlanPref != null) {
if (getResources().getBoolean(R.bool.cell_to_wifi)) {
int value = getCellularToWlanValue();
mCellularToWlanPref.setValue(String.valueOf(value));
updateCellToWlanSummary(mCellularToWlanPref, value);
mCellularToWlanPref.setOnPreferenceChangeListener(this);
} else {
getPreferenceScreen().removePreference(mCellularToWlanPref);
}
}
CheckBoxPreference wlanToCellularHintPref = (CheckBoxPreference) findPreference(KEY_WLAN_TO_CELLULAR_HINT);
if (wlanToCellularHintPref != null) {
if (getResources().getBoolean(R.bool.wifi_to_cell)) {
wlanToCellularHintPref.setChecked(isWlanToCellHintEnable());
wlanToCellularHintPref.setOnPreferenceChangeListener(this);
} else {
getPreferenceScreen().removePreference(wlanToCellularHintPref);
}
}
CheckBoxPreference notifyConnectedApPref = (CheckBoxPreference) findPreference(KEY_CONNECT_NOTIFY);
if (notifyConnectedApPref != null) {
if (getResources().getBoolean(R.bool.connect_to_cmcc_notify)) {
notifyConnectedApPref.setChecked(ifNotifyConnect());
notifyConnectedApPref.setOnPreferenceChangeListener(this);
} else {
getPreferenceScreen().removePreference(notifyConnectedApPref);
}
}
mCellularToWlanHintPref = (CheckBoxPreference) findPreference(KEY_CELLULAR_TO_WLAN_HINT);
if (mCellularToWlanHintPref != null) {
if (getResources().getBoolean(R.bool.cellular_to_wlan_hint)) {
mCellularToWlanHintPref.setChecked(isCellularToWlanHintEnable());
mCellularToWlanHintPref.setOnPreferenceChangeListener(this);
} else {
getPreferenceScreen().removePreference(mCellularToWlanHintPref);
}
}
}
use of android.support.v7.preference.ListPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ConfigureWifiSettings method initPreferences.
private void initPreferences() {
List<WifiConfiguration> configs = mWifiManager.getConfiguredNetworks();
if (configs == null || configs.size() == 0) {
removePreference(KEY_SAVED_NETWORKS);
}
if (!mWifiManager.hasCarrierConfiguredNetworks()) {
removePreference(KEY_CONNECT_CARRIER_NETWORKS);
} else {
SwitchPreference connectToCarrierNetworks = (SwitchPreference) findPreference(KEY_CONNECT_CARRIER_NETWORKS);
if (connectToCarrierNetworks != null) {
connectToCarrierNetworks.setChecked(Settings.Global.getInt(getContentResolver(), Settings.Global.WIFI_CONNECT_CARRIER_NETWORKS, 0) == 1);
}
}
SwitchPreference notifyOpenNetworks = (SwitchPreference) findPreference(KEY_NOTIFY_OPEN_NETWORKS);
notifyOpenNetworks.setChecked(Settings.Global.getInt(getContentResolver(), Settings.Global.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON, 0) == 1);
notifyOpenNetworks.setEnabled(mWifiManager.isWifiEnabled());
final Context context = getActivity();
if (avoidBadWifiConfig()) {
// Hide preference toggle, always avoid bad wifi networks.
removePreference(KEY_CELLULAR_FALLBACK);
} else {
// Show preference toggle, initialized based on current settings value.
boolean currentSetting = avoidBadWifiCurrentSettings();
SwitchPreference pref = (SwitchPreference) findPreference(KEY_CELLULAR_FALLBACK);
// change if the resources change, but if that happens the activity will be recreated...
if (pref != null) {
pref.setChecked(currentSetting);
}
}
mWifiAssistantPreference = (AppListSwitchPreference) findPreference(KEY_WIFI_ASSISTANT);
Collection<NetworkScorerAppManager.NetworkScorerAppData> scorers = NetworkScorerAppManager.getAllValidScorers(context);
if (UserManager.get(context).isAdminUser() && !scorers.isEmpty()) {
mWifiAssistantPreference.setOnPreferenceChangeListener(this);
initWifiAssistantPreference(scorers);
} else if (mWifiAssistantPreference != null) {
getPreferenceScreen().removePreference(mWifiAssistantPreference);
}
ListPreference sleepPolicyPref = (ListPreference) findPreference(KEY_SLEEP_POLICY);
if (sleepPolicyPref != null) {
if (Utils.isWifiOnly(context)) {
sleepPolicyPref.setEntries(R.array.wifi_sleep_policy_entries_wifi_only);
}
sleepPolicyPref.setOnPreferenceChangeListener(this);
int value = Settings.Global.getInt(getContentResolver(), Settings.Global.WIFI_SLEEP_POLICY, Settings.Global.WIFI_SLEEP_POLICY_NEVER);
String stringValue = String.valueOf(value);
sleepPolicyPref.setValue(stringValue);
updateSleepPolicySummary(sleepPolicyPref, stringValue);
}
}
use of android.support.v7.preference.ListPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class DevelopmentSettings method updateHdcpValues.
private void updateHdcpValues() {
ListPreference hdcpChecking = (ListPreference) findPreference(HDCP_CHECKING_KEY);
if (hdcpChecking != null) {
String currentValue = SystemProperties.get(HDCP_CHECKING_PROPERTY);
String[] values = getResources().getStringArray(R.array.hdcp_checking_values);
String[] summaries = getResources().getStringArray(R.array.hdcp_checking_summaries);
// Defaults to drm-only. Needs to match with R.array.hdcp_checking_values
int index = 1;
for (int i = 0; i < values.length; i++) {
if (currentValue.equals(values[i])) {
index = i;
break;
}
}
hdcpChecking.setValue(values[index]);
hdcpChecking.setSummary(summaries[index]);
hdcpChecking.setOnPreferenceChangeListener(this);
}
}
use of android.support.v7.preference.ListPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class DevelopmentSettings method addListPreference.
private ListPreference addListPreference(String prefKey) {
ListPreference pref = (ListPreference) findPreference(prefKey);
mAllPrefs.add(pref);
pref.setOnPreferenceChangeListener(this);
return pref;
}
Aggregations