From 37cfb59216d9ea4aeb28e90baae4d1a94f5c1965 Mon Sep 17 00:00:00 2001 From: Nikolai R Kristiansen Date: Mon, 27 Sep 2021 23:42:49 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20Android=20build=20update?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ref: https://react-native-community.github.io/upgrade-helper/?from=0.59.0&to=0.66.0-rc.4 --- .eslintrc | 4 +- .flowconfig | 74 ++++++++-------- .gitignore | 3 +- README.md | 4 + android/app/{BUCK => _BUCK} | 0 android/app/build.gradle | 81 +++++++++++++++--- android/app/debug.keystore | Bin 0 -> 2257 bytes android/app/proguard-rules.pro | 7 -- android/app/src/debug/AndroidManifest.xml | 9 +- android/app/src/main/AndroidManifest.xml | 4 +- .../java/no/neuf/chateau/MainActivity.java | 8 +- .../java/no/neuf/chateau/MainApplication.java | 69 +++++++++++---- .../no/neuf/chateau/ReactNativeFlipper.java | 72 ++++++++++++++++ android/app/src/main/res/values/styles.xml | 2 +- android/build.gradle | 28 +++--- android/gradle.properties | 10 +++ .../gradle/wrapper/gradle-wrapper.properties | 2 +- android/gradlew.bat | 45 +++++----- android/keystores/BUCK | 8 -- android/keystores/debug.keystore.properties | 4 - android/settings.gradle | 3 +- jestSetup.js | 17 ++-- package.json | 2 +- src/modules/membership/Proof.js | 5 +- src/modules/membership/useProof.js | 1 - 25 files changed, 317 insertions(+), 145 deletions(-) rename android/app/{BUCK => _BUCK} (100%) create mode 100644 android/app/debug.keystore create mode 100644 android/app/src/main/java/no/neuf/chateau/ReactNativeFlipper.java delete mode 100644 android/keystores/BUCK delete mode 100644 android/keystores/debug.keystore.properties diff --git a/.eslintrc b/.eslintrc index 468dcf8..426151d 100644 --- a/.eslintrc +++ b/.eslintrc @@ -4,7 +4,7 @@ "plugin:prettier/recommended", "plugin:react/recommended", "plugin:import/errors", - "plugin:import/warnings", + "plugin:import/warnings" ], "rules": { "no-plusplus": 0, @@ -27,7 +27,7 @@ "parser": "@babel/eslint-parser", "settings": { "react": { - "version": "16.8" + "version": "detect" } } } diff --git a/.flowconfig b/.flowconfig index 47d80d9..005d5c4 100644 --- a/.flowconfig +++ b/.flowconfig @@ -5,65 +5,61 @@ ; Ignore "BUCK" generated dirs /\.buckd/ -; Ignore unexpected extra "@providesModule" -.*/node_modules/.*/node_modules/fbjs/.* - -; Ignore duplicate module providers -; For RN Apps installed via npm, "Libraries" folder is inside -; "node_modules/react-native" but in the source repo it is in the root -.*/Libraries/react-native/React.js - ; Ignore polyfills -.*/Libraries/polyfills/.* +node_modules/react-native/Libraries/polyfills/.* -; Ignore metro -.*/node_modules/metro/.* +; Flow doesn't support platforms +.*/Libraries/Utilities/LoadingView.js + +[untyped] +.*/node_modules/@react-native-community/cli/.*/.* [include] [libs] -node_modules/react-native/Libraries/react-native/react-native-interface.js +node_modules/react-native/interface.js node_modules/react-native/flow/ [options] emoji=true -esproposal.optional_chaining=enable -esproposal.nullish_coalescing=enable +exact_by_default=true -module.system=haste -module.system.haste.use_name_reducers=true -# get basename -module.system.haste.name_reducers='^.*/\([a-zA-Z0-9$_.-]+\.js\(\.flow\)?\)$' -> '\1' -# strip .js or .js.flow suffix -module.system.haste.name_reducers='^\(.*\)\.js\(\.flow\)?$' -> '\1' -# strip .ios suffix -module.system.haste.name_reducers='^\(.*\)\.ios$' -> '\1' -module.system.haste.name_reducers='^\(.*\)\.android$' -> '\1' -module.system.haste.name_reducers='^\(.*\)\.native$' -> '\1' -module.system.haste.paths.blacklist=.*/__tests__/.* -module.system.haste.paths.blacklist=.*/__mocks__/.* -module.system.haste.paths.blacklist=/node_modules/react-native/Libraries/Animated/src/polyfills/.* -module.system.haste.paths.whitelist=/node_modules/react-native/Libraries/.* +format.bracket_spacing=false + +module.file_ext=.js +module.file_ext=.json +module.file_ext=.ios.js munge_underscores=true -module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub' - -module.file_ext=.js -module.file_ext=.jsx -module.file_ext=.json -module.file_ext=.native.js +module.name_mapper='^react-native/\(.*\)$' -> '/node_modules/react-native/\1' +module.name_mapper='^@?[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> '/node_modules/react-native/Libraries/Image/RelativeImageStub' suppress_type=$FlowIssue suppress_type=$FlowFixMe suppress_type=$FlowFixMeProps suppress_type=$FlowFixMeState -suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\) -suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+ -suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy -suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError +[lints] +sketchy-null-number=warn +sketchy-null-mixed=warn +sketchy-number=warn +untyped-type-import=warn +nonstrict-import=warn +deprecated-type=warn +unsafe-getters-setters=warn +unnecessary-invariant=warn +signature-verification-failure=warn + +[strict] +deprecated-type +nonstrict-import +sketchy-null +unclear-type +unsafe-getters-setters +untyped-import +untyped-type-import [version] -^0.92.0 +^0.158.0 \ No newline at end of file diff --git a/.gitignore b/.gitignore index 46dcdd7..fa7367d 100644 --- a/.gitignore +++ b/.gitignore @@ -20,7 +20,6 @@ DerivedData *.hmap *.ipa *.xcuserstate -project.xcworkspace # Android/IntelliJ # @@ -28,6 +27,7 @@ project.xcworkspace .gradle local.properties *.iml +*.hprof # node.js # @@ -39,6 +39,7 @@ yarn-error.log buck-out/ \.buckd/ *.keystore +!debug.keystore # fastlane # diff --git a/README.md b/README.md index ebff242..f835c52 100644 --- a/README.md +++ b/README.md @@ -54,3 +54,7 @@ We use fastlane and certificate management via fastlane match. Ask nikolai@stude ## Libraries We use https://nativebase.io/ for generic UI components + + +## TODO upgrade: + - `@react-native-community/eslint-config"` \ No newline at end of file diff --git a/android/app/BUCK b/android/app/_BUCK similarity index 100% rename from android/app/BUCK rename to android/app/_BUCK diff --git a/android/app/build.gradle b/android/app/build.gradle index 0276ae8..b10294f 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -74,7 +74,7 @@ import com.android.build.OutputFile */ project.ext.react = [ - entryFile: "index.js" + enableHermes: false, // clean and rebuild if changing ] apply from: "../../node_modules/react-native/react.gradle" @@ -94,13 +94,34 @@ def enableSeparateBuildPerCPUArchitecture = false */ def enableProguardInReleaseBuilds = false -android { - compileSdkVersion rootProject.ext.compileSdkVersion +/** + * The preferred build flavor of JavaScriptCore. + * + * 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 + * 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. + */ +def enableHermes = project.ext.react.get("enableHermes", false); +/** + * Architectures to build native code for in debug. + */ +def nativeArchitectures = project.getProperties().get("reactNativeDebugArchitectures") - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } +android { + ndkVersion rootProject.ext.ndkVersion + compileSdkVersion rootProject.ext.compileSdkVersion defaultConfig { applicationId "no.neuf.chateau" @@ -118,6 +139,12 @@ android { } } signingConfigs { + debug { + storeFile file('debug.keystore') + storePassword 'android' + keyAlias 'androiddebugkey' + keyPassword 'android' + } release { // These variables are in ~/.gradle/gradle.properties if (project.hasProperty('DUSKEN_RELEASE_STORE_FILE')) { @@ -129,6 +156,14 @@ android { } } buildTypes { + debug { + signingConfig signingConfigs.debug + if (nativeArchitectures) { + ndk { + abiFilters nativeArchitectures.split(',') + } + } + } release { minifyEnabled enableProguardInReleaseBuilds proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" @@ -139,19 +174,19 @@ android { applicationVariants.all { variant -> variant.outputs.each { output -> // For each separate APK per architecture, set a unique version code as described here: - // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits - def versionCodes = ["armeabi-v7a":1, "x86":2, "arm64-v8a": 3, "x86_64": 4] + // https://developer.android.com/studio/build/configure-apk-splits.html + // Example: versionCode 1 will generate 1001 for armeabi-v7a, 1002 for x86, etc. + def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4] def abi = output.getFilter(OutputFile.ABI) if (abi != null) { // null for the universal-debug, universal-release variants output.versionCodeOverride = - versionCodes.get(abi) * 1048576 + defaultConfig.versionCode + defaultConfig.versionCode * 1000 + versionCodes.get(abi) } } } } dependencies { - implementation project(':@react-native-community_async-storage') implementation project(':react-native-sentry') implementation project(':tipsi-stripe') implementation project(':react-native-vector-icons') @@ -159,12 +194,34 @@ dependencies { implementation project(':react-native-gesture-handler') implementation fileTree(dir: "libs", include: ["*.jar"]) implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}" + //noinspection GradleDynamicVersion implementation "com.facebook.react:react-native:+" // From node_modules + + implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0" + debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") { + exclude group:'com.facebook.fbjni' + } + debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") { + exclude group:'com.facebook.flipper' + exclude group:'com.squareup.okhttp3', module:'okhttp' + } + debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") { + exclude group:'com.facebook.flipper' + } + if (enableHermes) { + def hermesPath = "../../node_modules/hermes-engine/android/"; + debugImplementation files(hermesPath + "hermes-debug.aar") + releaseImplementation files(hermesPath + "hermes-release.aar") + } else { + implementation jscFlavor + } } // 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 + from configurations.implementation into 'libs' } + +apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project) \ No newline at end of file diff --git a/android/app/debug.keystore b/android/app/debug.keystore new file mode 100644 index 0000000000000000000000000000000000000000..364e105ed39fbfd62001429a68140672b06ec0de GIT binary patch literal 2257 zcmchYXEfYt8;7T1^dLH$VOTZ%2NOdOH5j5LYLtZ0q7x-V8_6gU5)#7dkq{HTmsfNq zB3ZqcAxeY^G10@?efK?Q&)M(qInVv!xjx+IKEL}p*K@LYvIzo#AZG>st5|P)KF1_Z;y){W{<7K{nl!CPuE z_^(!C(Ol0n8 zK13*rzAtW>(wULKPRYLd7G18F8#1P`V*9`(Poj26eOXYyBVZPno~Cvvhx7vPjAuZo zF?VD!zB~QG(!zbw#qsxT8%BSpqMZ4f70ZPn-3y$L8{EVbbN9$H`B&Z1quk9tgp5FM zuxp3pJ0b8u|3+#5bkJ4SRnCF2l7#DyLYXYY8*?OuAwK4E6J{0N=O3QNVzQ$L#FKkR zi-c@&!nDvezOV$i$Lr}iF$XEcwnybQ6WZrMKuw8gCL^U#D;q3t&HpTbqyD%vG=TeDlzCT~MXUPC|Leb-Uk+ z=vnMd(|>ld?Fh>V8poP;q;;nc@en$|rnP0ytzD&fFkCeUE^kG9Kx4wUh!!rpjwKDP zyw_e|a^x_w3E zP}}@$g>*LLJ4i0`Gx)qltL}@;mDv}D*xR^oeWcWdPkW@Uu)B^X&4W1$p6}ze!zudJ zyiLg@uggoMIArBr*27EZV7djDg@W1MaL+rcZ-lrANJQ%%>u8)ZMWU@R2qtnmG(acP z0d_^!t>}5W zpT`*2NR+0+SpTHb+6Js4b;%LJB;B_-ChhnU5py}iJtku*hm5F0!iql8Hrpcy1aYbT z1*dKC5ua6pMX@@iONI?Hpr%h;&YaXp9n!ND7-=a%BD7v&g zOO41M6EbE24mJ#S$Ui0-brR5ML%@|ndz^)YLMMV1atna{Fw<;TF@>d&F|!Z>8eg>>hkFrV)W+uv=`^F9^e zzzM2*oOjT9%gLoub%(R57p-`TXFe#oh1_{&N-YN z<}artH|m=d8TQuKSWE)Z%puU|g|^^NFwC#N=@dPhasyYjoy(fdEVfKR@cXKHZV-`06HsP`|Ftx;8(YD$fFXumLWbGnu$GMqRncXYY9mwz9$ap zQtfZB^_BeNYITh^hA7+(XNFox5WMeG_LtJ%*Q}$8VKDI_p8^pqX)}NMb`0e|wgF7D zuQACY_Ua<1ri{;Jwt@_1sW9zzdgnyh_O#8y+C;LcZq6=4e^cs6KvmK@$vVpKFGbQ= z$)Eux5C|Fx;Gtmv9^#Y-g@7Rt7*eLp5n!gJmn7&B_L$G?NCN`AP>cXQEz}%F%K;vUs{+l4Q{}eWW;ATe2 zqvXzxoIDy(u;F2q1JH7Sf;{jy_j})F+cKlIOmNfjBGHoG^CN zM|Ho&&X|L-36f}Q-obEACz`sI%2f&k>z5c$2TyTSj~vmO)BW~+N^kt`Jt@R|s!){H ze1_eCrlNaPkJQhL$WG&iRvF*YG=gXd1IyYQ9ew|iYn7r~g!wOnw;@n42>enAxBv*A zEmV*N#sxdicyNM=A4|yaOC5MByts}s_Hpfj|y<6G=o=!3S@eIFKDdpR7|FY>L&Wat&oW&cm&X~ z5Bt>Fcq(fgnvlvLSYg&o6>&fY`ODg4`V^lWWD=%oJ#Kbad2u~! zLECFS*??>|vDsNR&pH=Ze0Eo`sC_G`OjoEKVHY|wmwlX&(XBE<@sx3Hd^gtd-fNwUHsylg06p`U2y_={u}Bc - - + + + + \ No newline at end of file diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index cd86bba..72da13c 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -12,14 +12,14 @@ - diff --git a/android/app/src/main/java/no/neuf/chateau/MainActivity.java b/android/app/src/main/java/no/neuf/chateau/MainActivity.java index 0d548ee..99b7e8c 100644 --- a/android/app/src/main/java/no/neuf/chateau/MainActivity.java +++ b/android/app/src/main/java/no/neuf/chateau/MainActivity.java @@ -4,10 +4,10 @@ import com.facebook.react.ReactActivity; public class MainActivity extends ReactActivity { - /** - * Returns the name of the main component registered from JavaScript. - * This is used to schedule rendering of the component. - */ + /** + * Returns the name of the main component registered from JavaScript. This is used to schedule + * rendering of the component. + */ @Override protected String getMainComponentName() { return "Dusken"; diff --git a/android/app/src/main/java/no/neuf/chateau/MainApplication.java b/android/app/src/main/java/no/neuf/chateau/MainApplication.java index db49554..9469d8b 100644 --- a/android/app/src/main/java/no/neuf/chateau/MainApplication.java +++ b/android/app/src/main/java/no/neuf/chateau/MainApplication.java @@ -1,25 +1,28 @@ package no.neuf.chateau; import android.app.Application; - +import android.content.Context; +import com.facebook.react.PackageList; import com.facebook.react.ReactApplication; -import com.reactnativecommunity.asyncstorage.AsyncStoragePackage; -import io.sentry.RNSentryPackage; -import com.gettipsi.stripe.StripeReactPackage; -import com.oblador.vectoricons.VectorIconsPackage; -import com.lugg.ReactNativeConfig.ReactNativeConfigPackage; -import com.swmansion.gesturehandler.react.RNGestureHandlerPackage; +import com.facebook.react.ReactInstanceManager; import com.facebook.react.ReactNativeHost; import com.facebook.react.ReactPackage; import com.facebook.react.shell.MainReactPackage; import com.facebook.soloader.SoLoader; +import com.gettipsi.stripe.StripeReactPackage; +import com.lugg.ReactNativeConfig.ReactNativeConfigPackage; +import com.oblador.vectoricons.VectorIconsPackage; +import com.reactnativecommunity.asyncstorage.AsyncStoragePackage; +import com.swmansion.gesturehandler.react.RNGestureHandlerPackage; +import io.sentry.RNSentryPackage; -import java.util.Arrays; +import java.lang.reflect.InvocationTargetException; import java.util.List; public class MainApplication extends Application implements ReactApplication { - private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) { + private final ReactNativeHost mReactNativeHost = + new ReactNativeHost(this) { @Override public boolean getUseDeveloperSupport() { return BuildConfig.DEBUG; @@ -27,15 +30,15 @@ public class MainApplication extends Application implements ReactApplication { @Override protected List getPackages() { - return Arrays.asList( - new MainReactPackage(), - new AsyncStoragePackage(), - new RNSentryPackage(), - new StripeReactPackage(), - new VectorIconsPackage(), - new ReactNativeConfigPackage(), - new RNGestureHandlerPackage() - ); + @SuppressWarnings("UnnecessaryLocalVariable") + List packages = new PackageList(this).getPackages(); + packages.add(new AsyncStoragePackage()); + packages.add(new RNSentryPackage()); + packages.add(new StripeReactPackage()); + packages.add(new VectorIconsPackage()); + packages.add(new ReactNativeConfigPackage()); + packages.add(new RNGestureHandlerPackage()); + return packages; } @Override @@ -53,5 +56,35 @@ public class MainApplication extends Application implements ReactApplication { public void onCreate() { super.onCreate(); SoLoader.init(this, /* native exopackage */ false); + initializeFlipper(this, getReactNativeHost().getReactInstanceManager()); + } + /** + * 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("no.neuf.chateau.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(); + } + } } } diff --git a/android/app/src/main/java/no/neuf/chateau/ReactNativeFlipper.java b/android/app/src/main/java/no/neuf/chateau/ReactNativeFlipper.java new file mode 100644 index 0000000..cf04321 --- /dev/null +++ b/android/app/src/main/java/no/neuf/chateau/ReactNativeFlipper.java @@ -0,0 +1,72 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + *

This source code is licensed under the MIT license found in the LICENSE file in the root + * directory of this source tree. + */ +package com.rndiffapp; + +import android.content.Context; +import com.facebook.flipper.android.AndroidFlipperClient; +import com.facebook.flipper.android.utils.FlipperUtils; +import com.facebook.flipper.core.FlipperClient; +import com.facebook.flipper.plugins.crashreporter.CrashReporterPlugin; +import com.facebook.flipper.plugins.databases.DatabasesFlipperPlugin; +import com.facebook.flipper.plugins.fresco.FrescoFlipperPlugin; +import com.facebook.flipper.plugins.inspector.DescriptorMapping; +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.ReactInstanceManager; +import com.facebook.react.bridge.ReactContext; +import com.facebook.react.modules.network.NetworkingModule; +import okhttp3.OkHttpClient; + +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() { + @Override + public void apply(OkHttpClient.Builder builder) { + builder.addNetworkInterceptor(new FlipperOkhttpInterceptor(networkFlipperPlugin)); + } + }); + 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() { + @Override + public void onReactContextInitialized(ReactContext reactContext) { + reactInstanceManager.removeReactInstanceEventListener(this); + reactContext.runOnNativeModulesQueueThread( + new Runnable() { + @Override + public void run() { + client.addPlugin(new FrescoFlipperPlugin()); + } + }); + } + }); + } else { + client.addPlugin(new FrescoFlipperPlugin()); + } + } + } +} \ 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 319eb0c..24bc061 100644 --- a/android/app/src/main/res/values/styles.xml +++ b/android/app/src/main/res/values/styles.xml @@ -1,7 +1,7 @@ - diff --git a/android/build.gradle b/android/build.gradle index 4a51a02..97b7683 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -2,18 +2,19 @@ buildscript { ext { - buildToolsVersion = "28.0.3" - minSdkVersion = 16 - compileSdkVersion = 28 - targetSdkVersion = 28 - supportLibVersion = "28.0.0" + buildToolsVersion = "30.0.2" + minSdkVersion = 21 + compileSdkVersion = 30 + targetSdkVersion = 30 + supportLibVersion = 30 + ndkVersion = "21.4.7075529" } repositories { google() - jcenter() + mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:3.3.1' + classpath("com.android.tools.build:gradle:4.2.2") // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files @@ -22,14 +23,17 @@ buildscript { allprojects { repositories { - // Add jitpack repository (added by tipsi-stripe) - maven { url "https://jitpack.io" } + mavenCentral() mavenLocal() - google() - jcenter() maven { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm - url "$rootDir/../node_modules/react-native/android" + url("$rootDir/../node_modules/react-native/android") } + maven { + // Android JSC is installed from npm + url("$rootDir/../node_modules/jsc-android/dist") + } + google() + maven { url 'https://www.jitpack.io' } } } diff --git a/android/gradle.properties b/android/gradle.properties index 89e0d99..278b9c4 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -16,3 +16,13 @@ # This option should only be used with decoupled projects. More details, visit # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # org.gradle.parallel=true + +# AndroidX package structure to make it clearer which packages are bundled with the +# Android operating system, and which are packaged with your app's APK +# https://developer.android.com/topic/libraries/support-library/androidx-rn +android.useAndroidX=true +# Automatically convert third-party libraries to use AndroidX +android.enableJetifier=true + +# Version of flipper SDK to use with React Native +FLIPPER_VERSION=0.99.0 \ No newline at end of file diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties index 019065d..7665b0f 100644 --- a/android/gradle/wrapper/gradle-wrapper.properties +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.9-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip diff --git a/android/gradlew.bat b/android/gradlew.bat index e95643d..28690fe 100644 --- a/android/gradlew.bat +++ b/android/gradlew.bat @@ -1,3 +1,19 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + @if "%DEBUG%" == "" @echo off @rem ########################################################################## @rem @@ -13,15 +29,18 @@ if "%DIRNAME%" == "" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init +if "%ERRORLEVEL%" == "0" goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -35,7 +54,7 @@ goto fail set JAVA_HOME=%JAVA_HOME:"=% set JAVA_EXE=%JAVA_HOME%/bin/java.exe -if exist "%JAVA_EXE%" goto init +if exist "%JAVA_EXE%" goto execute echo. echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% @@ -45,28 +64,14 @@ echo location of your Java installation. goto fail -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - :execute @rem Setup the command line set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* :end @rem End local scope for the variables with windows NT shell @@ -81,4 +86,4 @@ exit /b 1 :mainEnd if "%OS%"=="Windows_NT" endlocal -:omega +:omega \ No newline at end of file diff --git a/android/keystores/BUCK b/android/keystores/BUCK deleted file mode 100644 index 88e4c31..0000000 --- a/android/keystores/BUCK +++ /dev/null @@ -1,8 +0,0 @@ -keystore( - name = "debug", - properties = "debug.keystore.properties", - store = "debug.keystore", - visibility = [ - "PUBLIC", - ], -) diff --git a/android/keystores/debug.keystore.properties b/android/keystores/debug.keystore.properties deleted file mode 100644 index 121bfb4..0000000 --- a/android/keystores/debug.keystore.properties +++ /dev/null @@ -1,4 +0,0 @@ -key.store=debug.keystore -key.alias=androiddebugkey -key.store.password=android -key.alias.password=android diff --git a/android/settings.gradle b/android/settings.gradle index bbe4567..df76ddd 100644 --- a/android/settings.gradle +++ b/android/settings.gradle @@ -1,6 +1,4 @@ rootProject.name = 'Dusken' -include ':@react-native-community_async-storage' -project(':@react-native-community_async-storage').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-community/async-storage/android') include ':react-native-sentry' project(':react-native-sentry').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-sentry/android') include ':tipsi-stripe' @@ -12,4 +10,5 @@ project(':react-native-config').projectDir = new File(rootProject.projectDir, '. include ':react-native-gesture-handler' project(':react-native-gesture-handler').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-gesture-handler/android') +apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings) include ':app' diff --git a/jestSetup.js b/jestSetup.js index d8978ae..e4500b5 100644 --- a/jestSetup.js +++ b/jestSetup.js @@ -1,15 +1,18 @@ +/* eslint-disable import/no-extraneous-dependencies */ +/* global jest */ +// ref https://github.com/kmagiera/react-native-gesture-handler/issues/344#issuecomment-489208684 +import { NativeModules } from 'react-native'; + +// ref https://github.com/react-native-community/react-native-async-storage/blob/master/docs/Jest-integration.md +import mockAsyncStorage from '@react-native-async-storage/async-storage/jest/async-storage-mock'; + jest.doMock('tipsi-stripe', () => ({ setOptions: jest.fn(), })); -jest.doMock('react-dom/server', () => {}, {virtual: true}) +jest.doMock('react-dom/server', () => {}, { virtual: true }); global.fetch = require('jest-fetch-mock'); -// ref https://github.com/kmagiera/react-native-gesture-handler/issues/344#issuecomment-489208684 -import { NativeModules } from 'react-native'; NativeModules.RNGestureHandlerModule = {}; -// ref https://github.com/react-native-community/react-native-async-storage/blob/master/docs/Jest-integration.md -import mockAsyncStorage from '@react-native-community/async-storage/jest/async-storage-mock'; - -jest.mock('@react-native-community/async-storage', () => mockAsyncStorage); +jest.mock('@react-native-async-storage/async-storage', () => mockAsyncStorage); diff --git a/package.json b/package.json index c083537..19cf79d 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "lint": "eslint --quiet src", "release:android": "cd android && bundle exec fastlane beta", "release:ios": "cd ios && bundle exec fastlane beta", - "start": "node node_modules/react-native/local-cli/cli.js start", + "start": "react-native start", "test": "jest" }, "dependencies": { diff --git a/src/modules/membership/Proof.js b/src/modules/membership/Proof.js index 6ac595f..13400c8 100644 --- a/src/modules/membership/Proof.js +++ b/src/modules/membership/Proof.js @@ -122,7 +122,10 @@ const MembershipName = ({ user }) => { const Proof = ({ onLogoutPress, user, fetchUser, isFetchingUserData }) => { const CONFETTI_TIMEOUT = 15000; const confettiRef = useRef(null); - const { chargeError, isChargingMembership, isLoadingMembershipType, onChargePress, membershipPrice } = useProof(); + const { chargeError, isChargingMembership, isLoadingMembershipType, onChargePress, membershipPrice } = useProof({ + user, + fetchUser, + }); useEffect(() => { return () => { diff --git a/src/modules/membership/useProof.js b/src/modules/membership/useProof.js index 996b542..8fd60ab 100644 --- a/src/modules/membership/useProof.js +++ b/src/modules/membership/useProof.js @@ -27,7 +27,6 @@ function getPrice(membershipTypes) { return membershipTypes[0].price / 100; } -// FIXME: where do these come from? const useProof = ({ user, fetchUser }) => { const dispatch = useDispatch(); const { userToken, isChargingMembership, chargeError } = useSelector((state) => ({