From d18b812e53968a3ba19ca9921a2446fa0260e97e Mon Sep 17 00:00:00 2001 From: Arnaud Vergnet Date: Wed, 27 May 2020 14:55:03 +0200 Subject: [PATCH] Updated react native to 62.2 --- android/app/build.gradle | 26 ++++++- .../application/ReactNativeFlipper.java | 67 +++++++++++++++++++ .../application/MainApplication.java | 18 +++-- android/build.gradle | 4 +- .../gradle/wrapper/gradle-wrapper.properties | 2 +- android/gradlew | 6 +- .../xcshareddata/xcschemes/Campus.xcscheme | 40 +---------- ios/Campus/AppDelegate.m | 22 ++++++ ios/Podfile | 62 +++++++++++++++-- package.json | 8 +-- .../Overrides/CustomHeaderButton.js | 2 - 11 files changed, 192 insertions(+), 65 deletions(-) create mode 100644 android/app/src/debug/java/fr/amicaleinsat/application/ReactNativeFlipper.java diff --git a/android/app/build.gradle b/android/app/build.gradle index b8fa57f..8de73e0 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -77,7 +77,7 @@ import com.android.build.OutputFile project.ext.react = [ entryFile: "index.js", - enableHermes: false, + enableHermes: true, ] apply from: "../../node_modules/react-native/react.gradle" @@ -136,8 +136,8 @@ android { applicationId 'fr.amicaleinsat.application' minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion - versionCode 19 - versionName "3.0.2" + versionCode 20 + versionName "3.0.3" missingDimensionStrategy 'react-native-camera', 'general' } splits { @@ -176,6 +176,14 @@ android { proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" } } + + packagingOptions { + pickFirst "lib/armeabi-v7a/libc++_shared.so" + pickFirst "lib/arm64-v8a/libc++_shared.so" + pickFirst "lib/x86/libc++_shared.so" + pickFirst "lib/x86_64/libc++_shared.so" + } + // applicationVariants are e.g. debug, release applicationVariants.all { variant -> variant.outputs.each { output -> @@ -194,8 +202,20 @@ android { dependencies { implementation fileTree(dir: "libs", include: ["*.jar"]) + //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' + } + 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") diff --git a/android/app/src/debug/java/fr/amicaleinsat/application/ReactNativeFlipper.java b/android/app/src/debug/java/fr/amicaleinsat/application/ReactNativeFlipper.java new file mode 100644 index 0000000..07e08af --- /dev/null +++ b/android/app/src/debug/java/fr/amicaleinsat/application/ReactNativeFlipper.java @@ -0,0 +1,67 @@ +/** + * 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/java/fr/amicaleinsat/application/MainApplication.java b/android/app/src/main/java/fr/amicaleinsat/application/MainApplication.java index 01abb07..86c81f6 100644 --- a/android/app/src/main/java/fr/amicaleinsat/application/MainApplication.java +++ b/android/app/src/main/java/fr/amicaleinsat/application/MainApplication.java @@ -5,6 +5,7 @@ import android.content.Context; import com.facebook.react.PackageList; import com.facebook.react.ReactApplication; +import com.facebook.react.ReactInstanceManager; import com.facebook.react.ReactNativeHost; import com.facebook.react.ReactPackage; import com.facebook.react.shell.MainReactPackage; @@ -44,23 +45,28 @@ public class MainApplication extends Application implements ReactApplication { public void onCreate() { super.onCreate(); SoLoader.init(this, /* native exopackage */ false); - initializeFlipper(this); // Remove this line if you don't want Flipper enabled + initializeFlipper(this, getReactNativeHost().getReactInstanceManager()); } - /** - * Loads Flipper in React Native templates. + /** + * 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) { + 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("com.facebook.flipper.ReactNativeFlipper"); - aClass.getMethod("initializeFlipper", Context.class).invoke(null, context); + Class aClass = Class.forName("com.rndiffapp.ReactNativeFlipper"); + aClass + .getMethod("initializeFlipper", Context.class, ReactInstanceManager.class) + .invoke(null, context, reactInstanceManager); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (NoSuchMethodException e) { diff --git a/android/build.gradle b/android/build.gradle index 8a8c05e..00b9181 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -12,7 +12,7 @@ buildscript { jcenter() } dependencies { - classpath("com.android.tools.build:gradle:3.5.3") + classpath("com.android.tools.build:gradle:3.5.2") // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files @@ -36,6 +36,6 @@ allprojects { } google() jcenter() - maven { url 'https://jitpack.io' } + maven { url 'https://www.jitpack.io' } } } diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties index 3a54a33..1ba7206 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-5.6.3-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.0.1-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/android/gradlew b/android/gradlew index b0d6d0a..83f2acf 100755 --- a/android/gradlew +++ b/android/gradlew @@ -7,7 +7,7 @@ # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, @@ -125,8 +125,8 @@ if $darwin; then GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" fi -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` JAVACMD=`cygpath --unix "$JAVACMD"` diff --git a/ios/Campus.xcodeproj/xcshareddata/xcschemes/Campus.xcscheme b/ios/Campus.xcodeproj/xcshareddata/xcschemes/Campus.xcscheme index 2c23aa5..be3b7d6 100644 --- a/ios/Campus.xcodeproj/xcshareddata/xcschemes/Campus.xcscheme +++ b/ios/Campus.xcodeproj/xcshareddata/xcschemes/Campus.xcscheme @@ -1,25 +1,11 @@ - - - - - - - - - - - +#import +#import +#import +#import +#import +static void InitializeFlipper(UIApplication *application) { + FlipperClient *client = [FlipperClient sharedClient]; + SKDescriptorMapper *layoutDescriptorMapper = [[SKDescriptorMapper alloc] initWithDefaults]; + [client addPlugin:[[FlipperKitLayoutPlugin alloc] initWithRootNode:application withDescriptorMapper:layoutDescriptorMapper]]; + [client addPlugin:[[FKUserDefaultsPlugin alloc] initWithSuiteName:nil]]; + [client addPlugin:[FlipperKitReactPlugin new]]; + [client addPlugin:[[FlipperKitNetworkPlugin alloc] initWithNetworkAdapter:[SKIOSNetworkAdapter new]]]; + [client start]; +} +#endif + - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + #if DEBUG + InitializeFlipper(application); + #endif + RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions]; RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge moduleName:@"main" initialProperties:nil]; rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1]; diff --git a/ios/Podfile b/ios/Podfile index bfc5ec4..3f4f3b2 100644 --- a/ios/Podfile +++ b/ios/Podfile @@ -2,10 +2,51 @@ platform :ios, '9.0' require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules' -target 'Campus' do - rnPrefix = "../node_modules/react-native" +def add_flipper_pods!(versions = {}) + versions['Flipper'] ||= '~> 0.33.1' + versions['DoubleConversion'] ||= '1.1.7' + versions['Flipper-Folly'] ||= '~> 2.1' + versions['Flipper-Glog'] ||= '0.3.6' + versions['Flipper-PeerTalk'] ||= '~> 0.0.4' + versions['Flipper-RSocket'] ||= '~> 1.0' + pod 'FlipperKit', versions['Flipper'], :configuration => 'Debug' + pod 'FlipperKit/FlipperKitLayoutPlugin', versions['Flipper'], :configuration => 'Debug' + pod 'FlipperKit/SKIOSNetworkPlugin', versions['Flipper'], :configuration => 'Debug' + pod 'FlipperKit/FlipperKitUserDefaultsPlugin', versions['Flipper'], :configuration => 'Debug' + pod 'FlipperKit/FlipperKitReactPlugin', versions['Flipper'], :configuration => 'Debug' + # List all transitive dependencies for FlipperKit pods + # to avoid them being linked in Release builds + pod 'Flipper', versions['Flipper'], :configuration => 'Debug' + pod 'Flipper-DoubleConversion', versions['DoubleConversion'], :configuration => 'Debug' + pod 'Flipper-Folly', versions['Flipper-Folly'], :configuration => 'Debug' + pod 'Flipper-Glog', versions['Flipper-Glog'], :configuration => 'Debug' + pod 'Flipper-PeerTalk', versions['Flipper-PeerTalk'], :configuration => 'Debug' + pod 'Flipper-RSocket', versions['Flipper-RSocket'], :configuration => 'Debug' + pod 'FlipperKit/Core', versions['Flipper'], :configuration => 'Debug' + pod 'FlipperKit/CppBridge', versions['Flipper'], :configuration => 'Debug' + pod 'FlipperKit/FBCxxFollyDynamicConvert', versions['Flipper'], :configuration => 'Debug' + pod 'FlipperKit/FBDefines', versions['Flipper'], :configuration => 'Debug' + pod 'FlipperKit/FKPortForwarding', versions['Flipper'], :configuration => 'Debug' + pod 'FlipperKit/FlipperKitHighlightOverlay', versions['Flipper'], :configuration => 'Debug' + pod 'FlipperKit/FlipperKitLayoutTextSearchable', versions['Flipper'], :configuration => 'Debug' + pod 'FlipperKit/FlipperKitNetworkPlugin', versions['Flipper'], :configuration => 'Debug' +end +# Post Install processing for Flipper +def flipper_post_install(installer) + installer.pods_project.targets.each do |target| + if target.name == 'YogaKit' + target.build_configurations.each do |config| + config.build_settings['SWIFT_VERSION'] = '4.1' + end + end + end +end - # React Native and its dependencies + + +target 'Campus' do + # Pods for Campus + rnPrefix = "../node_modules/react-native" pod 'FBLazyVector', :path => "#{rnPrefix}/Libraries/FBLazyVector" pod 'FBReactNativeSpec', :path => "#{rnPrefix}/Libraries/FBReactNativeSpec" pod 'RCTRequired', :path => "#{rnPrefix}/Libraries/RCTRequired" @@ -28,14 +69,14 @@ target 'Campus' do pod 'React-jsi', :path => "#{rnPrefix}/ReactCommon/jsi" pod 'React-jsiexecutor', :path => "#{rnPrefix}/ReactCommon/jsiexecutor" pod 'React-jsinspector', :path => "#{rnPrefix}/ReactCommon/jsinspector" - pod 'ReactCommon/jscallinvoker', :path => "#{rnPrefix}/ReactCommon" + pod 'ReactCommon/callinvoker', :path => "../node_modules/react-native/ReactCommon" pod 'ReactCommon/turbomodule/core', :path => "#{rnPrefix}/ReactCommon" - pod 'Yoga', :path => "#{rnPrefix}/ReactCommon/yoga" + pod 'Yoga', :path => '../node_modules/react-native/ReactCommon/yoga', :modular_headers => true + pod 'DoubleConversion', :podspec => "#{rnPrefix}/third-party-podspecs/DoubleConversion.podspec" pod 'glog', :podspec => "#{rnPrefix}/third-party-podspecs/glog.podspec" pod 'Folly', :podspec => "#{rnPrefix}/third-party-podspecs/Folly.podspec" - # Other native modules # react-native-cli autolinking use_native_modules! @@ -46,4 +87,13 @@ target 'Campus' do pod 'Permission-Notifications', :path => "#{permissions_path}/Notifications.podspec" pod 'Permission-Camera', :path => "#{permissions_path}/Camera.podspec" + # Enables Flipper. + # + # Note that if you have use_frameworks! enabled, Flipper will not work and + # you should disable these next few lines. + add_flipper_pods! + post_install do |installer| + flipper_post_install(installer) + end + end diff --git a/package.json b/package.json index 71ebf13..e963d45 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "campus", - "version": "3.0.2", + "version": "3.0.3", "private": true, "scripts": { "start": "react-native start", @@ -28,9 +28,9 @@ "@react-navigation/native": "^5.2.2", "@react-navigation/stack": "^5.2.17", "i18n-js": "^3.3.0", - "react": "~16.9.0", + "react": "16.11.0", "react-dom": "16.9.0", - "react-native": "~0.61.5", + "react-native": "0.62.2", "react-native-animatable": "^1.3.3", "react-native-app-intro-slider": "^4.0.0", "react-native-appearance": "~0.3.3", @@ -67,6 +67,6 @@ "jest": "^25.5.3", "jest-extended": "^0.11.5", "metro-react-native-babel-preset": "^0.59.0", - "react-test-renderer": "16.9.0" + "react-test-renderer": "16.11.0" } } diff --git a/src/components/Overrides/CustomHeaderButton.js b/src/components/Overrides/CustomHeaderButton.js index ec6754e..add0138 100644 --- a/src/components/Overrides/CustomHeaderButton.js +++ b/src/components/Overrides/CustomHeaderButton.js @@ -4,7 +4,6 @@ import * as React from 'react'; import MaterialCommunityIcons from "react-native-vector-icons/MaterialCommunityIcons"; import {HeaderButton, HeaderButtons} from 'react-navigation-header-buttons'; import {withTheme} from "react-native-paper"; -import * as Touchable from "react-native/Libraries/Components/Touchable/TouchableNativeFeedback.android"; const MaterialHeaderButton = (props: Object) => IconComponent={MaterialCommunityIcons} iconSize={26} color={props.color != null ? props.color : props.theme.colors.text} - background={Touchable.Ripple(props.theme.colors.ripple, true)} />; const MaterialHeaderButtons = (props: Object) => {