Cross-platform mobile development in Java T HE E-SURVEY CASE
Outline Context RP radiation surveys What s wrong with web based? Development process Java & Codename one Examples Deployment process Lessons learned With esurvey implementation 2
Context - The RadioLog project The RP group has to ensure radiological safety at CERN facilities Frequent radiation surveys are carried throughout the accelerator tunnels Radiation survey teams measure the radiation levels with probes Several measurements are performed every 100 meters weeks of work Optimizations needed Unified solution No version jungle Easier maintenance Identical look-andfeel for the users/clients Centralized storage Consistent data automatic Backed-up More secure Access is controlled Role based: Admin, Super-user, Users Open/Closed surveys Faster Friendly user interface Survey guides Automatic localization 3
Context - The RadioLog project Front-end Back-end esurvey Application server Application stack Web Application (interface, logic, data model) Framework (optional) Data server Database File system radiolog 4
Context Web based app? esurvey v1 was born web-based! Python/Django logic Jquery mobile Pros: Good looking, high development productivity Still programming for the web -> freedom! Cons: Actions execute server-side > quite some server communication -> less reactive Those parts where WLAN is not there? And 3G fails? -> Problematic! Can t be used for critical processes! 5
Development Native? Cross-Platform? Objectives: Keep platform independency Run on whatever Tablet style device Hardened app Handle connection problems, auto-save, verification, responsive Leverage existing in-house knowledge Avoid exotic frameworks/ languages (Objective C?) Java sounds good (Codename one): Easy to use, comes with Gui Builder, Fast - calls translated into native code Portable to ios, Android, windows, Blackberry build-servers 100 free build credits per month 6
Codename1 Where to start? Remember: Project is fairly recent: Documentation is not awesome... Little / Confusing Tutorials/Guidelines? Errr Community is not that large But Chen answers a lot in stackoverflow Sometimes Things don t seem logic It will not work well in the real device! Best way: Play with examples See source code :/ There s a Gui Builder! Be kind to it! And have patience! 7
Codename1 moving between forms GuiBuilder writes to StateMachineBase.java - implements App basic workflow - Includes helpers to find form controls Little control over load/initialize/show forms Forms referenced by their name Form mainfrm = showform( mainform ) The way we do: - constant names (no literals!) organized into static classes - Initialize contents in Before Show event - Control well the before show. It will run every time we show the form! - Save a pointer to the intro form here, so you can intro.showback(); 8
Codename1 A fancy list Imagine a scrollable list of complex lines - text boxes, buttons, etc Implement with list control, custom renderer - Probably possible but messy - callbacks must be implemented manually Solution: - Scrollable container - Dynamically added N Components, designed with Gui Builder 9
Codename1 A fancy list running Simulator Real device 10
Codename1 Oooops With more than 20 lines, the list became veeery slow Totally redrawing of form every box focus change. ->That s normal, we were told by developers Some unexpected behaviors :p 11
Codename1 Deployment Register in codenameone.com Register in developer.apple.com using your CERN email Register dev device and App IDs at CERN with servicenow Once ready, download certificates and provision profile, and set Proj props NOTE: Apparently Codename1 now has a wizard to help generating the certificates Don t exactly know if it can be used by us, since the provisioning profile can t be directly generated by the CERN developer Hit Send ios/ build Access the build server page with the ipad and Install 12
Codename1 Lessons learnt Codename one effectively allows writing cross-platform apps in Java. GUI Builder is nice, allows for very detailed interface styling Simulator is quite good Includes network and performance analyzer Deployment is sweet once configured! It is still young GUI builder should feel/be more professional Interface performance doesn t feel so native. Stay within short limits when creating forms Not all Java API is available. Currently support for java 5. Expect some bugs. Eventually subscribe professional support. They look responsive! 13
Thank you Acknowledgement C. Theis, Y. Pira & RP group technicians Questions? fernando.pereira@cern.ch