From 235404dc028495b20e7838d387c71e26dec330db Mon Sep 17 00:00:00 2001 From: Zhiyuan Zheng Date: Wed, 4 May 2022 23:07:24 +0200 Subject: [PATCH 1/5] Sharing on iOS almost working --- ios/Podfile | 1 - ios/Podfile.lock | 26 ++-- .../Base.lproj/MainInterface.storyboard | 27 ----- ios/ShareExtension/Info.plist | 4 +- ios/tooot.xcodeproj/project.pbxproj | 16 --- patches/react-native-share-menu+5.0.5.patch | 113 ++++++++++-------- 6 files changed, 85 insertions(+), 102 deletions(-) delete mode 100644 ios/ShareExtension/Base.lproj/MainInterface.storyboard diff --git a/ios/Podfile b/ios/Podfile index e9185d46..96639ed2 100644 --- a/ios/Podfile +++ b/ios/Podfile @@ -39,5 +39,4 @@ target 'ShareExtension' do ) pod 'RNShareMenu', :path => '../node_modules/react-native-share-menu' - pod 'RNFS', :path => '../node_modules/react-native-fs' end diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 930b8234..588aa9ea 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -1,6 +1,8 @@ PODS: - boost (1.76.0) - DoubleConversion (1.1.6) + - EXApplication (4.0.2): + - ExpoModulesCore - EXAV (10.2.1): - ExpoModulesCore - ReactCommon/turbomodule/core @@ -21,6 +23,8 @@ PODS: - EXFirebaseCore (4.1.1): - ExpoModulesCore - Firebase/Core (= 7.7.0) + - EXFont (10.0.5): + - ExpoModulesCore - EXImageLoader (3.1.1): - ExpoModulesCore - React-Core @@ -30,6 +34,8 @@ PODS: - EXImagePicker (12.0.2): - ExpoModulesCore - EXJSONUtils (0.2.1) + - EXKeepAwake (10.0.2): + - ExpoModulesCore - EXManifests (0.2.4): - EXJSONUtils - EXNotifications (0.14.1): @@ -454,8 +460,6 @@ PODS: - React-Core - SDWebImage (~> 5.12.5) - SDWebImageWebPCoder (~> 0.8.4) - - RNFS (2.19.0): - - React-Core - RNGestureHandler (2.4.1): - React-Core - RNReanimated (2.8.0): @@ -511,6 +515,7 @@ PODS: DEPENDENCIES: - boost (from `../node_modules/react-native/third-party-podspecs/boost.podspec`) - DoubleConversion (from `../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec`) + - EXApplication (from `../node_modules/expo-application/ios`) - EXAV (from `../node_modules/expo-av/ios`) - EXConstants (from `../node_modules/expo-constants/ios`) - EXCrypto (from `../node_modules/expo-crypto/ios`) @@ -519,10 +524,12 @@ DEPENDENCIES: - EXFileSystem (from `../node_modules/expo-file-system/ios`) - EXFirebaseAnalytics (from `../node_modules/expo-firebase-analytics/ios`) - EXFirebaseCore (from `../node_modules/expo-firebase-core/ios`) + - EXFont (from `../node_modules/expo-font/ios`) - EXImageLoader (from `../node_modules/expo-image-loader/ios`) - EXImageManipulator (from `../node_modules/expo-image-manipulator/ios`) - EXImagePicker (from `../node_modules/expo-image-picker/ios`) - EXJSONUtils (from `../node_modules/expo-json-utils/ios`) + - EXKeepAwake (from `../node_modules/expo-keep-awake/ios`) - EXManifests (from `../node_modules/expo-manifests/ios`) - EXNotifications (from `../node_modules/expo-notifications/ios`) - Expo (from `../node_modules/expo/ios`) @@ -580,7 +587,6 @@ DEPENDENCIES: - ReactCommon/turbomodule/core (from `../node_modules/react-native/ReactCommon`) - "RNCAsyncStorage (from `../node_modules/@react-native-async-storage/async-storage`)" - RNFastImage (from `../node_modules/react-native-fast-image`) - - RNFS (from `../node_modules/react-native-fs`) - RNGestureHandler (from `../node_modules/react-native-gesture-handler`) - RNReanimated (from `../node_modules/react-native-reanimated`) - RNScreens (from `../node_modules/react-native-screens`) @@ -615,6 +621,8 @@ EXTERNAL SOURCES: :podspec: "../node_modules/react-native/third-party-podspecs/boost.podspec" DoubleConversion: :podspec: "../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec" + EXApplication: + :path: "../node_modules/expo-application/ios" EXAV: :path: "../node_modules/expo-av/ios" EXConstants: @@ -631,6 +639,8 @@ EXTERNAL SOURCES: :path: "../node_modules/expo-firebase-analytics/ios" EXFirebaseCore: :path: "../node_modules/expo-firebase-core/ios" + EXFont: + :path: "../node_modules/expo-font/ios" EXImageLoader: :path: "../node_modules/expo-image-loader/ios" EXImageManipulator: @@ -639,6 +649,8 @@ EXTERNAL SOURCES: :path: "../node_modules/expo-image-picker/ios" EXJSONUtils: :path: "../node_modules/expo-json-utils/ios" + EXKeepAwake: + :path: "../node_modules/expo-keep-awake/ios" EXManifests: :path: "../node_modules/expo-manifests/ios" EXNotifications: @@ -745,8 +757,6 @@ EXTERNAL SOURCES: :path: "../node_modules/@react-native-async-storage/async-storage" RNFastImage: :path: "../node_modules/react-native-fast-image" - RNFS: - :path: "../node_modules/react-native-fs" RNGestureHandler: :path: "../node_modules/react-native-gesture-handler" RNReanimated: @@ -767,6 +777,7 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: boost: a7c83b31436843459a1961bfd74b96033dc77234 DoubleConversion: 831926d9b8bf8166fd87886c4abab286c2422662 + EXApplication: 54fe5bd6268d697771645e8f1aef8b806a65247a EXAV: b9ed0c201092244c46aa78f907f5c66176bed236 EXConstants: 88bf79622fbd9b476c96d8ec57fe97ca44fe8e3c EXCrypto: ab2ba0df3136a5f2407b8c7e70eb498ac20d704f @@ -775,10 +786,12 @@ SPEC CHECKSUMS: EXFileSystem: 7bcd3c1428698150d5c8ca140c8183f2ee204048 EXFirebaseAnalytics: a7ec2dd1394ad0de5c0c63fac0deee496f798284 EXFirebaseCore: 52151d0b008b99983e6a120cea94466ee760a4e9 + EXFont: 2597c10ac85a69d348d44d7873eccf5a7576ef5e EXImageLoader: 347b72c2ec2df65120ccec40ea65a4c4f24317ff EXImageManipulator: 60d1bf3f1d7709453b1feb38adf8594b7f58710f EXImagePicker: bf4d62532cc2bf217edbe4abbb0014e73e079eac EXJSONUtils: 5ee0d5cf76da70ad86f0be1a41cc70f47d69e06f + EXKeepAwake: bf48d7f740a5cd2befed6cf9a49911d385c6c47d EXManifests: d3464cd2278f4a19cd80c1aa673231570b534c11 EXNotifications: a7d582fa800d77f4a75bd22d52e84e2fbcee26df Expo: 534e51e607aba8229293297da5585f4b26f50fa1 @@ -846,7 +859,6 @@ SPEC CHECKSUMS: ReactCommon: 07d0c460b9ba9af3eaf1b8f5abe7daaad28c9c4e RNCAsyncStorage: 005c0e2f09575360f142d0d1f1f15e4ec575b1af RNFastImage: 945abf54742505d790d9024d230c69b1e866bc88 - RNFS: fc610f78fdf8bfc89a9e5cc2f898519f4dba1002 RNGestureHandler: 4f4986408310a43f1606c391f38f76e0d6e790d5 RNReanimated: 46cdb89ca59ab7181334f4ed05a70e82ddb36751 RNScreens: 40a2cb40a02a609938137a1e0acfbf8fc9eebf19 @@ -859,6 +871,6 @@ SPEC CHECKSUMS: UMTaskManagerInterface: 3184c93ecc290bd422c6e344badc89b601e9c29b Yoga: d6b6a80659aa3e91aaba01d0012e7edcbedcbecd -PODFILE CHECKSUM: 26ee7ffc1b88088246dc6a04f532230c6d5a5884 +PODFILE CHECKSUM: 040599cb42f9766a495935deae4c4908f2041ece COCOAPODS: 1.11.3 diff --git a/ios/ShareExtension/Base.lproj/MainInterface.storyboard b/ios/ShareExtension/Base.lproj/MainInterface.storyboard deleted file mode 100644 index 2e6951b8..00000000 --- a/ios/ShareExtension/Base.lproj/MainInterface.storyboard +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/ios/ShareExtension/Info.plist b/ios/ShareExtension/Info.plist index d2042261..7909276f 100644 --- a/ios/ShareExtension/Info.plist +++ b/ios/ShareExtension/Info.plist @@ -34,8 +34,8 @@ 1 - NSExtensionMainStoryboard - MainInterface + NSExtensionPrincipalClass + $(PRODUCT_MODULE_NAME).ShareViewController NSExtensionPointIdentifier com.apple.share-services diff --git a/ios/tooot.xcodeproj/project.pbxproj b/ios/tooot.xcodeproj/project.pbxproj index 38693b5f..5a471155 100644 --- a/ios/tooot.xcodeproj/project.pbxproj +++ b/ios/tooot.xcodeproj/project.pbxproj @@ -20,10 +20,8 @@ BB2F792D24A3F905000567C9 /* Expo.plist in Resources */ = {isa = PBXBuildFile; fileRef = BB2F792C24A3F905000567C9 /* Expo.plist */; }; DA8B5B7F0DED488CAC0FF169 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = B96B72E5384D44A7B240B27E /* GoogleService-Info.plist */; }; E3BC22F5F8ABE515E14CF199 /* ExpoModulesProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9D878F932AF7A9974E06E461 /* ExpoModulesProvider.swift */; }; - E633A426281EAEAB000E540F /* MainInterface.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = E633A424281EAEAB000E540F /* MainInterface.storyboard */; }; E633A42B281EAEAB000E540F /* ShareExtension.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = E633A420281EAEAB000E540F /* ShareExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; E633A430281EAF38000E540F /* ShareViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E633A42F281EAF38000E540F /* ShareViewController.swift */; }; - E633A437281EB5BC000E540F /* ReactShareViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E633A436281EB5BC000E540F /* ReactShareViewController.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -75,11 +73,9 @@ B96B72E5384D44A7B240B27E /* GoogleService-Info.plist */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 4; includeInIndex = 0; lastKnownFileType = text.plist.xml; name = "GoogleService-Info.plist"; path = "tooot/GoogleService-Info.plist"; sourceTree = ""; }; BB2F792C24A3F905000567C9 /* Expo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Expo.plist; sourceTree = ""; }; E633A420281EAEAB000E540F /* ShareExtension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = ShareExtension.appex; sourceTree = BUILT_PRODUCTS_DIR; }; - E633A425281EAEAB000E540F /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/MainInterface.storyboard; sourceTree = ""; }; E633A427281EAEAB000E540F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; E633A42F281EAF38000E540F /* ShareViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ShareViewController.swift; path = "../../node_modules/react-native-share-menu/ios/ShareViewController.swift"; sourceTree = ""; }; E633A431281EB55C000E540F /* ShareExtension-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "ShareExtension-Bridging-Header.h"; sourceTree = ""; }; - E633A436281EB5BC000E540F /* ReactShareViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ReactShareViewController.swift; path = "../../node_modules/react-native-share-menu/ios/ReactShareViewController.swift"; sourceTree = ""; }; ED297162215061F000B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; }; ED2971642150620600B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS12.0.sdk/System/Library/Frameworks/JavaScriptCore.framework; sourceTree = DEVELOPER_DIR; }; /* End PBXFileReference section */ @@ -207,9 +203,7 @@ E633A421281EAEAB000E540F /* ShareExtension */ = { isa = PBXGroup; children = ( - E633A436281EB5BC000E540F /* ReactShareViewController.swift */, E633A42F281EAF38000E540F /* ShareViewController.swift */, - E633A424281EAEAB000E540F /* MainInterface.storyboard */, E633A427281EAEAB000E540F /* Info.plist */, E633A431281EB55C000E540F /* ShareExtension-Bridging-Header.h */, ); @@ -324,7 +318,6 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - E633A426281EAEAB000E540F /* MainInterface.storyboard in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -502,7 +495,6 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - E633A437281EB5BC000E540F /* ReactShareViewController.swift in Sources */, E633A430281EAF38000E540F /* ShareViewController.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -536,14 +528,6 @@ name = InfoPlist.strings; sourceTree = ""; }; - E633A424281EAEAB000E540F /* MainInterface.storyboard */ = { - isa = PBXVariantGroup; - children = ( - E633A425281EAEAB000E540F /* Base */, - ); - name = MainInterface.storyboard; - sourceTree = ""; - }; /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ diff --git a/patches/react-native-share-menu+5.0.5.patch b/patches/react-native-share-menu+5.0.5.patch index 96a4c59f..f8e40599 100644 --- a/patches/react-native-share-menu+5.0.5.patch +++ b/patches/react-native-share-menu+5.0.5.patch @@ -291,10 +291,10 @@ index 0aa4c58..ad0812c 100644 + func continueInApp(with items: [NSExtensionItem], and extraData: [String:Any]?) } diff --git a/node_modules/react-native-share-menu/ios/ShareViewController.swift b/node_modules/react-native-share-menu/ios/ShareViewController.swift -index 7faf6e4..12d8c92 100644 +index 7faf6e4..f02bde5 100644 --- a/node_modules/react-native-share-menu/ios/ShareViewController.swift +++ b/node_modules/react-native-share-menu/ios/ShareViewController.swift -@@ -6,7 +6,9 @@ +@@ -6,15 +6,18 @@ // // Created by Gustavo Parreira on 26/07/2020. // @@ -304,38 +304,43 @@ index 7faf6e4..12d8c92 100644 import MobileCoreServices import UIKit import Social -@@ -15,6 +17,7 @@ import RNShareMenu - class ShareViewController: SLComposeServiceViewController { + import RNShareMenu + +-class ShareViewController: SLComposeServiceViewController { ++class ShareViewController: UIViewController { var hostAppId: String? var hostAppUrlScheme: String? + var sharedItems: [Any] = [] override func viewDidLoad() { super.viewDidLoad() -@@ -39,12 +42,12 @@ class ShareViewController: SLComposeServiceViewController { +@@ -30,46 +33,64 @@ class ShareViewController: SLComposeServiceViewController { + } else { + print("Error: \(NO_INFO_PLIST_URL_SCHEME_ERROR)") + } +- } - override func didSelectPost() { - // This is called after the user selects Post. Do the upload of contentText and/or NSExtensionContext attachments. +- override func isContentValid() -> Bool { +- // Do validation of contentText and/or NSExtensionContext attachments here +- return true ++ guard let items = extensionContext?.inputItems as? [NSExtensionItem] else { ++ cancelRequest() ++ return + } + +- override func didSelectPost() { +- // This is called after the user selects Post. Do the upload of contentText and/or NSExtensionContext attachments. - guard let item = extensionContext?.inputItems.first as? NSExtensionItem else { -+ guard let items = extensionContext?.inputItems as? [NSExtensionItem] else { - cancelRequest() - return - } - -- handlePost(item) -+ handlePost(items) - } - - override func configurationItems() -> [Any]! { -@@ -52,24 +55,50 @@ class ShareViewController: SLComposeServiceViewController { - return [] - } - -- func handlePost(_ item: NSExtensionItem, extraData: [String:Any]? = nil) { -- guard let provider = item.attachments?.first else { -- cancelRequest() -- return -- } +- cancelRequest() ++ handlePost(items) ++ } ++ ++ override func viewDidAppear(_ animated: Bool) { ++ super.viewDidAppear(animated) ++ ++ completeRequest() ++ } ++ + func handlePost(_ items: [NSExtensionItem], extraData: [String:Any]? = nil) { + DispatchQueue.global().async { + guard let hostAppId = self.hostAppId else { @@ -344,13 +349,10 @@ index 7faf6e4..12d8c92 100644 + } + guard let userDefaults = UserDefaults(suiteName: "group.\(hostAppId)") else { + self.exit(withError: NO_APP_GROUP_ERROR) -+ return -+ } + return + } -- if let data = extraData { -- storeExtraData(data) -- } else { -- removeExtraData() +- handlePost(item) - } + if let data = extraData { + self.storeExtraData(data) @@ -358,21 +360,28 @@ index 7faf6e4..12d8c92 100644 + self.removeExtraData() + } -- if provider.isText { -- storeText(withProvider: provider) -- } else if provider.isURL { -- storeUrl(withProvider: provider) -- } else { -- storeFile(withProvider: provider) +- override func configurationItems() -> [Any]! { +- // To add configuration options via table cells at the bottom of the sheet, return an array of SLComposeSheetConfigurationItem here. +- return [] +- } + let semaphore = DispatchSemaphore(value: 0) -+ var results: [Any] = [] -+ + +- func handlePost(_ item: NSExtensionItem, extraData: [String:Any]? = nil) { +- guard let provider = item.attachments?.first else { +- cancelRequest() +- return +- } + for item in items { + guard let attachments = item.attachments else { + self.cancelRequest() + return + } -+ + +- if let data = extraData { +- storeExtraData(data) +- } else { +- removeExtraData() +- } + for provider in attachments { + if provider.isText { + self.storeText(withProvider: provider, semaphore) @@ -381,7 +390,13 @@ index 7faf6e4..12d8c92 100644 + } else { + self.storeFile(withProvider: provider, semaphore) + } -+ + +- if provider.isText { +- storeText(withProvider: provider) +- } else if provider.isURL { +- storeUrl(withProvider: provider) +- } else { +- storeFile(withProvider: provider) + semaphore.wait() + } + } @@ -394,7 +409,7 @@ index 7faf6e4..12d8c92 100644 } } -@@ -99,7 +128,7 @@ class ShareViewController: SLComposeServiceViewController { +@@ -99,7 +120,7 @@ class ShareViewController: SLComposeServiceViewController { userDefaults.synchronize() } @@ -403,7 +418,7 @@ index 7faf6e4..12d8c92 100644 provider.loadItem(forTypeIdentifier: kUTTypeText as String, options: nil) { (data, error) in guard (error == nil) else { self.exit(withError: error.debugDescription) -@@ -109,24 +138,13 @@ class ShareViewController: SLComposeServiceViewController { +@@ -109,24 +130,13 @@ class ShareViewController: SLComposeServiceViewController { self.exit(withError: COULD_NOT_FIND_STRING_ERROR) return } @@ -415,11 +430,11 @@ index 7faf6e4..12d8c92 100644 - self.exit(withError: NO_APP_GROUP_ERROR) - return - } - +- - userDefaults.set([DATA_KEY: text, MIME_TYPE_KEY: "text/plain"], - forKey: USER_DEFAULTS_KEY) - userDefaults.synchronize() -- + - self.openHostApp() + self.sharedItems.append([DATA_KEY: text, MIME_TYPE_KEY: "text/plain"]) + semaphore.signal() @@ -431,7 +446,7 @@ index 7faf6e4..12d8c92 100644 provider.loadItem(forTypeIdentifier: kUTTypeURL as String, options: nil) { (data, error) in guard (error == nil) else { self.exit(withError: error.debugDescription) -@@ -136,24 +154,13 @@ class ShareViewController: SLComposeServiceViewController { +@@ -136,24 +146,13 @@ class ShareViewController: SLComposeServiceViewController { self.exit(withError: COULD_NOT_FIND_URL_ERROR) return } @@ -459,7 +474,7 @@ index 7faf6e4..12d8c92 100644 provider.loadItem(forTypeIdentifier: kUTTypeData as String, options: nil) { (data, error) in guard (error == nil) else { self.exit(withError: error.debugDescription) -@@ -167,10 +174,6 @@ class ShareViewController: SLComposeServiceViewController { +@@ -167,10 +166,6 @@ class ShareViewController: SLComposeServiceViewController { self.exit(withError: NO_INFO_PLIST_INDENTIFIER_ERROR) return } @@ -470,7 +485,7 @@ index 7faf6e4..12d8c92 100644 guard let groupFileManagerContainer = FileManager.default .containerURL(forSecurityApplicationGroupIdentifier: "group.\(hostAppId)") else { -@@ -189,11 +192,8 @@ class ShareViewController: SLComposeServiceViewController { +@@ -189,11 +184,8 @@ class ShareViewController: SLComposeServiceViewController { return } From b2043d884fe1014872d04f96dc3ba431f34916ab Mon Sep 17 00:00:00 2001 From: Zhiyuan Zheng Date: Wed, 4 May 2022 23:55:46 +0200 Subject: [PATCH 2/5] Update MainActivity.java https://docs.swmansion.com/react-native-gesture-handler/docs/guides/migrating-off-rnghenabledroot/ --- .../java/com/xmflsct/app/tooot/MainActivity.java | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/android/app/src/main/java/com/xmflsct/app/tooot/MainActivity.java b/android/app/src/main/java/com/xmflsct/app/tooot/MainActivity.java index b7611a1b..3abbde29 100644 --- a/android/app/src/main/java/com/xmflsct/app/tooot/MainActivity.java +++ b/android/app/src/main/java/com/xmflsct/app/tooot/MainActivity.java @@ -4,7 +4,6 @@ import android.os.Bundle; import com.facebook.react.ReactActivity; import com.facebook.react.ReactActivityDelegate; import com.facebook.react.ReactRootView; -import com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView; import expo.modules.ReactActivityDelegateWrapper; @@ -22,17 +21,4 @@ public class MainActivity extends ReactActivity { protected String getMainComponentName() { return "main"; } - - @Override - protected ReactActivityDelegate createReactActivityDelegate() { - return new ReactActivityDelegateWrapper( - this, - new ReactActivityDelegate(this, getMainComponentName()) { - @Override - protected ReactRootView createRootView() { - return new RNGestureHandlerEnabledRootView(MainActivity.this); - } - } - ); - } } From dce3e950104e13c41baadb1886016f81633150cf Mon Sep 17 00:00:00 2001 From: Zhiyuan Zheng Date: Thu, 5 May 2022 00:52:57 +0200 Subject: [PATCH 3/5] Proper content type header for Android --- src/api/general.ts | 10 +++++----- src/api/instance.ts | 6 ++++-- src/api/tooot.ts | 5 ++++- yarn.lock | 6 +++--- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/api/general.ts b/src/api/general.ts index 270286ce..24b1ef6a 100644 --- a/src/api/general.ts +++ b/src/api/general.ts @@ -1,7 +1,6 @@ import axios from 'axios' import chalk from 'chalk' import Constants from 'expo-constants' -import * as Sentry from 'sentry-expo' const ctx = new chalk.Instance({ level: 3 }) @@ -14,7 +13,6 @@ export type Params = { } headers?: { [key: string]: string } body?: FormData | Object - sentry?: boolean } const apiGeneral = async ({ @@ -23,8 +21,7 @@ const apiGeneral = async ({ url, params, headers, - body, - sentry = true + body }: Params): Promise<{ body: T }> => { console.log( ctx.bgGreen.bold(' API general ') + @@ -45,7 +42,10 @@ const apiGeneral = async ({ url, params, headers: { - 'Content-Type': 'application/json', + 'Content-Type': + body && body instanceof FormData + ? 'multipart/form-data' + : 'application/json', 'User-Agent': `tooot/${Constants.manifest?.version}`, Accept: '*/*', ...headers diff --git a/src/api/instance.ts b/src/api/instance.ts index 7a2558b7..73975956 100644 --- a/src/api/instance.ts +++ b/src/api/instance.ts @@ -3,7 +3,6 @@ import axios, { AxiosRequestConfig } from 'axios' import chalk from 'chalk' import Constants from 'expo-constants' import li from 'li' -import * as Sentry from 'sentry-expo' const ctx = new chalk.Instance({ level: 3 }) @@ -73,7 +72,10 @@ const apiInstance = async ({ url, params, headers: { - 'Content-Type': 'application/json', + 'Content-Type': + body && body instanceof FormData + ? 'multipart/form-data' + : 'application/json', 'User-Agent': `tooot/${Constants.manifest?.version}`, Accept: '*/*', ...headers, diff --git a/src/api/tooot.ts b/src/api/tooot.ts index 90a30717..6e7b9ba3 100644 --- a/src/api/tooot.ts +++ b/src/api/tooot.ts @@ -48,7 +48,10 @@ const apiTooot = async ({ url: `${url}`, params, headers: { - 'Content-Type': 'application/json', + 'Content-Type': + body && body instanceof FormData + ? 'multipart/form-data' + : 'application/json', 'User-Agent': `tooot/${Constants.manifest?.version}`, Accept: '*/*', ...headers diff --git a/yarn.lock b/yarn.lock index 7d88160e..8f67cba6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3963,9 +3963,9 @@ flow-parser@^0.121.0: integrity sha512-1gIBiWJNR0tKUNv8gZuk7l9rVX06OuLzY9AoGio7y/JT4V1IZErEMEq2TJS+PFcw/y0RshZ1J/27VfK1UQzYVg== follow-redirects@^1.14.9: - version "1.14.9" - resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.9.tgz#dd4ea157de7bfaf9ea9b3fbd85aa16951f78d8d7" - integrity sha512-MQDfihBQYMcyy5dhRDJUHcw7lb2Pv/TuE6xP1vyraLukNDHKbDxDNaOE3NbCAdKQApno+GPRyo1YAp89yCjK4w== + version "1.15.0" + resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.0.tgz#06441868281c86d0dda4ad8bdaead2d02dca89d4" + integrity sha512-aExlJShTV4qOUOL7yF1U5tvLCB0xQuudbf6toyYA0E/acBNw71mvjFTnLaRp50aQaYocMR0a/RMMBIHeZnGyjQ== fontfaceobserver@^2.1.0: version "2.1.0" From a73356c7e66f9e74a7837d299d10d728394c4a1d Mon Sep 17 00:00:00 2001 From: Zhiyuan Zheng Date: Thu, 5 May 2022 01:15:30 +0200 Subject: [PATCH 4/5] Update AndroidManifest.xml Android sharing working, but only one element at a time --- android/app/src/main/AndroidManifest.xml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 00c8fe89..7a814b0f 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -19,7 +19,7 @@ - + @@ -31,6 +31,13 @@ + + + + + + + From b8abd8db8afc8e62f8e5cfeebbf9ca6fc3794e44 Mon Sep 17 00:00:00 2001 From: Zhiyuan Zheng Date: Thu, 5 May 2022 01:32:32 +0200 Subject: [PATCH 5/5] Remove share react --- index.share.js | 4 ---- src/ShareExtension.tsx | 43 ------------------------------------------ 2 files changed, 47 deletions(-) delete mode 100644 index.share.js delete mode 100644 src/ShareExtension.tsx diff --git a/index.share.js b/index.share.js deleted file mode 100644 index d7072850..00000000 --- a/index.share.js +++ /dev/null @@ -1,4 +0,0 @@ -import { AppRegistry } from 'react-native' -import ShareExtension from './src/ShareExtension' - -AppRegistry.registerComponent('ShareMenuModuleComponent', () => ShareExtension) diff --git a/src/ShareExtension.tsx b/src/ShareExtension.tsx deleted file mode 100644 index 621f1f69..00000000 --- a/src/ShareExtension.tsx +++ /dev/null @@ -1,43 +0,0 @@ -import { useEffect } from 'react' -import { Appearance, Pressable } from 'react-native' -import { Circle } from 'react-native-animated-spinkit' -import { ShareMenuReactView } from 'react-native-share-menu' - -// mimeType -// text/plain - text only, website URL, video?! -// image/jpeg - image -// video/mp4 - video - -const colors = { - primary: { - light: 'rgb(18, 18, 18)', - dark: 'rgb(180, 180, 180)' - }, - background: { - light: 'rgb(250, 250, 250)', - dark: 'rgb(18, 18, 18)' - } -} - -const ShareExtension = () => { - useEffect(() => { - ShareMenuReactView.continueInApp() - }, []) - - const theme = Appearance.getColorScheme() || 'light' - - return ( - - - - ) -} - -export default ShareExtension