= Blueprint for Mobile Clients = [[TOC]] We want clients on Mobile devices to be able to talk to Sahana Eden servers. == Online == The simplest way to do this is to provide a layout for the web application suitable for smaller screens: * BluePrint/Mobile/Portal * [wiki:BluePrint/CSS#MobileView] An initial protoype should be developed in static HTML/CSS which can then be ported to Eden. - download a couple of pages' HTML & CSS & tweak the CSS until it is fully resizable. == Offline == Ideally, though, they should have local storage for use completely offline & then be able to sync back to the server using whatever connectivity becomes available: * SMS * compressed multi-part SMS to get maximal throughput * [wiki:BluePrint/Messaging#Micro-Syntax] * forms should be updatable via SMS * photos should stay offline until the phone has better connectivity, but then the photo needs to be used to update the same record * GPRS/3G * !WiFi * !BlueTooth * J2ME eedocs: * ''tbc'' * Python docs: * Intro: http://www.devshed.com/c/a/Python/Bluetooth-Programming-using-Python/ * http://lightblue.sourceforge.net/ * http://code.google.com/p/pybluez/ Using the open XForms standard means that we can support handsets using both Android & J2ME. XForms editor: * Written in Django, so should be easy to port to Sahana Eden: * http://github.com/nyaruka/rapidsms-xforms-builder * Video walk-through: * http://www.screencast.com/t/YmYwYjUzMz * http://www.youtube.com/watch?v=PyjEruT5uoU * Written in GWT, so includable in Eden as a simple HTML page: * [http://code.google.com/p/purcforms/ PurcForms] - can import the output from our controller, powerful but not for non-techies! * [http://design.openxdata.org Demo] * [http://ox-designer.blogspot.com OX-Designer] - more basic, but pretty. No import yet. Built for OpenMRS (which uses ODK) * Written in Ruby Rack, so harder to integrate as-is: * http://code.google.com/p/opendatakit/wiki/ODKBuild XForms can be submitted using SMS by including the encoding format within the XForm so that client & server agree on the encoding: * http://bitbucket.org/javarosa/javarosa/wiki/SMSSendingAPI == Android == * [MobileAndroid Android applications for Sahana] - including DeveloperGuidelines for [http://code.google.com/p/open-data-kit OpenDataKit]'s suite of Android tools. * UserGuidelinesMobile - how to use ODK Collect with Sahana Eden * [http://bitbucket.org/javarosa/javarosa/wiki/OpenRosaAPI OpenRosa] - joint project between ODK & !JavaRosa * http://code.google.com/p/python-for-android/ - it is now possible to program Android directly in Python (tbc whether this could include the full Web2Py, but even if not, then reusing elements like the DAL could still be useful so that forms can be built up from the same data models) * http://www.linuxjournal.com/article/10940 === !ToDo === * Get the newly-developed features merged into ODK Trunk: * jaxdroid work on Sahana compatibility * access to Image Library * Wireless location fix * SMS form submission * Dropdown support within the forms (which will be difficult to FKs) * Client-side validation where possible (which probably needs to be added/maintained manually...but we need somewhere to put these) * Can the client currently understand validation errors & present these back to the user? * We currently send back JSON * Send Images * Generate appropriate XForms from image_id fields (ideally using XSLT) * [http://code.google.com/p/opendatakit/source/browse/Geo+Tagger.xml?repo=forms&r=34910a944c745232d285d2caecf876c3dcae9674 GeoTagger] is a sample Form for ODK which can be used as a template for what needs to be produced by {{{controllers/xforms.py}}} * Provide an interface in Sahana through which users can submit these images via ODK Collect & have them stored (in the doc_image table, referenced by the image_id foreign key) * {{{controllers/xforms.py}}} * ideally use an XSLT to convert the XForm to S3XML * See [https://docs.google.com/document/d/1SSl8vtA7RYBrrXmPuqQvA7rQLyzv77ESZjB7KH9s6H4/edit?hl=en Sahana Eden Mobile Photo Upload Blueprint] for additional information. * Send Location Coordinates * Generate appropriate XForms from location_id fields (ideally using XSLT) * [http://code.google.com/p/opendatakit/source/browse/Geo+Tagger.xml?repo=forms&r=34910a944c745232d285d2caecf876c3dcae9674 GeoTagger] is a sample Form for ODK which can be used as a template for what needs to be produced by {{{controllers/xforms.py}}} * Provide an interface in Sahana through which users can submit these coordinates via ODK Collect & have them stored (in the gis_location table, referenced by the location_id foreign key) * {{{controllers/xforms.py}}} * ideally use an XSLT to convert the XForm to S3XML * Sahana's Location should have the lower accuracy marked when fix was obtained wirelessly: either source or ce fields (ideally the latter if we have a numeric value available). * Support Component Tabs for a multi-table form * SMS (building on the current NCSU code) * Need to give user feedback that SMS is sent when HTTP fails (currently they just get a 'Submission failed' message!) * Should really give them an optional Prompt * Need to compress the form submissions * Use the [http://bitbucket.org/javarosa/javarosa/wiki/SMSSendingAPI OpenRosa SMS API] * Strip out empty/default fields * encode the characters more efficiently * Need to authenticate the form submissions * Needs to work on the Sahana server side with more than just the controllers.msg.tropo() method (like sms_handler_modem) * Should have optional response notifications per complete form to say one of: * Submission Successful: URL of record: http://..../ * Validator Error: xxx * Need to delete the submitted form from the mobile device when it the submission was confirmed successful. * The [MobileAndroid#SMSStructure current multi-part transmission] uses a very custom sequence number, which should be made more standard (& take up less room) * Want to be able to download Forms via SMS * Push updates from server * Pull requests from client * QR Code to download the Trunk version (which should update from this version & not default ODK location) * UserGuidelines on creating/embedding a custom QR code for a deployment-specific version * Have the list of downloadable XForms more easily configurable (currently hardcoded in controllers/xforms.py formList()) * e.g. Use the same approach as Importer does by marking resources in the modules list in 000_config.py == J2ME == Documentation on the current implementation is here: http://wiki.sahanafoundation.org/phase2/doku.php/dev:j2meclient * This needs updating to the latest version of !JavaRosa !JavaRosa is a fast-developing framework which uses [wiki:XForms] & [http://www.j2mepolish.org/ J2MEPolish]: * http://code.javarosa.org This supports using Mesh4j to do synchronisation via SMS: * http://code.google.com/p/mesh4x/wiki/SMSAdapter === Alternatives === Another XForms/J2MEPolish client (Xfolite): * https://projects.forum.nokia.com/XFormsJ2ME KUIX can be used to develop lightweight applications which work across may handhelds & forms can be customised easily via XML/CSS: * http://www.kalmeo.org/projects/kuix Old, un-maintained J2ME client for the PHP back-end, which just uses XML-RPC (=> requires Internet): * http://wiki.sahanafoundation.org/doku.php?id=dev:sahana_mobile_intro == iPhone == Sahana Software Foundation have a developer license which can be used by anyone interested in developing this. == HTML 5 == * http://www.ibm.com/developerworks/xml/library/x-html5mobile1/index.html === jQuery Mobile === This has a lot of industry backing for a truly cross-platform solution: * http://jquerymobile.com === Sencha Touch === Cross-platform (Android/iPhone) HTML5 environment based on ExtJS * http://www.sencha.com/products/touch/ * http://dev.sencha.com/deploy/touch/getting-started.html == Mapping == !OpenLayers now has touch support: * http://m.openlayers.org * http://www.slideshare.net/cedricmoullet/openlayers-mobile-code-sprint-2011 On our map, the !Panning/Zooming works already, but Popups cannot be clicked yet. We'd also like to move the !LayerTree to a native-style widget. !ExtMap Touch: * http://www.extmap.com/index.php?pid=2 Taking the Map offline: * iPhone: http://www.offmaps.com !OpenStreetMap on Android: * http://developers.cloudmade.com/projects/show/j2me-lib-android Google Latitude would make an excellent Mobile Presence tool: * http://googlemobile.blogspot.com/2011/02/check-in-with-google-latitude.html * http://code.google.com/apis/latitude/v1/getting_started.html == Other projects == * [http://frontlinesms.ning.com/profiles/blog/show?id=2052630%3ABlogPost%3A8449 FrontlineSMS] * {{{FrontlineForms is a proprietary add-on for FrontlineSMS allowing a mobile Java client to connect to FrontlineSMS and share data with it.}}} * [http://grt.com Global Relief Technologies] * Ranked apps for iOS: http://ios-disasterapps.ideascale.com/