Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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/image_picker_android/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.8.12

* Fixes app crashes on Android 12+ caused by selecting images with size 0.

## 0.8.11

* Updates documentation to note that Android Photo Picker use is not optional on Android 13+.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ private void launchTakeVideoWithCameraIntent() {
} catch (ActivityNotFoundException e) {
try {
// If we can't delete the file again here, there's not really anything we can do about it.
//noinspection ResultOfMethodCallIgnored
// noinspection ResultOfMethodCallIgnored
videoFile.delete();
} catch (SecurityException exception) {
exception.printStackTrace();
Expand Down Expand Up @@ -515,7 +515,7 @@ private void launchTakeImageWithCameraIntent() {
} catch (ActivityNotFoundException e) {
try {
// If we can't delete the file again here, there's not really anything we can do about it.
//noinspection ResultOfMethodCallIgnored
// noinspection ResultOfMethodCallIgnored
imageFile.delete();
} catch (SecurityException exception) {
exception.printStackTrace();
Expand Down Expand Up @@ -692,7 +692,10 @@ private void handleChooseMediaResult(int resultCode, Intent intent) {
paths.add(new MediaPath(path, mimeType));
}
} else {
paths.add(new MediaPath(fileUtils.getPathFromUri(activity, intent.getData()), null));
Uri uri = intent.getData();
if (uri != null) {
paths.add(new MediaPath(fileUtils.getPathFromUri(activity, uri), null));
}
}
handleMediaResult(paths);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ public void chooseMediaFromGallery_whenPendingResultExists_finishesWithAlreadyAc
@Test
@Config(sdk = 30)
public void chooseImageFromGallery_launchesChooseFromGalleryIntent() {

ImagePickerDelegate delegate = createDelegate();
delegate.chooseImageFromGallery(DEFAULT_IMAGE_OPTIONS, false, mockResult);

Expand All @@ -194,7 +193,6 @@ public void chooseImageFromGallery_launchesChooseFromGalleryIntent() {
@Test
@Config(minSdk = 33)
public void chooseImageFromGallery_withPhotoPicker_launchesChooseFromGalleryIntent() {

ImagePickerDelegate delegate = createDelegate();
delegate.chooseImageFromGallery(DEFAULT_IMAGE_OPTIONS, true, mockResult);

Expand All @@ -206,7 +204,6 @@ public void chooseImageFromGallery_withPhotoPicker_launchesChooseFromGalleryInte
@Test
@Config(sdk = 30)
public void chooseMultiImageFromGallery_launchesChooseFromGalleryIntent() {

ImagePickerDelegate delegate = createDelegate();
delegate.chooseMultiImageFromGallery(
DEFAULT_IMAGE_OPTIONS, true, Integer.MAX_VALUE, mockResult);
Expand All @@ -220,7 +217,6 @@ public void chooseMultiImageFromGallery_launchesChooseFromGalleryIntent() {
@Test
@Config(minSdk = 33)
public void chooseMultiImageFromGallery_withPhotoPicker_launchesChooseFromGalleryIntent() {

ImagePickerDelegate delegate = createDelegate();
delegate.chooseMultiImageFromGallery(
DEFAULT_IMAGE_OPTIONS, false, Integer.MAX_VALUE, mockResult);
Expand All @@ -234,7 +230,6 @@ public void chooseMultiImageFromGallery_withPhotoPicker_launchesChooseFromGaller
@Test
@Config(sdk = 30)
public void chooseVideoFromGallery_launchesChooseFromGalleryIntent() {

ImagePickerDelegate delegate = createDelegate();
delegate.chooseVideoFromGallery(DEFAULT_VIDEO_OPTIONS, true, mockResult);

Expand All @@ -246,7 +241,6 @@ public void chooseVideoFromGallery_launchesChooseFromGalleryIntent() {
@Test
@Config(minSdk = 33)
public void chooseVideoFromGallery_withPhotoPicker_launchesChooseFromGalleryIntent() {

ImagePickerDelegate delegate = createDelegate();
delegate.chooseVideoFromGallery(DEFAULT_VIDEO_OPTIONS, true, mockResult);

Expand Down Expand Up @@ -820,6 +814,33 @@ public void onActivityResult_withUnknownRequest_returnsFalse() {
assertFalse(isHandled);
}

@Test
public void
onActivityResult_whenImagePickedFromGallery_finishesWithEmptyListIfIntentDataIsNull() {
setupMockClipDataNullUri();
when(mockIntent.getData()).thenReturn(null);
when(mockIntent.getClipData()).thenReturn(null);

Mockito.doAnswer(
invocation -> {
((Runnable) invocation.getArgument(0)).run();
return null;
})
.when(mockExecutor)
.execute(any(Runnable.class));
ImagePickerDelegate delegate =
createDelegateWithPendingResultAndOptions(DEFAULT_IMAGE_OPTIONS, null);

delegate.onActivityResult(
ImagePickerDelegate.REQUEST_CODE_CHOOSE_MEDIA_FROM_GALLERY, Activity.RESULT_OK, mockIntent);

@SuppressWarnings("unchecked")
ArgumentCaptor<List<String>> pathListCapture = ArgumentCaptor.forClass(List.class);
verify(mockResult).success(pathListCapture.capture());
assertEquals(0, pathListCapture.getValue().size());
verifyNoMoreInteractions(mockResult);
}

private ImagePickerDelegate createDelegate() {
return new ImagePickerDelegate(
mockActivity,
Expand Down
2 changes: 1 addition & 1 deletion packages/image_picker/image_picker_android/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: image_picker_android
description: Android implementation of the image_picker plugin.
repository: https://github.com/flutter/packages/tree/main/packages/image_picker/image_picker_android
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+image_picker%22
version: 0.8.11
version: 0.8.12

environment:
sdk: ^3.3.0
Expand Down