Java Code Examples for androidx.preference.Preference#setEnabled()
The following examples show how to use
androidx.preference.Preference#setEnabled() .
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: AppManagerAdvancedPreferences.java From commcare-android with Apache License 2.0 | 6 votes |
@Override protected void setupPrefClickListeners() { Preference enablePrivilegesButton = findPreference(ENABLE_PRIVILEGE); enablePrivilegesButton.setOnPreferenceClickListener(preference -> { FirebaseAnalyticsUtil.reportAdvancedActionSelected( AnalyticsParamValue.ENABLE_PRIVILEGES); launchPrivilegeClaimActivity(); return true; }); Preference clearUserDataButton = findPreference(CLEAR_USER_DATA); clearUserDataButton.setEnabled(!"".equals(CommCareApplication.instance().getCurrentUserId())); clearUserDataButton.setOnPreferenceClickListener(preference -> { FirebaseAnalyticsUtil.reportAdvancedActionSelected( AnalyticsParamValue.CLEAR_USER_DATA); AdvancedActionsPreferences.clearUserData(getActivity()); return true; }); Preference dataChangeLogs = findPreference(DATA_CHANGE_LOGS); dataChangeLogs.setOnPreferenceClickListener(preference -> { launchDataChangeLogsActivity(); return true; }); }
Example 2
Source File: EventPreferencesNFC.java From PhoneProfilesPlus with Apache License 2.0 | 6 votes |
@Override void checkPreferences(PreferenceManager prefMng, Context context) { boolean enabled = Event.isEventPreferenceAllowed(PREF_EVENT_NFC_ENABLED, context).allowed == PreferenceAllowed.PREFERENCE_ALLOWED; Preference nfcTagsPreference = prefMng.findPreference(PREF_EVENT_NFC_NFC_TAGS); Preference permanentRunPreference = prefMng.findPreference(PREF_EVENT_NFC_PERMANENT_RUN); Preference durationPreference = prefMng.findPreference(PREF_EVENT_NFC_DURATION); if (nfcTagsPreference != null) nfcTagsPreference.setEnabled(enabled); if (permanentRunPreference != null) permanentRunPreference.setEnabled(enabled); SharedPreferences preferences = prefMng.getSharedPreferences(); if (preferences != null) { boolean permanentRun = preferences.getBoolean(PREF_EVENT_NFC_PERMANENT_RUN, false); enabled = enabled && (!permanentRun); if (durationPreference != null) durationPreference.setEnabled(enabled); } }
Example 3
Source File: EventPreferencesNFC.java From PhoneProfilesPlus with Apache License 2.0 | 6 votes |
void setAllSummary(PreferenceManager prefMng, SharedPreferences preferences, Context context) { setSummary(prefMng, PREF_EVENT_NFC_ENABLED, preferences, context); setSummary(prefMng, PREF_EVENT_NFC_NFC_TAGS, preferences, context); setSummary(prefMng, PREF_EVENT_NFC_PERMANENT_RUN, preferences, context); setSummary(prefMng, PREF_EVENT_NFC_DURATION, preferences, context); if (Event.isEventPreferenceAllowed(PREF_EVENT_NFC_ENABLED, context).allowed != PreferenceAllowed.PREFERENCE_ALLOWED) { Preference preference = prefMng.findPreference(PREF_EVENT_NFC_ENABLED); if (preference != null) preference.setEnabled(false); preference = prefMng.findPreference(PREF_EVENT_NFC_NFC_TAGS); if (preference != null) preference.setEnabled(false); preference = prefMng.findPreference(PREF_EVENT_NFC_DURATION); if (preference != null) preference.setEnabled(false); } }
Example 4
Source File: SettingsActivity.java From VinylMusicPlayer with GNU General Public License v3.0 | 6 votes |
@Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { switch (key) { case PreferenceUtil.NOW_PLAYING_SCREEN_ID: updateNowPlayingScreenSummary(); break; case PreferenceUtil.CLASSIC_NOTIFICATION: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { findPreference("colored_notification").setEnabled(sharedPreferences.getBoolean(key, false)); } break; case PreferenceUtil.RG_SOURCE_MODE: Preference pref = findPreference("replaygain_preamp"); if (!sharedPreferences.getString(key, "none").equals("none")) { pref.setEnabled(true); pref.setSummary(R.string.pref_summary_rg_preamp); } else { pref.setEnabled(false); pref.setSummary(getResources().getString(R.string.pref_rg_disabled)); } break; } }
Example 5
Source File: SettingsActivity.java From GotoBrowser with GNU General Public License v3.0 | 5 votes |
private void saveQuotesFile(JsonObject item, Response<JsonObject> response) { String message = ""; String locale_code = item.get("locale_code").getAsString(); String commit = item.get("latest_commit").getAsString(); String filename = String.format(Locale.US, "quotes_%s.json", locale_code); JsonObject data = response.body(); String subtitle_folder = getContext().getFilesDir().getAbsolutePath().concat("/subtitle/"); String subtitle_path = subtitle_folder.concat(filename); File file = new File(subtitle_folder); try { if (!file.exists()) file.mkdirs(); if (data != null) { File subtitle_file = new File(subtitle_path); FileOutputStream fos = new FileOutputStream(subtitle_file); fos.write(data.toString().getBytes()); fos.close(); versionTable.putValue(filename, commit); Preference subtitleUpdate = findPreference(PREF_SUBTITLE_UPDATE); subtitleUpdate.setSummary(getString(R.string.setting_latest_version)); subtitleUpdate.setEnabled(false); } else { message = "No data to write: quotes_".concat(locale_code).concat(".json"); KcUtils.showToast(getContext(), message); } } catch (IOException e) { KcUtils.reportException(e); message = "IOException while saving quotes_".concat(locale_code).concat(".json"); KcUtils.showToast(getContext(), message); } }
Example 6
Source File: SettingsActivity.java From APDE with GNU General Public License v2.0 | 5 votes |
protected void updateSketchbookDrivePref(ListPreference sketchbookDrive, Preference sketchbookLocation, ArrayList<APDE.StorageDrive> drives) { int selectedIndex = sketchbookDrive.findIndexOfValue(sketchbookDrive.getValue()); if (selectedIndex == -1) { //Uh-oh return; } APDE.StorageDrive selected = drives.get(selectedIndex); sketchbookLocation.setEnabled(!(selected.type.equals(APDE.StorageDrive.StorageDriveType.INTERNAL) || selected.type.equals(APDE.StorageDrive.StorageDriveType.SECONDARY_EXTERNAL))); sketchbookDrive.setSummary(selected.space + " " + selected.type.title); }
Example 7
Source File: LocationPreferencesActivity.java From mage-android with Apache License 2.0 | 5 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final Context contextThemeWrapper = new ContextThemeWrapper(getActivity(), R.style.AppTheme); LayoutInflater localInflater = inflater.cloneInContext(contextThemeWrapper); if (!UserHelper.getInstance(context).isCurrentUserPartOfCurrentEvent()) { Preference reportLocationPreference = findPreference(getString(R.string.reportLocationKey)); reportLocationPreference.setEnabled(false); reportLocationPreference.setSummary("You are an administrator and not a member of the current event. You can not report your location in this event."); } return super.onCreateView(localInflater, container, savedInstanceState); }
Example 8
Source File: TalkBackPreferencesActivity.java From talkback with Apache License 2.0 | 5 votes |
/** * Updates the preferences state to match the actual state of touch exploration. This is called * once when the preferences activity launches and again whenever the actual state of touch * exploration changes. */ private void updateTouchExplorationState() { Activity activity = getActivity(); if (activity == null) { return; } final ContentResolver resolver = activity.getContentResolver(); final Resources res = getResources(); final SharedPreferences prefs = SharedPreferencesUtils.getSharedPreferences(activity); final boolean requestedState = SharedPreferencesUtils.getBooleanPref( prefs, res, R.string.pref_explore_by_touch_key, R.bool.pref_explore_by_touch_default); final boolean actualState; // If accessibility is disabled then touch exploration is always // disabled, so the "actual" state should just be the requested state. if (TalkBackService.isServiceActive()) { actualState = isTouchExplorationEnabled(resolver); } else { actualState = requestedState; } // Enable/disable preferences that depend on explore-by-touch. // Cannot use "dependency" attribute in preferences XML file, because touch-explore-preference // is in a different preference-activity (developer preferences). Preference singleTapPref = findPreferenceByResId(R.string.pref_single_tap_key); if (singleTapPref != null) { singleTapPref.setEnabled(actualState); } Preference tutorialPref = findPreferenceByResId(R.string.pref_tutorial_key); if (tutorialPref != null) { tutorialPref.setEnabled(actualState); } }
Example 9
Source File: PreferencesFastFragment.java From InviZible with GNU General Public License v3.0 | 5 votes |
private void changePreferencesWithRootMode(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.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); String refreshPeriod = shPref.getString("pref_fast_site_refresh_interval", "12"); refreshPeriodHours = Integer.parseInt(refreshPeriod); Preference prefTorSiteUnlock = findPreference("prefTorSiteUnlock"); Preference prefTorAppUnlock = findPreference("prefTorAppUnlock"); if (shPref.getBoolean("pref_fast_all_through_tor", true)) { if (prefTorSiteUnlock != null && prefTorAppUnlock != null) { prefTorSiteUnlock.setEnabled(false); prefTorAppUnlock.setEnabled(false); } } else { if (prefTorSiteUnlock != null && prefTorAppUnlock != null) { prefTorSiteUnlock.setEnabled(true); prefTorAppUnlock.setEnabled(true); } } }
Example 10
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 11
Source File: ProxyPreferenceChangeListener.java From Hauk with Apache License 2.0 | 5 votes |
@Override public boolean onPreferenceChange(Preference preference, Object newValue) { int choice = Integer.valueOf((String) newValue); boolean enable = choice != ProxyTypeResolver.SYSTEM_DEFAULT.getIndex() && choice != ProxyTypeResolver.DIRECT.getIndex(); for (Preference pref : this.prefsToDisable) { pref.setEnabled(enable); } return true; }
Example 12
Source File: AdvancedPreferenceFragment.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
@Override public void onCreate(Bundle paramBundle) { super.onCreate(paramBundle); initializeIdentitySelection(); Preference submitDebugLog = this.findPreference(SUBMIT_DEBUG_LOG_PREF); submitDebugLog.setOnPreferenceClickListener(new SubmitDebugLogListener()); submitDebugLog.setSummary(getVersion(getActivity())); submitDebugLog.setEnabled(TextSecurePreferences.isLogEnabled(getContext())); findPreference(TextSecurePreferences.LOG_ENABLED) .setOnPreferenceChangeListener(new EnableLogClickListener()); }
Example 13
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 14
Source File: MuzeiSettingsFragment.java From Mysplash with GNU Lesser General Public License v3.0 | 4 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.perference_muzei); MuzeiOptionManager manager = MuzeiOptionManager.getInstance(requireActivity()); // muzei source. ListPreference source = findPreference(getString(R.string.key_muzei_source)); source.setSummary( getNameByValue( manager.getSource(), R.array.muzei_sources, R.array.muzei_source_values ) ); source.setOnPreferenceChangeListener((preference, newValue) -> { manager.setSource((String) newValue); preference.setSummary( getNameByValue( manager.getSource(), R.array.muzei_sources, R.array.muzei_source_values ) ); findPreference(getString(R.string.key_muzei_collection_source)).setEnabled( manager.getSource().equals(MuzeiOptionManager.SOURCE_COLLECTIONS) ); return true; }); // screen size. SwitchPreference screenSizeImage = findPreference(getString(R.string.key_muzei_screen_size_image)); int[] size = MuzeiUpdateHelper.getScreenSize(requireActivity()); screenSizeImage.setSummaryOn(size[1] + "×" + size[0]); screenSizeImage.setSummaryOff(R.string.muzei_settings_title_screen_size_image_summary_off); screenSizeImage.setOnPreferenceChangeListener((preference, newValue) -> { manager.setScreenSizeImage((Boolean) newValue); return true; }); // cache mode. ListPreference cacheMode = findPreference(getString(R.string.key_muzei_cache_mode)); cacheMode.setSummary( getNameByValue( manager.getCacheMode(), R.array.muzei_cache_modes, R.array.muzei_cache_mode_values ) ); cacheMode.setOnPreferenceChangeListener((preference, newValue) -> { manager.setCacheMode((String) newValue); preference.setSummary( getNameByValue( manager.getCacheMode(), R.array.muzei_cache_modes, R.array.muzei_cache_mode_values ) ); return true; }); // collections. Preference collectionSource = findPreference(getString(R.string.key_muzei_collection_source)); collectionSource.setEnabled(manager.getSource().equals(MuzeiOptionManager.SOURCE_COLLECTIONS)); collectionSource.setOnPreferenceClickListener(preference -> { ComponentFactory.getMuzeiService() .startMuzeiCollectionSourceConfigActivity(requireActivity()); return true; }); // query. Preference query = findPreference(getString(R.string.key_muzei_query)); query.setSummary(manager.getQuery()); query.setOnPreferenceClickListener(preference -> { MuzeiQueryDialog dialog = new MuzeiQueryDialog(); dialog.setOnQueryChangedListener(query1 -> { MuzeiOptionManager.updateQuery(requireActivity(), query1); Preference q = findPreference(getString(R.string.key_muzei_query)); q.setSummary(MuzeiOptionManager.getInstance(requireActivity()).getQuery()); }); dialog.show(requireFragmentManager(), null); return true; }); }
Example 15
Source File: TalkBackVerbosityPreferencesActivity.java From talkback with Apache License 2.0 | 4 votes |
private void disablePreferenceDetails(ArrayList<Preference> detailedPrefs) { // For each detailed preference... disable preference. for (Preference preference : detailedPrefs) { preference.setEnabled(false); } }
Example 16
Source File: PreferencesFastFragment.java From InviZible with GNU General Public License v3.0 | 4 votes |
private void setUpdateTimeLast() { if (getActivity() == null) { return; } String updateTimeLastStr = new PrefManager(getActivity()).getStrPref("updateTimeLast"); String lastUpdateResult = new PrefManager(getActivity()).getStrPref("LastUpdateResult"); final Preference prefLastUpdate = findPreference("pref_fast_chek_update"); if (prefLastUpdate == null) return; if (!updateTimeLastStr.isEmpty() && updateTimeLastStr.trim().matches("\\d+")) { long updateTimeLast = Long.parseLong(updateTimeLastStr); Date date = new Date(updateTimeLast); String dateString = android.text.format.DateFormat.getDateFormat(getActivity()).format(date); String timeString = android.text.format.DateFormat.getTimeFormat(getActivity()).format(date); prefLastUpdate.setSummary(getString(R.string.update_last_check) + " " + dateString + " " + timeString + System.lineSeparator() + lastUpdateResult); } else if (lastUpdateResult.equals(getString(R.string.update_fault)) && new PrefManager(getActivity()).getStrPref("updateTimeLast").isEmpty() && appVersion.startsWith("p")) { Preference pref_fast_auto_update = findPreference("pref_fast_auto_update"); if (pref_fast_auto_update != null) { pref_fast_auto_update.setEnabled(false); } prefLastUpdate.setSummary(lastUpdateResult); } else { prefLastUpdate.setSummary(lastUpdateResult); } if (getActivity() == null) return; prefLastUpdate.setOnPreferenceClickListener(preference -> { if (prefLastUpdate.isEnabled()) { new Handler().post(() -> { if (getActivity() == null) { return; } Intent intent = new Intent(getActivity(), MainActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_ANIMATION); intent.setAction("check_update"); getActivity().overridePendingTransition(0, 0); getActivity().finish(); startActivity(intent); }); return true; } else { return false; } }); }
Example 17
Source File: EventPreferencesOrientation.java From PhoneProfilesPlus with Apache License 2.0 | 4 votes |
@Override void checkPreferences(PreferenceManager prefMng, Context context) { SensorManager sensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE); boolean hasAccelerometer = (sensorManager != null) && (sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER) != null); boolean hasMagneticField = (sensorManager != null) && (sensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD) != null); boolean hasProximity = (sensorManager != null) && (sensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY) != null); boolean hasLight = (sensorManager != null) && (sensorManager.getDefaultSensor(Sensor.TYPE_LIGHT) != null); boolean enabledAll = (hasAccelerometer) && (hasMagneticField); Preference preference = prefMng.findPreference(PREF_EVENT_ORIENTATION_DISPLAY); if (preference != null) { if (!hasAccelerometer) preference.setSummary(context.getString(R.string.profile_preferences_device_not_allowed)+ ": "+context.getString(R.string.preference_not_allowed_reason_no_hardware)); preference.setEnabled(hasAccelerometer); } preference = prefMng.findPreference(PREF_EVENT_ORIENTATION_SIDES); if (preference != null) { if (!enabledAll) preference.setSummary(context.getString(R.string.profile_preferences_device_not_allowed)+ ": "+context.getString(R.string.preference_not_allowed_reason_no_hardware)); preference.setEnabled(enabledAll); } boolean enabled = hasProximity; preference = prefMng.findPreference(PREF_EVENT_ORIENTATION_DISTANCE); if (preference != null) { if (!enabled) preference.setSummary(context.getString(R.string.profile_preferences_device_not_allowed)+ ": "+context.getString(R.string.preference_not_allowed_reason_no_hardware)); preference.setEnabled(enabled); } SwitchPreferenceCompat switchPreference = prefMng.findPreference(PREF_EVENT_ORIENTATION_CHECK_LIGHT); if (switchPreference != null) { boolean checkLight = switchPreference.isChecked(); if (checkLight) { enabled = hasLight; preference = prefMng.findPreference(PREF_EVENT_ORIENTATION_LIGHT_MIN); if (preference != null) { if (!enabled) preference.setSummary(context.getString(R.string.profile_preferences_device_not_allowed) + ": " + context.getString(R.string.preference_not_allowed_reason_no_hardware)); preference.setEnabled(enabled); } preference = prefMng.findPreference(PREF_EVENT_ORIENTATION_LIGHT_MAX); if (preference != null) { if (!enabled) preference.setSummary(context.getString(R.string.profile_preferences_device_not_allowed) + ": " + context.getString(R.string.preference_not_allowed_reason_no_hardware)); preference.setEnabled(enabled); } } } enabled = PPPExtenderBroadcastReceiver.isEnabled(context.getApplicationContext(), PPApplication.VERSION_CODE_EXTENDER_3_0); ApplicationsMultiSelectDialogPreferenceX applicationsPreference = prefMng.findPreference(PREF_EVENT_ORIENTATION_IGNORED_APPLICATIONS); if (applicationsPreference != null) { applicationsPreference.setEnabled(enabled); applicationsPreference.setSummaryAMSDP(); } SharedPreferences preferences = prefMng.getSharedPreferences(); setSummary(prefMng, PREF_EVENT_ORIENTATION_APP_SETTINGS, preferences, context); setCategorySummary(prefMng, preferences, context); }
Example 18
Source File: PreferencesCommonFragment.java From InviZible with GNU General Public License v3.0 | 4 votes |
@Override public boolean onPreferenceChange(Preference preference, Object newValue) { if (getActivity() == null) { return false; } switch (preference.getKey()) { case "swShowNotification": if (!Boolean.parseBoolean(newValue.toString())) { Intent intent = new Intent(getActivity(), ModulesService.class); intent.setAction(ModulesService.actionDismissNotification); getActivity().startService(intent); InfoNotificationProtectService infoNotification = new InfoNotificationProtectService(); if (isAdded()) { infoNotification.show(getParentFragmentManager(), "dialogProtectService"); } } break; case "pref_common_tor_tethering": allowTorTether = Boolean.parseBoolean(newValue.toString()); readTorConf(); if (new PrefManager(getActivity()).getBoolPref("Tor Running")) { ModulesRestarter.restartTor(getActivity()); ModulesStatus.getInstance().setIptablesRulesUpdateRequested(getActivity(), true); //ModulesAux.requestModulesStatusUpdate(getActivity()); } break; case "pref_common_itpd_tethering": allowITPDtether = Boolean.parseBoolean(newValue.toString()); readITPDConf(); readITPDTunnelsConf(); if (new PrefManager(getActivity()).getBoolPref("I2PD Running")) { ModulesRestarter.restartITPD(getActivity()); ModulesStatus.getInstance().setIptablesRulesUpdateRequested(getActivity(), true); //ModulesAux.requestModulesStatusUpdate(getActivity()); } break; case "pref_common_tor_route_all": Preference prefTorSiteUnlockTether = findPreference("prefTorSiteUnlockTether"); if (prefTorSiteUnlockTether != null) { if (Boolean.parseBoolean(newValue.toString())) { prefTorSiteUnlockTether.setEnabled(false); } else { prefTorSiteUnlockTether.setEnabled(true); } } if (new PrefManager(getActivity()).getBoolPref("Tor Running")) { ModulesStatus.getInstance().setIptablesRulesUpdateRequested(getActivity(), true); //ModulesAux.requestModulesStatusUpdate(getActivity()); } break; case "pref_common_block_http": if (new PrefManager(getActivity()).getBoolPref("DNSCrypt Running") || new PrefManager(getActivity()).getBoolPref("Tor Running")) { ModulesStatus.getInstance().setIptablesRulesUpdateRequested(getActivity(), true); //ModulesAux.requestModulesStatusUpdate(getActivity()); } break; case "swUseModulesRoot": ModulesStatus modulesStatus = ModulesStatus.getInstance(); ModulesAux.stopModulesIfRunning(getActivity()); boolean newOptionValue = Boolean.parseBoolean(newValue.toString()); modulesStatus.setUseModulesWithRoot(newOptionValue); modulesStatus.setContextUIDUpdateRequested(true); ModulesAux.makeModulesStateExtraLoop(getActivity()); //ModulesAux.requestModulesStatusUpdate(getActivity()); Preference fixTTLPreference = findPreference("pref_common_fix_ttl"); if (fixTTLPreference != null) { fixTTLPreference.setEnabled(!newOptionValue); } Log.i(LOG_TAG, "PreferencesCommonFragment switch to " + (Boolean.parseBoolean(newValue.toString())? "Root" : "No Root")); break; case "pref_common_fix_ttl": modulesStatus = ModulesStatus.getInstance(); boolean fixed = Boolean.parseBoolean(newValue.toString()); modulesStatus.setFixTTL(fixed); modulesStatus.setIptablesRulesUpdateRequested(getActivity(), true); new PrefManager(getActivity()).setBoolPref("refresh_main_activity", true); break; case "pref_common_local_eth_device_addr": ModulesStatus.getInstance().setIptablesRulesUpdateRequested(getActivity(), true); break; case "swWakelock": ModulesAux.requestModulesStatusUpdate(getActivity()); break; } return true; }