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