You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ni...@apache.org on 2020/12/01 19:08:53 UTC

[cordova-android] branch webviewassetloader created (now 1f0ad3e)

This is an automated email from the ASF dual-hosted git repository.

niklasmerz pushed a change to branch webviewassetloader
in repository https://gitbox.apache.org/repos/asf/cordova-android.git.


      at 1f0ad3e  Revert plugin loading change and implement plugin handler differently

This branch includes the following new commits:

     new 1f0ad3e  Revert plugin loading change and implement plugin handler differently

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


[cordova-android] 01/01: Revert plugin loading change and implement plugin handler differently

Posted by ni...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

niklasmerz pushed a commit to branch webviewassetloader
in repository https://gitbox.apache.org/repos/asf/cordova-android.git

commit 1f0ad3ec4052ed22f502bb906d4cb655154052f6
Author: Niklas Merz <ni...@apache.org>
AuthorDate: Tue Dec 1 20:08:15 2020 +0100

    Revert plugin loading change and implement plugin handler differently
---
 .../apache/cordova/CordovaPluginPathHandler.java    |  8 +-------
 .../src/org/apache/cordova/CordovaWebViewImpl.java  |  6 +++---
 .../apache/cordova/engine/SystemWebViewClient.java  | 21 ++++++++++++++-------
 3 files changed, 18 insertions(+), 17 deletions(-)

diff --git a/framework/src/org/apache/cordova/CordovaPluginPathHandler.java b/framework/src/org/apache/cordova/CordovaPluginPathHandler.java
index 0bdf4a8..b56c2b6 100644
--- a/framework/src/org/apache/cordova/CordovaPluginPathHandler.java
+++ b/framework/src/org/apache/cordova/CordovaPluginPathHandler.java
@@ -7,18 +7,12 @@ import androidx.webkit.WebViewAssetLoader;
  */
 public class CordovaPluginPathHandler {
 
-    private final String path;
     private final WebViewAssetLoader.PathHandler handler;
 
-    public  CordovaPluginPathHandler(String path, WebViewAssetLoader.PathHandler handler) {
-        this.path = path;
+    public  CordovaPluginPathHandler(WebViewAssetLoader.PathHandler handler) {
         this.handler = handler;
     }
 
-    public String getPath() {
-        return path;
-    }
-
     public WebViewAssetLoader.PathHandler getPathHandler() {
         return handler;
     }
diff --git a/framework/src/org/apache/cordova/CordovaWebViewImpl.java b/framework/src/org/apache/cordova/CordovaWebViewImpl.java
index 8e2d623..9d67972 100644
--- a/framework/src/org/apache/cordova/CordovaWebViewImpl.java
+++ b/framework/src/org/apache/cordova/CordovaWebViewImpl.java
@@ -106,9 +106,6 @@ public class CordovaWebViewImpl implements CordovaWebView {
         nativeToJsMessageQueue.addBridgeMode(new NativeToJsMessageQueue.NoOpBridgeMode());
         nativeToJsMessageQueue.addBridgeMode(new NativeToJsMessageQueue.LoadUrlBridgeMode(engine, cordova));
 
-        pluginManager.addService(CoreAndroid.PLUGIN_NAME, "org.apache.cordova.CoreAndroid");
-        pluginManager.init();
-
         if (preferences.getBoolean("DisallowOverscroll", false)) {
             engine.getView().setOverScrollMode(View.OVER_SCROLL_NEVER);
         }
@@ -116,6 +113,9 @@ public class CordovaWebViewImpl implements CordovaWebView {
         // This isn't enforced by the compiler, so assert here.
         assert engine.getView() instanceof CordovaWebViewEngine.EngineView;
 
+        pluginManager.addService(CoreAndroid.PLUGIN_NAME, "org.apache.cordova.CoreAndroid");
+        pluginManager.init();
+        
     }
 
     @Override
diff --git a/framework/src/org/apache/cordova/engine/SystemWebViewClient.java b/framework/src/org/apache/cordova/engine/SystemWebViewClient.java
index db7bfb2..09a47d6 100755
--- a/framework/src/org/apache/cordova/engine/SystemWebViewClient.java
+++ b/framework/src/org/apache/cordova/engine/SystemWebViewClient.java
@@ -76,16 +76,23 @@ public class SystemWebViewClient extends WebViewClient {
                 .setDomain("localhost")
                 .setHttpAllowed(true);
                 
-        // Check if there a plugins with pathHandlers
-        PluginManager pluginManager = this.parentEngine.pluginManager;
-        if (pluginManager != null) {
-           for (CordovaPluginPathHandler handler : pluginManager.getPluginPathHandlers()) {
-               assetLoaderBuilder.addPathHandler(handler.getPath(), handler.getPathHandler());
-           }
-        }
+
 
         assetLoaderBuilder.addPathHandler("/", path -> {
             try {
+                // Check if there a plugins with pathHandlers
+                PluginManager pluginManager = this.parentEngine.pluginManager;
+                if (pluginManager != null) {
+                    for (CordovaPluginPathHandler handler : pluginManager.getPluginPathHandlers()) {
+                        if (handler.getPathHandler() != null) {
+                            WebResourceResponse response = handler.getPathHandler().handle(path);
+                            if (response != null) {
+                                return response;
+                            }
+                        };
+                    }
+                }
+
                 if (path.isEmpty())
                     path = "index.html";
                 InputStream is = parentEngine.webView.getContext().getAssets().open("www/" + path, AssetManager.ACCESS_STREAMING);


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org