Search in sources :

Example 1 with DialogPreference

use of android.preference.DialogPreference 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 2 with DialogPreference

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

the class PreferenceSummaryHelper method updateSummary.

public static void updateSummary(PreferenceGroup group) {
    for (int index = 0; index < group.getPreferenceCount(); index++) {
        Preference preference = group.getPreference(index);
        if (preference instanceof PreferenceGroup) {
            updateSummary((PreferenceGroup) preference);
        }
        String titleAndSummary = preference.getTitle().toString();
        if (!isTitleAndSummary(titleAndSummary)) {
            continue;
        }
        preference.setTitle(getPreferenceTitle(titleAndSummary));
        if (preference instanceof DialogPreference) {
            ((DialogPreference) preference).setDialogTitle(preference.getTitle());
        }
        preference.setSummary(getPreferenceSummary(titleAndSummary));
    }
}
Also used : Preference(android.preference.Preference) DialogPreference(android.preference.DialogPreference) DialogPreference(android.preference.DialogPreference) PreferenceGroup(android.preference.PreferenceGroup)

Example 3 with DialogPreference

use of android.preference.DialogPreference in project Osmand by osmandapp.

the class SettingsOsmEditingActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    ((OsmandApplication) getApplication()).applyTheme(this);
    super.onCreate(savedInstanceState);
    getToolbar().setTitle(R.string.osm_settings);
    @SuppressWarnings("deprecation") PreferenceScreen grp = getPreferenceScreen();
    DialogPreference loginDialogPreference = new OsmLoginDataDialogPreference(this, null);
    grp.addPreference(loginDialogPreference);
    CheckBoxPreference poiEdit = createCheckBoxPreference(settings.OFFLINE_EDITION, R.string.offline_edition, R.string.offline_edition_descr);
    grp.addPreference(poiEdit);
    Preference pref = new Preference(this);
    pref.setTitle(R.string.local_openstreetmap_settings);
    pref.setSummary(R.string.local_openstreetmap_settings_descr);
    pref.setKey("local_openstreetmap_points");
    pref.setOnPreferenceClickListener(new OnPreferenceClickListener() {

        @Override
        public boolean onPreferenceClick(Preference preference) {
            OsmAndAppCustomization appCustomization = getMyApplication().getAppCustomization();
            final Intent favorites = new Intent(SettingsOsmEditingActivity.this, appCustomization.getFavoritesActivity());
            favorites.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
            getMyApplication().getSettings().FAVORITES_TAB.set(R.string.osm_edits);
            startActivity(favorites);
            return true;
        }
    });
    grp.addPreference(pref);
}
Also used : OnPreferenceClickListener(android.preference.Preference.OnPreferenceClickListener) OsmandApplication(net.osmand.plus.OsmandApplication) PreferenceScreen(android.preference.PreferenceScreen) DialogPreference(android.preference.DialogPreference) CheckBoxPreference(android.preference.CheckBoxPreference) CheckBoxPreference(android.preference.CheckBoxPreference) DialogPreference(android.preference.DialogPreference) Preference(android.preference.Preference) OsmAndAppCustomization(net.osmand.plus.OsmAndAppCustomization) Intent(android.content.Intent)

Example 4 with DialogPreference

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

the class PreferenceSummaryHelperActivity method updateSummary.

public static void updateSummary(PreferenceGroup group) {
    for (int index = 0; index < group.getPreferenceCount(); index++) {
        Preference preference = group.getPreference(index);
        if (preference instanceof PreferenceGroup) {
            updateSummary((PreferenceGroup) preference);
        }
        String titleAndSummary = preference.getTitle().toString();
        if (!isTitleAndSummary(titleAndSummary)) {
            continue;
        }
        preference.setTitle(getPreferenceTitle(titleAndSummary));
        if (preference instanceof DialogPreference) {
            ((DialogPreference) preference).setDialogTitle(preference.getTitle());
        }
        preference.setSummary(getPreferenceSummary(titleAndSummary));
    }
}
Also used : Preference(android.preference.Preference) DialogPreference(android.preference.DialogPreference) DialogPreference(android.preference.DialogPreference) PreferenceGroup(android.preference.PreferenceGroup)

Aggregations

DialogPreference (android.preference.DialogPreference)4 Preference (android.preference.Preference)3 PreferenceGroup (android.preference.PreferenceGroup)2 PreferenceScreen (android.preference.PreferenceScreen)2 Intent (android.content.Intent)1 CheckBoxPreference (android.preference.CheckBoxPreference)1 OnPreferenceClickListener (android.preference.Preference.OnPreferenceClickListener)1 OsmAndAppCustomization (net.osmand.plus.OsmAndAppCustomization)1 OsmandApplication (net.osmand.plus.OsmandApplication)1 Test (org.junit.Test)1