use of android.preference.PreferenceScreen in project AndroidChromium by JackyAndroid.
the class SingleWebsitePreferences method resetSite.
/**
* Resets the current site, clearing all permissions and storage used (inc. cookies).
*/
@VisibleForTesting
protected void resetSite() {
if (getActivity() == null)
return;
// Clear the screen.
// TODO(mvanouwerkerk): Refactor this class so that it does not depend on the screen state
// for its logic. This class should maintain its own data model, and only update the screen
// after a change is made.
PreferenceScreen screen = getPreferenceScreen();
for (String key : PERMISSION_PREFERENCE_KEYS) {
Preference preference = screen.findPreference(key);
if (preference != null)
screen.removePreference(preference);
}
// Clear the permissions.
mSite.setAutoplayPermission(ContentSetting.DEFAULT);
mSite.setBackgroundSyncPermission(ContentSetting.DEFAULT);
mSite.setCameraPermission(ContentSetting.DEFAULT);
mSite.setCookiePermission(ContentSetting.DEFAULT);
WebsitePreferenceBridge.nativeClearCookieData(mSite.getAddress().getTitle());
mSite.setFullscreenPermission(ContentSetting.DEFAULT);
mSite.setGeolocationPermission(ContentSetting.DEFAULT);
mSite.setJavaScriptPermission(ContentSetting.DEFAULT);
mSite.setKeygenPermission(ContentSetting.DEFAULT);
mSite.setMicrophonePermission(ContentSetting.DEFAULT);
mSite.setMidiPermission(ContentSetting.DEFAULT);
mSite.setNotificationPermission(ContentSetting.DEFAULT);
mSite.setPopupPermission(ContentSetting.DEFAULT);
mSite.setProtectedMediaIdentifierPermission(ContentSetting.DEFAULT);
for (UsbInfo info : mSite.getUsbInfo()) info.revoke();
// Clear the storage and finish the activity if necessary.
if (mSite.getTotalUsage() > 0) {
clearStoredData();
} else {
// Clearing stored data implies popping back to parent menu if there
// is nothing left to show. Therefore, we only need to explicitly
// close the activity if there's no stored data to begin with.
getActivity().finish();
}
}
use of android.preference.PreferenceScreen 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");
}
}
use of android.preference.PreferenceScreen in project zxing by zxing.
the class PreferencesFragment method onCreate.
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
addPreferencesFromResource(R.xml.preferences);
PreferenceScreen preferences = getPreferenceScreen();
preferences.getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
checkBoxPrefs = findDecodePrefs(preferences, PreferencesActivity.KEY_DECODE_1D_PRODUCT, PreferencesActivity.KEY_DECODE_1D_INDUSTRIAL, PreferencesActivity.KEY_DECODE_QR, PreferencesActivity.KEY_DECODE_DATA_MATRIX, PreferencesActivity.KEY_DECODE_AZTEC, PreferencesActivity.KEY_DECODE_PDF417);
disableLastCheckedPref();
EditTextPreference customProductSearch = (EditTextPreference) preferences.findPreference(PreferencesActivity.KEY_CUSTOM_PRODUCT_SEARCH);
customProductSearch.setOnPreferenceChangeListener(new CustomSearchURLValidator());
}
use of android.preference.PreferenceScreen in project KISS by Neamar.
the class SettingsActivity method onCreate.
@SuppressWarnings("deprecation")
@Override
protected void onCreate(Bundle savedInstanceState) {
prefs = PreferenceManager.getDefaultSharedPreferences(this);
String theme = prefs.getString("theme", "light");
if (theme.contains("dark")) {
setTheme(R.style.SettingThemeDark);
}
// Do it here to make the transition as smooth as possible
if (prefs.getBoolean("force-portrait", true)) {
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT);
} else {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
} else {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_USER);
}
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preferences);
ListPreference iconsPack = (ListPreference) findPreference("icons-pack");
setListPreferenceIconsPacksData(iconsPack);
fixSummaries();
addExcludedAppSettings(prefs);
addSearchProvidersSelector(prefs);
UiTweaks.updateThemePrimaryColor(this);
// Notification color can't be updated before Lollipop
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
PreferenceScreen screen = (PreferenceScreen) findPreference("ui-holder");
Preference pref = findPreference("notification-bar-color");
screen.removePreference(pref);
}
}
use of android.preference.PreferenceScreen in project kdeconnect-android by KDE.
the class SettingsActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final PreferenceScreen preferenceScreen = getPreferenceManager().createPreferenceScreen(this);
setPreferenceScreen(preferenceScreen);
if (getIntent().hasExtra("deviceId")) {
deviceId = getIntent().getStringExtra("deviceId");
}
BackgroundService.RunCommand(getApplicationContext(), new BackgroundService.InstanceCallback() {
@Override
public void onServiceStart(BackgroundService service) {
final Device device = service.getDevice(deviceId);
if (device == null) {
SettingsActivity.this.runOnUiThread(new Runnable() {
@Override
public void run() {
SettingsActivity.this.finish();
}
});
return;
}
List<String> plugins = device.getSupportedPlugins();
for (final String pluginKey : plugins) {
PluginPreference pref = new PluginPreference(SettingsActivity.this, pluginKey, device);
preferenceScreen.addPreference(pref);
}
}
});
}
Aggregations