From fdacd1b4210725500b8dd01f83a34b0fa07d1075 Mon Sep 17 00:00:00 2001 From: stamatiap Date: Fri, 30 Apr 2021 16:49:42 +0300 Subject: [PATCH 1/7] 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(); From 1f61926108e25a955cbf5619861d06821c9af9a6 Mon Sep 17 00:00:00 2001 From: stamatiap Date: Sat, 1 May 2021 10:39:27 +0300 Subject: [PATCH 2/7] add default case to switch statement - issue #1101 --- .../awais/instagrabber/fragments/StoryViewerFragment.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/src/main/java/awais/instagrabber/fragments/StoryViewerFragment.java b/app/src/main/java/awais/instagrabber/fragments/StoryViewerFragment.java index c6788dfa..9a02816f 100644 --- a/app/src/main/java/awais/instagrabber/fragments/StoryViewerFragment.java +++ b/app/src/main/java/awais/instagrabber/fragments/StoryViewerFragment.java @@ -458,6 +458,10 @@ public class StoryViewerFragment extends Fragment { //No button clicked dialog.dismiss(); break; + + default: + dialog.dismiss(); + break; } } }; From 13b747fc872ca9d706d24532ea698d33e2d82893 Mon Sep 17 00:00:00 2001 From: stamatiap Date: Mon, 10 May 2021 21:47:29 +0300 Subject: [PATCH 3/7] add string for swipe up link confirmation --- app/src/main/res/values/strings.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 8cc84a91..4253f02b 100755 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -503,4 +503,5 @@ Recent Clear No Map app found! + Are you sure you want to open this link? From 38b7f29d449d13234bd66e3c9906b0b34b06c5b7 Mon Sep 17 00:00:00 2001 From: stamatiap Date: Mon, 10 May 2021 21:48:25 +0300 Subject: [PATCH 4/7] update alert dialog title --- .../java/awais/instagrabber/fragments/StoryViewerFragment.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/awais/instagrabber/fragments/StoryViewerFragment.java b/app/src/main/java/awais/instagrabber/fragments/StoryViewerFragment.java index 9a02816f..55497989 100644 --- a/app/src/main/java/awais/instagrabber/fragments/StoryViewerFragment.java +++ b/app/src/main/java/awais/instagrabber/fragments/StoryViewerFragment.java @@ -467,7 +467,7 @@ public class StoryViewerFragment extends Fragment { }; AlertDialog.Builder builder = new AlertDialog.Builder(context); - builder.setTitle("Are you sure you want to open this link?"); + builder.setTitle(R.string.swipe_up_confirmation); builder.setMessage(tag.toString()).setPositiveButton("Yes", dialogClickListener) .setNegativeButton("No", dialogClickListener).show(); } From 407f0680c1a662f56c8dd7879d5fc73fe0411df9 Mon Sep 17 00:00:00 2001 From: stamatiap Date: Sun, 16 May 2021 10:00:16 +0300 Subject: [PATCH 5/7] make changes in dialog --- .../fragments/StoryViewerFragment.java | 31 +++---------------- 1 file changed, 5 insertions(+), 26 deletions(-) diff --git a/app/src/main/java/awais/instagrabber/fragments/StoryViewerFragment.java b/app/src/main/java/awais/instagrabber/fragments/StoryViewerFragment.java index 55497989..e40f445d 100644 --- a/app/src/main/java/awais/instagrabber/fragments/StoryViewerFragment.java +++ b/app/src/main/java/awais/instagrabber/fragments/StoryViewerFragment.java @@ -445,32 +445,11 @@ public class StoryViewerFragment extends Fragment { binding.swipeUp.setOnClickListener(v -> { 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; - - default: - dialog.dismiss(); - break; - } - } - }; - - AlertDialog.Builder builder = new AlertDialog.Builder(context); - builder.setTitle(R.string.swipe_up_confirmation); - builder.setMessage(tag.toString()).setPositiveButton("Yes", dialogClickListener) - .setNegativeButton("No", dialogClickListener).show(); - } + new AlertDialog.Builder(context) + .setTitle(R.string.swipe_up_confirmation) + .setMessage(tag.toString()).setPositiveButton(R.string.yes, (d, w) -> Utils.openURL(context, tag.toString())) + .setNegativeButton(R.string.no, (d, w) -> d.dismiss()).show(); + } }); binding.viewStoryPost.setOnClickListener(v -> { final Object tag = v.getTag(); From 78caa4286afda97a675e274d4db18111d607fe75 Mon Sep 17 00:00:00 2001 From: Austin Huang Date: Tue, 18 May 2021 17:14:28 -0400 Subject: [PATCH 6/7] fix indentations --- .../instagrabber/fragments/StoryViewerFragment.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/awais/instagrabber/fragments/StoryViewerFragment.java b/app/src/main/java/awais/instagrabber/fragments/StoryViewerFragment.java index 766c9837..0f0e9b9f 100644 --- a/app/src/main/java/awais/instagrabber/fragments/StoryViewerFragment.java +++ b/app/src/main/java/awais/instagrabber/fragments/StoryViewerFragment.java @@ -447,12 +447,12 @@ public class StoryViewerFragment extends Fragment { } }); binding.swipeUp.setOnClickListener(v -> { - final Object tag = v.getTag(); - if (tag instanceof CharSequence) { + final Object tag = v.getTag(); + if (tag instanceof CharSequence) { new AlertDialog.Builder(context) - .setTitle(R.string.swipe_up_confirmation) - .setMessage(tag.toString()).setPositiveButton(R.string.yes, (d, w) -> Utils.openURL(context, tag.toString())) - .setNegativeButton(R.string.no, (d, w) -> d.dismiss()).show(); + .setTitle(R.string.swipe_up_confirmation) + .setMessage(tag.toString()).setPositiveButton(R.string.yes, (d, w) -> Utils.openURL(context, tag.toString())) + .setNegativeButton(R.string.no, (d, w) -> d.dismiss()).show(); } }); binding.viewStoryPost.setOnClickListener(v -> { From f85daef6ea60cda06033d7180b1b847fa4a20cb3 Mon Sep 17 00:00:00 2001 From: Austin Huang Date: Tue, 18 May 2021 17:15:09 -0400 Subject: [PATCH 7/7] remove redundant import --- .../java/awais/instagrabber/fragments/StoryViewerFragment.java | 1 - 1 file changed, 1 deletion(-) diff --git a/app/src/main/java/awais/instagrabber/fragments/StoryViewerFragment.java b/app/src/main/java/awais/instagrabber/fragments/StoryViewerFragment.java index 0f0e9b9f..c3801ee0 100644 --- a/app/src/main/java/awais/instagrabber/fragments/StoryViewerFragment.java +++ b/app/src/main/java/awais/instagrabber/fragments/StoryViewerFragment.java @@ -3,7 +3,6 @@ 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;