SlideShare une entreprise Scribd logo
1  sur  19
HTML5 and Mobile




              Wenjuan (David) Cai, 2011
Goals

- Explore technologies available for mobile app
development

  HTML5, CSS3, jQuery Mobile, PhoneGap,
  Android SDK, iOS SDK


- Create a PoC prototype
Native vs. HTML5

- Android
  Fragmentation:
  http://techcrunch.com/2011/10/27/charted-android-fragmentation/



- iOS
  - Restrictive approval process
  - Objective C

- HTML5
  Mobile browser support: http://mobilehtml5.org/
HTML5

- A work in progress
   Modules:
     Canvas, Geolocation, Video, Audio,
     Application Cache, Web Storage, CSS3,
     Web Sockets, Web Workers, etc.
      
- Won't be fully released until 2022
     http://www.webmonkey.
     com/2008/09/html_5_won_t_be_ready_until_2022dot_yes__2022dot/
HTML5 (cont'd)

- Easy to start

  <!doctype html>
  <html lang="en">
      <head>
           <meta charset="utf-8">
           <title>...</title>
      </head>
      <body>...</body>
  </html>




- Based on HTML4
  Your existing HTML knowledge is not obsolete
JavaScript Libraries for Mobile

- jQuery Mobile
   Easy mockup, fast to prototype, jQuery is awesome


- Sencha Touch
   Full bloom mobile library
   Typical problem for big library: "code against
framework"


- YUI3
   Provided bolts and nuts but not a platform ... yet
Dive into HTML5 Source
<div data-role="page" id="login" data-theme="b">
    <%-- Header --%>
    <div data-role="header" data-theme="b">
         <h1>Financial Engines</h1>
    </div>


    <%-- Content --%>
    <div data-role="content" id="login-bd">
         <form action="/mobile/login-save.act" method="post" data-ajax="false">
              <s:actionerror />


              <input type="text" name="userId" id="userId" placeholder="User ID">
              <input type="password" name="password" id="password"
                   placeholder="Password">
              <input type="submit" value="Sign In">
         </form>
    </div>
</div>
jQuery Mobile in Action
<script type="text/javascript">
   $(function() {
       $('form').submit(function() {

            $.mobile.showPageLoadingMsg();
            console.log('Show page loading message');

            $('input[type=submit]', this)
               .attr('disabled', 'disabled');
            console.log('Disabled submit button');
      });
   });
</script>
jQuery Listview
<div data-role="page" id="dashboard">
    <div data-role="content">
        <ul data-role="listview">
             <li><a href=" #funds"></a></li>

             <li><a href="#savings"></a></li>

            <li><a href="#ret_income"></a></li>
        </ul>
    </div>
</div>

...

<div data-role="page" id="funds" data-add-back-btn="true">
    ...
</div>
Canvas

- Replace Flash
  JavaScript API to draw 2D/3D


- jQuery code to create pie
  <%-- Get style pie configuration --%>
  var pieConfig = jQuery.parseJSON(
      '<s:property
           value="stylePieConfig"
           escape="false" />'
  );
  <%-- Create style pie --%>
  $("#style-pie") .pie(pieConfig, 150, 150);
CSS3 Media Query

- Responsive Design
   /*
   For device with screen width being
   greater than 480px
   */
   @media screen and (min-width: 480px) {


        #styles #style-pie {
             float: left;
        }


        #styles .ui-content ul[data-role=listview] {
             float: left;
        }
   }



- The Boston Globe: http://bostonglobe.com/
Mobile Device Events

- Swipe Gestures
  $(function() {
        $('div.ui-page').live('swipeleft', function() {
              history.go(1);
        });
        $('div.ui-page').live('swiperight', function() {
              history.go(-1);
        });
  });




- Page Initialization vs. DOM Ready
  $('#styles').live('pageinit', function(event) {
        console.log('Page styles is initialized');
  });
Android Deployment

- Android SDK: http://developer.android.com/sdk/index.html

- ADT Eclipse Plugin:                     http://developer.android.com/sdk/eclipse-adt.html#installing




- PhoneGap: http://phonegap.com/
   - Wrap web apps in native container
   - Support iOS, Android, Blackberry, WebOS, and Symbian
   - Support native features:
       Camera, Geolocation, Native File System, Contacts, Compass, Notification, etc.
Android Project in Eclipse

- AndroidManifest.xml
- App.java
  public class App extends DroidGap
  {
       /** Called when the activity is first created. */
       @Override
       public void onCreate(Bundle savedInstanceState)
       {
            super.onCreate(savedInstanceState);
            super.init();

           // Clear browser cache
           super.clearCache();

           super.loadUrl("<your IP address>/mobile/login.act");
      }
  }
Deploy to Simulator

- Create AVD (Android Virtual Device)
  - Screen resolution
  - SD card size
  - Target Android SDK level
  - Hardware properties


- Run as Android Application
Deploy to Android Device

- Sign application
   - Generate key store
      keytool -genkey -v -keystore android-release-key.keystore
          -alias alias_name -keyalg RSA -validity 10000




- Export signed application
   - .apk file

- Install from apk file
iOS Development

- You need a Mac

- Xcode

- PhoneGap
iOS Development (cont'd)

- index.html
  <body onload="onBodyLoad()">
       <script type="text/javascript">
            window.location = "http://<your IP address>/mobile/login.act";
       </script>
  </body>




- AppDelegate.m
  shouldStartLoadWithRequest method
       return YES;




- Branding in <your-app>-info.plist file
Q&A

Contenu connexe

Tendances

Getting Started Building Windows 8 HTML/JavaScript Metro Apps
Getting Started Building Windows 8 HTML/JavaScript Metro AppsGetting Started Building Windows 8 HTML/JavaScript Metro Apps
Getting Started Building Windows 8 HTML/JavaScript Metro AppsDan Wahlin
 
Mobile Application Development for the Web Developer
Mobile Application Development for the Web DeveloperMobile Application Development for the Web Developer
Mobile Application Development for the Web DeveloperCraig Johnston
 
Don't Worry jQuery is very Easy:Learning Tips For jQuery
Don't Worry jQuery is very Easy:Learning Tips For jQueryDon't Worry jQuery is very Easy:Learning Tips For jQuery
Don't Worry jQuery is very Easy:Learning Tips For jQueryshabab shihan
 
JQuery Comprehensive Overview
JQuery Comprehensive OverviewJQuery Comprehensive Overview
JQuery Comprehensive OverviewMohamed Loey
 
Short intro to JQuery and Modernizr
Short intro to JQuery and ModernizrShort intro to JQuery and Modernizr
Short intro to JQuery and ModernizrJussi Pohjolainen
 
Twitter bootstrap
Twitter bootstrapTwitter bootstrap
Twitter bootstrapdennisdc
 
Introduction to ZendX jQuery
Introduction to ZendX jQueryIntroduction to ZendX jQuery
Introduction to ZendX jQuerydennisdc
 
Guia de Sobrevivência JS no mundo Open Source
Guia de Sobrevivência JS no mundo Open SourceGuia de Sobrevivência JS no mundo Open Source
Guia de Sobrevivência JS no mundo Open SourceLeonardo Balter
 
Migration to jQuery 3.5.x
Migration to jQuery 3.5.xMigration to jQuery 3.5.x
Migration to jQuery 3.5.xStanislavIdolov
 
Taking Web Apps Offline
Taking Web Apps OfflineTaking Web Apps Offline
Taking Web Apps OfflinePedro Morais
 

Tendances (20)

Jquery ui
Jquery uiJquery ui
Jquery ui
 
Getting Started Building Windows 8 HTML/JavaScript Metro Apps
Getting Started Building Windows 8 HTML/JavaScript Metro AppsGetting Started Building Windows 8 HTML/JavaScript Metro Apps
Getting Started Building Windows 8 HTML/JavaScript Metro Apps
 
Mobile Application Development for the Web Developer
Mobile Application Development for the Web DeveloperMobile Application Development for the Web Developer
Mobile Application Development for the Web Developer
 
Facebook
FacebookFacebook
Facebook
 
Symfony2. Form and Validation
Symfony2. Form and ValidationSymfony2. Form and Validation
Symfony2. Form and Validation
 
Don't Worry jQuery is very Easy:Learning Tips For jQuery
Don't Worry jQuery is very Easy:Learning Tips For jQueryDon't Worry jQuery is very Easy:Learning Tips For jQuery
Don't Worry jQuery is very Easy:Learning Tips For jQuery
 
JQuery Comprehensive Overview
JQuery Comprehensive OverviewJQuery Comprehensive Overview
JQuery Comprehensive Overview
 
JQuery
JQueryJQuery
JQuery
 
Short intro to JQuery and Modernizr
Short intro to JQuery and ModernizrShort intro to JQuery and Modernizr
Short intro to JQuery and Modernizr
 
Empty
EmptyEmpty
Empty
 
Twitter bootstrap
Twitter bootstrapTwitter bootstrap
Twitter bootstrap
 
Introduction to ZendX jQuery
Introduction to ZendX jQueryIntroduction to ZendX jQuery
Introduction to ZendX jQuery
 
Web storage
Web storageWeb storage
Web storage
 
Guia de Sobrevivência JS no mundo Open Source
Guia de Sobrevivência JS no mundo Open SourceGuia de Sobrevivência JS no mundo Open Source
Guia de Sobrevivência JS no mundo Open Source
 
Php if
Php ifPhp if
Php if
 
Migration to jQuery 3.5.x
Migration to jQuery 3.5.xMigration to jQuery 3.5.x
Migration to jQuery 3.5.x
 
test
testtest
test
 
Taking Web Apps Offline
Taking Web Apps OfflineTaking Web Apps Offline
Taking Web Apps Offline
 
J queryui
J queryuiJ queryui
J queryui
 
Jquery.Tmpl
Jquery.TmplJquery.Tmpl
Jquery.Tmpl
 

Similaire à HTML5 and Mobile

Building iPhone Web Apps using "classic" Domino
Building iPhone Web Apps using "classic" DominoBuilding iPhone Web Apps using "classic" Domino
Building iPhone Web Apps using "classic" DominoRob Bontekoe
 
Design Patterns for JavaScript Web Apps - JavaScript Conference 2012 - OPITZ ...
Design Patterns for JavaScript Web Apps - JavaScript Conference 2012 - OPITZ ...Design Patterns for JavaScript Web Apps - JavaScript Conference 2012 - OPITZ ...
Design Patterns for JavaScript Web Apps - JavaScript Conference 2012 - OPITZ ...OPITZ CONSULTING Deutschland
 
Introduction to jQuery Mobile
Introduction to jQuery MobileIntroduction to jQuery Mobile
Introduction to jQuery Mobileejlp12
 
Html5 on Mobile(For Developer)
Html5 on Mobile(For Developer)Html5 on Mobile(For Developer)
Html5 on Mobile(For Developer)Adam Lu
 
Oracle Application Express & jQuery Mobile - OGh Apex Dag 2012
Oracle Application Express & jQuery Mobile - OGh Apex Dag 2012Oracle Application Express & jQuery Mobile - OGh Apex Dag 2012
Oracle Application Express & jQuery Mobile - OGh Apex Dag 2012crokitta
 
After max+phonegap
After max+phonegapAfter max+phonegap
After max+phonegapyangdj
 
混搭移动开发:PhoneGap+JQurey+Dreamweaver
混搭移动开发:PhoneGap+JQurey+Dreamweaver混搭移动开发:PhoneGap+JQurey+Dreamweaver
混搭移动开发:PhoneGap+JQurey+Dreamweaveryangdj
 
HTML5 New and Improved
HTML5   New and ImprovedHTML5   New and Improved
HTML5 New and ImprovedTimothy Fisher
 
Design Tips & Development with jQuery Mobile and PhoneGap
Design Tips & Development with jQuery Mobile and PhoneGapDesign Tips & Development with jQuery Mobile and PhoneGap
Design Tips & Development with jQuery Mobile and PhoneGapGO Ohtani
 
HTML5 on Mobile
HTML5 on MobileHTML5 on Mobile
HTML5 on MobileAdam Lu
 
HTML5 and the dawn of rich mobile web applications pt 2
HTML5 and the dawn of rich mobile web applications pt 2HTML5 and the dawn of rich mobile web applications pt 2
HTML5 and the dawn of rich mobile web applications pt 2James Pearce
 
Desenvolvimento Mobile Híbrido
Desenvolvimento Mobile HíbridoDesenvolvimento Mobile Híbrido
Desenvolvimento Mobile HíbridoJuliano Martins
 
Mobile App Development: Primi passi con NativeScript e Angular 2
Mobile App Development: Primi passi con NativeScript e Angular 2Mobile App Development: Primi passi con NativeScript e Angular 2
Mobile App Development: Primi passi con NativeScript e Angular 2Filippo Matteo Riggio
 
Multi screen HTML5
Multi screen HTML5Multi screen HTML5
Multi screen HTML5Ron Reiter
 

Similaire à HTML5 and Mobile (20)

Building iPhone Web Apps using "classic" Domino
Building iPhone Web Apps using "classic" DominoBuilding iPhone Web Apps using "classic" Domino
Building iPhone Web Apps using "classic" Domino
 
Design Patterns for JavaScript Web Apps - JavaScript Conference 2012 - OPITZ ...
Design Patterns for JavaScript Web Apps - JavaScript Conference 2012 - OPITZ ...Design Patterns for JavaScript Web Apps - JavaScript Conference 2012 - OPITZ ...
Design Patterns for JavaScript Web Apps - JavaScript Conference 2012 - OPITZ ...
 
Introduction to jQuery Mobile
Introduction to jQuery MobileIntroduction to jQuery Mobile
Introduction to jQuery Mobile
 
Html5 on Mobile(For Developer)
Html5 on Mobile(For Developer)Html5 on Mobile(For Developer)
Html5 on Mobile(For Developer)
 
Oracle Application Express & jQuery Mobile - OGh Apex Dag 2012
Oracle Application Express & jQuery Mobile - OGh Apex Dag 2012Oracle Application Express & jQuery Mobile - OGh Apex Dag 2012
Oracle Application Express & jQuery Mobile - OGh Apex Dag 2012
 
After max+phonegap
After max+phonegapAfter max+phonegap
After max+phonegap
 
混搭移动开发:PhoneGap+JQurey+Dreamweaver
混搭移动开发:PhoneGap+JQurey+Dreamweaver混搭移动开发:PhoneGap+JQurey+Dreamweaver
混搭移动开发:PhoneGap+JQurey+Dreamweaver
 
One Size Fits All
One Size Fits AllOne Size Fits All
One Size Fits All
 
HTML5 New and Improved
HTML5   New and ImprovedHTML5   New and Improved
HTML5 New and Improved
 
Xxx
XxxXxx
Xxx
 
Client Web
Client WebClient Web
Client Web
 
Design Tips & Development with jQuery Mobile and PhoneGap
Design Tips & Development with jQuery Mobile and PhoneGapDesign Tips & Development with jQuery Mobile and PhoneGap
Design Tips & Development with jQuery Mobile and PhoneGap
 
HTML5 on Mobile
HTML5 on MobileHTML5 on Mobile
HTML5 on Mobile
 
Adobe & HTML5
Adobe & HTML5Adobe & HTML5
Adobe & HTML5
 
HTML5 and the dawn of rich mobile web applications pt 2
HTML5 and the dawn of rich mobile web applications pt 2HTML5 and the dawn of rich mobile web applications pt 2
HTML5 and the dawn of rich mobile web applications pt 2
 
Desenvolvimento Mobile Híbrido
Desenvolvimento Mobile HíbridoDesenvolvimento Mobile Híbrido
Desenvolvimento Mobile Híbrido
 
Taking your Web App for a walk
Taking your Web App for a walkTaking your Web App for a walk
Taking your Web App for a walk
 
Mobile App Development: Primi passi con NativeScript e Angular 2
Mobile App Development: Primi passi con NativeScript e Angular 2Mobile App Development: Primi passi con NativeScript e Angular 2
Mobile App Development: Primi passi con NativeScript e Angular 2
 
Multi screen HTML5
Multi screen HTML5Multi screen HTML5
Multi screen HTML5
 
Html5 For Jjugccc2009fall
Html5 For Jjugccc2009fallHtml5 For Jjugccc2009fall
Html5 For Jjugccc2009fall
 

HTML5 and Mobile

  • 1. HTML5 and Mobile Wenjuan (David) Cai, 2011
  • 2. Goals - Explore technologies available for mobile app development HTML5, CSS3, jQuery Mobile, PhoneGap, Android SDK, iOS SDK - Create a PoC prototype
  • 3. Native vs. HTML5 - Android Fragmentation: http://techcrunch.com/2011/10/27/charted-android-fragmentation/ - iOS - Restrictive approval process - Objective C - HTML5 Mobile browser support: http://mobilehtml5.org/
  • 4. HTML5 - A work in progress Modules: Canvas, Geolocation, Video, Audio, Application Cache, Web Storage, CSS3, Web Sockets, Web Workers, etc.   - Won't be fully released until 2022 http://www.webmonkey. com/2008/09/html_5_won_t_be_ready_until_2022dot_yes__2022dot/
  • 5. HTML5 (cont'd) - Easy to start <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>...</title> </head> <body>...</body> </html> - Based on HTML4 Your existing HTML knowledge is not obsolete
  • 6. JavaScript Libraries for Mobile - jQuery Mobile Easy mockup, fast to prototype, jQuery is awesome - Sencha Touch Full bloom mobile library Typical problem for big library: "code against framework" - YUI3 Provided bolts and nuts but not a platform ... yet
  • 7. Dive into HTML5 Source <div data-role="page" id="login" data-theme="b"> <%-- Header --%> <div data-role="header" data-theme="b"> <h1>Financial Engines</h1> </div> <%-- Content --%> <div data-role="content" id="login-bd"> <form action="/mobile/login-save.act" method="post" data-ajax="false"> <s:actionerror /> <input type="text" name="userId" id="userId" placeholder="User ID"> <input type="password" name="password" id="password" placeholder="Password"> <input type="submit" value="Sign In"> </form> </div> </div>
  • 8. jQuery Mobile in Action <script type="text/javascript"> $(function() { $('form').submit(function() { $.mobile.showPageLoadingMsg(); console.log('Show page loading message'); $('input[type=submit]', this) .attr('disabled', 'disabled'); console.log('Disabled submit button'); }); }); </script>
  • 9. jQuery Listview <div data-role="page" id="dashboard"> <div data-role="content"> <ul data-role="listview"> <li><a href=" #funds"></a></li> <li><a href="#savings"></a></li> <li><a href="#ret_income"></a></li> </ul> </div> </div> ... <div data-role="page" id="funds" data-add-back-btn="true"> ... </div>
  • 10. Canvas - Replace Flash JavaScript API to draw 2D/3D - jQuery code to create pie <%-- Get style pie configuration --%> var pieConfig = jQuery.parseJSON( '<s:property value="stylePieConfig" escape="false" />' ); <%-- Create style pie --%> $("#style-pie") .pie(pieConfig, 150, 150);
  • 11. CSS3 Media Query - Responsive Design /* For device with screen width being greater than 480px */ @media screen and (min-width: 480px) { #styles #style-pie { float: left; } #styles .ui-content ul[data-role=listview] { float: left; } } - The Boston Globe: http://bostonglobe.com/
  • 12. Mobile Device Events - Swipe Gestures $(function() { $('div.ui-page').live('swipeleft', function() { history.go(1); }); $('div.ui-page').live('swiperight', function() { history.go(-1); }); }); - Page Initialization vs. DOM Ready $('#styles').live('pageinit', function(event) { console.log('Page styles is initialized'); });
  • 13. Android Deployment - Android SDK: http://developer.android.com/sdk/index.html - ADT Eclipse Plugin: http://developer.android.com/sdk/eclipse-adt.html#installing - PhoneGap: http://phonegap.com/ - Wrap web apps in native container - Support iOS, Android, Blackberry, WebOS, and Symbian - Support native features: Camera, Geolocation, Native File System, Contacts, Compass, Notification, etc.
  • 14. Android Project in Eclipse - AndroidManifest.xml - App.java public class App extends DroidGap { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); super.init(); // Clear browser cache super.clearCache(); super.loadUrl("<your IP address>/mobile/login.act"); } }
  • 15. Deploy to Simulator - Create AVD (Android Virtual Device) - Screen resolution - SD card size - Target Android SDK level - Hardware properties - Run as Android Application
  • 16. Deploy to Android Device - Sign application - Generate key store keytool -genkey -v -keystore android-release-key.keystore -alias alias_name -keyalg RSA -validity 10000 - Export signed application - .apk file - Install from apk file
  • 17. iOS Development - You need a Mac - Xcode - PhoneGap
  • 18. iOS Development (cont'd) - index.html <body onload="onBodyLoad()"> <script type="text/javascript"> window.location = "http://<your IP address>/mobile/login.act"; </script> </body> - AppDelegate.m shouldStartLoadWithRequest method return YES; - Branding in <your-app>-info.plist file
  • 19. Q&A