use of android.preference.ListPreference in project physical-web by google.
the class SettingsFragment method updateSettingSummary.
private void updateSettingSummary(String key) {
Preference pref = findPreference(key);
if (pref instanceof ListPreference) {
ListPreference listPref = (ListPreference) pref;
listPref.setSummary(listPref.getEntry());
} else if (pref instanceof EditTextPreference) {
EditTextPreference editTextPref = (EditTextPreference) pref;
editTextPref.setSummary(editTextPref.getText());
}
}
use of android.preference.ListPreference in project physical-web by google.
the class SettingsFragment method updatePwsPreference.
private void updatePwsPreference() {
ListPreference listPreference = (ListPreference) findPreference(getString(R.string.pws_endpoint_setting_key));
String entry = (String) listPreference.getEntry();
if (entry == null) {
return;
}
if (entry.equals(getString(R.string.custom_pws))) {
// User selected custom PWS therefore need to update it accordingly
EditTextPreference customPwsUrlPreference = (EditTextPreference) mCustomEndpointCategory.findPreference(getString(R.string.custom_pws_url_key));
ListPreference customPwsVersionPreference = (ListPreference) mCustomEndpointCategory.findPreference(getString(R.string.custom_pws_version_key));
EditTextPreference customPwsApiKeyPreference = (EditTextPreference) mCustomEndpointCategory.findPreference(getString(R.string.custom_pws_api_key_key));
String customPwsUrl = customPwsUrlPreference.getText();
int customPwsVersion = Integer.parseInt(customPwsVersionPreference.getValue());
String customPwsApiKey = customPwsApiKeyPreference.getText();
customPwsUrl = customPwsUrl == null ? "" : customPwsUrl;
customPwsApiKey = customPwsApiKey == null ? "" : customPwsApiKey;
listPreference.setValue(Utils.formatEndpointForSharedPrefernces(customPwsUrl, customPwsVersion, customPwsApiKey));
getPreferenceScreen().addPreference(mCustomEndpointCategory);
} else {
getPreferenceScreen().removePreference(mCustomEndpointCategory);
}
}
use of android.preference.ListPreference in project Jota-Text-Editor-old by jiro-aqua.
the class SettingsActivity method createDictionaryPreference.
private void createDictionaryPreference(String categ) {
// new PreferenceScreen
mPs = mPm.createPreferenceScreen(this);
{
if (CAT_TOP.equals(categ)) {
setTitle(R.string.menu_preferences);
{
final Preference pr = new Preference(this);
pr.setTitle(R.string.menu_pref_search);
pr.setOnPreferenceClickListener(mProcPrefSearch);
mPs.addPreference(pr);
}
{
final Preference pr = new Preference(this);
pr.setTitle(R.string.menu_pref_font);
pr.setOnPreferenceClickListener(mProcPrefFont);
mPs.addPreference(pr);
}
{
final Preference pr = new Preference(this);
pr.setTitle(R.string.menu_pref_view);
pr.setOnPreferenceClickListener(mProcPrefView);
mPs.addPreference(pr);
}
{
final Preference pr = new Preference(this);
pr.setTitle(R.string.menu_pref_file);
pr.setOnPreferenceClickListener(mProcPrefFile);
mPs.addPreference(pr);
}
{
final Preference pr = new Preference(this);
pr.setTitle(R.string.menu_pref_input);
pr.setOnPreferenceClickListener(mProcPrefInput);
mPs.addPreference(pr);
}
{
final Preference pr = new Preference(this);
pr.setTitle(R.string.label_miscllaneous);
pr.setOnPreferenceClickListener(mProcPrefMisc);
mPs.addPreference(pr);
}
}
if (CAT_SEARCH.equals(categ)) {
// Search Category
setTitle(R.string.menu_pref_search);
final PreferenceCategory category = new PreferenceCategory(this);
category.setTitle(R.string.label_search);
mPs.addPreference(category);
{
final CheckBoxPreference pr = new CheckBoxPreference(this);
pr.setKey(KEY_RE);
pr.setTitle(R.string.label_re);
category.addPreference(pr);
}
{
final CheckBoxPreference pr = new CheckBoxPreference(this);
pr.setKey(KEY_IGNORE_CASE);
pr.setTitle(R.string.label_ignore_case);
category.addPreference(pr);
}
}
if (CAT_FONT.equals(categ)) {
// Font Category
setTitle(R.string.menu_pref_font);
final PreferenceCategory catfont = new PreferenceCategory(this);
catfont.setTitle(R.string.label_font);
mPs.addPreference(catfont);
{
// Font Typeface
final ListPreference pr = new ListPreference(this);
pr.setKey(KEY_FONT);
pr.setTitle(R.string.label_font_type);
pr.setEntries(new String[] { getString(R.string.label_font_type_normal), getString(R.string.label_font_type_monospace) });
pr.setEntryValues(new CharSequence[] { "NORMAL", "MONOSPACE" });
// pr.setSummary(sp.getString(pr.getKey(), ""));
catfont.addPreference(pr);
mPrefFont = pr;
}
{
// FontSize
final ListPreference pr = new ListPreference(this);
pr.setKey(KEY_FONT_SIZE);
// pr.setSummary(sp.getString(pr.getKey(), ""));
pr.setTitle(R.string.label_font_size);
pr.setEntries(new String[] { "8", "9", "10", "11", "12", "14", "16", "18", "20", "24", "30", "36", "48", "64", "72", "96" });
pr.setEntryValues(new String[] { "8", "9", "10", "11", "12", "14", "16", "18", "20", "24", "30", "36", "48", "64", "72", "96" });
catfont.addPreference(pr);
mPrefFontSize = pr;
}
}
if (CAT_VIEW.equals(categ)) {
// View Category
setTitle(R.string.menu_pref_view);
final PreferenceCategory cat = new PreferenceCategory(this);
cat.setTitle(R.string.label_view);
mPs.addPreference(cat);
{
// word wrap
final CheckBoxPreference pr = new CheckBoxPreference(this);
pr.setKey(KEY_WORD_WRAP);
pr.setTitle(R.string.label_word_wrap);
cat.addPreference(pr);
}
{
// Wrap width portrait
final Preference pr = new Preference(this);
pr.setTitle(R.string.label_wrapwidth_p);
pr.setSummary(R.string.summary_wrapwidth_p);
pr.setOnPreferenceClickListener(mProcWrapWidthPortrait);
cat.addPreference(pr);
mPrefWrapWidthP = pr;
}
{
// Wrap width landscape
final Preference pr = new Preference(this);
pr.setTitle(R.string.label_wrapwidth_l);
pr.setSummary(R.string.summary_wrapwidth_l);
pr.setOnPreferenceClickListener(mProcWrapWidthLandscape);
cat.addPreference(pr);
mPrefWrapWidthL = pr;
}
{
// Tab width
final Preference pr = new Preference(this);
pr.setTitle(R.string.label_tabwidth);
pr.setOnPreferenceClickListener(mProcTabWidthLandscape);
cat.addPreference(pr);
}
{
// Line Spacing
final Preference pr = new Preference(this);
pr.setTitle(R.string.label_line_space);
pr.setOnPreferenceClickListener(mProcLineSpace);
cat.addPreference(pr);
}
{
// show underline
final CheckBoxPreference pr = new CheckBoxPreference(this);
pr.setKey(KEY_UNDERLINE);
pr.setTitle(R.string.label_underline);
cat.addPreference(pr);
}
{
// show line numbers
final CheckBoxPreference pr = new CheckBoxPreference(this);
pr.setKey(KEY_SHOW_LINENUMBERS);
pr.setTitle(R.string.label_show_linenumbers);
cat.addPreference(pr);
}
{
// show tab
final CheckBoxPreference pr = new CheckBoxPreference(this);
pr.setKey(KEY_SHOW_TAB);
pr.setTitle(R.string.label_show_tab);
cat.addPreference(pr);
}
{
// theme
final ListPreference pr = new ListPreference(this);
pr.setDialogTitle(R.string.label_theme);
pr.setKey(KEY_THEME);
pr.setTitle(R.string.label_theme);
pr.setEntries(new String[] { getResources().getString(R.string.label_background_white), getResources().getString(R.string.label_background_black) });
final String[] values = new String[] { THEME_DEFAULT, THEME_BLACK };
pr.setEntryValues(values);
pr.setOnPreferenceChangeListener(mProcTheme);
cat.addPreference(pr);
}
{
// Text Color
final Preference pr = new Preference(this);
pr.setTitle(R.string.label_text_color);
pr.setOnPreferenceClickListener(mProcTextColor);
cat.addPreference(pr);
}
{
// Selection Color
final Preference pr = new Preference(this);
pr.setTitle(R.string.label_highlight_color);
pr.setOnPreferenceClickListener(mProcHighlightColor);
cat.addPreference(pr);
}
{
// Underline Color
final Preference pr = new Preference(this);
pr.setTitle(R.string.label_underline_color);
pr.setOnPreferenceClickListener(mProcUnderlineColor);
cat.addPreference(pr);
}
{
// blink cursor
final CheckBoxPreference pr = new CheckBoxPreference(this);
pr.setKey(KEY_BLINK_CURSOR);
pr.setTitle(R.string.label_blink_cursor);
cat.addPreference(pr);
}
{
// hide titlebar
final CheckBoxPreference pr = new CheckBoxPreference(this);
pr.setKey(KEY_HIDETITLEBAR);
pr.setTitle(R.string.label_hide_titlebar);
pr.setSummary(R.string.summary_need_restart);
cat.addPreference(pr);
}
{
// screen orientation
final ListPreference pr = new ListPreference(this);
pr.setKey(KEY_ORIENTATION);
pr.setDialogTitle(R.string.label_orientation);
pr.setTitle(R.string.label_orientation);
pr.setEntries(new String[] { getResources().getString(R.string.label_orientation_auto), getResources().getString(R.string.label_orientation_portrait), getResources().getString(R.string.label_orientation_landscape) });
final String[] values = new String[] { ORI_AUTO, ORI_PORTRAIT, ORI_LANDSCAPE };
pr.setEntryValues(values);
cat.addPreference(pr);
mPrefOrientation = pr;
}
if (IS01FullScreen.isIS01orLynx()) {
// hide softkey
final CheckBoxPreference pr = new CheckBoxPreference(this);
pr.setKey(KEY_HIDESOFTKEY_IS01);
pr.setTitle(R.string.label_hide_softkey_is01);
pr.setSummary(R.string.summary_need_restart);
cat.addPreference(pr);
}
}
if (CAT_FILE.equals(categ)) {
// File Category
setTitle(R.string.menu_pref_file);
final PreferenceCategory cat = new PreferenceCategory(this);
cat.setTitle(R.string.label_file);
mPs.addPreference(cat);
{
// default directory
final Preference pr = new Preference(this);
pr.setTitle(R.string.label_default_new_file);
pr.setOnPreferenceClickListener(mProcDefaultDirectory);
cat.addPreference(pr);
}
{
// rememer last file
final CheckBoxPreference pr = new CheckBoxPreference(this);
pr.setKey(KEY_REMEMBER_LAST_FILE);
pr.setTitle(R.string.label_open_last_file);
pr.setSummary(R.string.label_open_last_file_summary);
cat.addPreference(pr);
}
{
// create backup file
final CheckBoxPreference pr = new CheckBoxPreference(this);
pr.setKey(KEY_CRETAE_BACKUP);
pr.setTitle(R.string.label_create_backup);
pr.setSummary(R.string.summary_create_backup);
cat.addPreference(pr);
}
{
// Characterset for Open
final ListPreference pr = new ListPreference(this);
pr.setKey(KEY_CHARSET_OPEN);
pr.setTitle(R.string.label_charset_open);
String[] entries = getResources().getStringArray(R.array.CharcterSet_open);
String[] values = getResources().getStringArray(R.array.CharcterSet_open);
values[0] = "";
pr.setEntries(entries);
pr.setEntryValues(values);
cat.addPreference(pr);
mPrefCharsetOpen = pr;
}
{
// Characterset for Save
final ListPreference pr = new ListPreference(this);
pr.setKey(KEY_CHARSET_SAVE);
pr.setTitle(R.string.label_charset_save);
String[] entries = getResources().getStringArray(R.array.CharcterSet_save);
String[] values = getResources().getStringArray(R.array.CharcterSet_save);
values[0] = "";
pr.setEntries(entries);
pr.setEntryValues(values);
cat.addPreference(pr);
mPrefCharsetSave = pr;
}
{
// Characterset for Save
final ListPreference pr = new ListPreference(this);
pr.setKey(KEY_LINEBREAK_SAVE);
pr.setTitle(R.string.label_linebreak_save);
String[] entries = getResources().getStringArray(R.array.LineBreak_save);
String[] values = new String[] { "-1", "0", "1", "2" };
pr.setEntries(entries);
pr.setEntryValues(values);
cat.addPreference(pr);
mPrefLinebreakSave = pr;
}
{
// auto save
final CheckBoxPreference pr = new CheckBoxPreference(this);
pr.setKey(KEY_AUTO_SAVE);
pr.setTitle(R.string.label_auto_save);
pr.setSummary(R.string.summary_auto_save);
cat.addPreference(pr);
}
}
if (CAT_MISC.equals(categ)) {
// Direct Intent Category
setTitle(R.string.label_miscllaneous);
final PreferenceCategory category = new PreferenceCategory(this);
category.setTitle(R.string.label_direct_intent);
mPs.addPreference(category);
{
final ListPreference pr = new ListPreference(this);
pr.setDialogTitle(R.string.label_select_kind);
pr.setKey(KEY_DIRECT_INTENT);
pr.setTitle(R.string.label_select_direct_intent);
pr.setEntries(new String[] { getResources().getString(R.string.label_di_share), getResources().getString(R.string.label_di_search), getResources().getString(R.string.label_di_mushroom), getResources().getString(R.string.label_di_view) });
final String[] values = new String[] { DI_SHARE, DI_SEARCH, DI_MUSHROOM, DI_VIEW };
pr.setEntryValues(values);
pr.setOnPreferenceChangeListener(mProcDirectIntent);
category.addPreference(pr);
mPrefDirectIntent = pr;
}
{
final ListPreference pr = new ListPreference(this);
pr.setDialogTitle(R.string.label_select_kind);
pr.setKey(KEY_DIRECT_INTENT2);
pr.setTitle(R.string.label_select_insert);
pr.setEntries(new String[] { getResources().getString(R.string.label_di_insert), getResources().getString(R.string.label_di_share), getResources().getString(R.string.label_di_search), getResources().getString(R.string.label_di_mushroom), getResources().getString(R.string.label_di_view) });
final String[] values = new String[] { DI_INSERT, DI_SHARE, DI_SEARCH, DI_MUSHROOM, DI_VIEW };
pr.setEntryValues(values);
pr.setOnPreferenceChangeListener(mProcDirectIntent2);
category.addPreference(pr);
mPrefInsert = pr;
}
}
if (CAT_INPUT.equals(categ)) {
// Input Category
setTitle(R.string.menu_pref_input);
final PreferenceCategory category = new PreferenceCategory(this);
category.setTitle(R.string.label_input);
mPs.addPreference(category);
{
// viewer mode
final CheckBoxPreference pr = new CheckBoxPreference(this);
pr.setKey(KEY_VIEWER_MODE);
pr.setTitle(R.string.label_viewer_mode);
pr.setSummary(R.string.summary_viewer_mode);
category.addPreference(pr);
}
{
final CheckBoxPreference pr = new CheckBoxPreference(this);
pr.setKey(KEY_USE_VOLUMEKEY);
pr.setTitle(R.string.label_use_volumekey);
pr.setSummary(R.string.summary_use_volumekey);
category.addPreference(pr);
}
{
// Trackball Button
final ListPreference pr = new ListPreference(this);
pr.setKey(KEY_TRACKBALL_BUTTON);
pr.setTitle(R.string.label_trackball_button);
pr.setEntries(new String[] { getString(R.string.trackball_centering), getString(R.string.trackball_enter), getString(R.string.trackball_contextmenu) });
pr.setEntryValues(new CharSequence[] { TB_CENTERING, TB_ENTER, TB_CONTEXTMENU });
category.addPreference(pr);
mPrefTrackball = pr;
}
{
// AUto capitalize
final CheckBoxPreference pr = new CheckBoxPreference(this);
pr.setKey(KEY_AUTO_CAPITALIZE);
pr.setTitle(R.string.label_auto_capitalize);
pr.setSummary(R.string.summary_auto_capitalize);
category.addPreference(pr);
}
{
final CheckBoxPreference pr = new CheckBoxPreference(this);
pr.setKey(KEY_SHORTCUT_ALT_LEFT);
pr.setTitle(R.string.label_shortcut_alt_left);
category.addPreference(pr);
}
{
final CheckBoxPreference pr = new CheckBoxPreference(this);
pr.setKey(KEY_SHORTCUT_ALT_RIGHT);
pr.setTitle(R.string.label_shortcut_alt_right);
category.addPreference(pr);
}
{
final CheckBoxPreference pr = new CheckBoxPreference(this);
pr.setKey(KEY_SHORTCUT_CTRL);
pr.setTitle(R.string.label_shortcut_ctrl);
pr.setSummary(R.string.summary_ctrl_daz);
category.addPreference(pr);
}
{
final CheckBoxPreference pr = new CheckBoxPreference(this);
pr.setKey(KEY_SHORTCUT_CTRL_LTN);
pr.setTitle(R.string.label_shortcut_ctrl);
pr.setSummary(R.string.summary_ctrl_ltn);
category.addPreference(pr);
}
{
final CheckBoxPreference pr = new CheckBoxPreference(this);
pr.setKey(KEY_SPECIAL_KEY_DESIREZ);
pr.setTitle(R.string.label_shortcut_ctrl);
pr.setSummary(R.string.summary_desirez);
category.addPreference(pr);
}
{
final Preference pr = new Preference(this);
pr.setTitle(R.string.label_customize_shortcut);
pr.setOnPreferenceClickListener(mProcShortcutSettings);
category.addPreference(pr);
}
{
// auto indent
final CheckBoxPreference pr = new CheckBoxPreference(this);
pr.setKey(KEY_AUTO_INDENT);
pr.setTitle(R.string.label_auto_indent);
category.addPreference(pr);
}
}
if (CAT_MISC.equals(categ)) {
// Misc Category
final PreferenceCategory category = new PreferenceCategory(this);
category.setTitle(R.string.label_miscllaneous);
mPs.addPreference(category);
{
// ACTION SHARE
final ListPreference pr = new ListPreference(this);
pr.setKey(KEY_ACTION_SHARE);
pr.setTitle(R.string.label_action_share);
pr.setSummary(R.string.summary_action_share);
pr.setEntries(new String[] { getString(R.string.label_action_share_insert), getString(R.string.label_action_share_newfile) });
pr.setEntryValues(new CharSequence[] { AS_INSERT, AS_NEWFILE });
category.addPreference(pr);
mPrefActionShare = pr;
}
{
final Preference pr = new Preference(this);
pr.setTitle(R.string.label_clear_history);
pr.setOnPreferenceClickListener(mProcClearHisotry);
category.addPreference(pr);
}
{
final Preference pr = new Preference(this);
pr.setTitle(R.string.label_init);
pr.setOnPreferenceClickListener(mProcInit);
category.addPreference(pr);
}
}
if (CAT_MISC.equals(categ)) {
// Help Category
final PreferenceCategory category = new PreferenceCategory(this);
category.setTitle(R.string.label_help);
mPs.addPreference(category);
{
final Preference pr = new Preference(this);
pr.setTitle(R.string.label_help);
pr.setOnPreferenceClickListener(mProcHelp);
category.addPreference(pr);
}
{
final Preference pr = new Preference(this);
pr.setTitle(R.string.label_mail);
pr.setOnPreferenceClickListener(mProcMail);
pr.setSummary(R.string.label_mail_summary);
category.addPreference(pr);
}
{
final Preference pr = new Preference(this);
pr.setTitle(R.string.label_tweet);
pr.setOnPreferenceClickListener(mProcTweet);
pr.setSummary(R.string.label_tweet_summary);
category.addPreference(pr);
}
{
// donate
final Preference pr = new Preference(this);
pr.setTitle(R.string.label_donate);
pr.setSummary(R.string.summary_donate);
pr.setOnPreferenceClickListener(mProcDonate);
category.addPreference(pr);
}
{
final Preference pr = new Preference(this);
pr.setTitle(R.string.label_about);
pr.setOnPreferenceClickListener(mProcAbout);
category.addPreference(pr);
}
}
if (CAT_TOP.equals(categ)) {
if (sSettings.donateCounter == 0) {
// donate
final Preference pr = new Preference(this);
pr.setTitle(R.string.label_donate);
pr.setSummary(R.string.summary_donate);
pr.setOnPreferenceClickListener(mProcDonate);
mPs.addPreference(pr);
}
{
final Preference pr = new Preference(this);
pr.setTitle(R.string.label_about);
pr.setOnPreferenceClickListener(mProcAbout);
mPs.addPreference(pr);
}
}
}
setPreferenceScreen(mPs);
setSummary();
}
use of android.preference.ListPreference in project xabber-android by redsolution.
the class ChannelSettingsFragment method loadVibro.
private void loadVibro(@StringRes int resid, final NotificationChannelUtils.ChannelType type) {
ListPreference preference = (ListPreference) getPreferenceScreen().findPreference(getString(resid));
preference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
NotificationChannelUtils.updateMessageChannel(notificationManager, type, null, MessageNotificationCreator.getVibroValue(((String) newValue), getActivity()), null);
return true;
}
});
}
use of android.preference.ListPreference in project meatspace-android by RomainPiel.
the class SettingsFragment method onActivityCreated.
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
ListPreference urlPreference = (ListPreference) findPreference(getString(R.string.settings_url_key));
if (urlPreference.getValue() == null) {
urlPreference.setValue(getString(BuildConfig.MEATSPACE_BASE_URL));
}
urlPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
getActivity().sendBroadcast(new Intent(Constants.FILTER_CHAT_CLOSE));
return true;
}
});
}
Aggregations