diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 97c8d09d5..d6235c448 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -283,8 +283,7 @@
android:parentActivityName=".activities.ControlCenter" />
+ android:label="@string/activity_web_view"/>
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/GBApplication.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/GBApplication.java
index 599b53c13..54fe09288 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/GBApplication.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/GBApplication.java
@@ -136,7 +136,9 @@ public class GBApplication extends Application {
}
private void createWebViewActivity() {
- startActivity(new Intent(getContext(), BackgroundWebViewActivity.class));
+ Intent intent = new Intent(getContext(), BackgroundWebViewActivity.class);
+ intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ startActivity(intent);
}
@Override
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/BackgroundWebViewActivity.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/BackgroundWebViewActivity.java
index 9b3fda2d3..7acd28ccc 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/BackgroundWebViewActivity.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/BackgroundWebViewActivity.java
@@ -2,15 +2,19 @@ package nodomain.freeyourgadget.gadgetbridge.activities;
import android.app.Activity;
import android.os.Bundle;
-import android.os.PersistableBundle;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import nodomain.freeyourgadget.gadgetbridge.util.WebViewSingleton;
public class BackgroundWebViewActivity extends Activity {
+ private static Logger LOG = LoggerFactory.getLogger(BackgroundWebViewActivity.class);
+
@Override
- public void onCreate(Bundle savedInstanceState, PersistableBundle persistentState) {
- super.onCreate(savedInstanceState, persistentState);
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
WebViewSingleton.createWebView(this);
- setVisible(false);
+ finish();
}
}
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 a7985dbb9..5f98350a2 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/ExternalPebbleJSActivity.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/ExternalPebbleJSActivity.java
@@ -50,6 +50,8 @@ public class ExternalPebbleJSActivity extends GBActivity {
WebViewSingleton.updateActivityContext(this);
myWebView = WebViewSingleton.getWebView();
+ myWebView.setWillNotDraw(false);
+ myWebView.removeJavascriptInterface("GBActivity");
myWebView.addJavascriptInterface(new ActivityJSInterface(ExternalPebbleJSActivity.this), "GBActivity");
FrameLayout fl = (FrameLayout) findViewById(R.id.webview_placeholder);
fl.addView(myWebView);
@@ -104,7 +106,6 @@ public class ExternalPebbleJSActivity extends GBActivity {
fl.removeAllViews();
}
});
-
}
@Override
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/WebViewSingleton.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/WebViewSingleton.java
index ce453821b..b3cf91a84 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/WebViewSingleton.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/WebViewSingleton.java
@@ -48,7 +48,7 @@ import java.util.UUID;
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
-public class WebViewSingleton extends Activity {
+public class WebViewSingleton {
private static final Logger LOG = LoggerFactory.getLogger(WebViewSingleton.class);
@@ -154,7 +154,7 @@ public class WebViewSingleton extends Activity {
@Override
public boolean onConsoleMessage(ConsoleMessage consoleMessage) {
if (ConsoleMessage.MessageLevel.ERROR.equals(consoleMessage.messageLevel())) {
- GB.toast(consoleMessage.message(), Toast.LENGTH_LONG, GB.ERROR);
+ GB.toast(formatConsoleMessage(consoleMessage), Toast.LENGTH_LONG, GB.ERROR);
//TODO: show error page
}
return super.onConsoleMessage(consoleMessage);
@@ -162,6 +162,14 @@ public class WebViewSingleton extends Activity {
}
+ private static String formatConsoleMessage(ConsoleMessage message) {
+ String sourceId = message.sourceId();
+ if (sourceId == null || sourceId.length() == 0) {
+ sourceId = "unknown";
+ }
+ return String.format("%s (at %s: %d)", message.message(), sourceId, message.lineNumber());
+ }
+
private static class GBWebClient extends WebViewClient {
@Override
public WebResourceResponse shouldInterceptRequest(WebView view, WebResourceRequest request) {