From d36ec9af4785ac477aaaeffa0898eff2051a03d5 Mon Sep 17 00:00:00 2001 From: Cody Henthorne Date: Fri, 30 Oct 2020 11:36:12 -0400 Subject: [PATCH] Fix permission bug with avatar gallery selection. --- .../AvatarSelectionBottomSheetDialogFragment.java | 8 ++++++++ app/src/main/res/values/strings.xml | 1 + 2 files changed, 9 insertions(+) diff --git a/app/src/main/java/org/thoughtcrime/securesms/mediasend/AvatarSelectionBottomSheetDialogFragment.java b/app/src/main/java/org/thoughtcrime/securesms/mediasend/AvatarSelectionBottomSheetDialogFragment.java index 8ff7a6cc86..45095010b9 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/mediasend/AvatarSelectionBottomSheetDialogFragment.java +++ b/app/src/main/java/org/thoughtcrime/securesms/mediasend/AvatarSelectionBottomSheetDialogFragment.java @@ -112,6 +112,14 @@ public class AvatarSelectionBottomSheetDialogFragment extends BottomSheetDialogF .onAnyDenied(() -> Toast.makeText(requireContext(), R.string.AvatarSelectionBottomSheetDialogFragment__taking_a_photo_requires_the_camera_permission, Toast.LENGTH_SHORT) .show()) .execute(); + } else if (option == SelectionOption.GALLERY) { + Permissions.with(this) + .request(Manifest.permission.READ_EXTERNAL_STORAGE) + .ifNecessary() + .onAllGranted(() -> launchOptionAndDismiss(option)) + .onAnyDenied(() -> Toast.makeText(requireContext(), R.string.AvatarSelectionBottomSheetDialogFragment__viewing_your_gallery_requires_the_storage_permission, Toast.LENGTH_SHORT) + .show()) + .execute(); } else { launchOptionAndDismiss(option); } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index c8bd6c368f..303c0492d7 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -427,6 +427,7 @@ Choose from gallery Remove photo Taking a photo requires the camera permission. + Viewing your gallery requires the storage permission. Now