Java Code Examples for android.preference.SwitchPreference#isChecked()
The following examples show how to use
android.preference.SwitchPreference#isChecked() .
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: SettingsActivity.java From AudioAnchor with GNU General Public License v3.0 | 6 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.settings); // Make sure the autoplay position preference is enabled iff autoplay is final SwitchPreference autoplayPref = (SwitchPreference) findPreference(getString(R.string.settings_autoplay_key)); final SwitchPreference autoplayPositionPref = (SwitchPreference) findPreference(getString(R.string.settings_autoplay_restart_key)); // This is needed for cases where autoplay was checked while a previous version of // AudioAnchor was installed if (autoplayPref.isChecked()) { autoplayPositionPref.setEnabled(true); } else { autoplayPositionPref.setEnabled(false); } initSummary(getPreferenceScreen()); }
Example 2
Source File: NotificationsActivity.java From wear-os-samples with Apache License 2.0 | 5 votes |
public void initInLineAction(SwitchPreference switchPref) { switchPref.setChecked(true); mActionOn = switchPref.isChecked(); switchPref.setOnPreferenceChangeListener( new OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { mActionOn = (Boolean) newValue; return true; } }); }
Example 3
Source File: NotificationsActivity.java From wear-os-samples with Apache License 2.0 | 5 votes |
public void initAvatar(SwitchPreference switchPref) { switchPref.setChecked(true); mAvatarOn = switchPref.isChecked(); switchPref.setOnPreferenceChangeListener( new OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { mAvatarOn = (Boolean) newValue; return true; } }); }
Example 4
Source File: GeneralPreferenceFragment.java From redgram-for-reddit with GNU General Public License v3.0 | 5 votes |
private void toggleOver18Dependants(boolean flag){ SwitchPreference labelPref = (SwitchPreference) getPreferenceManager().findPreference(SettingsActivity.general_label_nsfw); if(labelPref.isChecked() != flag){ labelPref.setChecked(flag); } SwitchPreference prevPref = (SwitchPreference) getPreferenceManager().findPreference(SettingsActivity.general_preview_nsfw); if(prevPref.isChecked() != flag){ prevPref.setChecked(flag); } }
Example 5
Source File: SudokuBoardCustomThemePreferenceGroup.java From opensudoku with GNU General Public License v3.0 | 5 votes |
private void commitLightThemeOrDarkThemeChanges() { SwitchPreference preference = (SwitchPreference) getPreference(0); SharedPreferences.Editor settingsEditor = mGameSettings.edit(); String newTheme = preference.isChecked() ? "custom_light" : "custom"; if (!mGameSettings.getString("theme", "opensudoku").equals(newTheme)) { settingsEditor.putString("theme", newTheme); } settingsEditor.apply(); ThemeUtils.sTimestampOfLastThemeUpdate = System.currentTimeMillis(); callChangeListener(null); }
Example 6
Source File: StatsWidgetSettings.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.stats_widget_settings); int defaultAppsNo = WIDGET_3X3_DEFAULT_APPSNO; int defaultAppsNoLs = WIDGET_3X3_DEFAULT_APPSNO_LS; SharedPreferences mPrefs = prefs.prefsGet(); divider_preference = (CheckBoxPreference)findPreference(Settings.DIVIDER_PREFERENCE); divider_preference.setChecked(mPrefs.getBoolean(Settings.DIVIDER_PREFERENCE, Settings.DIVIDER_DEFAULT)); divider_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); 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); } 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 7
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); }