close dialogs onBackPressed (fixes #363)
This commit is contained in:
@ -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);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user