Search in sources :

Example 11 with AlertDialogBuilder

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

the class CrashReportExceptionHandler method askUserToSendErrorReport.

private void askUserToSendErrorReport(final Activity activityCtx, final int titleResourceId, String error) {
    final String report = "Describe how to reproduce it here:\n\n\n\n" + getDeviceInformationString() + "\n" + error;
    new Handler(Looper.getMainLooper()).post(() -> {
        new AlertDialogBuilder(activityCtx).setTitle(titleResourceId).setMessage(R.string.crash_message).setPositiveButton(R.string.crash_compose_email, (dialog, which) -> sendEmail(activityCtx, report)).setNegativeButton(android.R.string.no, (dialog, which) -> Toast.makeText(activityCtx, "\uD83D\uDE22", Toast.LENGTH_SHORT).show()).setCancelable(false).show();
    });
}
Also used : PrintWriter(java.io.PrintWriter) Context(android.content.Context) Arrays(java.util.Arrays) AlertDialogBuilder(de.westnordost.streetcomplete.view.dialogs.AlertDialogBuilder) StringWriter(java.io.StringWriter) BuildConfig(de.westnordost.streetcomplete.BuildConfig) Uri(android.net.Uri) StreamUtils(de.westnordost.streetcomplete.util.StreamUtils) FileOutputStream(java.io.FileOutputStream) Intent(android.content.Intent) IOException(java.io.IOException) FileInputStream(java.io.FileInputStream) ApplicationConstants(de.westnordost.streetcomplete.ApplicationConstants) Inject(javax.inject.Inject) R(de.westnordost.streetcomplete.R) Handler(android.os.Handler) Looper(android.os.Looper) Toast(android.widget.Toast) Build(android.os.Build) Activity(android.app.Activity) AlertDialogBuilder(de.westnordost.streetcomplete.view.dialogs.AlertDialogBuilder) Handler(android.os.Handler)

Example 12 with AlertDialogBuilder

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

the class MainActivity method confirmUndo.

private void confirmUndo(final OsmQuest quest) {
    Element element = questController.getOsmElement(quest);
    View inner = LayoutInflater.from(this).inflate(R.layout.dialog_undo, null, false);
    ImageView icon = inner.findViewById(R.id.icon);
    icon.setImageResource(quest.getType().getIcon());
    TextView text = inner.findViewById(R.id.text);
    text.setText(QuestUtil.getHtmlTitle(getResources(), quest.getType(), element));
    new AlertDialogBuilder(this).setTitle(R.string.undo_confirm_title).setView(inner).setPositiveButton(R.string.undo_confirm_positive, (dialog, which) -> {
        questController.undoOsmQuest(quest);
        unsyncedChangesCounter.decrement(quest.getChangesSource());
    }).setNegativeButton(R.string.undo_confirm_negative, null).show();
}
Also used : AlertDialogBuilder(de.westnordost.streetcomplete.view.dialogs.AlertDialogBuilder) Element(de.westnordost.osmapi.map.data.Element) OsmElement(de.westnordost.osmapi.map.data.OsmElement) TextView(android.widget.TextView) ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView)

Example 13 with AlertDialogBuilder

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

the class MainActivity method downloadDisplayedArea.

@UiThread
private void downloadDisplayedArea() {
    BoundingBox displayArea;
    if ((displayArea = mapFragment.getDisplayedArea(new Rect())) == null) {
        Toast.makeText(this, R.string.cannot_find_bbox_or_reduce_tilt, Toast.LENGTH_LONG).show();
    } else {
        final BoundingBox enclosingBBox = SlippyMapMath.asBoundingBoxOfEnclosingTiles(displayArea, ApplicationConstants.QUEST_TILE_ZOOM);
        double areaInSqKm = SphericalEarthMath.enclosedArea(enclosingBBox) / 1000000;
        if (areaInSqKm > ApplicationConstants.MAX_DOWNLOADABLE_AREA_IN_SQKM) {
            Toast.makeText(this, R.string.download_area_too_big, Toast.LENGTH_LONG).show();
        } else {
            if (questController.isPriorityDownloadRunning()) {
                new AlertDialogBuilder(this).setMessage(R.string.confirmation_cancel_prev_download_title).setPositiveButton(android.R.string.ok, (dialog, which) -> downloadAreaConfirmed(enclosingBBox)).setNegativeButton(android.R.string.cancel, null).show();
            } else {
                downloadAreaConfirmed(enclosingBBox);
            }
        }
    }
}
Also used : Rect(android.graphics.Rect) AlertDialogBuilder(de.westnordost.streetcomplete.view.dialogs.AlertDialogBuilder) BoundingBox(de.westnordost.osmapi.map.data.BoundingBox) UiThread(android.support.annotation.UiThread)

Example 14 with AlertDialogBuilder

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

the class MainActivity method requestOAuthorized.

@UiThread
private void requestOAuthorized() {
    if (dontShowRequestAuthorizationAgain)
        return;
    View inner = LayoutInflater.from(this).inflate(R.layout.dialog_authorize_now, null, false);
    final CheckBox checkBox = inner.findViewById(R.id.checkBoxDontShowAgain);
    new AlertDialogBuilder(this).setView(inner).setPositiveButton(android.R.string.ok, (dialog, which) -> {
        Intent intent = new Intent(MainActivity.this, SettingsActivity.class);
        intent.putExtra(SettingsActivity.EXTRA_LAUNCH_AUTH, true);
        startActivity(intent);
    }).setNegativeButton(R.string.later, (dialog, which) -> {
        dontShowRequestAuthorizationAgain = checkBox.isChecked();
    }).show();
}
Also used : Rect(android.graphics.Rect) AnyThread(android.support.annotation.AnyThread) PointF(android.graphics.PointF) Bundle(android.os.Bundle) QuestDownloadProgressListener(de.westnordost.streetcomplete.data.download.QuestDownloadProgressListener) AbstractBottomSheetFragment(de.westnordost.streetcomplete.quests.AbstractBottomSheetFragment) OsmQuestAnswerListener(de.westnordost.streetcomplete.quests.OsmQuestAnswerListener) ProgressBar(android.widget.ProgressBar) LocationState(de.westnordost.streetcomplete.location.LocationState) WindowManager(android.view.WindowManager) ImageView(android.widget.ImageView) LocalBroadcastManager(android.support.v4.content.LocalBroadcastManager) LinkMovementMethod(android.text.method.LinkMovementMethod) IBinder(android.os.IBinder) BoundingBox(de.westnordost.osmapi.map.data.BoundingBox) AccelerateDecelerateInterpolator(android.view.animation.AccelerateDecelerateInterpolator) QuestController(de.westnordost.streetcomplete.data.QuestController) CheckBox(android.widget.CheckBox) AboutFragment(de.westnordost.streetcomplete.about.AboutFragment) OAuthPrefs(de.westnordost.streetcomplete.oauth.OAuthPrefs) ServiceConnection(android.content.ServiceConnection) View(android.view.View) QuestAutoSyncer(de.westnordost.streetcomplete.data.QuestAutoSyncer) QuestDownloadService(de.westnordost.streetcomplete.data.download.QuestDownloadService) UploadedAnswersCounter(de.westnordost.streetcomplete.statistics.UploadedAnswersCounter) ConnectivityManager(android.net.ConnectivityManager) AlertDialogBuilder(de.westnordost.streetcomplete.view.dialogs.AlertDialogBuilder) ObjectAnimator(android.animation.ObjectAnimator) Collection(java.util.Collection) QuestChangesUploadProgressListener(de.westnordost.streetcomplete.data.upload.QuestChangesUploadProgressListener) QuestAnswerComponent(de.westnordost.streetcomplete.quests.QuestAnswerComponent) Fragment(android.support.v4.app.Fragment) IntentFilter(android.content.IntentFilter) NetworkInfo(android.net.NetworkInfo) UiThread(android.support.annotation.UiThread) BroadcastReceiver(android.content.BroadcastReceiver) AppCompatActivity(android.support.v7.app.AppCompatActivity) SphericalEarthMath(de.westnordost.streetcomplete.util.SphericalEarthMath) PreferenceManager(android.support.v7.preference.PreferenceManager) FindQuestSourceComponent(de.westnordost.streetcomplete.quests.FindQuestSourceComponent) TextView(android.widget.TextView) CrashReportExceptionHandler(de.westnordost.streetcomplete.tools.CrashReportExceptionHandler) Location(android.location.Location) Nullable(android.support.annotation.Nullable) MapFragment(de.westnordost.streetcomplete.tangram.MapFragment) VisibleQuestListener(de.westnordost.streetcomplete.data.VisibleQuestListener) OsmConnectionException(de.westnordost.osmapi.common.errors.OsmConnectionException) Context(android.content.Context) SlippyMapMath(de.westnordost.streetcomplete.util.SlippyMapMath) AbstractQuestAnswerFragment(de.westnordost.streetcomplete.quests.AbstractQuestAnswerFragment) LatLon(de.westnordost.osmapi.map.data.LatLon) Intent(android.content.Intent) Linkify(android.text.util.Linkify) MenuItem(android.view.MenuItem) InputMethodManager(android.view.inputmethod.InputMethodManager) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) Element(de.westnordost.osmapi.map.data.Element) QuestsMapFragment(de.westnordost.streetcomplete.tangram.QuestsMapFragment) Quest(de.westnordost.streetcomplete.data.Quest) VersionBannedException(de.westnordost.streetcomplete.data.upload.VersionBannedException) Toast(android.widget.Toast) Menu(android.view.Menu) OsmQuest(de.westnordost.streetcomplete.data.osm.OsmQuest) OsmAuthorizationException(de.westnordost.osmapi.common.errors.OsmAuthorizationException) UnsyncedChangesCounter(de.westnordost.streetcomplete.statistics.UnsyncedChangesCounter) QuestChangesUploadService(de.westnordost.streetcomplete.data.upload.QuestChangesUploadService) OsmApiReadResponseException(de.westnordost.osmapi.common.errors.OsmApiReadResponseException) LocationUtil(de.westnordost.streetcomplete.location.LocationUtil) ComponentName(android.content.ComponentName) LayoutInflater(android.view.LayoutInflater) Point(android.graphics.Point) QuestUtil(de.westnordost.streetcomplete.quests.QuestUtil) OsmElement(de.westnordost.osmapi.map.data.OsmElement) CreateNoteListener(de.westnordost.streetcomplete.data.osmnotes.CreateNoteListener) FragmentManager(android.support.v4.app.FragmentManager) AlertDialog(android.support.v7.app.AlertDialog) SharedPreferences(android.content.SharedPreferences) QuestGroup(de.westnordost.streetcomplete.data.QuestGroup) Toolbar(android.support.v7.widget.Toolbar) MapControlsFragment(de.westnordost.streetcomplete.tangram.MapControlsFragment) CreateNoteFragment(de.westnordost.streetcomplete.data.osmnotes.CreateNoteFragment) SettingsActivity(de.westnordost.streetcomplete.settings.SettingsActivity) FragmentTransaction(android.support.v4.app.FragmentTransaction) Collections(java.util.Collections) LocationRequestFragment(de.westnordost.streetcomplete.location.LocationRequestFragment) AlertDialogBuilder(de.westnordost.streetcomplete.view.dialogs.AlertDialogBuilder) CheckBox(android.widget.CheckBox) Intent(android.content.Intent) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) UiThread(android.support.annotation.UiThread)

Example 15 with AlertDialogBuilder

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

the class AddMaxSpeedForm method confirmNoSignSlowZone.

private void confirmNoSignSlowZone(final Runnable callback) {
    View view = LayoutInflater.from(getActivity()).inflate(R.layout.quest_maxspeed_no_sign_no_slow_zone_confirmation, null, false);
    ImageView imgSlowZone = view.findViewById(R.id.imgSlowZone);
    ImageView mainLayoutImgSlowZone = getView() != null ? (ImageView) getView().findViewById(R.id.zoneImg) : null;
    if (mainLayoutImgSlowZone != null) {
        Drawable slowZoneDrawable = mainLayoutImgSlowZone.getDrawable();
        imgSlowZone.setImageDrawable(slowZoneDrawable);
    }
    new AlertDialogBuilder(getActivity()).setView(view).setTitle(R.string.quest_maxspeed_answer_noSign_confirmation_title).setPositiveButton(R.string.quest_maxspeed_answer_noSign_confirmation_positive, (dialog, which) -> callback.run()).setNegativeButton(R.string.quest_generic_confirmation_no, null).show();
}
Also used : AlertDialogBuilder(de.westnordost.streetcomplete.view.dialogs.AlertDialogBuilder) Drawable(android.graphics.drawable.Drawable) ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) View(android.view.View)

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