motorinc-gallery-picker-pro 1.0.7 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -58,6 +58,7 @@ public class ImagePickerModule extends ReactContextBaseJavaModule {
|
|
|
58
58
|
private static final String TAG = "ImagePickerModule";
|
|
59
59
|
private static final int CAMERA_REQUEST_CODE = 1001;
|
|
60
60
|
private static final int GALLERY_REQUEST_CODE = 1002;
|
|
61
|
+
private static final int PHOTO_PICKER_REQUEST_CODE = 1003;
|
|
61
62
|
private static final int CAMERA_PERMISSION_REQUEST_CODE = 2001;
|
|
62
63
|
private static final int STORAGE_PERMISSION_REQUEST_CODE = 2002;
|
|
63
64
|
|
|
@@ -163,15 +164,36 @@ public class ImagePickerModule extends ReactContextBaseJavaModule {
|
|
|
163
164
|
|
|
164
165
|
@ReactMethod
|
|
165
166
|
public void managePhotoSelection(Promise promise) {
|
|
166
|
-
|
|
167
|
-
if (
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
167
|
+
Activity activity = getCurrentActivity();
|
|
168
|
+
if (activity == null) {
|
|
169
|
+
promise.reject("ACTIVITY_ERROR", "Activity is null");
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// Android 13+ (API 33+) supports the Photo Picker
|
|
174
|
+
if (Build.VERSION.SDK_INT >= 33) {
|
|
175
|
+
try {
|
|
176
|
+
Log.d(TAG, "Launching Android Photo Picker for photo selection management");
|
|
177
|
+
|
|
178
|
+
// Create intent to launch the system Photo Picker
|
|
179
|
+
Intent intent = new Intent(MediaStore.ACTION_PICK_IMAGES);
|
|
180
|
+
|
|
181
|
+
// Set multi-select mode with maximum limit
|
|
182
|
+
intent.putExtra(MediaStore.EXTRA_PICK_IMAGES_MAX, MediaStore.getPickImagesMaxLimit());
|
|
183
|
+
|
|
184
|
+
// Store the promise to resolve after selection
|
|
185
|
+
currentPromise = promise;
|
|
186
|
+
|
|
187
|
+
// Launch the photo picker
|
|
188
|
+
activity.startActivityForResult(intent, PHOTO_PICKER_REQUEST_CODE);
|
|
189
|
+
|
|
190
|
+
} catch (Exception e) {
|
|
191
|
+
Log.e(TAG, "Error launching Photo Picker: " + e.getMessage());
|
|
192
|
+
promise.reject("PHOTO_PICKER_ERROR", "Failed to launch photo picker: " + e.getMessage());
|
|
193
|
+
}
|
|
172
194
|
} else {
|
|
173
|
-
|
|
174
|
-
|
|
195
|
+
// Android 12 and below - open app settings for permission management
|
|
196
|
+
Log.d(TAG, "Not Android 13+, opening app settings");
|
|
175
197
|
try {
|
|
176
198
|
Intent intent = new Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
|
|
177
199
|
intent.setData(android.net.Uri.parse("package:" + getReactApplicationContext().getPackageName()));
|
|
@@ -1098,6 +1120,9 @@ public class ImagePickerModule extends ReactContextBaseJavaModule {
|
|
|
1098
1120
|
case GALLERY_REQUEST_CODE:
|
|
1099
1121
|
handleGalleryResult(data);
|
|
1100
1122
|
break;
|
|
1123
|
+
case PHOTO_PICKER_REQUEST_CODE:
|
|
1124
|
+
handlePhotoPickerResult(data);
|
|
1125
|
+
break;
|
|
1101
1126
|
}
|
|
1102
1127
|
} catch (Exception e) {
|
|
1103
1128
|
rejectPromise("PROCESSING_ERROR", e.getMessage());
|
|
@@ -1139,6 +1164,34 @@ public class ImagePickerModule extends ReactContextBaseJavaModule {
|
|
|
1139
1164
|
sendEvent("PhotoLibraryChanged");
|
|
1140
1165
|
}
|
|
1141
1166
|
|
|
1167
|
+
private void handlePhotoPickerResult(Intent data) {
|
|
1168
|
+
try {
|
|
1169
|
+
Log.d(TAG, "Processing Photo Picker result");
|
|
1170
|
+
|
|
1171
|
+
// The Photo Picker was used to allow users to select additional photos
|
|
1172
|
+
// We don't need to return the selected URIs, just notify that the selection changed
|
|
1173
|
+
// and resolve the promise successfully
|
|
1174
|
+
|
|
1175
|
+
// Send event to notify React Native that photo library changed
|
|
1176
|
+
sendEvent("PhotoLibraryChanged");
|
|
1177
|
+
|
|
1178
|
+
// Resolve the promise
|
|
1179
|
+
if (currentPromise != null) {
|
|
1180
|
+
currentPromise.resolve(true);
|
|
1181
|
+
currentPromise = null;
|
|
1182
|
+
}
|
|
1183
|
+
|
|
1184
|
+
Log.d(TAG, "Photo Picker result processed successfully");
|
|
1185
|
+
|
|
1186
|
+
} catch (Exception e) {
|
|
1187
|
+
Log.e(TAG, "Error processing Photo Picker result: " + e.getMessage());
|
|
1188
|
+
if (currentPromise != null) {
|
|
1189
|
+
currentPromise.reject("PROCESSING_ERROR", "Error processing photo picker result: " + e.getMessage());
|
|
1190
|
+
currentPromise = null;
|
|
1191
|
+
}
|
|
1192
|
+
}
|
|
1193
|
+
}
|
|
1194
|
+
|
|
1142
1195
|
private void copyUriToFile(Uri uri, File file) throws IOException {
|
|
1143
1196
|
try (InputStream inputStream = getReactApplicationContext().getContentResolver().openInputStream(uri);
|
|
1144
1197
|
FileOutputStream outputStream = new FileOutputStream(file)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "motorinc-gallery-picker-pro",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"description": "A comprehensive React Native media gallery picker with smooth animations, multi-select, single-select, crop functionality, and native iOS/Android support",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|