Try hard to hide the browser activity from the stack.

This commit is contained in:
Daniele Gobbetti 2016-06-18 21:08:51 +02:00
parent 245b8655e7
commit ad3f7e53b3
2 changed files with 12 additions and 4 deletions

View File

@ -261,7 +261,9 @@
</receiver> </receiver>
<activity <activity
android:launchMode="singleInstance" android:launchMode="singleTask"
android:allowTaskReparenting="true"
android:clearTaskOnLaunch="true"
android:name=".activities.ExternalPebbleJSActivity" android:name=".activities.ExternalPebbleJSActivity"
android:label="@string/app_configure" android:label="@string/app_configure"
android:parentActivityName=".activities.AppManagerActivity"> android:parentActivityName=".activities.AppManagerActivity">

View File

@ -1,5 +1,6 @@
package nodomain.freeyourgadget.gadgetbridge.activities; package nodomain.freeyourgadget.gadgetbridge.activities;
import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
@ -66,7 +67,7 @@ public class ExternalPebbleJSActivity extends GBActivity {
//needed to access the DOM //needed to access the DOM
webSettings.setDomStorageEnabled(true); webSettings.setDomStorageEnabled(true);
JSInterface gbJSInterface = new JSInterface(); JSInterface gbJSInterface = new JSInterface(this);
myWebView.addJavascriptInterface(gbJSInterface, "GBjs"); myWebView.addJavascriptInterface(gbJSInterface, "GBjs");
myWebView.loadUrl("file:///android_asset/app_config/configure.html"); myWebView.loadUrl("file:///android_asset/app_config/configure.html");
@ -75,6 +76,7 @@ public class ExternalPebbleJSActivity extends GBActivity {
@Override @Override
protected void onNewIntent(Intent incoming) { protected void onNewIntent(Intent incoming) {
incoming.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
super.onNewIntent(incoming); super.onNewIntent(incoming);
confUri = incoming.getData(); confUri = incoming.getData();
} }
@ -129,6 +131,7 @@ public class ExternalPebbleJSActivity extends GBActivity {
public boolean shouldOverrideUrlLoading(WebView view, String url) { public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (url.startsWith("http://") || url.startsWith("https://")) { if (url.startsWith("http://") || url.startsWith("https://")) {
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i); startActivity(i);
} else { } else {
url = url.replaceFirst("^pebblejs://close#", "file:///android_asset/app_config/configure.html?config=true&json="); 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 { private class JSInterface {
public JSInterface() { Context mContext;
public JSInterface(Context c) {
mContext = c;
} }
@JavascriptInterface @JavascriptInterface
@ -240,7 +246,7 @@ public class ExternalPebbleJSActivity extends GBActivity {
@JavascriptInterface @JavascriptInterface
public void closeActivity() { public void closeActivity() {
finish(); NavUtils.navigateUpFromSameTask((ExternalPebbleJSActivity) mContext);
} }
} }