diff --git a/app/src/main/java/dummydomain/yetanothercallblocker/InfoDialogHelper.java b/app/src/main/java/dummydomain/yetanothercallblocker/InfoDialogHelper.java index fc1e53e..18fe06e 100644 --- a/app/src/main/java/dummydomain/yetanothercallblocker/InfoDialogHelper.java +++ b/app/src/main/java/dummydomain/yetanothercallblocker/InfoDialogHelper.java @@ -52,16 +52,37 @@ public class InfoDialogHelper { ReviewsSummaryHelper.populateSummary(view.findViewById(R.id.reviews_summary), numberInfo.communityDatabaseItem); - builder.setView(view); - - builder.setNeutralButton(R.string.online_reviews, (d, w) - -> ReviewsActivity.startForNumber(context, numberInfo.number)); - - builder.setNegativeButton(R.string.back, null); + builder.setView(view) + .setNeutralButton(R.string.online_reviews, null) + .setNegativeButton(R.string.back, null); if (onDismissListener != null) builder.setOnDismissListener(onDismissListener); - builder.show(); + AlertDialog dialog = builder.create(); + + // avoid dismissing the original dialog on button press + + Runnable action = () -> { + ReviewsActivity.startForNumber(context, numberInfo.number); + dialog.dismiss(); + }; + + dialog.setOnShowListener(x -> { + dialog.getButton(AlertDialog.BUTTON_NEUTRAL).setOnClickListener(v -> { + if (numberInfo.contactItem != null) { + new AlertDialog.Builder(context) + .setTitle(R.string.load_reviews_confirmation_title) + .setMessage(R.string.load_reviews_confirmation_message) + .setPositiveButton(android.R.string.yes, (d1, w) -> action.run()) + .setNegativeButton(android.R.string.no, null) + .show(); + } else { + action.run(); + } + }); + }); + + dialog.show(); } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index d32e53a..55d81f3 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -70,6 +70,9 @@ Back No + Are you sure? + Loading online reviews will leak the number to a 3rd party service. Are you sure you want to do it with a number present in your Contacts? + Incoming call notifications Block unwanted calls Auto-update database