From d3fa8dda4deccbb603b2e9cbe8a7c555c5e292dd Mon Sep 17 00:00:00 2001 From: Daniel Friesen Date: Wed, 21 Mar 2018 19:03:14 -0700 Subject: [PATCH 01/13] Fix license attribute The package.json declares the ISC (default when you use npm init) but the library is actually MIT licensed. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 049b88db..e344c694 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "icloud" ], "author": "Elyx0 (@Elyx0)", - "license": "ISC", + "license": "MIT", "bugs": { "url": "https://github.com/Elyx0/react-native-document-picker/issues" }, From 2d19080da0bb53539eda930a56469a8c90729ba5 Mon Sep 17 00:00:00 2001 From: Christian Date: Tue, 19 Jun 2018 19:31:40 +0200 Subject: [PATCH 02/13] Add specific ActivityNotFoundException catch for the case where no app is available to open the desired file type --- .../reactnativedocumentpicker/DocumentPickerModule.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/android/src/main/java/io/github/elyx0/reactnativedocumentpicker/DocumentPickerModule.java b/android/src/main/java/io/github/elyx0/reactnativedocumentpicker/DocumentPickerModule.java index aec7ab4b..da29b2ec 100644 --- a/android/src/main/java/io/github/elyx0/reactnativedocumentpicker/DocumentPickerModule.java +++ b/android/src/main/java/io/github/elyx0/reactnativedocumentpicker/DocumentPickerModule.java @@ -1,6 +1,7 @@ package io.github.elyx0.reactnativedocumentpicker; import android.app.Activity; +import android.content.ActivityNotFoundException; import android.content.ClipData; import android.content.ContentResolver; import android.content.Intent; @@ -34,6 +35,7 @@ public class DocumentPickerModule extends ReactContextBaseJavaModule { private static final String E_ACTIVITY_DOES_NOT_EXIST = "ACTIVITY_DOES_NOT_EXIST"; private static final String E_FAILED_TO_SHOW_PICKER = "FAILED_TO_SHOW_PICKER"; private static final String E_DOCUMENT_PICKER_CANCELED = "DOCUMENT_PICKER_CANCELED"; + private static final String E_UNABLE_TO_OPEN_FILE_TYPE = "UNABLE_TO_OPEN_FILE_TYPE"; private static final String E_UNKNOWN_ACTIVITY_RESULT = "UNKNOWN_ACTIVITY_RESULT"; private static final String E_INVALID_DATA_RETURNED = "INVALID_DATA_RETURNED"; private static final String E_UNEXPECTED_EXCEPTION = "UNEXPECTED_EXCEPTION"; @@ -125,6 +127,9 @@ public void pick(ReadableMap args, Promise promise) { } currentActivity.startActivityForResult(intent, READ_REQUEST_CODE, Bundle.EMPTY); + } catch (ActivityNotFoundException e) { + this.promise.reject(UNABLE_TO_OPEN_FILE_TYPE, e.getLocalizedMessage()); + this.promise = null; } catch (Exception e) { e.printStackTrace(); this.promise.reject(E_FAILED_TO_SHOW_PICKER, e.getLocalizedMessage()); From 42a8945b0832cde58d4637e5a89e93b6e93586f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Legan=C3=A9s-Combarro=20=27piranna?= Date: Wed, 18 Jul 2018 19:37:48 +0200 Subject: [PATCH 03/13] Sorted file types and extensions alphabetically --- index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 2270accc..4baa9ae0 100644 --- a/index.js +++ b/index.js @@ -55,23 +55,23 @@ function pick(opts) { const Types = { mimeTypes: { 'allFiles': '*/*', + 'audio': 'audio/*', 'images': 'image/*', 'plainText': 'text/plain', - 'audio': 'audio/*', 'pdf': 'application/pdf', }, utis: { 'allFiles': 'public.content', + 'audio': 'public.audio', 'images': 'public.image', 'plainText': 'public.plain-text', - 'audio': 'public.audio', 'pdf': 'com.adobe.pdf', }, extensions: { 'allFiles': '*', - 'images': '.png .jpg .jpeg', + 'audio': '.3g2 .3gp .aac .adt .adts .aif .aifc .aiff .asf .au .m3u .m4a .m4b .mid .midi .mp2 .mp3 .mp4 .rmi .snd .wav .wax .wma', + 'images': '.jpeg .jpg .png', 'plainText': '.txt', - 'audio': '.adts .adt .aac .aif .aifc .aiff .au .snd .mid .midi .rmi .mp3 .mp2 .m3u .m4a .wav .wma .wax .asf .3g2 .3gp .m4b .mp4', 'pdf': '.pdf', } }; From bf3db757988e321fe04af3c655efd4f205663ab9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Legan=C3=A9s-Combarro=20=27piranna?= Date: Wed, 18 Jul 2018 19:38:17 +0200 Subject: [PATCH 04/13] Added video file types and extensions --- index.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/index.js b/index.js index 4baa9ae0..eb284299 100644 --- a/index.js +++ b/index.js @@ -59,6 +59,7 @@ const Types = { 'images': 'image/*', 'plainText': 'text/plain', 'pdf': 'application/pdf', + 'video': 'video/*', }, utis: { 'allFiles': 'public.content', @@ -66,6 +67,7 @@ const Types = { 'images': 'public.image', 'plainText': 'public.plain-text', 'pdf': 'com.adobe.pdf', + 'video': 'public.video', }, extensions: { 'allFiles': '*', @@ -73,6 +75,7 @@ const Types = { 'images': '.jpeg .jpg .png', 'plainText': '.txt', 'pdf': '.pdf', + 'video': '.mp4', } }; From 339dc08f8157217eee9484297f7a2d24de079e09 Mon Sep 17 00:00:00 2001 From: Lachlan Roche Date: Wed, 31 Oct 2018 22:22:18 +1000 Subject: [PATCH 05/13] remove runtime warning about requiresMainQueueSetup --- ios/RNDocumentPicker/RNDocumentPicker.m | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ios/RNDocumentPicker/RNDocumentPicker.m b/ios/RNDocumentPicker/RNDocumentPicker.m index f12904df..1cb8b4b0 100644 --- a/ios/RNDocumentPicker/RNDocumentPicker.m +++ b/ios/RNDocumentPicker/RNDocumentPicker.m @@ -42,6 +42,10 @@ - (instancetype)init return self; } ++ (BOOL)requiresMainQueueSetup { + return NO; +} + - (dispatch_queue_t)methodQueue { return dispatch_get_main_queue(); From f2e6bd5ae1b8b67c559ce2f401468ab293df182a Mon Sep 17 00:00:00 2001 From: Johnson Su Date: Wed, 7 Nov 2018 19:12:14 -0500 Subject: [PATCH 06/13] Fix typo and android build issue --- .../elyx0/reactnativedocumentpicker/DocumentPickerModule.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/src/main/java/io/github/elyx0/reactnativedocumentpicker/DocumentPickerModule.java b/android/src/main/java/io/github/elyx0/reactnativedocumentpicker/DocumentPickerModule.java index da29b2ec..5985bce1 100644 --- a/android/src/main/java/io/github/elyx0/reactnativedocumentpicker/DocumentPickerModule.java +++ b/android/src/main/java/io/github/elyx0/reactnativedocumentpicker/DocumentPickerModule.java @@ -128,7 +128,7 @@ public void pick(ReadableMap args, Promise promise) { currentActivity.startActivityForResult(intent, READ_REQUEST_CODE, Bundle.EMPTY); } catch (ActivityNotFoundException e) { - this.promise.reject(UNABLE_TO_OPEN_FILE_TYPE, e.getLocalizedMessage()); + this.promise.reject(E_UNABLE_TO_OPEN_FILE_TYPE, e.getLocalizedMessage()); this.promise = null; } catch (Exception e) { e.printStackTrace(); From 677545b6ef02954d6d48c8ddd8492a50e89a5567 Mon Sep 17 00:00:00 2001 From: Rafael Contreras Date: Fri, 9 Nov 2018 10:38:45 +1300 Subject: [PATCH 07/13] Missing symbol Gradle started to throw error on build --- .../elyx0/reactnativedocumentpicker/DocumentPickerModule.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/src/main/java/io/github/elyx0/reactnativedocumentpicker/DocumentPickerModule.java b/android/src/main/java/io/github/elyx0/reactnativedocumentpicker/DocumentPickerModule.java index da29b2ec..5985bce1 100644 --- a/android/src/main/java/io/github/elyx0/reactnativedocumentpicker/DocumentPickerModule.java +++ b/android/src/main/java/io/github/elyx0/reactnativedocumentpicker/DocumentPickerModule.java @@ -128,7 +128,7 @@ public void pick(ReadableMap args, Promise promise) { currentActivity.startActivityForResult(intent, READ_REQUEST_CODE, Bundle.EMPTY); } catch (ActivityNotFoundException e) { - this.promise.reject(UNABLE_TO_OPEN_FILE_TYPE, e.getLocalizedMessage()); + this.promise.reject(E_UNABLE_TO_OPEN_FILE_TYPE, e.getLocalizedMessage()); this.promise = null; } catch (Exception e) { e.printStackTrace(); From 902ba8012ce7d1d31d76ac23745c5027a228fb71 Mon Sep 17 00:00:00 2001 From: Sergey Zolotarev Date: Mon, 26 Nov 2018 02:31:21 +0600 Subject: [PATCH 08/13] Fix Xcode 10 warnings --- .../project.pbxproj | 26 ++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/ios/RNDocumentPicker.xcodeproj/project.pbxproj b/ios/RNDocumentPicker.xcodeproj/project.pbxproj index 88409bc8..2b1f1db8 100644 --- a/ios/RNDocumentPicker.xcodeproj/project.pbxproj +++ b/ios/RNDocumentPicker.xcodeproj/project.pbxproj @@ -92,7 +92,7 @@ E01DD9D31D2311A600C39062 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0730; + LastUpgradeCheck = 1010; ORGANIZATIONNAME = Elialys; TargetAttributes = { E01DD9DA1D2311A600C39062 = { @@ -138,13 +138,23 @@ CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; @@ -166,7 +176,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 7.0; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -182,13 +192,23 @@ CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; @@ -204,7 +224,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 7.0; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; VALIDATE_PRODUCT = YES; From 5f7d6ecedad33dd67324a51976dc7abfeb55c33a Mon Sep 17 00:00:00 2001 From: Manuel Nakamurakare Date: Mon, 10 Dec 2018 14:29:01 -0800 Subject: [PATCH 09/13] changed dynamic version dependency to static --- android/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/build.gradle b/android/build.gradle index 86182ae6..1a86523e 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -3,7 +3,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:2.3.+' + classpath 'com.android.tools.build:gradle:2.3.3' } } From 0283de71ad3823125abb8ff66dbc916cf6ca914d Mon Sep 17 00:00:00 2001 From: arelstone Date: Wed, 9 Jan 2019 12:08:44 +0100 Subject: [PATCH 10/13] default function param + no changing imutable opts --- index.js | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/index.js b/index.js index eb284299..9e812252 100644 --- a/index.js +++ b/index.js @@ -93,16 +93,22 @@ export default class DocumentPicker { */ static types = PlatformTypes[Platform.OS] || Types.mimeTypes - static pick(opts) { - opts = opts || {}; - opts.multiple = false; - return pick(opts).then((results) => results[0]); + static pick(opts = {}) { + const options = { + ...opts, + multiple: false + } + + return pick(options).then((results) => results[0]); } - static pickMultiple(opts) { - opts = opts || {}; - opts.multiple = true; - return pick(opts); + static pickMultiple(opts = {}) { + const options = { + ...opts, + multiple: true + } + + return pick(options); } static isCancel(err) { From 467887e2204612a07a1facd5404f5c26729b48c8 Mon Sep 17 00:00:00 2001 From: arelstone Date: Thu, 10 Jan 2019 08:16:26 +0100 Subject: [PATCH 11/13] no need to parse param as object --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 9e812252..95e76f84 100644 --- a/index.js +++ b/index.js @@ -93,7 +93,7 @@ export default class DocumentPicker { */ static types = PlatformTypes[Platform.OS] || Types.mimeTypes - static pick(opts = {}) { + static pick(opts) { const options = { ...opts, multiple: false @@ -102,7 +102,7 @@ export default class DocumentPicker { return pick(options).then((results) => results[0]); } - static pickMultiple(opts = {}) { + static pickMultiple(opts) { const options = { ...opts, multiple: true From 3cc59199e8b73a3112945741261e207bac82b622 Mon Sep 17 00:00:00 2001 From: Leonard Krause Date: Thu, 17 Jan 2019 00:14:16 +0100 Subject: [PATCH 12/13] use react-native 0.57 compatible windows sdk and newtonsoft versions --- windows/RNDocumentPicker/RNDocumentPicker.csproj | 2 +- windows/RNDocumentPicker/project.json | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/windows/RNDocumentPicker/RNDocumentPicker.csproj b/windows/RNDocumentPicker/RNDocumentPicker.csproj index 9d14dbd3..d6e2f96e 100644 --- a/windows/RNDocumentPicker/RNDocumentPicker.csproj +++ b/windows/RNDocumentPicker/RNDocumentPicker.csproj @@ -12,7 +12,7 @@ en-US UAP 10.0.14393.0 - 10.0.10240.0 + 10.0.14393.0 14 512 {A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} diff --git a/windows/RNDocumentPicker/project.json b/windows/RNDocumentPicker/project.json index 91780b8d..52c8348d 100644 --- a/windows/RNDocumentPicker/project.json +++ b/windows/RNDocumentPicker/project.json @@ -1,12 +1,12 @@ { "dependencies": { "Microsoft.NETCore.UniversalWindowsPlatform": "5.2.2", - "Newtonsoft.Json": "9.0.1", + "Newtonsoft.Json": "12.0.1", "System.Reactive.Linq": "3.1.1", "ZXing.Net": "0.16.0" }, "frameworks": { - "uap10.0.10240": {} + "uap10.0.14393": {} }, "runtimes": { "win10-arm": {}, From c2cee5ad3994a2d84b0282ee9e8e6a60d7d7388d Mon Sep 17 00:00:00 2001 From: Leonard Krause Date: Thu, 17 Jan 2019 00:15:06 +0100 Subject: [PATCH 13/13] remove double or unused using directives to avoid warnings --- windows/RNDocumentPicker/RCTDocumentPickerModule.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/windows/RNDocumentPicker/RCTDocumentPickerModule.cs b/windows/RNDocumentPicker/RCTDocumentPickerModule.cs index 41119473..4269457e 100644 --- a/windows/RNDocumentPicker/RCTDocumentPickerModule.cs +++ b/windows/RNDocumentPicker/RCTDocumentPickerModule.cs @@ -1,18 +1,12 @@ using Newtonsoft.Json.Linq; using ReactNative.Bridge; using System; -using Newtonsoft.Json.Linq; -using ReactNative.Bridge; -using ReactNative.Collections; using System.Linq; using System.Collections.Generic; using Windows.ApplicationModel.Core; using Windows.UI.Core; -using Windows.UI.Popups; using Windows.Storage; using Windows.Storage.Pickers; -using ZXing; -using static System.FormattableString; using System.Text.RegularExpressions; using System.Threading.Tasks;