Java Code Examples for android.preference.CheckBoxPreference#setEnabled()
The following examples show how to use
android.preference.CheckBoxPreference#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: SettingsFragment.java From glimmr with Apache License 2.0 | 6 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.preferences); PreferenceManager.setDefaultValues(getActivity(), R.xml.preferences, false); mSharedPrefs = PreferenceManager .getDefaultSharedPreferences(getActivity()); mIntervalsListPreference = (ListPreference) getPreferenceScreen() .findPreference(Constants.KEY_INTERVALS_LIST_PREFERENCE); mInitialTabListPreference = (ListPreference) getPreferenceScreen() .findPreference(Constants.KEY_INITIAL_TAB_LIST_PREFERENCE); mSlideshowIntervalPreference = (EditTextPreference) getPreferenceScreen().findPreference( Constants.KEY_SLIDESHOW_INTERVAL); mHighQualityThumbsCbPreference = (CheckBoxPreference) getPreferenceScreen() .findPreference(Constants.KEY_HIGH_QUALITY_THUMBNAILS); if (Constants.PRO_VERSION) { mHighQualityThumbsCbPreference.setEnabled(true); } }
Example 2
Source File: PreferencesActivity.java From crazyflie-android-client with GNU General Public License v2.0 | 6 votes |
private void checkGyroSensors() { //Test the available sensors SensorManager sensorManager = (SensorManager) getActivity().getSystemService(Context.SENSOR_SERVICE); CheckBoxPreference pref = (CheckBoxPreference) findPreference(KEY_PREF_USE_GYRO_BOOL); if (sensorManager.getDefaultSensor(Sensor.TYPE_ROTATION_VECTOR) == null && sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER) == null) { pref.setEnabled(false); pref.setChecked(false); resetPreference(KEY_PREF_USE_GYRO_BOOL, false); mNoGyroSensor = true; pref.setSummaryOff("No gyro or accelerometer sensors found"); Log.i(LOG_TAG, "No gyro or accelerometer sensors found"); } else { pref.setEnabled(true); mNoGyroSensor = false; } }
Example 3
Source File: GameSettingsActivity.java From opensudoku with GNU General Public License v3.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { ThemeUtils.setThemeFromPreferences(this); mTimestampWhenApplyingTheme = System.currentTimeMillis(); super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.game_settings); findPreference("show_hints").setOnPreferenceChangeListener(mShowHintsChanged); findPreference("theme").setOnPreferenceChangeListener(((preference, newValue) -> { recreate(); return true; })); ListPreference themePreference = (ListPreference) findPreference("theme"); mScreenCustomTheme = (PreferenceGroup)findPreference("screen_custom_theme"); enableScreenCustomTheme(themePreference.getValue()); mScreenCustomTheme.setOnPreferenceChangeListener((preference, newValue) -> { recreate(); return true; }); mHighlightSimilarNotesPreference = (CheckBoxPreference)findPreference("highlight_similar_notes"); CheckBoxPreference highlightSimilarCellsPreference = (CheckBoxPreference)findPreference("highlight_similar_cells"); highlightSimilarCellsPreference.setOnPreferenceChangeListener(mHighlightSimilarCellsChanged); mHighlightSimilarNotesPreference.setEnabled(highlightSimilarCellsPreference.isChecked()); }
Example 4
Source File: SyncCustomizationFragment.java From 365browser with Apache License 2.0 | 5 votes |
/** * Update the data type switch state. * * If sync is on, load the prefs from native. Otherwise, all data types are disabled and * checked. Note that the Password data type will be shown as disabled and unchecked between * sync being turned on and the engine initialization completing. */ private void updateDataTypeState() { boolean isSyncEnabled = mSyncSwitchPreference.isChecked(); boolean syncEverything = mSyncEverything.isChecked(); boolean passwordSyncConfigurable = mProfileSyncService.isEngineInitialized() && mProfileSyncService.isCryptographerReady(); Set<Integer> syncTypes = mProfileSyncService.getPreferredDataTypes(); boolean syncAutofill = syncTypes.contains(ModelType.AUTOFILL); for (CheckBoxPreference pref : mAllTypes) { boolean canSyncType = true; if (pref == mSyncPasswords) canSyncType = passwordSyncConfigurable; if (pref == mPaymentsIntegration) { canSyncType = syncAutofill || syncEverything; } if (!isSyncEnabled) { pref.setChecked(true); } else if (syncEverything) { pref.setChecked(canSyncType); } pref.setEnabled(isSyncEnabled && !syncEverything && canSyncType); } if (isSyncEnabled && !syncEverything) { mSyncAutofill.setChecked(syncAutofill); mSyncBookmarks.setChecked(syncTypes.contains(ModelType.BOOKMARKS)); mSyncOmnibox.setChecked(syncTypes.contains(ModelType.TYPED_URLS)); mSyncPasswords.setChecked(passwordSyncConfigurable && syncTypes.contains(ModelType.PASSWORDS)); mSyncRecentTabs.setChecked(syncTypes.contains(ModelType.PROXY_TABS)); mSyncSettings.setChecked(syncTypes.contains(ModelType.PREFERENCES)); mPaymentsIntegration.setChecked( syncAutofill && PersonalDataManager.isPaymentsIntegrationEnabled()); } }
Example 5
Source File: SettingsFragment.java From Linphone4Android with GNU General Public License v3.0 | 5 votes |
private void initNetworkSettings() { ((CheckBoxPreference) findPreference(getString(R.string.pref_wifi_only_key))).setChecked(mPrefs.isWifiOnlyEnabled()); // Disable UPnP if ICE si enabled, or disable ICE if UPnP is enabled CheckBoxPreference ice = (CheckBoxPreference) findPreference(getString(R.string.pref_ice_enable_key)); CheckBoxPreference turn = (CheckBoxPreference) findPreference(getString(R.string.pref_turn_enable_key)); ice.setChecked(mPrefs.isIceEnabled()); turn.setEnabled(mPrefs.getStunServer() != null); turn.setChecked(mPrefs.isTurnEnabled()); EditTextPreference turnUsername = (EditTextPreference) findPreference(getString(R.string.pref_turn_username_key)); EditTextPreference turnPassword = (EditTextPreference) findPreference(getString(R.string.pref_turn_passwd_key)); turnUsername.setEnabled(mPrefs.isTurnEnabled()); turnUsername.setSummary(mPrefs.getTurnUsername()); turnUsername.setText(mPrefs.getTurnUsername()); turnPassword.setEnabled(mPrefs.isTurnEnabled()); CheckBoxPreference randomPort = (CheckBoxPreference) findPreference(getString(R.string.pref_transport_use_random_ports_key)); randomPort.setChecked(mPrefs.isUsingRandomPort()); // Disable sip port choice if port is random EditTextPreference sipPort = (EditTextPreference) findPreference(getString(R.string.pref_sip_port_key)); sipPort.setEnabled(!randomPort.isChecked()); sipPort.setSummary(mPrefs.getSipPort()); sipPort.setText(mPrefs.getSipPort()); EditTextPreference stun = (EditTextPreference) findPreference(getString(R.string.pref_stun_server_key)); stun.setSummary(mPrefs.getStunServer()); stun.setText(mPrefs.getStunServer()); ((CheckBoxPreference) findPreference(getString(R.string.pref_push_notification_key))).setChecked(mPrefs.isPushNotificationEnabled()); ((CheckBoxPreference) findPreference(getString(R.string.pref_ipv6_key))).setChecked(mPrefs.isUsingIpv6()); }
Example 6
Source File: PreferenceMatchersTest.java From android-test with Apache License 2.0 | 5 votes |
@Test @UiThreadTest public void isEnabledTest() { CheckBoxPreference pref = new CheckBoxPreference(getApplicationContext()); pref.setEnabled(true); assertThat(pref, isEnabled()); pref.setEnabled(false); assertThat(pref, not(isEnabled())); EditTextPreference pref2 = new EditTextPreference(getApplicationContext()); pref2.setEnabled(true); assertThat(pref2, isEnabled()); pref2.setEnabled(false); assertThat(pref2, not(isEnabled())); }
Example 7
Source File: FourchanModule.java From Overchan-Android with GNU General Public License v3.0 | 5 votes |
@Override public void addPreferencesOnScreen(PreferenceGroup preferenceGroup) { Context context = preferenceGroup.getContext(); addPasscodePreference(preferenceGroup); CheckBoxPreference newRecaptchaPref = new LazyPreferences.CheckBoxPreference(context); newRecaptchaPref.setTitle(R.string.fourchan_prefs_new_recaptcha); newRecaptchaPref.setSummary(R.string.fourchan_prefs_new_recaptcha_summary); newRecaptchaPref.setKey(getSharedKey(PREF_KEY_NEW_RECAPTCHA)); newRecaptchaPref.setDefaultValue(NEW_RECAPTCHA_DEFAULT); preferenceGroup.addPreference(newRecaptchaPref); final CheckBoxPreference fallbackRecaptchaPref = new LazyPreferences.CheckBoxPreference(context); fallbackRecaptchaPref.setTitle(R.string.fourchan_prefs_new_recaptcha_fallback); fallbackRecaptchaPref.setSummary(R.string.fourchan_prefs_new_recaptcha_fallback_summary); fallbackRecaptchaPref.setKey(getSharedKey(PREF_KEY_NEW_RECAPTCHA_FALLBACK)); fallbackRecaptchaPref.setDefaultValue(false); preferenceGroup.addPreference(fallbackRecaptchaPref); fallbackRecaptchaPref.setDependency(getSharedKey(PREF_KEY_NEW_RECAPTCHA)); addPasswordPreference(preferenceGroup); addHttpsPreference(preferenceGroup, true); addProxyPreferences(preferenceGroup); final CheckBoxPreference proxyPreference = (CheckBoxPreference) preferenceGroup.findPreference(getSharedKey(PREF_KEY_USE_PROXY)); fallbackRecaptchaPref.setEnabled(!proxyPreference.isChecked()); proxyPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { fallbackRecaptchaPref.setEnabled(!proxyPreference.isChecked()); if (proxyPreference.isChecked() && !fallbackRecaptchaPref.isChecked()) fallbackRecaptchaPref.setChecked(true); return false; } }); }
Example 8
Source File: SettingsActivity.java From Hews with MIT License | 5 votes |
private void disableOpenLinkOptionPreference() { CheckBoxPreference openLinkOptionPref = (CheckBoxPreference) findPreference( getString(R.string.pref_key_open_link_option)); openLinkOptionPref.setEnabled(false); openLinkOptionPref.setChecked(false); openLinkOptionPref.setSummary(R.string.summary_open_link_option_unavailable); }
Example 9
Source File: ActiveScreenActivity.java From GravityBox with Apache License 2.0 | 5 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mPrefs = SharedPreferencesUtils.getSharedPreferences(getPreferenceManager(), "ledcontrol"); addPreferencesFromResource(R.xml.led_control_active_screen_settings); mPrefPocketMode = (CheckBoxPreference) findPreference( LedSettings.PREF_KEY_ACTIVE_SCREEN_POCKET_MODE); if (LedSettings.isProximityWakeUpEnabled(getActivity())) { mPrefPocketMode.setSummary(R.string.pref_unc_as_pocket_mode_summary_overriden); mPrefPocketMode.setEnabled(false); } }
Example 10
Source File: SettingFragment.java From SeeWeather with Apache License 2.0 | 5 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.setting); mSharedPreferenceUtil = SharedPreferenceUtil.getInstance(); mChangeIcons = findPreference(SharedPreferenceUtil.CHANGE_ICONS); mChangeUpdate = findPreference(SharedPreferenceUtil.AUTO_UPDATE); mClearCache = findPreference(SharedPreferenceUtil.CLEAR_CACHE); mAnimationOnOff = (CheckBoxPreference) findPreference(SharedPreferenceUtil.ANIM_START); mNotificationType = (CheckBoxPreference) findPreference(SharedPreferenceUtil.NOTIFICATION_MODEL); mWatcherSwitch = (CheckBoxPreference) findPreference(SharedPreferenceUtil.WATCHER); mNotificationType.setChecked( SharedPreferenceUtil.getInstance().getNotificationModel() == Notification.FLAG_ONGOING_EVENT); mAnimationOnOff.setChecked(SharedPreferenceUtil.getInstance().getMainAnim()); mWatcherSwitch.setChecked(SharedPreferenceUtil.getInstance().getWatcherSwitch()); if (Build.VERSION.SDK_INT >= 23 && !Settings.canDrawOverlays(getContext())) { mWatcherSwitch.setEnabled(false); } mChangeIcons.setSummary(getResources().getStringArray(R.array.icons)[mSharedPreferenceUtil.getIconType()]); mChangeUpdate.setSummary( mSharedPreferenceUtil.getAutoUpdate() == 0 ? "禁止刷新" : "每" + mSharedPreferenceUtil.getAutoUpdate() + "小时更新"); mClearCache.setSummary(FileSizeUtil.getAutoFileOrFilesSize(C.NET_CACHE)); mChangeIcons.setOnPreferenceClickListener(this); mChangeUpdate.setOnPreferenceClickListener(this); mClearCache.setOnPreferenceClickListener(this); mNotificationType.setOnPreferenceChangeListener(this); mAnimationOnOff.setOnPreferenceChangeListener(this); mWatcherSwitch.setOnPreferenceChangeListener(this); }
Example 11
Source File: Pref.java From GeoLog with Apache License 2.0 | 5 votes |
public static CheckBoxPreference Check(Context context, PreferenceCategory category, int caption, int summary, String key, Object defaultValue, boolean enabled) { CheckBoxPreference retval = new CheckBoxPreference(context); if (caption > 0) retval.setTitle(caption); if (summary > 0) retval.setSummary(summary); retval.setEnabled(enabled); retval.setKey(key); retval.setDefaultValue(defaultValue); if (category != null) category.addPreference(retval); return retval; }
Example 12
Source File: SyncCustomizationFragment.java From delion with Apache License 2.0 | 5 votes |
/** * Update the data type switch state. * * If sync is on, load the prefs from native. Otherwise, all data types are disabled and * checked. Note that the Password data type will be shown as disabled and unchecked between * sync being turned on and the backend initialization completing. */ private void updateDataTypeState() { boolean isSyncEnabled = mSyncSwitchPreference.isChecked(); boolean syncEverything = mSyncEverything.isChecked(); boolean passwordSyncConfigurable = mProfileSyncService.isBackendInitialized() && mProfileSyncService.isCryptographerReady(); Set<Integer> syncTypes = mProfileSyncService.getPreferredDataTypes(); boolean syncAutofill = syncTypes.contains(ModelType.AUTOFILL); for (CheckBoxPreference pref : mAllTypes) { boolean canSyncType = true; if (pref == mSyncPasswords) canSyncType = passwordSyncConfigurable; if (pref == mPaymentsIntegration) { canSyncType = syncAutofill || syncEverything; } if (!isSyncEnabled) { pref.setChecked(true); } else if (syncEverything) { pref.setChecked(canSyncType); } pref.setEnabled(isSyncEnabled && !syncEverything && canSyncType); } if (isSyncEnabled && !syncEverything) { mSyncAutofill.setChecked(syncAutofill); mSyncBookmarks.setChecked(syncTypes.contains(ModelType.BOOKMARKS)); mSyncOmnibox.setChecked(syncTypes.contains(ModelType.TYPED_URLS)); mSyncPasswords.setChecked(passwordSyncConfigurable && syncTypes.contains(ModelType.PASSWORDS)); mSyncRecentTabs.setChecked(syncTypes.contains(ModelType.PROXY_TABS)); // TODO(zea): Switch this to PREFERENCE once that datatype is // supported on Android. mSyncSettings.setChecked(syncTypes.contains(ModelType.PRIORITY_PREFERENCES)); mPaymentsIntegration.setChecked( syncAutofill && PersonalDataManager.isPaymentsIntegrationEnabled()); } }
Example 13
Source File: SettingsFragment.java From Torchie-Android with GNU General Public License v2.0 | 4 votes |
private void ableCheckboxPref(CheckBoxPreference checkBoxPreference, boolean enable) { checkBoxPreference.setEnabled(enable); }
Example 14
Source File: XmlSettingsActivity.java From WhereYouGo with GNU General Public License v3.0 | 4 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setTitle(R.string.settings); needRestart = false; /* workaround: I don't really know why I cannot call CustomActivity.customOnCreate(this); - OMG! */ switch (Preferences.APPEARANCE_FONT_SIZE) { case PreferenceValues.VALUE_FONT_SIZE_SMALL: this.setTheme(R.style.FontSizeSmall); break; case PreferenceValues.VALUE_FONT_SIZE_MEDIUM: this.setTheme(R.style.FontSizeMedium); break; case PreferenceValues.VALUE_FONT_SIZE_LARGE: this.setTheme(R.style.FontSizeLarge); break; } /* * */ addPreferencesFromResource(R.xml.whereyougo_preferences); PreferenceManager.getDefaultSharedPreferences(this).registerOnSharedPreferenceChangeListener(this); /* * Remove internal preferences */ Preference somePreference = findPreference(R.string.pref_KEY_X_HIDDEN_PREFERENCES); PreferenceScreen preferenceScreen = getPreferenceScreen(); preferenceScreen.removePreference(somePreference); /* * Register OnClick handler */ Preference preferenceRoot = findPreference(R.string.pref_KEY_S_ROOT); preferenceRoot.setOnPreferenceClickListener(this); Preference preferenceAbout = findPreference(R.string.pref_KEY_X_ABOUT); if (preferenceAbout != null) { preferenceAbout.setOnPreferenceClickListener(this); } /* * Workaround: Update/set value preview */ // String dir = Preferences.getStringPreference( R.string.pref_KEY_S_ROOT ); // x.setSummary( "(" + dir + ") " + Locale.getString( R.string.pref_root_desc ) ); // TODO make it better :-( /* TODO - check this code */ if (!Utils.isAndroid201OrMore()) { Preference prefSensorFilter = findPreference(R.string.pref_KEY_S_SENSORS_ORIENT_FILTER); if (prefSensorFilter != null) { prefSensorFilter.setEnabled(false); } } if (getIntent() != null && getIntent().hasExtra(getString(R.string.pref_KEY_X_LOGIN_PREFERENCES))) { Preference preferenceLogin = findPreference(R.string.pref_KEY_X_LOGIN_PREFERENCES); if (preferenceLogin != null) { PreferenceScreen screen = getPreferenceScreen(); for (int i = 0; i < screen.getPreferenceCount(); ++i) { if (screen.getPreference(i) == preferenceLogin) { getIntent().putExtra(getString(R.string.pref_KEY_X_LOGIN_PREFERENCES), false); screen.onItemClick(null, null, i, 0); break; } } } } /* * Enable/disable status bar propertie */ if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) { CheckBoxPreference status_bar = (CheckBoxPreference) findPreference(R.string.pref_KEY_B_STATUSBAR); CheckBoxPreference gps_hide = (CheckBoxPreference) findPreference(R.string.pref_KEY_B_GPS_DISABLE_WHEN_HIDE); CheckBoxPreference gps_guiding = (CheckBoxPreference) findPreference(R.string.pref_KEY_B_GUIDING_GPS_REQUIRED); if (gps_hide.isChecked()) { status_bar.setEnabled(!gps_guiding.isChecked()); } else { status_bar.setEnabled(false); } } }
Example 15
Source File: PrivacySettingsFragment.java From Xndroid with GNU General Public License v3.0 | 4 votes |
private void initPrefs() { Preference clearcache = findPreference(SETTINGS_CLEARCACHE); Preference clearhistory = findPreference(SETTINGS_CLEARHISTORY); Preference clearcookies = findPreference(SETTINGS_CLEARCOOKIES); Preference clearwebstorage = findPreference(SETTINGS_CLEARWEBSTORAGE); CheckBoxPreference cblocation = (CheckBoxPreference) findPreference(SETTINGS_LOCATION); CheckBoxPreference cb3cookies = (CheckBoxPreference) findPreference(SETTINGS_THIRDPCOOKIES); CheckBoxPreference cbsavepasswords = (CheckBoxPreference) findPreference(SETTINGS_SAVEPASSWORD); CheckBoxPreference cbcacheexit = (CheckBoxPreference) findPreference(SETTINGS_CACHEEXIT); CheckBoxPreference cbhistoryexit = (CheckBoxPreference) findPreference(SETTINGS_HISTORYEXIT); CheckBoxPreference cbcookiesexit = (CheckBoxPreference) findPreference(SETTINGS_COOKIEEXIT); CheckBoxPreference cbwebstorageexit = (CheckBoxPreference) findPreference(SETTINGS_WEBSTORAGEEXIT); CheckBoxPreference cbDoNotTrack = (CheckBoxPreference) findPreference(SETTINGS_DONOTTRACK); CheckBoxPreference cbIdentifyingHeaders = (CheckBoxPreference) findPreference(SETTINGS_IDENTIFYINGHEADERS); clearcache.setOnPreferenceClickListener(this); clearhistory.setOnPreferenceClickListener(this); clearcookies.setOnPreferenceClickListener(this); clearwebstorage.setOnPreferenceClickListener(this); cblocation.setOnPreferenceChangeListener(this); cb3cookies.setOnPreferenceChangeListener(this); cbsavepasswords.setOnPreferenceChangeListener(this); cbcacheexit.setOnPreferenceChangeListener(this); cbhistoryexit.setOnPreferenceChangeListener(this); cbcookiesexit.setOnPreferenceChangeListener(this); cbwebstorageexit.setOnPreferenceChangeListener(this); cbDoNotTrack.setOnPreferenceChangeListener(this); cbIdentifyingHeaders.setOnPreferenceChangeListener(this); cblocation.setChecked(mPreferenceManager.getLocationEnabled()); cbsavepasswords.setChecked(mPreferenceManager.getSavePasswordsEnabled()); cbcacheexit.setChecked(mPreferenceManager.getClearCacheExit()); cbhistoryexit.setChecked(mPreferenceManager.getClearHistoryExitEnabled()); cbcookiesexit.setChecked(mPreferenceManager.getClearCookiesExitEnabled()); cb3cookies.setChecked(mPreferenceManager.getBlockThirdPartyCookiesEnabled()); cbwebstorageexit.setChecked(mPreferenceManager.getClearWebStorageExitEnabled()); cbDoNotTrack.setChecked(mPreferenceManager.getDoNotTrackEnabled() && Utils.doesSupportHeaders()); cbIdentifyingHeaders.setChecked(mPreferenceManager.getRemoveIdentifyingHeadersEnabled() && Utils.doesSupportHeaders()); cbDoNotTrack.setEnabled(Utils.doesSupportHeaders()); cbIdentifyingHeaders.setEnabled(Utils.doesSupportHeaders()); String identifyingHeadersSummary = LightningView.HEADER_REQUESTED_WITH + ", " + LightningView.HEADER_WAP_PROFILE; cbIdentifyingHeaders.setSummary(identifyingHeadersSummary); cb3cookies.setEnabled(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP); }
Example 16
Source File: PGPClipperSettingsActivity.java From PGPClipper with Apache License 2.0 | 4 votes |
@Override protected void onResume() { super.onResume(); final ListPreference themePref = (ListPreference) fragment.findPreference("themeSelection"); final SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); final CheckBoxPreference fingerprintCheckboxPreference = (CheckBoxPreference) fragment.findPreference("enableFingerprintAuth"); final CheckBoxPreference pgpClipperEnabledCheckbox = (CheckBoxPreference) fragment.findPreference("pgpClipperEnabledCheckbox"); themePref.setEntryValues(R.array.themes_values); themePref.setEntries(R.array.themes); String currentVal = sharedPreferences.getString("themeSelection", "dark"); if (currentVal != null) { switch (currentVal) { case "dark": themePref.setSummary(getResources().getString(R.string.darkText)); break; case "light": themePref.setSummary(getResources().getString(R.string.lightText)); break; } } String providerApp = sharedPreferences.getString("pgpServiceProviderApp", null); if (providerApp == null || "".equals(providerApp)) { pgpClipperEnabledCheckbox.setEnabled(false); pgpClipperEnabledCheckbox.setChecked(false); stopService(new Intent(PGPClipperSettingsActivity.this, PGPClipperService.class)); } else { if (pgpClipperEnabledCheckbox.isChecked()) { startService(new Intent(PGPClipperSettingsActivity.this, PGPClipperService.class)); } pgpClipperEnabledCheckbox.setEnabled(true); } if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.M) // Fingerprint API not supported below M fingerprintCheckboxPreference.setEnabled(false); else { fingerprintCheckboxPreference.setEnabled(true); } }
Example 17
Source File: PrivacySettingsFragment.java From JumpGo with Mozilla Public License 2.0 | 4 votes |
private void initPrefs() { Preference clearcache = findPreference(SETTINGS_CLEARCACHE); Preference clearhistory = findPreference(SETTINGS_CLEARHISTORY); Preference clearcookies = findPreference(SETTINGS_CLEARCOOKIES); Preference clearwebstorage = findPreference(SETTINGS_CLEARWEBSTORAGE); CheckBoxPreference cblocation = (CheckBoxPreference) findPreference(SETTINGS_LOCATION); CheckBoxPreference cb3cookies = (CheckBoxPreference) findPreference(SETTINGS_THIRDPCOOKIES); CheckBoxPreference cbsavepasswords = (CheckBoxPreference) findPreference(SETTINGS_SAVEPASSWORD); CheckBoxPreference cbcacheexit = (CheckBoxPreference) findPreference(SETTINGS_CACHEEXIT); CheckBoxPreference cbhistoryexit = (CheckBoxPreference) findPreference(SETTINGS_HISTORYEXIT); CheckBoxPreference cbcookiesexit = (CheckBoxPreference) findPreference(SETTINGS_COOKIEEXIT); CheckBoxPreference cbwebstorageexit = (CheckBoxPreference) findPreference(SETTINGS_WEBSTORAGEEXIT); CheckBoxPreference cbDoNotTrack = (CheckBoxPreference) findPreference(SETTINGS_DONOTTRACK); CheckBoxPreference cbIdentifyingHeaders = (CheckBoxPreference) findPreference(SETTINGS_IDENTIFYINGHEADERS); clearcache.setOnPreferenceClickListener(this); clearhistory.setOnPreferenceClickListener(this); clearcookies.setOnPreferenceClickListener(this); clearwebstorage.setOnPreferenceClickListener(this); cblocation.setOnPreferenceChangeListener(this); cb3cookies.setOnPreferenceChangeListener(this); cbsavepasswords.setOnPreferenceChangeListener(this); cbcacheexit.setOnPreferenceChangeListener(this); cbhistoryexit.setOnPreferenceChangeListener(this); cbcookiesexit.setOnPreferenceChangeListener(this); cbwebstorageexit.setOnPreferenceChangeListener(this); cbDoNotTrack.setOnPreferenceChangeListener(this); cbIdentifyingHeaders.setOnPreferenceChangeListener(this); cblocation.setChecked(mPreferenceManager.getLocationEnabled()); cbsavepasswords.setChecked(mPreferenceManager.getSavePasswordsEnabled()); cbcacheexit.setChecked(mPreferenceManager.getClearCacheExit()); cbhistoryexit.setChecked(mPreferenceManager.getClearHistoryExitEnabled()); cbcookiesexit.setChecked(mPreferenceManager.getClearCookiesExitEnabled()); cb3cookies.setChecked(mPreferenceManager.getBlockThirdPartyCookiesEnabled()); cbwebstorageexit.setChecked(mPreferenceManager.getClearWebStorageExitEnabled()); cbDoNotTrack.setChecked(mPreferenceManager.getDoNotTrackEnabled() && Utils.doesSupportHeaders()); cbIdentifyingHeaders.setChecked(mPreferenceManager.getRemoveIdentifyingHeadersEnabled() && Utils.doesSupportHeaders()); cbDoNotTrack.setEnabled(Utils.doesSupportHeaders()); cbIdentifyingHeaders.setEnabled(Utils.doesSupportHeaders()); String identifyingHeadersSummary = LightningView.HEADER_REQUESTED_WITH + ", " + LightningView.HEADER_WAP_PROFILE; cbIdentifyingHeaders.setSummary(identifyingHeadersSummary); cb3cookies.setEnabled(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP); }
Example 18
Source File: PreferencesFragment.java From itracing2 with GNU General Public License v2.0 | 4 votes |
public void setForegroundBackground(final boolean checked) { final CheckBoxPreference preference = (CheckBoxPreference) findPreference(Preferences.FOREGROUND); preference.setChecked(checked); preference.setEnabled(!checked); }
Example 19
Source File: Settings.java From SMP with GNU General Public License v3.0 | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { Log.d("Settings", "onCreate"); super.onCreate(savedInstanceState); params = new ParametersImpl(this); // fixme: everything should be put in onResume? addPreferencesFromResource(R.xml.preferences); playIntent = new Intent(this, MusicService.class); bindService(playIntent, musicConnection, Context.BIND_AUTO_CREATE); SharedPreferences sharedPreferences = getPreferenceScreen().getSharedPreferences(); String thresholdKeys = PrefKeys.SHAKE_THRESHOLD.name(); EditTextPreference prefShakeThreshold = (EditTextPreference) findPreference(thresholdKeys); CheckBoxPreference prefEnableShake = (CheckBoxPreference) findPreference(PrefKeys.ENABLE_SHAKE.name()); if(getPackageManager().hasSystemFeature(PackageManager.FEATURE_SENSOR_ACCELEROMETER)) { prefShakeThreshold.setSummary(String.valueOf(params.getShakeThreshold())); prefEnableShake.setChecked(params.getEnableShake()); } else { prefShakeThreshold.setEnabled(false); prefEnableShake.setEnabled(false); Toast.makeText(getApplicationContext(), getResources().getString(R.string.settings_no_accelerometer), Toast.LENGTH_LONG).show(); } findPreference(PrefKeys.TEXT_SIZE_NORMAL.name()).setSummary(String.valueOf(params.getNormalTextSize())); findPreference(PrefKeys.TEXT_SIZE_BIG.name()).setSummary(String.valueOf(params.getBigTextSize())); findPreference(PrefKeys.TEXT_SIZE_RATIO.name()).setSummary(String.valueOf(params.getTextSizeRatio())); Preference rescan = findPreference(getResources().getString(R.string.settings_rescan_key)); rescan.setOnPreferenceClickListener(this); Preference donate = findPreference(getResources().getString(R.string.settings_donate_key)); donate.setOnPreferenceClickListener(this); setUnfoldSubgroup(); setUnfoldThresholdSummary(); String rootFoldersKey = PrefKeys.ROOT_FOLDERS.name(); EditTextPreference prefRootFolders = (EditTextPreference) findPreference(rootFoldersKey); prefRootFolders.setSummary(params.getRootFolders()); if(!sharedPreferences.contains(rootFoldersKey)) prefRootFolders.setText(Path.getMusicStoragesStr(getBaseContext())); setFoldSummary(); this.onContentChanged(); }
Example 20
Source File: GeneralSettingsFragment.java From NotificationPeekPort with Apache License 2.0 | 4 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.preferences); // Appearance settings entrance. Preference appearancePref = findPreference(PreferenceKeys.PREF_APPEARANCE); appearancePref.setOnPreferenceClickListener(this); // Clock preference. CheckBoxPreference clockPref = (CheckBoxPreference) findPreference(PreferenceKeys.PREF_CLOCK); clockPref.setOnPreferenceChangeListener(this); // Always show content preference. CheckBoxPreference alwaysShowContentPref = (CheckBoxPreference) findPreference(PreferenceKeys.PREF_ALWAYS_SHOW_CONTENT); alwaysShowContentPref.setOnPreferenceChangeListener(this); // Notification Peek timeout preference. ListPreference peekTimeoutPref = (ListPreference) findPreference(PreferenceKeys.PREF_PEEK_TIMEOUT); peekTimeoutPref.setOnPreferenceChangeListener(this); bindPreferenceSummaryToValue(peekTimeoutPref); // Listen forever preference. ListPreference sensorTimeoutPref = (ListPreference) findPreference(PreferenceKeys.PREF_SENSOR_TIMEOUT); sensorTimeoutPref.setOnPreferenceChangeListener(this); bindPreferenceSummaryToValue(sensorTimeoutPref); // Gyroscope sensor enable/disable preference. CheckBoxPreference gyroPref = (CheckBoxPreference) findPreference(PreferenceKeys.PREF_GYRO_SENSOR); if (!SensorHelper.checkSensorStatus(getActivity(), SensorHelper.SENSOR_GYRO, false)) { // No gyroscope sensor found. gyroPref.setEnabled(false); } else { gyroPref.setEnabled(true); gyroPref.setOnPreferenceChangeListener(this); } // Proximity/Light sensor enable/disable preference. CheckBoxPreference proxPref = (CheckBoxPreference) findPreference(PreferenceKeys.PREF_PROX_LIGHT_SENSOR); if (!SensorHelper .checkSensorStatus(getActivity(), SensorHelper.SENSOR_PROXIMITY_LIGHT, false)) { // No proximity or light sensor found. proxPref.setEnabled(false); } else { proxPref.setEnabled(true); proxPref.setOnPreferenceChangeListener(this); } }