SlideShare uma empresa Scribd logo
1 de 80
Using GWT and Eclipse to Build Great
Mobile Web Apps
Chris Ramsdale
Product Manager, GWT and Google Plugin for Eclipse

Feedback: http://goo.gl/mn6Y4
Twitter: #io2011 #gwt
Why Are We Here?




3
The Problems
• Mobile devices
    – ...have smaller screens
    – ...can have different orientations
    – ...have slower processors
    – ...can be disconnected




4
The Solution
• Use GWT and Google's Plugin for Eclipse (GPE) to build great mobile web apps
  for iPhone and Android


• And helps you
    – ...build great mobile UIs for any form factor
    – ...optimize the user experience
    – ...make it snappy
    – ...work without a connection




5
Example App: Cloud Tasks
• Web based task mgmt app
• UIs for Android, iPhone, iPad, and desktop browsers
• Orientation change handling
• Offline support
• Source code available at the end




6
•   Build great UIs for any form factor
•   Optimize the user experience
•   Make it snappy
•   Work without a connection
Build Great Mobile UIs For Any Form Factor
• UI code like you expect it
    – Declarative UI layout with UiBinder


• Speed up UI development with WYSIWYG tools
    – Using GWT Designer to build great UIs




8
Build Great Mobile UIs For Any Form Factor
UI code like you expect it
<ui:UiBinder>
    <ui:style>
        .addButton {
            color: white;
            font-size: 18pt;
            background: none;
            border: none;
            text-align: right;
            font-weight: bold;
        }
    </ui:style>

     ...

</ui:UiBinder>




9
Build Great Mobile UIs For Any Form Factor
UI code like you expect it
<ui:UiBinder>
    <ui:style>
        .addButton {
            color: white;
            font-size: 18pt;
            background: none;
            border: none;
            text-align: right;
            font-weight: bold;
        }
    </ui:style>

     ...

</ui:UiBinder>




10
Build Great Mobile UIs For Any Form Factor
UI code like you expect it
<ui:UiBinder>
    <g:DockLayoutPanel>

        <!-- Header -->
        <g:north size="32">
          <g:HTMLPanel></g:HTMLPanel>
        </g:north>

        <g:center>
            <g:DockLayoutPanel>
                <!-- Task List. -->
                <g:west size="30">
                    <g:SimpleLayoutPanel addStyleNames="{style.taskList}"/>
                </g:west>

                <!-- Content. -->
                <g:center>
                    <g:DeckLayoutPanel></g:DeckLayoutPanel>
                </g:center>
            </g:DockLayoutPanel>
        </g:center>
    </g:DockLayoutPanel>
</ui:UiBinder>



11
Build Great Mobile UIs For Any Form Factor
UI code like you expect it
<ui:UiBinder>
    <g:DockLayoutPanel>

        <!-- Header -->
        <g:north size="32">
          <g:HTMLPanel></g:HTMLPanel>
        </g:north>

        <g:center>
            <g:DockLayoutPanel>
                <!-- Task List. -->
                <g:west size="30">
                    <g:SimpleLayoutPanel addStyleNames="{style.taskList}"/>
                </g:west>

                <!-- Content. -->
                <g:center>
                    <g:DeckLayoutPanel></g:DeckLayoutPanel>
                </g:center>
            </g:DockLayoutPanel>
        </g:center>
    </g:DockLayoutPanel>
</ui:UiBinder>



12
Build Great Mobile UIs For Any Form Factor
UI code like you expect it




13
Build Great Mobile UIs For Any Form Factor
UI code like you expect it
<ui:UiBinder>
    <g:DockLayoutPanel>

        <!-- Header -->
        <g:north size="32">
          <g:HTMLPanel></g:HTMLPanel>
        </g:north>

        <g:center>
            <g:DockLayoutPanel>
                <!-- Task List. -->
                <g:west size="30">
                    <g:SimpleLayoutPanel addStyleNames="{style.taskList}"/>
                </g:west>

                <!-- Content. -->
                <g:center>
                    <g:DeckLayoutPanel></g:DeckLayoutPanel>
                </g:center>
            </g:DockLayoutPanel>
        </g:center>
    </g:DockLayoutPanel>
</ui:UiBinder>



14
Build Great Mobile UIs For Any Form Factor
UI code like you expect it




15
Build Great Mobile UIs For Any Form Factor
UI code like you expect it
<ui:UiBinder>
    <g:DockLayoutPanel>

        <!-- Header -->
        <g:north size="32">
          <g:HTMLPanel></g:HTMLPanel>
        </g:north>

        <g:center>
            <g:DockLayoutPanel>
                <!-- Task List. -->
                <g:west size="30">
                    <g:SimpleLayoutPanel addStyleNames="{style.taskList}"/>
                </g:west>

                <!-- Content. -->
                <g:center>
                    <g:DeckLayoutPanel></g:DeckLayoutPanel>
                </g:center>
            </g:DockLayoutPanel>
        </g:center>
    </g:DockLayoutPanel>
</ui:UiBinder>



16
Build Great Mobile UIs For Any Form Factor
UI code like you expect it




17
Build Great Mobile UIs For Any Form Factor
Speed up UI development with WYSIWYG tools




18
Build Great Mobile UIs For Any Form Factor
Speed up UI development with WYSIWYG tools




19
Build Great Mobile UIs For Any Form Factor
Device-specific, declarative UIs




                                             ListViewPhone.ui.xml
                   ListViewTablet.ui.xml
20
•   Build great UIs for any form factor
•   Optimize the user experience
•   Make it snappy
•   Work without a connection
Optimize the User Experience
• Desktops, tablets, and phones...oh my!
     – Deferred binding to sort them out


• Landscape vs. portrait
     – Capture and respond to orientation changes


• Icing on the cake
     – Maximize code reuse by using the Model-View-Presenter (MVP) design pattern




22
Optimize the User Experience
Select the right UI using deferred binding




                                        Deferred what?




23
Optimize the User Experience
Deferred binding - optimize for the browser




24
Optimize the User Experience
Select the right UI using deferred binding




25
Optimize the User Experience
Select the right UI using deferred binding




26
Optimize the User Experience
Select the right UI using deferred binding
     CloudTasks.gwt.xml (GWT app config)
     <!-- Use ViewFactoryImplMobile for mobile form factor. -->
     <replace-with class="com.google.mobilecalendar.client.ViewFactoryImplMobile">
       <when-type-is class="com.google.mobilecalendar.client.ViewFactory"/>
       <when-property-is name="formfactor" value="mobile"/>
     </replace-with>




27
Optimize the User Experience
Select the right UI using deferred binding
     CloudTasks.gwt.xml (GWT app config)
     <!-- Use ViewFactoryImplMobile for mobile form factor. -->
     <replace-with class="com.google.mobilecalendar.client.ViewFactoryImplMobile">
       <when-type-is class="com.google.mobilecalendar.client.ViewFactory"/>
       <when-property-is name="formfactor" value="mobile"/>
     </replace-with>




28
Optimize the User Experience
Select the right UI using deferred binding
     CloudTasks.gwt.xml (GWT app config)
     <!-- Use ViewFactoryImplMobile for tablet form factor. -->
     <replace-with class="com.google.mobilecalendar.client.ViewFactoryImplTablet">
       <when-type-is class="com.google.mobilecalendar.client.ViewFactory"/>
       <when-property-is name="formfactor" value="tablet"/>
     </replace-with>




29
Optimize the User Experience
Select the right UI using deferred binding
     CloudTasks.gwt.xml (GWT app config)
     <!-- Use ViewFactoryImplMobile for tablet form factor. -->
     <replace-with class="com.google.mobilecalendar.client.ViewFactoryImplTablet">
       <when-type-is class="com.google.mobilecalendar.client.ViewFactory"/>
       <when-property-is name="formfactor" value="tablet"/>
     </replace-with>




30
Optimize the User Experience
Select the right UI using deferred binding
     FormFactor.gwt.xml
     <property-provider name="formfactor">
       <![CDATA[
         var ua = navigator.userAgent.toLowerCase();
         if (ua.indexOf("ipad") != -1) {
             return "tablet";
         } else if (ua.indexOf("iphone") != -1 || ) {
           return "mobile";
         } else if (ua.indexOf("android") != -1) {
             // Overly complex hueristic for determining Android form factor
             ...
         }
       ]]>
     </property-provider>
31
Optimize the User Experience
Select the right UI using deferred binding
     FormFactor.gwt.xml
     <property-provider name="formfactor">
       <![CDATA[
         var ua = navigator.userAgent.toLowerCase();
         if (ua.indexOf("ipad") != -1) {
             return "tablet";
         } else if (ua.indexOf("iphone") != -1 || ) {
           return "mobile";
         } else if (ua.indexOf("android") != -1) {
             // Overly complex hueristic for determining Android form factor
             ...
         }
       ]]>
     </property-provider>
32
Optimize the User Experience
Select the right UI using deferred binding
     FormFactor.gwt.xml
     <property-provider name="formfactor">
       <![CDATA[
         var ua = navigator.userAgent.toLowerCase();
         if (ua.indexOf("ipad") != -1) {
             return "tablet";
         } else if (ua.indexOf("iphone") != -1 || ) {
           return "mobile";
         } else if (ua.indexOf("android") != -1) {
             // Overly complex hueristic for determining Android form factor
             ...
         }
       ]]>
     </property-provider>
33
Optimize the User Experience
Select the right UI using deferred binding
     FormFactor.gwt.xml
     <property-provider name="formfactor">
       <![CDATA[
         var ua = navigator.userAgent.toLowerCase();
         if (ua.indexOf("ipad") != -1) {
             return "tablet";
         } else if (ua.indexOf("iphone") != -1 || ) {
           return "mobile";
         } else if (ua.indexOf("android") != -1) {
             // Overly complex heuristic for determining Android form factor
             ...
         }
       ]]>
     </property-provider>
34
Optimize the User Experience
Select the right UI using deferred binding
     CloudTasks.gwt.xml (GWT app config)
     <!-- Use ViewFactoryImplMobile for tablet form factor. -->
     <replace-with class="com.google.mobilecalendar.client.ViewFactoryImplTablet">
       <when-type-is class="com.google.mobilecalendar.client.ViewFactory"/>
       <when-property-is name="formfactor" value="tablet"/>
     </replace-with>




35
Optimize the User Experience
Select the right UI using deferred binding




36
Build Great Mobile UIs For Any Form Factor
Device-specific, declarative UIs




                                             ListViewPhone.ui.xml
                   ListViewTablet.ui.xml
37
Optimize the User Experience
Capture and respond to orientation changes




38
Optimize the User Experience
Capture and respond to orientation changes




39
Optimize the User Experience
Capture and respond to orientation changes




40
Optimize the User Experience
Capture and respond to orientation changes
     /*
      * Listen for changes in the window size so we can adjust the
      * orientation of the app. This will also catch orientation changes
      * on mobile devices.
      */
     windowResizeHandler = Window.addResizeHandler(new ResizeHandler() {
       public void onResize(ResizeEvent event) {
           if (isOrientationPortrait != calculateOrientationPortrait()) {
               isOrientationPortrait = !isOrientationPortrait;
               adjustOrientation(isOrientationPortrait);
           }
       }
     });

41
Optimize the User Experience
Capture and respond to orientation changes
     /*
      * Listen for changes in the window size so we can adjust the
      * orientation of the app. This will also catch orientation changes
      * on mobile devices.
      */
     windowResizeHandler = Window.addResizeHandler(new ResizeHandler() {
       public void onResize(ResizeEvent event) {
           if (isOrientationPortrait != calculateOrientationPortrait()) {
               isOrientationPortrait = !isOrientationPortrait;
               adjustOrientation(isOrientationPortrait);
           }
       }
     });

42
Optimize the User Experience
Capture and respond to orientation changes




     private static boolean calculateOrientationPortrait() {
         return Window.getClientHeight() > Window.getClientWidth();
     }




43
Optimize the User Experience
Capture and respond to orientation changes
     /*
      * Listen for changes in the window size so we can adjust the
      * orientation of the app. This will also catch orientation changes
      * on mobile devices.
      */
     windowResizeHandler = Window.addResizeHandler(new ResizeHandler() {
       public void onResize(ResizeEvent event) {
           if (isOrientationPortrait != calculateOrientationPortrait()) {
               isOrientationPortrait = !isOrientationPortrait;
               adjustOrientation(isOrientationPortrait);
           }
       }
     });

44
Optimize the User Experience
Capture and respond to orientation changes




45
Optimize the User Experience
Capture and respond to orientation changes




46
Optimize the User Experience
Maximize code reuse using the MVP pattern




47
Optimize the User Experience
Maximize code reuse using the MVP pattern

• MVP recap
     – Model-View-Presenter design pattern
     – Similar to MVC - less logic in the View
     – Business logic goes are part of Model/Presenter
     – Keep Views as simple as possible
     – Faster test cycles: run tests as vanilla JRE tests




48
Optimize the User Experience
Maximize code reuse using the MVP pattern

• Tablet vs Phone
     – Business logic is the same
     – Views change
     – Ideal design pattern for supporting multiple form factors




49
Optimize the User Experience
Maximize code reuse using the MVP pattern




50
Optimize the User Experience
Maximize code reuse using the MVP pattern




51
Optimize the User Experience
Select the right UI using deferred binding
     CloudTasks.gwt.xml (GWT module config)
     <!-- Use ViewFactoryImplTablet for tablet form factor. -->
     <replace-with class="com.google.mobilecalendar.client.ViewFactoryImplTablet">
       <when-type-is class="com.google.mobilecalendar.client.ViewFactory"/>
       <when-property-is name="formfactor" value="tablet"/>
     </replace-with>




52
•   Build great UIs for any form factor
•   Optimize the user experience
•   Make it snappy
•   Work without a connection
Make it Snappy

• Increase responsiveness
     – Problem: HTTP requests are expensive over 3G connections


• Minimize startup time
     – Problem: Mobile processing power still trails desktops/laptops
     – Problem: Parsing large amounts of Javascript can be a large source of latency




54
Make it Snappy

• Increase responsiveness
     – Solution: Use GWT's Client Bundle to batch resource fetches


• Minimize startup time
     – Solution: Use Code Splitting to grab only the code you need
     – Solution: Remove unused code, reduce overall code size using GWT compiler optimizations




55
Make it Snappy
Increase responsiveness by bundling resource fetches




                                             Demo




56
Make it Snappy
Increase responsiveness by bundling resource fetches

• Even worse, mobile browsers limit the number of concurrent requests
• Ex http request waterfall chart for Android - 4 concurrent TCP connections




     http://calendar.perfplanet.com/2010/mobile-performance-analysis-using-pcapperf/
57
Make it Snappy
Increase responsiveness by bundling resources

     public interface Resources extends ClientBundle {
         @Source("image0.gif")
         public ImageResource image0();

         @Source("image1.gif")
         public ImageResource image1();

         ...
     }

58
Make it Snappy
Increase responsiveness by deferring resource fetching

     void onShowImagesButtonClicked() {
         GWT.runAsync(new RunAsyncCallback() {
             public void onSuccess() {
                 showImagesDialog();
             }
         }
     }




59
Make it Snappy
Increase responsiveness by deferring resource fetching

     void onShowImagesButtonClicked() {
         GWT.runAsync(new RunAsyncCallback() {
             public void onSuccess() {
                 showImagesDialog();
             }
         }
     }




60
Make it Snappy
Increase responsiveness by deferring resource fetching
                                                                          HTTP Request Overhead
                                                2000



Total time spent waiting (ms)
                                                1500




• Not bundled: 1409ms
                                                1000




• Bundled: 594ms
                                                 500




• Bundled and code split: 664ms                    0
                                                         Not bundled             Bundled              Bundled/code split


                                                                       Startup             Image dialog



61
Make it Snappy
Reduce overall code size, reduce startup time

• More Javascript == more parsing == increased load time, cpu cycles
• Increased cpu cycles == battery drain == poor user experience
                                                       Optimized vs Unoptimized Output
                                                1100


• GWT compiler optimizations can help
     – Dead code elimination                     825




     – Duplicate function removal
                                                 550

     – Obfuscation
                                                 275




                                                   0
                                                             Size of Javascript in KB

                                                        Optimized                       Unoptimized




62
•   Build great UIs for any form factor
•   Optimize the user experience
•   Make it snappy
•   Work without a connection
Work Without a Connection

• Run wherever, whenever
     – Use Application Cache to load resources locally


• Access data wherever, whenever
     – Use Local Storage as a caching mechanism for RPCs




64
Work Without a Connection
Run wherever, whenever using Application Cache

• Part of the HTML5 feature set
• Loads resources like HTML, CSS, and JS from disk
• Works with iPhone and Android (+ Chrome, Safari, and Firefox)




65
Work Without a Connection
Run wherever, whenever using Application Cache

• appcache.nocache.manifest
     – Lists all of the files that you want to browser to cache
        • Include HTML, CSS, JS
           – Exclude GWT-RPC-related files (security)
           – "nocache" - always requested


• web.xml
     – mime-type for manifest files (text/plain)


• <your_app>.html
     – include <html manifest="app.nocache.manifest">

66
Work Without a Connection
Run wherever, whenever using Application Cache




                 ...or check out the GWT 2.4 SDK :-)




67
Work Without a Connection
Run wherever, whenever using Application Cache


<!-- Define a custom App Cache linker -->
<define-linker name="appcachelinker"
    class="com.google.gwt.sample.mobilewebapp.linker.AppCacheLinker"/>

<!-- Use it -->
<add-linker name="appcachelinker"/>




68
Work Without a Connection
Access data wherever, whenever using Local Storage

• Part of the HTML5 feature set
• Utilizes a local database for reading/writing data
• Key/value-pair persistence
• Works with iPhone and Android (+ Chrome, Safari, and Firefox)
• Included in the GWT 2.3 SDK




69
Work Without a Connection
Access data wherever, whenever using Local Storage

• Grab an instance of the Local Storage interface
     localStorage = Storage.getLocalStorageIfSupported();


• Read cache and then request any updates
     public List<Tasks> getTasks() {
         String taskListString = localStorage.getItem(TASKLIST_SAVE_KEY);
         List<Tasks> tasks = deserialize(taskListString);
         requestFactory.taskRequest().queryForUpdates().fire(...) {
             ...
         }
         return tasks;
     }
70
Work Without a Connection
Access data wherever, whenever using Local Storage

• Upon response, update cache and any listeners
     public List<Tasks> getTasks() {
         ...
         requestFactory.taskRequest().queryForUpdates().fire(
           new Receiver<List<Tasks>>() {
               public onSuccess(List<Tasks> tasks) {
                 String tasksListString = serialize(tasks);
                 localStorage.setItem(TASKSLIST_SAVE_KEY, tasksListString);
                 // update everyone listening for task list updates
               }});
         ...
     }
71
Summary

• There are many challenges when building great mobile web apps


• GWT and GPE can help


• Tools for quickly building great UIs


• Frameworks for optimizing the user experience


• Compilers and code generators to improve speed


• API support for working offline
72
More Info...

• You can download the source and tools here:
     – http://code.google.com/webtoolkit/download.html


• Other sessions to check out
     – Use Page Speed to Optimize Your Web Site For Mobile (Check back for YouTube link)
     – Mobile Web Development: From Zero to Hero (12:30pm)
     – HTML5 versus Android: Apps or Web for Mobile Development? (3pm)




73
Q&A




74
</presentation>




75

Mais conteúdo relacionado

Destaque

Social Media for IABC Chapters
Social Media for IABC ChaptersSocial Media for IABC Chapters
Social Media for IABC ChaptersDare to Lead 2011
 
Event Management by Redefine SAPCPG
Event Management by Redefine SAPCPGEvent Management by Redefine SAPCPG
Event Management by Redefine SAPCPGRedefine
 
Event Management by Redefine SEL_Offsite
Event Management by Redefine SEL_Offsite Event Management by Redefine SEL_Offsite
Event Management by Redefine SEL_Offsite Redefine
 
Redefine Profile
Redefine ProfileRedefine Profile
Redefine ProfileRedefine
 
Creative Showcase by Redefine Team
Creative Showcase by Redefine TeamCreative Showcase by Redefine Team
Creative Showcase by Redefine TeamRedefine
 
Jacobson Cardinali 15 Principes
Jacobson Cardinali 15 PrincipesJacobson Cardinali 15 Principes
Jacobson Cardinali 15 PrincipesOlaf Jacobson
 
Les tic a l´educació
Les tic a l´educacióLes tic a l´educació
Les tic a l´educacióraqueltarraco
 
Classe d´anglés amb tic
Classe d´anglés amb ticClasse d´anglés amb tic
Classe d´anglés amb ticraqueltarraco
 
Classe d´anglés amb tic
Classe d´anglés amb ticClasse d´anglés amb tic
Classe d´anglés amb ticraqueltarraco
 

Destaque (13)

Social Media for IABC Chapters
Social Media for IABC ChaptersSocial Media for IABC Chapters
Social Media for IABC Chapters
 
Event Management by Redefine SAPCPG
Event Management by Redefine SAPCPGEvent Management by Redefine SAPCPG
Event Management by Redefine SAPCPG
 
Event Management by Redefine SEL_Offsite
Event Management by Redefine SEL_Offsite Event Management by Redefine SEL_Offsite
Event Management by Redefine SEL_Offsite
 
Purify water
Purify waterPurify water
Purify water
 
Facebook採用活動のご案内
Facebook採用活動のご案内Facebook採用活動のご案内
Facebook採用活動のご案内
 
Redefine Profile
Redefine ProfileRedefine Profile
Redefine Profile
 
Creative Showcase by Redefine Team
Creative Showcase by Redefine TeamCreative Showcase by Redefine Team
Creative Showcase by Redefine Team
 
Jacobson Cardinali 15 Principes
Jacobson Cardinali 15 PrincipesJacobson Cardinali 15 Principes
Jacobson Cardinali 15 Principes
 
Les tic a l´educació
Les tic a l´educacióLes tic a l´educació
Les tic a l´educació
 
Classe d´anglés amb tic
Classe d´anglés amb ticClasse d´anglés amb tic
Classe d´anglés amb tic
 
Classe d´anglés amb tic
Classe d´anglés amb ticClasse d´anglés amb tic
Classe d´anglés amb tic
 
Bus
BusBus
Bus
 
O novo-gmail
O novo-gmailO novo-gmail
O novo-gmail
 

Semelhante a Cramsdale dev tools_using-gwt-and-google-plugin-for-eclipse-to-build-greate-mobile-web-apps

What's new in Android at I/O'16
What's new in Android at I/O'16What's new in Android at I/O'16
What's new in Android at I/O'16Elif Boncuk
 
Desenvolvimento Mobile Híbrido
Desenvolvimento Mobile HíbridoDesenvolvimento Mobile Híbrido
Desenvolvimento Mobile HíbridoJuliano Martins
 
Primefaces mobile users_guide_0_9
Primefaces mobile users_guide_0_9Primefaces mobile users_guide_0_9
Primefaces mobile users_guide_0_9ednilsoncampos
 
Android Wear: A Developer's Perspective
Android Wear: A Developer's PerspectiveAndroid Wear: A Developer's Perspective
Android Wear: A Developer's PerspectiveVin Lim
 
Android N Highligts
Android N HighligtsAndroid N Highligts
Android N HighligtsSercan Yusuf
 
Telerik Kendo UI Overview
Telerik Kendo UI OverviewTelerik Kendo UI Overview
Telerik Kendo UI OverviewEd Musters
 
embedding web browser in your app
embedding web browser in your appembedding web browser in your app
embedding web browser in your appSamsung
 
Mobile html5 today
Mobile html5 todayMobile html5 today
Mobile html5 todayIdo Green
 
How To Build a Multi-Field Search Page For Your XPages Application
How To Build a Multi-Field Search Page For Your XPages ApplicationHow To Build a Multi-Field Search Page For Your XPages Application
How To Build a Multi-Field Search Page For Your XPages ApplicationMichael McGarel
 
How to speedup GWT compiler
How to speedup GWT compilerHow to speedup GWT compiler
How to speedup GWT compilerMohammed Kharma
 
The fundamental problems of GUI applications and why people choose React
The fundamental problems of GUI applications and why people choose ReactThe fundamental problems of GUI applications and why people choose React
The fundamental problems of GUI applications and why people choose ReactOliver N
 
CiklumJavaSat15112011:Andrew Mormysh-GWT features overview
CiklumJavaSat15112011:Andrew Mormysh-GWT features overviewCiklumJavaSat15112011:Andrew Mormysh-GWT features overview
CiklumJavaSat15112011:Andrew Mormysh-GWT features overviewCiklum Ukraine
 
V Legakis Presentation
V Legakis PresentationV Legakis Presentation
V Legakis PresentationVLegakis
 
BP204 - Take a REST and put your data to work with APIs!
BP204 - Take a REST and put your data to work with APIs!BP204 - Take a REST and put your data to work with APIs!
BP204 - Take a REST and put your data to work with APIs!Craig Schumann
 
Google I/O 2019 - what's new in Android Q and Jetpack
Google I/O 2019 - what's new in Android Q and JetpackGoogle I/O 2019 - what's new in Android Q and Jetpack
Google I/O 2019 - what's new in Android Q and JetpackSunita Singh
 
MOPCON 2014 - Best software architecture in app development
MOPCON 2014 - Best software architecture in app developmentMOPCON 2014 - Best software architecture in app development
MOPCON 2014 - Best software architecture in app developmentanistar sung
 
Polymer
Polymer Polymer
Polymer jskvara
 
Final year project working documentation 2020
Final year project working documentation 2020Final year project working documentation 2020
Final year project working documentation 2020Vikram Singh
 
Gdg san diego android 11 meetups what's new in android - ui and dev tools
Gdg san diego android 11 meetups  what's new in android  - ui and dev toolsGdg san diego android 11 meetups  what's new in android  - ui and dev tools
Gdg san diego android 11 meetups what's new in android - ui and dev toolsSvetlin Stanchev
 

Semelhante a Cramsdale dev tools_using-gwt-and-google-plugin-for-eclipse-to-build-greate-mobile-web-apps (20)

What's new in Android at I/O'16
What's new in Android at I/O'16What's new in Android at I/O'16
What's new in Android at I/O'16
 
Desenvolvimento Mobile Híbrido
Desenvolvimento Mobile HíbridoDesenvolvimento Mobile Híbrido
Desenvolvimento Mobile Híbrido
 
Primefaces mobile users_guide_0_9
Primefaces mobile users_guide_0_9Primefaces mobile users_guide_0_9
Primefaces mobile users_guide_0_9
 
Android Wear: A Developer's Perspective
Android Wear: A Developer's PerspectiveAndroid Wear: A Developer's Perspective
Android Wear: A Developer's Perspective
 
Android N Highligts
Android N HighligtsAndroid N Highligts
Android N Highligts
 
Telerik Kendo UI Overview
Telerik Kendo UI OverviewTelerik Kendo UI Overview
Telerik Kendo UI Overview
 
embedding web browser in your app
embedding web browser in your appembedding web browser in your app
embedding web browser in your app
 
Mobile html5 today
Mobile html5 todayMobile html5 today
Mobile html5 today
 
How To Build a Multi-Field Search Page For Your XPages Application
How To Build a Multi-Field Search Page For Your XPages ApplicationHow To Build a Multi-Field Search Page For Your XPages Application
How To Build a Multi-Field Search Page For Your XPages Application
 
How to speedup GWT compiler
How to speedup GWT compilerHow to speedup GWT compiler
How to speedup GWT compiler
 
The fundamental problems of GUI applications and why people choose React
The fundamental problems of GUI applications and why people choose ReactThe fundamental problems of GUI applications and why people choose React
The fundamental problems of GUI applications and why people choose React
 
CiklumJavaSat15112011:Andrew Mormysh-GWT features overview
CiklumJavaSat15112011:Andrew Mormysh-GWT features overviewCiklumJavaSat15112011:Andrew Mormysh-GWT features overview
CiklumJavaSat15112011:Andrew Mormysh-GWT features overview
 
V Legakis Presentation
V Legakis PresentationV Legakis Presentation
V Legakis Presentation
 
BP204 - Take a REST and put your data to work with APIs!
BP204 - Take a REST and put your data to work with APIs!BP204 - Take a REST and put your data to work with APIs!
BP204 - Take a REST and put your data to work with APIs!
 
Google I/O 2019 - what's new in Android Q and Jetpack
Google I/O 2019 - what's new in Android Q and JetpackGoogle I/O 2019 - what's new in Android Q and Jetpack
Google I/O 2019 - what's new in Android Q and Jetpack
 
MOPCON 2014 - Best software architecture in app development
MOPCON 2014 - Best software architecture in app developmentMOPCON 2014 - Best software architecture in app development
MOPCON 2014 - Best software architecture in app development
 
Polymer
Polymer Polymer
Polymer
 
Final year project working documentation 2020
Final year project working documentation 2020Final year project working documentation 2020
Final year project working documentation 2020
 
Gdg san diego android 11 meetups what's new in android - ui and dev tools
Gdg san diego android 11 meetups  what's new in android  - ui and dev toolsGdg san diego android 11 meetups  what's new in android  - ui and dev tools
Gdg san diego android 11 meetups what's new in android - ui and dev tools
 
Night Watch with QA
Night Watch with QANight Watch with QA
Night Watch with QA
 

Último

Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 

Último (20)

Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 

Cramsdale dev tools_using-gwt-and-google-plugin-for-eclipse-to-build-greate-mobile-web-apps

  • 1.
  • 2.
  • 3. Using GWT and Eclipse to Build Great Mobile Web Apps Chris Ramsdale Product Manager, GWT and Google Plugin for Eclipse Feedback: http://goo.gl/mn6Y4 Twitter: #io2011 #gwt
  • 4. Why Are We Here? 3
  • 5. The Problems • Mobile devices – ...have smaller screens – ...can have different orientations – ...have slower processors – ...can be disconnected 4
  • 6. The Solution • Use GWT and Google's Plugin for Eclipse (GPE) to build great mobile web apps for iPhone and Android • And helps you – ...build great mobile UIs for any form factor – ...optimize the user experience – ...make it snappy – ...work without a connection 5
  • 7. Example App: Cloud Tasks • Web based task mgmt app • UIs for Android, iPhone, iPad, and desktop browsers • Orientation change handling • Offline support • Source code available at the end 6
  • 8.
  • 9. Build great UIs for any form factor • Optimize the user experience • Make it snappy • Work without a connection
  • 10. Build Great Mobile UIs For Any Form Factor • UI code like you expect it – Declarative UI layout with UiBinder • Speed up UI development with WYSIWYG tools – Using GWT Designer to build great UIs 8
  • 11. Build Great Mobile UIs For Any Form Factor UI code like you expect it <ui:UiBinder> <ui:style> .addButton { color: white; font-size: 18pt; background: none; border: none; text-align: right; font-weight: bold; } </ui:style> ... </ui:UiBinder> 9
  • 12. Build Great Mobile UIs For Any Form Factor UI code like you expect it <ui:UiBinder> <ui:style> .addButton { color: white; font-size: 18pt; background: none; border: none; text-align: right; font-weight: bold; } </ui:style> ... </ui:UiBinder> 10
  • 13. Build Great Mobile UIs For Any Form Factor UI code like you expect it <ui:UiBinder> <g:DockLayoutPanel> <!-- Header --> <g:north size="32"> <g:HTMLPanel></g:HTMLPanel> </g:north> <g:center> <g:DockLayoutPanel> <!-- Task List. --> <g:west size="30"> <g:SimpleLayoutPanel addStyleNames="{style.taskList}"/> </g:west> <!-- Content. --> <g:center> <g:DeckLayoutPanel></g:DeckLayoutPanel> </g:center> </g:DockLayoutPanel> </g:center> </g:DockLayoutPanel> </ui:UiBinder> 11
  • 14. Build Great Mobile UIs For Any Form Factor UI code like you expect it <ui:UiBinder> <g:DockLayoutPanel> <!-- Header --> <g:north size="32"> <g:HTMLPanel></g:HTMLPanel> </g:north> <g:center> <g:DockLayoutPanel> <!-- Task List. --> <g:west size="30"> <g:SimpleLayoutPanel addStyleNames="{style.taskList}"/> </g:west> <!-- Content. --> <g:center> <g:DeckLayoutPanel></g:DeckLayoutPanel> </g:center> </g:DockLayoutPanel> </g:center> </g:DockLayoutPanel> </ui:UiBinder> 12
  • 15. Build Great Mobile UIs For Any Form Factor UI code like you expect it 13
  • 16. Build Great Mobile UIs For Any Form Factor UI code like you expect it <ui:UiBinder> <g:DockLayoutPanel> <!-- Header --> <g:north size="32"> <g:HTMLPanel></g:HTMLPanel> </g:north> <g:center> <g:DockLayoutPanel> <!-- Task List. --> <g:west size="30"> <g:SimpleLayoutPanel addStyleNames="{style.taskList}"/> </g:west> <!-- Content. --> <g:center> <g:DeckLayoutPanel></g:DeckLayoutPanel> </g:center> </g:DockLayoutPanel> </g:center> </g:DockLayoutPanel> </ui:UiBinder> 14
  • 17. Build Great Mobile UIs For Any Form Factor UI code like you expect it 15
  • 18. Build Great Mobile UIs For Any Form Factor UI code like you expect it <ui:UiBinder> <g:DockLayoutPanel> <!-- Header --> <g:north size="32"> <g:HTMLPanel></g:HTMLPanel> </g:north> <g:center> <g:DockLayoutPanel> <!-- Task List. --> <g:west size="30"> <g:SimpleLayoutPanel addStyleNames="{style.taskList}"/> </g:west> <!-- Content. --> <g:center> <g:DeckLayoutPanel></g:DeckLayoutPanel> </g:center> </g:DockLayoutPanel> </g:center> </g:DockLayoutPanel> </ui:UiBinder> 16
  • 19. Build Great Mobile UIs For Any Form Factor UI code like you expect it 17
  • 20. Build Great Mobile UIs For Any Form Factor Speed up UI development with WYSIWYG tools 18
  • 21. Build Great Mobile UIs For Any Form Factor Speed up UI development with WYSIWYG tools 19
  • 22. Build Great Mobile UIs For Any Form Factor Device-specific, declarative UIs ListViewPhone.ui.xml ListViewTablet.ui.xml 20
  • 23.
  • 24. Build great UIs for any form factor • Optimize the user experience • Make it snappy • Work without a connection
  • 25. Optimize the User Experience • Desktops, tablets, and phones...oh my! – Deferred binding to sort them out • Landscape vs. portrait – Capture and respond to orientation changes • Icing on the cake – Maximize code reuse by using the Model-View-Presenter (MVP) design pattern 22
  • 26. Optimize the User Experience Select the right UI using deferred binding Deferred what? 23
  • 27. Optimize the User Experience Deferred binding - optimize for the browser 24
  • 28. Optimize the User Experience Select the right UI using deferred binding 25
  • 29. Optimize the User Experience Select the right UI using deferred binding 26
  • 30. Optimize the User Experience Select the right UI using deferred binding CloudTasks.gwt.xml (GWT app config) <!-- Use ViewFactoryImplMobile for mobile form factor. --> <replace-with class="com.google.mobilecalendar.client.ViewFactoryImplMobile"> <when-type-is class="com.google.mobilecalendar.client.ViewFactory"/> <when-property-is name="formfactor" value="mobile"/> </replace-with> 27
  • 31. Optimize the User Experience Select the right UI using deferred binding CloudTasks.gwt.xml (GWT app config) <!-- Use ViewFactoryImplMobile for mobile form factor. --> <replace-with class="com.google.mobilecalendar.client.ViewFactoryImplMobile"> <when-type-is class="com.google.mobilecalendar.client.ViewFactory"/> <when-property-is name="formfactor" value="mobile"/> </replace-with> 28
  • 32. Optimize the User Experience Select the right UI using deferred binding CloudTasks.gwt.xml (GWT app config) <!-- Use ViewFactoryImplMobile for tablet form factor. --> <replace-with class="com.google.mobilecalendar.client.ViewFactoryImplTablet"> <when-type-is class="com.google.mobilecalendar.client.ViewFactory"/> <when-property-is name="formfactor" value="tablet"/> </replace-with> 29
  • 33. Optimize the User Experience Select the right UI using deferred binding CloudTasks.gwt.xml (GWT app config) <!-- Use ViewFactoryImplMobile for tablet form factor. --> <replace-with class="com.google.mobilecalendar.client.ViewFactoryImplTablet"> <when-type-is class="com.google.mobilecalendar.client.ViewFactory"/> <when-property-is name="formfactor" value="tablet"/> </replace-with> 30
  • 34. Optimize the User Experience Select the right UI using deferred binding FormFactor.gwt.xml <property-provider name="formfactor"> <![CDATA[ var ua = navigator.userAgent.toLowerCase(); if (ua.indexOf("ipad") != -1) { return "tablet"; } else if (ua.indexOf("iphone") != -1 || ) { return "mobile"; } else if (ua.indexOf("android") != -1) { // Overly complex hueristic for determining Android form factor ... } ]]> </property-provider> 31
  • 35. Optimize the User Experience Select the right UI using deferred binding FormFactor.gwt.xml <property-provider name="formfactor"> <![CDATA[ var ua = navigator.userAgent.toLowerCase(); if (ua.indexOf("ipad") != -1) { return "tablet"; } else if (ua.indexOf("iphone") != -1 || ) { return "mobile"; } else if (ua.indexOf("android") != -1) { // Overly complex hueristic for determining Android form factor ... } ]]> </property-provider> 32
  • 36. Optimize the User Experience Select the right UI using deferred binding FormFactor.gwt.xml <property-provider name="formfactor"> <![CDATA[ var ua = navigator.userAgent.toLowerCase(); if (ua.indexOf("ipad") != -1) { return "tablet"; } else if (ua.indexOf("iphone") != -1 || ) { return "mobile"; } else if (ua.indexOf("android") != -1) { // Overly complex hueristic for determining Android form factor ... } ]]> </property-provider> 33
  • 37. Optimize the User Experience Select the right UI using deferred binding FormFactor.gwt.xml <property-provider name="formfactor"> <![CDATA[ var ua = navigator.userAgent.toLowerCase(); if (ua.indexOf("ipad") != -1) { return "tablet"; } else if (ua.indexOf("iphone") != -1 || ) { return "mobile"; } else if (ua.indexOf("android") != -1) { // Overly complex heuristic for determining Android form factor ... } ]]> </property-provider> 34
  • 38. Optimize the User Experience Select the right UI using deferred binding CloudTasks.gwt.xml (GWT app config) <!-- Use ViewFactoryImplMobile for tablet form factor. --> <replace-with class="com.google.mobilecalendar.client.ViewFactoryImplTablet"> <when-type-is class="com.google.mobilecalendar.client.ViewFactory"/> <when-property-is name="formfactor" value="tablet"/> </replace-with> 35
  • 39. Optimize the User Experience Select the right UI using deferred binding 36
  • 40. Build Great Mobile UIs For Any Form Factor Device-specific, declarative UIs ListViewPhone.ui.xml ListViewTablet.ui.xml 37
  • 41. Optimize the User Experience Capture and respond to orientation changes 38
  • 42. Optimize the User Experience Capture and respond to orientation changes 39
  • 43. Optimize the User Experience Capture and respond to orientation changes 40
  • 44. Optimize the User Experience Capture and respond to orientation changes /* * Listen for changes in the window size so we can adjust the * orientation of the app. This will also catch orientation changes * on mobile devices. */ windowResizeHandler = Window.addResizeHandler(new ResizeHandler() { public void onResize(ResizeEvent event) { if (isOrientationPortrait != calculateOrientationPortrait()) { isOrientationPortrait = !isOrientationPortrait; adjustOrientation(isOrientationPortrait); } } }); 41
  • 45. Optimize the User Experience Capture and respond to orientation changes /* * Listen for changes in the window size so we can adjust the * orientation of the app. This will also catch orientation changes * on mobile devices. */ windowResizeHandler = Window.addResizeHandler(new ResizeHandler() { public void onResize(ResizeEvent event) { if (isOrientationPortrait != calculateOrientationPortrait()) { isOrientationPortrait = !isOrientationPortrait; adjustOrientation(isOrientationPortrait); } } }); 42
  • 46. Optimize the User Experience Capture and respond to orientation changes private static boolean calculateOrientationPortrait() { return Window.getClientHeight() > Window.getClientWidth(); } 43
  • 47. Optimize the User Experience Capture and respond to orientation changes /* * Listen for changes in the window size so we can adjust the * orientation of the app. This will also catch orientation changes * on mobile devices. */ windowResizeHandler = Window.addResizeHandler(new ResizeHandler() { public void onResize(ResizeEvent event) { if (isOrientationPortrait != calculateOrientationPortrait()) { isOrientationPortrait = !isOrientationPortrait; adjustOrientation(isOrientationPortrait); } } }); 44
  • 48. Optimize the User Experience Capture and respond to orientation changes 45
  • 49. Optimize the User Experience Capture and respond to orientation changes 46
  • 50. Optimize the User Experience Maximize code reuse using the MVP pattern 47
  • 51. Optimize the User Experience Maximize code reuse using the MVP pattern • MVP recap – Model-View-Presenter design pattern – Similar to MVC - less logic in the View – Business logic goes are part of Model/Presenter – Keep Views as simple as possible – Faster test cycles: run tests as vanilla JRE tests 48
  • 52. Optimize the User Experience Maximize code reuse using the MVP pattern • Tablet vs Phone – Business logic is the same – Views change – Ideal design pattern for supporting multiple form factors 49
  • 53. Optimize the User Experience Maximize code reuse using the MVP pattern 50
  • 54. Optimize the User Experience Maximize code reuse using the MVP pattern 51
  • 55. Optimize the User Experience Select the right UI using deferred binding CloudTasks.gwt.xml (GWT module config) <!-- Use ViewFactoryImplTablet for tablet form factor. --> <replace-with class="com.google.mobilecalendar.client.ViewFactoryImplTablet"> <when-type-is class="com.google.mobilecalendar.client.ViewFactory"/> <when-property-is name="formfactor" value="tablet"/> </replace-with> 52
  • 56.
  • 57. Build great UIs for any form factor • Optimize the user experience • Make it snappy • Work without a connection
  • 58. Make it Snappy • Increase responsiveness – Problem: HTTP requests are expensive over 3G connections • Minimize startup time – Problem: Mobile processing power still trails desktops/laptops – Problem: Parsing large amounts of Javascript can be a large source of latency 54
  • 59. Make it Snappy • Increase responsiveness – Solution: Use GWT's Client Bundle to batch resource fetches • Minimize startup time – Solution: Use Code Splitting to grab only the code you need – Solution: Remove unused code, reduce overall code size using GWT compiler optimizations 55
  • 60. Make it Snappy Increase responsiveness by bundling resource fetches Demo 56
  • 61. Make it Snappy Increase responsiveness by bundling resource fetches • Even worse, mobile browsers limit the number of concurrent requests • Ex http request waterfall chart for Android - 4 concurrent TCP connections http://calendar.perfplanet.com/2010/mobile-performance-analysis-using-pcapperf/ 57
  • 62. Make it Snappy Increase responsiveness by bundling resources public interface Resources extends ClientBundle { @Source("image0.gif") public ImageResource image0(); @Source("image1.gif") public ImageResource image1(); ... } 58
  • 63. Make it Snappy Increase responsiveness by deferring resource fetching void onShowImagesButtonClicked() { GWT.runAsync(new RunAsyncCallback() { public void onSuccess() { showImagesDialog(); } } } 59
  • 64. Make it Snappy Increase responsiveness by deferring resource fetching void onShowImagesButtonClicked() { GWT.runAsync(new RunAsyncCallback() { public void onSuccess() { showImagesDialog(); } } } 60
  • 65. Make it Snappy Increase responsiveness by deferring resource fetching HTTP Request Overhead 2000 Total time spent waiting (ms) 1500 • Not bundled: 1409ms 1000 • Bundled: 594ms 500 • Bundled and code split: 664ms 0 Not bundled Bundled Bundled/code split Startup Image dialog 61
  • 66. Make it Snappy Reduce overall code size, reduce startup time • More Javascript == more parsing == increased load time, cpu cycles • Increased cpu cycles == battery drain == poor user experience Optimized vs Unoptimized Output 1100 • GWT compiler optimizations can help – Dead code elimination 825 – Duplicate function removal 550 – Obfuscation 275 0 Size of Javascript in KB Optimized Unoptimized 62
  • 67.
  • 68. Build great UIs for any form factor • Optimize the user experience • Make it snappy • Work without a connection
  • 69. Work Without a Connection • Run wherever, whenever – Use Application Cache to load resources locally • Access data wherever, whenever – Use Local Storage as a caching mechanism for RPCs 64
  • 70. Work Without a Connection Run wherever, whenever using Application Cache • Part of the HTML5 feature set • Loads resources like HTML, CSS, and JS from disk • Works with iPhone and Android (+ Chrome, Safari, and Firefox) 65
  • 71. Work Without a Connection Run wherever, whenever using Application Cache • appcache.nocache.manifest – Lists all of the files that you want to browser to cache • Include HTML, CSS, JS – Exclude GWT-RPC-related files (security) – "nocache" - always requested • web.xml – mime-type for manifest files (text/plain) • <your_app>.html – include <html manifest="app.nocache.manifest"> 66
  • 72. Work Without a Connection Run wherever, whenever using Application Cache ...or check out the GWT 2.4 SDK :-) 67
  • 73. Work Without a Connection Run wherever, whenever using Application Cache <!-- Define a custom App Cache linker --> <define-linker name="appcachelinker" class="com.google.gwt.sample.mobilewebapp.linker.AppCacheLinker"/> <!-- Use it --> <add-linker name="appcachelinker"/> 68
  • 74. Work Without a Connection Access data wherever, whenever using Local Storage • Part of the HTML5 feature set • Utilizes a local database for reading/writing data • Key/value-pair persistence • Works with iPhone and Android (+ Chrome, Safari, and Firefox) • Included in the GWT 2.3 SDK 69
  • 75. Work Without a Connection Access data wherever, whenever using Local Storage • Grab an instance of the Local Storage interface localStorage = Storage.getLocalStorageIfSupported(); • Read cache and then request any updates public List<Tasks> getTasks() { String taskListString = localStorage.getItem(TASKLIST_SAVE_KEY); List<Tasks> tasks = deserialize(taskListString); requestFactory.taskRequest().queryForUpdates().fire(...) { ... } return tasks; } 70
  • 76. Work Without a Connection Access data wherever, whenever using Local Storage • Upon response, update cache and any listeners public List<Tasks> getTasks() { ... requestFactory.taskRequest().queryForUpdates().fire( new Receiver<List<Tasks>>() { public onSuccess(List<Tasks> tasks) { String tasksListString = serialize(tasks); localStorage.setItem(TASKSLIST_SAVE_KEY, tasksListString); // update everyone listening for task list updates }}); ... } 71
  • 77. Summary • There are many challenges when building great mobile web apps • GWT and GPE can help • Tools for quickly building great UIs • Frameworks for optimizing the user experience • Compilers and code generators to improve speed • API support for working offline 72
  • 78. More Info... • You can download the source and tools here: – http://code.google.com/webtoolkit/download.html • Other sessions to check out – Use Page Speed to Optimize Your Web Site For Mobile (Check back for YouTube link) – Mobile Web Development: From Zero to Hero (12:30pm) – HTML5 versus Android: Apps or Web for Mobile Development? (3pm) 73

Notas do Editor

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. \n
  38. \n
  39. \n
  40. \n
  41. \n
  42. \n
  43. \n
  44. \n
  45. \n
  46. \n
  47. \n
  48. \n
  49. \n
  50. \n
  51. \n
  52. \n
  53. \n
  54. \n
  55. \n
  56. \n
  57. \n
  58. \n
  59. \n
  60. \n
  61. \n
  62. \n
  63. \n
  64. \n
  65. \n
  66. \n
  67. \n
  68. \n
  69. \n
  70. \n
  71. \n
  72. \n
  73. \n
  74. \n
  75. \n
  76. \n
  77. \n
  78. \n