From ad3f7e53b3344b73820af3bd8487795ea3db4f0d Mon Sep 17 00:00:00 2001 From: Daniele Gobbetti Date: Sat, 18 Jun 2016 21:08:51 +0200 Subject: [PATCH] Try hard to hide the browser activity from the stack. --- app/src/main/AndroidManifest.xml | 4 +++- .../activities/ExternalPebbleJSActivity.java | 12 +++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 68536ab3..7ab23f56 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -261,7 +261,9 @@ 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 f756ecb5..200c0328 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/ExternalPebbleJSActivity.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/ExternalPebbleJSActivity.java @@ -1,5 +1,6 @@ package nodomain.freeyourgadget.gadgetbridge.activities; +import android.content.Context; import android.content.Intent; import android.net.Uri; import android.os.Bundle; @@ -66,7 +67,7 @@ public class ExternalPebbleJSActivity extends GBActivity { //needed to access the DOM webSettings.setDomStorageEnabled(true); - JSInterface gbJSInterface = new JSInterface(); + JSInterface gbJSInterface = new JSInterface(this); myWebView.addJavascriptInterface(gbJSInterface, "GBjs"); myWebView.loadUrl("file:///android_asset/app_config/configure.html"); @@ -75,6 +76,7 @@ public class ExternalPebbleJSActivity extends GBActivity { @Override protected void onNewIntent(Intent incoming) { + incoming.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); super.onNewIntent(incoming); confUri = incoming.getData(); } @@ -129,6 +131,7 @@ public class ExternalPebbleJSActivity extends GBActivity { public boolean shouldOverrideUrlLoading(WebView view, String url) { if (url.startsWith("http://") || url.startsWith("https://")) { Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); + i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(i); } else { url = url.replaceFirst("^pebblejs://close#", "file:///android_asset/app_config/configure.html?config=true&json="); @@ -142,7 +145,10 @@ public class ExternalPebbleJSActivity extends GBActivity { private class JSInterface { - public JSInterface() { + Context mContext; + + public JSInterface(Context c) { + mContext = c; } @JavascriptInterface @@ -240,7 +246,7 @@ public class ExternalPebbleJSActivity extends GBActivity { @JavascriptInterface public void closeActivity() { - finish(); + NavUtils.navigateUpFromSameTask((ExternalPebbleJSActivity) mContext); } }