Intercept clay pebblejs://close url

This commit is contained in:
danielegobbetti 2016-03-08 21:44:12 +01:00
parent 2da50e27c2
commit d378b4eb7b
1 changed files with 12 additions and 0 deletions

View File

@ -9,6 +9,7 @@ import android.view.MenuItem;
import android.webkit.JavascriptInterface; import android.webkit.JavascriptInterface;
import android.webkit.WebSettings; import android.webkit.WebSettings;
import android.webkit.WebView; import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Toast; import android.widget.Toast;
import org.json.JSONException; import org.json.JSONException;
@ -61,6 +62,7 @@ public class ExternalPebbleJSActivity extends Activity {
WebView myWebView = (WebView) findViewById(R.id.configureWebview); WebView myWebView = (WebView) findViewById(R.id.configureWebview);
myWebView.clearCache(true); myWebView.clearCache(true);
myWebView.setWebViewClient(new GBWebClient());
WebSettings webSettings = myWebView.getSettings(); WebSettings webSettings = myWebView.getSettings();
webSettings.setJavaScriptEnabled(true); webSettings.setJavaScriptEnabled(true);
//needed to access the DOM //needed to access the DOM
@ -87,6 +89,16 @@ public class ExternalPebbleJSActivity extends Activity {
return null; 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 { private class JSInterface {
public JSInterface() { public JSInterface() {