Search in sources :

Example 11 with CheckBoxPreference

use of android.preference.CheckBoxPreference in project Anki-Android by Ramblurr.

the class DeckOptions method updateSummaries.

protected void updateSummaries() {
    Resources res = getResources();
    // for all text preferences, set summary as current database value
    for (String key : mPref.mValues.keySet()) {
        Preference pref = this.findPreference(key);
        if (key.equals("deckConf")) {
            String groupName = getOptionsGroupName();
            int count = getOptionsGroupCount();
            pref.setSummary(res.getQuantityString(R.plurals.deck_conf_group_summ, count, groupName, count));
            continue;
        }
        String value = null;
        if (pref == null) {
            continue;
        } else if (pref instanceof CheckBoxPreference) {
            continue;
        } else if (pref instanceof ListPreference) {
            ListPreference lp = (ListPreference) pref;
            value = lp.getEntry() != null ? lp.getEntry().toString() : "";
        } else {
            value = this.mPref.getString(key, "");
        }
        // update summary
        if (!mPref.mSummaries.containsKey(key)) {
            CharSequence s = pref.getSummary();
            mPref.mSummaries.put(key, s != null ? pref.getSummary().toString() : null);
        }
        String summ = mPref.mSummaries.get(key);
        if (summ != null && summ.contains("XXX")) {
            pref.setSummary(summ.replace("XXX", value));
        } else {
            pref.setSummary(value);
        }
    }
    // Update summaries of preference items that don't have values (aren't in mValues)
    int subDeckCount = getSubdeckCount();
    this.findPreference("confSetSubdecks").setSummary(res.getQuantityString(R.plurals.deck_conf_set_subdecks_summ, subDeckCount, subDeckCount));
}
Also used : CheckBoxPreference(android.preference.CheckBoxPreference) StepsPreference(com.ichi2.preferences.StepsPreference) ListPreference(android.preference.ListPreference) Preference(android.preference.Preference) CheckBoxPreference(android.preference.CheckBoxPreference) Resources(android.content.res.Resources) ListPreference(android.preference.ListPreference)

Example 12 with CheckBoxPreference

use of android.preference.CheckBoxPreference in project KeepScore by nolanlawson.

the class SettingsActivity method setUpPreferences.

private void setUpPreferences() {
    plusButtonPref = (EditTextPreference) findPreferenceById(R.string.CONSTANT_pref_plus_button);
    minusButtonPref = (EditTextPreference) findPreferenceById(R.string.CONSTANT_pref_minus_button);
    button1Pref = (EditTextPreference) findPreferenceById(R.string.CONSTANT_pref_button_1);
    button2Pref = (EditTextPreference) findPreferenceById(R.string.CONSTANT_pref_button_2);
    button3Pref = (EditTextPreference) findPreferenceById(R.string.CONSTANT_pref_button_3);
    button4Pref = (EditTextPreference) findPreferenceById(R.string.CONSTANT_pref_button_4);
    twoPlayerButton1Pref = (EditTextPreference) findPreferenceById(R.string.CONSTANT_pref_2p_button_1);
    twoPlayerButton2Pref = (EditTextPreference) findPreferenceById(R.string.CONSTANT_pref_2p_button_2);
    twoPlayerButton3Pref = (EditTextPreference) findPreferenceById(R.string.CONSTANT_pref_2p_button_3);
    twoPlayerButton4Pref = (EditTextPreference) findPreferenceById(R.string.CONSTANT_pref_2p_button_4);
    greenTextPref = (CheckBoxPreference) findPreferenceById(R.string.CONSTANT_pref_green_text);
    showRoundTotalsPref = (CheckBoxPreference) findPreferenceById(R.string.CONSTANT_pref_show_round_totals);
    showInitialMessagePref = (CheckBoxPreference) findPreferenceById(R.string.CONSTANT_pref_initial_message);
    disableHighlightTagPref = (CheckBoxPreference) findPreferenceById(R.string.CONSTANT_pref_disable_highlight_tag);
    showColorsPref = (CheckBoxPreference) findPreferenceById(R.string.CONSTANT_pref_show_colors);
    updateDelayPref = (EditTextPreference) findPreferenceById(R.string.CONSTANT_pref_update_delay);
    initialScorePref = (EditTextPreference) findPreferenceById(R.string.CONSTANT_pref_initial_score);
    resetPref = findPreferenceById(R.string.CONSTANT_pref_reset);
    aboutPref = findPreferenceById(R.string.CONSTANT_pref_about);
    colorSchemePref = (ListPreference) findPreferenceById(R.string.CONSTANT_pref_color_scheme);
    orientationPref = (ListPreference) findPreferenceById(R.string.CONSTANT_pref_orientation);
    loadSettingsPref = findPreferenceById(R.string.CONSTANT_pref_load_settings);
    saveSettingsPref = findPreferenceById(R.string.CONSTANT_pref_save_settings);
    // changed
    for (EditTextPreference pref : new EditTextPreference[] { button1Pref, button2Pref, button3Pref, button4Pref, twoPlayerButton1Pref, twoPlayerButton2Pref, twoPlayerButton3Pref, twoPlayerButton4Pref, plusButtonPref, minusButtonPref }) {
        setDynamicSummary(pref);
    }
    // do a special check for the update delay value
    updateDelayPref.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {

        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            if (!IntegerUtil.validInt(newValue.toString()) || Integer.parseInt(newValue.toString()) < 1 || Integer.parseInt(newValue.toString()) > 600) {
                ToastHelper.showLong(SettingsActivity.this, R.string.toast_valid_update_delay_values);
                return false;
            }
            PreferenceHelper.resetCache();
            return true;
        }
    });
    // do another special check for the initial score value
    initialScorePref.setSummary(initialScorePref.getText());
    initialScorePref.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {

        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            if (!IntegerUtil.validInt(newValue.toString())) {
                ToastHelper.showLong(SettingsActivity.this, R.string.toast_valid_initial_score);
                return false;
            }
            preference.setSummary(newValue.toString());
            return true;
        }
    });
    // show the version number in the "about" summary text
    String version = String.format(getString(R.string.text_version_number), PackageHelper.getVersionName(this));
    aboutPref.setSummary(version);
    // do a special popup for the reset preference
    resetPref.setOnPreferenceClickListener(this);
    loadSettingsPref.setOnPreferenceClickListener(this);
    saveSettingsPref.setOnPreferenceClickListener(this);
    setDynamicListPreferenceSummary(colorSchemePref);
    setDynamicListPreferenceSummary(orientationPref);
    // go to the about activity if the about pref is pressed
    aboutPref.setOnPreferenceClickListener(this);
    greenTextPref.setOnPreferenceChangeListener(this);
    showRoundTotalsPref.setOnPreferenceChangeListener(this);
    disableHighlightTagPref.setOnPreferenceChangeListener(this);
    showInitialMessagePref.setOnPreferenceChangeListener(this);
    showColorsPref.setOnPreferenceChangeListener(this);
}
Also used : CheckBoxPreference(android.preference.CheckBoxPreference) EditTextPreference(android.preference.EditTextPreference) ListPreference(android.preference.ListPreference) Preference(android.preference.Preference) EditTextPreference(android.preference.EditTextPreference) OnPreferenceChangeListener(android.preference.Preference.OnPreferenceChangeListener)

Example 13 with CheckBoxPreference

use of android.preference.CheckBoxPreference 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();
}
Also used : CheckBoxPreference(android.preference.CheckBoxPreference) ListPreference(android.preference.ListPreference) Preference(android.preference.Preference) PreferenceCategory(android.preference.PreferenceCategory) CheckBoxPreference(android.preference.CheckBoxPreference) ListPreference(android.preference.ListPreference)

Example 14 with CheckBoxPreference

use of android.preference.CheckBoxPreference in project android_packages_inputmethods_LatinIME by CyanogenMod.

the class TwoStatePreferenceHelper method replaceAllCheckBoxPreferencesBySwitchPreferences.

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);
            }
        }
    }
}
Also used : Preference(android.preference.Preference) CheckBoxPreference(android.preference.CheckBoxPreference) SwitchPreference(android.preference.SwitchPreference) CheckBoxPreference(android.preference.CheckBoxPreference) ArrayList(java.util.ArrayList) PreferenceGroup(android.preference.PreferenceGroup)

Example 15 with CheckBoxPreference

use of android.preference.CheckBoxPreference in project android_packages_apps_Torch by CyanogenMod.

the class WidgetOptionsActivity method onCreate.

@SuppressWarnings("deprecation")
public //No need to go to fragments right now
void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.layout.optionsview);
    mPreferences = PreferenceManager.getDefaultSharedPreferences(this);
    Bundle extras = getIntent().getExtras();
    if (extras != null) {
        mAppWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
    }
    CheckBoxPreference brightPref = (CheckBoxPreference) findPreference("widget_bright");
    brightPref.setChecked(false);
    CheckBoxPreference strobePref = (CheckBoxPreference) findPreference("widget_strobe");
    strobePref.setChecked(false);
    mStrobeFrequency = (SeekBarPreference) findPreference("widget_strobe_freq");
    mStrobeFrequency.setEnabled(false);
    //keeps 'Strobe frequency' option available
    getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
}
Also used : CheckBoxPreference(android.preference.CheckBoxPreference) Bundle(android.os.Bundle)

Aggregations

CheckBoxPreference (android.preference.CheckBoxPreference)49 Preference (android.preference.Preference)31 ListPreference (android.preference.ListPreference)20 PreferenceScreen (android.preference.PreferenceScreen)11 SharedPreferences (android.content.SharedPreferences)10 EditTextPreference (android.preference.EditTextPreference)10 PreferenceCategory (android.preference.PreferenceCategory)9 Intent (android.content.Intent)8 ArrayList (java.util.ArrayList)8 OnPreferenceClickListener (android.preference.Preference.OnPreferenceClickListener)6 Uri (android.net.Uri)5 View (android.view.View)5 OnPreferenceChangeListener (android.preference.Preference.OnPreferenceChangeListener)4 PreferenceManager (android.preference.PreferenceManager)4 DialogInterface (android.content.DialogInterface)3 PackageInfo (android.content.pm.PackageInfo)3 Resources (android.content.res.Resources)3 Build (android.os.Build)3 Bundle (android.os.Bundle)3 SwitchPreference (android.preference.SwitchPreference)3