diff --git a/engine/src/flutter/shell/android/org/domokit/sky/shell/SkyActivity.java b/engine/src/flutter/shell/android/org/domokit/sky/shell/SkyActivity.java index 0724ebf9a1d..de84817719f 100644 --- a/engine/src/flutter/shell/android/org/domokit/sky/shell/SkyActivity.java +++ b/engine/src/flutter/shell/android/org/domokit/sky/shell/SkyActivity.java @@ -85,4 +85,14 @@ public class SkyActivity extends Activity { public void loadUrl(String url) { mView.loadUrl(url); } + + public boolean loadBundleByName(String name) { + File dataDir = new File(PathUtils.getDataDirectory(this)); + File bundle = new File(dataDir, name); + if (!bundle.exists()) { + return false; + } + mView.loadBundle(bundle.getPath()); + return true; + } } diff --git a/engine/src/flutter/shell/android/org/domokit/sky/shell/SkyApplication.java b/engine/src/flutter/shell/android/org/domokit/sky/shell/SkyApplication.java index a20da1e14b8..eabb6608a4a 100644 --- a/engine/src/flutter/shell/android/org/domokit/sky/shell/SkyApplication.java +++ b/engine/src/flutter/shell/android/org/domokit/sky/shell/SkyApplication.java @@ -41,7 +41,25 @@ public class SkyApplication extends BaseChromiumApplication { initJavaUtils(); initResources(); initNative(); - initServiceRegistry(); + onServiceRegistryAvailable(ServiceRegistry.SHARED); + } + + /** + * Override this function to add more resources for extraction. + */ + protected void onBeforeResourceExtraction(ResourceExtractor extractor) { + extractor.addResources(SKY_RESOURCES); + } + + /** + * Override this function to register more services. + */ + protected void onServiceRegistryAvailable(ServiceRegistry registry) { + registry.register(NetworkService.MANAGER.getName(), new ServiceFactory() { + public void connectToService(Context context, Core core, MessagePipeHandle pipe) { + new NetworkServiceImpl(context, core, pipe); + } + }); } private void initJavaUtils() { @@ -51,7 +69,7 @@ public class SkyApplication extends BaseChromiumApplication { private void initResources() { mResourceExtractor = new ResourceExtractor(getApplicationContext()); - mResourceExtractor.addResources(SKY_RESOURCES); + onBeforeResourceExtraction(mResourceExtractor); mResourceExtractor.start(); } @@ -63,12 +81,4 @@ public class SkyApplication extends BaseChromiumApplication { throw new RuntimeException(e); } } - - private void initServiceRegistry() { - ServiceRegistry.SHARED.register(NetworkService.MANAGER.getName(), new ServiceFactory() { - public void connectToService(Context context, Core core, MessagePipeHandle pipe) { - new NetworkServiceImpl(context, core, pipe); - } - }); - } }