From ec061bedc142a0f688cffe09144b4027a669ab84 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sat, 24 Apr 2021 08:20:27 +0200 Subject: [PATCH] always show contact permission explain dialog on Quicksy Until now Conversations and Quicksy would only disply the dialog that explains why we want contact read permissions after the user rejected the request once (following Android design guidelines and `shouldShowRequestPermissionRationale()`) However for PlayStore policy this is no longer enough and the app needs to explain and ask for consent before starting to upload the data. This commit now displays the explain dialog immediately before asking for the first time. --- .../ui/StartConversationActivity.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java index 1e9ea0062..139c55665 100644 --- a/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java @@ -39,6 +39,7 @@ import android.widget.Toast; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.annotation.StringRes; import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.AlertDialog; import androidx.databinding.DataBindingUtil; @@ -731,7 +732,7 @@ public class StartConversationActivity extends XmppActivity implements XmppConne if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { if (checkSelfPermission(Manifest.permission.READ_CONTACTS) != PackageManager.PERMISSION_GRANTED) { if (mRequestedContactsPermission.compareAndSet(false, true)) { - if (shouldShowRequestPermissionRationale(Manifest.permission.READ_CONTACTS)) { + if (QuickConversationsService.isQuicksy() || shouldShowRequestPermissionRationale(Manifest.permission.READ_CONTACTS)) { final AlertDialog.Builder builder = new AlertDialog.Builder(this); final AtomicBoolean requestPermission = new AtomicBoolean(false); builder.setTitle(R.string.sync_with_contacts); @@ -740,20 +741,26 @@ public class StartConversationActivity extends XmppActivity implements XmppConne } else { builder.setMessage(getString(R.string.sync_with_contacts_long, getString(R.string.app_name))); } - builder.setPositiveButton(R.string.next, (dialog, which) -> { + @StringRes int confirmButtonText; + if (QuickConversationsService.isConversations()) { + confirmButtonText = R.string.next; + } else { + confirmButtonText = R.string.confirm; + } + builder.setPositiveButton(confirmButtonText, (dialog, which) -> { if (requestPermission.compareAndSet(false, true)) { requestPermissions(new String[]{Manifest.permission.READ_CONTACTS}, REQUEST_SYNC_CONTACTS); } }); builder.setOnDismissListener(dialog -> { - if (requestPermission.compareAndSet(false, true)) { + if (QuickConversationsService.isConversations() && requestPermission.compareAndSet(false, true)) { requestPermissions(new String[]{Manifest.permission.READ_CONTACTS}, REQUEST_SYNC_CONTACTS); } }); - builder.setCancelable(false); + builder.setCancelable(QuickConversationsService.isQuicksy()); final AlertDialog dialog = builder.create(); - dialog.setCanceledOnTouchOutside(false); + dialog.setCanceledOnTouchOutside(QuickConversationsService.isQuicksy()); dialog.setOnShowListener(dialogInterface -> { final TextView tv = dialog.findViewById(android.R.id.message); if (tv != null) {