Search in sources :

Example 1 with AlertDialogBuilder

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

the class LocationRequestFragment method requestLocationSettingsToBeOn.

private void requestLocationSettingsToBeOn() {
    if (LocationUtil.isLocationOn(getContext())) {
        state = LocationState.ENABLED;
        nextStep();
    } else {
        final AlertDialog dlg = new AlertDialogBuilder(getContext()).setMessage(R.string.turn_on_location_request).setPositiveButton(android.R.string.yes, (dialog, which) -> {
            dialog.dismiss();
            Intent viewIntent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
            startActivityForResult(viewIntent, LOCATION_TURN_ON_REQUEST);
        }).setNegativeButton(android.R.string.no, (dialog, which) -> cancelTurnLocationOnDialog()).setOnCancelListener(dialog -> cancelTurnLocationOnDialog()).create();
        // the user may turn on location in the pull-down-overlay, without actually going into
        // settings dialog
        registerForLocationProviderChanges(dlg);
        dlg.show();
    }
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) Context(android.content.Context) Bundle(android.os.Bundle) AlertDialogBuilder(de.westnordost.streetcomplete.view.dialogs.AlertDialogBuilder) PackageManager(android.content.pm.PackageManager) Fragment(android.support.v4.app.Fragment) Intent(android.content.Intent) NonNull(android.support.annotation.NonNull) LocalBroadcastManager(android.support.v4.content.LocalBroadcastManager) BroadcastReceiver(android.content.BroadcastReceiver) Manifest(android.Manifest) R(de.westnordost.streetcomplete.R) AlertDialog(android.support.v7.app.AlertDialog) Settings(android.provider.Settings) Nullable(android.support.annotation.Nullable) AlertDialogBuilder(de.westnordost.streetcomplete.view.dialogs.AlertDialogBuilder) Intent(android.content.Intent)

Example 2 with AlertDialogBuilder

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

the class FindQuestSourceComponent method findSource.

public void findSource(final long questId, final QuestGroup group, final Location[] locations, final Listener listener) {
    Double distance = getDistanceToElementInMeters(questId, group, locations);
    if (dontShowAgain || distance != null && distance < MAX_DISTANCE_TO_ELEMENT_FOR_SURVEY) {
        listener.onFindQuestSourceResult(SURVEY);
    } else {
        View inner = LayoutInflater.from(activity).inflate(R.layout.quest_source_dialog_layout, null, false);
        final CheckBox checkBox = inner.findViewById(R.id.checkBoxDontShowAgain);
        AlertDialogBuilder alertDialogBuilder = new AlertDialogBuilder(activity);
        alertDialogBuilder.setTitle(R.string.quest_source_dialog_title).setView(inner).setPositiveButton(R.string.quest_generic_confirmation_yes, (dialog, which) -> {
            ++timesShown;
            dontShowAgain = checkBox.isChecked();
            listener.onFindQuestSourceResult(SURVEY);
        }).setNegativeButton(android.R.string.cancel, null);
        checkBox.setVisibility(timesShown < 2 ? View.GONE : View.VISIBLE);
        alertDialogBuilder.show();
    }
}
Also used : Coordinate(com.vividsolutions.jts.geom.Coordinate) OsmNoteQuestDao(de.westnordost.streetcomplete.data.osmnotes.OsmNoteQuestDao) AlertDialogBuilder(de.westnordost.streetcomplete.view.dialogs.AlertDialogBuilder) LayoutInflater(android.view.LayoutInflater) DistanceOp(com.vividsolutions.jts.operation.distance.DistanceOp) SphericalEarthMath(de.westnordost.streetcomplete.util.SphericalEarthMath) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) List(java.util.List) R(de.westnordost.streetcomplete.R) CheckBox(android.widget.CheckBox) QuestGroup(de.westnordost.streetcomplete.data.QuestGroup) View(android.view.View) Geometry(com.vividsolutions.jts.geom.Geometry) GeometryFactory(com.vividsolutions.jts.geom.GeometryFactory) Location(android.location.Location) JTSConst(de.westnordost.streetcomplete.util.JTSConst) Activity(android.app.Activity) OsmQuestDao(de.westnordost.streetcomplete.data.osm.persist.OsmQuestDao) ElementGeometry(de.westnordost.streetcomplete.data.osm.ElementGeometry) AlertDialogBuilder(de.westnordost.streetcomplete.view.dialogs.AlertDialogBuilder) CheckBox(android.widget.CheckBox) View(android.view.View)

Example 3 with AlertDialogBuilder

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

the class AddCyclewayForm method showCyclewaySelectionDialog.

private void showCyclewaySelectionDialog(final boolean isRight) {
    RecyclerView recyclerView = new RecyclerView(getActivity());
    recyclerView.setLayoutParams(new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    recyclerView.setLayoutManager(new GridLayoutManager(getActivity(), 2));
    final AlertDialog alertDialog = new AlertDialogBuilder(getActivity()).setTitle(R.string.quest_select_hint).setView(recyclerView).create();
    recyclerView.setAdapter(createAdapter(getCyclewayItems(isRight), cycleway -> {
        alertDialog.dismiss();
        int iconResId = cycleway.getIconResId(isLeftHandTraffic());
        if (isRight) {
            puzzle.replaceRightSideImageResource(iconResId);
            rightSide = cycleway;
        } else {
            puzzle.replaceLeftSideImageResource(iconResId);
            leftSide = cycleway;
        }
    }));
    alertDialog.show();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) AnyThread(android.support.annotation.AnyThread) GridLayoutManager(android.support.v7.widget.GridLayoutManager) Arrays(java.util.Arrays) Bundle(android.os.Bundle) LatLon(de.westnordost.osmapi.map.data.LatLon) ImageView(android.widget.ImageView) FiltersParser(de.westnordost.streetcomplete.data.osm.tql.FiltersParser) StreetSideSelectPuzzle(de.westnordost.streetcomplete.view.StreetSideSelectPuzzle) ArrayList(java.util.ArrayList) CompassView(de.westnordost.streetcomplete.view.CompassView) R(de.westnordost.streetcomplete.R) TagFilterExpression(de.westnordost.streetcomplete.data.osm.tql.TagFilterExpression) Toast(android.widget.Toast) Map(java.util.Map) View(android.view.View) ElementGeometry(de.westnordost.streetcomplete.data.osm.ElementGeometry) AlertDialogBuilder(de.westnordost.streetcomplete.view.dialogs.AlertDialogBuilder) LayoutInflater(android.view.LayoutInflater) ViewGroup(android.view.ViewGroup) SphericalEarthMath(de.westnordost.streetcomplete.util.SphericalEarthMath) ListAdapter(de.westnordost.streetcomplete.view.ListAdapter) RecyclerView(android.support.v7.widget.RecyclerView) List(java.util.List) AlertDialog(android.support.v7.app.AlertDialog) TextView(android.widget.TextView) AbstractQuestFormAnswerFragment(de.westnordost.streetcomplete.quests.AbstractQuestFormAnswerFragment) AlertDialogBuilder(de.westnordost.streetcomplete.view.dialogs.AlertDialogBuilder) GridLayoutManager(android.support.v7.widget.GridLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView)

Example 4 with AlertDialogBuilder

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

the class AddBuildingLevelsForm method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = super.onCreateView(inflater, container, savedInstanceState);
    View contentView = setContentView(R.layout.quest_building_levels);
    levelsInput = contentView.findViewById(R.id.levelsInput);
    levelsInput.requestFocus();
    roofLevelsInput = contentView.findViewById(R.id.roofLevelsInput);
    addOtherAnswer(R.string.quest_buildingLevels_answer_multipleLevels, () -> {
        new AlertDialogBuilder(getActivity()).setMessage(R.string.quest_buildingLevels_answer_description).setPositiveButton(android.R.string.ok, null).show();
    });
    return view;
}
Also used : AlertDialogBuilder(de.westnordost.streetcomplete.view.dialogs.AlertDialogBuilder) View(android.view.View)

Example 5 with AlertDialogBuilder

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

the class AddHousenumberForm method addOtherAnswers.

private void addOtherAnswers() {
    addOtherAnswer(R.string.quest_address_answer_house_name, () -> {
        isHousename = true;
        setLayout(R.layout.quest_housename);
    });
    addOtherAnswer(R.string.quest_housenumber_multiple_numbers, () -> {
        new AlertDialogBuilder(getActivity()).setMessage(R.string.quest_housenumber_multiple_numbers_description).setPositiveButton(android.R.string.ok, null).show();
    });
}
Also used : AlertDialogBuilder(de.westnordost.streetcomplete.view.dialogs.AlertDialogBuilder)

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