Search in sources :

Example 46 with PreferenceScreen

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

the class PreferenceIntegrationTest method inflate_shouldParseIntentContainedInPreference.

@Test
public void inflate_shouldParseIntentContainedInPreference() throws Exception {
    final PreferenceScreen screen = inflatePreferenceActivity();
    final Preference intentPreference = screen.findPreference("intent");
    Intent intent = intentPreference.getIntent();
    assertThat(intent).isNotNull();
    assertThat(intent.getAction()).isEqualTo("action");
    assertThat(intent.getData()).isEqualTo(Uri.parse("tel://1235"));
    assertThat(intent.getType()).isEqualTo("application/text");
    assertThat(intent.getComponent().getClassName()).isEqualTo("org.robolectric.test.Intent");
    assertThat(intent.getComponent().getPackageName()).isEqualTo("org.robolectric");
}
Also used : PreferenceScreen(android.preference.PreferenceScreen) CheckBoxPreference(android.preference.CheckBoxPreference) EditTextPreference(android.preference.EditTextPreference) ListPreference(android.preference.ListPreference) Preference(android.preference.Preference) RingtonePreference(android.preference.RingtonePreference) Intent(android.content.Intent) Test(org.junit.Test)

Example 47 with PreferenceScreen

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

the class PreferenceIntegrationTest method setEnabled_shouldEnableThePreference.

@Test
public void setEnabled_shouldEnableThePreference() throws Exception {
    final PreferenceScreen screen = inflatePreferenceActivity();
    final Preference preference = screen.findPreference("preference");
    preference.setEnabled(true);
    assertThat(preference.isEnabled()).isTrue();
    preference.setEnabled(false);
    assertThat(preference.isEnabled()).isFalse();
}
Also used : PreferenceScreen(android.preference.PreferenceScreen) CheckBoxPreference(android.preference.CheckBoxPreference) EditTextPreference(android.preference.EditTextPreference) ListPreference(android.preference.ListPreference) Preference(android.preference.Preference) RingtonePreference(android.preference.RingtonePreference) Test(org.junit.Test)

Example 48 with PreferenceScreen

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

the class ShadowDialogPreferenceTest method inflate_shouldCreateDialogPreference.

@Test
public void inflate_shouldCreateDialogPreference() {
    final PreferenceScreen screen = inflatePreferenceActivity();
    final DialogPreference preference = (DialogPreference) screen.findPreference("dialog");
    assertThat(preference.getTitle().toString()).isEqualTo("Dialog Preference");
    assertThat(preference.getSummary().toString()).isEqualTo("This is the dialog summary");
    assertThat(preference.getDialogMessage().toString()).isEqualTo("This is the dialog message");
    assertThat(preference.getPositiveButtonText().toString()).isEqualTo("YES");
    assertThat(preference.getNegativeButtonText().toString()).isEqualTo("NO");
}
Also used : PreferenceScreen(android.preference.PreferenceScreen) DialogPreference(android.preference.DialogPreference) Test(org.junit.Test)

Example 49 with PreferenceScreen

use of android.preference.PreferenceScreen in project NimbusBase_Android_Tutorial by NimbusBase.

the class PGFragmentRecord method getAllAttributeItems.

protected List<PGListItemAttribute> getAllAttributeItems() {
    final PreferenceScreen root = getPreferenceScreen();
    List<PGListItemAttribute> items = new ArrayList<PGListItemAttribute>(mAttrTypesByName.size());
    for (int index = 0; index < root.getPreferenceCount(); index++) {
        final PreferenceCategory category = (PreferenceCategory) root.getPreference(index);
        final PGListItemAttribute item = (PGListItemAttribute) category.getPreference(0);
        items.add(item);
    }
    return items;
}
Also used : PreferenceScreen(android.preference.PreferenceScreen) PreferenceCategory(android.preference.PreferenceCategory) ArrayList(java.util.ArrayList)

Example 50 with PreferenceScreen

use of android.preference.PreferenceScreen in project NimbusBase_Android_Tutorial by NimbusBase.

the class IndexFragment method initiatePreferenceScreen.

protected PreferenceScreen initiatePreferenceScreen(Base base, int preferencesResID) {
    addPreferencesFromResource(preferencesResID);
    final PreferenceScreen preferenceScreen = getPreferenceScreen();
    final PreferenceCategory serverCate = getServerCategory(preferenceScreen);
    serverCate.setOrderingAsAdded(true);
    final Server[] servers = base.getServers();
    for (int index = 0; index < servers.length; index++) {
        final Server server = servers[index];
        final ListItemServer item = new ListItemServer(getActivity(), server);
        item.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {

            @Override
            public boolean onPreferenceChange(Preference preference, Object newValue) {
                onServerItemStateChange((ListItemServer) preference, (Boolean) newValue);
                return false;
            }
        });
        item.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {

            @Override
            public boolean onPreferenceClick(Preference preference) {
                onServerItemClick((ListItemServer) preference);
                return true;
            }
        });
        serverCate.addPreference(item);
        onServerStateChange(server, index);
    }
    final PreferenceCategory databaseCate = getDatabaseCategory(preferenceScreen);
    final PreferenceScreen playgroundItem = (PreferenceScreen) databaseCate.findPreference(getString(R.string.item_playground));
    playgroundItem.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {

        @Override
        public boolean onPreferenceClick(Preference preference) {
            return onPlaygroundItemClick(preference);
        }
    });
    return preferenceScreen;
}
Also used : PreferenceScreen(android.preference.PreferenceScreen) Server(com.nimbusbase.nimbusbase.Server) PreferenceCategory(android.preference.PreferenceCategory) Preference(android.preference.Preference)

Aggregations

PreferenceScreen (android.preference.PreferenceScreen)153 Preference (android.preference.Preference)68 ListPreference (android.preference.ListPreference)42 CheckBoxPreference (android.preference.CheckBoxPreference)38 PreferenceCategory (android.preference.PreferenceCategory)32 Bundle (android.os.Bundle)26 EditTextPreference (android.preference.EditTextPreference)24 Method (java.lang.reflect.Method)20 Intent (android.content.Intent)19 SharedPreferences (android.content.SharedPreferences)11 RingtonePreference (android.preference.RingtonePreference)9 Test (org.junit.Test)9 Context (android.content.Context)8 OnPreferenceClickListener (android.preference.Preference.OnPreferenceClickListener)8 TwoStatePreference (android.preference.TwoStatePreference)8 AlertDialog (android.support.v7.app.AlertDialog)8 OsmandApplication (net.osmand.plus.OsmandApplication)8 ArrayList (java.util.ArrayList)7 SuppressLint (android.annotation.SuppressLint)6 ComponentName (android.content.ComponentName)6