Java Code Examples for android.preference.SwitchPreference#setOnPreferenceChangeListener()
The following examples show how to use
android.preference.SwitchPreference#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: SettingsFragment.java From Interessant with Apache License 2.0 | 6 votes |
@Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.settings); cacheWithWifi = (SwitchPreference) findPreference("cache_with_wifi"); cacheWithWifi.setOnPreferenceChangeListener(this); boolean checked = PreferenceManager.getBooleanValue(context, CACHE_KEY, true); cacheWithWifi.setChecked(checked); clearVideoCache = findPreference("clear_video_cache"); clearVideoCache.setOnPreferenceClickListener(this); float videoFileSize = calculateCacheFileSize("video-cache", true); clearVideoCache.setSummary(String.format(Locale.CHINESE, "%.2fMb", videoFileSize)); clearPhotoCache = findPreference("clear_photo_cache"); clearPhotoCache.setOnPreferenceClickListener(this); float photoFileSize = calculateCacheFileSize("image_manager_disk_cache", false); photoFileSize += calculateCacheFileSize("picasso-cache", false); clearPhotoCache.setSummary(String.format(Locale.CHINESE, "%.2fMb", photoFileSize)); }
Example 2
Source File: SettingsActivity.java From bcm-android with GNU General Public License v3.0 | 6 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Load the preferences from an XML resource addPreferencesFromResource(R.xml.pref_general); final SwitchPreference zeroAmountTx = (SwitchPreference) findPreference("zeroAmountSwitch"); zeroAmountTx.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object o) { Settings.showTransactionsWithZero = !zeroAmountTx.isChecked(); return true; } }); Settings.displayAds = false; }
Example 3
Source File: SettingFragment.java From Ency with Apache License 2.0 | 6 votes |
@Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.preferences); sharePrefManager = new SharePrefManager(getActivity()); provincialFlowPreference = (SwitchPreference) findPreference(getResources().getString(R.string.key_provincial_traffic_patterns)); nightModePreference = (SwitchPreference) findPreference(getResources().getString(R.string.key_night_mode)); cleanCachePreference = findPreference(getResources().getString(R.string.key_clear_cache)); versionPreference = findPreference(getResources().getString(R.string.key_version)); homepagePreference = findPreference(getResources().getString(R.string.key_homepage)); provincialFlowPreference.setOnPreferenceChangeListener(this); nightModePreference.setOnPreferenceChangeListener(this); cleanCachePreference.setOnPreferenceClickListener(this); versionPreference.setOnPreferenceClickListener(this); homepagePreference.setOnPreferenceClickListener(this); // 设置当前版本号 versionPreference.setSummary("V " + AppApplicationUtil.getVersionName(getActivity())); // 设置缓存大小 cleanCachePreference.setSummary("缓存大小:" + SystemUtil.getTotalCacheSize(getActivity())); }
Example 4
Source File: InputSettingsFragment.java From wearmouse with Apache License 2.0 | 5 votes |
private void initBooleanPref(@SettingKey final String key) { final SwitchPreference pref = (SwitchPreference) findPreference(key); pref.setChecked(settings.getBoolean(key)); pref.setOnPreferenceChangeListener( (p, newVal) -> { settings.setBoolean(p.getKey(), ((Boolean) newVal)); return true; }); }
Example 5
Source File: AdBlockSettings.java From Cornowser with MIT License | 5 votes |
private void initAdBlockNetBehaviorPref() { final SwitchPreference pref = (SwitchPreference) findPreference("adblock_network_behavior"); pref.setChecked(!CornBrowser.getBrowserStorage().getAdBlockNetBehavior()); pref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { CornBrowser.getBrowserStorage().saveAdBlockNetBehavior(!(boolean)newValue); pref.setChecked((boolean)newValue); return false; } }); }
Example 6
Source File: AdBlockSettings.java From Cornowser with MIT License | 5 votes |
private void initAdBlockEnable() { final SwitchPreference pref = (SwitchPreference) findPreference("adblock_enable"); pref.setChecked(CornBrowser.getBrowserStorage().isAdBlockEnabled()); pref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { CornBrowser.getBrowserStorage().saveEnableAdBlock((boolean)newValue); pref.setChecked((boolean)newValue); if((boolean)newValue) doUpdateAdBlock(); return false; } }); }
Example 7
Source File: SettingsFragment.java From DeviceConnect-Android with MIT License | 5 votes |
/** * Preferenceの設定を有効にします. */ private void enablePreference() { // 設定画面の有効化 getPreferenceScreen().setEnabled(true); // 設定変更イベントの受信開始 mCheckBoxSslPreferences.setOnPreferenceChangeListener(this); EditTextPreference editHostPreferences = (EditTextPreference) getPreferenceScreen() .findPreference(getString(R.string.key_settings_dconn_host)); editHostPreferences.setOnPreferenceChangeListener(this); EditTextPreference editKeywordPreferences = (EditTextPreference) getPreferenceScreen() .findPreference(getString(R.string.key_settings_dconn_keyword)); editKeywordPreferences.setOnPreferenceChangeListener(this); EditTextPreference editNamePreferences = (EditTextPreference) getPreferenceScreen() .findPreference(getString(R.string.key_settings_dconn_name)); editNamePreferences.setOnPreferenceChangeListener(this); mEditPortPreferences.setOnPreferenceChangeListener(this); mCheckBoxOauthPreferences.setOnPreferenceChangeListener(this); mCheckBoxExternalIpPreferences.setOnPreferenceChangeListener(this); mCheckBoxExternalStartAndStartPreferences.setOnPreferenceChangeListener(this); mCheckBoxRequireOriginPreferences.setOnPreferenceChangeListener(this); mCheckBoxOriginBlockingPreferences.setOnPreferenceChangeListener(this); mCheckBoxManagerNameVisiblePreferences.setOnPreferenceChangeListener(this); mObserverPreferences.setOnPreferenceChangeListener(this); mWebPortPreferences.setOnPreferenceChangeListener(this); SwitchPreference serverPreferences = (SwitchPreference) getPreferenceScreen() .findPreference(getString(R.string.key_settings_dconn_server_on_off)); serverPreferences.setOnPreferenceChangeListener(this); SwitchPreference webPreferences = (SwitchPreference) getPreferenceScreen() .findPreference(getString(R.string.key_settings_web_server_on_off)); webPreferences.setOnPreferenceChangeListener(this); SwitchPreference eventKeepAlive = (SwitchPreference) getPreferenceScreen() .findPreference(getString(R.string.key_settings_event_keep_alive_on_off)); eventKeepAlive.setOnPreferenceChangeListener(this); }
Example 8
Source File: SettingsActivity.java From good-weather with GNU General Public License v3.0 | 5 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.pref_general); final SwitchPreference notificationSwitch = (SwitchPreference) findPreference( Constants.KEY_PREF_IS_NOTIFICATION_ENABLED); notificationSwitch.setOnPreferenceChangeListener(notificationListener); }
Example 9
Source File: SettingsActivity.java From XCallRecording-xposed with GNU General Public License v3.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getPreferenceManager().setSharedPreferencesMode(MODE_WORLD_READABLE); addPreferencesFromResource(R.xml.preferences); findPreference(Settings.PREF_VERSION_NAME).setSummary(BuildConfig.VERSION_NAME); mPrefSkipMediaScan = (SwitchPreference) findPreference(Settings.PREF_SKIP_MEDIA_SCAN); mPrefSkipMediaScan.setOnPreferenceChangeListener(this); }
Example 10
Source File: DebugSettingsFragment.java From JumpGo with Mozilla Public License 2.0 | 5 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); BrowserApp.getAppComponent().inject(this); addPreferencesFromResource(R.xml.preference_debug); mSwitchLeakCanary = (SwitchPreference) findPreference(LEAK_CANARY); mSwitchLeakCanary.setChecked(mPreferenceManager.getUseLeakCanary()); mSwitchLeakCanary.setOnPreferenceChangeListener(this); }
Example 11
Source File: SettingsActivity.java From your-local-weather with GNU General Public License v3.0 | 5 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.pref_notification); final SwitchPreference notificationSwitch = (SwitchPreference) findPreference( Constants.KEY_PREF_IS_NOTIFICATION_ENABLED); notificationSwitch.setOnPreferenceChangeListener(notificationListener); }
Example 12
Source File: InLineActivity.java From wear-os-samples with Apache License 2.0 | 5 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Load the preferences from an XML resource addPreferencesFromResource(R.xml.prefs_in_line_progress); mDeterminantSwitchPref = (SwitchPreference) findPreference(getString(R.string.key_pref_determinant_switch)); mDeterminantSwitchPref.setChecked(true); mCircledImageViewPref = (CircledImageViewPreference) findPreference(getString(R.string.key_pref_circled_image_view)); mPreferenceScreen = (PreferenceScreen) findPreference(getString(R.string.key_pref_progress_screen)); mProgressBarPreference = new ProgressBarPreference(getContext()); mProgressBarPreference.setTitle("@string/indeterminant_progress"); mDeterminantSwitchPref.setOnPreferenceChangeListener( new OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { mDeterminantSwitchPref.setChecked(!mDeterminantSwitchPref.isChecked()); if (mDeterminantSwitchPref.isChecked()) { mCircledImageViewPref.cancelCountDownTimer(); mCircledImageViewPref.setStartCircledImageView(); mPreferenceScreen.removePreference(mProgressBarPreference); mPreferenceScreen.addPreference(mCircledImageViewPref); } else { mPreferenceScreen.removePreference(mCircledImageViewPref); mPreferenceScreen.addPreference(mProgressBarPreference); } return true; } }); }
Example 13
Source File: AdBlockSettings.java From Cornowser with MIT License | 5 votes |
private void initAdBlockWaitForPref() { final SwitchPreference pref = (SwitchPreference) findPreference("adblock_waitfor"); pref.setChecked(CornBrowser.getBrowserStorage().isWaitForAdBlockEnabled()); pref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { CornBrowser.getBrowserStorage().saveWaitForAdBlock((boolean)newValue); pref.setChecked((boolean)newValue); return false; } }); }
Example 14
Source File: SwitchAccessPreferenceActivity.java From talkback with Apache License 2.0 | 5 votes |
private void adjustAutoSelectPref() { SwitchPreference autoselectPreference = (SwitchPreference) findPreference(R.string.switch_access_choose_action_auto_select_key); autoselectPreference.setChecked( SwitchAccessPreferenceUtils.isAutoselectEnabled(getActivity())); autoselectPreference.setOnPreferenceChangeListener( (preference, newValue) -> { SwitchAccessPreferenceUtils.setAutoselectEnabled(getActivity(), (boolean) newValue); return true; }); }
Example 15
Source File: InputSettingsFragment.java From wearmouse with Apache License 2.0 | 5 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads(); try { addPreferencesFromResource(R.xml.prefs_input_settings); } finally { StrictMode.setThreadPolicy(oldPolicy); } settings = new SettingsUtil(getActivity()); onboardingRequest = new OnboardingRequest(getActivity(), ScreenKey.CALIBRATION); calibrationPref = (SwitchPreference) findPreference(SettingKey.CALIBRATION); initBooleanPref(SettingKey.STABILIZE); initBooleanPref(SettingKey.CURSOR_8_WAY); initBooleanPref(SettingKey.REDUCED_RATE); initBooleanPref(SettingKey.STAY_CONNECTED); updateCalibrationPref(); calibrationPref.setOnPreferenceChangeListener( (p, newVal) -> { settings.setBoolean(SettingKey.CALIBRATION, false); onboardingRequest.start(this); return true; }); OnboardingController onboardingController = new OnboardingController(getActivity()); Preference onboardingPref = findPreference(ONBOARDING_PREF); onboardingPref.setEnabled(onboardingController.isAnyComplete()); onboardingPref.setOnPreferenceClickListener( preference -> { if (preference.isEnabled()) { onboardingController.resetAll(); preference.setEnabled(false); } return true; }); }
Example 16
Source File: SettingsActivity.java From javaide with GNU General Public License v3.0 | 4 votes |
private void setUpPreferences() { displayLimitPreference = (EditTextPreference) findPreference(getString(R.string.pref_display_limit)); int displayLimitValue = PreferenceHelper.getDisplayLimitPreference(getActivity()); displayLimitPreference.setSummary(getString(R.string.pref_display_limit_summary, displayLimitValue, getString(R.string.pref_display_limit_default))); displayLimitPreference.setOnPreferenceChangeListener(this); logLinePeriodPreference = (EditTextPreference) findPreference(getString(R.string.pref_log_line_period)); int logLinePrefValue = PreferenceHelper.getLogLinePeriodPreference(getActivity()); logLinePeriodPreference.setSummary(getString(R.string.pref_log_line_period_summary, logLinePrefValue, getString(R.string.pref_log_line_period_default))); logLinePeriodPreference.setOnPreferenceChangeListener(this); textSizePreference = (ListPreference) findPreference(getString(R.string.pref_text_size)); textSizePreference.setSummary(textSizePreference.getEntry()); textSizePreference.setOnPreferenceChangeListener(this); defaultLevelPreference = (ListPreference) findPreference(getString(R.string.pref_default_log_level)); defaultLevelPreference.setOnPreferenceChangeListener(this); setDefaultLevelPreferenceSummary(defaultLevelPreference.getEntry()); bufferPreference = (MultipleChoicePreference) findPreference(getString(R.string.pref_buffer)); bufferPreference.setOnPreferenceChangeListener(this); setBufferPreferenceSummary(bufferPreference.getValue()); scrubberPreference = (SwitchPreference) getPreferenceScreen().findPreference("scrubber"); scrubberPreference.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { LogLine.isScrubberEnabled = (boolean) newValue; return true; } }); }
Example 17
Source File: SettingsMain.java From ExpressHelper with GNU General Public License v3.0 | 4 votes |
@Override public void onCreate(Bundle savedInstance) { super.onCreate(savedInstance); addPreferencesFromResource(R.xml.pref_main); mSets = Settings.getInstance(getActivity().getApplicationContext()); getActivity().setTitle(R.string.title_settings); pref_version = findPreference("application_version"); pref_weibo = findPreference("sina_weibo"); pref_os_license = findPreference("open_source_license"); pref_api_provider = findPreference("api_provider"); pref_github = findPreference("github_repo"); pref_token_choose = (MaterialListPreference) findPreference("api_token_choose"); pref_token_custom = findPreference("api_token_custom"); pref_swipe_back = (SwitchPreference) findPreference("swipe_back"); pref_notification_interval = (MaterialListPreference) findPreference("notification_interval"); pref_do_not_disturb = (SwitchPreference) findPreference("do_not_disturb"); pref_disable_animation = (SwitchPreference) findPreference("disable_animation"); pref_navigation_tint = (SwitchPreference) findPreference("navigation_tint"); String version = "Unknown"; try { version = getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(), 0).versionName; version += " (" + getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(), 0).versionCode + ")"; } catch (Exception e) { // Keep the default value } pref_version.setSummary(version); pref_swipe_back.setChecked(mSets.getBoolean(Settings.KEY_SWIPE_BACK, true)); pref_token_custom.setDefaultValue(mSets.getInt(Settings.KEY_TOKEN_CHOOSE, 0)); pref_token_custom.setEnabled(mSets.getInt(Settings.KEY_TOKEN_CHOOSE, 0) == 2); pref_do_not_disturb.setChecked(mSets.getBoolean(Settings.KEY_NOTIFICATION_DO_NOT_DISTURB, true)); pref_disable_animation.setChecked(mSets.getBoolean(Settings.KEY_DISABLE_ANIMATION, false)); if (Build.VERSION.SDK_INT < 21) { pref_navigation_tint.setEnabled(false); pref_navigation_tint.setChecked(false); } else { pref_navigation_tint.setChecked(mSets.getBoolean(Settings.KEY_NAVIGATION_TINT, true)); } String[] values = getResources().getStringArray(R.array.item_token_list_values); int index, target = mSets.getInt(Settings.KEY_TOKEN_CHOOSE, 0); for (index = 0; index < values.length; index++) { if (values[index].equals(String.valueOf(target))) break; } pref_token_choose.setSummary( getResources().getStringArray(R.array.item_token_list) [index] ); String[] values1 = getResources().getStringArray(R.array.notification_interval_item); int index1, target1 = mSets.getInt(Settings.KEY_NOTIFICATION_INTERVAL, 0); for (index1 = 0; index1 < values.length; index1++) { if (values1[index1].equals(String.valueOf(target1))) break; } pref_notification_interval.setSummary( getResources().getStringArray(R.array.notification_interval) [index1] ); pref_weibo.setOnPreferenceClickListener(this); pref_os_license.setOnPreferenceClickListener(this); pref_api_provider.setOnPreferenceClickListener(this); pref_github.setOnPreferenceClickListener(this); pref_token_custom.setOnPreferenceClickListener(this); pref_token_choose.setOnPreferenceChangeListener(this); pref_swipe_back.setOnPreferenceChangeListener(this); pref_notification_interval.setOnPreferenceChangeListener(this); pref_do_not_disturb.setOnPreferenceChangeListener(this); pref_disable_animation.setOnPreferenceChangeListener(this); pref_navigation_tint.setOnPreferenceChangeListener(this); }
Example 18
Source File: AppsWidgetSettings.java From Hangar with GNU General Public License v3.0 | 4 votes |
@Override public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.layout.apps_widget_settings); int defaultAppsNo = APPS_WIDGET_DEFAULT_APPSNO; int defaultAppsNoLs = APPS_WIDGET_DEFAULT_APPSNO_LS; SharedPreferences mPrefs = prefs.prefsGet(); apps_by_widget_size_preference = (SwitchPreference)findPreference(Settings.APPS_BY_WIDGET_SIZE_PREFERENCE); apps_by_widget_size_preference.setChecked(mPrefs.getBoolean(Settings.APPS_BY_WIDGET_SIZE_PREFERENCE, Settings.APPS_BY_WIDGET_SIZE_DEFAULT)); apps_by_widget_size_preference.setOnPreferenceChangeListener(changeListener); background_color_preference = (ColorPickerPreference) findPreference(Settings.BACKGROUND_COLOR_PREFERENCE); int intColor = mPrefs.getInt(Settings.BACKGROUND_COLOR_PREFERENCE, Settings.BACKGROUND_COLOR_DEFAULT); String hexColor = String.format("#%08x", (intColor)); background_color_preference.setSummary(hexColor); background_color_preference.setOnPreferenceChangeListener(changeListener); appnos_preference = (UpdatingListPreference)findPreference(Settings.STATS_WIDGET_APPSNO_PREFERENCE); appnos_preference.setValue(mPrefs.getString(extras == null ? Settings.STATS_WIDGET_APPSNO_PREFERENCE : Integer.toString(defaultAppsNo), Integer.toString(defaultAppsNo))); appnos_preference.setOnPreferenceChangeListener(changeListener); if (apps_by_widget_size_preference.isChecked()) { appnos_preference.setSummary(R.string.automatic_appsno); } appnos_ls_preference = (UpdatingListPreference)findPreference(Settings.STATS_WIDGET_APPSNO_LS_PREFERENCE); appnos_ls_preference.setValue(mPrefs.getString(extras == null ? Settings.STATS_WIDGET_APPSNO_LS_PREFERENCE : Integer.toString(defaultAppsNoLs), Integer.toString(defaultAppsNoLs))); appnos_ls_preference.setOnPreferenceChangeListener(changeListener); if (apps_by_widget_size_preference.isChecked()) { appnos_ls_preference.setSummary(R.string.automatic_appsno); } weighted_recents_preference = (CheckBoxPreference)findPreference(Settings.WEIGHTED_RECENTS_PREFERENCE); weighted_recents_preference.setChecked(mPrefs.getBoolean(Settings.WEIGHTED_RECENTS_PREFERENCE, Settings.WEIGHTED_RECENTS_DEFAULT)); weighted_recents_preference.setOnPreferenceChangeListener(changeListener); weight_priority_preference = (UpdatingListPreference)findPreference(Settings.WEIGHT_PRIORITY_PREFERENCE); weight_priority_preference.setValue(mPrefs.getString(Settings.WEIGHT_PRIORITY_PREFERENCE, Integer.toString(Settings.WEIGHT_PRIORITY_DEFAULT))); weight_priority_preference.setOnPreferenceChangeListener(changeListener); colorize_preference = (CheckBoxPreference)findPreference(Settings.COLORIZE_PREFERENCE); colorize_preference.setChecked(mPrefs.getBoolean(Settings.COLORIZE_PREFERENCE, Settings.COLORIZE_DEFAULT)); colorize_preference.setOnPreferenceChangeListener(changeListener); ignore_pinned_preference = (CheckBoxPreference)findPreference(Settings.IGNORE_PINNED_PREFERENCE); ignore_pinned_preference.setChecked(mPrefs.getBoolean(Settings.IGNORE_PINNED_PREFERENCE, Settings.IGNORE_PINNED_DEFAULT)); ignore_pinned_preference.setOnPreferenceChangeListener(changeListener); icon_color_preference = (ColorPickerPreference) findPreference(Settings.ICON_COLOR_PREFERENCE); int intColor2 = mPrefs.getInt(Settings.ICON_COLOR_PREFERENCE, Settings.ICON_COLOR_DEFAULT); String hexColor2 = String.format("#%08x", (intColor2)); icon_color_preference.setSummary(hexColor2); icon_color_preference.setOnPreferenceChangeListener(changeListener); rounded_corners_preference = (CheckBoxPreference)findPreference(Settings.ROUNDED_CORNERS_PREFERENCE); rounded_corners_preference.setChecked(mPrefs.getBoolean(Settings.ROUNDED_CORNERS_PREFERENCE, Settings.ROUNDED_CORNERS_DEFAULT)); rounded_corners_preference.setOnPreferenceChangeListener(changeListener); icon_size_preference = (UpdatingListPreference)findPreference(Settings.ICON_SIZE_PREFERENCE); icon_size_preference.setValue(mPrefs.getString(Settings.ICON_SIZE_PREFERENCE, Integer.toString(Settings.ICON_SIZE_DEFAULT))); icon_size_preference.setOnPreferenceChangeListener(changeListener); alignment_preference = (UpdatingListPreference)findPreference(Settings.ALIGNMENT_PREFERENCE); alignment_preference.setValue(mPrefs.getString(Settings.ALIGNMENT_PREFERENCE, Integer.toString(Settings.ALIGNMENT_DEFAULT))); alignment_preference.setOnPreferenceChangeListener(changeListener); }
Example 19
Source File: SettingsActivity.java From matlog with GNU General Public License v3.0 | 4 votes |
private void setUpPreferences() { setCurrentValue("ui.theme"); setCurrentValue("theme"); displayLimitPreference = (EditTextPreference) findPreference(getString(R.string.pref_display_limit)); int displayLimitValue = PreferenceHelper.getDisplayLimitPreference(getActivity()); displayLimitPreference.setSummary(getString(R.string.pref_display_limit_summary, displayLimitValue, getString(R.string.pref_display_limit_default))); displayLimitPreference.setOnPreferenceChangeListener(this); filterPatternPreference = (EditTextPreference) findPreference(getString(R.string.pref_filter_pattern)); filterPatternPreference.setSummary(getString(R.string.pref_filter_pattern_summary)); filterPatternPreference.setOnPreferenceChangeListener(this); logLinePeriodPreference = (EditTextPreference) findPreference(getString(R.string.pref_log_line_period)); int logLinePrefValue = PreferenceHelper.getLogLinePeriodPreference(getActivity()); logLinePeriodPreference.setSummary(getString(R.string.pref_log_line_period_summary, logLinePrefValue, getString(R.string.pref_log_line_period_default))); logLinePeriodPreference.setOnPreferenceChangeListener(this); textSizePreference = (ListPreference) findPreference(getString(R.string.pref_text_size)); textSizePreference.setSummary(textSizePreference.getEntry()); textSizePreference.setOnPreferenceChangeListener(this); defaultLevelPreference = (ListPreference) findPreference(getString(R.string.pref_default_log_level)); defaultLevelPreference.setOnPreferenceChangeListener(this); setDefaultLevelPreferenceSummary(defaultLevelPreference.getEntry()); mThemePreference = findPreference("ui.theme"); mThemePreference.setOnPreferenceChangeListener(this); bufferPreference = (MultipleChoicePreference) findPreference(getString(R.string.pref_buffer)); bufferPreference.setOnPreferenceChangeListener(this); setBufferPreferenceSummary(bufferPreference.getValue()); mThemePreference.setOnPreferenceChangeListener(this); mAboutPreference = findPreference(getString(R.string.pref_about)); mAboutPreference.setOnPreferenceClickListener(preference -> { // launch about activity Intent intent = new Intent(getActivity(), AboutDialogActivity.class); startActivity(intent); return true; }); mAboutPreference.setSummary(getString(R.string.version, PackageHelper.getVersionName(getActivity()))); scrubberPreference = (SwitchPreference) getPreferenceScreen().findPreference("scrubber"); scrubberPreference.setOnPreferenceChangeListener((preference, newValue) -> { LogLine.isScrubberEnabled = (boolean) newValue; return true; }); }
Example 20
Source File: RecorderSettingFragment.java From VIA-AI with MIT License | 4 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); int rID []; final Resources resource = getResources(); // set name of actionbar. ActionBar actionBar = getActivity().getActionBar(); if (actionBar != null) { actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setTitle(resource.getString(R.string.prefTitle_Recoder)); } // load default value PreferenceManager.setDefaultValues(getActivity(), R.xml.pref_recoder_setting, false); // config xml addPreferencesFromResource(R.xml.pref_recoder_setting); FileDialogPreference fPreference; // set preference rules (Video Record Path) fPreference = (FileDialogPreference)findPreference(resource.getString(R.string.prefKey_Recoder_VideoRecordPath)); fPreference.setDialog(false, ""); // set preference rules (VehicleBus Record Path) fPreference = (FileDialogPreference)findPreference(resource.getString(R.string.prefKey_Recoder_VehicleBusRecordPath)); fPreference.setDialog(false, ""); // set preference rules (Video Record) Listener_VideoRecord listener_VideoRecord = new Listener_VideoRecord(resource); SwitchPreference pvideo = (SwitchPreference)findPreference(resource.getString(R.string.prefKey_Recoder_VideoRecord)); pvideo.setOnPreferenceChangeListener(listener_VideoRecord); // set preference rules (VehicleBus Record) Listener_VehicleBusRecord listener_VehicleBusRecord = new Listener_VehicleBusRecord(resource); SwitchPreference pvbus = (SwitchPreference)findPreference(resource.getString(R.string.prefKey_Recoder_VehicleBusRecord)); pvbus.setOnPreferenceChangeListener(listener_VehicleBusRecord); // notify parts listener listener_VideoRecord.onPreferenceChange(pvideo, pvideo.isChecked()); listener_VehicleBusRecord.onPreferenceChange(pvbus, pvbus.isChecked()); }