Merge remote-tracking branch 'origin/danielegobbetti-playground'
This commit is contained in:
commit
5906c02330
|
@ -1,6 +1,7 @@
|
||||||
package nodomain.freeyourgadget.gadgetbridge.activities;
|
package nodomain.freeyourgadget.gadgetbridge.activities;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.content.Intent;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.NavUtils;
|
import android.support.v4.app.NavUtils;
|
||||||
|
@ -9,6 +10,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 +63,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 +90,23 @@ public class ExternalPebbleJSActivity extends Activity {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class GBWebClient extends WebViewClient {
|
||||||
|
@Override
|
||||||
|
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
||||||
|
if (url.startsWith("http://") || url.startsWith("https://")) {
|
||||||
|
Intent i = new Intent(Intent.ACTION_VIEW,
|
||||||
|
Uri.parse(url));
|
||||||
|
startActivity(i);
|
||||||
|
} else {
|
||||||
|
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() {
|
||||||
|
|
Loading…
Reference in New Issue