Search in sources :

Example 6 with AlertDialogBuilder

use of de.westnordost.streetcomplete.view.dialogs.AlertDialogBuilder in project StreetComplete by westnordost.

the class AddMaxSpeedForm method confirmLivingStreet.

private void confirmLivingStreet(final Runnable callback) {
    View view = LayoutInflater.from(getActivity()).inflate(R.layout.quest_maxspeed_living_street_confirmation, null, false);
    ImageView img = view.findViewById(R.id.imgLivingStreet);
    int drawableId = getResources().getIdentifier(getCountryInfo().getLivingStreetSign(), "drawable", getActivity().getPackageName());
    img.setImageDrawable(getResources().getDrawable(drawableId));
    new AlertDialogBuilder(getActivity()).setView(view).setTitle(R.string.quest_maxspeed_answer_living_street_confirmation_title).setPositiveButton(R.string.quest_generic_confirmation_yes, (dialog, which) -> callback.run()).setNegativeButton(R.string.quest_generic_confirmation_no, null).show();
}
Also used : AlertDialogBuilder(de.westnordost.streetcomplete.view.dialogs.AlertDialogBuilder) ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) View(android.view.View)

Example 7 with AlertDialogBuilder

use of de.westnordost.streetcomplete.view.dialogs.AlertDialogBuilder in project StreetComplete by westnordost.

the class AddPlaceNameForm method confirmNoName.

private void confirmNoName() {
    new AlertDialogBuilder(getActivity()).setTitle(R.string.quest_name_answer_noName_confirmation_title).setPositiveButton(R.string.quest_name_noName_confirmation_positive, (dialog, which) -> {
        Bundle data = new Bundle();
        data.putBoolean(NO_NAME, true);
        applyImmediateAnswer(data);
    }).setNegativeButton(R.string.quest_generic_confirmation_no, null).show();
}
Also used : AlertDialogBuilder(de.westnordost.streetcomplete.view.dialogs.AlertDialogBuilder) Bundle(android.os.Bundle)

Example 8 with AlertDialogBuilder

use of de.westnordost.streetcomplete.view.dialogs.AlertDialogBuilder in project StreetComplete by westnordost.

the class AddRoadNameForm method selectNoStreetNameReason.

private void selectNoStreetNameReason() {
    final String linkRoad = getResources().getString(R.string.quest_streetName_answer_noProperStreet_link), serviceRoad = getResources().getString(R.string.quest_streetName_answer_noProperStreet_service2), trackRoad = getResources().getString(R.string.quest_streetName_answer_noProperStreet_track2), noName = getResources().getString(R.string.quest_streetName_answer_noName_noname), leaveNote = getResources().getString(R.string.quest_streetName_answer_noProperStreet_leaveNote);
    String highwayValue = getOsmElement().getTags().get("highway");
    boolean mayBeLink = highwayValue.matches("primary|secondary|tertiary");
    final List<String> answers = new ArrayList<>(3);
    if (mayBeLink)
        answers.add(linkRoad);
    answers.add(serviceRoad);
    answers.add(trackRoad);
    answers.add(leaveNote);
    answers.add(noName);
    DialogInterface.OnClickListener onSelect = new DialogInterface.OnClickListener() {

        Integer selection = null;

        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (which >= 0) {
                selection = which;
                ((AlertDialog) dialog).getButton(DialogInterface.BUTTON_POSITIVE).setEnabled(true);
            } else if (which == DialogInterface.BUTTON_POSITIVE) {
                if (selection == null || selection < 0 || selection >= answers.size())
                    return;
                onAnswer();
            }
        }

        private void onAnswer() {
            String answer = answers.get(selection);
            if (answer.equals(leaveNote)) {
                onClickCantSay();
            } else if (answer.equals(noName)) {
                confirmNoStreetName();
            } else {
                Bundle data = new Bundle();
                int type = 0;
                if (answer.equals(linkRoad))
                    type = IS_LINK;
                if (answer.equals(serviceRoad))
                    type = IS_SERVICE;
                if (answer.equals(trackRoad))
                    type = IS_TRACK;
                data.putInt(NO_PROPER_ROAD, type);
                applyImmediateAnswer(data);
            }
        }
    };
    AlertDialog dlg = new AlertDialogBuilder(getActivity()).setSingleChoiceItems(answers.toArray(new String[0]), -1, onSelect).setTitle(R.string.quest_streetName_answer_noName_question).setPositiveButton(android.R.string.ok, onSelect).setNegativeButton(android.R.string.cancel, null).show();
    dlg.getButton(DialogInterface.BUTTON_POSITIVE).setEnabled(false);
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) AlertDialogBuilder(de.westnordost.streetcomplete.view.dialogs.AlertDialogBuilder) DialogInterface(android.content.DialogInterface) Bundle(android.os.Bundle) ArrayList(java.util.ArrayList)

Example 9 with AlertDialogBuilder

use of de.westnordost.streetcomplete.view.dialogs.AlertDialogBuilder in project StreetComplete by westnordost.

the class AddRoadNameForm method confirmPossibleAbbreviation.

private void confirmPossibleAbbreviation(String name, final Runnable onConfirmed) {
    Spanned title = Html.fromHtml(getResources().getString(R.string.quest_streetName_nameWithAbbreviations_confirmation_title_name, "<i>" + Html.escapeHtml(name) + "</i>"));
    new AlertDialogBuilder(getActivity()).setTitle(title).setMessage(R.string.quest_streetName_nameWithAbbreviations_confirmation_description).setPositiveButton(R.string.quest_streetName_nameWithAbbreviations_confirmation_positive, (dialog, which) -> onConfirmed.run()).setNegativeButton(R.string.quest_generic_confirmation_no, null).show();
}
Also used : AlertDialogBuilder(de.westnordost.streetcomplete.view.dialogs.AlertDialogBuilder) Spanned(android.text.Spanned)

Example 10 with AlertDialogBuilder

use of de.westnordost.streetcomplete.view.dialogs.AlertDialogBuilder in project StreetComplete by westnordost.

the class SettingsFragment method onCreatePreferences.

@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
    Injector.instance.getApplicationComponent().inject(this);
    PreferenceManager.setDefaultValues(getContext(), R.xml.preferences, false);
    addPreferencesFromResource(R.xml.preferences);
    Preference oauth = getPreferenceScreen().findPreference("oauth");
    oauth.setOnPreferenceClickListener(preference -> {
        new OsmOAuthDialogFragment().show(getFragmentManager(), OsmOAuthDialogFragment.TAG);
        return true;
    });
    Preference quests = getPreferenceScreen().findPreference("quests");
    quests.setOnPreferenceClickListener(preference -> {
        getFragmentActivity().setCurrentFragment(new QuestSelectionFragment());
        return true;
    });
    Preference questsInvalidation = getPreferenceScreen().findPreference("quests.invalidation");
    questsInvalidation.setOnPreferenceClickListener(preference -> {
        new AlertDialogBuilder(getContext()).setMessage(R.string.invalidation_dialog_message).setPositiveButton(R.string.invalidate_confirmation, (dialog, which) -> {
            downloadedTilesDao.removeAll();
        }).setNegativeButton(android.R.string.cancel, null).create().show();
        return true;
    });
}
Also used : Bundle(android.os.Bundle) FragmentContainerActivity(de.westnordost.streetcomplete.FragmentContainerActivity) Provider(javax.inject.Provider) AlertDialogBuilder(de.westnordost.streetcomplete.view.dialogs.AlertDialogBuilder) PreferenceFragmentCompat(android.support.v7.preference.PreferenceFragmentCompat) Intent(android.content.Intent) DialogFragment(android.support.v4.app.DialogFragment) DownloadedTilesDao(de.westnordost.streetcomplete.data.tiles.DownloadedTilesDao) Preference(android.support.v7.preference.Preference) PreferenceManager(android.support.v7.preference.PreferenceManager) Inject(javax.inject.Inject) IntentListener(de.westnordost.streetcomplete.IntentListener) R(de.westnordost.streetcomplete.R) SharedPreferences(android.content.SharedPreferences) Injector(de.westnordost.streetcomplete.Injector) OAuthPrefs(de.westnordost.streetcomplete.oauth.OAuthPrefs) Prefs(de.westnordost.streetcomplete.Prefs) OsmOAuthDialogFragment(de.westnordost.streetcomplete.oauth.OsmOAuthDialogFragment) AlertDialogBuilder(de.westnordost.streetcomplete.view.dialogs.AlertDialogBuilder) Preference(android.support.v7.preference.Preference) OsmOAuthDialogFragment(de.westnordost.streetcomplete.oauth.OsmOAuthDialogFragment)

Aggregations

AlertDialogBuilder (de.westnordost.streetcomplete.view.dialogs.AlertDialogBuilder)21 Bundle (android.os.Bundle)11 View (android.view.View)11 R (de.westnordost.streetcomplete.R)8 AlertDialog (android.support.v7.app.AlertDialog)6 LayoutInflater (android.view.LayoutInflater)6 ArrayList (java.util.ArrayList)6 Intent (android.content.Intent)5 RecyclerView (android.support.v7.widget.RecyclerView)5 ImageView (android.widget.ImageView)5 Inject (javax.inject.Inject)5 Context (android.content.Context)4 Toast (android.widget.Toast)4 Arrays (java.util.Arrays)4 List (java.util.List)4 DialogInterface (android.content.DialogInterface)3 ViewGroup (android.view.ViewGroup)3 TextView (android.widget.TextView)3 Activity (android.app.Activity)2 BroadcastReceiver (android.content.BroadcastReceiver)2