Skip to content

Commit

Permalink
chore: [IAI-16] Upgrade react-native to 0.64.2 (#3301)
Browse files Browse the repository at this point in the history
* porting to react navigation 4.0

* fix navigation tab

* remove old patch

* add IsSupportedConfig

* fix bottom navigator style

* upgrade react native first required changes

* add locks

* fix test

* update calendar-events config and picker to enable android build

* upgrade keychain and fix manifest

* upgrade clipboard

* fix clipboard on android

* link art

* fix jest react-native-clipboard

* fix test

* fix typo

* fix react-navigation upgrade regression

* fix react-navigation upgrade regression

* update package

* remove legacy okhttp version

Co-authored-by: Cristiano Tofani <[email protected]>
  • Loading branch information
fabriziofff and CrisTofani authored Aug 18, 2021
1 parent c8849ed commit b0c1eaa
Show file tree
Hide file tree
Showing 29 changed files with 5,453 additions and 1,828 deletions.
4 changes: 2 additions & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
*.pbxproj -text
# specific for windows script files
# Windows files should use crlf line endings
# https://help.github.com/articles/dealing-with-line-endings/
*.bat text eol=crlf
3 changes: 3 additions & 0 deletions _editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Windows files
[*.bat]
end_of_line = crlf
10 changes: 4 additions & 6 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ def enableSeparateBuildPerCPUArchitecture = true
def enableProguardInReleaseBuilds = false

android {
ndkVersion rootProject.ext.ndkVersion
compileSdkVersion rootProject.ext.compileSdkVersion

compileOptions {
Expand Down Expand Up @@ -167,7 +168,7 @@ android {
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
defaultConfig.versionCode * 10 + versionCodes.get(abi)
defaultConfig.versionCode * 1000 + versionCodes.get(abi)
}
}
}
Expand Down Expand Up @@ -218,10 +219,6 @@ dependencies {
// compile "com.squareup.okhttp3:okhttp:4.2.1"
// compile "com.squareup.okhttp3:logging-interceptor:4.2.1"
// compile "com.squareup.okhttp3:okhttp-urlconnection:4.2.1"
//OkHttp
implementation ("com.squareup.okhttp3:okhttp:3.12.12"){
force = true //API 19 support
}
implementation 'com.squareup.okhttp3:logging-interceptor:3.12.12'
if (enableHermes) {
def hermesPath = "../../node_modules/hermes-engine/android/";
Expand All @@ -231,7 +228,8 @@ dependencies {
implementation jscFlavor
}
implementation project(':@react-native-community_datetimepicker')

implementation project(':@react-native-clipboard_clipboard')
implementation project(':react-native-art')
}

// Run this once to be able to run the application with BUCK
Expand Down
7 changes: 6 additions & 1 deletion android/app/src/debug/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,10 @@

<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>

<application android:usesCleartextTraffic="true" tools:targetApi="28" tools:ignore="GoogleAppIndexingWarning" />
<application
android:usesCleartextTraffic="true"
tools:targetApi="28"
tools:ignore="GoogleAppIndexingWarning">
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
</application>
</manifest>
1 change: 0 additions & 1 deletion android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@
<data android:scheme="ioit" android:host="ioit" />
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
</application>

</manifest>
10 changes: 0 additions & 10 deletions android/app/src/main/java/it/pagopa/io/app/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@
import com.facebook.react.ReactActivityDelegate;
import com.facebook.react.ReactRootView;
import com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView;
import com.calendarevents.CalendarEventsPackage;
import org.devio.rn.splashscreen.SplashScreen;
import java.io.BufferedReader;
import java.io.File;
import java.io.InputStreamReader;

public class MainActivity extends ReactActivity {

Expand Down Expand Up @@ -52,12 +48,6 @@ protected ReactRootView createRootView() {
};
}

@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
CalendarEventsPackage.onRequestPermissionsResult(requestCode, permissions, grantResults);
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
}


private void showAlertDialog(String title, String message) {
new AlertDialog.Builder(MainActivity.this).setTitle(title).setMessage(message)
Expand Down
14 changes: 8 additions & 6 deletions android/app/src/main/java/it/pagopa/io/app/MainApplication.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package it.pagopa.io.app;

import androidx.multidex.MultiDexApplication;

import com.robinpowered.react.ScreenBrightness.ScreenBrightnessPackage;
import com.AlexanderZaytsev.RNI18n.RNI18nPackage;
import com.sha256lib.Sha256Package;
Expand All @@ -24,7 +22,7 @@
import com.rnfs.RNFSPackage;
import com.levelasquez.androidopensettings.AndroidOpenSettingsPackage;
import com.swmansion.gesturehandler.react.RNGestureHandlerPackage;
import com.calendarevents.CalendarEventsPackage;
import com.calendarevents.RNCalendarEventsPackage;
import com.rnfingerprint.FingerprintAuthPackage;
import com.ocetnik.timer.BackgroundTimerPackage;
import com.horcrux.svg.SvgPackage;
Expand All @@ -42,8 +40,11 @@
import it.ipzs.cieidsdk.native_bridge.CiePackage;
import com.reactnativecommunity.rnpermissions.RNPermissionsPackage;
import com.reactcommunity.rndatetimepicker.RNDateTimePickerPackage;
import com.reactnativecommunity.art.ARTPackage;

import com.facebook.react.PackageList;

import android.app.Application;
import android.content.Context;
import com.facebook.react.ReactInstanceManager;
import java.lang.reflect.InvocationTargetException;
Expand All @@ -52,7 +53,7 @@
import java.util.Arrays;
import java.util.List;

public class MainApplication extends MultiDexApplication implements ReactApplication {
public class MainApplication extends Application implements ReactApplication {


private final ReactNativeHost mReactNativeHost =
Expand All @@ -70,16 +71,17 @@ protected String getJSMainModuleName() {
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(new MainReactPackage(),
new ClipboardPackage(),
new ReanimatedPackage(),
new ARTPackage(),
new CookieManagerPackage(),
new ClipboardPackage(),
new CameraRollPackage(),
new RNViewShotPackage(),
new JailMonkeyPackage(),
new LinearGradientPackage(),
new RNSharePackage(), new ScreenBrightnessPackage(), new AsyncStoragePackage(), new QRScanReaderPackage(),
new ImagePickerPackage(), new FlagSecurePackage(), new RNFSPackage(), new AndroidOpenSettingsPackage(),
new RNGestureHandlerPackage(), new CalendarEventsPackage(), new RNCWebViewPackage(),
new RNGestureHandlerPackage(), new RNCalendarEventsPackage(), new RNCWebViewPackage(),
new FingerprintAuthPackage(), new BackgroundTimerPackage(), new SvgPackage(),
new SplashScreenReactPackage(), new ReactNativeExceptionHandlerPackage(), new RNCameraPackage(),
new ReactNativePushNotificationPackage(), new KeychainPackage(), new RNI18nPackage(), new Sha256Package(),
Expand Down
2 changes: 1 addition & 1 deletion android/app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
<!-- Customize your theme here. -->
<item name="android:windowIsTranslucent">true</item>
<item name="android:textColor">#000000</item>
Expand Down
7 changes: 4 additions & 3 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,19 @@ buildscript {
ext {
firebaseVersion = "17.6.0"
kotlin_version = '1.3.41'
buildToolsVersion = "29.0.2"
minSdkVersion = 19
buildToolsVersion = "29.0.3"
minSdkVersion = 21
compileSdkVersion = 29
targetSdkVersion = 29
supportLibVersion = "28.0.0"
ndkVersion = "20.1.5948944"
}
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.3'
classpath 'com.android.tools.build:gradle:4.1.0'
classpath 'com.google.gms:google-services:4.3.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

Expand Down
2 changes: 1 addition & 1 deletion android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ android.useAndroidX=true
android.enableJetifier=true

# Version of flipper SDK to use with React Native
FLIPPER_VERSION=0.37.0
FLIPPER_VERSION=0.75.1
2 changes: 1 addition & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
21 changes: 3 additions & 18 deletions android/gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ 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.
Expand All @@ -54,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%
Expand All @@ -64,28 +64,13 @@ 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
Expand Down
6 changes: 4 additions & 2 deletions android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
rootProject.name = 'ItaliaApp'
include ':react-native-reanimated'
project(':react-native-reanimated').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-reanimated/android')
include ':@react-native-community_clipboard'
project(':@react-native-community_clipboard').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-community/clipboard/android')
include ':@react-native-clipboard_clipboard'
project(':@react-native-clipboard_clipboard').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-clipboard/clipboard/android')
include ':@react-native-community_cookies'
project(':@react-native-community_cookies').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-community/cookies/android')
include ':@react-native-community_cameraroll'
Expand Down Expand Up @@ -71,3 +71,5 @@ project(':react-native-permissions').projectDir = new File(rootProject.projectDi
include ':app'
include ':@react-native-community_datetimepicker'
project(':@react-native-community_datetimepicker').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-community/datetimepicker/android')
include ':react-native-art'
project(':react-native-art').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-community/art/android')
6 changes: 4 additions & 2 deletions ios/ItaliaApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
8D109BF3B47F46FDA6B105CE /* TitilliumWeb-BoldItalic.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 1E4EECD1122B401CAC190472 /* TitilliumWeb-BoldItalic.ttf */; };
8E7BB01F1A6D4D79B17B4210 /* RobotoMono-BoldItalic.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 2A1DC2C4323E417BBBAE8817 /* RobotoMono-BoldItalic.ttf */; };
9975E38DE95949D28D07A275 /* RobotoMono-Bold.ttf in Resources */ = {isa = PBXBuildFile; fileRef = B7088D9B42BA4275A767BEFF /* RobotoMono-Bold.ttf */; };
9AA4918716C04270861750C9 /* io-icon-font.ttf in Resources */ = {isa = PBXBuildFile; fileRef = FB6C250A30844C039ED2913E /* io-icon-font.ttf */; };
BE1A42156484487BABBC4DED /* TitilliumWeb-Bold.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 309BA0207AA24FE9A0EBE61C /* TitilliumWeb-Bold.ttf */; };
C2CF038002D24FEEAB41B336 /* RobotoMono-LightItalic.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 640E574519CA4183B230AF22 /* RobotoMono-LightItalic.ttf */; };
D18E075B28304466B6CA2381 /* TitilliumWeb-LightItalic.ttf in Resources */ = {isa = PBXBuildFile; fileRef = B65D221FCB5A461FBC44285D /* TitilliumWeb-LightItalic.ttf */; };
Expand All @@ -36,7 +37,6 @@
F0625E7F2326825600EDEF90 /* JavaScriptCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = ED297162215061F000B7C4FE /* JavaScriptCore.framework */; };
F09FEB3C231818E3007071DB /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = F09FEB0D231818E3007071DB /* Localizable.strings */; };
FEA80827C89F6ED5C4C7DF76 /* libPods-ItaliaApp-ItaliaAppTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = B4A03CDB7A4D7F945386FFCB /* libPods-ItaliaApp-ItaliaAppTests.a */; };
9AA4918716C04270861750C9 /* io-icon-font.ttf in Resources */ = {isa = PBXBuildFile; fileRef = FB6C250A30844C039ED2913E /* io-icon-font.ttf */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -110,7 +110,7 @@
F09FEB0E231818E3007071DB /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = ItaliaApp/en.lproj/Localizable.strings; sourceTree = "<group>"; };
F09FEB3D231818F0007071DB /* it */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = it; path = ItaliaApp/it.lproj/Localizable.strings; sourceTree = "<group>"; };
F709D4AE20E44EFAAB255A8E /* TitilliumWeb-Italic.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = "TitilliumWeb-Italic.ttf"; path = "../assets/fonts/TitilliumWeb/TitilliumWeb-Italic.ttf"; sourceTree = "<group>"; };
FB6C250A30844C039ED2913E /* io-icon-font.ttf */ = {isa = PBXFileReference; name = "io-icon-font.ttf"; path = "../assets/fonts/io-icon-font/io-icon-font.ttf"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = unknown; explicitFileType = undefined; includeInIndex = 0; };
FB6C250A30844C039ED2913E /* io-icon-font.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = undefined; includeInIndex = 0; lastKnownFileType = unknown; name = "io-icon-font.ttf"; path = "../assets/fonts/io-icon-font/io-icon-font.ttf"; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -945,6 +945,7 @@
COPY_PHASE_STRIP = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = "arm64 ";
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
Expand Down Expand Up @@ -1005,6 +1006,7 @@
COPY_PHASE_STRIP = YES;
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = "arm64 ";
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
Expand Down
6 changes: 5 additions & 1 deletion ios/ItaliaApp/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
moduleName:@"ItaliaApp"
initialProperties:nil];

rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];
if (@available(iOS 13.0, *)) {
rootView.backgroundColor = [UIColor systemBackgroundColor];
} else {
rootView.backgroundColor = [UIColor whiteColor];
}

self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
UIViewController *rootViewController = [UIViewController new];
Expand Down
10 changes: 7 additions & 3 deletions ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ target 'ItaliaApp' do
pod 'RNCPushNotificationIOS', :path => '../node_modules/@react-native-community/push-notification-ios'
pod 'react-native-netinfo', :path => '../node_modules/@react-native-community/netinfo'
pod 'ReactNativeART', :podspec => '../node_modules/@react-native-community/art/ReactNativeART.podspec'
use_react_native!(:path => config["reactNativePath"])
use_react_native!(
:path => config[:reactNativePath],
# to enable hermes on iOS, change `false` to `true` and then install pods
:hermes_enabled => false
)

target 'ItaliaAppTests' do
inherit! :complete
Expand All @@ -30,8 +34,8 @@ target 'ItaliaApp' do
#
# Note that if you have use_frameworks! enabled, Flipper will not work and
# you should disable these next few lines.
use_flipper!({ 'Flipper-Folly' => '2.5.3', 'Flipper' => '0.87.0', 'Flipper-RSocket' => '1.3.1' })
use_flipper!()
post_install do |installer|
flipper_post_install(installer)
react_native_post_install(installer)
end
end
Loading

0 comments on commit b0c1eaa

Please sign in to comment.