Add confirmation before loading reviews for contacts

This commit is contained in:
xynngh 2020-05-07 23:33:31 +04:00
parent d65828f369
commit c130c7853f
2 changed files with 31 additions and 7 deletions

View File

@ -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();
}
}

View File

@ -70,6 +70,9 @@
<string name="back">Back</string>
<string name="no">No</string>
<string name="load_reviews_confirmation_title">Are you sure?</string>
<string name="load_reviews_confirmation_message">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?</string>
<string name="incoming_call_notifications">Incoming call notifications</string>
<string name="block_calls">Block unwanted calls</string>
<string name="auto_updates">Auto-update database</string>