From ce3dde8358e2bf59774feb65b2c852d877c8d282 Mon Sep 17 00:00:00 2001 From: Santiago Castro Date: Tue, 17 May 2016 10:40:47 -0300 Subject: [PATCH] Ask for camera permission --- .../rx_paparazzo/interactors/GrantPermissions.java | 11 ++++++++++- .../fuck_boilerplate/rx_paparazzo/workers/Camera.java | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/rx_paparazzo/src/main/java/com/fuck_boilerplate/rx_paparazzo/interactors/GrantPermissions.java b/rx_paparazzo/src/main/java/com/fuck_boilerplate/rx_paparazzo/interactors/GrantPermissions.java index dd88c9f..f16cfaa 100644 --- a/rx_paparazzo/src/main/java/com/fuck_boilerplate/rx_paparazzo/interactors/GrantPermissions.java +++ b/rx_paparazzo/src/main/java/com/fuck_boilerplate/rx_paparazzo/interactors/GrantPermissions.java @@ -34,11 +34,20 @@ public final class GrantPermissions extends UseCase { } @Override public Observable react() { + return requestPermissions(Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE); + } + + private Observable requestPermissions(String... permissionsString) { RxPermissions permissions = RxPermissions.getInstance(targetUi.activity()); - return permissions.request(Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE) + return permissions.request(permissionsString) .flatMap(granted -> { if (granted) return Observable.just(null); throw new UserCanceledException(); }); } + + public Observable reactAlsoWithCameraPermission() { + return requestPermissions(Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE, + Manifest.permission.CAMERA); + } } diff --git a/rx_paparazzo/src/main/java/com/fuck_boilerplate/rx_paparazzo/workers/Camera.java b/rx_paparazzo/src/main/java/com/fuck_boilerplate/rx_paparazzo/workers/Camera.java index a9c2f00..4903918 100644 --- a/rx_paparazzo/src/main/java/com/fuck_boilerplate/rx_paparazzo/workers/Camera.java +++ b/rx_paparazzo/src/main/java/com/fuck_boilerplate/rx_paparazzo/workers/Camera.java @@ -46,7 +46,7 @@ public final class Camera extends Worker { } public Observable> takePhoto() { - return grantPermissions.react() + return grantPermissions.reactAlsoWithCameraPermission() .flatMap(granted -> takePhoto.react()) .flatMap(uri -> cropImage.with(uri).react()) .flatMap(uri -> saveImage.with(uri).react())