use of android.support.v7.preference.CheckBoxPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ApplicationSettings method onCreate.
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
addPreferencesFromResource(R.xml.application_settings);
mToggleAdvancedSettings = (CheckBoxPreference) findPreference(KEY_TOGGLE_ADVANCED_SETTINGS);
mToggleAdvancedSettings.setChecked(isAdvancedSettingsEnabled());
getPreferenceScreen().removePreference(mToggleAdvancedSettings);
// not ready for prime time yet
if (false) {
getPreferenceScreen().removePreference(mInstallLocation);
}
mInstallLocation = (ListPreference) findPreference(KEY_APP_INSTALL_LOCATION);
// Is app default install location set?
boolean userSetInstLocation = (Settings.Global.getInt(getContentResolver(), Settings.Global.SET_INSTALL_LOCATION, 0) != 0);
if (!userSetInstLocation) {
getPreferenceScreen().removePreference(mInstallLocation);
} else {
mInstallLocation.setValue(getAppInstallLocation());
mInstallLocation.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
public boolean onPreferenceChange(Preference preference, Object newValue) {
String value = (String) newValue;
handleUpdateAppInstallLocation(value);
return false;
}
});
}
}
use of android.support.v7.preference.CheckBoxPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class KeyboardLayoutPickerFragment method createPreferenceHierarchy.
private PreferenceScreen createPreferenceHierarchy() {
PreferenceScreen root = getPreferenceManager().createPreferenceScreen(getActivity());
Context context = getActivity();
for (KeyboardLayout layout : mKeyboardLayouts) {
CheckBoxPreference pref = new CheckBoxPreference(getPrefContext());
pref.setTitle(layout.getLabel());
pref.setSummary(layout.getCollection());
root.addPreference(pref);
mPreferenceMap.put(pref, layout);
}
return root;
}
use of android.support.v7.preference.CheckBoxPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class LocationSettings method createPreferenceHierarchy.
private PreferenceScreen createPreferenceHierarchy() {
final SettingsActivity activity = (SettingsActivity) getActivity();
PreferenceScreen root = getPreferenceScreen();
if (root != null) {
root.removeAll();
}
addPreferencesFromResource(R.xml.location_settings);
root = getPreferenceScreen();
setupManagedProfileCategory(root);
mLocationMode = root.findPreference(KEY_LOCATION_MODE);
mLocationMode.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
activity.startPreferencePanel(LocationMode.class.getName(), null, R.string.location_mode_screen_title, null, LocationSettings.this, 0);
return true;
}
});
mAgpsEnabled = getActivity().getResources().getBoolean(R.bool.config_agps_enabled);
mAssistedGps = (CheckBoxPreference) root.findPreference(KEY_ASSISTED_GPS);
if (!mAgpsEnabled) {
root.removePreference(mAssistedGps);
}
if (mAssistedGps != null) {
mAssistedGps.setChecked(Settings.Global.getInt(getContentResolver(), Settings.Global.ASSISTED_GPS_ENABLED, 0) == 1);
}
mCategoryRecentLocationRequests = (PreferenceCategory) root.findPreference(KEY_RECENT_LOCATION_REQUESTS);
RecentLocationApps recentApps = new RecentLocationApps(activity);
List<RecentLocationApps.Request> recentLocationRequests = recentApps.getAppList();
List<Preference> recentLocationPrefs = new ArrayList<>(recentLocationRequests.size());
for (final RecentLocationApps.Request request : recentLocationRequests) {
DimmableIconPreference pref = new DimmableIconPreference(getPrefContext(), request.contentDescription);
pref.setIcon(request.icon);
pref.setTitle(request.label);
if (request.isHighBattery) {
pref.setSummary(R.string.location_high_battery_use);
} else {
pref.setSummary(R.string.location_low_battery_use);
}
pref.setOnPreferenceClickListener(new PackageEntryClickedListener(request.packageName, request.userHandle));
recentLocationPrefs.add(pref);
}
if (recentLocationRequests.size() > 0) {
addPreferencesSorted(recentLocationPrefs, mCategoryRecentLocationRequests);
} else {
// If there's no item to display, add a "No recent apps" item.
Preference banner = new Preference(getPrefContext());
banner.setLayoutResource(R.layout.location_list_no_item);
banner.setTitle(R.string.location_no_recent_apps);
banner.setSelectable(false);
mCategoryRecentLocationRequests.addPreference(banner);
}
boolean lockdownOnLocationAccess = false;
// injected location services must not be shown.
if (mManagedProfile != null && mUm.hasUserRestriction(UserManager.DISALLOW_SHARE_LOCATION, mManagedProfile)) {
lockdownOnLocationAccess = true;
}
addLocationServices(activity, root, lockdownOnLocationAccess);
refreshLocationMode();
return root;
}
use of android.support.v7.preference.CheckBoxPreference 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.CheckBoxPreference in project AntennaPod by AntennaPod.
the class PreferenceController method buildAutodownloadSelectedNetworsPreference.
private void buildAutodownloadSelectedNetworsPreference() {
final Activity activity = ui.getActivity();
if (selectedNetworks != null) {
clearAutodownloadSelectedNetworsPreference();
}
// get configured networks
WifiManager wifiservice = (WifiManager) activity.getSystemService(Context.WIFI_SERVICE);
List<WifiConfiguration> networks = wifiservice.getConfiguredNetworks();
if (networks != null) {
Collections.sort(networks, new Comparator<WifiConfiguration>() {
@Override
public int compare(WifiConfiguration x, WifiConfiguration y) {
return x.SSID.compareTo(y.SSID);
}
});
selectedNetworks = new CheckBoxPreference[networks.size()];
List<String> prefValues = Arrays.asList(UserPreferences.getAutodownloadSelectedNetworks());
PreferenceScreen prefScreen = (PreferenceScreen) ui.findPreference(PreferenceController.AUTO_DL_PREF_SCREEN);
Preference.OnPreferenceClickListener clickListener = preference -> {
if (preference instanceof CheckBoxPreference) {
String key = preference.getKey();
List<String> prefValuesList = new ArrayList<>(Arrays.asList(UserPreferences.getAutodownloadSelectedNetworks()));
boolean newValue = ((CheckBoxPreference) preference).isChecked();
Log.d(TAG, "Selected network " + key + ". New state: " + newValue);
int index = prefValuesList.indexOf(key);
if (index >= 0 && !newValue) {
prefValuesList.remove(index);
} else if (index < 0 && newValue) {
prefValuesList.add(key);
}
UserPreferences.setAutodownloadSelectedNetworks(prefValuesList.toArray(new String[prefValuesList.size()]));
return true;
} else {
return false;
}
};
// value
for (int i = 0; i < networks.size(); i++) {
WifiConfiguration config = networks.get(i);
CheckBoxPreference pref = new CheckBoxPreference(activity);
String key = Integer.toString(config.networkId);
pref.setTitle(config.SSID);
pref.setKey(key);
pref.setOnPreferenceClickListener(clickListener);
pref.setPersistent(false);
pref.setChecked(prefValues.contains(key));
selectedNetworks[i] = pref;
prefScreen.addPreference(pref);
}
} else {
Log.e(TAG, "Couldn't get list of configure Wi-Fi networks");
}
}
Aggregations