From 4843d1c39ee036ec92825ebdc78d9fc65c4a8ff3 Mon Sep 17 00:00:00 2001 From: Ammar Ahmed <40239442+ammarahm-ed@users.noreply.github.com> Date: Mon, 26 Jun 2023 21:50:20 +0500 Subject: [PATCH] mobile: update mobile app to react-native 0.72.0 (#2814) * mobile: upgrade to react-native 0.71 * mobile: update to react-native 0.72.0 * mobile: fix release build on android * mobile: fix editor stuck in loading state * mobile: fix bootsplash logo in dark mode * mobile: update patch files * mobile: cleanup * mobile: increase delay * mobile: add logs on upload * mobile: ensure editor is ready before note loading * mobile: fix ui * mobile: fix * ci: update workflow * ci: undo workflow changes --------- Signed-off-by: Ammar Ahmed <40239442+ammarahm-ed@users.noreply.github.com> --- apps/mobile/.gitignore | 4 +- apps/mobile/__tests__/App-test.js | 1 + apps/mobile/app/common/filesystem/download.js | 1 + apps/mobile/app/common/filesystem/upload.js | 15 +- .../app/components/app-lock-overlay/index.js | 2 +- .../app/components/attachments/index.js | 94 +- apps/mobile/app/components/auth/auth-modal.js | 1 + .../app/components/auth/session-expired.js | 4 +- apps/mobile/app/hooks/use-app-events.js | 41 +- apps/mobile/app/package.json | 5 +- apps/mobile/app/screens/editor/index.tsx | 1 + apps/mobile/app/screens/editor/loading.js | 4 +- .../app/screens/editor/tiptap/commands.ts | 2 +- .../app/screens/editor/tiptap/use-editor.ts | 16 +- apps/mobile/app/screens/editor/wrapper.js | 9 +- apps/mobile/app/screens/settings/group.tsx | 2 + apps/mobile/native/.buckconfig | 6 - apps/mobile/native/.flowconfig | 75 - apps/mobile/native/Gemfile | 4 +- apps/mobile/native/android/app/build.gradle | 274 +- .../notesnook/ReactNativeFlipper.java | 2 - .../streetwriters/notesnook/MainActivity.java | 51 +- .../notesnook/MainApplication.java | 157 +- .../notesnook/OnClearFromRecentService.java | 4 +- .../notesnook/RCTNNativeModule.java | 1 - .../notesnook/ShareActivity.java | 37 +- .../MainApplicationReactNativeHost.java | 116 - .../components/MainComponentsRegistry.java | 36 - ...ApplicationTurboModuleManagerDelegate.java | 48 - .../android/app/src/main/jni/Android.mk | 48 - .../jni/MainApplicationModuleProvider.cpp | 24 - .../main/jni/MainApplicationModuleProvider.h | 16 - ...nApplicationTurboModuleManagerDelegate.cpp | 45 - ...ainApplicationTurboModuleManagerDelegate.h | 38 - .../src/main/jni/MainComponentsRegistry.cpp | 61 - .../app/src/main/jni/MainComponentsRegistry.h | 32 - .../android/app/src/main/jni/OnLoad.cpp | 11 - .../main/res/mipmap-anydpi-v26/logo_dark.xml | 5 - ...oreground.png => bootsplash_logo_dark.png} | Bin .../src/main/res/mipmap-hdpi/logo_dark.png | Bin 1218 -> 0 bytes ...oreground.png => bootsplash_logo_dark.png} | Bin .../src/main/res/mipmap-mdpi/logo_dark.png | Bin 797 -> 0 bytes ...oreground.png => bootsplash_logo_dark.png} | Bin .../src/main/res/mipmap-xhdpi/logo_dark.png | Bin 1625 -> 0 bytes ...oreground.png => bootsplash_logo_dark.png} | Bin .../src/main/res/mipmap-xxhdpi/logo_dark.png | Bin 2551 -> 0 bytes ...oreground.png => bootsplash_logo_dark.png} | Bin .../src/main/res/mipmap-xxxhdpi/logo_dark.png | Bin 3522 -> 0 bytes .../app/src/main/res/values-night/colors.xml | 8 + .../app/src/main/res/values-night/styles.xml | 45 +- .../app/src/main/res/values-night/themes.xml | 7 - .../app/src/main/res/values/colors.xml | 1 - .../main/res/values/logo_dark_background.xml | 4 - .../app/src/main/res/values/strings.xml | 1 - .../app/src/main/res/values/styles.xml | 10 +- .../notesnook/ReactNativeFlipper.java | 19 + apps/mobile/native/android/build.gradle | 61 +- apps/mobile/native/android/gradle.properties | 8 +- .../android/gradle/wrapper/gradle-wrapper.jar | Bin 59203 -> 61574 bytes .../gradle/wrapper/gradle-wrapper.properties | 2 +- apps/mobile/native/android/gradlew | 18 +- apps/mobile/native/android/gradlew.bat | 15 +- apps/mobile/native/android/settings.gradle | 8 +- .../ios/Notesnook.xcodeproj/project.pbxproj | 14 +- .../mobile/native/ios/Notesnook/AppDelegate.h | 6 +- .../native/ios/Notesnook/AppDelegate.mm | 122 +- apps/mobile/native/ios/Podfile | 64 +- apps/mobile/native/ios/Podfile.lock | 719 +- apps/mobile/native/jest.config.js | 1 - apps/mobile/native/metro.config.js | 53 +- apps/mobile/native/package.json | 42 +- apps/mobile/package-lock.json | 35502 +++++++++--- apps/mobile/package.json | 8 +- ...marahmed+notifee-react-native+7.4.4.patch} | 0 ....0.patch => @callstack+repack+3.2.0.patch} | 0 ...ve-community+cli-plugin-metro+11.3.2.patch | 24 + ....7.patch => react-native+0.69.7.patch.old} | 0 apps/mobile/patches/react-native+0.72.0.patch | 70 + ...ive-keyboard-aware-scroll-view+0.9.5.patch | 17 + ... => react-native-mmkv-storage+0.9.1.patch} | 0 ...act-native-notification-sounds+0.5.5.patch | 107 + .../patches/react-native-tooltips+1.0.3.patch | 45227 +--------------- .../react-native-vector-icons+9.2.0.patch | 15 + extensions/web-clipper/package-lock.json | 4 +- 84 files changed, 28498 insertions(+), 54997 deletions(-) delete mode 100644 apps/mobile/native/.buckconfig delete mode 100644 apps/mobile/native/.flowconfig rename apps/mobile/native/android/app/src/debug/java/com/{ => streetwriters}/notesnook/ReactNativeFlipper.java (96%) delete mode 100644 apps/mobile/native/android/app/src/main/java/com/streetwriters/notesnook/newarchitecture/MainApplicationReactNativeHost.java delete mode 100644 apps/mobile/native/android/app/src/main/java/com/streetwriters/notesnook/newarchitecture/components/MainComponentsRegistry.java delete mode 100644 apps/mobile/native/android/app/src/main/java/com/streetwriters/notesnook/newarchitecture/modules/MainApplicationTurboModuleManagerDelegate.java delete mode 100644 apps/mobile/native/android/app/src/main/jni/Android.mk delete mode 100644 apps/mobile/native/android/app/src/main/jni/MainApplicationModuleProvider.cpp delete mode 100644 apps/mobile/native/android/app/src/main/jni/MainApplicationModuleProvider.h delete mode 100644 apps/mobile/native/android/app/src/main/jni/MainApplicationTurboModuleManagerDelegate.cpp delete mode 100644 apps/mobile/native/android/app/src/main/jni/MainApplicationTurboModuleManagerDelegate.h delete mode 100644 apps/mobile/native/android/app/src/main/jni/MainComponentsRegistry.cpp delete mode 100644 apps/mobile/native/android/app/src/main/jni/MainComponentsRegistry.h delete mode 100644 apps/mobile/native/android/app/src/main/jni/OnLoad.cpp delete mode 100644 apps/mobile/native/android/app/src/main/res/mipmap-anydpi-v26/logo_dark.xml rename apps/mobile/native/android/app/src/main/res/mipmap-hdpi/{logo_dark_foreground.png => bootsplash_logo_dark.png} (100%) delete mode 100644 apps/mobile/native/android/app/src/main/res/mipmap-hdpi/logo_dark.png rename apps/mobile/native/android/app/src/main/res/mipmap-mdpi/{logo_dark_foreground.png => bootsplash_logo_dark.png} (100%) delete mode 100644 apps/mobile/native/android/app/src/main/res/mipmap-mdpi/logo_dark.png rename apps/mobile/native/android/app/src/main/res/mipmap-xhdpi/{logo_dark_foreground.png => bootsplash_logo_dark.png} (100%) delete mode 100644 apps/mobile/native/android/app/src/main/res/mipmap-xhdpi/logo_dark.png rename apps/mobile/native/android/app/src/main/res/mipmap-xxhdpi/{logo_dark_foreground.png => bootsplash_logo_dark.png} (100%) delete mode 100644 apps/mobile/native/android/app/src/main/res/mipmap-xxhdpi/logo_dark.png rename apps/mobile/native/android/app/src/main/res/mipmap-xxxhdpi/{logo_dark_foreground.png => bootsplash_logo_dark.png} (100%) delete mode 100644 apps/mobile/native/android/app/src/main/res/mipmap-xxxhdpi/logo_dark.png create mode 100644 apps/mobile/native/android/app/src/main/res/values-night/colors.xml delete mode 100644 apps/mobile/native/android/app/src/main/res/values-night/themes.xml delete mode 100644 apps/mobile/native/android/app/src/main/res/values/logo_dark_background.xml create mode 100644 apps/mobile/native/android/app/src/release/java/com/streetwriters/notesnook/ReactNativeFlipper.java rename apps/mobile/patches/{@ammarahmed+notifee-react-native+7.3.1.patch => @ammarahmed+notifee-react-native+7.4.4.patch} (100%) rename apps/mobile/patches/{@callstack+repack+3.0.0.patch => @callstack+repack+3.2.0.patch} (100%) create mode 100644 apps/mobile/patches/@react-native-community+cli-plugin-metro+11.3.2.patch rename apps/mobile/patches/{react-native+0.69.7.patch => react-native+0.69.7.patch.old} (100%) create mode 100644 apps/mobile/patches/react-native+0.72.0.patch create mode 100644 apps/mobile/patches/react-native-keyboard-aware-scroll-view+0.9.5.patch rename apps/mobile/patches/{react-native-mmkv-storage+0.8.0.patch => react-native-mmkv-storage+0.9.1.patch} (100%) create mode 100644 apps/mobile/patches/react-native-notification-sounds+0.5.5.patch create mode 100644 apps/mobile/patches/react-native-vector-icons+9.2.0.patch diff --git a/apps/mobile/.gitignore b/apps/mobile/.gitignore index d3b27e403..738a6ab8f 100644 --- a/apps/mobile/.gitignore +++ b/apps/mobile/.gitignore @@ -14,7 +14,9 @@ build_cache/ .yarnrc.yml .yarn *.log - +.cxx/ +*.keystore +!debug.keystore # Xcode # diff --git a/apps/mobile/__tests__/App-test.js b/apps/mobile/__tests__/App-test.js index 8defb77d8..1362d9405 100644 --- a/apps/mobile/__tests__/App-test.js +++ b/apps/mobile/__tests__/App-test.js @@ -3,6 +3,7 @@ */ import "react-native"; +import { it } from "@jest/globals"; // Note: test renderer must be required after react-native. import renderer from "react-test-renderer"; import Heading from "../app/components/ui/typography/heading"; diff --git a/apps/mobile/app/common/filesystem/download.js b/apps/mobile/app/common/filesystem/download.js index 0719e8878..9a3710592 100644 --- a/apps/mobile/app/common/filesystem/download.js +++ b/apps/mobile/app/common/filesystem/download.js @@ -46,6 +46,7 @@ export async function downloadFile(filename, data, cancelToken) { if (!downloadUrl) throw new Error("Unable to resolve download url"); let totalSize = 0; + console.log("Download starting"); let request = RNFetchBlob.config({ path: path, IOSBackgroundTask: true diff --git a/apps/mobile/app/common/filesystem/upload.js b/apps/mobile/app/common/filesystem/upload.js index fbc325342..19ec7446c 100644 --- a/apps/mobile/app/common/filesystem/upload.js +++ b/apps/mobile/app/common/filesystem/upload.js @@ -19,7 +19,7 @@ along with this program. If not, see . import RNFetchBlob from "react-native-blob-util"; import { useAttachmentStore } from "../../stores/use-attachment-store"; -import { db } from "../database"; +import { DatabaseLogger, db } from "../database"; import { cacheDir } from "./utils"; import { isImage, isDocument } from "@notesnook/core/utils/filename"; import { Platform } from "react-native"; @@ -29,7 +29,8 @@ export async function uploadFile(filename, data, cancelToken) { if (!data) return false; let { url, headers } = data; - console.log("uploading file: ", filename, headers); + DatabaseLogger.info(`Preparing to upload file: ${filename}`); + try { let res = await fetch(url, { method: "PUT", @@ -37,7 +38,7 @@ export async function uploadFile(filename, data, cancelToken) { }); if (!res.ok) throw new Error(`${res.status}: Unable to resolve upload url`); const uploadUrl = await res.text(); - if (!uploadUrl) throw new Error("Unable to resolve upload url"); + if (!uploadUrl) throw new Error("Unable to resolve attachment upload url"); let uploadFilePath = `${cacheDir}/${filename}`; const iosAppGroup = @@ -49,6 +50,7 @@ export async function uploadFile(filename, data, cancelToken) { if (!exists && Platform.OS === "ios") { uploadFilePath = appGroupPath; } + DatabaseLogger.info(`Starting upload: ${filename}`); let request = RNFetchBlob.config({ IOSBackgroundTask: !globalThis["IS_SHARE_EXTENSION"] }) @@ -64,7 +66,7 @@ export async function uploadFile(filename, data, cancelToken) { useAttachmentStore .getState() .setProgress(sent, total, filename, 0, "upload"); - console.log("uploading: ", sent, total); + DatabaseLogger.info(`uploading file: ${sent}/${total}`); }); cancelToken.cancel = request.cancel; let response = await request; @@ -83,11 +85,12 @@ export async function uploadFile(filename, data, cancelToken) { RNFetchBlob.fs.unlink(`${cacheDir}/${filename}`).catch(console.log); } } - + DatabaseLogger.info(`File uploaded: ${filename}`); return result; } catch (e) { useAttachmentStore.getState().remove(filename); - console.log("upload file: ", e, url, headers); + DatabaseLogger.info(`File upload error: ${filename}, ${e}`); + DatabaseLogger.error(e); return false; } } diff --git a/apps/mobile/app/components/app-lock-overlay/index.js b/apps/mobile/app/components/app-lock-overlay/index.js index ef6c3acde..cf60f4d5a 100644 --- a/apps/mobile/app/components/app-lock-overlay/index.js +++ b/apps/mobile/app/components/app-lock-overlay/index.js @@ -202,7 +202,7 @@ const AppLockedOverlay = () => { width={250} onPress={onUnlockAppRequested} icon={"fingerprint"} - type={user ? "grayAccent" : "accent"} + type="transparent" /> diff --git a/apps/mobile/app/components/attachments/index.js b/apps/mobile/app/components/attachments/index.js index b66185b46..ad780a2af 100644 --- a/apps/mobile/app/components/attachments/index.js +++ b/apps/mobile/app/components/attachments/index.js @@ -19,7 +19,7 @@ along with this program. If not, see . import React, { useRef, useState } from "react"; import { ActivityIndicator, ScrollView, View } from "react-native"; -import { FlatList } from "react-native-actions-sheet"; + import Icon from "react-native-vector-icons/MaterialCommunityIcons"; import { db } from "../../common/database"; import filesystem from "../../common/filesystem"; @@ -41,10 +41,12 @@ import { isImage, isVideo } from "@notesnook/core/utils/filename"; +import { useSettingStore } from "../../stores/use-setting-store"; +import { FlashList } from "react-native-actions-sheet/dist/src/views/FlashList"; export const AttachmentDialog = ({ note }) => { const colors = useThemeStore((state) => state.colors); - + const { height } = useSettingStore((state) => state.dimensions); const [attachments, setAttachments] = useState( note ? db.attachments.ofNote(note.id, "all") @@ -159,7 +161,8 @@ export const AttachmentDialog = ({ note }) => { style={{ width: "100%", alignSelf: "center", - paddingHorizontal: 12 + paddingHorizontal: 12, + height: height * 0.85 }} > @@ -228,51 +231,48 @@ export const AttachmentDialog = ({ note }) => { }} /> - + + {attachmentTypes.map((item) => ( +