My app tries to support both portrait and landscape modes. In portrait mode it has to show the status bar, but not in landscape mode (on iOS). This is achieved by using 1) theme constant landscapeTitleUiidBool=true and 2) overriding StatusBarLandscape, as suggested here: Codename One iOS Statusbar on landscape orientation. I have created a test project with two forms and the following logic:
public void start() {
if (current != null) {
current.show();
return;
}
Form home = new Form("Home", BoxLayout.y());
Button ok = new Button("OK");
ok.addActionListener(e -> {
showOKForm(home);
});
home.add(ok);
home.show();
}
// precondition: Toolbar.setGlobalToolbar(true) set in init(Object)
private void showOKForm(Form home) {
Form f = new Form("OK", BoxLayout.y());
f.add(new Label("Thanks"));
f.getToolbar().setBackCommand("", e -> home.showBack());
f.show();
}
This works as expected - but not always!
Testing the app on an iPhone X device things quickly go wrong if we play around a little with form navigation and rotating the device.
All situations occur: both forms in portrait mode showing the status bar correctly and incorrectly (i.e. the title and back command on top of the status bar) and both forms in landscape mode not showing the status bar correctly (i.e. no status bar) and incorrectly (i.e. status bar space above the title and back command).
See the attached picture with partial screenshots (only the relevant top (left) parts are shown).
Scenarios to achieve this are not reproducible: it depends.
The problems also occur in the simulator.
It appears that sometimes the wrong UIID is used: StatusBar vs StatusBarLandscape. (Edit: in the simulator it shows the correct UIIDs but the dimensions are wrong, i.e. "reversed".)
In my real app (i.e. not the test project) I have reproducible situations where things go wrong, especially in this scenario: 1) open a form, 2) rotate the device, 3) go back to the previous form. I tried overriding showBack() to redo the layout or to revalidate, but nothing helps.
Question: is the above implementation correct and how can this problem be solved?