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);
}
}
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);
}
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);
}
}
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));
}
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)]);
}
}
}
Aggregations