android.preference.CheckBoxPreference Java Examples
The following examples show how to use
android.preference.CheckBoxPreference.
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: FakeSignatureGlobalUI.java From haystack with GNU General Public License v3.0 | 6 votes |
static CheckBoxPreference addPreference(PreferenceFragment fragment) { //>5.1// static SwitchPreference addPreference(PreferenceFragment fragment) { PreferenceGroup pg = (PreferenceGroup) fragment.findPreference(PREFERENCE_CATEGORY_KEY); if (pg != null) { /*<5.1*/ CheckBoxPreference p = new CheckBoxPreference(pg.getContext()); //>5.1// SwitchPreference p = new SwitchPreference(pg.getContext()); p.setKey(PREFERENCE_KEY); p.setTitle(PREFERENCE_TITLE); p.setSummary(PREFERENCE_SUMMARY); p.setPersistent(false); pg.addPreference(p); return p; } else { Log.e("FakeSignatureGlobalUI", "cannot find '" + PREFERENCE_CATEGORY_KEY +"' preference category"); return null; } }
Example #2
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 #3
Source File: SettingsFragment.java From secrecy with Apache License 2.0 | 6 votes |
private void preparePreferenceStealthMode(){ final CheckBoxPreference stealth_mode = (CheckBoxPreference) findPreference(Config.STEALTH_MODE); stealth_mode.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object o) { SharedPreferences.Editor editor = PreferenceManager.getDefaultSharedPreferences(getActivity()).edit(); if (!(Boolean) o) { StealthMode.showApp(context); editor.putBoolean(Config.STEALTH_MODE, (Boolean) o); editor.putString(Config.STEALTH_MODE_PASSWORD, ""); editor.apply(); } else { editor.putBoolean(Config.STEALTH_MODE, (Boolean) o); editor.apply(); } return true; } }); }
Example #4
Source File: FakeSignatureGlobalUI.java From haystack with GNU General Public License v3.0 | 6 votes |
static CheckBoxPreference addPreference(PreferenceFragment fragment) { //>5.1// static SwitchPreference addPreference(PreferenceFragment fragment) { PreferenceGroup pg = (PreferenceGroup) fragment.findPreference(PREFERENCE_CATEGORY_KEY); if (pg != null) { /*<5.1*/ CheckBoxPreference p = new CheckBoxPreference(pg.getContext()); //>5.1// SwitchPreference p = new SwitchPreference(pg.getContext()); p.setKey(PREFERENCE_KEY); p.setTitle(PREFERENCE_TITLE); p.setSummary(PREFERENCE_SUMMARY); p.setPersistent(false); pg.addPreference(p); return p; } else { Log.e("FakeSignatureGlobalUI", "cannot find '" + PREFERENCE_CATEGORY_KEY +"' preference category"); return null; } }
Example #5
Source File: PrefFragment.java From NetUpDown with Apache License 2.0 | 6 votes |
@TargetApi(14) @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.preferences); /* * SwitchPreferences calls multiple times the onPreferenceChange() method * It is due to the bug in SwitchPreference implementation. * And it's solved in API 21+ */ //if (C.SDK >= 14) { if (C.SDK >= 21) { switchPreference = (SwitchPreference) findPreference("run"); } else { checkBoxPreference = (CheckBoxPreference) findPreference("run"); } findPreference("run").setOnPreferenceChangeListener(this); serviceReceiver = new ServiceReceiver(); sp = new SP(getActivity()); }
Example #6
Source File: SettingFragment.java From NewsMe with Apache License 2.0 | 6 votes |
@Override public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) { String key = preference.getKey(); if (getString(R.string.pre_clear_cache).equals(key)) { clearCache(); } else if (getString(R.string.pre_reputation).equals(key)) { soureApp(); } else if (getString(R.string.pre_share).equals(key)) { shareFriend(); } else if (getString(R.string.pre_feedback).equals(key)) { feedback(); } else if (getString(R.string.pre_version).equals(key)) { version(); } else if (getString(R.string.pre_hid_benefits).equals(key)) { seleteSex((CheckBoxPreference) preference); } else if (getString(R.string.pre_app_wall).equals(key)) { appWall(); } return super.onPreferenceTreeClick(preferenceScreen, preference); }
Example #7
Source File: TwoStatePreferenceHelper.java From simple-keyboard with Apache License 2.0 | 6 votes |
static void addSwitchPreferenceBasedOnCheckBoxPreference(final CheckBoxPreference checkBox, final PreferenceGroup group) { final SwitchPreference switchPref = new SwitchPreference(checkBox.getContext()); switchPref.setTitle(checkBox.getTitle()); switchPref.setKey(checkBox.getKey()); switchPref.setOrder(checkBox.getOrder()); switchPref.setPersistent(checkBox.isPersistent()); switchPref.setEnabled(checkBox.isEnabled()); switchPref.setChecked(checkBox.isChecked()); switchPref.setSummary(checkBox.getSummary()); switchPref.setSummaryOn(checkBox.getSummaryOn()); switchPref.setSummaryOff(checkBox.getSummaryOff()); switchPref.setSwitchTextOn(EMPTY_TEXT); switchPref.setSwitchTextOff(EMPTY_TEXT); group.addPreference(switchPref); switchPref.setDependency(checkBox.getDependency()); }
Example #8
Source File: Preferences.java From xDrip with GNU General Public License v3.0 | 6 votes |
private void update_nfc_expiry_preferences(Boolean show_age) { try { ; final PreferenceScreen nfcScreen = (PreferenceScreen) findPreference("xdrip_plus_nfc_settings"); final String nfc_expiry_days_string = AllPrefsFragment.this.prefs.getString("nfc_expiry_days", "14.5"); final CheckBoxPreference nfc_show_age = (CheckBoxPreference) findPreference("nfc_show_age"); nfc_show_age.setSummaryOff("Show the sensor expiry time based on " + nfc_expiry_days_string + " days"); if (show_age == null) show_age = nfc_show_age.isChecked(); if (show_age) { nfcScreen.removePreference(nfc_expiry_days); } else { nfc_expiry_days.setOrder(3); nfcScreen.addPreference(nfc_expiry_days); } } catch (NullPointerException e) { // } }
Example #9
Source File: TwoStatePreferenceHelper.java From Android-Keyboard with Apache License 2.0 | 6 votes |
private static void replaceAllCheckBoxPreferencesBySwitchPreferences( final PreferenceGroup group) { final ArrayList<Preference> preferences = new ArrayList<>(); final int count = group.getPreferenceCount(); for (int index = 0; index < count; index++) { preferences.add(group.getPreference(index)); } group.removeAll(); for (int index = 0; index < count; index++) { final Preference preference = preferences.get(index); if (preference instanceof CheckBoxPreference) { addSwitchPreferenceBasedOnCheckBoxPreference((CheckBoxPreference)preference, group); } else { group.addPreference(preference); if (preference instanceof PreferenceGroup) { replaceAllCheckBoxPreferencesBySwitchPreferences((PreferenceGroup)preference); } } } }
Example #10
Source File: SettingsActivity.java From mosmetro-android with GNU General Public License v3.0 | 6 votes |
@Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Generate random User-Agent if it is unset new Randomizer(getActivity()).cached_useragent(); setTitle(getString(R.string.pref_category_connection)); addPreferencesFromResource(R.xml.pref_conn); PreferenceScreen screen = getPreferenceScreen(); final CheckBoxPreference pref_mainet = (CheckBoxPreference) screen.findPreference("pref_mainet"); final LoginFormPreference pref_mainet_creds = (LoginFormPreference) screen.findPreference("pref_mainet_credentials"); pref_mainet_creds.setEnabled(pref_mainet.isChecked()); pref_mainet.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { pref_mainet_creds.setEnabled((Boolean) newValue); return true; } }); }
Example #11
Source File: AccountSettingsActivity.java From zom-android-matrix with Apache License 2.0 | 6 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Set dummy name for preferences so that they don't mix with global ones. // FIXME we should not be writing these out to a file, since they are written to // the DB in onSharedPreferenceChanged(). getPreferenceManager().setSharedPreferencesName("account"); addPreferencesFromResource(R.xml.account_settings); Intent intent = getIntent(); mProviderId = intent.getLongExtra(ImServiceConstants.EXTRA_INTENT_PROVIDER_ID, -1); mAccountId = intent.getLongExtra(ImServiceConstants.EXTRA_INTENT_ACCOUNT_ID, -1); if (mProviderId < 0) { Log.e(LOG_TAG, "AccountSettingsActivity intent requires provider id extra"); throw new RuntimeException( "AccountSettingsActivity must be created with an provider id"); } mDeviceName = (EditTextPreference) findPreference(("pref_account_xmpp_resource")); mServer = (EditTextPreference) findPreference(("pref_account_server")); mUseProxy = (CheckBoxPreference) findPreference(("pref_security_use_proxy")); mProxyServer = (EditTextPreference) findPreference(("pref_security_proxy_host")); mProxyPort = (EditTextPreference) findPreference(("pref_security_proxy_port")); }
Example #12
Source File: PrivacyPreferenceFragment.java From SkyTube with GNU General Public License v3.0 | 6 votes |
@Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { if (key.equals(getString(R.string.pref_key_disable_search_history))) { CheckBoxPreference disableSearchHistoryPreference = (CheckBoxPreference)findPreference(key); // If Search History is disabled, clear the Search History database. if(disableSearchHistoryPreference.isChecked()) { SearchHistoryDb.getSearchHistoryDb().deleteAllSearchHistory(); Toast.makeText(getActivity(), getString(R.string.pref_disable_search_history_deleted), Toast.LENGTH_LONG).show(); } } else if (key.equals(getString(R.string.pref_key_disable_playback_status))) { CheckBoxPreference disablePlaybackStatusPreference = (CheckBoxPreference)findPreference(key); if(disablePlaybackStatusPreference.isChecked()) { PlaybackStatusDb.getPlaybackStatusDb().deleteAllPlaybackHistory(); Toast.makeText(getActivity(), getString(R.string.pref_disable_playback_status_deleted), Toast.LENGTH_LONG).show(); } } }
Example #13
Source File: DvachModule.java From Overchan-Android with GNU General Public License v3.0 | 6 votes |
@Override public void addPreferencesOnScreen(PreferenceGroup preferenceGroup) { Context context = preferenceGroup.getContext(); addPasswordPreference(preferenceGroup); CheckBoxPreference onionPref = new LazyPreferences.CheckBoxPreference(context); onionPref.setTitle(R.string.pref_use_onion); onionPref.setSummary(R.string.pref_use_onion_summary); onionPref.setKey(getSharedKey(PREF_KEY_USE_ONION)); onionPref.setDefaultValue(false); onionPref.setDisableDependentsState(true); preferenceGroup.addPreference(onionPref); EditTextPreference domainPref = new EditTextPreference(context); domainPref.setTitle(R.string.pref_domain); domainPref.setDialogTitle(R.string.pref_domain); domainPref.setSummary(resources.getString(R.string.pref_domain_summary, DOMAINS_HINT)); domainPref.setKey(getSharedKey(PREF_KEY_DOMAIN)); domainPref.getEditText().setHint(DEFAULT_DOMAIN); domainPref.getEditText().setSingleLine(); domainPref.getEditText().setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI); preferenceGroup.addPreference(domainPref); domainPref.setDependency(getSharedKey(PREF_KEY_USE_ONION)); addProxyPreferences(preferenceGroup); }
Example #14
Source File: PreferencesActivity.java From reacteu-app with MIT License | 6 votes |
private void disableLastCheckedPref() { Collection<CheckBoxPreference> checked = new ArrayList<CheckBoxPreference>(3); if (decode1D.isChecked()) { checked.add(decode1D); } if (decodeQR.isChecked()) { checked.add(decodeQR); } if (decodeDataMatrix.isChecked()) { checked.add(decodeDataMatrix); } boolean disable = checked.size() < 2; CheckBoxPreference[] checkBoxPreferences = {decode1D, decodeQR, decodeDataMatrix}; for (CheckBoxPreference pref : checkBoxPreferences) { pref.setEnabled(!(disable && checked.contains(pref))); } }
Example #15
Source File: SettingsActivity.java From android-espresso-revealed with Apache License 2.0 | 6 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.pref_notification); setHasOptionsMenu(true); // Bind the summaries of EditText/List/Dialog/Ringtone preferences // to their values. When their values change, their summaries are // updated to reflect the new value, per the Android Design // guidelines. bindPreferenceSummaryToValue(findPreference("notifications_new_message_ringtone")); preferenceScreen = getPreferenceScreen(); sendNotificationPreference = (Preference) this.findPreference("notifications_send"); sendNotificationWithDelayPreference = (Preference) this.findPreference("notifications_with_delay_send"); switchPreference = (SwitchPreference) this.findPreference("notifications_new_message"); ringtonePreference = (RingtonePreference) this.findPreference("notifications_new_message_ringtone"); vibratePreference = (CheckBoxPreference) this.findPreference("notifications_new_message_vibrate"); notificationsSlider = (SliderPreference) this.findPreference("notifications_slider"); setNotificationPreferences(); sendNotificationPreference.setOnPreferenceClickListener(sendNotificationListener); sendNotificationWithDelayPreference.setOnPreferenceClickListener(sendNotificationWithDelayListener); switchPreference.setOnPreferenceClickListener(switchPreferenceListener); }
Example #16
Source File: SettingsFragment.java From 920-text-editor-v2 with Apache License 2.0 | 5 votes |
private static void dependBindPreference(PreferenceGroup pg) { int count = pg.getPreferenceCount(); Preference preference; String key; Object value; Pref pref = Pref.getInstance(pg.getContext()); for(int i = 0; i < count; i++) { preference = pg.getPreference(i); key = preference.getKey(); if(preference instanceof PreferenceGroup) { dependBindPreference((PreferenceGroup) preference); continue; } Class<? extends Preference> cls = preference.getClass(); if(cls.equals(Preference.class)) continue; value = pref.getValue(key); if(preference instanceof JecListPreference) { // if("pref_font_size".equals(key)) { // new FontSizePreference((JecListPreference)preference); // } else if("pref_cursor_width".equals(key)) { // new CursorWidthPreference((JecListPreference)preference); // } } else if(preference instanceof EditTextPreference) { ((EditTextPreference)preference).setText(String.valueOf(value)); } else if(preference instanceof CheckBoxPreference) { ((CheckBoxPreference)preference).setChecked((boolean)value); } if (!Pref.KEY_SYMBOL.equals(key)) bindPreferenceSummaryToValue(preference); } }
Example #17
Source File: SettingsFragment.java From Leisure with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.settings); mSettings = Settings.getInstance(); mLanguage = findPreference(Settings.LANGUAGE); mSearch = findPreference(Settings.SEARCH); mSwipeBack = findPreference(Settings.SWIPE_BACK); mAutoRefresh = (CheckBoxPreference) findPreference(Settings.AUTO_REFRESH); mNightMode = (CheckBoxPreference) findPreference(Settings.NIGHT_MODE); mShakeToReturn = (CheckBoxPreference) findPreference(Settings.SHAKE_TO_RETURN); mNoPicMode = (CheckBoxPreference) findPreference(Settings.NO_PIC_MODE); mExitConfirm = (CheckBoxPreference) findPreference(Settings.EXIT_CONFIRM); mClearCache = findPreference(Settings.CLEAR_CACHE); mLanguage.setSummary(this.getResources().getStringArray(R.array.langs)[Utils.getCurrentLanguage()]); mSearch.setSummary(this.getResources().getStringArray(R.array.search)[Settings.searchID]); mSwipeBack.setSummary(this.getResources().getStringArray(R.array.swipe_back)[Settings.swipeID]); mAutoRefresh.setChecked(Settings.isAutoRefresh); mNightMode.setChecked(Settings.isNightMode); mShakeToReturn.setChecked(Settings.isShakeMode); mExitConfirm.setChecked(Settings.isExitConfirm); mNoPicMode.setChecked(Settings.noPicMode); mAutoRefresh.setOnPreferenceChangeListener(this); mNightMode.setOnPreferenceChangeListener(this); mShakeToReturn.setOnPreferenceChangeListener(this); mExitConfirm.setOnPreferenceChangeListener(this); mNoPicMode.setOnPreferenceChangeListener(this); mLanguage.setOnPreferenceClickListener(this); mSearch.setOnPreferenceClickListener(this); mSwipeBack.setOnPreferenceClickListener(this); mClearCache.setOnPreferenceClickListener(this); }
Example #18
Source File: AccountSettingsActivity.java From Zom-Android-XMPP with GNU General Public License v3.0 | 5 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Set dummy name for preferences so that they don't mix with global ones. // FIXME we should not be writing these out to a file, since they are written to // the DB in onSharedPreferenceChanged(). getPreferenceManager().setSharedPreferencesName("account"); addPreferencesFromResource(R.xml.account_settings); Intent intent = getIntent(); mProviderId = intent.getLongExtra(ImServiceConstants.EXTRA_INTENT_PROVIDER_ID, -1); mAccountId = intent.getLongExtra(ImServiceConstants.EXTRA_INTENT_ACCOUNT_ID, -1); if (mProviderId < 0) { Log.e(ImApp.LOG_TAG, "AccountSettingsActivity intent requires provider id extra"); throw new RuntimeException( "AccountSettingsActivity must be created with an provider id"); } mXmppResource = (EditTextPreference) findPreference(("pref_account_xmpp_resource")); mXmppResourcePrio = (EditTextPreference) findPreference(("pref_account_xmpp_resource_prio")); mPort = (EditTextPreference) findPreference(("pref_account_port")); mServer = (EditTextPreference) findPreference(("pref_account_server")); mAllowPlainAuth = (CheckBoxPreference) findPreference(("pref_security_allow_plain_auth")); mRequireTls = (CheckBoxPreference) findPreference(("pref_security_require_tls")); mDoDnsSrv = (CheckBoxPreference) findPreference(("pref_security_do_dns_srv")); mUseProxy = (CheckBoxPreference) findPreference(("pref_security_use_proxy")); mProxyServer = (EditTextPreference) findPreference(("pref_security_proxy_host")); mProxyPort = (EditTextPreference) findPreference(("pref_security_proxy_port")); }
Example #19
Source File: DisplaySettingsFragment.java From JumpGo with Mozilla Public License 2.0 | 5 votes |
private void initPrefs() { // mPreferences storage mThemeOptions = this.getResources().getStringArray(R.array.themes); mCurrentTheme = mPreferenceManager.getUseTheme(); mTheme = findPreference(SETTINGS_THEME); Preference textSize = findPreference(SETTINGS_TEXTSIZE); CheckBoxPreference cbStatus = (CheckBoxPreference) findPreference(SETTINGS_HIDESTATUSBAR); CheckBoxPreference cbFullScreen = (CheckBoxPreference) findPreference(SETTINGS_FULLSCREEN); CheckBoxPreference cbViewPort = (CheckBoxPreference) findPreference(SETTINGS_VIEWPORT); CheckBoxPreference cbOverview = (CheckBoxPreference) findPreference(SETTINGS_OVERVIEWMODE); CheckBoxPreference cbReflow = (CheckBoxPreference) findPreference(SETTINGS_REFLOW); CheckBoxPreference cbBlackStatus = (CheckBoxPreference) findPreference(SETTINGS_BLACK_STATUS); CheckBoxPreference cbDrawerTabs = (CheckBoxPreference) findPreference(SETTINGS_DRAWERTABS); CheckBoxPreference cbSwapTabs = (CheckBoxPreference) findPreference(SETTINGS_SWAPTABS); mTheme.setOnPreferenceClickListener(this); textSize.setOnPreferenceClickListener(this); cbStatus.setOnPreferenceChangeListener(this); cbFullScreen.setOnPreferenceChangeListener(this); cbViewPort.setOnPreferenceChangeListener(this); cbOverview.setOnPreferenceChangeListener(this); cbReflow.setOnPreferenceChangeListener(this); cbBlackStatus.setOnPreferenceChangeListener(this); cbDrawerTabs.setOnPreferenceChangeListener(this); cbSwapTabs.setOnPreferenceChangeListener(this); cbStatus.setChecked(mPreferenceManager.getHideStatusBarEnabled()); cbFullScreen.setChecked(mPreferenceManager.getFullScreenEnabled()); cbViewPort.setChecked(mPreferenceManager.getUseWideViewportEnabled()); cbOverview.setChecked(mPreferenceManager.getOverviewModeEnabled()); cbReflow.setChecked(mPreferenceManager.getTextReflowEnabled()); cbBlackStatus.setChecked(mPreferenceManager.getUseBlackStatusBar()); cbDrawerTabs.setChecked(mPreferenceManager.getShowTabsInDrawer(true)); cbSwapTabs.setChecked(mPreferenceManager.getBookmarksAndTabsSwapped()); mTheme.setSummary(mThemeOptions[mPreferenceManager.getUseTheme()]); }
Example #20
Source File: SuntimesSettingsActivity.java From SuntimesWidget with GNU General Public License v3.0 | 5 votes |
private static void initPref_altitude(final Activity context, final CheckBoxPreference altitudePref) { TypedArray a = context.obtainStyledAttributes(new int[]{R.attr.icActionAltitude}); int drawableID = a.getResourceId(0, R.drawable.baseline_terrain_black_18); a.recycle(); String title = context.getString(R.string.configLabel_general_altitude_enabled) + " [i]"; ImageSpan altitudeIcon = SuntimesUtils.createImageSpan(context, drawableID, 32, 32, 0); SpannableStringBuilder altitudeSpan = SuntimesUtils.createSpan(context, title, "[i]", altitudeIcon); altitudePref.setTitle(altitudeSpan); }
Example #21
Source File: PreferencesBrowser.java From habpanelviewer with GNU General Public License v3.0 | 5 votes |
@Override public void onStart() { super.onStart(); if (needsPermissions()) { CheckBoxPreference allowPreference = (CheckBoxPreference) findPreference(Constants.PREF_ALLOW_WEBRTC); allowPreference.setChecked(false); } }
Example #22
Source File: AbstractChanModule.java From Overchan-Android with GNU General Public License v3.0 | 5 votes |
/** * Добавить в группу параметров (на экран/в категорию) новую категорию настроек прокси-сервера * @param group группа, на которую добавляются параметры */ protected void addProxyPreferences(PreferenceGroup group) { final Context context = group.getContext(); PreferenceCategory proxyCat = new PreferenceCategory(context); //категория настроек прокси proxyCat.setTitle(R.string.pref_cat_proxy); group.addPreference(proxyCat); CheckBoxPreference useProxyPref = new LazyPreferences.CheckBoxPreference(context); //чекбокс "использовать ли прокси вообще" useProxyPref.setTitle(R.string.pref_use_proxy); useProxyPref.setSummary(R.string.pref_use_proxy_summary); useProxyPref.setKey(getSharedKey(PREF_KEY_USE_PROXY)); useProxyPref.setDefaultValue(false); useProxyPref.setOnPreferenceChangeListener(updateHttpListener); proxyCat.addPreference(useProxyPref); EditTextPreference proxyHostPref = new LazyPreferences.EditTextPreference(context); //поле ввода адреса прокси-сервера proxyHostPref.setTitle(R.string.pref_proxy_host); proxyHostPref.setDialogTitle(R.string.pref_proxy_host); proxyHostPref.setSummary(R.string.pref_proxy_host_summary); proxyHostPref.setKey(getSharedKey(PREF_KEY_PROXY_HOST)); proxyHostPref.setDefaultValue(DEFAULT_PROXY_HOST); proxyHostPref.getEditText().setSingleLine(); proxyHostPref.getEditText().setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI); proxyHostPref.setOnPreferenceChangeListener(updateHttpListener); proxyCat.addPreference(proxyHostPref); proxyHostPref.setDependency(getSharedKey(PREF_KEY_USE_PROXY)); EditTextPreference proxyHostPort = new LazyPreferences.EditTextPreference(context); //поле ввода порта прокси-сервера proxyHostPort.setTitle(R.string.pref_proxy_port); proxyHostPort.setDialogTitle(R.string.pref_proxy_port); proxyHostPort.setSummary(R.string.pref_proxy_port_summary); proxyHostPort.setKey(getSharedKey(PREF_KEY_PROXY_PORT)); proxyHostPort.setDefaultValue(DEFAULT_PROXY_PORT); proxyHostPort.getEditText().setSingleLine(); proxyHostPort.getEditText().setInputType(InputType.TYPE_CLASS_NUMBER); proxyHostPort.setOnPreferenceChangeListener(updateHttpListener); proxyCat.addPreference(proxyHostPort); proxyHostPort.setDependency(getSharedKey(PREF_KEY_USE_PROXY)); }
Example #23
Source File: PreferencesBrowser.java From habpanelviewer with GNU General Public License v3.0 | 5 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.preferences_browser); // add validation to the allow webrtc CheckBoxPreference allowPreference = (CheckBoxPreference) findPreference(Constants.PREF_ALLOW_WEBRTC); allowPreference.setOnPreferenceChangeListener(new WebRtcValidatingListener()); }
Example #24
Source File: FloatDisplaySettingActivity.java From Float-Bar with Eclipse Public License 1.0 | 5 votes |
@SuppressWarnings("deprecation") @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.prefs_list_content); addPreferencesFromResource(R.xml.float_display_preference); prefs = new Prefs(this); colorList = (MyListPreference) findPreference("color"); colorList.setOnPreferenceChangeListener(this); alphaSb = (MySeekBarPreference) findPreference("alpha");// 找到preference alphaSb.setDefaultProgressValue(prefs.getAlpha());// 设置起始时的进度 alphaSb.setMax(255);// 设置最大的数值,不超过10000。如果超过了请在seekbarPreference源码中进行修改max值 alphaSb.setOnSeekBarPrefsChangeListener(this);// 设置监听器 rightCBox = (CheckBoxPreference) findPreference("rightMode"); rightCBox.setOnPreferenceChangeListener(this); widthSb = (MySeekBarPreference) findPreference("width"); widthSb.setMax(80); widthSb.setDefaultProgressValue(prefs.getWidth()); widthSb.setOnSeekBarPrefsChangeListener(this); heightSb = (MySeekBarPreference) findPreference("height"); heightSb.setMax(1000); heightSb.setDefaultProgressValue(prefs.getHeight()); heightSb.setOnSeekBarPrefsChangeListener(this); distanceSb = (MySeekBarPreference) findPreference("distance"); distanceSb.setMax(1000); distanceSb.setDefaultProgressValue(prefs.getDistance()); distanceSb.setOnSeekBarPrefsChangeListener(this); }
Example #25
Source File: LocationFragment.java From android with Apache License 2.0 | 5 votes |
@Override public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { if (requestCode == DEFAULT_PERMISSIONS_REQUEST_CODE) { CheckBoxPreference auto = (CheckBoxPreference) findPreference("location_automatic"); int permission = PermissionChecker.checkSelfPermission(getActivity(), Manifest.permission.ACCESS_FINE_LOCATION); auto.setChecked(permission == PermissionChecker.PERMISSION_GRANTED); } }
Example #26
Source File: SettingActivity.java From sensordatacollector with GNU General Public License v2.0 | 5 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Load the preferences from an XML resource addPreferencesFromResource(R.xml.preferences); // register listener CheckBoxPreference watchDirectBox = (CheckBoxPreference) findPreference("watch_direct"); watchDirectBox.setOnPreferenceChangeListener(this); }
Example #27
Source File: SettingsActivity.java From MuslimMateAndroid with GNU General Public License v3.0 | 5 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.settings); sp = PreferenceManager.getDefaultSharedPreferences(getActivity()); locationInfo = ConfigPreferences.getLocationConfig(getActivity()); //disable and enable praying notification related setting if (ConfigPreferences.getPrayingNotification(getActivity()) == false) { getPreferenceScreen().findPreference("silent").setEnabled(false); getPreferenceScreen().findPreference("vibration").setEnabled(false); getPreferenceScreen().findPreference("led").setEnabled(false); } //disable or enable silent related settings if(ConfigPreferences.getSilentMood(getActivity()) == false){ getPreferenceScreen().findPreference("vibration").setEnabled(false); } if (locationInfo != null) { Log.i("DATA_SETTING" ,"locationInfo.dls : "+(locationInfo.dls > 0)); CheckBoxPreference checked = (CheckBoxPreference) getPreferenceScreen().findPreference("day_light"); checked.setChecked(locationInfo.dls > 0); ListPreference wayPref = (ListPreference) getPreferenceScreen().findPreference("calculations"); Log.i("DATA_SETTING" ,"locationInfo.way : "+locationInfo.way); wayPref.setValueIndex(locationInfo.way); ListPreference mazhapPref = (ListPreference) getPreferenceScreen().findPreference("mazhab"); mazhapPref.setValueIndex(locationInfo.mazhab); Log.i("DATA_SETTING" ,"locationInfo.mazhab : "+locationInfo.mazhab); } listPreference = (ListPreference) findPreference("language"); String lang = ConfigPreferences.getApplicationLanguage(getActivity()).equalsIgnoreCase("en") ? "English" : "العربية"; listPreference.setSummary(getString(R.string.language_summary) + " (" + lang + ") "); }
Example #28
Source File: AllPreferences.java From YalpStore with GNU General Public License v2.0 | 5 votes |
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) private void drawBlackList() { Blacklist blacklistFragment = new Blacklist(activity); blacklistFragment.setBlackOrWhite((ListPreference) activity.findPreference(PreferenceUtil.PREFERENCE_UPDATE_LIST_WHITE_OR_BLACK)); blacklistFragment.setAppList((MultiSelectListPreference) activity.findPreference(PreferenceUtil.PREFERENCE_UPDATE_LIST)); blacklistFragment.setAutoWhitelist((CheckBoxPreference) activity.findPreference(PreferenceUtil.PREFERENCE_AUTO_WHITELIST)); blacklistFragment.draw(); }
Example #29
Source File: AllPreferences.java From YalpStore with GNU General Public License v2.0 | 5 votes |
private void drawUpdatesCheck() { CheckUpdates checkUpdatesFragment = new CheckUpdates(activity); checkUpdatesFragment.setCheckForUpdates((ListPreference) activity.findPreference(PreferenceUtil.PREFERENCE_BACKGROUND_UPDATE_INTERVAL)); checkUpdatesFragment.setAlsoInstall((CheckBoxPreference) activity.findPreference(PreferenceUtil.PREFERENCE_BACKGROUND_UPDATE_INSTALL)); checkUpdatesFragment.setAlsoDownload((CheckBoxPreference) activity.findPreference(PreferenceUtil.PREFERENCE_BACKGROUND_UPDATE_DOWNLOAD)); checkUpdatesFragment.draw(); }
Example #30
Source File: PreferenceMatchersTest.java From android-test with Apache License 2.0 | 5 votes |
@Test public void withTitleTest() { CheckBoxPreference pref = new CheckBoxPreference(getApplicationContext()); assertThat(pref, not(withTitle(R.string.other_string))); assertThat(pref, not(withTitleText("not null"))); pref.setTitle(R.string.other_string); assertThat(pref, withTitle(R.string.other_string)); assertThat(pref, not(withTitle(R.string.something))); assertThat(pref, withTitleText("Goodbye!!")); assertThat(pref, not(withTitleText("Hello Mars"))); assertThat(pref, withTitleText(is("Goodbye!!"))); }