Skip to content

Commit 6d0f74b

Browse files
committed
Fix crash where I would not return from function if user cancelled camera/gallery intent.
1 parent 2aa1368 commit 6d0f74b

File tree

5 files changed

+5
-1
lines changed

5 files changed

+5
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ It's finally easy to take photos/videos via camera or get photos/videos from gal
1111
Shutter is an Android library to take photos, record videos, pick images/videos from gallery, with ease. I always have difficulty working with images/videos while developing Android apps *especially since file providers were added*.
1212

1313
### Why use Shutter?
14-
14+
ShutterPickVideoGalleryBuilder.kt:113)
1515
* Less bugs. No more publishing apps and have your app crash on a user's devices because of file permission issues you did not handle or boilerplate code you forgot to include (believe me, I have done this many times).
1616
* No more copy/paste of boilerplate code. Install lib, call Shutter, and be done across all of your apps.
1717
* Lightweight. [Check out the methods count here](http://www.methodscount.com/?lib=com.github.levibostian%3AShutter-Android%3A0.1.0)

lib/src/main/java/com/levibostian/shutter_android/builder/ShutterPickPhotoGalleryBuilder.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ class ShutterPickPhotoGalleryBuilder(val companion: Shutter.ShutterCompanion): S
108108
if (requestCode == GET_PHOTO_REQUEST_CODE) {
109109
if (resultCode != Activity.RESULT_OK) {
110110
resultCallback?.onError("You cancelled finding a photo.", ShutterUserCancelledOperation("User cancelled finding a photo from gallery."))
111+
return true
111112
}
112113

113114
val contentUriPhoto = intent!!.data

lib/src/main/java/com/levibostian/shutter_android/builder/ShutterPickVideoGalleryBuilder.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ class ShutterPickVideoGalleryBuilder(val companion: Shutter.ShutterCompanion): S
108108
if (requestCode == GET_VIDEO_REQUEST_CODE) {
109109
if (resultCode != Activity.RESULT_OK) {
110110
resultCallback?.onError("You cancelled finding a video.", ShutterUserCancelledOperation("User cancelled finding a video from gallery."))
111+
return true
111112
}
112113

113114
val contentUriVideo = intent!!.data

lib/src/main/java/com/levibostian/shutter_android/builder/ShutterRecordVideoBuilder.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ class ShutterRecordVideoBuilder(val companion: Shutter.ShutterCompanion): Shutte
143143
if (requestCode == RECORD_VIDEO_REQUEST_CODE) {
144144
if (resultCode != Activity.RESULT_OK) {
145145
resultCallback?.onError("You cancelled recording a video.", ShutterUserCancelledOperation("User cancelled recording a video."))
146+
return true
146147
}
147148

148149
if (addVidToGallery) addVideoToPublicGallery()

lib/src/main/java/com/levibostian/shutter_android/builder/ShutterTakePhotoBuilder.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ class ShutterTakePhotoBuilder(val companion: Shutter.ShutterCompanion): ShutterR
143143
if (requestCode == TAKE_PHOTO_REQUEST_CODE) {
144144
if (resultCode != Activity.RESULT_OK) {
145145
resultCallback?.onError("You cancelled taking a photo.", ShutterUserCancelledOperation("User cancelled taking a photo."))
146+
return true
146147
}
147148

148149
if (addPicToGallery) addPhotoToPublicGallery()

0 commit comments

Comments
 (0)