Skip to content

Commit

Permalink
photo picker
Browse files Browse the repository at this point in the history
  • Loading branch information
tarrinneal committed Mar 4, 2023
1 parent b4ec176 commit 1f7d252
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 36 deletions.
2 changes: 1 addition & 1 deletion packages/image_picker/image_picker/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## 0.8.6+5

* Adds `useImagePickerAndroid` options.
* Adds `usePhotoPickerAndroid` options.

## 0.8.6+4

Expand Down
12 changes: 6 additions & 6 deletions packages/image_picker/image_picker/lib/image_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ class ImagePicker {
int? imageQuality,
CameraDevice preferredCameraDevice = CameraDevice.rear,
bool requestFullMetadata = true,
bool useImagePickerAndroid = false,
bool usePhotoPickerAndroid = false,
}) {
if (imageQuality != null && (imageQuality < 0 || imageQuality > 100)) {
throw ArgumentError.value(
Expand All @@ -237,7 +237,7 @@ class ImagePicker {
imageQuality: imageQuality,
preferredCameraDevice: preferredCameraDevice,
requestFullMetadata: requestFullMetadata,
useImagePickerAndroid: useImagePickerAndroid,
usePhotoPickerAndroid: usePhotoPickerAndroid,
),
);
}
Expand Down Expand Up @@ -278,7 +278,7 @@ class ImagePicker {
double? maxHeight,
int? imageQuality,
bool requestFullMetadata = true,
bool useImagePickerAndroid = false,
bool usePhotoPickerAndroid = false,
}) {
if (imageQuality != null && (imageQuality < 0 || imageQuality > 100)) {
throw ArgumentError.value(
Expand All @@ -299,7 +299,7 @@ class ImagePicker {
imageQuality: imageQuality,
requestFullMetadata: requestFullMetadata,
),
useImagePickerAndroid: useImagePickerAndroid,
usePhotoPickerAndroid: usePhotoPickerAndroid,
),
);
}
Expand Down Expand Up @@ -330,13 +330,13 @@ class ImagePicker {
required ImageSource source,
CameraDevice preferredCameraDevice = CameraDevice.rear,
Duration? maxDuration,
bool useImagePickerAndroid = false,
bool usePhotoPickerAndroid = false,
}) {
return platform.getVideo(
source: source,
preferredCameraDevice: preferredCameraDevice,
maxDuration: maxDuration,
useImagePickerAndroid: useImagePickerAndroid,
usePhotoPickerAndroid: usePhotoPickerAndroid,
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,12 +252,12 @@ public void chooseVideoFromGallery(MethodCall methodCall, MethodChannel.Result r
return;
}

launchPickVideoFromGalleryIntent(methodCall.useImagePicker);
launchPickVideoFromGalleryIntent(methodCall.usePhotoPicker);
}

private void launchPickVideoFromGalleryIntent(Boolean useImagePicker) {
private void launchPickVideoFromGalleryIntent(Boolean usePhotoPicker) {
Intent pickVideoIntent;
if (useImagePicker && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
if (usePhotoPicker && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
pickVideoIntent =
new ActivityResultContracts.PickVisualMedia()
.createIntent(
Expand Down Expand Up @@ -326,7 +326,7 @@ public void chooseImageFromGallery(MethodCall methodCall, MethodChannel.Result r
return;
}

launchPickImageFromGalleryIntent(methodCall.useImagePicker);
launchPickImageFromGalleryIntent(methodCall.usePhotoPicker);
}

public void chooseMultiImageFromGallery(MethodCall methodCall, MethodChannel.Result result) {
Expand All @@ -335,12 +335,12 @@ public void chooseMultiImageFromGallery(MethodCall methodCall, MethodChannel.Res
return;
}

launchMultiPickImageFromGalleryIntent(methodCall.useImagePicker);
launchMultiPickImageFromGalleryIntent(methodCall.usePhotoPicker);
}

private void launchPickImageFromGalleryIntent(Boolean useImagePicker) {
private void launchPickImageFromGalleryIntent(Boolean usePhotoPicker) {
Intent pickImageIntent;
if (useImagePicker && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
if (usePhotoPicker && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
pickImageIntent =
new ActivityResultContracts.PickVisualMedia()
.createIntent(
Expand All @@ -356,9 +356,9 @@ private void launchPickImageFromGalleryIntent(Boolean useImagePicker) {
activity.startActivityForResult(pickImageIntent, REQUEST_CODE_CHOOSE_IMAGE_FROM_GALLERY);
}

private void launchMultiPickImageFromGalleryIntent(Boolean useImagePicker) {
private void launchMultiPickImageFromGalleryIntent(Boolean usePhotoPicker) {
Intent pickMultiImageIntent;
if (useImagePicker && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
if (usePhotoPicker && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
pickMultiImageIntent =
new ActivityResultContracts.PickMultipleVisualMedia()
.createIntent(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class ImagePickerAndroid extends ImagePickerPlatform {
double? maxWidth,
double? maxHeight,
int? imageQuality,
bool useImagePicker = false,
bool usePhotoPicker = false,
}) {
if (imageQuality != null && (imageQuality < 0 || imageQuality > 100)) {
throw ArgumentError.value(
Expand All @@ -84,7 +84,7 @@ class ImagePickerAndroid extends ImagePickerPlatform {
'maxWidth': maxWidth,
'maxHeight': maxHeight,
'imageQuality': imageQuality,
'useImagePicker': useImagePicker,
'usePhotoPicker': usePhotoPicker,
},
);
}
Expand All @@ -96,7 +96,7 @@ class ImagePickerAndroid extends ImagePickerPlatform {
int? imageQuality,
CameraDevice preferredCameraDevice = CameraDevice.rear,
bool requestFullMetadata = true,
bool useImagePicker = false,
bool usePhotoPicker = false,
}) {
if (imageQuality != null && (imageQuality < 0 || imageQuality > 100)) {
throw ArgumentError.value(
Expand All @@ -120,7 +120,7 @@ class ImagePickerAndroid extends ImagePickerPlatform {
'imageQuality': imageQuality,
'cameraDevice': preferredCameraDevice.index,
'requestFullMetadata': requestFullMetadata,
'useImagePicker': useImagePicker,
'usePhotoPicker': usePhotoPicker,
},
);
}
Expand All @@ -143,15 +143,15 @@ class ImagePickerAndroid extends ImagePickerPlatform {
required ImageSource source,
CameraDevice preferredCameraDevice = CameraDevice.rear,
Duration? maxDuration,
bool useImagePicker = false,
bool usePhotoPicker = false,
}) {
return _channel.invokeMethod<String>(
'pickVideo',
<String, dynamic>{
'source': source.index,
'maxDuration': maxDuration?.inSeconds,
'cameraDevice': preferredCameraDevice.index,
'useImagePicker': useImagePicker,
'usePhotoPicker': usePhotoPicker,
},
);
}
Expand All @@ -163,15 +163,15 @@ class ImagePickerAndroid extends ImagePickerPlatform {
double? maxHeight,
int? imageQuality,
CameraDevice preferredCameraDevice = CameraDevice.rear,
bool useImagePickerAndroid = false,
bool usePhotoPickerAndroid = false,
}) async {
final String? path = await _getImagePath(
source: source,
maxWidth: maxWidth,
maxHeight: maxHeight,
imageQuality: imageQuality,
preferredCameraDevice: preferredCameraDevice,
useImagePicker: useImagePickerAndroid,
usePhotoPicker: usePhotoPickerAndroid,
);
return path != null ? XFile(path) : null;
}
Expand All @@ -197,13 +197,13 @@ class ImagePickerAndroid extends ImagePickerPlatform {
double? maxWidth,
double? maxHeight,
int? imageQuality,
bool useImagePickerAndroid = false,
bool usePhotoPickerAndroid = false,
}) async {
final List<dynamic>? paths = await _getMultiImagePath(
maxWidth: maxWidth,
maxHeight: maxHeight,
imageQuality: imageQuality,
useImagePicker: useImagePickerAndroid,
usePhotoPicker: usePhotoPickerAndroid,
);
if (paths == null) {
return null;
Expand All @@ -217,13 +217,13 @@ class ImagePickerAndroid extends ImagePickerPlatform {
required ImageSource source,
CameraDevice preferredCameraDevice = CameraDevice.rear,
Duration? maxDuration,
bool useImagePickerAndroid = false,
bool usePhotoPickerAndroid = false,
}) async {
final String? path = await _getVideoPath(
source: source,
maxDuration: maxDuration,
preferredCameraDevice: preferredCameraDevice,
useImagePicker: useImagePickerAndroid,
usePhotoPicker: usePhotoPickerAndroid,
);
return path != null ? XFile(path) : null;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## 2.6.4

* Adds `useImagePickerAndroid` options.
* Adds `usePhotoPickerAndroid` options.

## 2.6.3

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ abstract class ImagePickerPlatform extends PlatformInterface {
double? maxHeight,
int? imageQuality,
CameraDevice preferredCameraDevice = CameraDevice.rear,
bool useImagePickerAndroid = false,
bool usePhotoPickerAndroid = false,
}) {
throw UnimplementedError('pickImage() has not been implemented.');
}
Expand All @@ -102,7 +102,7 @@ abstract class ImagePickerPlatform extends PlatformInterface {
double? maxWidth,
double? maxHeight,
int? imageQuality,
bool useImagePickerAndroid = false,
bool usePhotoPickerAndroid = false,
}) {
throw UnimplementedError('pickMultiImage() has not been implemented.');
}
Expand All @@ -127,7 +127,7 @@ abstract class ImagePickerPlatform extends PlatformInterface {
required ImageSource source,
CameraDevice preferredCameraDevice = CameraDevice.rear,
Duration? maxDuration,
bool useImagePickerAndroid = false,
bool usePhotoPickerAndroid = false,
}) {
throw UnimplementedError('pickVideo() has not been implemented.');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class ImagePickerOptions {
this.imageQuality,
this.preferredCameraDevice = CameraDevice.rear,
this.requestFullMetadata = true,
this.useImagePickerAndroid = false,
this.usePhotoPickerAndroid = false,
});

/// The maximum width of the image, in pixels.
Expand Down Expand Up @@ -54,5 +54,5 @@ class ImagePickerOptions {
/// If true, uses the 2022 Image Picker on Android.
///
/// Defaults to false.
final bool useImagePickerAndroid;
final bool usePhotoPickerAndroid;
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class MultiImagePickerOptions {
/// Creates an instance with the given [imageOptions].
const MultiImagePickerOptions({
this.imageOptions = const ImageOptions(),
this.useImagePickerAndroid = true,
this.usePhotoPickerAndroid = true,
});

/// The image-specific options for picking.
Expand All @@ -20,5 +20,5 @@ class MultiImagePickerOptions {
/// If true, uses the 2022 Image Picker on Android.
///
/// Defaults to false.
final bool useImagePickerAndroid;
final bool usePhotoPickerAndroid;
}

0 comments on commit 1f7d252

Please sign in to comment.