Skip to content

Commit a635656

Browse files
committed
chore: release example app 3.10.0
1 parent cac4195 commit a635656

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+196
-900
lines changed

example/android/.gitignore

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,5 @@ local.properties
1111
*.iml
1212
*.hprof
1313

14-
# BUCK
15-
buck-out/
16-
\.buckd/
17-
*.keystore
18-
!debug.keystore
19-
2014
# Bundle artifacts
2115
*.jsbundle

example/android/app/BUCK

Lines changed: 0 additions & 55 deletions
This file was deleted.

example/android/app/build.gradle

Lines changed: 93 additions & 219 deletions
Large diffs are not rendered by default.

example/android/app/build_defs.bzl

Lines changed: 0 additions & 19 deletions
This file was deleted.

example/android/app/src/debug/java/com/callstack/reactnativepaperexample/ReactNativeFlipper.java

Lines changed: 11 additions & 5 deletions
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);
@@ -66,4 +72,4 @@ public void run() {
6672
}
6773
}
6874
}
69-
}
75+
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
</queries>
1414
<application android:name=".MainApplication" android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" android:allowBackup="true" android:theme="@style/AppTheme" android:usesCleartextTraffic="true">
1515
<meta-data android:name="expo.modules.updates.ENABLED" android:value="true"/>
16-
<meta-data android:name="expo.modules.updates.EXPO_RUNTIME_VERSION" android:value="exposdk:47.0.0"/>
16+
<meta-data android:name="expo.modules.updates.EXPO_RUNTIME_VERSION" android:value="@string/expo_runtime_version"/>
1717
<meta-data android:name="expo.modules.updates.EXPO_UPDATES_CHECK_ON_LAUNCH" android:value="ALWAYS"/>
1818
<meta-data android:name="expo.modules.updates.EXPO_UPDATES_LAUNCH_WAIT_MS" android:value="0"/>
1919
<meta-data android:name="expo.modules.updates.EXPO_UPDATE_URL" android:value="https://u.expo.dev/ba8f5139-58fe-48f0-b2f2-2d675b6eb2d4"/>

example/android/app/src/main/java/com/callstack/reactnativepaperexample/MainActivity.java

Lines changed: 13 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55

66
import com.facebook.react.ReactActivity;
77
import com.facebook.react.ReactActivityDelegate;
8-
import com.facebook.react.ReactRootView;
8+
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint;
9+
import com.facebook.react.defaults.DefaultReactActivityDelegate;
910

1011
import expo.modules.ReactActivityDelegateWrapper;
1112

@@ -29,15 +30,20 @@ protected String getMainComponentName() {
2930
}
3031

3132
/**
32-
* Returns the instance of the {@link ReactActivityDelegate}. There the RootView is created and
33-
* you can specify the renderer you wish to use - the new renderer (Fabric) or the old renderer
34-
* (Paper).
33+
* Returns the instance of the {@link ReactActivityDelegate}. Here we use a util class {@link
34+
* DefaultReactActivityDelegate} which allows you to easily enable Fabric and Concurrent React
35+
* (aka React 18) with two boolean flags.
3536
*/
3637
@Override
3738
protected ReactActivityDelegate createReactActivityDelegate() {
38-
return new ReactActivityDelegateWrapper(this, BuildConfig.IS_NEW_ARCHITECTURE_ENABLED,
39-
new MainActivityDelegate(this, getMainComponentName())
40-
);
39+
return new ReactActivityDelegateWrapper(this, BuildConfig.IS_NEW_ARCHITECTURE_ENABLED, new DefaultReactActivityDelegate(
40+
this,
41+
getMainComponentName(),
42+
// If you opted-in for the New Architecture, we enable the Fabric Renderer.
43+
DefaultNewArchitectureEntryPoint.getFabricEnabled(), // fabricEnabled
44+
// If you opted-in for the New Architecture, we enable Concurrent React (i.e. React 18).
45+
DefaultNewArchitectureEntryPoint.getConcurrentReactEnabled() // concurrentRootEnabled
46+
));
4147
}
4248

4349
/**
@@ -59,25 +65,4 @@ public void invokeDefaultOnBackPressed() {
5965
// because it's doing more than {@link Activity#moveTaskToBack} in fact.
6066
super.invokeDefaultOnBackPressed();
6167
}
62-
63-
public static class MainActivityDelegate extends ReactActivityDelegate {
64-
public MainActivityDelegate(ReactActivity activity, String mainComponentName) {
65-
super(activity, mainComponentName);
66-
}
67-
68-
@Override
69-
protected ReactRootView createRootView() {
70-
ReactRootView reactRootView = new ReactRootView(getContext());
71-
// If you opted-in for the New Architecture, we enable the Fabric Renderer.
72-
reactRootView.setIsFabric(BuildConfig.IS_NEW_ARCHITECTURE_ENABLED);
73-
return reactRootView;
74-
}
75-
76-
@Override
77-
protected boolean isConcurrentRootEnabled() {
78-
// If you opted-in for the New Architecture, we enable Concurrent Root (i.e. React 18).
79-
// More on this on https://reactjs.org/blog/2022/03/29/react-v18.html
80-
return BuildConfig.IS_NEW_ARCHITECTURE_ENABLED;
81-
}
82-
}
8368
}
Lines changed: 37 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,70 @@
11
package com.callstack.reactnativepaperexample;
22

33
import android.app.Application;
4-
import android.content.Context;
54
import android.content.res.Configuration;
65
import androidx.annotation.NonNull;
76

87
import com.facebook.react.PackageList;
98
import com.facebook.react.ReactApplication;
10-
import com.facebook.react.ReactInstanceManager;
119
import com.facebook.react.ReactNativeHost;
1210
import com.facebook.react.ReactPackage;
13-
import com.facebook.react.config.ReactFeatureFlags;
11+
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint;
12+
import com.facebook.react.defaults.DefaultReactNativeHost;
1413
import com.facebook.soloader.SoLoader;
15-
import com.callstack.reactnativepaperexample.newarchitecture.MainApplicationReactNativeHost;
1614

1715
import expo.modules.ApplicationLifecycleDispatcher;
1816
import expo.modules.ReactNativeHostWrapper;
1917

20-
import java.lang.reflect.InvocationTargetException;
2118
import java.util.List;
2219

2320
public class MainApplication extends Application implements ReactApplication {
24-
private final ReactNativeHost mReactNativeHost = new ReactNativeHostWrapper(
25-
this,
26-
new ReactNativeHost(this) {
27-
@Override
28-
public boolean getUseDeveloperSupport() {
29-
return BuildConfig.DEBUG;
30-
}
3121

32-
@Override
33-
protected List<ReactPackage> getPackages() {
34-
@SuppressWarnings("UnnecessaryLocalVariable")
35-
List<ReactPackage> packages = new PackageList(this).getPackages();
36-
// Packages that cannot be autolinked yet can be added manually here, for example:
37-
// packages.add(new MyReactNativePackage());
38-
return packages;
39-
}
22+
private final ReactNativeHost mReactNativeHost =
23+
new ReactNativeHostWrapper(this, new DefaultReactNativeHost(this) {
24+
@Override
25+
public boolean getUseDeveloperSupport() {
26+
return BuildConfig.DEBUG;
27+
}
4028

41-
@Override
42-
protected String getJSMainModuleName() {
43-
return "index";
44-
}
45-
});
29+
@Override
30+
protected List<ReactPackage> getPackages() {
31+
@SuppressWarnings("UnnecessaryLocalVariable")
32+
List<ReactPackage> packages = new PackageList(this).getPackages();
33+
// Packages that cannot be autolinked yet can be added manually here, for example:
34+
// packages.add(new MyReactNativePackage());
35+
return packages;
36+
}
4637

47-
private final ReactNativeHost mNewArchitectureNativeHost =
48-
new ReactNativeHostWrapper(this, new MainApplicationReactNativeHost(this));
38+
@Override
39+
protected String getJSMainModuleName() {
40+
return "index";
41+
}
42+
43+
@Override
44+
protected boolean isNewArchEnabled() {
45+
return BuildConfig.IS_NEW_ARCHITECTURE_ENABLED;
46+
}
47+
48+
@Override
49+
protected Boolean isHermesEnabled() {
50+
return BuildConfig.IS_HERMES_ENABLED;
51+
}
52+
});
4953

5054
@Override
5155
public ReactNativeHost getReactNativeHost() {
52-
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
53-
return mNewArchitectureNativeHost;
54-
} else {
55-
return mReactNativeHost;
56-
}
56+
return mReactNativeHost;
5757
}
5858

5959
@Override
6060
public void onCreate() {
6161
super.onCreate();
62-
// If you opted-in for the New Architecture, we enable the TurboModule system
63-
ReactFeatureFlags.useTurboModules = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED;
6462
SoLoader.init(this, /* native exopackage */ false);
65-
66-
initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
63+
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
64+
// If you opted-in for the New Architecture, we load the native entry point for this app.
65+
DefaultNewArchitectureEntryPoint.load();
66+
}
67+
ReactNativeFlipper.initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
6768
ApplicationLifecycleDispatcher.onApplicationCreate(this);
6869
}
6970

@@ -72,35 +73,4 @@ public void onConfigurationChanged(@NonNull Configuration newConfig) {
7273
super.onConfigurationChanged(newConfig);
7374
ApplicationLifecycleDispatcher.onConfigurationChanged(this, newConfig);
7475
}
75-
76-
/**
77-
* Loads Flipper in React Native templates. Call this in the onCreate method with something like
78-
* initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
79-
*
80-
* @param context
81-
* @param reactInstanceManager
82-
*/
83-
private static void initializeFlipper(
84-
Context context, ReactInstanceManager reactInstanceManager) {
85-
if (BuildConfig.DEBUG) {
86-
try {
87-
/*
88-
We use reflection here to pick up the class that initializes Flipper,
89-
since Flipper library is not available in release mode
90-
*/
91-
Class<?> aClass = Class.forName("com.callstack.reactnativepaperexample.ReactNativeFlipper");
92-
aClass
93-
.getMethod("initializeFlipper", Context.class, ReactInstanceManager.class)
94-
.invoke(null, context, reactInstanceManager);
95-
} catch (ClassNotFoundException e) {
96-
e.printStackTrace();
97-
} catch (NoSuchMethodException e) {
98-
e.printStackTrace();
99-
} catch (IllegalAccessException e) {
100-
e.printStackTrace();
101-
} catch (InvocationTargetException e) {
102-
e.printStackTrace();
103-
}
104-
}
105-
}
10676
}

0 commit comments

Comments
 (0)