Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/image_picker/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.6.0+11

* Android: throw exception when permissions denied

## 0.6.0+10

* iOS: support picking GIF from gallery.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -386,21 +386,29 @@ public boolean onRequestPermissionsResult(
case REQUEST_EXTERNAL_IMAGE_STORAGE_PERMISSION:
if (permissionGranted) {
launchPickImageFromGalleryIntent();
} else {
finishWithError("photo_access_denied", "The user did not allow photo access.");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe combine these 4 statements in the if (!permissionGranted) clause?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactored per yr comment

}
break;
case REQUEST_EXTERNAL_VIDEO_STORAGE_PERMISSION:
if (permissionGranted) {
launchPickVideoFromGalleryIntent();
} else {
finishWithError("photo_access_denied", "The user did not allow photo access.");
}
break;
case REQUEST_CAMERA_IMAGE_PERMISSION:
if (permissionGranted) {
launchTakeImageWithCameraIntent();
} else {
finishWithError("camera_access_denied", "The user did not allow camera access.");
}
break;
case REQUEST_CAMERA_VIDEO_PERMISSION:
if (permissionGranted) {
launchTakeVideoWithCameraIntent();
} else {
finishWithError("camera_access_denied", "The user did not allow camera access.");
}
break;
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,15 +184,15 @@ public void takeImageWithCamera_WhenCameraPermissionNotPresent_RequestsForPermis

@Test
public void
onRequestPermissionsResult_WhenReadExternalStoragePermissionDenied_FinishesWithNull() {
onRequestPermissionsResult_WhenReadExternalStoragePermissionDenied_FinishesWithError() {
ImagePickerDelegate delegate = createDelegateWithPendingResultAndMethodCall();

delegate.onRequestPermissionsResult(
ImagePickerDelegate.REQUEST_EXTERNAL_IMAGE_STORAGE_PERMISSION,
new String[] {Manifest.permission.READ_EXTERNAL_STORAGE},
new int[] {PackageManager.PERMISSION_DENIED});

verify(mockResult).success(null);
verify(mockResult).error("photo_access_denied", "The user did not allow photo access.", null);
verifyNoMoreInteractions(mockResult);
}

Expand Down Expand Up @@ -227,15 +227,15 @@ public void takeImageWithCamera_WhenCameraPermissionNotPresent_RequestsForPermis
}

@Test
public void onRequestPermissionsResult_WhenCameraPermissionDenied_FinishesWithNull() {
public void onRequestPermissionsResult_WhenCameraPermissionDenied_FinishesWithError() {
ImagePickerDelegate delegate = createDelegateWithPendingResultAndMethodCall();

delegate.onRequestPermissionsResult(
ImagePickerDelegate.REQUEST_CAMERA_IMAGE_PERMISSION,
new String[] {Manifest.permission.CAMERA},
new int[] {PackageManager.PERMISSION_DENIED});

verify(mockResult).success(null);
verify(mockResult).error("camera_access_denied", "The user did not allow camera access.", null);
verifyNoMoreInteractions(mockResult);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/image_picker/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ authors:
- Flutter Team <[email protected]>
- Rhodes Davis Jr. <[email protected]>
homepage: https://github.com/flutter/plugins/tree/master/packages/image_picker
version: 0.6.0+10
version: 0.6.0+11

flutter:
plugin:
Expand Down