Java Code Examples for androidx.preference.Preference#setOnPreferenceChangeListener()
The following examples show how to use
androidx.preference.Preference#setOnPreferenceChangeListener() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LockScreenPolicyFragment.java From android-testdpc with Apache License 2.0 | 5 votes |
/** * Set an initial value. Updates the summary to match. */ private void setup(String key, Object adminSetting) { final Preference pref = findPreference(key); final DpcPreferenceBase dpcPref = (DpcPreferenceBase) pref; // Disable preferences that don't apply to the parent profile dpcPref.setCustomConstraint( () -> Keys.NOT_APPLICABLE_TO_PARENT.contains(key) && isParentProfileInstance() ? R.string.not_for_parent_profile : NO_CUSTOM_CONSTRIANT ); // We do not allow user to add trust agent config in pre-N devices in managed profile. if (Util.SDK_INT < VERSION_CODES.N && key.equals(Keys.SET_TRUST_AGENT_CONFIG)) { dpcPref.setAdminConstraint(DpcPreferenceHelper.ADMIN_DEVICE_OWNER); return; } // Set up initial state and possibly a descriptive summary of said state. if (pref instanceof EditTextPreference) { String stringValue = (adminSetting != null ? adminSetting.toString() : null); if (adminSetting instanceof Number && "0".equals(stringValue)) { stringValue = null; } ((EditTextPreference) pref).setText(stringValue); pref.setSummary(stringValue); } else if (pref instanceof TwoStatePreference) { ((TwoStatePreference) pref).setChecked((Boolean) adminSetting); } // Start listening for change events. pref.setOnPreferenceChangeListener(this); pref.setOnPreferenceClickListener(this); }
Example 2
Source File: SettingsActivity.java From Hauk with Apache License 2.0 | 5 votes |
private static void setChangeListeners(PreferenceManager manager, info.varden.hauk.system.preferences.Preference<?> preference, Preference.OnPreferenceChangeListener... listeners) { Preference pref = manager.findPreference(preference.getKey()); if (pref != null) { pref.setOnPreferenceChangeListener(new CascadeChangeListener(listeners)); } else { Log.wtf("Could not find setting for preference %s when setting OnPreferenceChangeListener", preference); //NON-NLS } }
Example 3
Source File: SketchPropertiesFragment.java From APDE with GNU General Public License v2.0 | 5 votes |
private static void bindPreferenceSummaryToValue(Preference preference) { // Set the listener to watch for value changes. preference.setOnPreferenceChangeListener(sBindPreferenceSummaryToValueListener); // Trigger the listener immediately with the preference's // current value. sBindPreferenceSummaryToValueListener.onPreferenceChange( preference, PreferenceManager.getDefaultSharedPreferences( preference.getContext()).getString(preference.getKey(), "")); }
Example 4
Source File: AppearancePreferenceFragment.java From AndroidPreferenceActivity with Apache License 2.0 | 5 votes |
@Override public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { addPreferencesFromResource(R.xml.appearance_preferences); Preference themePreference = findPreference(getString(R.string.theme_preference_key)); themePreference.setOnPreferenceChangeListener(createThemeChangeListener()); Preference toolbarElevationPreference = findPreference(getString(R.string.toolbar_elevation_preference_key)); toolbarElevationPreference .setOnPreferenceChangeListener(createToolbarElevationChangeListener()); Preference navigationWidthPreference = findPreference(getString(R.string.navigation_width_preference_key)); navigationWidthPreference .setOnPreferenceChangeListener(createNavigationWidthChangeListener()); Preference preferenceScreenElevationPreference = findPreference(getString(R.string.preference_screen_elevation_preference_key)); preferenceScreenElevationPreference .setOnPreferenceChangeListener(createPreferenceScreenElevationChangeListener()); Preference breadCrumbElevationPreference = findPreference(getString(R.string.bread_crumb_elevation_preference_key)); breadCrumbElevationPreference .setOnPreferenceChangeListener(createBreadCrumbElevationChangeListener()); Preference wizardButtonBarElevationPreference = findPreference(getString(R.string.wizard_button_bar_elevation_preference_key)); wizardButtonBarElevationPreference .setOnPreferenceChangeListener(createWizardButtonBarElevationChangeListener()); Preference preferenceFragmentButtonBarElevationPreference = findPreference( getString(R.string.preference_fragment_button_bar_elevation_preference_key)); preferenceFragmentButtonBarElevationPreference.setOnPreferenceChangeListener( createPreferenceFragmentButtonBarElevationChangeListener()); }
Example 5
Source File: PreferencesCommonFragment.java From InviZible with GNU General Public License v3.0 | 5 votes |
private void registerPreferences() { if (getActivity() == null) { return; } Preference swFixTTL = findPreference("pref_common_fix_ttl"); if (swFixTTL != null) { swFixTTL.setOnPreferenceChangeListener(this); SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity()); swFixTTL.setEnabled(!sharedPreferences.getBoolean("swUseModulesRoot", false)); } Preference prefTorSiteUnlockTether = findPreference("prefTorSiteUnlockTether"); if (prefTorSiteUnlockTether != null) { SharedPreferences shPref = PreferenceManager.getDefaultSharedPreferences(getActivity()); if (shPref.getBoolean("pref_common_tor_route_all", false)) { prefTorSiteUnlockTether.setEnabled(false); } else { prefTorSiteUnlockTether.setEnabled(true); } } ArrayList<Preference> preferences = new ArrayList<>(); preferences.add(findPreference("pref_common_tor_tethering")); preferences.add(findPreference("pref_common_tor_route_all")); preferences.add(findPreference("pref_common_itpd_tethering")); preferences.add(findPreference("pref_common_block_http")); preferences.add(findPreference("swUseModulesRoot")); preferences.add(findPreference("swWakelock")); preferences.add(findPreference("pref_common_local_eth_device_addr")); for (Preference preference : preferences) { if (preference != null) { preference.setOnPreferenceChangeListener(this); } } }
Example 6
Source File: BehaviorPreferenceFragment.java From AndroidPreferenceActivity with Apache License 2.0 | 5 votes |
@Override public void onCreatePreferences(final Bundle savedInstanceState, final String rootKey) { addPreferencesFromResource(R.xml.behavior_preferences); Preference overrideBackButtonPreference = findPreference(getString(R.string.override_navigation_icon_preference_key)); overrideBackButtonPreference .setOnPreferenceChangeListener(createOverrideBackButtonChangeListener()); Preference hideNavigationPreference = findPreference(getString(R.string.hide_navigation_preference_key)); hideNavigationPreference .setOnPreferenceChangeListener(createHideNavigationChangeListener()); }
Example 7
Source File: SettingsActivity.java From APDE with GNU General Public License v2.0 | 5 votes |
private static void bindPreferenceSummaryToValue(Preference preference) { //Don't bind the preference if it doesn't appear in this fragment if(preference != null) { // Set the listener to watch for value changes. preference.setOnPreferenceChangeListener(sBindPreferenceSummaryToValueListener); // Trigger the listener immediately with the preference's // current value. sBindPreferenceSummaryToValueListener.onPreferenceChange( preference, PreferenceManager.getDefaultSharedPreferences( preference.getContext()).getString(preference.getKey(), "")); } }
Example 8
Source File: BaseSettingFragment.java From hipda with GNU General Public License v2.0 | 5 votes |
protected static void bindPreferenceSummaryToValue(Preference preference) { // Set the listener to watch for value changes. if (preference == null) return; preference.setOnPreferenceChangeListener(sBindPreferenceSummaryToValueListener); // Trigger the listener immediately with the preference's // current value. if (preference instanceof CheckBoxPreference) { sBindPreferenceSummaryToValueListener.onPreferenceChange( preference, PreferenceManager.getDefaultSharedPreferences( preference.getContext()).getBoolean(preference.getKey(), false)); } else if (preference instanceof SwitchPreference) { sBindPreferenceSummaryToValueListener.onPreferenceChange( preference, PreferenceManager.getDefaultSharedPreferences( preference.getContext()).getBoolean(preference.getKey(), false)); } else if (preference instanceof MultiSelectListPreference) { sBindPreferenceSummaryToValueListener.onPreferenceChange( preference, PreferenceManager.getDefaultSharedPreferences( preference.getContext()).getStringSet(preference.getKey(), new HashSet<String>())); } else { sBindPreferenceSummaryToValueListener.onPreferenceChange( preference, PreferenceManager.getDefaultSharedPreferences( preference.getContext()).getString(preference.getKey(), "")); } }
Example 9
Source File: SettingsFragment.java From ground-android with Apache License 2.0 | 5 votes |
@Override public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { setPreferencesFromResource(R.xml.preferences, rootKey); for (String key : Keys.ALL_KEYS) { Preference preference = findPreference(key); if (preference == null) { throw new IllegalArgumentException("Key not found in preferences.xml: " + key); } preference.setOnPreferenceChangeListener(this); preference.setOnPreferenceClickListener(this); } }
Example 10
Source File: GAPreferenceFragment.java From green_android with GNU General Public License v3.0 | 5 votes |
protected void bindPreferenceSummaryToValue(final Preference preference) { preference.setOnPreferenceChangeListener(onPreferenceChanged); // Trigger the listener immediately with the preference's // current value. final String currentVal = cfg().getString(preference.getKey(), ""); onPreferenceChanged.onPreferenceChange(preference, currentVal); }
Example 11
Source File: PreferencesFastFragment.java From InviZible with GNU General Public License v3.0 | 4 votes |
private void changePreferencesWithVPNMode(Context context) { Preference pref_fast_all_through_tor = findPreference("pref_fast_all_through_tor"); if (pref_fast_all_through_tor != null) { //pref_fast_all_through_tor.setTitle(R.string.pref_fast_all_through_ipro); pref_fast_all_through_tor.setOnPreferenceChangeListener(this); } Preference pref_fast_block_http = findPreference("pref_fast_block_http"); if (pref_fast_block_http != null) { pref_fast_block_http.setOnPreferenceChangeListener(this); } SharedPreferences shPref = PreferenceManager.getDefaultSharedPreferences(context); Preference prefTorAppUnlock = findPreference("prefTorAppUnlock"); /*if (prefTorAppUnlock != null) { prefTorAppUnlock.setSummary(R.string.pref_fast_unlock_apps_with_ipro_summ); }*/ if (shPref.getBoolean("pref_fast_all_through_tor", true)) { if (prefTorAppUnlock != null) { prefTorAppUnlock.setEnabled(false); } } else { if (prefTorAppUnlock != null) { prefTorAppUnlock.setEnabled(true); } } /*Preference prefTorAppExclude = findPreference("prefTorAppExclude"); if (prefTorAppExclude != null) { prefTorAppExclude.setSummary(R.string.pref_fast_exclude_apps_from_ipro_summ); }*/ PreferenceCategory torSettingsCategory = findPreference("Tor Settings"); /*if (torSettingsCategory != null) { torSettingsCategory.setTitle(R.string.pref_fast_routing); }*/ List<Preference> preferencesList = new ArrayList<>(); preferencesList.add(findPreference("prefTorSiteUnlock")); preferencesList.add(findPreference("prefTorSiteExclude")); preferencesList.add(findPreference("pref_fast_site_refresh_interval")); for (Preference preference : preferencesList) { if (preference != null) { if (torSettingsCategory != null) { torSettingsCategory.removePreference(preference); } } } PreferenceCategory fastUpdateCategory = findPreference("fast_update"); Preference updateThroughTor = findPreference("pref_fast through_tor_update"); if (fastUpdateCategory != null && updateThroughTor != null) { fastUpdateCategory.removePreference(updateThroughTor); } }
Example 12
Source File: PreferenceFragment.java From AndroidMaterialPreferences with Apache License 2.0 | 4 votes |
@Override public final void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); initializeThemePreference(); SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity()); boolean showValueAsSummary = sharedPreferences .getBoolean(getString(R.string.show_value_as_summary_preference_key), true); boolean showDialogHeader = sharedPreferences .getBoolean(getString(R.string.show_dialog_header_preference_key), false); boolean showDialogButtonBarDivider = sharedPreferences .getBoolean(getString(R.string.show_dialog_button_bar_divider_preference_key), false); Preference showValueAsSummaryPreference = findPreference(getString(R.string.show_value_as_summary_preference_key)); showValueAsSummaryPreference .setOnPreferenceChangeListener(createShowValueAsSummaryListener()); Preference showDialogHeaderPreference = findPreference(getString(R.string.show_dialog_header_preference_key)); showDialogHeaderPreference.setOnPreferenceChangeListener(createShowDialogHeaderListener()); Preference showDialogButtonBarDividerPreference = findPreference(getString(R.string.show_dialog_button_bar_divider_preference_key)); showDialogButtonBarDividerPreference .setOnPreferenceChangeListener(createShowDialogButtonBarDividerListener()); dialogPreference = (DialogPreference) findPreference(getString(R.string.dialog_preference_key)); dialogPreference.showDialogHeader(showDialogHeader); dialogPreference.showDialogButtonBarDivider(showDialogButtonBarDivider); dialogPreference.setOnClickListener(createDialogPreferenceClickListener()); editTextPreference = (EditTextPreference) findPreference(getString(R.string.edit_text_preference_key)); editTextPreference.addValidator( Validators.notEmpty(getActivity(), R.string.not_empty_validator_error_message)); editTextPreference.showValueAsSummary(showValueAsSummary); editTextPreference.showDialogHeader(showDialogHeader); editTextPreference.showDialogButtonBarDivider(showDialogButtonBarDivider); listPreference = (ListPreference) findPreference(getString(R.string.list_preference_key)); listPreference.showValueAsSummary(showValueAsSummary); listPreference.showDialogHeader(showDialogHeader); listPreference.showDialogButtonBarDivider(showDialogButtonBarDivider); multiChoiceListPreference = (MultiChoiceListPreference) findPreference( getString(R.string.multi_choice_list_preference_key)); multiChoiceListPreference.showValueAsSummary(showValueAsSummary); multiChoiceListPreference.showDialogHeader(showDialogHeader); multiChoiceListPreference.showDialogButtonBarDivider(showDialogButtonBarDivider); seekBarPreference = (SeekBarPreference) findPreference(getString(R.string.seek_bar_preference_key)); seekBarPreference.showValueAsSummary(showValueAsSummary); seekBarPreference.showDialogHeader(showDialogHeader); seekBarPreference.showDialogButtonBarDivider(showDialogButtonBarDivider); numberPickerPreference = (NumberPickerPreference) findPreference( getString(R.string.number_picker_preference_key)); numberPickerPreference.showValueAsSummary(showValueAsSummary); numberPickerPreference.showDialogHeader(showDialogHeader); numberPickerPreference.showDialogButtonBarDivider(showDialogButtonBarDivider); digitPickerPreference = (DigitPickerPreference) findPreference( getString(R.string.digit_picker_preference_key)); digitPickerPreference.showValueAsSummary(showValueAsSummary); digitPickerPreference.showDialogHeader(showDialogHeader); digitPickerPreference.showDialogButtonBarDivider(showDialogButtonBarDivider); resolutionPreference = (ResolutionPreference) findPreference( getString(R.string.resolution_preference_key)); resolutionPreference.showValueAsSummary(showValueAsSummary); resolutionPreference.showDialogHeader(showDialogHeader); resolutionPreference.showDialogButtonBarDivider(showDialogButtonBarDivider); colorPalettePreference = (ColorPalettePreference) findPreference( getString(R.string.color_palette_preference_key)); colorPalettePreference.showValueAsSummary(showValueAsSummary); colorPalettePreference.showDialogHeader(showDialogHeader); colorPalettePreference.showDialogButtonBarDivider(showDialogButtonBarDivider); switchPreference = (SwitchPreference) findPreference(getString(R.string.switch_preference_key)); checkBoxPreference = (CheckBoxPreference) findPreference(getString(R.string.check_box_preference_key)); ActionPreference actionPreference = (ActionPreference) findPreference(getString(R.string.action_preference_key)); actionPreference.setOnPreferenceClickListener(createActionPreferenceClickListener()); adaptSwitchPreferenceSummary(showValueAsSummary); adaptCheckBoxPreferenceSummary(showValueAsSummary); }
Example 13
Source File: SettingsFragment.java From GeometricWeather with GNU Lesser General Public License v3.0 | 4 votes |
private void initBasicPart() { // background free. findPreference(getString(R.string.key_background_free)).setOnPreferenceChangeListener((preference, newValue) -> { boolean backgroundFree = (boolean) newValue; getSettingsOptionManager().setBackgroundFree(backgroundFree); PollingManager.resetNormalBackgroundTask(requireActivity(), false); if (!backgroundFree) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { new RunningInBackgroundODialog().show(getParentFragmentManager(), null); } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { new RunningInBackgroundDialog().show(getParentFragmentManager(), null); } } return true; }); // alert notification. findPreference(getString(R.string.key_alert_notification_switch)).setOnPreferenceChangeListener((p, newValue) -> { getSettingsOptionManager().setAlertPushEnabled((Boolean) newValue); return true; }); // precipitation notification. findPreference(getString(R.string.key_precipitation_notification_switch)).setOnPreferenceChangeListener((p, v) -> { getSettingsOptionManager().setPrecipitationPushEnabled((Boolean) v); return true; }); // update interval. Preference refreshRate = findPreference(getString(R.string.key_refresh_rate)); refreshRate.setSummary(getSettingsOptionManager().getUpdateInterval().getUpdateIntervalName(getActivity())); refreshRate.setOnPreferenceChangeListener((preference, newValue) -> { getSettingsOptionManager().setUpdateInterval(OptionMapper.getUpdateInterval((String) newValue)); preference.setSummary(getSettingsOptionManager().getUpdateInterval().getUpdateIntervalName(getActivity())); PollingManager.resetNormalBackgroundTask(requireActivity(), false); return true; }); // dark mode. Preference darkMode = findPreference(getString(R.string.key_dark_mode)); darkMode.setSummary(getSettingsOptionManager().getDarkMode().getDarkModeName(getActivity())); darkMode.setOnPreferenceChangeListener((preference, newValue) -> { getSettingsOptionManager().setDarkMode(OptionMapper.getDarkMode((String) newValue)); preference.setSummary(getSettingsOptionManager().getDarkMode().getDarkModeName(getActivity())); GeometricWeather.getInstance().resetDayNightMode(); GeometricWeather.getInstance().recreateAllActivities(); return true; }); // live wallpaper. findPreference(getString(R.string.key_live_wallpaper)).setOnPreferenceClickListener(preference -> { IntentHelper.startLiveWallpaperActivity((GeoActivity) requireActivity()); return true; }); // service provider. findPreference(getString(R.string.key_service_provider)).setOnPreferenceClickListener(preference -> { pushFragment(new ServiceProviderSettingsFragment(), preference.getKey()); return true; }); // unit. findPreference(getString(R.string.key_unit)).setOnPreferenceClickListener(preference -> { pushFragment(new UnitSettingsFragment(), preference.getKey()); return true; }); // appearance. findPreference(getString(R.string.key_appearance)).setOnPreferenceClickListener(preference -> { pushFragment(new AppearanceSettingsFragment(), preference.getKey()); return true; }); }
Example 14
Source File: RecipientPreferenceActivity.java From mollyim-android with GNU General Public License v3.0 | 4 votes |
@Override public void onCreate(Bundle icicle) { Log.i(TAG, "onCreate (fragment)"); super.onCreate(icicle); initializeRecipients(); this.canHaveSafetyNumber = recipient.get().isRegistered() && !recipient.get().isLocalNumber(); Preference customNotificationsPref = this.findPreference(PREFERENCE_CUSTOM_NOTIFICATIONS); if (NotificationChannels.supported()) { ((SwitchPreferenceCompat) customNotificationsPref).setChecked(recipient.get().getNotificationChannel() != null); customNotificationsPref.setOnPreferenceChangeListener(new CustomNotificationsChangedListener()); this.findPreference(PREFERENCE_MESSAGE_TONE).setDependency(PREFERENCE_CUSTOM_NOTIFICATIONS); this.findPreference(PREFERENCE_MESSAGE_VIBRATE).setDependency(PREFERENCE_CUSTOM_NOTIFICATIONS); if (recipient.get().getNotificationChannel() != null) { final Context context = requireContext(); new AsyncTask<Void, Void, Void>() { @Override protected Void doInBackground(Void... voids) { RecipientDatabase db = DatabaseFactory.getRecipientDatabase(getContext()); db.setMessageRingtone(recipient.getId(), NotificationChannels.getMessageRingtone(context, recipient.get())); db.setMessageVibrate(recipient.getId(), NotificationChannels.getMessageVibrate(context, recipient.get()) ? VibrateState.ENABLED : VibrateState.DISABLED); NotificationChannels.ensureCustomChannelConsistency(context); return null; } }.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR); } } else { customNotificationsPref.setVisible(false); } this.findPreference(PREFERENCE_MESSAGE_TONE) .setOnPreferenceChangeListener(new RingtoneChangeListener(false)); this.findPreference(PREFERENCE_MESSAGE_TONE) .setOnPreferenceClickListener(new RingtoneClickedListener(false)); this.findPreference(PREFERENCE_CALL_TONE) .setOnPreferenceChangeListener(new RingtoneChangeListener(true)); this.findPreference(PREFERENCE_CALL_TONE) .setOnPreferenceClickListener(new RingtoneClickedListener(true)); this.findPreference(PREFERENCE_MESSAGE_VIBRATE) .setOnPreferenceChangeListener(new VibrateChangeListener(false)); this.findPreference(PREFERENCE_CALL_VIBRATE) .setOnPreferenceChangeListener(new VibrateChangeListener(true)); this.findPreference(PREFERENCE_MUTED) .setOnPreferenceClickListener(new MuteClickedListener()); this.findPreference(PREFERENCE_BLOCK) .setOnPreferenceClickListener(new BlockClickedListener()); this.findPreference(PREFERENCE_COLOR) .setOnPreferenceChangeListener(new ColorChangeListener()); ((ContactPreference)this.findPreference(PREFERENCE_ABOUT)) .setListener(new AboutNumberClickedListener()); }
Example 15
Source File: PreferenceFragment.java From AndroidMaterialDialog with Apache License 2.0 | 4 votes |
/** * Initializes the preference, which allows to specfify, whether dialogs should be shown * fullscreen, or not. */ private void initializeFullscreenPreference() { Preference fullscreenPreference = findPreference(getString(R.string.fullscreen_preference_key)); fullscreenPreference.setOnPreferenceChangeListener(createThemeChangeListener()); }
Example 16
Source File: PreferencesFastFragment.java From InviZible with GNU General Public License v3.0 | 4 votes |
@Override public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (getActivity() == null) { return super.onCreateView(inflater, container, savedInstanceState); } getActivity().setTitle(R.string.drawer_menu_fastSettings); Preference prefDNSCryptServer = findPreference("prefDNSCryptServer"); if (prefDNSCryptServer != null) { prefDNSCryptServer.setSummary(new PrefManager(requireActivity()).getStrPref("DNSCrypt Servers")); } Preference swAutostartTor = findPreference("swAutostartTor"); if (swAutostartTor != null) { swAutostartTor.setOnPreferenceChangeListener(this); } Preference pref_fast_theme = findPreference("pref_fast_theme"); if (pref_fast_theme != null) { pref_fast_theme.setOnPreferenceChangeListener(this); } Preference pref_fast_language = findPreference("pref_fast_language"); if (pref_fast_language != null) { pref_fast_language.setOnPreferenceChangeListener(this); } if (ModulesStatus.getInstance().getMode() == ROOT_MODE) { changePreferencesWithRootMode(getActivity()); } else if (ModulesStatus.getInstance().getMode() == VPN_MODE) { changePreferencesWithVPNMode(getActivity()); } else { changePreferencesWithProxyMode(); } if (appVersion.startsWith("g")) { changePreferencesForGPVersion(); } else if (appVersion.endsWith("d")) { changePreferencesForFDVersion(); } return super.onCreateView(inflater, container, savedInstanceState); }
Example 17
Source File: PreferencesTorFragment.java From InviZible with GNU General Public License v3.0 | 4 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setRetainInstance(true); addPreferencesFromResource(R.xml.preferences_tor); if (appVersion.endsWith("p")) { changePreferencesForGPVersion(); } ArrayList<Preference> preferences = new ArrayList<>(); preferences.add(findPreference("VirtualAddrNetwork")); preferences.add(findPreference("AvoidDiskWrites")); preferences.add(findPreference("ConnectionPadding")); preferences.add(findPreference("ReducedConnectionPadding")); preferences.add(findPreference("ExcludeExitNodes")); preferences.add(findPreference("ExitNodes")); preferences.add(findPreference("ExcludeNodes")); preferences.add(findPreference("EntryNodes")); preferences.add(findPreference("StrictNodes")); preferences.add(findPreference("FascistFirewall")); preferences.add(findPreference("NewCircuitPeriod")); preferences.add(findPreference("MaxCircuitDirtiness")); preferences.add(findPreference("EnforceDistinctSubnets")); preferences.add(findPreference("Enable SOCKS proxy")); preferences.add(findPreference("SOCKSPort")); preferences.add(findPreference("Enable HTTPTunnel")); preferences.add(findPreference("HTTPTunnelPort")); preferences.add(findPreference("Enable Transparent proxy")); preferences.add(findPreference("TransPort")); preferences.add(findPreference("Enable DNS")); preferences.add(findPreference("DNSPort")); preferences.add(findPreference("ClientUseIPv4")); preferences.add(findPreference("ClientUseIPv6")); preferences.add(findPreference("pref_tor_snowflake_stun")); preferences.add(findPreference("pref_tor_isolate_dest_address")); preferences.add(findPreference("pref_tor_isolate_dest_port")); for (Preference preference : preferences) { if (preference != null) { preference.setOnPreferenceChangeListener(this); } else if (!appVersion.startsWith("g")) { Log.e(LOG_TAG, "PreferencesTorFragment preference is null exception"); } } Preference editTorConfDirectly = findPreference("editTorConfDirectly"); if (editTorConfDirectly != null) { editTorConfDirectly.setOnPreferenceClickListener(this); } Preference cleanTorFolder = findPreference("cleanTorFolder"); if (cleanTorFolder != null) { cleanTorFolder.setOnPreferenceClickListener(this); } if (getArguments() != null) { key_tor = getArguments().getStringArrayList("key_tor"); val_tor = getArguments().getStringArrayList("val_tor"); key_tor_orig = new ArrayList<>(key_tor); val_tor_orig = new ArrayList<>(val_tor); } }
Example 18
Source File: PreferencesITPDFragment.java From InviZible with GNU General Public License v3.0 | 4 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setRetainInstance(true); addPreferencesFromResource(R.xml.preferences_i2pd); if (appVersion.endsWith("p")) { changePreferencesForGPVersion(); } ArrayList<Preference> preferences = new ArrayList<>(); preferences.add(findPreference("Allow incoming connections")); preferences.add(findPreference("incoming port")); preferences.add(findPreference("incoming host")); preferences.add(findPreference("ipv4")); preferences.add(findPreference("ipv6")); preferences.add(findPreference("notransit")); preferences.add(findPreference("floodfill")); preferences.add(findPreference("bandwidth")); preferences.add(findPreference("share")); preferences.add(findPreference("ssu")); preferences.add(findPreference("ntcp")); preferences.add(findPreference("Enable ntcpproxy")); preferences.add(findPreference("ntcpproxy")); preferences.add(findPreference("HTTP proxy")); preferences.add(findPreference("HTTP proxy port")); preferences.add(findPreference("HTTP outproxy")); preferences.add(findPreference("HTTP outproxy address")); preferences.add(findPreference("Socks proxy")); preferences.add(findPreference("Socks proxy port")); preferences.add(findPreference("Socks outproxy")); preferences.add(findPreference("Socks outproxy address")); preferences.add(findPreference("Socks outproxy port")); preferences.add(findPreference("SAM interface")); preferences.add(findPreference("SAM interface port")); preferences.add(findPreference("elgamal")); preferences.add(findPreference("UPNP")); preferences.add(findPreference("ntcp2 enabled")); preferences.add(findPreference("verify")); preferences.add(findPreference("transittunnels")); preferences.add(findPreference("openfiles")); preferences.add(findPreference("coresize")); preferences.add(findPreference("ntcpsoft")); preferences.add(findPreference("ntcphard")); preferences.add(findPreference("defaulturl")); for (Preference preference : preferences) { if (preference != null) { preference.setOnPreferenceChangeListener(this); } else if (!appVersion.startsWith("g")){ Log.e(LOG_TAG, "PreferencesITPDFragment preference is null exception"); } } Preference editITPDConfDirectly = findPreference("editITPDConfDirectly"); if (editITPDConfDirectly != null) { editITPDConfDirectly.setOnPreferenceClickListener(this); } Preference editTunnelsDirectly = findPreference("editTunnelsDirectly"); if (editTunnelsDirectly != null) { editTunnelsDirectly.setOnPreferenceClickListener(this); } Preference cleanITPDFolder = findPreference("cleanITPDFolder"); if (cleanITPDFolder != null) { cleanITPDFolder.setOnPreferenceClickListener(this); } if (getArguments() != null) { key_itpd = getArguments().getStringArrayList("key_itpd"); val_itpd = getArguments().getStringArrayList("val_itpd"); key_itpd_orig = new ArrayList<>(key_itpd); val_itpd_orig = new ArrayList<>(val_itpd); } }
Example 19
Source File: PreferencesCommonFragment.java From InviZible with GNU General Public License v3.0 | 4 votes |
@Override public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (getActivity() == null) { super.onCreateView(inflater, container, savedInstanceState); } getActivity().setTitle(R.string.drawer_menu_commonSettings); PreferenceCategory others = findPreference("common_other"); Preference swShowNotification = findPreference("swShowNotification"); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { if (others != null && swShowNotification != null) { others.removePreference(swShowNotification); } } else { if (swShowNotification != null) { swShowNotification.setOnPreferenceChangeListener(this); } } if (ModulesStatus.getInstance().getMode() == ROOT_MODE) { registerPreferences(); } else { removePreferences(); } manageLANDeviceAddressPreference(); PreferenceCategory otherSettingsCategory = findPreference("common_other"); Preference shellControl = findPreference("pref_common_shell_control"); if (appVersion.startsWith("g")) { PreferenceCategory hotspotSettingsCategory = findPreference("HOTSPOT"); Preference blockHTTP = findPreference("pref_common_block_http"); if (hotspotSettingsCategory != null && blockHTTP != null) { hotspotSettingsCategory.removePreference(blockHTTP); } if (otherSettingsCategory != null && shellControl != null) { otherSettingsCategory.removePreference(shellControl); } } else if (shellControl != null){ shellControl.setSummary(String.format(getString(R.string.pref_common_shell_control_summ), getActivity().getPackageName())); } return super.onCreateView(inflater, container, savedInstanceState); }
Example 20
Source File: PreferenceFragment.java From AndroidMaterialPreferences with Apache License 2.0 | 4 votes |
/** * Initializes the preference, which allows to change the app's theme. */ private void initializeThemePreference() { Preference themePreference = findPreference(getString(R.string.theme_preference_key)); themePreference.setOnPreferenceChangeListener(createThemeChangeListener()); }