From fdacd1b4210725500b8dd01f83a34b0fa07d1075 Mon Sep 17 00:00:00 2001 From: stamatiap Date: Fri, 30 Apr 2021 16:49:42 +0300 Subject: [PATCH] add alert dialog for swipe up link - issue #1101 --- .../fragments/StoryViewerFragment.java | 29 ++++++++++++++++--- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/awais/instagrabber/fragments/StoryViewerFragment.java b/app/src/main/java/awais/instagrabber/fragments/StoryViewerFragment.java index a170a8a0..c6788dfa 100644 --- a/app/src/main/java/awais/instagrabber/fragments/StoryViewerFragment.java +++ b/app/src/main/java/awais/instagrabber/fragments/StoryViewerFragment.java @@ -3,6 +3,7 @@ package awais.instagrabber.fragments; import android.annotation.SuppressLint; import android.content.Context; import android.content.pm.PackageManager; +import android.content.DialogInterface; import android.graphics.drawable.Animatable; import android.net.Uri; import android.os.Bundle; @@ -442,10 +443,30 @@ public class StoryViewerFragment extends Fragment { } }); binding.swipeUp.setOnClickListener(v -> { - final Object tag = v.getTag(); - if (tag instanceof CharSequence) { - Utils.openURL(context, tag.toString()); - } + final Object tag = v.getTag(); + if (tag instanceof CharSequence) { + DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + switch (which){ + case DialogInterface.BUTTON_POSITIVE: + //Yes button clicked + Utils.openURL(context, tag.toString()); + break; + + case DialogInterface.BUTTON_NEGATIVE: + //No button clicked + dialog.dismiss(); + break; + } + } + }; + + AlertDialog.Builder builder = new AlertDialog.Builder(context); + builder.setTitle("Are you sure you want to open this link?"); + builder.setMessage(tag.toString()).setPositiveButton("Yes", dialogClickListener) + .setNegativeButton("No", dialogClickListener).show(); + } }); binding.viewStoryPost.setOnClickListener(v -> { final Object tag = v.getTag();