@connectedbits/react-native-image-picker 2.4.16-rc1 → 2.4.16-rc3
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.
- package/android/.gradle/5.4.1/executionHistory/executionHistory.lock +0 -0
- package/android/.gradle/5.4.1/fileChanges/last-build.bin +0 -0
- package/android/.gradle/5.4.1/fileHashes/fileHashes.bin +0 -0
- package/android/.gradle/5.4.1/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/5.4.1/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
- package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/.idea/.gitignore +3 -0
- package/android/.idea/compiler.xml +6 -0
- package/android/.idea/gradle.xml +18 -0
- package/android/.idea/jarRepositories.xml +40 -0
- package/android/.idea/ktfmt.xml +6 -0
- package/android/.idea/misc.xml +9 -0
- package/android/.idea/vcs.xml +6 -0
- package/android/src/main/java/com/imagepicker/ImagePickerModule.java +295 -270
- package/package.json +1 -1
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="GradleMigrationSettings" migrationVersion="1" />
|
|
4
|
+
<component name="GradleSettings">
|
|
5
|
+
<option name="linkedExternalProjectsSettings">
|
|
6
|
+
<GradleProjectSettings>
|
|
7
|
+
<option name="testRunner" value="GRADLE" />
|
|
8
|
+
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
|
9
|
+
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
|
10
|
+
<option name="modules">
|
|
11
|
+
<set>
|
|
12
|
+
<option value="$PROJECT_DIR$" />
|
|
13
|
+
</set>
|
|
14
|
+
</option>
|
|
15
|
+
</GradleProjectSettings>
|
|
16
|
+
</option>
|
|
17
|
+
</component>
|
|
18
|
+
</project>
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="RemoteRepositoriesConfiguration">
|
|
4
|
+
<remote-repository>
|
|
5
|
+
<option name="id" value="central" />
|
|
6
|
+
<option name="name" value="Maven Central repository" />
|
|
7
|
+
<option name="url" value="https://repo1.maven.org/maven2" />
|
|
8
|
+
</remote-repository>
|
|
9
|
+
<remote-repository>
|
|
10
|
+
<option name="id" value="jboss.community" />
|
|
11
|
+
<option name="name" value="JBoss Community repository" />
|
|
12
|
+
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
|
|
13
|
+
</remote-repository>
|
|
14
|
+
<remote-repository>
|
|
15
|
+
<option name="id" value="maven" />
|
|
16
|
+
<option name="name" value="maven" />
|
|
17
|
+
<option name="url" value="file:$PROJECT_DIR$/../node_modules/react-native/android/" />
|
|
18
|
+
</remote-repository>
|
|
19
|
+
<remote-repository>
|
|
20
|
+
<option name="id" value="maven2" />
|
|
21
|
+
<option name="name" value="maven2" />
|
|
22
|
+
<option name="url" value="file:$PROJECT_DIR$/../node_modules/jsc-android/dist/" />
|
|
23
|
+
</remote-repository>
|
|
24
|
+
<remote-repository>
|
|
25
|
+
<option name="id" value="MavenLocal" />
|
|
26
|
+
<option name="name" value="MavenLocal" />
|
|
27
|
+
<option name="url" value="file:$USER_HOME$/.m2/repository/" />
|
|
28
|
+
</remote-repository>
|
|
29
|
+
<remote-repository>
|
|
30
|
+
<option name="id" value="BintrayJCenter" />
|
|
31
|
+
<option name="name" value="BintrayJCenter" />
|
|
32
|
+
<option name="url" value="https://jcenter.bintray.com/" />
|
|
33
|
+
</remote-repository>
|
|
34
|
+
<remote-repository>
|
|
35
|
+
<option name="id" value="Google" />
|
|
36
|
+
<option name="name" value="Google" />
|
|
37
|
+
<option name="url" value="https://dl.google.com/dl/android/maven2/" />
|
|
38
|
+
</remote-repository>
|
|
39
|
+
</component>
|
|
40
|
+
</project>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<project version="4">
|
|
2
|
+
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
|
3
|
+
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="zulu-1.8" project-jdk-type="JavaSDK">
|
|
4
|
+
<output url="file://$PROJECT_DIR$/build/classes" />
|
|
5
|
+
</component>
|
|
6
|
+
<component name="ProjectType">
|
|
7
|
+
<option name="id" value="Android" />
|
|
8
|
+
</component>
|
|
9
|
+
</project>
|
|
@@ -11,6 +11,7 @@ import android.graphics.Bitmap;
|
|
|
11
11
|
import android.graphics.BitmapFactory;
|
|
12
12
|
import android.net.Uri;
|
|
13
13
|
import android.os.Build;
|
|
14
|
+
import android.os.Handler;
|
|
14
15
|
import android.provider.MediaStore;
|
|
15
16
|
import android.provider.Settings;
|
|
16
17
|
import androidx.annotation.NonNull;
|
|
@@ -151,62 +152,67 @@ public class ImagePickerModule extends ReactContextBaseJavaModule
|
|
|
151
152
|
|
|
152
153
|
@ReactMethod
|
|
153
154
|
public void showImagePicker(final ReadableMap options, final Callback callback) {
|
|
154
|
-
|
|
155
|
-
|
|
155
|
+
final ImagePickerModule self = this;
|
|
156
|
+
final Activity currentActivity = getCurrentActivity();
|
|
157
|
+
Handler handler = new Handler(this.reactContext.getMainLooper());
|
|
158
|
+
this.callback = callback;
|
|
159
|
+
this.options = options;
|
|
156
160
|
if (currentActivity == null)
|
|
157
161
|
{
|
|
158
162
|
responseHelper.invokeError(callback, "can't find current Activity");
|
|
159
163
|
return;
|
|
160
164
|
}
|
|
161
|
-
|
|
162
|
-
this.callback = callback;
|
|
163
|
-
this.options = options;
|
|
164
165
|
imageConfig = new ImageConfig(0, 0, 100, 0, false);
|
|
165
|
-
|
|
166
|
-
final AlertDialog dialog = UI.chooseDialog(this, options, new UI.OnAction()
|
|
167
|
-
{
|
|
166
|
+
handler.post(new Runnable() {
|
|
168
167
|
@Override
|
|
169
|
-
public void
|
|
170
|
-
{
|
|
171
|
-
if (module == null)
|
|
172
|
-
{
|
|
173
|
-
return;
|
|
174
|
-
}
|
|
175
|
-
module.launchCamera();
|
|
176
|
-
}
|
|
168
|
+
public void run() {
|
|
177
169
|
|
|
178
|
-
|
|
179
|
-
public void onUseLibrary(@NonNull final ImagePickerModule module)
|
|
180
|
-
{
|
|
181
|
-
if (module == null)
|
|
170
|
+
final AlertDialog dialog = UI.chooseDialog(self, options, new UI.OnAction()
|
|
182
171
|
{
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
172
|
+
@Override
|
|
173
|
+
public void onTakePhoto(@NonNull final ImagePickerModule module)
|
|
174
|
+
{
|
|
175
|
+
if (module == null)
|
|
176
|
+
{
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
module.launchCamera();
|
|
180
|
+
}
|
|
187
181
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
182
|
+
@Override
|
|
183
|
+
public void onUseLibrary(@NonNull final ImagePickerModule module)
|
|
184
|
+
{
|
|
185
|
+
if (module == null)
|
|
186
|
+
{
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
module.launchImageLibrary();
|
|
190
|
+
}
|
|
197
191
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
192
|
+
@Override
|
|
193
|
+
public void onCancel(@NonNull final ImagePickerModule module)
|
|
194
|
+
{
|
|
195
|
+
if (module == null)
|
|
196
|
+
{
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
module.doOnCancel();
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
@Override
|
|
203
|
+
public void onCustomButton(@NonNull final ImagePickerModule module,
|
|
204
|
+
@NonNull final String action)
|
|
205
|
+
{
|
|
206
|
+
if (module == null)
|
|
207
|
+
{
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
module.invokeCustomButton(action);
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
dialog.show();
|
|
207
214
|
}
|
|
208
215
|
});
|
|
209
|
-
dialog.show();
|
|
210
216
|
}
|
|
211
217
|
|
|
212
218
|
public void doOnCancel()
|
|
@@ -226,6 +232,8 @@ public class ImagePickerModule extends ReactContextBaseJavaModule
|
|
|
226
232
|
@ReactMethod
|
|
227
233
|
public void launchCamera(final ReadableMap options, final Callback callback)
|
|
228
234
|
{
|
|
235
|
+
final ImagePickerModule self = this;
|
|
236
|
+
Handler handler = new Handler(this.getContext().getMainLooper());
|
|
229
237
|
permissionRequestCallback = callback;
|
|
230
238
|
|
|
231
239
|
if (!isCameraAvailable())
|
|
@@ -244,67 +252,72 @@ public class ImagePickerModule extends ReactContextBaseJavaModule
|
|
|
244
252
|
this.callback = callback;
|
|
245
253
|
this.options = options;
|
|
246
254
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
255
|
+
handler.post(new Runnable() {
|
|
256
|
+
@Override
|
|
257
|
+
public void run() {
|
|
258
|
+
if (!permissionsCheck(currentActivity, callback, REQUEST_PERMISSIONS_FOR_CAMERA))
|
|
259
|
+
{
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
parseOptions(options);
|
|
264
|
+
|
|
265
|
+
int requestCode;
|
|
266
|
+
Intent cameraIntent;
|
|
267
|
+
|
|
268
|
+
if (pickVideo)
|
|
269
|
+
{
|
|
270
|
+
requestCode = REQUEST_LAUNCH_VIDEO_CAPTURE;
|
|
271
|
+
cameraIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
|
|
272
|
+
cameraIntent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, videoQuality);
|
|
273
|
+
if (videoDurationLimit > 0)
|
|
274
|
+
{
|
|
275
|
+
cameraIntent.putExtra(MediaStore.EXTRA_DURATION_LIMIT, videoDurationLimit);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
else
|
|
279
|
+
{
|
|
280
|
+
requestCode = REQUEST_LAUNCH_IMAGE_CAPTURE;
|
|
281
|
+
cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
|
282
|
+
|
|
283
|
+
final File original = createNewFile(self.getContext(), options, false);
|
|
284
|
+
|
|
285
|
+
if (original != null) {
|
|
286
|
+
cameraCaptureURI = RealPathUtil.compatUriFromFile(self.getContext(), original);
|
|
287
|
+
}else {
|
|
288
|
+
responseHelper.invokeError(callback, "Couldn't get file path for photo");
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
if (cameraCaptureURI == null)
|
|
292
|
+
{
|
|
293
|
+
responseHelper.invokeError(callback, "Couldn't get file path for photo");
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, cameraCaptureURI);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
// Workaround for Android bug.
|
|
300
|
+
// grantUriPermission also needed for KITKAT,
|
|
301
|
+
// see https://code.google.com/p/android/issues/detail?id=76683
|
|
302
|
+
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) {
|
|
303
|
+
List<ResolveInfo> resInfoList = self.getContext().getPackageManager().queryIntentActivities(cameraIntent, PackageManager.MATCH_DEFAULT_ONLY);
|
|
304
|
+
for (ResolveInfo resolveInfo : resInfoList) {
|
|
305
|
+
String packageName = resolveInfo.activityInfo.packageName;
|
|
306
|
+
self.getContext().grantUriPermission(packageName, cameraCaptureURI, Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
try
|
|
311
|
+
{
|
|
312
|
+
currentActivity.startActivityForResult(cameraIntent, requestCode);
|
|
313
|
+
}
|
|
314
|
+
catch (ActivityNotFoundException e)
|
|
315
|
+
{
|
|
316
|
+
e.printStackTrace();
|
|
317
|
+
responseHelper.invokeError(callback, "Cannot launch camera, unable to start");
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
});
|
|
308
321
|
}
|
|
309
322
|
|
|
310
323
|
public void launchImageLibrary()
|
|
@@ -326,197 +339,209 @@ public class ImagePickerModule extends ReactContextBaseJavaModule
|
|
|
326
339
|
this.callback = callback;
|
|
327
340
|
this.options = options;
|
|
328
341
|
|
|
329
|
-
|
|
330
|
-
{
|
|
331
|
-
|
|
332
|
-
|
|
342
|
+
Handler handler = new Handler(this.getContext().getMainLooper());
|
|
343
|
+
handler.post(new Runnable() {
|
|
344
|
+
@Override
|
|
345
|
+
public void run(){
|
|
346
|
+
if (!permissionsCheck(currentActivity, callback, REQUEST_PERMISSIONS_FOR_LIBRARY))
|
|
347
|
+
{
|
|
348
|
+
return;
|
|
349
|
+
}
|
|
333
350
|
|
|
334
|
-
|
|
351
|
+
parseOptions(options);
|
|
335
352
|
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
353
|
+
int requestCode;
|
|
354
|
+
Intent libraryIntent;
|
|
355
|
+
if (pickVideo)
|
|
356
|
+
{
|
|
357
|
+
requestCode = REQUEST_LAUNCH_VIDEO_LIBRARY;
|
|
358
|
+
libraryIntent = new Intent(Intent.ACTION_GET_CONTENT);
|
|
359
|
+
libraryIntent.setType("video/*");
|
|
360
|
+
libraryIntent.putExtra(Intent.EXTRA_LOCAL_ONLY, true);
|
|
361
|
+
libraryIntent.putExtra(Intent.CATEGORY_OPENABLE, true);
|
|
362
|
+
}
|
|
363
|
+
else
|
|
364
|
+
{
|
|
365
|
+
requestCode = REQUEST_LAUNCH_IMAGE_LIBRARY;
|
|
366
|
+
libraryIntent = new Intent(Intent.ACTION_GET_CONTENT);
|
|
367
|
+
libraryIntent.putExtra(Intent.EXTRA_LOCAL_ONLY, true);
|
|
368
|
+
libraryIntent.putExtra(Intent.CATEGORY_OPENABLE, true);
|
|
369
|
+
|
|
370
|
+
if (pickBoth)
|
|
371
|
+
{
|
|
372
|
+
libraryIntent.setType("image/* video/*");
|
|
373
|
+
} else {
|
|
374
|
+
libraryIntent.setType("image/*");
|
|
375
|
+
}
|
|
376
|
+
}
|
|
352
377
|
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
378
|
+
try
|
|
379
|
+
{
|
|
380
|
+
String chooseWhichLibraryTitle = null;
|
|
381
|
+
if (ReadableMapUtils.hasAndNotEmptyString(options, "chooseWhichLibraryTitle"))
|
|
382
|
+
{
|
|
383
|
+
chooseWhichLibraryTitle = options.getString("chooseWhichLibraryTitle");
|
|
384
|
+
}
|
|
360
385
|
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
386
|
+
currentActivity.startActivityForResult(Intent.createChooser(libraryIntent, chooseWhichLibraryTitle), requestCode);
|
|
387
|
+
}
|
|
388
|
+
catch (ActivityNotFoundException e)
|
|
389
|
+
{
|
|
390
|
+
e.printStackTrace();
|
|
391
|
+
responseHelper.invokeError(callback, "Cannot launch photo library");
|
|
392
|
+
}
|
|
367
393
|
}
|
|
368
|
-
|
|
369
|
-
currentActivity.startActivityForResult(Intent.createChooser(libraryIntent, chooseWhichLibraryTitle), requestCode);
|
|
370
|
-
}
|
|
371
|
-
catch (ActivityNotFoundException e)
|
|
372
|
-
{
|
|
373
|
-
e.printStackTrace();
|
|
374
|
-
responseHelper.invokeError(callback, "Cannot launch photo library");
|
|
375
|
-
}
|
|
394
|
+
});
|
|
376
395
|
}
|
|
377
396
|
|
|
378
397
|
@Override
|
|
379
|
-
public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data) {
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
{
|
|
383
|
-
|
|
384
|
-
|
|
398
|
+
public void onActivityResult(Activity activity, final int requestCode, final int resultCode, final Intent data) {
|
|
399
|
+
final ImagePickerModule self = this;
|
|
400
|
+
Handler handler = new Handler(this.getContext().getMainLooper());
|
|
401
|
+
handler.post(new Runnable() {
|
|
402
|
+
@Override
|
|
403
|
+
public void run() {
|
|
404
|
+
if (self.passResult(requestCode))
|
|
405
|
+
{
|
|
406
|
+
return;
|
|
407
|
+
}
|
|
385
408
|
|
|
386
|
-
|
|
409
|
+
responseHelper.cleanResponse();
|
|
387
410
|
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
411
|
+
// user cancel
|
|
412
|
+
if (resultCode != Activity.RESULT_OK)
|
|
413
|
+
{
|
|
414
|
+
responseHelper.invokeCancel(callback);
|
|
415
|
+
callback = null;
|
|
416
|
+
return;
|
|
417
|
+
}
|
|
395
418
|
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
419
|
+
Uri uri = null;
|
|
420
|
+
switch (requestCode)
|
|
421
|
+
{
|
|
422
|
+
case REQUEST_LAUNCH_IMAGE_CAPTURE:
|
|
423
|
+
uri = cameraCaptureURI;
|
|
424
|
+
break;
|
|
425
|
+
|
|
426
|
+
case REQUEST_LAUNCH_IMAGE_LIBRARY:
|
|
427
|
+
uri = data.getData();
|
|
428
|
+
if(uri == null){
|
|
429
|
+
responseHelper.putString("error", "Could not read photo");
|
|
430
|
+
responseHelper.invokeResponse(callback);
|
|
431
|
+
callback = null;
|
|
432
|
+
return;
|
|
433
|
+
}
|
|
434
|
+
break;
|
|
402
435
|
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
if(uri == null){
|
|
406
|
-
responseHelper.putString("error", "Could not read photo");
|
|
436
|
+
case REQUEST_LAUNCH_VIDEO_LIBRARY:
|
|
437
|
+
responseHelper.putString("uri", data.getData().toString());
|
|
407
438
|
responseHelper.invokeResponse(callback);
|
|
408
439
|
callback = null;
|
|
409
440
|
return;
|
|
410
|
-
}
|
|
411
|
-
break;
|
|
412
441
|
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
case REQUEST_LAUNCH_VIDEO_CAPTURE:
|
|
420
|
-
responseHelper.putString("uri", data.getData().toString());
|
|
421
|
-
responseHelper.invokeResponse(callback);
|
|
422
|
-
callback = null;
|
|
423
|
-
return;
|
|
424
|
-
}
|
|
442
|
+
case REQUEST_LAUNCH_VIDEO_CAPTURE:
|
|
443
|
+
responseHelper.putString("uri", data.getData().toString());
|
|
444
|
+
responseHelper.invokeResponse(callback);
|
|
445
|
+
callback = null;
|
|
446
|
+
return;
|
|
447
|
+
}
|
|
425
448
|
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
449
|
+
ReadExifResult result = null;
|
|
450
|
+
try {
|
|
451
|
+
InputStream imageInputStream = self.getContext().getContentResolver().openInputStream(uri);
|
|
452
|
+
if(imageInputStream != null){
|
|
453
|
+
result = readExifInterface(imageInputStream, responseHelper);
|
|
454
|
+
}
|
|
455
|
+
} catch(IOException ex){
|
|
456
|
+
responseHelper.invokeError(callback, ex.getMessage());
|
|
457
|
+
callback = null;
|
|
458
|
+
return;
|
|
459
|
+
}
|
|
460
|
+
if (result == null) {
|
|
461
|
+
responseHelper.invokeError(callback, "Image could not be read");
|
|
462
|
+
callback = null;
|
|
463
|
+
return;
|
|
464
|
+
}
|
|
465
|
+
if (result.error != null)
|
|
466
|
+
{
|
|
467
|
+
responseHelper.invokeError(callback, result.error.getMessage());
|
|
468
|
+
callback = null;
|
|
469
|
+
return;
|
|
470
|
+
}
|
|
448
471
|
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
472
|
+
BitmapFactory.Options options = new BitmapFactory.Options();
|
|
473
|
+
options.inJustDecodeBounds = true;
|
|
474
|
+
Bitmap imageBitmap = null;
|
|
475
|
+
try {
|
|
476
|
+
InputStream imageInputStream = self.getContext().getContentResolver().openInputStream(uri);
|
|
477
|
+
imageBitmap = BitmapFactory.decodeStream(imageInputStream, null, options);
|
|
478
|
+
} catch(FileNotFoundException ex){
|
|
479
|
+
responseHelper.invokeError(callback, "Could not find file");
|
|
480
|
+
callback = null;
|
|
481
|
+
return;
|
|
482
|
+
}
|
|
460
483
|
|
|
461
484
|
|
|
462
|
-
|
|
463
|
-
|
|
485
|
+
int initialWidth = options.outWidth;
|
|
486
|
+
int initialHeight = options.outHeight;
|
|
464
487
|
|
|
465
488
|
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
489
|
+
// don't create a new file if contraint are respected
|
|
490
|
+
if (imageConfig.useOriginal(initialWidth, initialHeight, result.currentRotation))
|
|
491
|
+
{
|
|
492
|
+
responseHelper.putInt("width", initialWidth);
|
|
493
|
+
responseHelper.putInt("height", initialHeight);
|
|
494
|
+
|
|
495
|
+
try {
|
|
496
|
+
InputStream imageInputStream = self.getContext().getContentResolver().openInputStream(uri);
|
|
497
|
+
updatedResultResponse(imageInputStream);
|
|
498
|
+
} catch(FileNotFoundException ex){
|
|
499
|
+
responseHelper.invokeError(callback, "Could not find file");
|
|
500
|
+
callback = null;
|
|
501
|
+
return;
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
else
|
|
505
|
+
{
|
|
506
|
+
Bitmap resizedImage = null;
|
|
507
|
+
ImageConfig rotatedImageConfig = imageConfig.withRotation(result.currentRotation);
|
|
508
|
+
try {
|
|
509
|
+
InputStream imageInputStream = self.getContext().getContentResolver().openInputStream(uri);
|
|
510
|
+
resizedImage = getResizedImage(imageInputStream, rotatedImageConfig, initialWidth, initialHeight);
|
|
511
|
+
} catch(FileNotFoundException ex){
|
|
512
|
+
responseHelper.invokeError(callback, "Could not find file");
|
|
513
|
+
callback = null;
|
|
514
|
+
return;
|
|
515
|
+
}
|
|
493
516
|
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
517
|
+
if (resizedImage == null)
|
|
518
|
+
{
|
|
519
|
+
responseHelper.putString("error", "Can't resize the image");
|
|
520
|
+
}
|
|
521
|
+
else
|
|
522
|
+
{
|
|
523
|
+
responseHelper.putInt("width", resizedImage.getWidth());
|
|
524
|
+
responseHelper.putInt("height", resizedImage.getHeight());
|
|
525
|
+
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
|
526
|
+
resizedImage.compress(Bitmap.CompressFormat.JPEG, imageConfig.quality, bos);
|
|
527
|
+
byte[] bitmapdata = bos.toByteArray();
|
|
528
|
+
ByteArrayInputStream bs = new ByteArrayInputStream(bitmapdata);
|
|
529
|
+
updatedResultResponse(bs);
|
|
530
|
+
resizedImage.recycle();
|
|
531
|
+
resizedImage = null;
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
if(imageBitmap != null){
|
|
535
|
+
imageBitmap.recycle();
|
|
536
|
+
imageBitmap = null;
|
|
537
|
+
}
|
|
515
538
|
|
|
516
539
|
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
540
|
+
responseHelper.invokeResponse(callback);
|
|
541
|
+
self.callback = null;
|
|
542
|
+
self.options = null;
|
|
543
|
+
}
|
|
544
|
+
});
|
|
520
545
|
}
|
|
521
546
|
|
|
522
547
|
public void invokeCustomButton(@NonNull final String action)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@connectedbits/react-native-image-picker",
|
|
3
|
-
"version": "2.4.16-
|
|
3
|
+
"version": "2.4.16-rc3",
|
|
4
4
|
"description": "A React Native module that allows you to use native UI to select media from the device library or directly from the camera",
|
|
5
5
|
"react-native": "src/index.ts",
|
|
6
6
|
"types": "lib/typescript/index.d.ts",
|