A few notes on developing web apps specifically for phones and tablets. My goal is to create a toolkit that makes it easier to build a web application with a small UI that can scale from phones to tablets to desktop browsers, and gracefully handle orientation changes.
Some assumptions:
Layout will be different in landscape and portrait modes.
You might want to pack more stuff on tablet pages than phone pages, for example.
The dektop version could simulate a tablet or phone layout by placing the controls inside a pre-sized rectangle in landscape orientation, centering the rectangle on page.
Some issues:
Safari on iOS seems most reliable at handling orientation changes.
Firefox on Android has a different event/property for orientation changes than WebKit. It’s possible to hack support into your Web Edition app with some JavaScript when the first page opens in your session. There’s a feedback report on this issue:
<[https://xojo.com/issue/27846](https://xojo.com/issue/27846)>
WebSession.BrowserType and WebSession.PlatformType need constants for Windows Phone and Tablet. However, IE on these devices doesn’t seem to have orientation events/properties yet.
<[https://xojo.com/issue/27849](https://xojo.com/issue/27849)>
If you want sound, like for games, it’s easy to whip up a simple sound player. I added one to Studio Stable Web Essentials last week. However, the Chrome Android people think sound should only be played in response to a click. A click in a Web Edition app that talks to the server, and then your Xojo code sending back a command to play the sound doesn’t count. It’s easy enough to detect Chrome on Android and set some onclick events via JavaScript, but that doesn’t solve the issues of page startup sounds or sounds played in response to logic on the server side.
Knowing the orientation, and not just deducing it from the width/height, is important on Android because in both Chrome and Firefox, the page is resized when the onscreen keyboard is displayed. You can be holding the device in portrat mode (width < height), tap in an edit field, keyboard shows, then you get a resize that shows width > height even though you are still in portrait mode. If you’re wholesale rearranging controls from portrait to landscape, the edit field might jump elsewhere while you’re typing. So it’s imperative to know what the device thinks its orientation is.
Chrome on Android (and Firefox w/a JavaScript hack) tries to send the resize event first, then the orientation changed event. But often enough, the server gets them out of order. Recall from last point, that you need to both the size and the orientation of the device to arrange controls correctly. Since the order that you get to handle these events is not guaranteed, I arrange controls in response to both events.
Occasionally, your requests to move controls get lost in a reply that the browser bails on or loses, typically leaving your controls laid out for the wrong orientation. You might think using a tap in the main window to arrange controls would help. It won’t, because on the server side, they positions and sizes are correct, as you set them. Not so on the client side.
As I understand it, the last two issues should go away when we get WebSockets, as a single bi-directional channel is kept alive and commands are necessarily serialized, so everything on both sides happens in order.
There are some great possibilities for apps in this space, targeted rather than just tolerant of mobile devices. Xojo is fairly serviceable for creating such apps that run well on what most people have. But there are definitely some issues to watch for.