From dfd6a46eb127b5c426724645f40a962803f8b81e Mon Sep 17 00:00:00 2001 From: dhivya0413 <120356578+dhivya0413@users.noreply.github.com> Date: Wed, 13 Sep 2023 11:53:59 +0530 Subject: [PATCH] [INJI-195] Upgrade React native version to 0.71.8 (#824) * chore(INJI-195): upgrade react native version and dependencies * chore(INJI-195): upgrade expo version and dependencies * chore(INJI-195): modify associated files on version upgrade * chore(INJI-295): fixed react native flipper and patch packages * chore(INJI-195): fix for expo prebuild * chore(INJI-195): expo linked to android/ios projects * chore(INJI-195): update metro config * chore(INJI-195): fix ios build with mmkv storage patch * chore(INJI-195): gradle version modified * chore(INJI-195): fixed rn version 0.71.8 due to mmkv library issue * chore(INJI-195): removed files in android * chore(INJI-195): fix 0.71.8 for iOS project through pods with expo linking * chore(INJI-195): fix for custom fonts added through pods due to rn linkage * chore(INJI-195): fix for removing assets.car generated from pods * Modify Node version in pipeline (#806) * chore(INJI-195): fix for android splash screen not shown up * chore(INJI-195): upgraded to node 18 in pipeline * chore(INJI-195): add the pod install twice to remove duplicates via script workaround (#807) Signed-off-by: dhivya0413 <120356578+dhivya0413@users.noreply.github.com> * INJI-195 Set the signing team for iOS (#810) * chore(INJI-195): add the pod install twice to remove duplicates via script workaround * chore(INJI-195): set the signing team for ios build --------- Signed-off-by: dhivya0413 <120356578+dhivya0413@users.noreply.github.com> * Modify github runner to self hosted runner (#811) * chore(INJI-195): add the pod install twice to remove duplicates via script workaround * chore(INJI-195): set the signing team for ios build * chore(INJI-195): set the self hosted runner for ios build --------- Signed-off-by: dhivya0413 <120356578+dhivya0413@users.noreply.github.com> * Modify self hosted runner to github hosted runner (#813) * chore(INJI-195): add the pod install twice to remove duplicates via script workaround * chore(INJI-195): set the signing team for ios build * chore(INJI-195): set the self hosted runner for ios build * chore(INJI-195): modify the self hosted to github hosted runner --------- Signed-off-by: dhivya0413 <120356578+dhivya0413@users.noreply.github.com> * chore(INJI-195): modify the self hosted to github hosted runner * chore(INJI-195): set the code signing identity for ios build * chore(INJI-195): assigned app icon files to asset --------- Signed-off-by: dhivya0413 <120356578+dhivya0413@users.noreply.github.com> Signed-off-by: Swati Goel Co-authored-by: Swati Goel --- .bundle/config | 2 + .eslintrc.js | 4 + .github/workflows/ios-build.yml | 21 +- .gitignore | 32 +- .prettierrc.js | 7 + .prettierrc.json | 13 - .watchmanconfig | 5 + README.md | 23 + .../org.eclipse.buildship.core.prefs | 13 - android/app/BUCK | 55 - android/app/build.gradle | 203 +- android/app/build_defs.bzl | 19 - android/app/src/debug/AndroidManifest.xml | 5 +- .../mosip/residentapp/ReactNativeFlipper.java | 14 +- android/app/src/main/AndroidManifest.xml | 81 +- .../io/mosip/residentapp/MainActivity.java | 20 + .../mosip/residentapp/MainActivity.java.bak | 42 - .../io/mosip/residentapp/MainApplication.java | 68 +- .../src/main/res/drawable/splashscreen.xml | 1 - .../app/src/main/res/values-night/colors.xml | 1 - android/app/src/main/res/values/colors.xml | 3 +- android/app/src/main/res/values/strings.xml | 2 +- android/app/src/main/res/values/styles.xml | 1 - .../mosip/residentapp/ReactNativeFlipper.java | 20 + android/build.gradle | 46 +- android/gradle.properties | 50 +- android/gradle/wrapper/gradle-wrapper.jar | Bin 53639 -> 59821 bytes .../gradle/wrapper/gradle-wrapper.properties | 3 +- android/gradlew | 257 +- android/gradlew.bat | 37 +- android/settings.gradle | 11 +- app.config.ts | 3 +- app.json | 4 + components/FaceScanner.tsx | 28 +- components/HelpScreen.tsx | 22 +- components/KebabPopUp.tsx | 28 +- components/LanguageSelector.tsx | 14 +- components/MessageOverlay.tsx | 20 +- components/PasscodeVerify.tsx | 14 +- components/PinInput.tsx | 20 +- components/ProgressingModal.tsx | 18 +- components/QrCodeOverlay.tsx | 20 +- components/QrScanner.tsx | 36 +- components/VcDetails.tsx | 58 +- components/VcItem.tsx | 36 +- components/VcItemActivationStatus.tsx | 38 +- components/VcItemContent.tsx | 26 +- components/ui/Modal.tsx | 14 +- components/ui/Picker.tsx | 14 +- components/ui/SetupPicker.tsx | 14 +- components/ui/TextItem.tsx | 10 +- components/ui/themes/DefaultTheme.ts | 14 +- components/ui/themes/PurpleTheme.ts | 14 +- i18n.ts | 4 +- ios/.gitignore | 30 + ios/.xcode.env | 11 + ios/Gemfile | 7 +- ios/Inji.xcodeproj/project.pbxproj | 164 +- .../xcshareddata/xcschemes/Inji.xcscheme | 9 +- ios/Inji/AppDelegate.h | 6 +- ios/Inji/AppDelegate.m | 91 - ios/Inji/AppDelegate.mm | 67 + .../AppIcon.appiconset/Contents.json | 154 +- .../AppIcon.appiconset/icon-29@3x.png | Bin 2805 -> 7218 bytes .../AppIcon.appiconset/icon-57@1x.png | Bin 2656 -> 3944 bytes .../AppIcon.appiconset/icon-60@2x.png | Bin 6846 -> 9016 bytes ios/Inji/Info.plist | 2 +- ios/Inji/Inji-Bridging-Header.h | 4 - ios/Inji/Inji.entitlements | 7 +- ios/Inji/Supporting/Expo.plist | 4 +- ios/Podfile | 118 +- ios/Podfile.lock | 777 +- ios/Podfile.properties.json | 4 +- jest.config.js | 3 + machines/app.typegen.ts | 11 +- machines/bleShare/request/requestMachine.ts | 132 +- .../request/requestMachine.typegen.ts | 24 +- machines/bleShare/request/selectors.ts | 4 +- machines/bleShare/scan/scanMachine.ts | 165 +- machines/bleShare/scan/scanMachine.typegen.ts | 26 +- machines/bleShare/scan/selectors.ts | 4 +- machines/settings.typegen.ts | 20 +- metro.config.js | 24 +- package-lock.json | 67571 ++++++++-------- package.json | 91 +- patches/react-native-elements+3.4.2.patch | 26 - patches/react-native-elements+3.4.3.patch | 22 + patches/react-native-location+2.5.0.patch | 29 + ... => react-native-mmkv-storage+0.9.1.patch} | 4 +- react-native.config.js | 9 + routes/main.ts | 14 +- routes/routesConstants.ts | 2 +- screens/AuthScreen.tsx | 18 +- screens/Home/IntroSlidersScreen.tsx | 30 +- screens/Home/MyVcs/HistoryTab.tsx | 28 +- screens/Home/MyVcs/WalletBinding.tsx | 30 +- screens/Home/MyVcsTab.tsx | 28 +- screens/Home/MyVcsTabController.ts | 20 +- screens/Home/MyVcsTabMachine.ts | 40 +- screens/Home/MyVcsTabMachine.typegen.ts | 22 +- screens/MainLayout.tsx | 48 +- screens/PasscodeScreen.tsx | 26 +- screens/Request/RequestLayout.tsx | 24 +- screens/Request/RequestLayoutController.ts | 28 +- screens/Request/RequestScreen.tsx | 36 +- screens/Scan/ScanLayout.tsx | 20 +- screens/Scan/ScanLayoutController.ts | 38 +- screens/Scan/ScanScreen.tsx | 28 +- screens/Settings/AboutInji.tsx | 28 +- screens/Settings/ReceivedCards.tsx | 18 +- screens/Settings/ReceivedCardsModal.tsx | 22 +- screens/Settings/SettingScreen.tsx | 46 +- screens/Settings/SettingScreenController.ts | 38 +- screens/SetupLanguageScreen.tsx | 26 +- screens/WelcomeScreen.tsx | 16 +- tsconfig.json | 10 +- 116 files changed, 34586 insertions(+), 37246 deletions(-) create mode 100644 .bundle/config create mode 100644 .eslintrc.js create mode 100644 .prettierrc.js delete mode 100644 .prettierrc.json create mode 100644 .watchmanconfig delete mode 100644 android/.settings/org.eclipse.buildship.core.prefs delete mode 100644 android/app/BUCK delete mode 100644 android/app/build_defs.bzl delete mode 100644 android/app/src/main/java/io/mosip/residentapp/MainActivity.java.bak create mode 100644 android/app/src/release/java/io/mosip/residentapp/ReactNativeFlipper.java create mode 100644 app.json create mode 100644 ios/.gitignore create mode 100644 ios/.xcode.env delete mode 100644 ios/Inji/AppDelegate.m create mode 100644 ios/Inji/AppDelegate.mm delete mode 100644 ios/Inji/Inji-Bridging-Header.h create mode 100644 jest.config.js delete mode 100644 patches/react-native-elements+3.4.2.patch create mode 100644 patches/react-native-elements+3.4.3.patch create mode 100644 patches/react-native-location+2.5.0.patch rename patches/{react-native-mmkv-storage+0.8.0.patch => react-native-mmkv-storage+0.9.1.patch} (84%) create mode 100644 react-native.config.js diff --git a/.bundle/config b/.bundle/config new file mode 100644 index 0000000000..d137d242ed --- /dev/null +++ b/.bundle/config @@ -0,0 +1,2 @@ +BUNDLE_PATH: "vendor/bundle" +BUNDLE_FORCE_RUBY_PLATFORM: 1 \ No newline at end of file diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000000..187894b6af --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,4 @@ +module.exports = { + root: true, + extends: '@react-native', +}; diff --git a/.github/workflows/ios-build.yml b/.github/workflows/ios-build.yml index 76d56181c5..a5a2f2e89d 100644 --- a/.github/workflows/ios-build.yml +++ b/.github/workflows/ios-build.yml @@ -1,6 +1,6 @@ name: Inji iOS build -on: +on: workflow_dispatch: inputs: mimotoBackendServiceUrl: @@ -50,22 +50,23 @@ jobs: build_ios: name: Deploying to Testflight runs-on: macos-13 - + steps: - uses: actions/checkout@v3.1.0 - uses: actions/setup-node@v3 with: - node-version: '16.x' - + node-version: '18.x' + - name: Install npm dependencies run: | npm install - + - name: Install Pod run: | cd ios pod install - + pod install + - name: Deploy iOS Beta to TestFlight run: | cd ios @@ -89,3 +90,11 @@ jobs: APPLICATION_THEME: ${{ github.event.inputs.theme }} TESTFLIGHT_INTERNAL_TESTERS_GROUP: ${{ github.event.inputs.internal-testers }} TESTFLIGHT_BETA_APP_DESCRIPTION: ${{ github.event.inputs.buildDescription }} + + - name: Upload Runner Log on Failure + if: failure() # Only run this step if the previous steps failed + uses: actions/upload-artifact@v3.1.1 + with: + name: runner-log + path: /Users/runner/Library/Logs/gym/ + retention-days: 1 diff --git a/.gitignore b/.gitignore index dc099a79d6..8daf666cf4 100644 --- a/.gitignore +++ b/.gitignore @@ -41,6 +41,7 @@ DerivedData *.ipa *.xcuserstate project.xcworkspace +ios/.xcode.env.local # Android/IntelliJ # @@ -50,6 +51,10 @@ build/ local.properties *.iml *.hprof +*.hprof +.cxx/ +*.keystore +!debug.keystore # node.js # @@ -57,6 +62,18 @@ node_modules/ npm-debug.log yarn-error.log + + +# fastlane +# +# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the +# For more information about the recommended setup visit: +# https://docs.fastlane.tools/best-practices/source-control/ +**/fastlane/report.xml +**/fastlane/Preview.html +**/fastlane/screenshots +**/fastlane/test_output + # BUCK buck-out/ \.buckd/ @@ -64,9 +81,15 @@ buck-out/ # Bundle artifacts *.jsbundle -# CocoaPods -ios/Pods/ +# Ruby / CocoaPods +/ios/Pods/ +/vendor/bundle/ +# Temporary files created by Metro to check the health of the file watcher +.metro-health-check* +# testing +/coverage +c # OS X temporary files that should never be committed .DS_Store src/components/.DS_Store @@ -94,3 +117,8 @@ temp/ yalc.lock android/app/debug.keystore + +# Expo +.expo +dist/ +web-build/ \ No newline at end of file diff --git a/.prettierrc.js b/.prettierrc.js new file mode 100644 index 0000000000..2b540746a7 --- /dev/null +++ b/.prettierrc.js @@ -0,0 +1,7 @@ +module.exports = { + arrowParens: 'avoid', + bracketSameLine: true, + bracketSpacing: false, + singleQuote: true, + trailingComma: 'all', +}; diff --git a/.prettierrc.json b/.prettierrc.json deleted file mode 100644 index 3c8528fa00..0000000000 --- a/.prettierrc.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "arrowParens": "always", - "bracketSpacing": true, - "bracketSameLine": true, - "jsxSingleQuote": false, - "quoteProps": "consistent", - "printWidth": 80, - "semi": true, - "singleQuote": true, - "tabWidth": 2, - "trailingComma": "es5", - "useTabs": false -} diff --git a/.watchmanconfig b/.watchmanconfig new file mode 100644 index 0000000000..a091263670 --- /dev/null +++ b/.watchmanconfig @@ -0,0 +1,5 @@ +{ + "ignore_dirs": [], + "fsevents_latency": 0.5, + "fsevents_try_resync": true +} diff --git a/README.md b/README.md index ef19c1bbc2..48d5ad3694 100644 --- a/README.md +++ b/README.md @@ -174,3 +174,26 @@ More info here: ## Credits Credits listed [here](/Credits.md) + +## Congratulations! :tada: + +You've successfully run and modified your React Native App. :partying_face: + +### Now what? + +- If you want to add this new React Native code to an existing application, check out the [Integration guide](https://reactnative.dev/docs/integration-with-existing-apps). +- If you're curious to learn more about React Native, check out the [Introduction to React Native](https://reactnative.dev/docs/getting-started). + +# Troubleshooting + +If you can't get this to work, see the [Troubleshooting](https://reactnative.dev/docs/troubleshooting) page. + +# Learn More + +To learn more about React Native, take a look at the following resources: + +- [React Native Website](https://reactnative.dev) - learn more about React Native. +- [Getting Started](https://reactnative.dev/docs/environment-setup) - an **overview** of React Native and how setup your environment. +- [Learn the Basics](https://reactnative.dev/docs/getting-started) - a **guided tour** of the React Native **basics**. +- [Blog](https://reactnative.dev/blog) - read the latest official React Native **Blog** posts. +- [`@facebook/react-native`](https://github.com/facebook/react-native) - the Open Source; GitHub **repository** for React Native. diff --git a/android/.settings/org.eclipse.buildship.core.prefs b/android/.settings/org.eclipse.buildship.core.prefs deleted file mode 100644 index 267336a273..0000000000 --- a/android/.settings/org.eclipse.buildship.core.prefs +++ /dev/null @@ -1,13 +0,0 @@ -arguments= -auto.sync=false -build.scans.enabled=false -connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER) -connection.project.dir= -eclipse.preferences.version=1 -gradle.user.home= -java.home=C\:/Program Files/OpenJDK/openjdk-11.0.12_7 -jvm.arguments= -offline.mode=false -override.workspace.settings=true -show.console.view=true -show.executions.view=true diff --git a/android/app/BUCK b/android/app/BUCK deleted file mode 100644 index b4ce6f6aae..0000000000 --- a/android/app/BUCK +++ /dev/null @@ -1,55 +0,0 @@ -# To learn about Buck see [Docs](https://buckbuild.com/). -# To run your application with Buck: -# - install Buck -# - `npm start` - to start the packager -# - `cd android` -# - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"` -# - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck -# - `buck install -r android/app` - compile, install and run application -# - -load(":build_defs.bzl", "create_aar_targets", "create_jar_targets") - -lib_deps = [] - -create_aar_targets(glob(["libs/*.aar"])) - -create_jar_targets(glob(["libs/*.jar"])) - -android_library( - name = "all-libs", - exported_deps = lib_deps, -) - -android_library( - name = "app-code", - srcs = glob([ - "src/main/java/**/*.java", - ]), - deps = [ - ":all-libs", - ":build_config", - ":res", - ], -) - -android_build_config( - name = "build_config", - package = "io.mosip.residentapp", -) - -android_resource( - name = "res", - package = "io.mosip.residentapp", - res = "src/main/res", -) - -android_binary( - name = "app", - keystore = "//android/keystores:debug", - manifest = "src/main/AndroidManifest.xml", - package_type = "debug", - deps = [ - ":app-code", - ], -) diff --git a/android/app/build.gradle b/android/app/build.gradle index d689d91ab8..377bf9d810 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -5,131 +5,87 @@ plugins { apply plugin: "com.android.application" apply plugin: 'com.google.gms.google-services' apply plugin: 'com.google.firebase.crashlytics' -import com.android.build.OutputFile +apply plugin: "com.facebook.react" -/** - * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets - * and bundleReleaseJsAndAssets). - * These basically call `react-native bundle` with the correct arguments during the Android build - * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the - * bundle directly from the development server. Below you can see all the possible configurations - * and their defaults. If you decide to add a configuration block, make sure to add it before the - * `apply from: "../../node_modules/react-native/react.gradle"` line. - * - * project.ext.react = [ - * // the name of the generated asset file containing your JS bundle - * bundleAssetName: "index.android.bundle", - * - * // the entry file for bundle generation. If none specified and - * // "index.android.js" exists, it will be used. Otherwise "index.js" is - * // default. Can be overridden with ENTRY_FILE environment variable. - * entryFile: "index.android.js", - * - * // https://reactnative.dev/docs/performance#enable-the-ram-format - * bundleCommand: "ram-bundle", - * - * // whether to bundle JS and assets in debug mode - * bundleInDebug: false, - * - * // whether to bundle JS and assets in release mode - * bundleInRelease: true, - * - * // whether to bundle JS and assets in another build variant (if configured). - * // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants - * // The configuration property can be in the following formats - * // 'bundleIn${productFlavor}${buildType}' - * // 'bundleIn${buildType}' - * // bundleInFreeDebug: true, - * // bundleInPaidRelease: true, - * // bundleInBeta: true, - * - * // whether to disable dev mode in custom build variants (by default only disabled in release) - * // for example: to disable dev mode in the staging build type (if configured) - * devDisabledInStaging: true, - * // The configuration property can be in the following formats - * // 'devDisabledIn${productFlavor}${buildType}' - * // 'devDisabledIn${buildType}' - * - * // the root of your project, i.e. where "package.json" lives - * root: "../../", - * - * // where to put the JS bundle asset in debug mode - * jsBundleDirDebug: "$buildDir/intermediates/assets/debug", - * - * // where to put the JS bundle asset in release mode - * jsBundleDirRelease: "$buildDir/intermediates/assets/release", - * - * // where to put drawable resources / React Native assets, e.g. the ones you use via - * // require('./image.png')), in debug mode - * resourcesDirDebug: "$buildDir/intermediates/res/merged/debug", - * - * // where to put drawable resources / React Native assets, e.g. the ones you use via - * // require('./image.png')), in release mode - * resourcesDirRelease: "$buildDir/intermediates/res/merged/release", - * - * // by default the gradle tasks are skipped if none of the JS files or assets change; this means - * // that we don't look at files in android/ or ios/ to determine whether the tasks are up to - * // date; if you have any other folders that you want to ignore for performance reasons (gradle - * // indexes the entire tree), add them here. Alternatively, if you have JS files in android/ - * // for example, you might want to remove it from here. - * inputExcludes: ["android/**", "ios/**"], - * - * // override which node gets called and with what additional arguments - * nodeExecutableAndArgs: ["node"], - * - * // supply additional arguments to the packager - * extraPackagerArgs: [] - * ] - */ - -project.ext.react = [ - enableHermes: (findProperty('expo.jsEngine') ?: "jsc") == "hermes", - bundleInDebug: true, - bundleInRelease: true, - devDisabledInRelease: true, - cliPath: new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim()).getParentFile().getAbsolutePath() + "/cli.js", - hermesCommand: new File(["node", "--print", "require.resolve('hermes-engine/package.json')"].execute(null, rootDir).text.trim()).getParentFile().getAbsolutePath() + "/%OS-BIN%/hermesc", - composeSourceMapsPath: new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim()).getParentFile().getAbsolutePath() + "/scripts/compose-source-maps.js", -] +import com.android.build.OutputFile -apply from: new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim(), "../react.gradle") +react { + /* Folders */ + // The root of your project, i.e. where "package.json" lives. Default is '..' + // root = file("../") + // The folder where the react-native NPM package is. Default is ../node_modules/react-native + // reactNativeDir = file("../node_modules/react-native") + // The folder where the react-native Codegen package is. Default is ../node_modules/@react-native/codegen + // codegenDir = file("../node_modules/@react-native/codegen") + // The cli.js file which is the React Native CLI entrypoint. Default is ../node_modules/react-native/cli.js + // cliFile = file("../node_modules/react-native/cli.js") + /* Variants */ + // The list of variants to that are debuggable. For those we're going to + // skip the bundling of the JS bundle and the assets. By default is just 'debug'. + // If you add flavors like lite, prod, etc. you'll have to list your debuggableVariants. + // debuggableVariants = ["liteDebug", "prodDebug"] + /* Bundling */ + // A list containing the node command and its flags. Default is just 'node'. + // nodeExecutableAndArgs = ["node"] + // + // The command to run when bundling. By default is 'bundle' + // bundleCommand = "ram-bundle" + // + // The path to the CLI configuration file. Default is empty. + // bundleConfig = file(../rn-cli.config.js) + // + // The name of the generated asset file containing your JS bundle + // bundleAssetName = "MyApplication.android.bundle" + // + // The entry file for bundle generation. Default is 'index.android.js' or 'index.js' + // entryFile = file("../js/MyApplication.android.js") + // + // A list of extra flags to pass to the 'bundle' commands. + // See https://github.com/react-native-community/cli/blob/main/docs/commands.md#bundle + // extraPackagerArgs = [] + /* Hermes Commands */ + // The hermes compiler command to run. By default it is 'hermesc' + // hermesCommand = "$rootDir/my-custom-hermesc/bin/hermesc" + // + // The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map" + // hermesFlags = ["-O", "-output-source-map"] +} /** - * Set this to true to create two separate APKs instead of one: - * - An APK that only works on ARM devices - * - An APK that only works on x86 devices - * The advantage is the size of the APK is reduced by about 4MB. - * Upload all the APKs to the Play Store and people will download - * the correct one based on the CPU architecture of their device. + * Set this to true to create four separate APKs instead of one, + * one for each native architecture. This is useful if you don't + * use App Bundles (https://developer.android.com/guide/app-bundle/) + * and want to have separate APKs to upload to the Play Store. */ def enableSeparateBuildPerCPUArchitecture = true /** - * Run Proguard to shrink the Java bytecode in release builds. + * Set this to true to Run Proguard on Release builds to minify the Java bytecode. */ def enableProguardInReleaseBuilds = false /** - * The preferred build flavor of JavaScriptCore. + * The preferred build flavor of JavaScriptCore (JSC) * * For example, to use the international variant, you can use: * `def jscFlavor = 'org.webkit:android-jsc-intl:+'` * * The international variant includes ICU i18n library and necessary data * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that - * give correct results when using with locales other than en-US. Note that + * give correct results when using with locales other than en-US. Note that * this variant is about 6MiB larger per architecture than default. */ def jscFlavor = 'org.webkit:android-jsc:+' /** - * Whether to enable the Hermes VM. - * - * This should be set on project.ext.react and mirrored here. If it is not set - * on project.ext.react, JavaScript will not be compiled to Hermes Bytecode - * and the benefits of using Hermes will therefore be sharply reduced. + * Private function to get the list of Native Architectures you want to build. + * This reads the value from reactNativeArchitectures in your gradle.properties + * file and works together with the --active-arch-only flag of react-native run-android. */ -def enableHermes = project.ext.react.get("enableHermes", false); +def reactNativeArchitectures() { + def value = project.getProperties().get("reactNativeArchitectures") + return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"] +} androidGitVersion { baseCode 0 @@ -138,19 +94,20 @@ androidGitVersion { } android { + ndkVersion rootProject.ext.ndkVersion compileSdkVersion rootProject.ext.compileSdkVersion ext { APP_NAME_RELEASE = "@string/app_name" - APP_NAME_PH = "@string/app_name_ph" APP_NAME_MOSIP = "@string/app_name_mosip" APP_NAME_BETA = "@string/app_name_beta" } - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } + + namespace 'io.mosip.residentapp' + + + namespace 'io.mosip.residentapp' defaultConfig { applicationId 'io.mosip.residentapp' @@ -175,6 +132,7 @@ android { include "armeabi-v7a", "x86", "arm64-v8a", "x86_64" } } + signingConfigs { release { def keystore = file('release.keystore') @@ -233,13 +191,6 @@ android { ] dimension "inji" } - ph { - versionName defaultConfig.versionName + "-ph" - manifestPlaceholders = [ - APP_NAME: APP_NAME_PH - ] - dimension "inji" - } } android.applicationVariants.all { variant -> @@ -252,9 +203,10 @@ android { } dependencies { - implementation fileTree(dir: "libs", include: ["*.jar"]) - //noinspection GradleDynamicVersion - implementation "com.facebook.react:react-native:+"// From node_modules + + // The version of react-native is set by the React Native Gradle Plugin + implementation("com.facebook.react:react-android") + implementation 'com.facebook.soloader:soloader:0.10.1+' def isGifEnabled = (findProperty('expo.gif.enabled') ?: "") == "true"; @@ -283,9 +235,7 @@ dependencies { } implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0" - debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") { - exclude group:'com.facebook.fbjni' - } + debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") { exclude group:'com.facebook.flipper' exclude group:'com.squareup.okhttp3', module:'okhttp' @@ -294,9 +244,8 @@ dependencies { exclude group:'com.facebook.flipper' } - if (enableHermes) { - debugImplementation files(new File(["node", "--print", "require.resolve('hermes-engine/package.json')"].execute(null, rootDir).text.trim(), "../android/hermes-debug.aar")) - releaseImplementation files(new File(["node", "--print", "require.resolve('hermes-engine/package.json')"].execute(null, rootDir).text.trim(), "../android/hermes-release.aar")) + if (hermesEnabled.toBoolean()) { + implementation("com.facebook.react:hermes-android") } else { implementation jscFlavor } @@ -306,15 +255,7 @@ dependencies { implementation 'com.jakewharton.timber:timber:4.7.1' } -// Run this once to be able to run the application with BUCK -// puts all compile dependencies into folder libs for BUCK to use -task copyDownloadableDepsToLibs(type: Copy) { - from configurations.compile - into 'libs' -} - -apply from: new File(["node", "--print", "require.resolve('@react-native-community/cli-platform-android/package.json')"].execute(null, rootDir).text.trim(), "../native_modules.gradle"); -applyNativeModulesAppBuildGradle(project) +apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project) apply from: "./eas-build.gradle" try { diff --git a/android/app/build_defs.bzl b/android/app/build_defs.bzl deleted file mode 100644 index fff270f8d1..0000000000 --- a/android/app/build_defs.bzl +++ /dev/null @@ -1,19 +0,0 @@ -"""Helper definitions to glob .aar and .jar targets""" - -def create_aar_targets(aarfiles): - for aarfile in aarfiles: - name = "aars__" + aarfile[aarfile.rindex("/") + 1:aarfile.rindex(".aar")] - lib_deps.append(":" + name) - android_prebuilt_aar( - name = name, - aar = aarfile, - ) - -def create_jar_targets(jarfiles): - for jarfile in jarfiles: - name = "jars__" + jarfile[jarfile.rindex("/") + 1:jarfile.rindex(".jar")] - lib_deps.append(":" + name) - prebuilt_jar( - name = name, - binary_jar = jarfile, - ) diff --git a/android/app/src/debug/AndroidManifest.xml b/android/app/src/debug/AndroidManifest.xml index a1bdc91d6b..77f4f4f18b 100644 --- a/android/app/src/debug/AndroidManifest.xml +++ b/android/app/src/debug/AndroidManifest.xml @@ -12,5 +12,8 @@ - + + + + diff --git a/android/app/src/debug/java/io/mosip/residentapp/ReactNativeFlipper.java b/android/app/src/debug/java/io/mosip/residentapp/ReactNativeFlipper.java index ef368bd9d2..f4263ee7e6 100644 --- a/android/app/src/debug/java/io/mosip/residentapp/ReactNativeFlipper.java +++ b/android/app/src/debug/java/io/mosip/residentapp/ReactNativeFlipper.java @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * Copyright (c) Meta Platforms, Inc. and affiliates. * *

This source code is licensed under the MIT license found in the LICENSE file in the root * directory of this source tree. @@ -17,22 +17,27 @@ import com.facebook.flipper.plugins.inspector.InspectorFlipperPlugin; import com.facebook.flipper.plugins.network.FlipperOkhttpInterceptor; import com.facebook.flipper.plugins.network.NetworkFlipperPlugin; -import com.facebook.flipper.plugins.react.ReactFlipperPlugin; import com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin; +import com.facebook.react.ReactInstanceEventListener; import com.facebook.react.ReactInstanceManager; import com.facebook.react.bridge.ReactContext; import com.facebook.react.modules.network.NetworkingModule; import okhttp3.OkHttpClient; +/** + * Class responsible of loading Flipper inside your React Native application. This is the debug + * flavor of it. Here you can add your own plugins and customize the Flipper setup. + */ public class ReactNativeFlipper { public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) { if (FlipperUtils.shouldEnableFlipper(context)) { final FlipperClient client = AndroidFlipperClient.getInstance(context); + client.addPlugin(new InspectorFlipperPlugin(context, DescriptorMapping.withDefaults())); - client.addPlugin(new ReactFlipperPlugin()); client.addPlugin(new DatabasesFlipperPlugin(context)); client.addPlugin(new SharedPreferencesFlipperPlugin(context)); client.addPlugin(CrashReporterPlugin.getInstance()); + NetworkFlipperPlugin networkFlipperPlugin = new NetworkFlipperPlugin(); NetworkingModule.setCustomClientBuilder( new NetworkingModule.CustomClientBuilder() { @@ -43,12 +48,13 @@ public void apply(OkHttpClient.Builder builder) { }); client.addPlugin(networkFlipperPlugin); client.start(); + // Fresco Plugin needs to ensure that ImagePipelineFactory is initialized // Hence we run if after all native modules have been initialized ReactContext reactContext = reactInstanceManager.getCurrentReactContext(); if (reactContext == null) { reactInstanceManager.addReactInstanceEventListener( - new ReactInstanceManager.ReactInstanceEventListener() { + new ReactInstanceEventListener() { @Override public void onReactContextInitialized(ReactContext reactContext) { reactInstanceManager.removeReactInstanceEventListener(this); diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 047aeb58cb..1233607628 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -1,54 +1,51 @@ - + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - - - + + + - - - - - - - - - + + + + + + + + - - + + - - - - + + + + - + - + \ No newline at end of file diff --git a/android/app/src/main/java/io/mosip/residentapp/MainActivity.java b/android/app/src/main/java/io/mosip/residentapp/MainActivity.java index 61304f517c..cf7449c3ae 100644 --- a/android/app/src/main/java/io/mosip/residentapp/MainActivity.java +++ b/android/app/src/main/java/io/mosip/residentapp/MainActivity.java @@ -1,4 +1,5 @@ package io.mosip.residentapp; +import expo.modules.ReactActivityDelegateWrapper; import android.Manifest; import android.content.Context; @@ -13,6 +14,9 @@ import com.facebook.react.ReactActivity; import com.facebook.react.ReactActivityDelegate; import com.facebook.react.ReactRootView; +import com.facebook.react.ReactActivityDelegate; +import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint; +import com.facebook.react.defaults.DefaultReactActivityDelegate; import expo.modules.ReactActivityDelegateWrapper; /** @@ -108,4 +112,20 @@ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permis } recreate(); } + + /** + * Returns the instance of the {@link ReactActivityDelegate}. Here we use a util class {@link + * DefaultReactActivityDelegate} which allows you to easily enable Fabric and Concurrent React + * (aka React 18) with two boolean flags. + */ + @Override + protected ReactActivityDelegate createReactActivityDelegate() { + return new ReactActivityDelegateWrapper(this, BuildConfig.IS_NEW_ARCHITECTURE_ENABLED, new DefaultReactActivityDelegate( this, + getMainComponentName(), + // If you opted-in for the New Architecture, we enable the Fabric Renderer. + DefaultNewArchitectureEntryPoint.getFabricEnabled(), // fabricEnabled + // If you opted-in for the New Architecture, we enable Concurrent React (i.e. React 18). + DefaultNewArchitectureEntryPoint.getConcurrentReactEnabled() // concurrentRootEnabled + )); + } } diff --git a/android/app/src/main/java/io/mosip/residentapp/MainActivity.java.bak b/android/app/src/main/java/io/mosip/residentapp/MainActivity.java.bak deleted file mode 100644 index 329fdf4c21..0000000000 --- a/android/app/src/main/java/io/mosip/residentapp/MainActivity.java.bak +++ /dev/null @@ -1,42 +0,0 @@ -package io.mosip.residentapp; - -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; - -public class MainActivity extends ReactActivity { - @Override - protected void onCreate(Bundle savedInstanceState) { - // Set the theme to AppTheme BEFORE onCreate to support - // coloring the background, status bar, and navigation bar. - // This is required for expo-splash-screen. - setTheme(R.style.AppTheme); - super.onCreate(null); - } - - /** - * Returns the name of the main component registered from JavaScript. - * This is used to schedule rendering of the component. - */ - @Override - 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); - } - }); - } -} diff --git a/android/app/src/main/java/io/mosip/residentapp/MainApplication.java b/android/app/src/main/java/io/mosip/residentapp/MainApplication.java index 80c0d4bf5c..d952ffcff7 100644 --- a/android/app/src/main/java/io/mosip/residentapp/MainApplication.java +++ b/android/app/src/main/java/io/mosip/residentapp/MainApplication.java @@ -1,4 +1,6 @@ package io.mosip.residentapp; +import expo.modules.ApplicationLifecycleDispatcher; +import expo.modules.ReactNativeHostWrapper; import android.app.Application; import android.content.Context; @@ -12,10 +14,10 @@ import com.facebook.react.ReactInstanceManager; import com.facebook.react.ReactNativeHost; import com.facebook.react.ReactPackage; +import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint; +import com.facebook.react.defaults.DefaultReactNativeHost; import com.facebook.soloader.SoLoader; -import expo.modules.ApplicationLifecycleDispatcher; -import expo.modules.ReactNativeHostWrapper; import timber.log.Timber; import com.facebook.react.bridge.JSIModulePackage; @@ -26,9 +28,8 @@ import java.util.List; public class MainApplication extends Application implements ReactApplication { - private final ReactNativeHost mReactNativeHost = new ReactNativeHostWrapper( - this, - new ReactNativeHost(this) { + private final ReactNativeHost mReactNativeHost = + new ReactNativeHostWrapper(this, new DefaultReactNativeHost(this) { @Override public boolean getUseDeveloperSupport() { return BuildConfig.DEBUG; @@ -47,6 +48,14 @@ protected List getPackages() { protected String getJSMainModuleName() { return "index"; } + @Override + protected boolean isNewArchEnabled() { + return BuildConfig.IS_NEW_ARCHITECTURE_ENABLED; + } + @Override + protected Boolean isHermesEnabled() { + return BuildConfig.IS_HERMES_ENABLED; + } }); @Override @@ -59,8 +68,11 @@ public void onCreate() { super.onCreate(); SoLoader.init(this, /* native exopackage */ false); - initializeFlipper(this, getReactNativeHost().getReactInstanceManager()); - ApplicationLifecycleDispatcher.onApplicationCreate(this); + if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) { + // If you opted-in for the New Architecture, we load the native entry point for this app. + DefaultNewArchitectureEntryPoint.load(); + } + ReactNativeFlipper.initializeFlipper(this, getReactNativeHost().getReactInstanceManager()); if (BuildConfig.DEBUG) { Timber.plant(new Timber.DebugTree()); @@ -68,44 +80,10 @@ public void onCreate() { // Setup Firebase FirebaseAnalytics.getInstance(this); Timber.plant(new CrashReportingTree()); + ApplicationLifecycleDispatcher.onApplicationCreate(this); } - @Override - public void onConfigurationChanged(@NonNull Configuration newConfig) { - super.onConfigurationChanged(newConfig); - ApplicationLifecycleDispatcher.onConfigurationChanged(this, newConfig); - } - /** - * Loads Flipper in React Native templates. Call this in the onCreate method with something like - * initializeFlipper(this, getReactNativeHost().getReactInstanceManager()); - * - * @param context - * @param reactInstanceManager - */ - private static void initializeFlipper( - Context context, ReactInstanceManager reactInstanceManager) { - if (BuildConfig.DEBUG) { - try { - /* - We use reflection here to pick up the class that initializes Flipper, - since Flipper library is not available in release mode - */ - Class aClass = Class.forName("io.mosip.residentapp.ReactNativeFlipper"); - aClass - .getMethod("initializeFlipper", Context.class, ReactInstanceManager.class) - .invoke(null, context, reactInstanceManager); - } catch (ClassNotFoundException e) { - e.printStackTrace(); - } catch (NoSuchMethodException e) { - e.printStackTrace(); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } catch (InvocationTargetException e) { - e.printStackTrace(); - } - } - } /** * A tree which logs important information for crash reporting. */ @@ -128,4 +106,10 @@ protected void log(int priority, String tag, @NonNull String message, Throwable } } } + + @Override + public void onConfigurationChanged(Configuration newConfig) { + super.onConfigurationChanged(newConfig); + ApplicationLifecycleDispatcher.onConfigurationChanged(this, newConfig); + } } diff --git a/android/app/src/main/res/drawable/splashscreen.xml b/android/app/src/main/res/drawable/splashscreen.xml index b6846e4731..341aa5379f 100644 --- a/android/app/src/main/res/drawable/splashscreen.xml +++ b/android/app/src/main/res/drawable/splashscreen.xml @@ -1,4 +1,3 @@ - diff --git a/android/app/src/main/res/values-night/colors.xml b/android/app/src/main/res/values-night/colors.xml index 9dc2f904b3..3c05de5be8 100644 --- a/android/app/src/main/res/values-night/colors.xml +++ b/android/app/src/main/res/values-night/colors.xml @@ -1,2 +1 @@ - \ No newline at end of file diff --git a/android/app/src/main/res/values/colors.xml b/android/app/src/main/res/values/colors.xml index b95dc16474..b1e869b65d 100644 --- a/android/app/src/main/res/values/colors.xml +++ b/android/app/src/main/res/values/colors.xml @@ -1,6 +1,5 @@ - - #FFFFFF + #ffffff #FFFFFF #023c69 #ffffff diff --git a/android/app/src/main/res/values/strings.xml b/android/app/src/main/res/values/strings.xml index ff10a980a0..811dbf265d 100644 --- a/android/app/src/main/res/values/strings.xml +++ b/android/app/src/main/res/values/strings.xml @@ -1,4 +1,3 @@ - Inji MOSIP Resident App - Mosip/Inji @@ -6,4 +5,5 @@ MOSIP Resident App - PH cover false + undefined \ No newline at end of file diff --git a/android/app/src/main/res/values/styles.xml b/android/app/src/main/res/values/styles.xml index bef78ada36..b0cbdbeb18 100644 --- a/android/app/src/main/res/values/styles.xml +++ b/android/app/src/main/res/values/styles.xml @@ -1,4 +1,3 @@ -