Update dependencies and fix metro bundler

This commit is contained in:
Elias Nahum 2021-04-20 10:25:08 -04:00
parent 9a4a93a1a5
commit 2b51a23c35
No known key found for this signature in database
GPG key ID: E038DB71E0B61702
8 changed files with 339 additions and 829 deletions

View file

@ -1,7 +1,6 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import 'intl';
import moment from 'moment';
import en from '@assets/i18n/en.json';

View file

@ -3,10 +3,10 @@ PODS:
- BVLinearGradient (2.5.6):
- React
- DoubleConversion (1.1.6)
- EXConstants (10.1.2):
- EXConstants (10.1.3):
- UMConstantsInterface
- UMCore
- EXFileSystem (11.0.1):
- EXFileSystem (11.0.2):
- UMCore
- UMFileSystemInterface
- FBLazyVector (0.64.0)
@ -29,9 +29,9 @@ PODS:
- libwebp/mux (1.1.0):
- libwebp/demux
- libwebp/webp (1.1.0)
- Permission-Camera (3.0.1):
- Permission-Camera (3.0.2):
- RNPermissions
- Permission-PhotoLibrary (3.0.1):
- Permission-PhotoLibrary (3.0.2):
- RNPermissions
- RCT-Folly (2020.01.13.00):
- boost-for-react-native
@ -239,8 +239,6 @@ PODS:
- React-Core
- react-native-hw-keyboard-event (0.0.4):
- React
- react-native-image-picker (2.3.4):
- React-Core
- react-native-netinfo (6.0.0):
- React-Core
- react-native-notifications (3.4.2):
@ -255,7 +253,7 @@ PODS:
- react-native-video/Video (= 5.1.1)
- react-native-video/Video (5.1.1):
- React-Core
- react-native-webview (11.3.2):
- react-native-webview (11.4.0):
- React-Core
- React-perflogger (0.64.0)
- React-RCTActionSheet (0.64.0):
@ -340,7 +338,7 @@ PODS:
- React-Core
- RNCMaskedView (0.1.10):
- React
- RNDeviceInfo (8.1.0):
- RNDeviceInfo (8.1.2):
- React-Core
- RNDevMenu (4.0.2):
- React-Core
@ -354,11 +352,11 @@ PODS:
- React-Core
- RNGestureHandler (1.10.3):
- React-Core
- RNKeychain (6.2.0):
- React
- RNLocalize (2.0.2):
- RNKeychain (7.0.0):
- React-Core
- RNPermissions (3.0.1):
- RNLocalize (2.0.3):
- React-Core
- RNPermissions (3.0.2):
- React-Core
- RNReactNativeHapticFeedback (1.11.0):
- React-Core
@ -394,16 +392,16 @@ PODS:
- RNRudderSdk (1.0.0):
- React
- Rudder
- RNSentry (2.4.0):
- RNSentry (2.4.1):
- React-Core
- Sentry (= 6.1.4)
- RNShare (5.2.2):
- RNShare (6.0.0):
- React-Core
- RNSVG (12.1.1-0):
- RNSVG (12.1.1):
- React
- RNVectorIcons (8.1.0):
- React-Core
- Rudder (1.0.9)
- Rudder (1.0.11)
- SDWebImage (5.9.4):
- SDWebImage/Core (= 5.9.4)
- SDWebImage/Core (5.9.4)
@ -428,7 +426,7 @@ PODS:
- UMImageLoaderInterface (6.1.0)
- UMPermissionsInterface (6.1.0):
- UMCore
- UMReactNativeAdapter (6.2.1):
- UMReactNativeAdapter (6.2.2):
- React-Core
- UMCore
- UMFontInterface
@ -473,7 +471,6 @@ DEPENDENCIES:
- react-native-document-picker (from `../node_modules/react-native-document-picker`)
- "react-native-emm (from `../node_modules/@mattermost/react-native-emm`)"
- react-native-hw-keyboard-event (from `../node_modules/react-native-hw-keyboard-event`)
- react-native-image-picker (from `../node_modules/react-native-image-picker`)
- "react-native-netinfo (from `../node_modules/@react-native-community/netinfo`)"
- react-native-notifications (from `../node_modules/react-native-notifications`)
- "react-native-paste-input (from `../node_modules/@mattermost/react-native-paste-input`)"
@ -598,8 +595,6 @@ EXTERNAL SOURCES:
:path: "../node_modules/@mattermost/react-native-emm"
react-native-hw-keyboard-event:
:path: "../node_modules/react-native-hw-keyboard-event"
react-native-image-picker:
:path: "../node_modules/react-native-image-picker"
react-native-netinfo:
:path: "../node_modules/@react-native-community/netinfo"
react-native-notifications:
@ -713,15 +708,15 @@ SPEC CHECKSUMS:
boost-for-react-native: 39c7adb57c4e60d6c5479dd8623128eb5b3f0f2c
BVLinearGradient: e3aad03778a456d77928f594a649e96995f1c872
DoubleConversion: cf9b38bf0b2d048436d9a82ad2abe1404f11e7de
EXConstants: 9d38f1a67f2bfcb222bb1d108a7070cf38132891
EXFileSystem: b3857957f9ca86c8743c6c60cc27fa078ac2992b
EXConstants: c00cd53a17a65b2e53ddb3890e4e74d3418e406e
EXFileSystem: 35769beb727d5341d1276fd222710f9704f7164e
FBLazyVector: 49cbe4b43e445b06bf29199b6ad2057649e4c8f5
FBReactNativeSpec: a804c9d6c798f94831713302354003ee54ea18cb
glog: 73c2498ac6884b13ede40eda8228cb1eee9d9d62
jail-monkey: 80c9e34da2cd54023e5ad08bf7051ec75bd43d5b
libwebp: 946cb3063cea9236285f7e9a8505d806d30e07f3
Permission-Camera: 0d2d15352e9c54c3ea8686c8c21fb1a9edf3431b
Permission-PhotoLibrary: e5d0500209f22e2a5b281501cd3744a965747726
Permission-Camera: 4eb4a67be32698c5927cb12313c3c1f23ee5b7b2
Permission-PhotoLibrary: 5b198e177c0bc5c91c20e66ae7202d0183c78b87
RCT-Folly: ec7a233ccc97cc556cf7237f0db1ff65b986f27c
RCTRequired: 2f8cb5b7533219bf4218a045f92768129cf7050a
RCTTypeSafety: 512728b73549e72ad7330b92f3d42936f2a4de5b
@ -739,13 +734,12 @@ SPEC CHECKSUMS:
react-native-document-picker: d2b8fa4d9b268a316515b1f631236f7a87813df6
react-native-emm: 480fc1cf19a8f3cd2b7e96d15ae3a238307bd534
react-native-hw-keyboard-event: b517cefb8d5c659a38049c582de85ff43337dc53
react-native-image-picker: 32d1ad2c0024ca36161ae0d5c2117e2d6c441f11
react-native-netinfo: 34f4d7a42f49157f3b45c14217d256bce7dc9682
react-native-notifications: e914ff49de3b2268cfa1b5e2ad21fd27c36d5b7b
react-native-paste-input: 003693cff6fcea476066172e66901beb7ef25670
react-native-safe-area-context: e471852c5ed67eea4b10c5d9d43c1cebae3b231d
react-native-video: 1574074179ecaf6a9dd067116c8f31bf9fec15c8
react-native-webview: aea3233f26253f5c360164ee87d01ef9f7b9a27f
react-native-webview: fdd3c7c2ad173e8ca8c82729ed05f3fda2491a82
React-perflogger: 9c547d8f06b9bf00cb447f2b75e8d7f19b7e02af
React-RCTActionSheet: 3080b6e12e0e1a5b313c8c0050699b5c794a1b11
React-RCTAnimation: 3f96f21a497ae7dabf4d2f150ee43f906aaf516f
@ -764,22 +758,22 @@ SPEC CHECKSUMS:
RNCAsyncStorage: cb9a623793918c6699586281f0b51cbc38f046f9
RNCClipboard: 5e299c6df8e0c98f3d7416b86ae563d3a9f768a3
RNCMaskedView: f5c7d14d6847b7b44853f7acb6284c1da30a3459
RNDeviceInfo: 77944ee74f4464aa4672b62e3239e4fa69ab534f
RNDeviceInfo: 4f480456c7ac8c9919448375399c1a6f14479549
RNDevMenu: 9f80d65b80ba1fa84e5361d017b8c854a2f05005
RNFastImage: d4870d58f5936111c56218dbd7fcfc18e65b58ff
RNFileViewer: 83cc066ad795b1f986791d03b56fe0ee14b6a69f
RNGestureHandler: a479ebd5ed4221a810967000735517df0d2db211
RNKeychain: b8e0711b959a19c5b057d1e970d3c83d159b6da5
RNLocalize: 47e22ef8c36df1d572e42a87c8ae22e3fcf551dd
RNPermissions: eb94f9fdc0a8ecd02fcce0676d56ffb1395d41e1
RNKeychain: f75b8c8b2f17d3b2aa1f25b4a0ac5b83d947ff8f
RNLocalize: 29e84ea169d3bca6c3b83584536c7f586a07fb98
RNPermissions: 84ffe5ee7d608e037d9ed1db846ffb1d5d4e1dba
RNReactNativeHapticFeedback: 653a8c126a0f5e88ce15ffe280b3ff37e1fbb285
RNReanimated: b8c8004b43446e3c2709fe64b2b41072f87428ad
RNRudderSdk: 5d99b1a5a582ab55d6213b38018d35e98818af63
RNSentry: b0d55027200c96f52e26b9bfb20296d47fc5051d
RNShare: 5cfe16bfd42cd2c4869a7692462181ac8cc15a6d
RNSVG: 1a8855adeb20c5beb0a808281608315fc1092d15
RNSentry: 824a6a0ec885428163fe6827aa08014f9962f223
RNShare: 31fa0cedbd06c2744a78e0d2b7ba364778aa3506
RNSVG: 551acb6562324b1d52a4e0758f7ca0ec234e278f
RNVectorIcons: 31cebfcf94e8cf8686eb5303ae0357da64d7a5a4
Rudder: 90ed801a09c73017184e6fc901370be1754eb182
Rudder: ef340f877a39653f19e69124dffae12fde3f881b
SDWebImage: b69257f4ab14e9b6a2ef53e910fdf914d8f757c1
SDWebImageWebPCoder: d0dac55073088d24b2ac1b191a71a8f8d0adac21
Sentry: 9d055e2de30a77685e86b219acf02e59b82091fc
@ -794,7 +788,7 @@ SPEC CHECKSUMS:
UMFontInterface: 81a951117d03f57aa636fba3992adefd0191f200
UMImageLoaderInterface: 5cd09b41630dc8aef7619fabc497c01c0f6b715c
UMPermissionsInterface: 4351145563e703c521fe2299e08227bc3584b94a
UMReactNativeAdapter: 7e15ed07bf2d7290e997e5d892e31bd276d4f4f1
UMReactNativeAdapter: 7b458ca3d4497b5114e6bb766b223432bad22d8a
UMSensorsInterface: 50439b47826e716a514cbd7384aebe9ab4fde5f4
UMTaskManagerInterface: 482155764886069beb1bc7fcf6036f12e4ad0751
WatermelonDB: e6706a0fac2221e2be4bdc93ff0e3990231d91bd

View file

@ -17,7 +17,9 @@ const config = {
console.log('BUILDING MODULES FOR', platform);
const moduleMap = {};
let modulePaths = [];
if (platform === 'ios') {
if (platform === 'android') {
modulePaths = require('./packager/modules.android');
} else {
modulePaths = require('./packager/modules.ios');
}
modulePaths.forEach((path) => {
@ -35,7 +37,7 @@ const config = {
preloadedModules: moduleMap,
transform: {
inlineRequires: {
blacklist: moduleMap,
blockList: moduleMap,
},
},
};

561
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -7,7 +7,7 @@
"license": "Apache 2.0",
"private": true,
"dependencies": {
"@babel/runtime": "7.13.10",
"@babel/runtime": "7.13.16",
"@mattermost/react-native-emm": "1.1.1",
"@mattermost/react-native-paste-input": "0.1.3",
"@nozbe/watermelondb": "0.21.0",
@ -19,25 +19,23 @@
"@react-native-community/masked-view": "0.1.10",
"@react-native-community/netinfo": "6.0.0",
"@rudderstack/rudder-sdk-react-native": "1.0.6",
"@sentry/react-native": "2.4.0",
"@sentry/react-native": "2.4.1",
"commonmark": "github:mattermost/commonmark.js#f6ab98dede6ce4b4e7adea140ac77249bfb2d6ce",
"commonmark-react-renderer": "github:mattermost/commonmark-react-renderer#3a2ac19cab725ad28b170fdc1d397dddedcf87eb",
"deep-equal": "2.0.5",
"deepmerge": "4.2.2",
"emoji-regex": "9.2.2",
"fuse.js": "6.4.6",
"intl": "1.2.5",
"jail-monkey": "2.3.3",
"mime-db": "1.47.0",
"moment-timezone": "0.5.33",
"prop-types": "15.7.2",
"react": "17.0.1",
"react": "17.0.2",
"react-intl": "5.15.8",
"react-native": "0.64.0",
"react-native-android-open-settings": "1.3.0",
"react-native-animatable": "1.3.3",
"react-native-calendars": "1.1255.0",
"react-native-device-info": "8.1.0",
"react-native-calendars": "1.1257.0",
"react-native-device-info": "8.1.2",
"react-native-document-picker": "5.0.3",
"react-native-elements": "3.3.2",
"react-native-exception-handler": "2.10.10",
@ -46,36 +44,34 @@
"react-native-gesture-handler": "1.10.3",
"react-native-haptic-feedback": "1.11.0",
"react-native-hw-keyboard-event": "0.0.4",
"react-native-image-picker": "2.3.4",
"react-native-keyboard-aware-scrollview": "2.1.0",
"react-native-keyboard-tracking-view": "5.7.0",
"react-native-keychain": "6.2.0",
"react-native-keychain": "7.0.0",
"react-native-linear-gradient": "2.5.6",
"react-native-localize": "2.0.2",
"react-native-localize": "2.0.3",
"react-native-navigation": "7.13.0",
"react-native-notifications": "3.4.2",
"react-native-permissions": "3.0.1",
"react-native-permissions": "3.0.2",
"react-native-reanimated": "2.1.0",
"react-native-redash": "16.0.11",
"react-native-safe-area-context": "3.2.0",
"react-native-share": "5.2.2",
"react-native-share": "6.0.0",
"react-native-slider": "0.11.0",
"react-native-svg": "12.1.1-0",
"react-native-unimodules": "0.13.2",
"react-native-svg": "12.1.1",
"react-native-unimodules": "0.13.3",
"react-native-vector-icons": "8.1.0",
"react-native-video": "5.1.1",
"react-native-webview": "11.3.2",
"react-native-webview": "11.4.0",
"react-native-youtube": "2.0.1",
"rn-placeholder": "3.0.3",
"semver": "7.3.5",
"serialize-error": "8.0.1",
"serialize-error": "8.1.0",
"shallow-equals": "1.0.0",
"tinycolor2": "1.4.2",
"url-parse": "1.5.1"
},
"devDependencies": {
"@babel/cli": "7.13.14",
"@babel/core": "7.13.15",
"@babel/cli": "7.13.16",
"@babel/core": "7.13.16",
"@babel/plugin-proposal-class-properties": "7.13.0",
"@babel/plugin-proposal-decorators": "7.13.15",
"@babel/plugin-transform-flow-strip-types": "7.13.0",
@ -84,14 +80,14 @@
"@babel/preset-typescript": "7.13.0",
"@babel/register": "7.13.14",
"@react-native-community/eslint-config": "2.0.0",
"@storybook/addon-knobs": "6.2.7",
"@storybook/addon-knobs": "6.2.8",
"@storybook/addon-ondevice-knobs": "5.3.25",
"@storybook/react-native": "5.3.25",
"@storybook/react-native-server": "5.3.23",
"@testing-library/react-native": "7.2.0",
"@types/jest": "26.0.22",
"@types/react": "17.0.3",
"@types/react-native": "0.64.2",
"@types/react-native": "0.64.4",
"@types/react-native-share": "3.3.2",
"@types/react-native-video": "5.0.4",
"@types/react-test-renderer": "17.0.1",
@ -107,7 +103,7 @@
"babel-plugin-module-resolver": "4.1.0",
"babel-plugin-transform-remove-console": "6.9.4",
"deep-freeze": "0.0.1",
"detox": "18.11.1",
"detox": "18.12.0",
"eslint": "7.24.0",
"eslint-plugin-header": "3.1.1",
"eslint-plugin-jest": "24.3.5",
@ -118,16 +114,16 @@
"jest": "26.6.3",
"jest-cli": "26.6.3",
"jetifier": "1.6.6",
"metro-react-native-babel-preset": "0.65.2",
"metro-react-native-babel-preset": "0.66.0",
"mmjstool": "github:mattermost/mattermost-utilities#519b99a4e51e6c67a0dbd46a6efdff27dc835aaa",
"mock-async-storage": "2.2.0",
"patch-package": "6.4.7",
"react-native-dev-menu": "4.0.2",
"react-native-dotenv": "2.5.5",
"react-native-storybook-loader": "2.0.2",
"ts-jest": "26.5.4",
"ts-jest": "26.5.5",
"typescript": "4.2.4",
"underscore": "1.13.0",
"underscore": "1.13.1",
"util": "0.12.3"
},
"scripts": {

View file

@ -1,476 +0,0 @@
diff --git a/node_modules/react-native-image-picker/android/src/main/java/com/imagepicker/ImagePickerModule.java b/node_modules/react-native-image-picker/android/src/main/java/com/imagepicker/ImagePickerModule.java
index 48fb5c1..3872d91 100644
--- a/node_modules/react-native-image-picker/android/src/main/java/com/imagepicker/ImagePickerModule.java
+++ b/node_modules/react-native-image-picker/android/src/main/java/com/imagepicker/ImagePickerModule.java
@@ -3,6 +3,7 @@ package com.imagepicker;
import android.Manifest;
import android.app.Activity;
import android.content.ActivityNotFoundException;
+import android.content.ContentResolver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
@@ -49,6 +50,7 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.lang.ref.WeakReference;
import java.util.List;
+import java.util.ArrayList;
import com.facebook.react.modules.core.PermissionListener;
import com.facebook.react.modules.core.PermissionAwareActivity;
@@ -69,6 +71,7 @@ public class ImagePickerModule extends ReactContextBaseJavaModule
public static final int REQUEST_LAUNCH_IMAGE_LIBRARY = 13002;
public static final int REQUEST_LAUNCH_VIDEO_LIBRARY = 13003;
public static final int REQUEST_LAUNCH_VIDEO_CAPTURE = 13004;
+ public static final int REQUEST_LAUNCH_MIXED_CAPTURE = 13005;
public static final int REQUEST_PERMISSIONS_FOR_CAMERA = 14001;
public static final int REQUEST_PERMISSIONS_FOR_LIBRARY = 14002;
@@ -266,26 +269,24 @@ public class ImagePickerModule extends ReactContextBaseJavaModule
cameraIntent.putExtra(MediaStore.EXTRA_DURATION_LIMIT, videoDurationLimit);
}
}
+ else if (pickBoth) {
+ Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
+ this.setImageCaptureUri(takePictureIntent);
+ Intent takeVideoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
+ cameraIntent = new Intent(Intent.ACTION_CHOOSER);
+ Intent contentSelectionIntent = new Intent(Intent.ACTION_GET_CONTENT);
+ Intent[] intentArray = new Intent[]{takePictureIntent,takeVideoIntent};
+ cameraIntent.putExtra(Intent.EXTRA_INTENT, contentSelectionIntent);
+ cameraIntent.putExtra(Intent.EXTRA_TITLE, "Choose an action");
+ cameraIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, intentArray);
+ requestCode = REQUEST_LAUNCH_MIXED_CAPTURE;
+ }
else
{
requestCode = REQUEST_LAUNCH_IMAGE_CAPTURE;
cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
- final File original = createNewFile(reactContext, this.options, false);
- imageConfig = imageConfig.withOriginalFile(original);
-
- if (imageConfig.original != null) {
- cameraCaptureURI = RealPathUtil.compatUriFromFile(reactContext, imageConfig.original);
- }else {
- responseHelper.invokeError(callback, "Couldn't get file path for photo");
- return;
- }
- if (cameraCaptureURI == null)
- {
- responseHelper.invokeError(callback, "Couldn't get file path for photo");
- return;
- }
- cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, cameraCaptureURI);
+ this.setImageCaptureUri(cameraIntent);
}
if (cameraIntent.resolveActivity(reactContext.getPackageManager()) == null)
@@ -350,16 +351,19 @@ public class ImagePickerModule extends ReactContextBaseJavaModule
libraryIntent = new Intent(Intent.ACTION_PICK);
libraryIntent.setType("video/*");
}
+ else if (pickBoth) {
+ libraryIntent = new Intent(Intent.ACTION_GET_CONTENT);
+ libraryIntent.addCategory(Intent.CATEGORY_OPENABLE);
+ libraryIntent.setType("image/*");
+ libraryIntent.putExtra(Intent.EXTRA_MIME_TYPES, new String[] {"image/*", "video/*"});
+ requestCode = REQUEST_LAUNCH_MIXED_CAPTURE;
+ }
else
{
requestCode = REQUEST_LAUNCH_IMAGE_LIBRARY;
libraryIntent = new Intent(Intent.ACTION_PICK,
MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
-
- if (pickBoth)
- {
- libraryIntent.setType("image/* video/*");
- }
+ libraryIntent.setType("image/*");
}
if (libraryIntent.resolveActivity(reactContext.getPackageManager()) == null)
@@ -385,75 +389,47 @@ public class ImagePickerModule extends ReactContextBaseJavaModule
}
}
- @Override
- public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data) {
- //robustness code
- if (passResult(requestCode))
- {
- return;
- }
-
- responseHelper.cleanResponse();
-
- // user cancel
- if (resultCode != Activity.RESULT_OK)
- {
- removeUselessFiles(requestCode, imageConfig);
- responseHelper.invokeCancel(callback);
- callback = null;
- return;
- }
+ protected String getMimeType(Activity activity, Uri uri) {
+ String mimeType = null;
+ if (uri.getScheme().equals(ContentResolver.SCHEME_CONTENT)) {
+ ContentResolver cr = activity.getApplicationContext().getContentResolver();
+ mimeType = cr.getType(uri);
+ } else {
+ String fileExtension = MimeTypeMap.getFileExtensionFromUrl(uri
+ .toString());
+ mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(
+ fileExtension.toLowerCase());
+ }
+ return mimeType;
+ }
- Uri uri = null;
- switch (requestCode)
+ protected void extractImageFromResult(Activity activity, Uri uri, int requestCode) {
+ String realPath = getRealPathFromURI(uri);
+ String mime = getMimeType(activity, uri);
+ final boolean isUrl = !TextUtils.isEmpty(realPath) &&
+ Patterns.WEB_URL.matcher(realPath).matches();
+ if (realPath == null || isUrl)
{
- case REQUEST_LAUNCH_IMAGE_CAPTURE:
- uri = cameraCaptureURI;
- break;
-
- case REQUEST_LAUNCH_IMAGE_LIBRARY:
- uri = data.getData();
- String realPath = getRealPathFromURI(uri);
- final boolean isUrl = !TextUtils.isEmpty(realPath) &&
- Patterns.WEB_URL.matcher(realPath).matches();
- if (realPath == null || isUrl)
- {
- try
- {
- File file = createFileFromURI(uri);
- realPath = file.getAbsolutePath();
- uri = Uri.fromFile(file);
- }
- catch (Exception e)
- {
- // image not in cache
- responseHelper.putString("error", "Could not read photo");
- responseHelper.putString("uri", uri.toString());
- responseHelper.invokeResponse(callback);
- callback = null;
- return;
- }
- }
- imageConfig = imageConfig.withOriginalFile(new File(realPath));
- break;
-
- case REQUEST_LAUNCH_VIDEO_LIBRARY:
- responseHelper.putString("uri", data.getData().toString());
- responseHelper.putString("path", getRealPathFromURI(data.getData()));
- responseHelper.invokeResponse(callback);
- callback = null;
- return;
-
- case REQUEST_LAUNCH_VIDEO_CAPTURE:
- final String path = getRealPathFromURI(data.getData());
- responseHelper.putString("uri", data.getData().toString());
- responseHelper.putString("path", path);
- fileScan(reactContext, path);
+ try
+ {
+ File file = createFileFromURI(uri);
+ realPath = file.getAbsolutePath();
+ uri = Uri.fromFile(file);
+ }
+ catch (Exception e)
+ {
+ // image not in cache
+ responseHelper.putString("error", "Could not read photo");
+ responseHelper.putString("uri", uri.toString());
responseHelper.invokeResponse(callback);
callback = null;
+ this.options = null;
return;
+ }
}
+ imageConfig = imageConfig.withOriginalFile(new File(realPath));
+
final ReadExifResult result = readExifInterface(responseHelper, imageConfig);
if (result.error != null)
@@ -461,6 +437,7 @@ public class ImagePickerModule extends ReactContextBaseJavaModule
removeUselessFiles(requestCode, imageConfig);
responseHelper.invokeError(callback, result.error.getMessage());
callback = null;
+ this.options = null;
return;
}
@@ -472,7 +449,7 @@ public class ImagePickerModule extends ReactContextBaseJavaModule
updatedResultResponse(uri, imageConfig.original.getAbsolutePath());
// don't create a new file if contraint are respected
- if (imageConfig.useOriginal(initialWidth, initialHeight, result.currentRotation))
+ if (imageConfig.useOriginal(initialWidth, initialHeight, result.currentRotation) || mime.equals("image/gif"))
{
responseHelper.putInt("width", initialWidth);
responseHelper.putInt("height", initialHeight);
@@ -481,6 +458,14 @@ public class ImagePickerModule extends ReactContextBaseJavaModule
else
{
imageConfig = getResizedImage(reactContext, this.options, imageConfig, initialWidth, initialHeight, requestCode);
+ if (imageConfig == null)
+ {
+ responseHelper.invokeError(callback, "Could not read image");
+ callback = null;
+ this.options = null;
+ return;
+ }
+
if (imageConfig.resized == null)
{
removeUselessFiles(requestCode, imageConfig);
@@ -523,6 +508,64 @@ public class ImagePickerModule extends ReactContextBaseJavaModule
this.options = null;
}
+ protected void extractVideoFromResult(Uri uri) {
+ responseHelper.putString("uri", uri.toString());
+ responseHelper.putString("path", getRealPathFromURI(uri));
+ responseHelper.invokeResponse(callback);
+ callback = null;
+ this.options = null;
+ }
+
+ @Override
+ public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data) {
+ //robustness code
+ if (passResult(requestCode))
+ {
+ return;
+ }
+
+ responseHelper.cleanResponse();
+
+ // user cancel
+ if (resultCode != Activity.RESULT_OK)
+ {
+ removeUselessFiles(requestCode, imageConfig);
+ responseHelper.invokeCancel(callback);
+ callback = null;
+ return;
+ }
+
+ switch (requestCode)
+ {
+ case REQUEST_LAUNCH_IMAGE_CAPTURE:
+ extractImageFromResult(activity, cameraCaptureURI, requestCode);
+ break;
+
+ case REQUEST_LAUNCH_IMAGE_LIBRARY:
+ extractImageFromResult(activity, data.getData(), requestCode);
+ break;
+
+ case REQUEST_LAUNCH_VIDEO_LIBRARY:
+ extractVideoFromResult(data.getData());
+ break;
+
+ case REQUEST_LAUNCH_MIXED_CAPTURE:
+ case REQUEST_LAUNCH_VIDEO_CAPTURE:
+ if (data == null || data.getData() == null) {
+ extractImageFromResult(activity, cameraCaptureURI, requestCode);
+ } else {
+ Uri selectedMediaUri = data.getData();
+ String mime = getMimeType(activity, selectedMediaUri);
+ if (mime.contains("image")) {
+ extractImageFromResult(activity, selectedMediaUri, requestCode);
+ } else {
+ extractVideoFromResult(selectedMediaUri);
+ }
+ }
+ break;
+ }
+ }
+
public void invokeCustomButton(@NonNull final String action)
{
responseHelper.invokeCustomButton(this.callback, action);
@@ -551,7 +594,8 @@ public class ImagePickerModule extends ReactContextBaseJavaModule
{
return callback == null || (cameraCaptureURI == null && requestCode == REQUEST_LAUNCH_IMAGE_CAPTURE)
|| (requestCode != REQUEST_LAUNCH_IMAGE_CAPTURE && requestCode != REQUEST_LAUNCH_IMAGE_LIBRARY
- && requestCode != REQUEST_LAUNCH_VIDEO_LIBRARY && requestCode != REQUEST_LAUNCH_VIDEO_CAPTURE);
+ && requestCode != REQUEST_LAUNCH_VIDEO_LIBRARY && requestCode != REQUEST_LAUNCH_VIDEO_CAPTURE
+ && requestCode != REQUEST_LAUNCH_MIXED_CAPTURE);
}
private void updatedResultResponse(@Nullable final Uri uri,
@@ -571,22 +615,23 @@ public class ImagePickerModule extends ReactContextBaseJavaModule
@NonNull final Callback callback,
@NonNull final int requestCode)
{
- final int writePermission = ActivityCompat
- .checkSelfPermission(activity, Manifest.permission.WRITE_EXTERNAL_STORAGE);
- final int cameraPermission = ActivityCompat
- .checkSelfPermission(activity, Manifest.permission.CAMERA);
-
- boolean permissionsGranted = false;
-
+ int selfCheckResult = 0;
switch (requestCode) {
case REQUEST_PERMISSIONS_FOR_LIBRARY:
- permissionsGranted = writePermission == PackageManager.PERMISSION_GRANTED;
+ selfCheckResult = ActivityCompat
+ .checkSelfPermission(activity, Manifest.permission.WRITE_EXTERNAL_STORAGE);
break;
case REQUEST_PERMISSIONS_FOR_CAMERA:
- permissionsGranted = cameraPermission == PackageManager.PERMISSION_GRANTED && writePermission == PackageManager.PERMISSION_GRANTED;
+ selfCheckResult = ActivityCompat
+ .checkSelfPermission(activity, Manifest.permission.CAMERA);
+ if (selfCheckResult == PackageManager.PERMISSION_GRANTED) {
+ selfCheckResult = ActivityCompat
+ .checkSelfPermission(activity, Manifest.permission.WRITE_EXTERNAL_STORAGE);
+ }
break;
}
+ final boolean permissionsGranted = selfCheckResult == PackageManager.PERMISSION_GRANTED;
if (!permissionsGranted)
{
final Boolean dontAskAgain = ActivityCompat.shouldShowRequestPermissionRationale(activity, Manifest.permission.WRITE_EXTERNAL_STORAGE) && ActivityCompat.shouldShowRequestPermissionRationale(activity, Manifest.permission.CAMERA);
@@ -787,4 +832,22 @@ public class ImagePickerModule extends ReactContextBaseJavaModule
videoDurationLimit = options.getInt("durationLimit");
}
}
+
+ private void setImageCaptureUri(Intent cameraIntent) {
+ final File original = createNewFile(reactContext, this.options, false);
+ imageConfig = imageConfig.withOriginalFile(original);
+
+ if (imageConfig.original != null) {
+ cameraCaptureURI = RealPathUtil.compatUriFromFile(reactContext, imageConfig.original);
+ }else {
+ responseHelper.invokeError(callback, "Couldn't get file path for photo");
+ return;
+ }
+ if (cameraCaptureURI == null)
+ {
+ responseHelper.invokeError(callback, "Couldn't get file path for photo");
+ return;
+ }
+ cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, cameraCaptureURI);
+ }
}
diff --git a/node_modules/react-native-image-picker/android/src/main/java/com/imagepicker/utils/RealPathUtil.java b/node_modules/react-native-image-picker/android/src/main/java/com/imagepicker/utils/RealPathUtil.java
index cc90dce..c1cc74d 100644
--- a/node_modules/react-native-image-picker/android/src/main/java/com/imagepicker/utils/RealPathUtil.java
+++ b/node_modules/react-native-image-picker/android/src/main/java/com/imagepicker/utils/RealPathUtil.java
@@ -7,16 +7,22 @@ import android.net.Uri;
import android.os.Build;
import android.provider.DocumentsContract;
import android.provider.MediaStore;
+import android.provider.OpenableColumns;
import android.content.ContentUris;
import android.os.Environment;
+import android.os.ParcelFileDescriptor;
+import android.webkit.MimeTypeMap;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.content.FileProvider;
-import java.io.File;
+import java.io.*;
+import java.nio.channels.FileChannel;
public class RealPathUtil {
+ public static final String CACHE_DIR_NAME = "mmShare";
+
public static @Nullable Uri compatUriFromFile(@NonNull final Context context,
@NonNull final File file) {
Uri result = null;
@@ -58,12 +64,7 @@ public class RealPathUtil {
}
// DownloadsProvider
else if (isDownloadsDocument(uri)) {
-
- final String id = DocumentsContract.getDocumentId(uri);
- final Uri contentUri = ContentUris.withAppendedId(
- Uri.parse("content://downloads/public_downloads"), Long.valueOf(id));
-
- return getDataColumn(context, contentUri, null, null);
+ return getPathFromSavingTempFile(context, uri);
}
// MediaProvider
else if (isMediaDocument(uri)) {
@@ -89,7 +90,7 @@ public class RealPathUtil {
}
}
// MediaStore (and general)
- else if ("content".equalsIgnoreCase(uri.getScheme())) {
+ if ("content".equalsIgnoreCase(uri.getScheme())) {
// Return the remote address
if (isGooglePhotosUri(uri))
@@ -98,7 +99,7 @@ public class RealPathUtil {
if (isFileProviderUri(context, uri))
return getFileProviderPath(context, uri);
- return getDataColumn(context, uri, null, null);
+ return getPathFromSavingTempFile(context, uri);
}
// File
else if ("file".equalsIgnoreCase(uri.getScheme())) {
@@ -108,6 +109,49 @@ public class RealPathUtil {
return null;
}
+
+ public static String getPathFromSavingTempFile(Context context, final Uri uri) {
+ File tmpFile;
+ String fileName = null;
+
+ // Try and get the filename from the Uri
+ try {
+ Cursor returnCursor =
+ context.getContentResolver().query(uri, null, null, null, null);
+ int nameIndex = returnCursor.getColumnIndex(OpenableColumns.DISPLAY_NAME);
+ returnCursor.moveToFirst();
+ fileName = returnCursor.getString(nameIndex);
+ } catch (Exception e) {
+ // just continue to get the filename with the last segment of the path
+ }
+
+ try {
+ if (fileName == null) {
+ fileName = uri.getLastPathSegment().toString().trim();
+ }
+
+
+ File cacheDir = new File(context.getCacheDir(), CACHE_DIR_NAME);
+ if (!cacheDir.exists()) {
+ cacheDir.mkdirs();
+ }
+
+ tmpFile = new File(cacheDir, fileName);
+ tmpFile.createNewFile();
+
+ ParcelFileDescriptor pfd = context.getContentResolver().openFileDescriptor(uri, "r");
+
+ FileChannel src = new FileInputStream(pfd.getFileDescriptor()).getChannel();
+ FileChannel dst = new FileOutputStream(tmpFile).getChannel();
+ dst.transferFrom(src, 0, src.size());
+ src.close();
+ dst.close();
+ } catch (IOException ex) {
+ return null;
+ }
+ return tmpFile.getAbsolutePath();
+ }
+
/**
* Get the value of the data column for this Uri. This is useful for
* MediaStore Uris, and other file-based ContentProviders.

View file

@ -1,5 +1,5 @@
diff --git a/node_modules/react-native-keychain/android/src/main/java/com/oblador/keychain/KeychainModule.java b/node_modules/react-native-keychain/android/src/main/java/com/oblador/keychain/KeychainModule.java
index d4ded69..af35eaa 100644
index 3da433f..112cc74 100644
--- a/node_modules/react-native-keychain/android/src/main/java/com/oblador/keychain/KeychainModule.java
+++ b/node_modules/react-native-keychain/android/src/main/java/com/oblador/keychain/KeychainModule.java
@@ -1,6 +1,7 @@
@ -7,10 +7,10 @@ index d4ded69..af35eaa 100644
import android.os.Build;
+import android.os.Bundle;
import android.os.Looper;
import android.text.TextUtils;
import android.util.Log;
@@ -128,6 +129,7 @@ public class KeychainModule extends ReactContextBaseJavaModule {
@@ -129,6 +130,7 @@ public class KeychainModule extends ReactContextBaseJavaModule {
//region Members
/** Name-to-instance lookup map. */
private final Map<String, CipherStorage> cipherStorageMap = new HashMap<>();
@ -18,12 +18,12 @@ index d4ded69..af35eaa 100644
/** Shared preferences storage. */
private final PrefsStorage prefsStorage;
//endregion
@@ -139,13 +141,13 @@ public class KeychainModule extends ReactContextBaseJavaModule {
@@ -140,13 +142,13 @@ public class KeychainModule extends ReactContextBaseJavaModule {
super(reactContext);
prefsStorage = new PrefsStorage(reactContext);
- addCipherStorageToMap(new CipherStorageFacebookConceal(reactContext));
+ // addCipherStorageToMap(new CipherStorageFacebookConceal(reactContext));
+ //addCipherStorageToMap(new CipherStorageFacebookConceal(reactContext));
addCipherStorageToMap(new CipherStorageKeystoreAesCbc());
// we have a references to newer api that will fail load of app classes in old androids OS
@ -36,7 +36,7 @@ index d4ded69..af35eaa 100644
}
/** Allow initialization in chain. */
@@ -277,6 +279,12 @@ public class KeychainModule extends ReactContextBaseJavaModule {
@@ -278,6 +280,12 @@ public class KeychainModule extends ReactContextBaseJavaModule {
@Nullable final ReadableMap options,
@NonNull final Promise promise) {
try {
@ -49,7 +49,7 @@ index d4ded69..af35eaa 100644
final ResultSet resultSet = prefsStorage.getEncryptedEntry(alias);
if (resultSet == null) {
@@ -299,6 +307,7 @@ public class KeychainModule extends ReactContextBaseJavaModule {
@@ -300,6 +308,7 @@ public class KeychainModule extends ReactContextBaseJavaModule {
credentials.putString(Maps.USERNAME, decryptionResult.username);
credentials.putString(Maps.PASSWORD, decryptionResult.password);
credentials.putString(Maps.STORAGE, current.getCipherStorageName());