diff --git a/target/android/app/build.gradle b/target/android/app/build.gradle
index 7b514939..7deff3cf 100644
--- a/target/android/app/build.gradle
+++ b/target/android/app/build.gradle
@@ -31,4 +31,13 @@ android {
implementation "pub.doric:core:0.1.0"
debugImplementation "pub.doric:core:0.1.0"
}
+}
+
+afterEvaluate {
+ buildJSBundle.exec()
+}
+
+task buildJSBundle(type: Exec) {
+ workingDir project.rootDir.getParent() + "/js"
+ commandLine 'doric', 'build'
}
\ No newline at end of file
diff --git a/target/android/app/src/main/java/pub/doric/example/MainActivity.java b/target/android/app/src/main/java/pub/doric/example/MainActivity.java
index 06285095..adcd9138 100644
--- a/target/android/app/src/main/java/pub/doric/example/MainActivity.java
+++ b/target/android/app/src/main/java/pub/doric/example/MainActivity.java
@@ -5,17 +5,29 @@ import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
-import pub.doric.DoricPanel;
-import pub.doric.utils.DoricUtils;
+import pub.doric.DoricFragment;
public class MainActivity extends AppCompatActivity {
private final String BUNDLE_NAME = "__$__";
+ private DoricFragment doricFragment;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
- DoricPanel doricPanel = findViewById(R.id.doric_panel);
- doricPanel.config(DoricUtils.readAssetFile(BUNDLE_NAME + ".js"), BUNDLE_NAME);
+ if (savedInstanceState == null) {
+ String scheme = "assets://" + BUNDLE_NAME + ".js";
+ this.doricFragment = DoricFragment.newInstance(scheme, BUNDLE_NAME);
+ this.getSupportFragmentManager().beginTransaction().add(R.id.root, this.doricFragment).commit();
+ }
+ }
+
+ @Override
+ public void onBackPressed() {
+ if (this.doricFragment.canPop()) {
+ this.doricFragment.pop();
+ } else {
+ super.onBackPressed();
+ }
}
}
diff --git a/target/android/app/src/main/res/layout/activity_main.xml b/target/android/app/src/main/res/layout/activity_main.xml
index fd930106..c4576e97 100644
--- a/target/android/app/src/main/res/layout/activity_main.xml
+++ b/target/android/app/src/main/res/layout/activity_main.xml
@@ -1,5 +1,5 @@
-
\ No newline at end of file
diff --git a/target/android/app/src/main/res/values/styles.xml b/target/android/app/src/main/res/values/styles.xml
index 5885930d..0eb88fe3 100644
--- a/target/android/app/src/main/res/values/styles.xml
+++ b/target/android/app/src/main/res/values/styles.xml
@@ -1,7 +1,7 @@
-