diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml deleted file mode 100644 index dfffaeaf05c0e8dd11907931f5939cc5bbd983c3..0000000000000000000000000000000000000000 --- a/.github/FUNDING.yml +++ /dev/null @@ -1 +0,0 @@ -github: [vonovak] \ No newline at end of file diff --git a/.github/label-actions.yml b/.github/label-actions.yml deleted file mode 100644 index b304f2d40920904f80e1a8b10cccc1d5b26253d4..0000000000000000000000000000000000000000 --- a/.github/label-actions.yml +++ /dev/null @@ -1,36 +0,0 @@ -# Configuration for Label Actions - https://github.com/dessant/label-actions - -# Actions taken when the `repro-required` label is added -repro-required: - # Post a comment - comment: > - :wave: @{issue-author}, sorry you're having an issue. This issue is being closed because it does not provide all information required by the [issue template](https://raw.githubusercontent.com/rnmods/.github/master/.github/ISSUE_TEMPLATE/bug_report.md). - As the issue template explains, we require that you provide a runnable example that reproduces your issue and your environment information. - This means you need to provide a code snippet that we can copy-paste into an empty project and see the error ourselves, or provide a git repository with the issue. - - The reason is that maintainers do not have time to try reproduce bugs themselves. Please try to minimize the superfluous code and focus only on reproducing the bug. - - Please create a new issue with this and we'll be happy to review it! - # Lock the thread - lock: true - close: true -# Actions taken when the `repro-required` label is removed --repro-required: - # Unlock the thread - unlock: true - reopen: true - -question: - # Post a comment - comment: > - :wave: @{issue-author}, thanks for opening the issue. The issue tracker is intended for tracking bug reports and feature requests only. - - Seems you have a usage question. Please ask the question on [StackOverflow](https://stackoverflow.com/questions/tagged/react-native). You can also chat with other community members on [Reactiflux Discord server](https://www.reactiflux.com/). - # Lock the thread - lock: true - close: true -# Actions taken when the `repro-required` label is removed --question: - # Unlock the thread - unlock: true - reopen: true diff --git a/.github/workflows/label-actions.yml b/.github/workflows/label-actions.yml deleted file mode 100644 index c11dde1bac04289dca33c0a64ea6d6575e00a660..0000000000000000000000000000000000000000 --- a/.github/workflows/label-actions.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: 'Label Actions' - -on: - issues: - types: [labeled, unlabeled] -# pull_request: -# types: [labeled, unlabeled] -# discussion: -# types: [labeled, unlabeled] - -permissions: - contents: read - issues: write - pull-requests: write - discussions: write - -jobs: - action: - runs-on: ubuntu-latest - steps: - - uses: dessant/label-actions@v2 diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml deleted file mode 100644 index b9177882eb1e57148d4e646479224d8fa6d7d215..0000000000000000000000000000000000000000 --- a/.github/workflows/nodejs.yml +++ /dev/null @@ -1,52 +0,0 @@ -# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node -# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions - -name: Node.js CI - -on: - push: - branches: [master] - pull_request: - branches: [master] - - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: - -jobs: - build: - runs-on: ubuntu-latest - - strategy: - matrix: - node-version: [18.x] - - steps: - - uses: actions/checkout@v2 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 - with: - node-version: ${{ matrix.node-version }} - - run: yarn install --frozen-lockfile - - run: yarn lint && yarn typescript - env: - CI: true -# release: -# runs-on: ubuntu-latest -# if: github.ref == 'refs/heads/master' -# steps: -# - uses: actions/checkout@v2 -# with: -# fetch-depth: 0 -# - name: git config -# run: | -# git config user.name "${GITHUB_ACTOR}" -# git config user.email "${GITHUB_ACTOR}@users.noreply.github.com" -# - run: | -# echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc -# npm config set //registry.npmjs.org/:_authToken $NPM_TOKEN -# env: -# NPM_TOKEN: ${{ secrets.NPM_TOKEN }} -# - run: yarn install --frozen-lockfile -# - run: yarn prepare && yarn release -# env: -# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/COMMITTERS.md b/COMMITTERS.md new file mode 100644 index 0000000000000000000000000000000000000000..093caa50b3983fe553009d7ddab1d582f9593a7e --- /dev/null +++ b/COMMITTERS.md @@ -0,0 +1,10 @@ +## Committers列表 + +### 以下是此项目的committer人员 +不区分先后顺序 + +- [MaDiXin](https://gitee.com/MaDiXin) +- [xiafeng_xf_admin](https://gitee.com/xiafeng_xf_admin) +- [chenLixi](https://gitee.com/Louis-C7) +- [LinJiacheng](https://gitee.com/LLLLLLin) +- [ZhengJinshou](https://gitee.com/longziz) diff --git a/OAT.xml b/OAT.xml new file mode 100644 index 0000000000000000000000000000000000000000..3fbce46e312c6694a42f7cd76803244562d1945a --- /dev/null +++ b/OAT.xml @@ -0,0 +1,60 @@ + + + + LICENSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/README.OpenSource b/README.OpenSource new file mode 100644 index 0000000000000000000000000000000000000000..2870dd0517d4c553a3f0b87054981cbfad6c7d5d --- /dev/null +++ b/README.OpenSource @@ -0,0 +1,13 @@ +[ + { + "Name": "react-native-document-picker", + "License": "MIT License", + "License File": "https://github.com/react-native-documents/document-picker/blob/master/LICENSE.md", + "Version Number": "9.2.1", + "Owner" : "xiafeng@huawei.com", + "Upstream URL": "https://github.com/react-native-documents/document-picker", + "Description": "A file selection library in React Native" + } +] + + diff --git a/android/build.gradle b/android/build.gradle deleted file mode 100644 index fd24a6ec7d86eef36de92be375b6aa0f275c45bb..0000000000000000000000000000000000000000 --- a/android/build.gradle +++ /dev/null @@ -1,66 +0,0 @@ -buildscript { - repositories { - google() - mavenCentral() - } -} - -def getExtOrIntegerDefault(name) { - return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties['ReactNativeDocumentPicker_' + name]).toInteger() -} - -def isNewArchitectureEnabled() { - // To opt-in for the New Architecture, you can either: - // - Set `newArchEnabled` to true inside the `gradle.properties` file - // - Invoke gradle with `-newArchEnabled=true` - // - Set an environment variable `ORG_GRADLE_PROJECT_newArchEnabled=true` - return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true" -} - -apply plugin: 'com.android.library' -if (isNewArchitectureEnabled()) { - apply plugin: "com.facebook.react" -} - - -android { - def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION - if (agpVersion.tokenize('.')[0].toInteger() >= 7) { - namespace "com.reactnativedocumentpicker" - } - compileSdkVersion getExtOrIntegerDefault('compileSdkVersion') - - // Used to override the NDK path/version on internal CI or by allowing - // users to customize the NDK path/version from their root project (e.g. for M1 support) - if (rootProject.hasProperty("ndkPath")) { - ndkPath rootProject.ext.ndkPath - } - if (rootProject.hasProperty("ndkVersion")) { - ndkVersion rootProject.ext.ndkVersion - } - - defaultConfig { - minSdkVersion getExtOrIntegerDefault('minSdkVersion') - targetSdkVersion getExtOrIntegerDefault('targetSdkVersion') - buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString() - } - - sourceSets.main { - java { - if (!isNewArchitectureEnabled()) { - srcDirs += 'src/paper/java' - } - } - } -} - -repositories { - google() - mavenLocal() - mavenCentral() -} - -dependencies { - //noinspection GradleDynamicVersion - implementation 'com.facebook.react:react-native:+' // from node_modules -} diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml deleted file mode 100644 index f2855c8df090a321996650dc89d78d305b645346..0000000000000000000000000000000000000000 --- a/android/src/main/AndroidManifest.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - diff --git a/android/src/main/java/com/reactnativedocumentpicker/RNDocumentPickerModule.java b/android/src/main/java/com/reactnativedocumentpicker/RNDocumentPickerModule.java deleted file mode 100644 index 5001525e27475858fe60cbdf77c5c62ff52a92ae..0000000000000000000000000000000000000000 --- a/android/src/main/java/com/reactnativedocumentpicker/RNDocumentPickerModule.java +++ /dev/null @@ -1,361 +0,0 @@ -package com.reactnativedocumentpicker; - -import android.app.Activity; -import android.content.ActivityNotFoundException; -import android.content.ClipData; -import android.content.ContentResolver; -import android.content.Context; -import android.content.Intent; -import android.database.Cursor; -import android.net.Uri; -import android.os.Bundle; -import android.provider.DocumentsContract; -import android.provider.OpenableColumns; -import android.util.Log; - -import androidx.annotation.NonNull; - -import com.facebook.react.bridge.ActivityEventListener; -import com.facebook.react.bridge.Arguments; -import com.facebook.react.bridge.BaseActivityEventListener; -import com.facebook.react.bridge.GuardedResultAsyncTask; -import com.facebook.react.bridge.Promise; -import com.facebook.react.bridge.ReactApplicationContext; -import com.facebook.react.bridge.ReactContext; -import com.facebook.react.bridge.ReactMethod; -import com.facebook.react.bridge.ReadableArray; -import com.facebook.react.bridge.ReadableMap; -import com.facebook.react.bridge.WritableArray; -import com.facebook.react.bridge.WritableMap; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.lang.ref.WeakReference; -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; - -public class RNDocumentPickerModule extends NativeDocumentPickerSpec { - public static final String NAME = "RNDocumentPicker"; - private static final int READ_REQUEST_CODE = 41; - private static final int PICK_DIR_REQUEST_CODE = 42; - - 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"; - - private static final String OPTION_TYPE = "type"; - private static final String OPTION_MULTIPLE = "allowMultiSelection"; - private static final String OPTION_COPY_TO = "copyTo"; - - private static final String FIELD_URI = "uri"; - private static final String FIELD_FILE_COPY_URI = "fileCopyUri"; - private static final String FIELD_COPY_ERROR = "copyError"; - private static final String FIELD_NAME = "name"; - private static final String FIELD_TYPE = "type"; - private static final String FIELD_SIZE = "size"; - - private Promise promise; - private String copyTo; - - public RNDocumentPickerModule(ReactApplicationContext reactContext) { - super(reactContext); - reactContext.addActivityEventListener(activityEventListener); - } - - private final ActivityEventListener activityEventListener = new BaseActivityEventListener() { - @Override - public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data) { - boolean isForeignResult = requestCode != READ_REQUEST_CODE && requestCode != PICK_DIR_REQUEST_CODE; - if (isForeignResult) { - return; - } - final Promise storedPromise = promise; - if (storedPromise == null) { - Log.e(NAME, "promise was null in onActivityResult"); - return; - } - if (resultCode == Activity.RESULT_CANCELED) { - sendError(E_DOCUMENT_PICKER_CANCELED, "User canceled directory picker"); - return; - } - if (requestCode == READ_REQUEST_CODE) { - onShowActivityResult(resultCode, data, storedPromise); - } else { - onPickDirectoryResult(resultCode, data); - } - } - }; - - private String[] readableArrayToStringArray(ReadableArray readableArray) { - int size = readableArray.size(); - String[] array = new String[size]; - for (int i = 0; i < size; ++i) { - array[i] = readableArray.getString(i); - } - return array; - } - - @Override - public void invalidate() { - getReactApplicationContext().removeActivityEventListener(activityEventListener); - super.invalidate(); - } - - @NonNull - @Override - public String getName() { - return NAME; - } - - @ReactMethod - public void pick(ReadableMap args, Promise promise) { - Activity currentActivity = getCurrentActivity(); - this.promise = promise; - this.copyTo = args.hasKey(OPTION_COPY_TO) ? args.getString(OPTION_COPY_TO) : null; - - if (currentActivity == null) { - sendError(E_ACTIVITY_DOES_NOT_EXIST, "Current activity does not exist"); - return; - } - - try { - Intent intent = new Intent(Intent.ACTION_GET_CONTENT); - intent.addCategory(Intent.CATEGORY_OPENABLE); - - intent.setType("*/*"); - if (!args.isNull(OPTION_TYPE)) { - ReadableArray types = args.getArray(OPTION_TYPE); - if (types != null) { - if (types.size() > 1) { - String[] mimeTypes = readableArrayToStringArray(types); - intent.putExtra(Intent.EXTRA_MIME_TYPES, mimeTypes); - intent.setType(String.join("|",mimeTypes)); - } else if (types.size() == 1) { - intent.setType(types.getString(0)); - } - } - } - - boolean multiple = !args.isNull(OPTION_MULTIPLE) && args.getBoolean(OPTION_MULTIPLE); - intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, multiple); - - currentActivity.startActivityForResult(intent, READ_REQUEST_CODE, Bundle.EMPTY); - } catch (ActivityNotFoundException e) { - sendError(E_UNABLE_TO_OPEN_FILE_TYPE, e.getLocalizedMessage()); - } catch (Exception e) { - e.printStackTrace(); - sendError(E_FAILED_TO_SHOW_PICKER, e.getLocalizedMessage()); - } - } - - @ReactMethod - public void pickDirectory(Promise promise) { - Activity currentActivity = getCurrentActivity(); - - if (currentActivity == null) { - promise.reject(E_ACTIVITY_DOES_NOT_EXIST, "Current activity does not exist"); - return; - } - this.promise = promise; - try { - Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE); - currentActivity.startActivityForResult(intent, PICK_DIR_REQUEST_CODE, null); - } catch (Exception e) { - sendError(E_FAILED_TO_SHOW_PICKER, "Failed to create directory picker", e); - } - } - - @Override - public void releaseSecureAccess(ReadableArray uris, Promise promise) { - promise.reject("RNDocumentPicker:releaseSecureAccess", "releaseSecureAccess is not supported on Android"); - } - - private void onPickDirectoryResult(int resultCode, Intent data) { - if (resultCode != Activity.RESULT_OK) { - sendError(E_UNKNOWN_ACTIVITY_RESULT, "Unknown activity result: " + resultCode); - return; - } - - if (data == null || data.getData() == null) { - sendError(E_INVALID_DATA_RETURNED, "Invalid data returned by intent"); - return; - } - Uri uri = data.getData(); - - WritableMap map = Arguments.createMap(); - map.putString(FIELD_URI, uri.toString()); - promise.resolve(map); - } - - public void onShowActivityResult(int resultCode, Intent data, Promise promise) { - if (resultCode != Activity.RESULT_OK) { - sendError(E_UNKNOWN_ACTIVITY_RESULT, "Unknown activity result: " + resultCode); - return; - } - Uri uri = null; - ClipData clipData = null; - - if (data != null) { - uri = data.getData(); - clipData = data.getClipData(); - } - - try { - List uris = new ArrayList<>(); - // condition order seems to matter: https://github.com/rnmods/react-native-document-picker/issues/317#issuecomment-645222635 - if (clipData != null && clipData.getItemCount() > 0) { - final int length = clipData.getItemCount(); - for (int i = 0; i < length; ++i) { - ClipData.Item item = clipData.getItemAt(i); - uris.add(item.getUri()); - } - } else if (uri != null) { - uris.add(uri); - } else { - sendError(E_INVALID_DATA_RETURNED, "Invalid data returned by intent"); - return; - } - - new ProcessDataTask(getReactApplicationContext(), uris, copyTo, promise).execute(); - } catch (Exception e) { - sendError(E_UNEXPECTED_EXCEPTION, e.getLocalizedMessage(), e); - } - } - - private static class ProcessDataTask extends GuardedResultAsyncTask { - private final WeakReference weakContext; - private final List uris; - private final String copyTo; - private final Promise promise; - - protected ProcessDataTask(ReactContext reactContext, List uris, String copyTo, Promise promise) { - super(reactContext.getExceptionHandler()); - this.weakContext = new WeakReference<>(reactContext.getApplicationContext()); - this.uris = uris; - this.copyTo = copyTo; - this.promise = promise; - } - - @Override - protected ReadableArray doInBackgroundGuarded() { - WritableArray results = Arguments.createArray(); - for (Uri uri : uris) { - results.pushMap(getMetadata(uri)); - } - return results; - } - - @Override - protected void onPostExecuteGuarded(ReadableArray readableArray) { - promise.resolve(readableArray); - } - - private WritableMap getMetadata(Uri uri) { - Context context = weakContext.get(); - if (context == null) { - return Arguments.createMap(); - } - ContentResolver contentResolver = context.getContentResolver(); - WritableMap map = Arguments.createMap(); - map.putString(FIELD_URI, uri.toString()); - map.putString(FIELD_TYPE, contentResolver.getType(uri)); - try (Cursor cursor = contentResolver.query(uri, null, null, null, null, null)) { - if (cursor != null && cursor.moveToFirst()) { - int displayNameIndex = cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME); - if (!cursor.isNull(displayNameIndex)) { - String fileName = cursor.getString(displayNameIndex); - map.putString(FIELD_NAME, fileName); - } else { - map.putNull(FIELD_NAME); - } - int mimeIndex = cursor.getColumnIndex(DocumentsContract.Document.COLUMN_MIME_TYPE); - if (!cursor.isNull(mimeIndex)) { - map.putString(FIELD_TYPE, cursor.getString(mimeIndex)); - } - int sizeIndex = cursor.getColumnIndex(OpenableColumns.SIZE); - if (cursor.isNull(sizeIndex)) { - map.putNull(FIELD_SIZE); - } else { - map.putDouble(FIELD_SIZE, cursor.getLong(sizeIndex)); - } - } - } - - prepareFileUri(context, map, uri); - return map; - } - - private void prepareFileUri(Context context, WritableMap map, Uri uri) { - if (copyTo == null) { - map.putNull(FIELD_FILE_COPY_URI); - } else { - copyFileToLocalStorage(context, map, uri); - } - } - - private void copyFileToLocalStorage(Context context, WritableMap map, Uri uri) { - File dir = context.getCacheDir(); - if (copyTo.equals("documentDirectory")) { - dir = context.getFilesDir(); - } - // we don't want to rename the file so we put it into a unique location - dir = new File(dir, UUID.randomUUID().toString()); - try { - boolean didCreateDir = dir.mkdir(); - if (!didCreateDir) { - throw new IOException("failed to create directory at " + dir.getAbsolutePath()); - } - String fileName = map.getString(FIELD_NAME); - if (fileName == null) { - fileName = String.valueOf(System.currentTimeMillis()); - } - File destFile = safeGetDestination(new File(dir, fileName), dir.getCanonicalPath()); - Uri copyPath = copyFile(context, uri, destFile); - map.putString(FIELD_FILE_COPY_URI, copyPath.toString()); - } catch (Exception e) { - e.printStackTrace(); - map.putNull(FIELD_FILE_COPY_URI); - map.putString(FIELD_COPY_ERROR, e.getLocalizedMessage()); - } - } - - public File safeGetDestination(File destFile, String expectedDir) throws IllegalArgumentException, IOException { - String canonicalPath = destFile.getCanonicalPath(); - if (!canonicalPath.startsWith(expectedDir)) { - throw new IllegalArgumentException("The copied file is attempting to write outside of the target directory."); - } - return destFile; - } - - public static Uri copyFile(Context context, Uri uri, File destFile) throws IOException { - try(InputStream inputStream = context.getContentResolver().openInputStream(uri); - FileOutputStream outputStream = new FileOutputStream(destFile)) { - byte[] buf = new byte[8192]; - int len; - while ((len = inputStream.read(buf)) > 0) { - outputStream.write(buf, 0, len); - } - return Uri.fromFile(destFile); - } - } - } - - private void sendError(String code, String message) { - sendError(code, message, null); - } - - private void sendError(String code, String message, Exception e) { - Promise temp = this.promise; - if (temp != null) { - this.promise = null; - temp.reject(code, message, e); - } - } -} diff --git a/android/src/main/java/com/reactnativedocumentpicker/RNDocumentPickerPackage.java b/android/src/main/java/com/reactnativedocumentpicker/RNDocumentPickerPackage.java deleted file mode 100644 index 3aaa938a01617d326ec2074ac70446d72aab25d6..0000000000000000000000000000000000000000 --- a/android/src/main/java/com/reactnativedocumentpicker/RNDocumentPickerPackage.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.reactnativedocumentpicker; - -import androidx.annotation.Nullable; - -import com.facebook.react.TurboReactPackage; -import com.facebook.react.bridge.NativeModule; -import com.facebook.react.bridge.ReactApplicationContext; -import com.facebook.react.module.model.ReactModuleInfo; -import com.facebook.react.module.model.ReactModuleInfoProvider; - -import java.util.HashMap; -import java.util.Map; - -public class RNDocumentPickerPackage extends TurboReactPackage { - - @Nullable - @Override - public NativeModule getModule(String name, ReactApplicationContext reactContext) { - if (name.equals(RNDocumentPickerModule.NAME)) { - return new RNDocumentPickerModule(reactContext); - } else { - return null; - } - } - - @Override - public ReactModuleInfoProvider getReactModuleInfoProvider() { - return () -> { - boolean isTurboModule = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED; - final Map moduleInfos = new HashMap<>(); - moduleInfos.put( - RNDocumentPickerModule.NAME, - new ReactModuleInfo( - RNDocumentPickerModule.NAME, - RNDocumentPickerModule.NAME, -// "DocumentPickerModule", - false, // canOverrideExistingModule - false, // needsEagerInit - true, // hasConstants - false, // isCxxModule - isTurboModule // isTurboModule - )); - return moduleInfos; - }; - } -} diff --git a/android/src/paper/java/com/reactnativedocumentpicker/NativeDocumentPickerSpec.java b/android/src/paper/java/com/reactnativedocumentpicker/NativeDocumentPickerSpec.java deleted file mode 100644 index 76323fa15f5a47c6ff0d9732a6ad8c5a6666f2d7..0000000000000000000000000000000000000000 --- a/android/src/paper/java/com/reactnativedocumentpicker/NativeDocumentPickerSpec.java +++ /dev/null @@ -1,41 +0,0 @@ - -/** - * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). - * - * Then it was commited. It is here to support the old architecture. - * If you use the new architecture, this file won't be included and instead will be generated by the codegen. - * - * @generated by codegen project: GenerateModuleJavaSpec.js - * - * @nolint - */ - -package com.reactnativedocumentpicker; - -import com.facebook.proguard.annotations.DoNotStrip; -import com.facebook.react.bridge.Promise; -import com.facebook.react.bridge.ReactApplicationContext; -import com.facebook.react.bridge.ReactContextBaseJavaModule; -import com.facebook.react.bridge.ReactMethod; -import com.facebook.react.bridge.ReactModuleWithSpec; -import com.facebook.react.bridge.ReadableArray; -import com.facebook.react.bridge.ReadableMap; -import com.facebook.react.turbomodule.core.interfaces.TurboModule; - -public abstract class NativeDocumentPickerSpec extends ReactContextBaseJavaModule implements ReactModuleWithSpec, TurboModule { - public NativeDocumentPickerSpec(ReactApplicationContext reactContext) { - super(reactContext); - } - - @ReactMethod - @DoNotStrip - public abstract void pick(ReadableMap options, Promise promise); - - @ReactMethod - @DoNotStrip - public abstract void releaseSecureAccess(ReadableArray uris, Promise promise); - - @ReactMethod - @DoNotStrip - public abstract void pickDirectory(Promise promise); -} diff --git a/docs/android_screenshot.jpg b/docs/android_screenshot.jpg deleted file mode 100644 index 47ec5611dcc7e397cd7661756d8d641658656356..0000000000000000000000000000000000000000 Binary files a/docs/android_screenshot.jpg and /dev/null differ diff --git a/docs/ios_screenshot.jpeg b/docs/ios_screenshot.jpeg deleted file mode 100644 index 4f37cc44c0c2cf517aa6a31174623d98882940c6..0000000000000000000000000000000000000000 Binary files a/docs/ios_screenshot.jpeg and /dev/null differ diff --git a/example/.gitignore b/example/.gitignore deleted file mode 100644 index 7a6efe5dde4f327cac6424a127e712b88ec257c1..0000000000000000000000000000000000000000 --- a/example/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -*.binlog -*.hprof -*.xcworkspace/ -*.zip -.DS_Store -.gradle/ -.idea/ -.vs/ -Pods/ -build/ -dist/ -local.properties -msbuild.binlog -node_modules/ diff --git a/example/.watchmanconfig b/example/.watchmanconfig deleted file mode 100644 index 9e26dfeeb6e641a33dae4961196235bdb965b21b..0000000000000000000000000000000000000000 --- a/example/.watchmanconfig +++ /dev/null @@ -1 +0,0 @@ -{} \ No newline at end of file diff --git a/example/App.tsx b/example/App.tsx deleted file mode 100644 index 84dd3a2dd345a44d7911767cf5b729d322eb498a..0000000000000000000000000000000000000000 --- a/example/App.tsx +++ /dev/null @@ -1,110 +0,0 @@ -import * as React from 'react' - -import { StyleSheet, View, Text, Button } from 'react-native' -import DocumentPicker, { - DirectoryPickerResponse, - DocumentPickerResponse, - isCancel, - isInProgress, - types, -} from 'react-native-document-picker' -import { useEffect } from 'react' - -export default function App() { - const [result, setResult] = React.useState< - Array | DirectoryPickerResponse | undefined | null - >() - - useEffect(() => { - console.log(JSON.stringify(result, null, 2)) - }, [result]) - - const handleError = (err: unknown) => { - if (isCancel(err)) { - console.warn('cancelled') - // User cancelled the picker, exit any dialogs or menus and move on - } else if (isInProgress(err)) { - console.warn('multiple pickers were opened, only the last will be considered') - } else { - throw err - } - } - - return ( - -