Search in sources :

Example 26 with PreferenceCategory

use of android.preference.PreferenceCategory in project AndroidChromium by JackyAndroid.

the class SavePasswordsPreferences method passwordExceptionListAvailable.

@Override
public void passwordExceptionListAvailable(int count) {
    resetList(PREF_CATEGORY_EXCEPTIONS);
    mNoPasswordExceptions = count == 0;
    if (mNoPasswordExceptions) {
        if (mNoPasswords)
            displayEmptyScreenMessage();
        return;
    }
    displayManageAccountLink();
    PreferenceCategory profileCategory = new PreferenceCategory(getActivity());
    profileCategory.setKey(PREF_CATEGORY_EXCEPTIONS);
    profileCategory.setTitle(R.string.section_saved_passwords_exceptions);
    profileCategory.setOrder(ORDER_EXCEPTIONS);
    getPreferenceScreen().addPreference(profileCategory);
    for (int i = 0; i < count; i++) {
        String exception = mPasswordManagerHandler.getSavedPasswordException(i);
        PreferenceScreen screen = getPreferenceManager().createPreferenceScreen(getActivity());
        screen.setTitle(exception);
        screen.setOnPreferenceClickListener(this);
        Bundle args = screen.getExtras();
        args.putString(PASSWORD_LIST_URL, exception);
        args.putInt(PASSWORD_LIST_ID, i);
        profileCategory.addPreference(screen);
    }
}
Also used : PreferenceScreen(android.preference.PreferenceScreen) PreferenceCategory(android.preference.PreferenceCategory) Bundle(android.os.Bundle) SpannableString(android.text.SpannableString)

Example 27 with PreferenceCategory

use of android.preference.PreferenceCategory in project AndroidChromium by JackyAndroid.

the class SavePasswordsPreferences method resetList.

private void resetList(String preferenceCategoryKey) {
    PreferenceCategory profileCategory = (PreferenceCategory) getPreferenceScreen().findPreference(preferenceCategoryKey);
    if (profileCategory != null) {
        profileCategory.removeAll();
        getPreferenceScreen().removePreference(profileCategory);
    }
    mEmptyView.setVisibility(View.GONE);
}
Also used : PreferenceCategory(android.preference.PreferenceCategory)

Example 28 with PreferenceCategory

use of android.preference.PreferenceCategory in project AndroidChromium by JackyAndroid.

the class SavePasswordsPreferences method passwordListAvailable.

@Override
public void passwordListAvailable(int count) {
    resetList(PREF_CATEGORY_SAVED_PASSWORDS);
    mNoPasswords = count == 0;
    if (mNoPasswords) {
        if (mNoPasswordExceptions)
            displayEmptyScreenMessage();
        return;
    }
    displayManageAccountLink();
    PreferenceCategory profileCategory = new PreferenceCategory(getActivity());
    profileCategory.setKey(PREF_CATEGORY_SAVED_PASSWORDS);
    profileCategory.setTitle(R.string.section_saved_passwords);
    profileCategory.setOrder(ORDER_SAVED_PASSWORDS);
    getPreferenceScreen().addPreference(profileCategory);
    for (int i = 0; i < count; i++) {
        PasswordUIView.SavedPasswordEntry saved = mPasswordManagerHandler.getSavedPasswordEntry(i);
        PreferenceScreen screen = getPreferenceManager().createPreferenceScreen(getActivity());
        String url = saved.getUrl();
        String name = saved.getUserName();
        screen.setTitle(url);
        screen.setOnPreferenceClickListener(this);
        screen.setSummary(name);
        Bundle args = screen.getExtras();
        args.putString(PASSWORD_LIST_NAME, name);
        args.putString(PASSWORD_LIST_URL, url);
        args.putInt(PASSWORD_LIST_ID, i);
        profileCategory.addPreference(screen);
    }
}
Also used : PreferenceScreen(android.preference.PreferenceScreen) PreferenceCategory(android.preference.PreferenceCategory) Bundle(android.os.Bundle) PasswordUIView(org.chromium.chrome.browser.PasswordUIView) SpannableString(android.text.SpannableString)

Example 29 with PreferenceCategory

use of android.preference.PreferenceCategory in project android-edittext-validator by vekexasia.

the class SettingsActivity method setupSimplePreferencesScreen.

/**
     * Shows the simplified settings UI if the device configuration if the device configuration dictates that a
     * simplified, single-pane UI should be shown.
     */
@SuppressWarnings("deprecation")
private void setupSimplePreferencesScreen() {
    if (!SettingsActivity.isSimplePreferences(this)) {
        return;
    }
    // Class<ContactPreferenceFragment> a = ContactPreferenceFragment.class;
    // In the simplified UI, fragments are not used at all and we instead
    // use the older PreferenceActivity APIs.
    // Add 'general' preferences.
    PreferenceCategory fakeHeader = new PreferenceCategory(this);
    addPreferencesFromResource(R.xml.pref_contact);
    SettingsActivity.bindPreferenceSummaryToValue(findPreference(SettingsActivity.PREF_KEY_FULL_NAME));
    SettingsActivity.bindPreferenceSummaryToValue(findPreference(SettingsActivity.PREF_KEY_ADDRESS));
    SettingsActivity.bindPreferenceSummaryToValue(findPreference(SettingsActivity.PREF_KEY_PHONE_NUMBER));
    SettingsActivity.bindPreferenceSummaryToValue(findPreference(SettingsActivity.PREF_KEY_EMAIL));
}
Also used : PreferenceCategory(android.preference.PreferenceCategory)

Example 30 with PreferenceCategory

use of android.preference.PreferenceCategory in project WordPress-Android by wordpress-mobile.

the class AppSettingsFragment method updateEditorSettings.

private void updateEditorSettings() {
    if (!AppPrefs.isVisualEditorAvailable()) {
        PreferenceScreen preferenceScreen = (PreferenceScreen) findPreference(getActivity().getString(R.string.pref_key_account_settings_root));
        PreferenceCategory editor = (PreferenceCategory) findPreference(getActivity().getString(R.string.pref_key_editor));
        if (preferenceScreen != null && editor != null) {
            preferenceScreen.removePreference(editor);
        }
    } else {
        final ListPreference editorTypePreference = (ListPreference) findPreference(getActivity().getString(R.string.pref_key_editor_type));
        // If user has Aztec preference from previous installation and it's not available anymore, don't use it
        if (!AppPrefs.isAztecEditorAvailable() && "2".equals(editorTypePreference.getValue())) {
            if (AppPrefs.isVisualEditorEnabled()) {
                editorTypePreference.setValue("1");
            } else {
                editorTypePreference.setValue("0");
            }
        }
        // if Aztec unavailable, only show the old list old of editors
        if (!AppPrefs.isAztecEditorAvailable()) {
            editorTypePreference.setEntries(R.array.editor_entries_without_aztec);
            editorTypePreference.setEntryValues(R.array.editor_values_without_aztec);
        }
        editorTypePreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {

            @Override
            public boolean onPreferenceChange(final Preference preference, final Object value) {
                if (value != null) {
                    int index = Integer.parseInt(value.toString());
                    CharSequence[] entries = editorTypePreference.getEntries();
                    editorTypePreference.setSummary(entries[index]);
                    switch(index) {
                        case 1:
                            AppPrefs.setAztecEditorEnabled(false);
                            AppPrefs.setVisualEditorEnabled(true);
                            break;
                        case 2:
                            AppPrefs.setAztecEditorEnabled(true);
                            AppPrefs.setVisualEditorEnabled(false);
                            break;
                        default:
                            AppPrefs.setAztecEditorEnabled(false);
                            AppPrefs.setVisualEditorEnabled(false);
                            break;
                    }
                    return true;
                } else {
                    return false;
                }
            }
        });
        String editorTypeKey = getString(R.string.pref_key_editor_type);
        String editorTypeSetting = mSettings.getString(editorTypeKey, "");
        if (!editorTypeSetting.equalsIgnoreCase("")) {
            CharSequence[] entries = editorTypePreference.getEntries();
            editorTypePreference.setSummary(entries[Integer.parseInt(editorTypeSetting)]);
        }
    }
}
Also used : PreferenceScreen(android.preference.PreferenceScreen) PreferenceCategory(android.preference.PreferenceCategory) ListPreference(android.preference.ListPreference) Preference(android.preference.Preference) ListPreference(android.preference.ListPreference)

Aggregations

PreferenceCategory (android.preference.PreferenceCategory)34 Preference (android.preference.Preference)22 PreferenceScreen (android.preference.PreferenceScreen)17 CheckBoxPreference (android.preference.CheckBoxPreference)12 ListPreference (android.preference.ListPreference)11 Intent (android.content.Intent)7 EditTextPreference (android.preference.EditTextPreference)6 Bundle (android.os.Bundle)4 OnPreferenceClickListener (android.preference.Preference.OnPreferenceClickListener)4 ArrayList (java.util.ArrayList)4 SharedPreferences (android.content.SharedPreferences)3 Uri (android.net.Uri)3 Activity (android.app.Activity)2 AlertDialog (android.app.AlertDialog)2 Context (android.content.Context)2 DialogInterface (android.content.DialogInterface)2 PackageInfo (android.content.pm.PackageInfo)2 PackageManager (android.content.pm.PackageManager)2 SpannableString (android.text.SpannableString)2 View (android.view.View)2