From 2a0388f1c63ab1e1ab52cca80cd76980b50c3446 Mon Sep 17 00:00:00 2001 From: Daniele Gobbetti Date: Fri, 13 Oct 2017 22:16:01 +0200 Subject: [PATCH] Pebble: background webview add allowed domains array --- .../service/devices/pebble/webview/GBWebClient.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/webview/GBWebClient.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/webview/GBWebClient.java index 5ae09438b..a018a6db0 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/webview/GBWebClient.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/webview/GBWebClient.java @@ -37,6 +37,10 @@ import static nodomain.freeyourgadget.gadgetbridge.util.WebViewSingleton.latch; public class GBWebClient extends WebViewClient { + private String[] AllowedDomains = new String[]{ + "openweathermap.org", //for weather :) + "tagesschau.de" //for internal watchapp tests + }; private static final Logger LOG = LoggerFactory.getLogger(GBWebClient.class); @TargetApi(Build.VERSION_CODES.LOLLIPOP) @@ -60,8 +64,9 @@ public class GBWebClient extends WebViewClient { return super.shouldInterceptRequest(view, url); } + private WebResourceResponse mimicReply(Uri requestedUri) { - if (requestedUri.getHost() != null && (requestedUri.getHost().contains("openweathermap.org") || requestedUri.getHost().contains("tagesschau.de"))) { + if (requestedUri.getHost() != null && (org.apache.commons.lang3.StringUtils.indexOfAny(requestedUri.getHost(), AllowedDomains) != -1)) { if (internetHelperBound) { LOG.debug("WEBVIEW forwarding request to the internet helper"); Bundle bundle = new Bundle();