let iitcm react on the dialog focused callback

This commit is contained in:
Philipp Schaefer 2013-07-02 10:53:03 +02:00
parent c3c03598b5
commit 255831f4eb
3 changed files with 19 additions and 2 deletions

View File

@ -205,6 +205,10 @@ window.dialog = function(options) {
// This dialog is now in focus
window.DIALOG_FOCUS = this;
// hint for iitc mobile that a dialog was focused
if (typeof android !== 'undefined' && android && android.dialogFocused) {
android.dialogFocused($(window.DIALOG_FOCUS).data('id'));
}
$(this).closest('.ui-dialog').find('.ui-dialog-title').removeClass('ui-dialog-title-inactive').addClass('ui-dialog-title-active');
}
}, options));

View File

@ -114,6 +114,11 @@ public class IITC_JSInterface {
((IITC_Mobile) context).dialogOpened(id, open);
}
@JavascriptInterface
public void dialogFocused(String id) {
((IITC_Mobile) context).setFocusedDialog(id);
}
// get layers and list them in a dialog
@JavascriptInterface
public void setLayers(String base_layer, String overlay_layer) {

View File

@ -559,6 +559,15 @@ public class IITC_Mobile extends Activity {
item.setVisible(!desktop);
}
// remove dialog and add it back again
// to ensure it is the last element of the list
// focused dialogs should be closed first
public void setFocusedDialog(String id) {
Log.d("iitcm", "Dialog " + id + " focused");
dialogStack.remove(id);
dialogStack.add(id);
}
// called by the javascript interface
public void dialogOpened(String id, boolean open) {
if (open) {
@ -566,8 +575,7 @@ public class IITC_Mobile extends Activity {
dialogStack.add(id);
} else {
Log.d("iitcm", "Dialog " + id + " closed");
int index = dialogStack.indexOf(id);
dialogStack.remove(index);
dialogStack.remove(id);
}
}
}