Skip to content

Commit 7d3bb44

Browse files
committed
added: ensemble app
1 parent 162ab98 commit 7d3bb44

30 files changed

+16255
-25
lines changed

android/build.gradle

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ android {
6969
release {
7070
minifyEnabled false
7171
}
72+
profile {
73+
initWith debug
74+
}
75+
7276
}
7377

7478
lintOptions {
@@ -98,6 +102,14 @@ android {
98102
repositories {
99103
mavenCentral()
100104
google()
105+
106+
maven {
107+
url "../ensemble_app/build/host/outputs/repo"
108+
}
109+
maven {
110+
url "https://storage.googleapis.com/download.flutter.io"
111+
}
112+
101113
}
102114

103115

@@ -106,6 +118,11 @@ dependencies {
106118
// For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
107119
//noinspection GradleDynamicVersion
108120
implementation "com.facebook.react:react-native:+"
121+
122+
debugImplementation 'com.ensembleui.ensemble_app:flutter_debug:1.0'
123+
profileImplementation 'com.ensembleui.ensemble_app:flutter_profile:1.0'
124+
releaseImplementation 'com.ensembleui.ensemble_app:flutter_release:1.0'
125+
109126
}
110127

111128
if (isNewArchitectureEnabled()) {
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
11
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
22
package="com.ensemblereactnative">
3+
<application>
4+
<activity
5+
android:name="io.flutter.embedding.android.FlutterActivity"
6+
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
7+
android:hardwareAccelerated="true"
8+
android:windowSoftInputMode="adjustResize"
9+
/>
10+
</application>
311
</manifest>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,11 @@
11
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
2+
<application>
3+
<activity
4+
android:name="io.flutter.embedding.android.FlutterActivity"
5+
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
6+
android:hardwareAccelerated="true"
7+
android:windowSoftInputMode="adjustResize"
8+
/>
9+
</application>
210
</manifest>
11+

android/src/main/java/com/ensemblereactnative/EnsembleReactNativeModule.java

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,53 @@
66
import com.facebook.react.bridge.ReactApplicationContext;
77
import com.facebook.react.bridge.ReactMethod;
88

9+
import com.facebook.react.bridge.ReactContextBaseJavaModule;
10+
import com.facebook.react.module.annotations.ReactModule;
11+
import io.flutter.embedding.android.FlutterActivity;
12+
import io.flutter.embedding.engine.FlutterEngine;
13+
import io.flutter.embedding.engine.FlutterEngineCache;
14+
import io.flutter.embedding.engine.dart.DartExecutor;
15+
import android.app.Activity;
16+
917
public class EnsembleReactNativeModule extends EnsembleReactNativeSpec {
1018
public static final String NAME = "EnsembleReactNative";
19+
private final ReactApplicationContext reactContext;
20+
public FlutterEngine flutterEngine;
1121

1222
EnsembleReactNativeModule(ReactApplicationContext context) {
1323
super(context);
24+
this.reactContext = context;
25+
new Thread(new Runnable() {
26+
@Override
27+
public void run() {
28+
try {
29+
//dummy delay
30+
Thread.sleep(100);
31+
} catch (InterruptedException e) {
32+
e.printStackTrace();
33+
}
34+
35+
//Update ui on UI thread
36+
reactContext.getCurrentActivity().runOnUiThread(new Runnable() {
37+
@Override
38+
public void run() {
39+
// Instantiate a FlutterEngine.
40+
flutterEngine = new FlutterEngine(reactContext.getApplicationContext());
41+
42+
// Start executing Dart code to pre-warm the FlutterEngine.
43+
flutterEngine.getDartExecutor().executeDartEntrypoint(
44+
DartExecutor.DartEntrypoint.createDefault()
45+
);
46+
47+
// Cache the FlutterEngine to be used by FlutterActivity.
48+
FlutterEngineCache
49+
.getInstance()
50+
.put(NAME, flutterEngine);
51+
}
52+
});
53+
54+
}
55+
}).start();
1456
}
1557

1658
@Override
@@ -20,10 +62,19 @@ public String getName() {
2062
}
2163

2264

23-
// Example method
24-
// See https://reactnative.dev/docs/native-modules-android
2565
@ReactMethod
2666
public void multiply(double a, double b, Promise promise) {
2767
promise.resolve(a * b);
2868
}
69+
70+
@ReactMethod
71+
public void openEnsembleApp(Promise promise) {
72+
Activity currentActivity = reactContext.getCurrentActivity();
73+
74+
currentActivity.startActivity(
75+
FlutterActivity
76+
.withCachedEngine(NAME)
77+
.build(currentActivity)
78+
);
79+
}
2980
}

android/src/oldarch/EnsembleReactNativeSpec.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,6 @@ abstract class EnsembleReactNativeSpec extends ReactContextBaseJavaModule {
1010
}
1111

1212
public abstract void multiply(double a, double b, Promise promise);
13+
public abstract void openEnsembleApp(Promise promise);
14+
1315
}

ensemble_app/.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
yourEnv=yourValue

ensemble_app/.gitignore

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
.DS_Store
2+
.dart_tool/
3+
4+
.pub/
5+
6+
.idea/
7+
.vagrant/
8+
.sconsign.dblite
9+
.svn/
10+
11+
migrate_working_dir/
12+
13+
*.swp
14+
profile
15+
16+
DerivedData/
17+
18+
.generated/
19+
20+
*.pbxuser
21+
*.mode1v3
22+
*.mode2v3
23+
*.perspectivev3
24+
25+
!default.pbxuser
26+
!default.mode1v3
27+
!default.mode2v3
28+
!default.perspectivev3
29+
30+
xcuserdata
31+
32+
*.moved-aside
33+
34+
*.pyc
35+
*sync/
36+
Icon?
37+
.tags*
38+
39+
build/
40+
.android/
41+
.ios/
42+
.flutter-plugins
43+
.flutter-plugins-dependencies
44+
45+
# Symbolication related
46+
app.*.symbols
47+
48+
# Obfuscation related
49+
app.*.map.json

ensemble_app/.metadata

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# This file tracks properties of this Flutter project.
2+
# Used by Flutter tool to assess capabilities and perform upgrades etc.
3+
#
4+
# This file should be version controlled and should not be manually edited.
5+
6+
version:
7+
revision: "300451adae589accbece3490f4396f10bdf15e6e"
8+
channel: "stable"
9+
10+
project_type: module

ensemble_app/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# ensemble_app
2+
3+
A new Flutter module project.
4+
5+
## Getting Started
6+
7+
For help getting started with Flutter development, view the online
8+
[documentation](https://flutter.dev/).
9+
10+
For instructions integrating Flutter modules to your existing applications,
11+
see the [add-to-app documentation](https://flutter.dev/docs/development/add-to-app).

ensemble_app/analysis_options.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
include: package:flutter_lints/flutter.yaml
2+
3+
# Additional information about this file can be found at
4+
# https://dart.dev/guides/language/analysis-options

0 commit comments

Comments
 (0)