Skip to content
Open

V3 #2

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
d3fa8dd
Fix license attribute
dantman Mar 22, 2018
2d19080
Add specific ActivityNotFoundException catch for the case where no ap…
khrizt Jun 19, 2018
42a8945
Sorted file types and extensions alphabetically
piranna Jul 18, 2018
bf3db75
Added video file types and extensions
piranna Jul 18, 2018
d7af250
Merge pull request #145 from QuantumBA/mime_types
dantman Jul 18, 2018
339dc08
remove runtime warning about requiresMainQueueSetup
lachlanroche Oct 31, 2018
88c0497
Merge pull request #100 from dantman/v3
Elyx0 Nov 7, 2018
1267fe9
Merge pull request #163 from lachlanroche/patch-requiresMainQueueSetup
Elyx0 Nov 7, 2018
7a09359
Merge pull request #132 from coverfy/v3
Elyx0 Nov 7, 2018
f2e6bd5
Fix typo and android build issue
johnsonsu Nov 8, 2018
677545b
Missing symbol
rafcontreras Nov 8, 2018
42eeb9b
Merge pull request #164 from johnsonsu/v3
Elyx0 Nov 13, 2018
902ba80
Fix Xcode 10 warnings
sryze Nov 25, 2018
5f7d6ec
changed dynamic version dependency to static
Dec 10, 2018
692af60
Merge pull request #173 from instructure/remove-dynamic-version-number
Elyx0 Dec 11, 2018
0283de7
default function param + no changing imutable opts
arelstone Jan 9, 2019
467887e
no need to parse param as object
arelstone Jan 10, 2019
3cc5919
use react-native 0.57 compatible windows sdk and newtonsoft versions
leoek Jan 16, 2019
c2cee5a
remove double or unused using directives to avoid warnings
leoek Jan 16, 2019
c390fed
Merge pull request #165 from rafcontreras/v3
Elyx0 Jan 22, 2019
53eec9a
Merge pull request #171 from sryze/xcode-10
Elyx0 Jan 22, 2019
a9ffa78
Merge pull request #175 from arelstone/v3
Elyx0 Jan 22, 2019
73ebe60
Merge pull request #176 from leoek/v3
Elyx0 Jan 22, 2019
cd82b95
Merge remote-tracking branch 'upstream/v3' into v3
piranna Feb 15, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ buildscript {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
classpath 'com.android.tools.build:gradle:2.3.3'
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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(E_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());
Expand Down
30 changes: 19 additions & 11 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,27 +57,29 @@ function pick(opts) {
const Types = {
mimeTypes: {
'allFiles': '*/*',
'audio': 'audio/*',
'images': 'image/*',
'video': 'video/mp4,video/x-m4v,video/*',
'plainText': 'text/plain',
'audio': 'audio/*',
'pdf': 'application/pdf',
'video': 'video/*',
},
utis: {
'allFiles': 'public.content',
'audio': 'public.audio',
'images': 'public.image',
'video': 'public.video',
'plainText': 'public.plain-text',
'audio': 'public.audio',
'pdf': 'com.adobe.pdf',
'video': 'public.video',
},
extensions: {
'allFiles': '*',
'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': '.png .jpg .jpeg',
'video': '.avi .mpeg .ogv .webm .3gp .3g2 .mp4',
'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',
'plainText': '.txt',
'video': '.avi .mpeg .ogv .webm .3gp .3g2 .mp4'
}
};

Expand All @@ -96,15 +98,21 @@ 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]);
const options = {
...opts,
multiple: false
}

return pick(options).then((results) => results[0]);
}

static pickMultiple(opts) {
opts = opts || {};
opts.multiple = true;
return pick(opts);
const options = {
...opts,
multiple: true
}

return pick(options);
}

static isCancel(err) {
Expand Down
26 changes: 23 additions & 3 deletions ios/RNDocumentPicker.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
E01DD9D31D2311A600C39062 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0730;
LastUpgradeCheck = 1010;
ORGANIZATIONNAME = Elialys;
TargetAttributes = {
E01DD9DA1D2311A600C39062 = {
Expand Down Expand Up @@ -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";
Expand All @@ -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;
Expand All @@ -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";
Expand All @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions ios/RNDocumentPicker/RNDocumentPicker.m
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ - (instancetype)init
return self;
}

+ (BOOL)requiresMainQueueSetup {
return NO;
}

- (dispatch_queue_t)methodQueue
{
return dispatch_get_main_queue();
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"icloud"
],
"author": "Elyx0 <elyx00@gmail.com> (@Elyx0)",
"license": "ISC",
"license": "MIT",
"bugs": {
"url": "https://github.com/Elyx0/react-native-document-picker/issues"
},
Expand Down
6 changes: 0 additions & 6 deletions windows/RNDocumentPicker/RCTDocumentPickerModule.cs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
2 changes: 1 addition & 1 deletion windows/RNDocumentPicker/RNDocumentPicker.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<DefaultLanguage>en-US</DefaultLanguage>
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
<TargetPlatformVersion>10.0.14393.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.10240.0</TargetPlatformMinVersion>
<TargetPlatformMinVersion>10.0.14393.0</TargetPlatformMinVersion>
<MinimumVisualStudioVersion>14</MinimumVisualStudioVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
Expand Down
4 changes: 2 additions & 2 deletions windows/RNDocumentPicker/project.json
Original file line number Diff line number Diff line change
@@ -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": {},
Expand Down