Search in sources :

Example 26 with Preference

use of android.preference.Preference in project xabber-android by redsolution.

the class BaseSettingsFragment method setPreferences.

/**
     * Set values to the UI elements.
     *
     * @param source
     */
protected void setPreferences(Map<String, Object> source) {
    PreferenceScreen preferenceScreen = getPreferenceScreen();
    for (int index = 0; index < preferenceScreen.getPreferenceCount(); index++) {
        Preference preference = preferenceScreen.getPreference(index);
        Object value = source.get(preference.getKey());
        setPreference(preference, value);
    }
}
Also used : PreferenceScreen(android.preference.PreferenceScreen) RingtonePreference(com.xabber.android.ui.widget.RingtonePreference) CheckBoxPreference(android.preference.CheckBoxPreference) EditTextPreference(android.preference.EditTextPreference) ListPreference(android.preference.ListPreference) Preference(android.preference.Preference) SwitchPreference(android.preference.SwitchPreference)

Example 27 with Preference

use of android.preference.Preference in project robolectric by robolectric.

the class ShadowPreferenceActivityTestWithFragment method preferenceAddedWithCorrectDetails.

@Test
public void preferenceAddedWithCorrectDetails() {
    Preference preference = fragment.findPreference("edit_text");
    assertThat(preference).isNotNull();
    assertThat(preference.getTitle()).isEqualTo("EditText Test");
    assertThat(preference.getSummary()).isEqualTo("");
}
Also used : Preference(android.preference.Preference) Test(org.junit.Test)

Example 28 with Preference

use of android.preference.Preference in project Conversations by siacs.

the class SettingsFragment method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Load the preferences from an XML resource
    addPreferencesFromResource(R.xml.preferences);
    // Remove from standard preferences if the flag ONLY_INTERNAL_STORAGE is not true
    if (!Config.ONLY_INTERNAL_STORAGE) {
        PreferenceCategory mCategory = (PreferenceCategory) findPreference("security_options");
        Preference mPref1 = findPreference("clean_cache");
        Preference mPref2 = findPreference("clean_private_storage");
        mCategory.removePreference(mPref1);
        mCategory.removePreference(mPref2);
    }
}
Also used : PreferenceCategory(android.preference.PreferenceCategory) Preference(android.preference.Preference)

Example 29 with Preference

use of android.preference.Preference in project androidannotations by androidannotations.

the class PreferenceEventsHandledActivityTest method testConventionPreferenceClickHandled.

@Test
public void testConventionPreferenceClickHandled() {
    assertThat(activity.conventionPrefClicked).isFalse();
    Preference preference = activity.findPreference(activity.getString(R.string.conventionKey));
    preference.getOnPreferenceClickListener().onPreferenceClick(preference);
    assertThat(activity.conventionPrefClicked).isTrue();
}
Also used : Preference(android.preference.Preference) Test(org.junit.Test)

Example 30 with Preference

use of android.preference.Preference in project androidannotations by androidannotations.

the class PreferenceEventsHandledActivityTest method testPreferenceChangeParsedParameterPassed.

@Test
public void testPreferenceChangeParsedParameterPassed() {
    Preference preference = activity.findPreference(activity.getString(R.string.editTextPrefKey));
    preference.getOnPreferenceChangeListener().onPreferenceChange(preference, "2");
    assertThat(activity.editTextPreference).isSameAs(preference);
    assertThat(activity.preferenceChangedParsedValue).isEqualTo(2);
}
Also used : Preference(android.preference.Preference) Test(org.junit.Test)

Aggregations

Preference (android.preference.Preference)173 CheckBoxPreference (android.preference.CheckBoxPreference)50 ListPreference (android.preference.ListPreference)49 PreferenceScreen (android.preference.PreferenceScreen)36 Intent (android.content.Intent)32 EditTextPreference (android.preference.EditTextPreference)26 OnPreferenceChangeListener (android.preference.Preference.OnPreferenceChangeListener)23 PreferenceCategory (android.preference.PreferenceCategory)23 OnPreferenceClickListener (android.preference.Preference.OnPreferenceClickListener)21 SharedPreferences (android.content.SharedPreferences)19 ChromeSwitchPreference (org.chromium.chrome.browser.preferences.ChromeSwitchPreference)16 Test (org.junit.Test)15 PreferenceGroup (android.preference.PreferenceGroup)13 Uri (android.net.Uri)12 Bundle (android.os.Bundle)12 ArrayList (java.util.ArrayList)11 Resources (android.content.res.Resources)10 SwitchPreference (android.preference.SwitchPreference)10 View (android.view.View)10 ChromeBasePreference (org.chromium.chrome.browser.preferences.ChromeBasePreference)10