close dialogs onBackPressed (fixes #363)
This commit is contained in:
parent
28e3ee075a
commit
b3a42783fa
@ -55,6 +55,11 @@ window.dialog = function(options) {
|
||||
var jqID = '#' + id;
|
||||
var html = '';
|
||||
|
||||
// hint for iitc mobile that a dialog was opened
|
||||
if (typeof android !== 'undefined' && android && android.dialogOpened) {
|
||||
android.dialogOpened(id);
|
||||
}
|
||||
|
||||
// Convert text to HTML if necessary
|
||||
if(options.text) {
|
||||
html = window.convertTextToTableMagic(options.text);
|
||||
|
@ -74,6 +74,12 @@ public class IITC_JSInterface {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void dialogOpened(String id) {
|
||||
((IITC_Mobile) context).dialogOpened(id);
|
||||
}
|
||||
|
||||
// get layers and list them in a dialog
|
||||
@JavascriptInterface
|
||||
public void setLayers(String base_layer, String overlay_layer) {
|
||||
|
@ -47,6 +47,7 @@ public class IITC_Mobile extends Activity {
|
||||
private MenuItem searchMenuItem;
|
||||
private boolean desktop = false;
|
||||
private boolean reload_needed = false;
|
||||
private ArrayList<String> dialogStack = new ArrayList<String>();
|
||||
|
||||
// Used for custom back stack handling
|
||||
private ArrayList<Integer> backStack = new ArrayList<Integer>();
|
||||
@ -264,6 +265,17 @@ public class IITC_Mobile extends Activity {
|
||||
// we want a self defined behavior for the back button
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
// first kill all open iitc dialogs
|
||||
if (!dialogStack.isEmpty()) {
|
||||
int last = dialogStack.size() - 1;
|
||||
String id = dialogStack.get(last);
|
||||
dialogStack.remove(last);
|
||||
iitc_view.loadUrl("javascript: " +
|
||||
"var selector = $(window.DIALOGS['" + id + "']); " +
|
||||
"selector.dialog('close'); " +
|
||||
"selector.remove();");
|
||||
return;
|
||||
}
|
||||
// exit fullscreen mode if it is enabled and action bar is disabled or the back stack is empty
|
||||
if (fullscreen_mode && (backStack.isEmpty() || fullscreen_actionbar)) {
|
||||
this.toggleFullscreen();
|
||||
@ -522,4 +534,10 @@ public class IITC_Mobile extends Activity {
|
||||
item = menu.findItem(R.id.menu_debug);
|
||||
item.setVisible(!desktop);
|
||||
}
|
||||
|
||||
// called by the javascript interface
|
||||
public void dialogOpened(String id) {
|
||||
Log.d("iitcm", "Dialog " + id + " added");
|
||||
dialogStack.add(id);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user