diff --git a/packages/image_picker/image_picker_android/CHANGELOG.md b/packages/image_picker/image_picker_android/CHANGELOG.md
index 654a05fb25bb..b0a583f27846 100644
--- a/packages/image_picker/image_picker_android/CHANGELOG.md
+++ b/packages/image_picker/image_picker_android/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 0.8.6+14
+
+* Fixes Java warnings.
+
## 0.8.6+13
* Fixes `BuildContext` handling in example.
diff --git a/packages/image_picker/image_picker_android/android/build.gradle b/packages/image_picker/image_picker_android/android/build.gradle
index 08b4bb3b4d05..367aa853247e 100644
--- a/packages/image_picker/image_picker_android/android/build.gradle
+++ b/packages/image_picker/image_picker_android/android/build.gradle
@@ -36,7 +36,6 @@ android {
checkAllWarnings true
warningsAsErrors true
disable 'AndroidGradlePluginVersion', 'InvalidPackage', 'GradleDependency'
- baseline file("lint-baseline.xml")
}
dependencies {
implementation 'androidx.core:core:1.9.0'
diff --git a/packages/image_picker/image_picker_android/android/lint-baseline.xml b/packages/image_picker/image_picker_android/android/lint-baseline.xml
deleted file mode 100644
index 765a6ca914b7..000000000000
--- a/packages/image_picker/image_picker_android/android/lint-baseline.xml
+++ /dev/null
@@ -1,400 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/packages/image_picker/image_picker_android/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java b/packages/image_picker/image_picker_android/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java
index 6aa1181ce908..423088590531 100644
--- a/packages/image_picker/image_picker_android/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java
+++ b/packages/image_picker/image_picker_android/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java
@@ -95,7 +95,7 @@ private static class PendingCallState {
public final @Nullable VideoSelectionOptions videoOptions;
public final @NonNull Messages.Result> result;
- private PendingCallState(
+ PendingCallState(
@Nullable ImageSelectionOptions imageOptions,
@Nullable VideoSelectionOptions videoOptions,
@NonNull Messages.Result> result) {
@@ -107,10 +107,10 @@ private PendingCallState(
@VisibleForTesting final String fileProviderName;
- private final Activity activity;
- @VisibleForTesting final File externalFilesDirectory;
- private final ImageResizer imageResizer;
- private final ImagePickerCache cache;
+ private final @NonNull Activity activity;
+ @VisibleForTesting final @NonNull File externalFilesDirectory;
+ private final @NonNull ImageResizer imageResizer;
+ private final @NonNull ImagePickerCache cache;
private final PermissionManager permissionManager;
private final FileUriResolver fileUriResolver;
private final FileUtils fileUtils;
@@ -140,10 +140,10 @@ interface OnPathReadyListener {
private final Object pendingCallStateLock = new Object();
public ImagePickerDelegate(
- final Activity activity,
- final File externalFilesDirectory,
- final ImageResizer imageResizer,
- final ImagePickerCache cache) {
+ final @NonNull Activity activity,
+ final @NonNull File externalFilesDirectory,
+ final @NonNull ImageResizer imageResizer,
+ final @NonNull ImagePickerCache cache) {
this(
activity,
externalFilesDirectory,
@@ -181,12 +181,7 @@ public void getFullImagePath(final Uri imageUri, final OnPathReadyListener liste
activity,
new String[] {(imageUri != null) ? imageUri.getPath() : ""},
null,
- new MediaScannerConnection.OnScanCompletedListener() {
- @Override
- public void onScanCompleted(String path, Uri uri) {
- listener.onPathReady(path);
- }
- });
+ (path, uri) -> listener.onPathReady(path));
}
},
new FileUtils(),
@@ -199,13 +194,13 @@ public void onScanCompleted(String path, Uri uri) {
*/
@VisibleForTesting
ImagePickerDelegate(
- final Activity activity,
- final File externalFilesDirectory,
- final ImageResizer imageResizer,
+ final @NonNull Activity activity,
+ final @NonNull File externalFilesDirectory,
+ final @NonNull ImageResizer imageResizer,
final @Nullable ImageSelectionOptions pendingImageOptions,
final @Nullable VideoSelectionOptions pendingVideoOptions,
final @Nullable Messages.Result> result,
- final ImagePickerCache cache,
+ final @NonNull ImagePickerCache cache,
final PermissionManager permissionManager,
final FileUriResolver fileUriResolver,
final FileUtils fileUtils,
@@ -290,7 +285,9 @@ Messages.CacheRetrievalResult retrieveLostImage() {
}
public void chooseVideoFromGallery(
- VideoSelectionOptions options, boolean usePhotoPicker, Messages.Result> result) {
+ @NonNull VideoSelectionOptions options,
+ boolean usePhotoPicker,
+ @NonNull Messages.Result> result) {
if (!setPendingOptionsAndResult(null, options, result)) {
finishWithAlreadyActiveError(result);
return;
@@ -318,7 +315,7 @@ private void launchPickVideoFromGalleryIntent(Boolean useAndroidPhotoPicker) {
}
public void takeVideoWithCamera(
- VideoSelectionOptions options, Messages.Result> result) {
+ @NonNull VideoSelectionOptions options, @NonNull Messages.Result> result) {
if (!setPendingOptionsAndResult(null, options, result)) {
finishWithAlreadyActiveError(result);
return;
@@ -376,7 +373,7 @@ private void launchTakeVideoWithCameraIntent() {
public void chooseImageFromGallery(
@NonNull ImageSelectionOptions options,
boolean usePhotoPicker,
- Messages.Result> result) {
+ @NonNull Messages.Result> result) {
if (!setPendingOptionsAndResult(options, null, result)) {
finishWithAlreadyActiveError(result);
return;
@@ -388,7 +385,7 @@ public void chooseImageFromGallery(
public void chooseMultiImageFromGallery(
@NonNull ImageSelectionOptions options,
boolean usePhotoPicker,
- Messages.Result> result) {
+ @NonNull Messages.Result> result) {
if (!setPendingOptionsAndResult(options, null, result)) {
finishWithAlreadyActiveError(result);
return;
@@ -436,7 +433,7 @@ private void launchMultiPickImageFromGalleryIntent(Boolean useAndroidPhotoPicker
}
public void takeImageWithCamera(
- @NonNull ImageSelectionOptions options, Messages.Result> result) {
+ @NonNull ImageSelectionOptions options, @NonNull Messages.Result> result) {
if (!setPendingOptionsAndResult(options, null, result)) {
finishWithAlreadyActiveError(result);
return;
@@ -556,7 +553,8 @@ public boolean onRequestPermissionsResult(
}
@Override
- public boolean onActivityResult(final int requestCode, final int resultCode, final Intent data) {
+ public boolean onActivityResult(
+ final int requestCode, final int resultCode, final @Nullable Intent data) {
Runnable handlerRunnable;
switch (requestCode) {
@@ -605,7 +603,7 @@ private void handleChooseMultiImageResult(int resultCode, Intent intent) {
} else {
paths.add(fileUtils.getPathFromUri(activity, intent.getData()));
}
- handleMultiImageResult(paths, false);
+ handleMultiImageResult(paths);
return;
}
@@ -632,12 +630,7 @@ private void handleCaptureImageResult(int resultCode) {
localPendingCameraMediaUri != null
? localPendingCameraMediaUri
: Uri.parse(cache.retrievePendingCameraMediaUriPath()),
- new OnPathReadyListener() {
- @Override
- public void onPathReady(String path) {
- handleImageResult(path, true);
- }
- });
+ path -> handleImageResult(path, true));
return;
}
@@ -652,12 +645,7 @@ private void handleCaptureVideoResult(int resultCode) {
localPendingCameraMediaUrl != null
? localPendingCameraMediaUrl
: Uri.parse(cache.retrievePendingCameraMediaUriPath()),
- new OnPathReadyListener() {
- @Override
- public void onPathReady(String path) {
- handleVideoResult(path);
- }
- });
+ this::handleVideoResult);
return;
}
@@ -665,8 +653,7 @@ public void onPathReady(String path) {
finishWithSuccess(null);
}
- private void handleMultiImageResult(
- ArrayList paths, boolean shouldDeleteOriginalIfScaled) {
+ private void handleMultiImageResult(ArrayList paths) {
ImageSelectionOptions localImageOptions = null;
synchronized (pendingCallStateLock) {
if (pendingCallState != null) {
@@ -678,13 +665,6 @@ private void handleMultiImageResult(
ArrayList finalPath = new ArrayList<>();
for (int i = 0; i < paths.size(); i++) {
String finalImagePath = getResizedImagePath(paths.get(i), localImageOptions);
-
- //delete original file if scaled
- if (finalImagePath != null
- && !finalImagePath.equals(paths.get(i))
- && shouldDeleteOriginalIfScaled) {
- new File(paths.get(i)).delete();
- }
finalPath.add(i, finalImagePath);
}
finishWithListSuccess(finalPath);
@@ -693,7 +673,7 @@ private void handleMultiImageResult(
}
}
- private void handleImageResult(String path, boolean shouldDeleteOriginalIfScaled) {
+ void handleImageResult(String path, boolean shouldDeleteOriginalIfScaled) {
ImageSelectionOptions localImageOptions = null;
synchronized (pendingCallStateLock) {
if (pendingCallState != null) {
@@ -721,7 +701,7 @@ private String getResizedImagePath(String path, @NonNull ImageSelectionOptions o
outputOptions.getQuality().intValue());
}
- private void handleVideoResult(String path) {
+ void handleVideoResult(String path) {
finishWithSuccess(path);
}
diff --git a/packages/image_picker/image_picker_android/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerPlugin.java b/packages/image_picker/image_picker_android/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerPlugin.java
index cbf52bd07782..330759208381 100644
--- a/packages/image_picker/image_picker_android/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerPlugin.java
+++ b/packages/image_picker/image_picker_android/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerPlugin.java
@@ -176,20 +176,18 @@ ImagePickerDelegate getDelegate() {
}
private FlutterPluginBinding pluginBinding;
- private ActivityState activityState;
+ ActivityState activityState;
@SuppressWarnings("deprecation")
- public static void registerWith(io.flutter.plugin.common.PluginRegistry.Registrar registrar) {
+ public static void registerWith(
+ @NonNull io.flutter.plugin.common.PluginRegistry.Registrar registrar) {
if (registrar.activity() == null) {
// If a background flutter view tries to register the plugin, there will be no activity from the registrar,
// we stop the registering process immediately because the ImagePicker requires an activity.
return;
}
Activity activity = registrar.activity();
- Application application = null;
- if (registrar.context() != null) {
- application = (Application) (registrar.context().getApplicationContext());
- }
+ Application application = (Application) (registrar.context().getApplicationContext());
ImagePickerPlugin plugin = new ImagePickerPlugin();
plugin.setup(registrar.messenger(), application, activity, registrar, null);
}
@@ -305,7 +303,7 @@ public void pickImages(
@NonNull Messages.ImageSelectionOptions options,
@NonNull Boolean allowMultiple,
@NonNull Boolean usePhotoPicker,
- Result> result) {
+ @NonNull Result> result) {
ImagePickerDelegate delegate = getImagePickerDelegate();
if (delegate == null) {
result.error(
@@ -335,7 +333,7 @@ public void pickVideos(
@NonNull Messages.VideoSelectionOptions options,
@NonNull Boolean allowMultiple,
@NonNull Boolean usePhotoPicker,
- Result> result) {
+ @NonNull Result> result) {
ImagePickerDelegate delegate = getImagePickerDelegate();
if (delegate == null) {
result.error(
diff --git a/packages/image_picker/image_picker_android/android/src/main/java/io/flutter/plugins/imagepicker/Messages.java b/packages/image_picker/image_picker_android/android/src/main/java/io/flutter/plugins/imagepicker/Messages.java
index af98078c673c..accf64b7e734 100644
--- a/packages/image_picker/image_picker_android/android/src/main/java/io/flutter/plugins/imagepicker/Messages.java
+++ b/packages/image_picker/image_picker_android/android/src/main/java/io/flutter/plugins/imagepicker/Messages.java
@@ -1,7 +1,7 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// Autogenerated from Pigeon (v9.1.0), do not edit directly.
+// Autogenerated from Pigeon (v9.2.5), do not edit directly.
// See also: https://pub.dev/packages/pigeon
package io.flutter.plugins.imagepicker;
@@ -39,7 +39,7 @@ public FlutterError(@NonNull String code, @Nullable String message, @Nullable Ob
}
@NonNull
- private static ArrayList