extended JSInterface to finish app via js (see #312)

This commit is contained in:
Philipp Schaefer
2013-05-24 17:24:02 +02:00
parent e7a296b2b3
commit 045279a265
2 changed files with 7 additions and 17 deletions

View File

@ -64,6 +64,13 @@ public class IITC_JSInterface {
.show();
}
// exit IITC Mobile
@JavascriptInterface
public void exitIITC() {
Log.d("iitcm","no back stack...finishing iitc");
((IITC_Mobile) context).finish();
}
// get layers and list them in a dialog
@JavascriptInterface
public void setLayers(String base_layer, String overlay_layer) {

View File

@ -17,7 +17,6 @@ import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.StrictMode;
import android.preference.PreferenceManager;
import android.util.Log;
@ -34,7 +33,6 @@ public class IITC_Mobile extends Activity {
private static final int REQUEST_LOGIN = 1;
private IITC_WebView iitc_view;
private boolean back_button_pressed = false;
private OnSharedPreferenceChangeListener listener;
private String intel_url = "https://www.ingress.com/intel";
private boolean user_loc = false;
@ -236,22 +234,7 @@ public class IITC_Mobile extends Activity {
this.toggleFullscreen();
return;
}
if (this.back_button_pressed) {
super.onBackPressed();
return;
}
iitc_view.loadUrl("javascript: window.goBack();");
this.back_button_pressed = true;
Toast.makeText(this, "Press twice to exit", Toast.LENGTH_SHORT).show();
// reset back button after 0.5 seconds
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
back_button_pressed = false;
}
}, 500);
}
@Override