Slide 1

Slide 1 text

A case study in webview based android app development Kiang @ ZF-TW / 2012-11-07

Slide 2

Slide 2 text

Environments / Tools ● Ubuntu Linux ● Aptana Studio 3 ● Google Chrome ● mysql2sqlite

Slide 3

Slide 3 text

Libraries ● Phonegap / Cordova ● Jquery Mobile ● Jquery Tmpl ● Jquery Validate ● MobileScroll - date/time select

Slide 4

Slide 4 text

Why Aptana Studio 3 ? ● Netbeans was my favorite one before ● NBAndroid is not active development ● ADT in original eclipse is not good for developing webview based applications ● Aptana is perfect for javascript editing ● The default theme is good for my eyes...

Slide 5

Slide 5 text

Google chrome? ● It does support WebSQL ● The business logic could be tested in desktop first, without the boring compiling time

Slide 6

Slide 6 text

Why jquery mobile? ● I like AngularJS more … ● The designer have the UI first, based on jquery mobile ● JQuery Mobile Angular Adapter is not that reliable, at least the document … ● I don't have much experience in mobile environment. But I've been familiar with the coding style using jquery

Slide 7

Slide 7 text

The dirty parts

Slide 8

Slide 8 text

Rev #36 ● Get the token from remote site ● Save the token using window.localStorage.setItem('token', 'xxx'); ● A login page ● User could logout and then login again to get another token

Slide 9

Slide 9 text

Rev #46 ● Prevent the app being terminated when the orientation changing ● AndroidManifest.xml

Slide 10

Slide 10 text

Rev #63 ● Enable the app for desktop(chrome) if( /Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent) ) { document.addEventListener("deviceready", function() { startApp(); }, false); } else { $(function() { startApp(); }) }

Slide 11

Slide 11 text

Rev #91 ● add page loading message if(i % 10 === 0) { $.mobile.showPageLoadingMsg("a", "Loading..." + i +' / '+ queries.length, true); }

Slide 12

Slide 12 text

Rev #127 ● Mysql2sqlite https://gist.github.com/943776 ● After executing the script, you must remove the following items: – Collat – Comments – Fix auto increasement fields

Slide 13

Slide 13 text

Rev #132 ● Once you used global variables, you just can't go back... ● Preload the data sets as it's annoying to deal with timing issue for sql execution ● In Single Page Application, global variable just like a session container, it will be there always ● I will try to have a better habit, next time XD

Slide 14

Slide 14 text

Rev #160 ● You can't just change the value only, for jquery mobile UI components – obj.attr('checked', true).checkboxradio('refresh', true); – obj.html('xxx').trigger('create');

Slide 15

Slide 15 text

Rev #166 ● You just have to wait... setTimeout(function() { initVariables(); }, 500);

Slide 16

Slide 16 text

Rev #172 ● In sqlite, you usually have n+2 tables – sqlite_master – sqlite_sequence

Slide 17

Slide 17 text

Rev #194 ● disable page transition – $.mobile.defaultPageTransition = 'none'; – $.mobile.defaultDialogTransition = 'none';

Slide 18

Slide 18 text

Rev #234 ● use mobiscroll to replace datebox ● Datebox is powerful, but slow on mobile device ● Mobiscroll make the date/time picker work as expected

Slide 19

Slide 19 text

Rev #242 ● Copy/Paste => Modify => Cleanup ● 3 days => 3 hours => 3minutes

Slide 20

Slide 20 text

Rev ? ● To be continued