From fe7d02148a9e31173a70671f9bb7aa3913cadd0c Mon Sep 17 00:00:00 2001 From: Siddarth Kumar Date: Sun, 19 Nov 2023 17:04:22 +0800 Subject: [PATCH] explicitly ask for permission during onboarding --- .../select_photo/method_menu/view.cljs | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/status_im2/contexts/onboarding/select_photo/method_menu/view.cljs b/src/status_im2/contexts/onboarding/select_photo/method_menu/view.cljs index 8f72c9eba4cf..71711e6f7794 100644 --- a/src/status_im2/contexts/onboarding/select_photo/method_menu/view.cljs +++ b/src/status_im2/contexts/onboarding/select_photo/method_menu/view.cljs @@ -2,6 +2,9 @@ (:require ["react-native-image-crop-picker" :default image-picker] [quo.core :as quo] + [react-native.permissions :as permissions] + [react-native.platform :as platform] + [taoensso.timbre :as log] [utils.i18n :as i18n] [utils.re-frame :as rf])) @@ -61,8 +64,26 @@ [[{:icon :i/camera :accessibility-label :take-photo-button :label (i18n/label :t/profile-pic-take) - :on-press #(take-pic update-profile-pic-callback)} + :on-press (fn [] + (permissions/request-permissions + {:permissions [(if platform/is-below-android-13? + :read-external-storage + :read-media-images) + :write-external-storage] + :on-allowed (fn [] (take-pic update-profile-pic-callback)) + :on-denied (fn [] + (log/info + "user has denied permissions to click picture"))}))} {:icon :i/image :accessibility-label :select-from-gallery-button :label (i18n/label :t/profile-pic-pick) - :on-press #(pick-pic update-profile-pic-callback)}]]]) + :on-press (fn [] + (permissions/request-permissions + {:permissions [(if platform/is-below-android-13? + :read-external-storage + :read-media-images) + :write-external-storage] + :on-allowed (fn [] (pick-pic update-profile-pic-callback)) + :on-denied (fn [] + (log/info "user has denied permissions to select picture")) + }))}]]])