From 42face1a645daef2673d60810094a0c57cc6455e Mon Sep 17 00:00:00 2001 From: Pixo Date: Mon, 3 Jul 2023 11:53:15 +0200 Subject: [PATCH] Add saveFileToDownloads method --- android/build.gradle | 2 +- .../com/internxt/mobilesdk/MobileSdkModule.kt | 13 +- .../internxt/mobilesdk/services/FileSystem.kt | 72 +- example/input.css | 1 + .../project.pbxproj | 6 +- .../contents.xcworkspacedata | 10 + example/ios/Podfile.lock | 635 ++ example/package.json | 9 +- example/src/App.tsx | 96 +- .../components/Playground/PlaygroundCase.tsx | 44 + example/tailwind.config.js | 226 + example/tailwind.css | 117 + example/tailwind.json | 153 + example/yarn.lock | 8313 +++++++++-------- package.json | 2 +- src/index.tsx | 2 + src/nativeSdk.ts | 4 + tsconfig.json | 3 +- 18 files changed, 5867 insertions(+), 3841 deletions(-) create mode 100644 example/input.css create mode 100644 example/ios/MobileSdkExample.xcworkspace/contents.xcworkspacedata create mode 100644 example/ios/Podfile.lock create mode 100644 example/src/components/Playground/PlaygroundCase.tsx create mode 100644 example/tailwind.config.js create mode 100644 example/tailwind.css create mode 100644 example/tailwind.json diff --git a/android/build.gradle b/android/build.gradle index 8cdef4d..8416bfb 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -84,7 +84,7 @@ dependencies { //noinspection GradleDynamicVersion implementation("androidx.work:work-runtime:$work_version") implementation("androidx.work:work-runtime-ktx:$work_version") - implementation 'com.facebook.react:react-native:0.70.0' + implementation 'com.facebook.react:react-native:+' implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" implementation "com.madgag.spongycastle:bcpkix-jdk15on:$spongycastle_version" implementation "com.madgag.spongycastle:bcpg-jdk15on:$spongycastle_version" diff --git a/android/src/main/java/com/internxt/mobilesdk/MobileSdkModule.kt b/android/src/main/java/com/internxt/mobilesdk/MobileSdkModule.kt index f448b2c..67918fa 100644 --- a/android/src/main/java/com/internxt/mobilesdk/MobileSdkModule.kt +++ b/android/src/main/java/com/internxt/mobilesdk/MobileSdkModule.kt @@ -214,10 +214,21 @@ class MobileSdkModule(val reactContext: ReactApplicationContext) : } catch (e: Exception) { e.printStackTrace() - // To late to reject, we only enqueue the job + // Too late to reject, we only enqueue the job } } + @ReactMethod + fun saveToDownloads(originUri: String, promise: Promise) { + try { + FS.saveFileToDownloadsDirectory(reactApplicationContext, originUri) + } catch (exception: Exception) { + exception.printStackTrace() + promise.reject(exception) + } + + } + companion object { const val NAME = "MobileSdk" diff --git a/android/src/main/java/com/internxt/mobilesdk/services/FileSystem.kt b/android/src/main/java/com/internxt/mobilesdk/services/FileSystem.kt index 0032be9..a819a20 100644 --- a/android/src/main/java/com/internxt/mobilesdk/services/FileSystem.kt +++ b/android/src/main/java/com/internxt/mobilesdk/services/FileSystem.kt @@ -1,10 +1,17 @@ package com.internxt.mobilesdk.services +import android.content.ContentResolver +import android.content.ContentValues import android.net.Uri +import android.os.Build +import android.os.Environment +import android.provider.MediaStore +import android.webkit.MimeTypeMap +import com.facebook.react.bridge.ReactApplicationContext import com.internxt.mobilesdk.utils.FileAccessRejectionException -import java.io.BufferedReader -import java.io.File -import java.io.FileReader -import java.io.IOException +import java.io.* +import com.internxt.mobilesdk.utils.Logger +import kotlin.io.path.Path + // This class is called FS to avoid naming conflicts with Java FileSystem class object FS { @@ -84,4 +91,61 @@ object FS { return true } } + + + @Throws(NoSuchFileException::class, FileAlreadyExistsException::class, IOException::class) + fun saveFileToDownloadsDirectory(context: ReactApplicationContext, originalFilePath: String) { + val filename = originalFilePath.substring(originalFilePath.lastIndexOf(File.separator)); + val fileInputStream: InputStream = + context.contentResolver.openInputStream(getFileUri(originalFilePath, true)) + ?: throw Exception("Cannot open Input stream at path $originalFilePath") + + + if (false && Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { + + val contentValues = ContentValues(); + + contentValues.put(MediaStore.MediaColumns.DISPLAY_NAME, filename); + val mimeType = getMimeType(context.contentResolver, originalFilePath) + Logger.info("Mime type") + if (mimeType != null) { + Logger.info(mimeType) + } else { + Logger.info("No mime") + } + contentValues.put(MediaStore.MediaColumns.MIME_TYPE, mimeType); + contentValues.put(MediaStore.MediaColumns.RELATIVE_PATH, Environment.DIRECTORY_DOWNLOADS); + context.contentResolver.insert(MediaStore.Downloads.EXTERNAL_CONTENT_URI, contentValues) + ?: throw Exception("FileUri not inserted in content resolver"); + + Logger.info("File inserted in content database") + } + + val buffer = ByteArray(8 * 1024) // 8KB buffer + var bytesRead: Int + + val downloadsDir = + Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).toString() + + val destination = File(downloadsDir, filename) + val outputStream = FileOutputStream(destination) + + try { + while (fileInputStream.read(buffer).also { bytesRead = it } != -1) { + outputStream.write(buffer, 0, bytesRead) + } + } catch (e: IOException) { + e.printStackTrace() + } finally { + fileInputStream.close() + outputStream.close() + } + + Logger.info("Closed stream") + + } + + fun getMimeType(contentResolver: ContentResolver, uri: String): String? { + return contentResolver.getType(getFileUri(uri, true)) + } } diff --git a/example/input.css b/example/input.css new file mode 100644 index 0000000..7b24fe3 --- /dev/null +++ b/example/input.css @@ -0,0 +1 @@ +@tailwind utilities \ No newline at end of file diff --git a/example/ios/MobileSdkExample.xcodeproj/project.pbxproj b/example/ios/MobileSdkExample.xcodeproj/project.pbxproj index 87561de..b0d524f 100644 --- a/example/ios/MobileSdkExample.xcodeproj/project.pbxproj +++ b/example/ios/MobileSdkExample.xcodeproj/project.pbxproj @@ -564,7 +564,7 @@ COPY_PHASE_STRIP = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; - "EXCLUDED_ARCHS[sdk=iphonesimulator*]" = ""; + "EXCLUDED_ARCHS[sdk=iphonesimulator*]" = i386; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; GCC_NO_COMMON_BLOCKS = YES; @@ -598,6 +598,7 @@ "-DFOLLY_MOBILE=1", "-DFOLLY_USE_LIBCPP=1", ); + REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native"; SDKROOT = iphoneos; }; name = Debug; @@ -635,7 +636,7 @@ COPY_PHASE_STRIP = YES; ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; - "EXCLUDED_ARCHS[sdk=iphonesimulator*]" = ""; + "EXCLUDED_ARCHS[sdk=iphonesimulator*]" = i386; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_NO_COMMON_BLOCKS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; @@ -661,6 +662,7 @@ "-DFOLLY_MOBILE=1", "-DFOLLY_USE_LIBCPP=1", ); + REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native"; SDKROOT = iphoneos; VALIDATE_PRODUCT = YES; }; diff --git a/example/ios/MobileSdkExample.xcworkspace/contents.xcworkspacedata b/example/ios/MobileSdkExample.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..be6b81e --- /dev/null +++ b/example/ios/MobileSdkExample.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,10 @@ + + + + + + + diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock new file mode 100644 index 0000000..1cb99eb --- /dev/null +++ b/example/ios/Podfile.lock @@ -0,0 +1,635 @@ +PODS: + - boost (1.76.0) + - CocoaAsyncSocket (7.6.5) + - DoubleConversion (1.1.6) + - FBLazyVector (0.71.4) + - FBReactNativeSpec (0.71.4): + - RCT-Folly (= 2021.07.22.00) + - RCTRequired (= 0.71.4) + - RCTTypeSafety (= 0.71.4) + - React-Core (= 0.71.4) + - React-jsi (= 0.71.4) + - ReactCommon/turbomodule/core (= 0.71.4) + - Flipper (0.125.0): + - Flipper-Folly (~> 2.6) + - Flipper-RSocket (~> 1.4) + - Flipper-Boost-iOSX (1.76.0.1.11) + - Flipper-DoubleConversion (3.2.0.1) + - Flipper-Fmt (7.1.7) + - Flipper-Folly (2.6.10): + - Flipper-Boost-iOSX + - Flipper-DoubleConversion + - Flipper-Fmt (= 7.1.7) + - Flipper-Glog + - libevent (~> 2.1.12) + - OpenSSL-Universal (= 1.1.1100) + - Flipper-Glog (0.5.0.5) + - Flipper-PeerTalk (0.0.4) + - Flipper-RSocket (1.4.3): + - Flipper-Folly (~> 2.6) + - FlipperKit (0.125.0): + - FlipperKit/Core (= 0.125.0) + - FlipperKit/Core (0.125.0): + - Flipper (~> 0.125.0) + - FlipperKit/CppBridge + - FlipperKit/FBCxxFollyDynamicConvert + - FlipperKit/FBDefines + - FlipperKit/FKPortForwarding + - SocketRocket (~> 0.6.0) + - FlipperKit/CppBridge (0.125.0): + - Flipper (~> 0.125.0) + - FlipperKit/FBCxxFollyDynamicConvert (0.125.0): + - Flipper-Folly (~> 2.6) + - FlipperKit/FBDefines (0.125.0) + - FlipperKit/FKPortForwarding (0.125.0): + - CocoaAsyncSocket (~> 7.6) + - Flipper-PeerTalk (~> 0.0.4) + - FlipperKit/FlipperKitHighlightOverlay (0.125.0) + - FlipperKit/FlipperKitLayoutHelpers (0.125.0): + - FlipperKit/Core + - FlipperKit/FlipperKitHighlightOverlay + - FlipperKit/FlipperKitLayoutTextSearchable + - FlipperKit/FlipperKitLayoutIOSDescriptors (0.125.0): + - FlipperKit/Core + - FlipperKit/FlipperKitHighlightOverlay + - FlipperKit/FlipperKitLayoutHelpers + - YogaKit (~> 1.18) + - FlipperKit/FlipperKitLayoutPlugin (0.125.0): + - FlipperKit/Core + - FlipperKit/FlipperKitHighlightOverlay + - FlipperKit/FlipperKitLayoutHelpers + - FlipperKit/FlipperKitLayoutIOSDescriptors + - FlipperKit/FlipperKitLayoutTextSearchable + - YogaKit (~> 1.18) + - FlipperKit/FlipperKitLayoutTextSearchable (0.125.0) + - FlipperKit/FlipperKitNetworkPlugin (0.125.0): + - FlipperKit/Core + - FlipperKit/FlipperKitReactPlugin (0.125.0): + - FlipperKit/Core + - FlipperKit/FlipperKitUserDefaultsPlugin (0.125.0): + - FlipperKit/Core + - FlipperKit/SKIOSNetworkPlugin (0.125.0): + - FlipperKit/Core + - FlipperKit/FlipperKitNetworkPlugin + - fmt (6.2.1) + - glog (0.3.5) + - hermes-engine (0.71.4): + - hermes-engine/Pre-built (= 0.71.4) + - hermes-engine/Pre-built (0.71.4) + - internxt-mobile-sdk (0.1.52): + - React-Core + - libevent (2.1.12) + - OpenSSL-Universal (1.1.1100) + - RCT-Folly (2021.07.22.00): + - boost + - DoubleConversion + - fmt (~> 6.2.1) + - glog + - RCT-Folly/Default (= 2021.07.22.00) + - RCT-Folly/Default (2021.07.22.00): + - boost + - DoubleConversion + - fmt (~> 6.2.1) + - glog + - RCT-Folly/Futures (2021.07.22.00): + - boost + - DoubleConversion + - fmt (~> 6.2.1) + - glog + - libevent + - RCTRequired (0.71.4) + - RCTTypeSafety (0.71.4): + - FBLazyVector (= 0.71.4) + - RCTRequired (= 0.71.4) + - React-Core (= 0.71.4) + - React (0.71.4): + - React-Core (= 0.71.4) + - React-Core/DevSupport (= 0.71.4) + - React-Core/RCTWebSocket (= 0.71.4) + - React-RCTActionSheet (= 0.71.4) + - React-RCTAnimation (= 0.71.4) + - React-RCTBlob (= 0.71.4) + - React-RCTImage (= 0.71.4) + - React-RCTLinking (= 0.71.4) + - React-RCTNetwork (= 0.71.4) + - React-RCTSettings (= 0.71.4) + - React-RCTText (= 0.71.4) + - React-RCTVibration (= 0.71.4) + - React-callinvoker (0.71.4) + - React-Codegen (0.71.4): + - FBReactNativeSpec + - hermes-engine + - RCT-Folly + - RCTRequired + - RCTTypeSafety + - React-Core + - React-jsi + - React-jsiexecutor + - ReactCommon/turbomodule/bridging + - ReactCommon/turbomodule/core + - React-Core (0.71.4): + - glog + - hermes-engine + - RCT-Folly (= 2021.07.22.00) + - React-Core/Default (= 0.71.4) + - React-cxxreact (= 0.71.4) + - React-hermes + - React-jsi (= 0.71.4) + - React-jsiexecutor (= 0.71.4) + - React-perflogger (= 0.71.4) + - Yoga + - React-Core/CoreModulesHeaders (0.71.4): + - glog + - hermes-engine + - RCT-Folly (= 2021.07.22.00) + - React-Core/Default + - React-cxxreact (= 0.71.4) + - React-hermes + - React-jsi (= 0.71.4) + - React-jsiexecutor (= 0.71.4) + - React-perflogger (= 0.71.4) + - Yoga + - React-Core/Default (0.71.4): + - glog + - hermes-engine + - RCT-Folly (= 2021.07.22.00) + - React-cxxreact (= 0.71.4) + - React-hermes + - React-jsi (= 0.71.4) + - React-jsiexecutor (= 0.71.4) + - React-perflogger (= 0.71.4) + - Yoga + - React-Core/DevSupport (0.71.4): + - glog + - hermes-engine + - RCT-Folly (= 2021.07.22.00) + - React-Core/Default (= 0.71.4) + - React-Core/RCTWebSocket (= 0.71.4) + - React-cxxreact (= 0.71.4) + - React-hermes + - React-jsi (= 0.71.4) + - React-jsiexecutor (= 0.71.4) + - React-jsinspector (= 0.71.4) + - React-perflogger (= 0.71.4) + - Yoga + - React-Core/RCTActionSheetHeaders (0.71.4): + - glog + - hermes-engine + - RCT-Folly (= 2021.07.22.00) + - React-Core/Default + - React-cxxreact (= 0.71.4) + - React-hermes + - React-jsi (= 0.71.4) + - React-jsiexecutor (= 0.71.4) + - React-perflogger (= 0.71.4) + - Yoga + - React-Core/RCTAnimationHeaders (0.71.4): + - glog + - hermes-engine + - RCT-Folly (= 2021.07.22.00) + - React-Core/Default + - React-cxxreact (= 0.71.4) + - React-hermes + - React-jsi (= 0.71.4) + - React-jsiexecutor (= 0.71.4) + - React-perflogger (= 0.71.4) + - Yoga + - React-Core/RCTBlobHeaders (0.71.4): + - glog + - hermes-engine + - RCT-Folly (= 2021.07.22.00) + - React-Core/Default + - React-cxxreact (= 0.71.4) + - React-hermes + - React-jsi (= 0.71.4) + - React-jsiexecutor (= 0.71.4) + - React-perflogger (= 0.71.4) + - Yoga + - React-Core/RCTImageHeaders (0.71.4): + - glog + - hermes-engine + - RCT-Folly (= 2021.07.22.00) + - React-Core/Default + - React-cxxreact (= 0.71.4) + - React-hermes + - React-jsi (= 0.71.4) + - React-jsiexecutor (= 0.71.4) + - React-perflogger (= 0.71.4) + - Yoga + - React-Core/RCTLinkingHeaders (0.71.4): + - glog + - hermes-engine + - RCT-Folly (= 2021.07.22.00) + - React-Core/Default + - React-cxxreact (= 0.71.4) + - React-hermes + - React-jsi (= 0.71.4) + - React-jsiexecutor (= 0.71.4) + - React-perflogger (= 0.71.4) + - Yoga + - React-Core/RCTNetworkHeaders (0.71.4): + - glog + - hermes-engine + - RCT-Folly (= 2021.07.22.00) + - React-Core/Default + - React-cxxreact (= 0.71.4) + - React-hermes + - React-jsi (= 0.71.4) + - React-jsiexecutor (= 0.71.4) + - React-perflogger (= 0.71.4) + - Yoga + - React-Core/RCTSettingsHeaders (0.71.4): + - glog + - hermes-engine + - RCT-Folly (= 2021.07.22.00) + - React-Core/Default + - React-cxxreact (= 0.71.4) + - React-hermes + - React-jsi (= 0.71.4) + - React-jsiexecutor (= 0.71.4) + - React-perflogger (= 0.71.4) + - Yoga + - React-Core/RCTTextHeaders (0.71.4): + - glog + - hermes-engine + - RCT-Folly (= 2021.07.22.00) + - React-Core/Default + - React-cxxreact (= 0.71.4) + - React-hermes + - React-jsi (= 0.71.4) + - React-jsiexecutor (= 0.71.4) + - React-perflogger (= 0.71.4) + - Yoga + - React-Core/RCTVibrationHeaders (0.71.4): + - glog + - hermes-engine + - RCT-Folly (= 2021.07.22.00) + - React-Core/Default + - React-cxxreact (= 0.71.4) + - React-hermes + - React-jsi (= 0.71.4) + - React-jsiexecutor (= 0.71.4) + - React-perflogger (= 0.71.4) + - Yoga + - React-Core/RCTWebSocket (0.71.4): + - glog + - hermes-engine + - RCT-Folly (= 2021.07.22.00) + - React-Core/Default (= 0.71.4) + - React-cxxreact (= 0.71.4) + - React-hermes + - React-jsi (= 0.71.4) + - React-jsiexecutor (= 0.71.4) + - React-perflogger (= 0.71.4) + - Yoga + - React-CoreModules (0.71.4): + - RCT-Folly (= 2021.07.22.00) + - RCTTypeSafety (= 0.71.4) + - React-Codegen (= 0.71.4) + - React-Core/CoreModulesHeaders (= 0.71.4) + - React-jsi (= 0.71.4) + - React-RCTBlob + - React-RCTImage (= 0.71.4) + - ReactCommon/turbomodule/core (= 0.71.4) + - React-cxxreact (0.71.4): + - boost (= 1.76.0) + - DoubleConversion + - glog + - hermes-engine + - RCT-Folly (= 2021.07.22.00) + - React-callinvoker (= 0.71.4) + - React-jsi (= 0.71.4) + - React-jsinspector (= 0.71.4) + - React-logger (= 0.71.4) + - React-perflogger (= 0.71.4) + - React-runtimeexecutor (= 0.71.4) + - React-hermes (0.71.4): + - DoubleConversion + - glog + - hermes-engine + - RCT-Folly (= 2021.07.22.00) + - RCT-Folly/Futures (= 2021.07.22.00) + - React-cxxreact (= 0.71.4) + - React-jsi + - React-jsiexecutor (= 0.71.4) + - React-jsinspector (= 0.71.4) + - React-perflogger (= 0.71.4) + - React-jsi (0.71.4): + - boost (= 1.76.0) + - DoubleConversion + - glog + - hermes-engine + - RCT-Folly (= 2021.07.22.00) + - React-jsiexecutor (0.71.4): + - DoubleConversion + - glog + - hermes-engine + - RCT-Folly (= 2021.07.22.00) + - React-cxxreact (= 0.71.4) + - React-jsi (= 0.71.4) + - React-perflogger (= 0.71.4) + - React-jsinspector (0.71.4) + - React-logger (0.71.4): + - glog + - react-native-document-picker (8.2.0): + - React-Core + - React-perflogger (0.71.4) + - React-RCTActionSheet (0.71.4): + - React-Core/RCTActionSheetHeaders (= 0.71.4) + - React-RCTAnimation (0.71.4): + - RCT-Folly (= 2021.07.22.00) + - RCTTypeSafety (= 0.71.4) + - React-Codegen (= 0.71.4) + - React-Core/RCTAnimationHeaders (= 0.71.4) + - React-jsi (= 0.71.4) + - ReactCommon/turbomodule/core (= 0.71.4) + - React-RCTAppDelegate (0.71.4): + - RCT-Folly + - RCTRequired + - RCTTypeSafety + - React-Core + - ReactCommon/turbomodule/core + - React-RCTBlob (0.71.4): + - hermes-engine + - RCT-Folly (= 2021.07.22.00) + - React-Codegen (= 0.71.4) + - React-Core/RCTBlobHeaders (= 0.71.4) + - React-Core/RCTWebSocket (= 0.71.4) + - React-jsi (= 0.71.4) + - React-RCTNetwork (= 0.71.4) + - ReactCommon/turbomodule/core (= 0.71.4) + - React-RCTImage (0.71.4): + - RCT-Folly (= 2021.07.22.00) + - RCTTypeSafety (= 0.71.4) + - React-Codegen (= 0.71.4) + - React-Core/RCTImageHeaders (= 0.71.4) + - React-jsi (= 0.71.4) + - React-RCTNetwork (= 0.71.4) + - ReactCommon/turbomodule/core (= 0.71.4) + - React-RCTLinking (0.71.4): + - React-Codegen (= 0.71.4) + - React-Core/RCTLinkingHeaders (= 0.71.4) + - React-jsi (= 0.71.4) + - ReactCommon/turbomodule/core (= 0.71.4) + - React-RCTNetwork (0.71.4): + - RCT-Folly (= 2021.07.22.00) + - RCTTypeSafety (= 0.71.4) + - React-Codegen (= 0.71.4) + - React-Core/RCTNetworkHeaders (= 0.71.4) + - React-jsi (= 0.71.4) + - ReactCommon/turbomodule/core (= 0.71.4) + - React-RCTSettings (0.71.4): + - RCT-Folly (= 2021.07.22.00) + - RCTTypeSafety (= 0.71.4) + - React-Codegen (= 0.71.4) + - React-Core/RCTSettingsHeaders (= 0.71.4) + - React-jsi (= 0.71.4) + - ReactCommon/turbomodule/core (= 0.71.4) + - React-RCTText (0.71.4): + - React-Core/RCTTextHeaders (= 0.71.4) + - React-RCTVibration (0.71.4): + - RCT-Folly (= 2021.07.22.00) + - React-Codegen (= 0.71.4) + - React-Core/RCTVibrationHeaders (= 0.71.4) + - React-jsi (= 0.71.4) + - ReactCommon/turbomodule/core (= 0.71.4) + - React-runtimeexecutor (0.71.4): + - React-jsi (= 0.71.4) + - ReactCommon/turbomodule/bridging (0.71.4): + - DoubleConversion + - glog + - hermes-engine + - RCT-Folly (= 2021.07.22.00) + - React-callinvoker (= 0.71.4) + - React-Core (= 0.71.4) + - React-cxxreact (= 0.71.4) + - React-jsi (= 0.71.4) + - React-logger (= 0.71.4) + - React-perflogger (= 0.71.4) + - ReactCommon/turbomodule/core (0.71.4): + - DoubleConversion + - glog + - hermes-engine + - RCT-Folly (= 2021.07.22.00) + - React-callinvoker (= 0.71.4) + - React-Core (= 0.71.4) + - React-cxxreact (= 0.71.4) + - React-jsi (= 0.71.4) + - React-logger (= 0.71.4) + - React-perflogger (= 0.71.4) + - SocketRocket (0.6.1) + - Yoga (1.14.0) + - YogaKit (1.18.1): + - Yoga (~> 1.14) + +DEPENDENCIES: + - boost (from `../node_modules/react-native/third-party-podspecs/boost.podspec`) + - DoubleConversion (from `../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec`) + - FBLazyVector (from `../node_modules/react-native/Libraries/FBLazyVector`) + - FBReactNativeSpec (from `../node_modules/react-native/React/FBReactNativeSpec`) + - Flipper (= 0.125.0) + - Flipper-Boost-iOSX (= 1.76.0.1.11) + - Flipper-DoubleConversion (= 3.2.0.1) + - Flipper-Fmt (= 7.1.7) + - Flipper-Folly (= 2.6.10) + - Flipper-Glog (= 0.5.0.5) + - Flipper-PeerTalk (= 0.0.4) + - Flipper-RSocket (= 1.4.3) + - FlipperKit (= 0.125.0) + - FlipperKit/Core (= 0.125.0) + - FlipperKit/CppBridge (= 0.125.0) + - FlipperKit/FBCxxFollyDynamicConvert (= 0.125.0) + - FlipperKit/FBDefines (= 0.125.0) + - FlipperKit/FKPortForwarding (= 0.125.0) + - FlipperKit/FlipperKitHighlightOverlay (= 0.125.0) + - FlipperKit/FlipperKitLayoutPlugin (= 0.125.0) + - FlipperKit/FlipperKitLayoutTextSearchable (= 0.125.0) + - FlipperKit/FlipperKitNetworkPlugin (= 0.125.0) + - FlipperKit/FlipperKitReactPlugin (= 0.125.0) + - FlipperKit/FlipperKitUserDefaultsPlugin (= 0.125.0) + - FlipperKit/SKIOSNetworkPlugin (= 0.125.0) + - glog (from `../node_modules/react-native/third-party-podspecs/glog.podspec`) + - hermes-engine (from `../node_modules/react-native/sdks/hermes-engine/hermes-engine.podspec`) + - internxt-mobile-sdk (from `../..`) + - libevent (~> 2.1.12) + - OpenSSL-Universal (= 1.1.1100) + - RCT-Folly (from `../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec`) + - RCTRequired (from `../node_modules/react-native/Libraries/RCTRequired`) + - RCTTypeSafety (from `../node_modules/react-native/Libraries/TypeSafety`) + - React (from `../node_modules/react-native/`) + - React-callinvoker (from `../node_modules/react-native/ReactCommon/callinvoker`) + - React-Codegen (from `build/generated/ios`) + - React-Core (from `../node_modules/react-native/`) + - React-Core/DevSupport (from `../node_modules/react-native/`) + - React-Core/RCTWebSocket (from `../node_modules/react-native/`) + - React-CoreModules (from `../node_modules/react-native/React/CoreModules`) + - React-cxxreact (from `../node_modules/react-native/ReactCommon/cxxreact`) + - React-hermes (from `../node_modules/react-native/ReactCommon/hermes`) + - React-jsi (from `../node_modules/react-native/ReactCommon/jsi`) + - React-jsiexecutor (from `../node_modules/react-native/ReactCommon/jsiexecutor`) + - React-jsinspector (from `../node_modules/react-native/ReactCommon/jsinspector`) + - React-logger (from `../node_modules/react-native/ReactCommon/logger`) + - react-native-document-picker (from `../node_modules/react-native-document-picker`) + - React-perflogger (from `../node_modules/react-native/ReactCommon/reactperflogger`) + - React-RCTActionSheet (from `../node_modules/react-native/Libraries/ActionSheetIOS`) + - React-RCTAnimation (from `../node_modules/react-native/Libraries/NativeAnimation`) + - React-RCTAppDelegate (from `../node_modules/react-native/Libraries/AppDelegate`) + - React-RCTBlob (from `../node_modules/react-native/Libraries/Blob`) + - React-RCTImage (from `../node_modules/react-native/Libraries/Image`) + - React-RCTLinking (from `../node_modules/react-native/Libraries/LinkingIOS`) + - React-RCTNetwork (from `../node_modules/react-native/Libraries/Network`) + - React-RCTSettings (from `../node_modules/react-native/Libraries/Settings`) + - React-RCTText (from `../node_modules/react-native/Libraries/Text`) + - React-RCTVibration (from `../node_modules/react-native/Libraries/Vibration`) + - React-runtimeexecutor (from `../node_modules/react-native/ReactCommon/runtimeexecutor`) + - ReactCommon/turbomodule/core (from `../node_modules/react-native/ReactCommon`) + - Yoga (from `../node_modules/react-native/ReactCommon/yoga`) + +SPEC REPOS: + trunk: + - CocoaAsyncSocket + - Flipper + - Flipper-Boost-iOSX + - Flipper-DoubleConversion + - Flipper-Fmt + - Flipper-Folly + - Flipper-Glog + - Flipper-PeerTalk + - Flipper-RSocket + - FlipperKit + - fmt + - libevent + - OpenSSL-Universal + - SocketRocket + - YogaKit + +EXTERNAL SOURCES: + boost: + :podspec: "../node_modules/react-native/third-party-podspecs/boost.podspec" + DoubleConversion: + :podspec: "../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec" + FBLazyVector: + :path: "../node_modules/react-native/Libraries/FBLazyVector" + FBReactNativeSpec: + :path: "../node_modules/react-native/React/FBReactNativeSpec" + glog: + :podspec: "../node_modules/react-native/third-party-podspecs/glog.podspec" + hermes-engine: + :podspec: "../node_modules/react-native/sdks/hermes-engine/hermes-engine.podspec" + internxt-mobile-sdk: + :path: "../.." + RCT-Folly: + :podspec: "../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec" + RCTRequired: + :path: "../node_modules/react-native/Libraries/RCTRequired" + RCTTypeSafety: + :path: "../node_modules/react-native/Libraries/TypeSafety" + React: + :path: "../node_modules/react-native/" + React-callinvoker: + :path: "../node_modules/react-native/ReactCommon/callinvoker" + React-Codegen: + :path: build/generated/ios + React-Core: + :path: "../node_modules/react-native/" + React-CoreModules: + :path: "../node_modules/react-native/React/CoreModules" + React-cxxreact: + :path: "../node_modules/react-native/ReactCommon/cxxreact" + React-hermes: + :path: "../node_modules/react-native/ReactCommon/hermes" + React-jsi: + :path: "../node_modules/react-native/ReactCommon/jsi" + React-jsiexecutor: + :path: "../node_modules/react-native/ReactCommon/jsiexecutor" + React-jsinspector: + :path: "../node_modules/react-native/ReactCommon/jsinspector" + React-logger: + :path: "../node_modules/react-native/ReactCommon/logger" + react-native-document-picker: + :path: "../node_modules/react-native-document-picker" + React-perflogger: + :path: "../node_modules/react-native/ReactCommon/reactperflogger" + React-RCTActionSheet: + :path: "../node_modules/react-native/Libraries/ActionSheetIOS" + React-RCTAnimation: + :path: "../node_modules/react-native/Libraries/NativeAnimation" + React-RCTAppDelegate: + :path: "../node_modules/react-native/Libraries/AppDelegate" + React-RCTBlob: + :path: "../node_modules/react-native/Libraries/Blob" + React-RCTImage: + :path: "../node_modules/react-native/Libraries/Image" + React-RCTLinking: + :path: "../node_modules/react-native/Libraries/LinkingIOS" + React-RCTNetwork: + :path: "../node_modules/react-native/Libraries/Network" + React-RCTSettings: + :path: "../node_modules/react-native/Libraries/Settings" + React-RCTText: + :path: "../node_modules/react-native/Libraries/Text" + React-RCTVibration: + :path: "../node_modules/react-native/Libraries/Vibration" + React-runtimeexecutor: + :path: "../node_modules/react-native/ReactCommon/runtimeexecutor" + ReactCommon: + :path: "../node_modules/react-native/ReactCommon" + Yoga: + :path: "../node_modules/react-native/ReactCommon/yoga" + +SPEC CHECKSUMS: + boost: 57d2868c099736d80fcd648bf211b4431e51a558 + CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99 + DoubleConversion: 5189b271737e1565bdce30deb4a08d647e3f5f54 + FBLazyVector: 446e84642979fff0ba57f3c804c2228a473aeac2 + FBReactNativeSpec: 241709e132e3bf1526c1c4f00bc5384dd39dfba9 + Flipper: 26fc4b7382499f1281eb8cb921e5c3ad6de91fe0 + Flipper-Boost-iOSX: fd1e2b8cbef7e662a122412d7ac5f5bea715403c + Flipper-DoubleConversion: 2dc99b02f658daf147069aad9dbd29d8feb06d30 + Flipper-Fmt: 60cbdd92fc254826e61d669a5d87ef7015396a9b + Flipper-Folly: 584845625005ff068a6ebf41f857f468decd26b3 + Flipper-Glog: 70c50ce58ddaf67dc35180db05f191692570f446 + Flipper-PeerTalk: 116d8f857dc6ef55c7a5a75ea3ceaafe878aadc9 + Flipper-RSocket: d9d9ade67cbecf6ac10730304bf5607266dd2541 + FlipperKit: cbdee19bdd4e7f05472a66ce290f1b729ba3cb86 + fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9 + glog: 04b94705f318337d7ead9e6d17c019bd9b1f6b1b + hermes-engine: a1f157c49ea579c28b0296bda8530e980c45bdb3 + internxt-mobile-sdk: 601b24b7ce4b58a4cc48c27f400e7be43c405e2f + libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913 + OpenSSL-Universal: ebc357f1e6bc71fa463ccb2fe676756aff50e88c + RCT-Folly: 424b8c9a7a0b9ab2886ffe9c3b041ef628fd4fb1 + RCTRequired: 5a024fdf458fa8c0d82fc262e76f982d4dcdecdd + RCTTypeSafety: b6c253064466411c6810b45f66bc1e43ce0c54ba + React: 715292db5bd46989419445a5547954b25d2090f0 + React-callinvoker: 105392d1179058585b564d35b4592fe1c46d6fba + React-Codegen: b75333b93d835afce84b73472927cccaef2c9f8c + React-Core: 88838ed1724c64905fc6c0811d752828a92e395b + React-CoreModules: cd238b4bb8dc8529ccc8b34ceae7267b04ce1882 + React-cxxreact: 291bfab79d8098dc5ebab98f62e6bdfe81b3955a + React-hermes: b1e67e9a81c71745704950516f40ee804349641c + React-jsi: c9d5b563a6af6bb57034a82c2b0d39d0a7483bdc + React-jsiexecutor: d6b7fa9260aa3cb40afee0507e3bc1d17ecaa6f2 + React-jsinspector: 1f51e775819199d3fe9410e69ee8d4c4161c7b06 + React-logger: 0d58569ec51d30d1792c5e86a8e3b78d24b582c6 + react-native-document-picker: 495c444c0c773c6e83a5d91165890ecb1c0a399a + React-perflogger: 0bb0522a12e058f6eb69d888bc16f40c16c4b907 + React-RCTActionSheet: bfd675a10f06a18728ea15d82082d48f228a213a + React-RCTAnimation: 2fa220b2052ec75b733112aca39143d34546a941 + React-RCTAppDelegate: 8564f93c1d9274e95e3b0c746d08a87ff5a621b2 + React-RCTBlob: d0336111f46301ae8aba2e161817e451aad72dd6 + React-RCTImage: fec592c46edb7c12a9cde08780bdb4a688416c62 + React-RCTLinking: 14eccac5d2a3b34b89dbfa29e8ef6219a153fe2d + React-RCTNetwork: 1fbce92e772e39ca3687a2ebb854501ff6226dd7 + React-RCTSettings: 1abea36c9bb16d9979df6c4b42e2ea281b4bbcc5 + React-RCTText: 15355c41561a9f43dfd23616d0a0dd40ba05ed61 + React-RCTVibration: ad17efcfb2fa8f6bfd8ac0cf48d96668b8b28e0b + React-runtimeexecutor: 8fa50b38df6b992c76537993a2b0553d3b088004 + ReactCommon: b49a4b00ca6d181ff74b17c12b2d59ac4add0bde + SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17 + Yoga: 79dd7410de6f8ad73a77c868d3d368843f0c93e0 + YogaKit: f782866e155069a2cca2517aafea43200b01fd5a + +PODFILE CHECKSUM: fb1e2ada8fb45c4b7a6169a5345fcafdbf583e53 + +COCOAPODS: 1.12.1 diff --git a/example/package.json b/example/package.json index 0bdc777..d1b1482 100644 --- a/example/package.json +++ b/example/package.json @@ -6,12 +6,17 @@ "android": "react-native run-android", "ios": "react-native run-ios", "start": "react-native start", - "pods": "pod-install --quiet" + "pods": "pod-install --quiet", + "tailwind:dev": "concurrently \"tailwindcss --input input.css --output tailwind.css --no-autoprefixer --watch\" \"tailwind-rn --watch -i tailwind.css -o tailwind.json\"", + "tailwind:build": "tailwindcss --input tw-input.css --output tailwind.css --no-autoprefixer && tailwind-rn -i tailwind.css -o tailwind.json" }, "dependencies": { + "concurrently": "^8.2.0", "react": "18.2.0", "react-native": "0.71.4", - "react-native-document-picker": "^8.2.0" + "react-native-document-picker": "^8.2.0", + "tailwind-rn": "^4.2.0", + "tailwindcss": "^3.3.2" }, "devDependencies": { "@babel/core": "^7.20.0", diff --git a/example/src/App.tsx b/example/src/App.tsx index ce624a2..59b2d21 100644 --- a/example/src/App.tsx +++ b/example/src/App.tsx @@ -1,18 +1,25 @@ import * as React from 'react'; -import { StyleSheet, View, Button } from 'react-native'; +import { StyleSheet, View, Button, Text, NativeModules } from 'react-native'; import DocumentPicker, { DocumentPickerResponse, isInProgress, } from 'react-native-document-picker'; -import { useEffect } from 'react'; -import { initSdk, core, photos } from '@internxt/mobile-sdk'; +import { useEffect, useState } from 'react'; +import { initSdk, core, photos, fs } from '@internxt/mobile-sdk'; +import { PlaygroundCase } from './components/Playground/PlaygroundCase'; +import { TailwindProvider, useTailwind } from 'tailwind-rn'; +import twUtilities from '../tailwind.json'; // Just for testing, fill this to reproduce a signed in user in the demo app const AUTH_TOKEN = ''; const MNEMONIC = ''; const BUCKET_ID = ''; const FOLDER_ID = ''; -export default function App() { +export function AppContent() { + const tailwind = useTailwind(); + const [activeAction, setActiveAction] = useState(-1); + const [output, setOutput] = useState(null); + const [error, setError] = useState(null); useEffect(() => { initSdk({ DRIVE_API_URL: 'EMPTY', @@ -36,6 +43,7 @@ export default function App() { 'multiple pickers were opened, only the last will be considered' ); } else { + setError(err); console.error(err); } }; @@ -84,9 +92,70 @@ export default function App() { console.log('RESPONSE', response.status); }; + const actions = [ + { + name: 'Save to downloads', + description: 'Opens a document picker, pick a file and ', + run: async () => { + try { + const pickerResult = await DocumentPicker.pickSingle({ + presentationStyle: 'fullScreen', + copyTo: 'cachesDirectory', + }); + if (pickerResult.fileCopyUri) { + await NativeModules.MobileSdk.saveToDownloads( + pickerResult.fileCopyUri + ); + } + + return true; + } catch (e) { + return e; + } + }, + }, + { + name: 'Process a photo', + description: 'Pick and send to encryption queue a Photo from the gallery', + run: async () => { + try { + const pickerResult = await DocumentPicker.pickSingle({ + presentationStyle: 'fullScreen', + copyTo: 'cachesDirectory', + }); + await handleProcessPhoto(pickerResult); + return true; + } catch (e) { + return e; + } + }, + }, + ]; return ( - -