From d378b4eb7bda400a790feface95beb35e3b4ac94 Mon Sep 17 00:00:00 2001 From: danielegobbetti Date: Tue, 8 Mar 2016 21:44:12 +0100 Subject: [PATCH] Intercept clay pebblejs://close url --- .../activities/ExternalPebbleJSActivity.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/ExternalPebbleJSActivity.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/ExternalPebbleJSActivity.java index 36e8101e..122a2969 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/ExternalPebbleJSActivity.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/ExternalPebbleJSActivity.java @@ -9,6 +9,7 @@ import android.view.MenuItem; import android.webkit.JavascriptInterface; import android.webkit.WebSettings; import android.webkit.WebView; +import android.webkit.WebViewClient; import android.widget.Toast; import org.json.JSONException; @@ -61,6 +62,7 @@ public class ExternalPebbleJSActivity extends Activity { WebView myWebView = (WebView) findViewById(R.id.configureWebview); myWebView.clearCache(true); + myWebView.setWebViewClient(new GBWebClient()); WebSettings webSettings = myWebView.getSettings(); webSettings.setJavaScriptEnabled(true); //needed to access the DOM @@ -87,6 +89,16 @@ public class ExternalPebbleJSActivity extends Activity { return null; } + private class GBWebClient extends WebViewClient { + @Override + public boolean shouldOverrideUrlLoading(WebView view, String url) { + url = url.replaceFirst("^pebblejs://close#", "file:///android_asset/app_config/configure.html?config=true&json="); + view.loadUrl(url); + return true; + + } + } + private class JSInterface { public JSInterface() {