Skip to content

Commit bee9c41

Browse files
NodoniskoChristoph Pader
and
Christoph Pader
authored
chore: move graph animations to UI thread (#74)
* chore: move graph animations to UI thread * update REA peer dependency version * update example app library versions * update Podfile * update ts config * chore: update RN and react * upgrade react-native and react in example * update RNGH * update react-native-static-safe-area-insets * upgrade project to [email protected] * fix: Info.plist * update Podfile and project structure * fix: development team * fix: network error for android app --------- Co-authored-by: Christoph Pader <[email protected]>
1 parent 0cebf28 commit bee9c41

31 files changed

+4015
-2522
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ DerivedData
2828
*.ipa
2929
*.xcuserstate
3030
project.xcworkspace
31+
example/ios/.xcode.env.local
3132

3233
# Android/IJ
3334
#
@@ -43,6 +44,9 @@ android.iml
4344
# Cocoapods
4445
#
4546
example/ios/Pods
47+
example/vendor/bundle/
48+
# Temporary files created by Metro to check the health of the file watcher
49+
example/.metro-health-check*
4650

4751
# node.js
4852
#

example/Gemfile

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
source 'https://rubygems.org'
2+
3+
# You may use http://rbenv.org/ or https://rvm.io/ to install and use this version
4+
ruby '>= 2.6.10'
5+
6+
gem 'cocoapods', '>= 1.11.3'

example/android/app/build.gradle

+77-123
Original file line numberDiff line numberDiff line change
@@ -1,140 +1,113 @@
11
apply plugin: "com.android.application"
2+
apply plugin: "com.facebook.react"
23

34
import com.android.build.OutputFile
45

56
/**
6-
* The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
7-
* and bundleReleaseJsAndAssets).
8-
* These basically call `react-native bundle` with the correct arguments during the Android build
9-
* cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
10-
* bundle directly from the development server. Below you can see all the possible configurations
11-
* and their defaults. If you decide to add a configuration block, make sure to add it before the
12-
* `apply from: "../../node_modules/react-native/react.gradle"` line.
13-
*
14-
* project.ext.react = [
15-
* // the name of the generated asset file containing your JS bundle
16-
* bundleAssetName: "index.android.bundle",
17-
*
18-
* // the entry file for bundle generation
19-
* entryFile: "index.android.js",
20-
*
21-
* // https://reactnative.dev/docs/performance#enable-the-ram-format
22-
* bundleCommand: "ram-bundle",
23-
*
24-
* // whether to bundle JS and assets in debug mode
25-
* bundleInDebug: false,
26-
*
27-
* // whether to bundle JS and assets in release mode
28-
* bundleInRelease: true,
29-
*
30-
* // whether to bundle JS and assets in another build variant (if configured).
31-
* // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
32-
* // The configuration property can be in the following formats
33-
* // 'bundleIn${productFlavor}${buildType}'
34-
* // 'bundleIn${buildType}'
35-
* // bundleInFreeDebug: true,
36-
* // bundleInPaidRelease: true,
37-
* // bundleInBeta: true,
38-
*
39-
* // whether to disable dev mode in custom build variants (by default only disabled in release)
40-
* // for GraphExample: to disable dev mode in the staging build type (if configured)
41-
* devDisabledInStaging: true,
42-
* // The configuration property can be in the following formats
43-
* // 'devDisabledIn${productFlavor}${buildType}'
44-
* // 'devDisabledIn${buildType}'
45-
*
46-
* // the root of your project, i.e. where "package.json" lives
47-
* root: "../../",
48-
*
49-
* // where to put the JS bundle asset in debug mode
50-
* jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
51-
*
52-
* // where to put the JS bundle asset in release mode
53-
* jsBundleDirRelease: "$buildDir/intermediates/assets/release",
54-
*
55-
* // where to put drawable resources / React Native assets, e.g. the ones you use via
56-
* // require('./image.png')), in debug mode
57-
* resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
58-
*
59-
* // where to put drawable resources / React Native assets, e.g. the ones you use via
60-
* // require('./image.png')), in release mode
61-
* resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
62-
*
63-
* // by default the gradle tasks are skipped if none of the JS files or assets change; this means
64-
* // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
65-
* // date; if you have any other folders that you want to ignore for performance reasons (gradle
66-
* // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
67-
* // for GraphExample, you might want to remove it from here.
68-
* inputExcludes: ["android/**", "ios/**"],
69-
*
70-
* // override which node gets called and with what additional arguments
71-
* nodeExecutableAndArgs: ["node"],
72-
*
73-
* // supply additional arguments to the packager
74-
* extraPackagerArgs: []
75-
* ]
7+
* This is the configuration block to customize your React Native Android app.
8+
* By default you don't need to apply any configuration, just uncomment the lines you need.
769
*/
77-
78-
project.ext.react = [
79-
enableHermes: true, // clean and rebuild if changing
80-
entryFile: "index.js",
81-
]
82-
83-
apply from: "../../node_modules/react-native/react.gradle"
10+
react {
11+
/* Folders */
12+
// The root of your project, i.e. where "package.json" lives. Default is '..'
13+
// root = file("../")
14+
// The folder where the react-native NPM package is. Default is ../node_modules/react-native
15+
// reactNativeDir = file("../node_modules/react-native")
16+
// The folder where the react-native Codegen package is. Default is ../node_modules/react-native-codegen
17+
// codegenDir = file("../node_modules/react-native-codegen")
18+
// The cli.js file which is the React Native CLI entrypoint. Default is ../node_modules/react-native/cli.js
19+
// cliFile = file("../node_modules/react-native/cli.js")
20+
21+
/* Variants */
22+
// The list of variants to that are debuggable. For those we're going to
23+
// skip the bundling of the JS bundle and the assets. By default is just 'debug'.
24+
// If you add flavors like lite, prod, etc. you'll have to list your debuggableVariants.
25+
// debuggableVariants = ["liteDebug", "prodDebug"]
26+
27+
/* Bundling */
28+
// A list containing the node command and its flags. Default is just 'node'.
29+
// nodeExecutableAndArgs = ["node"]
30+
//
31+
// The command to run when bundling. By default is 'bundle'
32+
// bundleCommand = "ram-bundle"
33+
//
34+
// The path to the CLI configuration file. Default is empty.
35+
// bundleConfig = file(../rn-cli.config.js)
36+
//
37+
// The name of the generated asset file containing your JS bundle
38+
// bundleAssetName = "MyApplication.android.bundle"
39+
//
40+
// The entry file for bundle generation. Default is 'index.android.js' or 'index.js'
41+
// entryFile = file("../js/MyApplication.android.js")
42+
//
43+
// A list of extra flags to pass to the 'bundle' commands.
44+
// See https://github.com/react-native-community/cli/blob/main/docs/commands.md#bundle
45+
// extraPackagerArgs = []
46+
47+
/* Hermes Commands */
48+
// The hermes compiler command to run. By default it is 'hermesc'
49+
// hermesCommand = "$rootDir/my-custom-hermesc/bin/hermesc"
50+
//
51+
// The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map"
52+
// hermesFlags = ["-O", "-output-source-map"]
53+
}
8454

8555
/**
86-
* Set this to true to create two separate APKs instead of one:
87-
* - An APK that only works on ARM devices
88-
* - An APK that only works on x86 devices
89-
* The advantage is the size of the APK is reduced by about 4MB.
90-
* Upload all the APKs to the Play Store and people will download
91-
* the correct one based on the CPU architecture of their device.
56+
* Set this to true to create four separate APKs instead of one,
57+
* one for each native architecture. This is useful if you don't
58+
* use App Bundles (https://developer.android.com/guide/app-bundle/)
59+
* and want to have separate APKs to upload to the Play Store.
9260
*/
9361
def enableSeparateBuildPerCPUArchitecture = false
9462

9563
/**
96-
* Run Proguard to shrink the Java bytecode in release builds.
64+
* Set this to true to Run Proguard on Release builds to minify the Java bytecode.
9765
*/
9866
def enableProguardInReleaseBuilds = false
9967

10068
/**
101-
* The preferred build flavor of JavaScriptCore.
69+
* The preferred build flavor of JavaScriptCore (JSC)
10270
*
103-
* For GraphExample, to use the international variant, you can use:
71+
* For example, to use the international variant, you can use:
10472
* `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
10573
*
10674
* The international variant includes ICU i18n library and necessary data
10775
* allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
108-
* give correct results when using with locales other than en-US. Note that
76+
* give correct results when using with locales other than en-US. Note that
10977
* this variant is about 6MiB larger per architecture than default.
11078
*/
11179
def jscFlavor = 'org.webkit:android-jsc:+'
11280

11381
/**
114-
* Whether to enable the Hermes VM.
115-
*
116-
* This should be set on project.ext.react and mirrored here. If it is not set
117-
* on project.ext.react, JavaScript will not be compiled to Hermes Bytecode
118-
* and the benefits of using Hermes will therefore be sharply reduced.
82+
* Private function to get the list of Native Architectures you want to build.
83+
* This reads the value from reactNativeArchitectures in your gradle.properties
84+
* file and works together with the --active-arch-only flag of react-native run-android.
11985
*/
120-
def enableHermes = project.ext.react.get("enableHermes", false);
86+
def reactNativeArchitectures() {
87+
def value = project.getProperties().get("reactNativeArchitectures")
88+
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
89+
}
12190

12291
android {
92+
ndkVersion rootProject.ext.ndkVersion
93+
12394
compileSdkVersion rootProject.ext.compileSdkVersion
12495

96+
namespace "com.example.reactnativegraph"
12597
defaultConfig {
12698
applicationId "com.example.reactnativegraph"
12799
minSdkVersion rootProject.ext.minSdkVersion
128100
targetSdkVersion rootProject.ext.targetSdkVersion
129101
versionCode 1
130102
versionName "1.0"
131103
}
104+
132105
splits {
133106
abi {
134107
reset()
135108
enable enableSeparateBuildPerCPUArchitecture
136109
universalApk false // If true, also generate a universal APK
137-
include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
110+
include (*reactNativeArchitectures())
138111
}
139112
}
140113
signingConfigs {
@@ -148,11 +121,6 @@ android {
148121
buildTypes {
149122
debug {
150123
signingConfig signingConfigs.debug
151-
if (nativeArchitectures) {
152-
ndk {
153-
abiFilters nativeArchitectures.split(',')
154-
}
155-
}
156124
}
157125
release {
158126
// Caution! In production, you need to generate your own keystore file.
@@ -162,55 +130,41 @@ android {
162130
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
163131
}
164132
}
133+
165134
// applicationVariants are e.g. debug, release
166135
applicationVariants.all { variant ->
167136
variant.outputs.each { output ->
168137
// For each separate APK per architecture, set a unique version code as described here:
169138
// https://developer.android.com/studio/build/configure-apk-splits.html
139+
// Example: versionCode 1 will generate 1001 for armeabi-v7a, 1002 for x86, etc.
170140
def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
171141
def abi = output.getFilter(OutputFile.ABI)
172142
if (abi != null) { // null for the universal-debug, universal-release variants
173143
output.versionCodeOverride =
174-
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
144+
defaultConfig.versionCode * 1000 + versionCodes.get(abi)
175145
}
176146

177147
}
178148
}
179149
}
180150

181151
dependencies {
182-
implementation fileTree(dir: "libs", include: ["*.jar"])
183-
//noinspection GradleDynamicVersion
184-
implementation "com.facebook.react:react-native:+" // From node_modules
152+
// The version of react-native is set by the React Native Gradle Plugin
153+
implementation("com.facebook.react:react-android")
185154

155+
implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.0.0")
186156

187-
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
188-
debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
189-
exclude group:'com.facebook.fbjni'
190-
}
157+
debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}")
191158
debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
192-
exclude group:'com.facebook.flipper'
193159
exclude group:'com.squareup.okhttp3', module:'okhttp'
194160
}
195-
debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
196-
exclude group:'com.facebook.flipper'
197-
}
198161

199-
if (enableHermes) {
200-
def hermesPath = "../../node_modules/hermes-engine/android/";
201-
debugImplementation files(hermesPath + "hermes-debug.aar")
202-
releaseImplementation files(hermesPath + "hermes-release.aar")
162+
debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}")
163+
if (hermesEnabled.toBoolean()) {
164+
implementation("com.facebook.react:hermes-android")
203165
} else {
204166
implementation jscFlavor
205167
}
206-
207-
}
208-
209-
// Run this once to be able to run the application with BUCK
210-
// puts all compile dependencies into folder libs for BUCK to use
211-
task copyDownloadableDepsToLibs(type: Copy) {
212-
from configurations.implementation
213-
into 'libs'
214168
}
215169

216170
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)

example/android/app/src/debug/AndroidManifest.xml

+5-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
33
xmlns:tools="http://schemas.android.com/tools">
44

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

7-
<application android:usesCleartextTraffic="true" tools:targetApi="28" tools:ignore="GoogleAppIndexingWarning">
8-
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
7+
<application android:usesCleartextTraffic="true" tools:targetApi="28"
8+
tools:ignore="GoogleAppIndexingWarning">
9+
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity"
10+
android:exported="false" />
911
</application>
1012
</manifest>

example/android/app/src/debug/java/com/example/reactnativegraph/ReactNativeFlipper.java

+10-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright (c) Facebook, Inc. and its affiliates.
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
33
*
44
* <p>This source code is licensed under the MIT license found in the LICENSE file in the root
55
* directory of this source tree.
@@ -17,22 +17,27 @@
1717
import com.facebook.flipper.plugins.inspector.InspectorFlipperPlugin;
1818
import com.facebook.flipper.plugins.network.FlipperOkhttpInterceptor;
1919
import com.facebook.flipper.plugins.network.NetworkFlipperPlugin;
20-
import com.facebook.flipper.plugins.react.ReactFlipperPlugin;
2120
import com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin;
21+
import com.facebook.react.ReactInstanceEventListener;
2222
import com.facebook.react.ReactInstanceManager;
2323
import com.facebook.react.bridge.ReactContext;
2424
import com.facebook.react.modules.network.NetworkingModule;
2525
import okhttp3.OkHttpClient;
2626

27+
/**
28+
* Class responsible of loading Flipper inside your React Native application. This is the debug
29+
* flavor of it. Here you can add your own plugins and customize the Flipper setup.
30+
*/
2731
public class ReactNativeFlipper {
2832
public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) {
2933
if (FlipperUtils.shouldEnableFlipper(context)) {
3034
final FlipperClient client = AndroidFlipperClient.getInstance(context);
35+
3136
client.addPlugin(new InspectorFlipperPlugin(context, DescriptorMapping.withDefaults()));
32-
client.addPlugin(new ReactFlipperPlugin());
3337
client.addPlugin(new DatabasesFlipperPlugin(context));
3438
client.addPlugin(new SharedPreferencesFlipperPlugin(context));
3539
client.addPlugin(CrashReporterPlugin.getInstance());
40+
3641
NetworkFlipperPlugin networkFlipperPlugin = new NetworkFlipperPlugin();
3742
NetworkingModule.setCustomClientBuilder(
3843
new NetworkingModule.CustomClientBuilder() {
@@ -43,12 +48,13 @@ public void apply(OkHttpClient.Builder builder) {
4348
});
4449
client.addPlugin(networkFlipperPlugin);
4550
client.start();
51+
4652
// Fresco Plugin needs to ensure that ImagePipelineFactory is initialized
4753
// Hence we run if after all native modules have been initialized
4854
ReactContext reactContext = reactInstanceManager.getCurrentReactContext();
4955
if (reactContext == null) {
5056
reactInstanceManager.addReactInstanceEventListener(
51-
new ReactInstanceManager.ReactInstanceEventListener() {
57+
new ReactInstanceEventListener() {
5258
@Override
5359
public void onReactContextInitialized(ReactContext reactContext) {
5460
reactInstanceManager.removeReactInstanceEventListener(this);

0 commit comments

Comments
 (0)