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