android.support.v7.preference.SwitchPreferenceCompat Java Examples
The following examples show how to use
android.support.v7.preference.SwitchPreferenceCompat.
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 skipTrackLongPressVolume with MIT License | 6 votes |
@Override // We only have SwitchPreferences so value is always a boolean public boolean onPreferenceTreeClick(Preference preference) { if (PREF_HIDE_ICON.equals(preference.getKey())) { boolean checked = ((SwitchPreferenceCompat) preference).isChecked(); PackageManager pm = getContext().getPackageManager(); ComponentName componentName = new ComponentName(getContext(), LauncherActivity.class); int invisible = checked ? COMPONENT_ENABLED_STATE_DISABLED : COMPONENT_ENABLED_STATE_ENABLED; pm.setComponentEnabledSetting(componentName, invisible, DONT_KILL_APP); } else if (PREF_ENABLED.equals(preference.getKey())) { boolean serviceEnabled = ((SwitchPreferenceCompat) preference).isChecked(); if (serviceEnabled) enableNotificationListener(); } return super.onPreferenceTreeClick(preference); }
Example #2
Source File: SynchroFragment.java From Focus with GNU General Public License v3.0 | 5 votes |
@Override public void initPreferenceComponent() { use_internet_while_open = (SwitchPreferenceCompat)findPreference(getString(R.string.pref_key_use_internet_while_open)); choose_rsshub = findPreference(getString(R.string.pref_key_rsshub_choice)); auto_name = (SwitchPreferenceCompat) findPreference(getString(R.string.pref_key_auto_name)); ownrsshub = findPreference(getString(R.string.pref_key_own_rsshub)); time_interval = findPreference(getString(R.string.pref_key_refresh_interval)); only_wifi = (SwitchPreferenceCompat) findPreference(getString(R.string.pref_key_only_use_wifi)); }
Example #3
Source File: SynchroFragment.java From Focus with GNU General Public License v3.0 | 5 votes |
@Override public void initPreferenceComponent() { use_internet_while_open = (SwitchPreferenceCompat)findPreference(getString(R.string.pref_key_use_internet_while_open)); choose_rsshub = findPreference(getString(R.string.pref_key_rsshub_choice)); auto_name = (SwitchPreferenceCompat) findPreference(getString(R.string.pref_key_auto_name)); ownrsshub = findPreference(getString(R.string.pref_key_own_rsshub)); time_interval = findPreference(getString(R.string.pref_key_refresh_interval)); only_wifi = (SwitchPreferenceCompat) findPreference(getString(R.string.pref_key_only_use_wifi)); }
Example #4
Source File: FragmentSettings.java From GPSLogger with GNU General Public License v3.0 | 5 votes |
public void PrefEGM96SetToFalse() { SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(getContext()); SharedPreferences.Editor editor1 = settings.edit(); editor1.putBoolean("prefEGM96AltitudeCorrection", false); editor1.commit(); SwitchPreferenceCompat EGM96 = (SwitchPreferenceCompat) super.findPreference("prefEGM96AltitudeCorrection"); EGM96.setChecked(false); }
Example #5
Source File: FragmentSettings.java From GPSLogger with GNU General Public License v3.0 | 5 votes |
public void PrefEGM96SetToTrue() { SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(getContext()); SharedPreferences.Editor editor1 = settings.edit(); editor1.putBoolean("prefEGM96AltitudeCorrection", true); editor1.commit(); SwitchPreferenceCompat EGM96 = (SwitchPreferenceCompat) super.findPreference("prefEGM96AltitudeCorrection"); EGM96.setChecked(true); }
Example #6
Source File: GestureFragment.java From Focus with GNU General Public License v3.0 | 4 votes |
@Override public void initPreferenceComponent() { notOpenClick = (SwitchPreferenceCompat) findPreference(getString(R.string.pref_key_not_pull_to_open_link)); notStar = (SwitchPreferenceCompat) findPreference(getString(R.string.pref_key_not_double_click_to_star)); notToTop = (SwitchPreferenceCompat) findPreference(getString(R.string.pref_key_not_double_click_to_top)); }
Example #7
Source File: DisplayFragment.java From Focus with GNU General Public License v3.0 | 4 votes |
@Override public void initPreferenceComponent() { not_show_image_in_list = (SwitchPreferenceCompat) findPreference(getString(R.string.pref_key_not_image_in_list)); not_use_chrome = (SwitchPreferenceCompat) findPreference(getString(R.string.pref_key_not_use_chrome)); }
Example #8
Source File: GestureFragment.java From Focus with GNU General Public License v3.0 | 4 votes |
@Override public void initPreferenceComponent() { notOpenClick = (SwitchPreferenceCompat) findPreference(getString(R.string.pref_key_not_pull_to_open_link)); notStar = (SwitchPreferenceCompat) findPreference(getString(R.string.pref_key_not_double_click_to_star)); notToTop = (SwitchPreferenceCompat) findPreference(getString(R.string.pref_key_not_double_click_to_top)); }
Example #9
Source File: DisplayFragment.java From Focus with GNU General Public License v3.0 | 4 votes |
@Override public void initPreferenceComponent() { not_show_image_in_list = (SwitchPreferenceCompat) findPreference(getString(R.string.pref_key_not_image_in_list)); not_use_chrome = (SwitchPreferenceCompat) findPreference(getString(R.string.pref_key_not_use_chrome)); }
Example #10
Source File: SettingsFragment.java From KernelAdiutor with GNU General Public License v3.0 | 4 votes |
@Override public void onCreatePreferences(Bundle bundle, String s) { addPreferencesFromResource(R.xml.settings); if (Utils.DONATED) { getPreferenceScreen().removePreference(findPreference(KEY_AD_VIEW)); } SwitchPreferenceCompat forceEnglish = (SwitchPreferenceCompat) findPreference(KEY_FORCE_ENGLISH); if (Resources.getSystem().getConfiguration().locale.getLanguage().startsWith("en")) { getPreferenceScreen().removePreference(forceEnglish); } else { forceEnglish.setOnPreferenceChangeListener(this); } if (Utils.hideStartActivity()) { ((PreferenceCategory) findPreference(KEY_USER_INTERFACE)) .removePreference(findPreference(KEY_MATERIAL_ICON)); } else { findPreference(KEY_MATERIAL_ICON).setOnPreferenceChangeListener(this); } findPreference(KEY_DARK_THEME).setOnPreferenceChangeListener(this); findPreference(KEY_BANNER_RESIZER).setOnPreferenceClickListener(this); findPreference(KEY_HIDE_BANNER).setOnPreferenceChangeListener(this); findPreference(KEY_PRIMARY_COLOR).setOnPreferenceClickListener(this); findPreference(KEY_ACCENT_COLOR).setOnPreferenceClickListener(this); findPreference(KEY_SECTIONS_ICON).setOnPreferenceChangeListener(this); findPreference(KEY_APPLY_ON_BOOT_TEST).setOnPreferenceClickListener(this); findPreference(KEY_LOGCAT).setOnPreferenceClickListener(this); if (Utils.existFile("/proc/last_kmsg") || Utils.existFile("/sys/fs/pstore/console-ramoops")) { findPreference(KEY_LAST_KMSG).setOnPreferenceClickListener(this); } else { ((PreferenceCategory) findPreference(KEY_DEBUGGING_CATEGORY)).removePreference( findPreference(KEY_LAST_KMSG)); } findPreference(KEY_DMESG).setOnPreferenceClickListener(this); findPreference(KEY_SET_PASSWORD).setOnPreferenceClickListener(this); findPreference(KEY_DELETE_PASSWORD).setOnPreferenceClickListener(this); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M || !FingerprintManagerCompat.from(getActivity()).isHardwareDetected()) { ((PreferenceCategory) findPreference(KEY_SECURITY_CATEGORY)).removePreference( findPreference(KEY_FINGERPRINT)); } else { mFingerprint = findPreference(KEY_FINGERPRINT); mFingerprint.setEnabled(!AppSettings.getPassword(getActivity()).isEmpty()); } NavigationActivity activity = (NavigationActivity) getActivity(); PreferenceCategory sectionsCategory = (PreferenceCategory) findPreference(KEY_SECTIONS); for (NavigationActivity.NavigationFragment navigationFragment : activity.getFragments()) { Class<? extends Fragment> fragmentClass = navigationFragment.mFragmentClass; int id = navigationFragment.mId; if (fragmentClass != null && fragmentClass != SettingsFragment.class) { SwitchPreferenceCompat switchPreference = new SwitchPreferenceCompat( new ContextThemeWrapper(getActivity(), R.style.Preference_SwitchPreferenceCompat_Material)); switchPreference.setSummary(getString(id)); switchPreference.setKey(fragmentClass.getSimpleName() + "_enabled"); switchPreference.setChecked(AppSettings.isFragmentEnabled(fragmentClass, getActivity())); switchPreference.setOnPreferenceChangeListener(this); switchPreference.setPersistent(true); sectionsCategory.addPreference(switchPreference); } } }