1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-12-25 18:15:49 +01:00

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>
<activity
android:launchMode="singleInstance"
android:launchMode="singleTask"
android:allowTaskReparenting="true"
android:clearTaskOnLaunch="true"
android:name=".activities.ExternalPebbleJSActivity"
android:label="@string/app_configure"
android:parentActivityName=".activities.AppManagerActivity">

View File

@ -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);
}
}