Java Code Examples for android.preference.CheckBoxPreference#setTitle()
The following examples show how to use
android.preference.CheckBoxPreference#setTitle() .
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: 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 3
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 4
Source File: NotificationSettingsActivity.java From AndroidPNClient with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setPreferenceScreen(createPreferenceHierarchy()); setPreferenceDependencies(); CheckBoxPreference notifyPref = (CheckBoxPreference) getPreferenceManager() .findPreference(Constants.SETTINGS_NOTIFICATION_ENABLED); if (notifyPref.isChecked()) { notifyPref.setTitle("Notifications Enabled"); } else { notifyPref.setTitle("Notifications Disabled"); } }
Example 5
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 6
Source File: FetchingPrefFragment.java From Onosendai with Apache License 2.0 | 5 votes |
private void addSyncScroll () { final CheckBoxPreference pref = new CheckBoxPreference(getActivity()); pref.setKey(KEY_SYNC_SCROLL); pref.setTitle("Sync column scroll position"); //ES pref.setSummary("But only if last scroll was upward."); //ES getPreferenceScreen().addPreference(pref); }
Example 7
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 8
Source File: NotifySettingsActivity.java From AndroidPNClient with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setPreferenceScreen(createPreferenceHierarchy()); setPreferenceDependencies(); CheckBoxPreference notifyPref = (CheckBoxPreference) getPreferenceManager() .findPreference(Constants.SETTINGS_NOTIFICATION_ENABLED); if (notifyPref.isChecked()) { notifyPref.setTitle(R.string.notifications_enabled); } else { notifyPref.setTitle(R.string.notifications_disabled); } }
Example 9
Source File: DobroModule.java From Overchan-Android with GNU General Public License v3.0 | 5 votes |
private void addCaptchaPreference(PreferenceGroup group) { Context context = group.getContext(); CheckBoxPreference showCaptchaPreference = new LazyPreferences.CheckBoxPreference(context); showCaptchaPreference.setTitle(R.string.dobrochan_prefs_show_captcha); showCaptchaPreference.setSummary(R.string.dobrochan_prefs_show_captcha_summary); showCaptchaPreference.setKey(getSharedKey(PREF_KEY_SHOW_CAPTCHA)); showCaptchaPreference.setDefaultValue(false); group.addPreference(showCaptchaPreference); }
Example 10
Source File: AbstractChanModule.java From Overchan-Android with GNU General Public License v3.0 | 5 votes |
/** * Добавить в группу параметров (на экран/в категорию) настройку выбора использования инкрементальной загрузки (загрузки только новых постов). * Для хранения используется ключ общих параметров {@link #PREF_KEY_ONLY_NEW_POSTS} ({@link #getSharedKey(String)}). * См. также: {@link #loadOnlyNewPosts(boolean)} - для получения значения параметра. * @param group группа, на которую добавляется параметр * @param defaultValue значение параметра по умолчанию * return объект {@link CheckBoxPreference} с параметром */ protected CheckBoxPreference addOnlyNewPostsPreference(PreferenceGroup group, boolean defaultValue) { final Context context = group.getContext(); CheckBoxPreference onlyNewPostsPref = new LazyPreferences.CheckBoxPreference(context); onlyNewPostsPref.setTitle(R.string.pref_only_new_posts); onlyNewPostsPref.setSummary(R.string.pref_only_new_posts_summary); onlyNewPostsPref.setKey(getSharedKey(PREF_KEY_ONLY_NEW_POSTS)); onlyNewPostsPref.setDefaultValue(defaultValue); group.addPreference(onlyNewPostsPref); return onlyNewPostsPref; }
Example 11
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!!"))); }
Example 12
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 13
Source File: CloudflareChanModule.java From Overchan-Android with GNU General Public License v3.0 | 5 votes |
protected void addCloudflareRecaptchaFallbackPreference(PreferenceGroup preferenceGroup) { if (canCloudflare()) { Context context = preferenceGroup.getContext(); CheckBoxPreference fallbackPref = new LazyPreferences.CheckBoxPreference(context); fallbackPref.setTitle(R.string.pref_cf_recaptcha_fallback); fallbackPref.setSummary(R.string.pref_cf_recaptcha_fallback_summary); fallbackPref.setKey(getSharedKey(PREF_KEY_CLOUDFLARE_RECAPTCHA_FALLBACK)); fallbackPref.setDefaultValue(false); preferenceGroup.addPreference(fallbackPref); } }
Example 14
Source File: ChartSettingsActivity.java From mytracks with Apache License 2.0 | 5 votes |
@SuppressWarnings("deprecation") private void updateUi() { CheckBoxPreference speedCheckBoxPreference = (CheckBoxPreference) findPreference( getString(R.string.chart_show_speed_key)); speedCheckBoxPreference.setTitle( PreferencesUtils.isReportSpeed(this) ? R.string.stats_speed : R.string.stats_pace); }
Example 15
Source File: NotificationSettingsActivity.java From android-demo-xmpp-androidpn with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setPreferenceScreen(createPreferenceHierarchy()); setPreferenceDependencies(); CheckBoxPreference notifyPref = (CheckBoxPreference) getPreferenceManager() .findPreference(Constants.SETTINGS_NOTIFICATION_ENABLED); if (notifyPref.isChecked()) { notifyPref.setTitle("Notifications Enabled"); } else { notifyPref.setTitle("Notifications Disabled"); } }
Example 16
Source File: AdvancedPrefFragment.java From Onosendai with Apache License 2.0 | 5 votes |
private void addThreadInspector () { final CheckBoxPreference pref = new CheckBoxPreference(getActivity()); pref.setKey(KEY_THREAD_INSPECTOR); pref.setTitle("Thread Inspector"); //ES pref.setSummary("For debugging issues with worker threads."); //ES getPreferenceScreen().addPreference(pref); }
Example 17
Source File: SettingsActivity.java From mosmetro-android with GNU General Public License v3.0 | 4 votes |
@Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setTitle(getString(R.string.pref_updater_branch)); PreferenceScreen screen = getPreferenceManager().createPreferenceScreen(getActivity()); setPreferenceScreen(screen); PreferenceCategory stable = new PreferenceCategory(getActivity()); stable.setTitle(R.string.pref_updater_branch_stable); screen.addPreference(stable); PreferenceCategory experimental = new PreferenceCategory(getActivity()); experimental.setTitle(R.string.pref_updater_branch_experimental); screen.addPreference(experimental); if (branches == null) return; final SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(getActivity()); for (final UpdateCheckTask.Branch branch : branches.values()) { CheckBoxPreference pref = new CheckBoxPreference(getActivity()) { @Override protected void onBindView(View view) { super.onBindView(view); // Increase number of lines on Android 4.x // Source: https://stackoverflow.com/a/2615650 TextView summary = (TextView) view.findViewById(android.R.id.summary); summary.setMaxLines(15); } }; pref.setTitle(branch.name); pref.setSummary(branch.description); pref.setChecked(Version.getBranch().equals(branch.name)); pref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { boolean same = Version.getBranch().equals(branch.name); ((CheckBoxPreference)preference).setChecked(same); if (!same) { settings.edit().putInt("pref_updater_ignore", 0).apply(); branch.dialog().show(); } getActivity().onBackPressed(); return true; } }); if (branch.stable) { stable.addPreference(pref); } else { experimental.addPreference(pref); } } }
Example 18
Source File: UiPrefFragment.java From Onosendai with Apache License 2.0 | 4 votes |
private void addColumnsRtl () { final CheckBoxPreference pref = new CheckBoxPreference(getActivity()); pref.setKey(KEY_COLUMNS_RTL); pref.setTitle("Columns RTL"); //ES getPreferenceScreen().addPreference(pref); }
Example 19
Source File: NotificationSettingsActivity.java From android-demo-xmpp-androidpn with Apache License 2.0 | 4 votes |
private PreferenceScreen createPreferenceHierarchy() { Log.d(LOGTAG, "createSettingsPreferenceScreen()..."); PreferenceManager preferenceManager = getPreferenceManager(); preferenceManager .setSharedPreferencesName(Constants.SHARED_PREFERENCE_NAME); preferenceManager.setSharedPreferencesMode(Context.MODE_PRIVATE); PreferenceScreen root = preferenceManager.createPreferenceScreen(this); // PreferenceCategory prefCat = new PreferenceCategory(this); // // inlinePrefCat.setTitle(""); // root.addPreference(prefCat); CheckBoxPreference notifyPref = new CheckBoxPreference(this); notifyPref.setKey(Constants.SETTINGS_NOTIFICATION_ENABLED); notifyPref.setTitle("Notifications Enabled"); notifyPref.setSummaryOn("Receive push messages"); notifyPref.setSummaryOff("Do not receive push messages"); notifyPref.setDefaultValue(Boolean.TRUE); notifyPref .setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { public boolean onPreferenceChange(Preference preference, Object newValue) { boolean checked = Boolean.valueOf(newValue.toString()); if (checked) { preference.setTitle("Notifications Enabled"); } else { preference.setTitle("Notifications Disabled"); } return true; } }); CheckBoxPreference soundPref = new CheckBoxPreference(this); soundPref.setKey(Constants.SETTINGS_SOUND_ENABLED); soundPref.setTitle("Sound"); soundPref.setSummary("Play a sound for notifications"); soundPref.setDefaultValue(Boolean.TRUE); // soundPref.setDependency(Constants.SETTINGS_NOTIFICATION_ENABLED); CheckBoxPreference vibratePref = new CheckBoxPreference(this); vibratePref.setKey(Constants.SETTINGS_VIBRATE_ENABLED); vibratePref.setTitle("Vibrate"); vibratePref.setSummary("Vibrate the phone for notifications"); vibratePref.setDefaultValue(Boolean.TRUE); // vibratePref.setDependency(Constants.SETTINGS_NOTIFICATION_ENABLED); root.addPreference(notifyPref); root.addPreference(soundPref); root.addPreference(vibratePref); // prefCat.addPreference(notifyPref); // prefCat.addPreference(soundPref); // prefCat.addPreference(vibratePref); // root.addPreference(prefCat); return root; }
Example 20
Source File: NotifySettingsActivity.java From AndroidPNClient with Apache License 2.0 | 4 votes |
private PreferenceScreen createPreferenceHierarchy() { Log.d(LOGTAG, "createSettingsPreferenceScreen()..."); PreferenceManager preferenceManager = getPreferenceManager(); preferenceManager .setSharedPreferencesName(Constants.SHARED_PREFERENCE_NAME); preferenceManager.setSharedPreferencesMode(Context.MODE_PRIVATE); PreferenceScreen root = preferenceManager.createPreferenceScreen(this); // PreferenceCategory prefCat = new PreferenceCategory(this); // // inlinePrefCat.setTitle(""); // root.addPreference(prefCat); CheckBoxPreference notifyPref = new CheckBoxPreference(this); notifyPref.setKey(Constants.SETTINGS_NOTIFICATION_ENABLED); notifyPref.setTitle(R.string.notifications_enabled); notifyPref.setSummaryOn(R.string.receive_push_messages); notifyPref.setSummaryOff(R.string.do_not_receive_push_messages); notifyPref.setDefaultValue(Boolean.TRUE); notifyPref .setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { public boolean onPreferenceChange(Preference preference, Object newValue) { boolean checked = Boolean.valueOf(newValue.toString()); if (checked) { preference.setTitle(R.string.notifications_enabled); } else { preference.setTitle(R.string.notifications_disabled); } return true; } }); CheckBoxPreference soundPref = new CheckBoxPreference(this); soundPref.setKey(Constants.SETTINGS_SOUND_ENABLED); soundPref.setTitle(R.string.sound); soundPref.setSummary(R.string.play_sound_for_notifications); soundPref.setDefaultValue(Boolean.TRUE); // soundPref.setDependency(Constants.SETTINGS_NOTIFICATION_ENABLED); CheckBoxPreference vibratePref = new CheckBoxPreference(this); vibratePref.setKey(Constants.SETTINGS_VIBRATE_ENABLED); vibratePref.setTitle(R.string.vibrate); vibratePref.setSummary(R.string.vibrate_the_phone_for_notifications); vibratePref.setDefaultValue(Boolean.TRUE); // vibratePref.setDependency(Constants.SETTINGS_NOTIFICATION_ENABLED); root.addPreference(notifyPref); root.addPreference(soundPref); root.addPreference(vibratePref); // prefCat.addPreference(notifyPref); // prefCat.addPreference(soundPref); // prefCat.addPreference(vibratePref); // root.addPreference(prefCat); return root; }