SlideShare a Scribd company logo
1 of 72
Download to read offline
Cross-Platform
                            Mobile
                         Development
                        with Titanium
                           DevTeach - June 1, 2011


   Vance Lucas (@vlucas)        http://brightb.it
Tuesday, May 31, 2011
Who Am I?
                  Vance Lucas

                        http://vancelucas.com

                        @vlucas

                  Brightbit

                        http://brightb.it

                        Mobile apps, PHP, Javascript/jQuery, Rails,
                        Training, Consulting


   Vance Lucas (@vlucas)                http://brightb.it      2

Tuesday, May 31, 2011
Titanium?
                  Open-Source native application development toolkit
                  created by Appcelerator.

                  Goal: Web Technologies for Native Apps

                  Desktop (OSX / Windows / Linux)

                        HTML / CSS / JS - Webkit

                  Mobile (iOS / Android / Blackberry (beta))

                        Pure Javascript translated to native code (kinda)


   Vance Lucas (@vlucas)                http://brightb.it       3

Tuesday, May 31, 2011
The Titanium Promise
                  Fulfilling the original promise of Java

                        “Write once, run anywhere”

                        ... not “write once, suck everywhere”

                  Single codebase => multiple platforms

                  Apps must look and feel like they belong on the
                  platform and be consistent with user expectations

                  Apps need to perform like native apps


   Vance Lucas (@vlucas)                http://brightb.it       4

Tuesday, May 31, 2011
What Does It Cost?
                  NOTHING! The whole Titanium platform itself and
                  all the tools required to build an app are free and
                  open source: https://github.com/appcelerator

                  What’s the Catch?

                        Appcelerator sells support and premium modules
                        to use in your app

                        They also do custom development on their own
                        platform


   Vance Lucas (@vlucas)              http://brightb.it     5

Tuesday, May 31, 2011
How Does it Work?
                  Pre-Compiler

                        Optimize, Analyze & Find Dependencies

                  Front End Compiler

                        Native code, project, other specific compile code,
                        copy in native modules, package JS interpreter

                  Platform Compiler

                        Compile with native tools (Xcode, Android SDK)


   Vance Lucas (@vlucas)                http://brightb.it       6

Tuesday, May 31, 2011
Titanium Environment




   Vance Lucas (@vlucas)   http://brightb.it   7

Tuesday, May 31, 2011
Mobile Development
                  Pure Javascript with custom APIs

                        UI, Network, Map, Geo-location, Gestures,
                        Accelerometer, Database, Filesystem, Media, etc.

                  Javascript API calls mapped to native APIs

                  JSON-like property description




   Vance Lucas (@vlucas)               http://brightb.it       8

Tuesday, May 31, 2011
Native UI Controls
                  Controls and UI elements are native to the platform




   Vance Lucas (@vlucas)            http://brightb.it      9

Tuesday, May 31, 2011
Code Composition
                  View-based and event-driven

                        Fits Javascript perfectly

                  iOS-style layered view hierarchy

                  ~60% UI Construction

                  ~20% Event Handling

                  ~20% Business Logic



   Vance Lucas (@vlucas)                 http://brightb.it   10

Tuesday, May 31, 2011
Windows &
                   Application Flow
                           Navigating your App




   Vance Lucas (@vlucas)       http://brightb.it
Tuesday, May 31, 2011
Project Structure
                  Resources directory has
                  the “meat” of your project

                  app.js is the “bootstrap”
                  file - always the first loaded

                  Do whatever you want after that!




   Vance Lucas (@vlucas)            http://brightb.it   12

Tuesday, May 31, 2011
Platform-Specifics
                  Special iphone and android folders will be used on
                  respective platforms & moved at compile time




   Vance Lucas (@vlucas)           http://brightb.it      13

Tuesday, May 31, 2011
Screen Densities
                  iOS / iPhone (3GS vs Retina)




                  Android (Cluster*@^#)




   Vance Lucas (@vlucas)           http://brightb.it   14

Tuesday, May 31, 2011
Windows
                  Base UI structure that other views and UI widgets
                  and components are placed on

                  Controlled programmatically with a single JS file

                  JS file then creates UI components and adds them to
                  itself in layers (button here, text here, etc.)




   Vance Lucas (@vlucas)            http://brightb.it      15

Tuesday, May 31, 2011
Code Execution Context




   Vance Lucas (@vlucas)   http://brightb.it   16

Tuesday, May 31, 2011
Includes
                  Includes are the primary way to use global variables
                  across different contexts and windows

                  Configuration, database, JS framework, etc.




   Vance Lucas (@vlucas)            http://brightb.it      17

Tuesday, May 31, 2011
Tabs
                  Tab-based apps are most
                  common and the easiest to make

                  Window transitions/navigation
                  are built-in and automatic

                  One window per tab

                  Can open window within tab
                  (shows “Back” button in iOS)




   Vance Lucas (@vlucas)           http://brightb.it   18

Tuesday, May 31, 2011
Tabs Code Example




   Vance Lucas (@vlucas)   http://brightb.it   19

Tuesday, May 31, 2011
Vance Lucas (@vlucas)   http://brightb.it   20

Tuesday, May 31, 2011
Sometimes
                  have to
                  account for
                  platform
                  differences

                  iOS has
                  title with
                  tabs,
                  Android
                  does not




   Vance Lucas (@vlucas)        http://brightb.it   21

Tuesday, May 31, 2011
Custom UI
                  Much more more difficult, but very possible

                  Have to create a stack of views and keep track of
                  position (esp. previous for “back” button)

                  Have to do everything by hand

                        Listen for “back” button (Android)

                        Transition animations

                        etc...


   Vance Lucas (@vlucas)               http://brightb.it     22

Tuesday, May 31, 2011
Tweetanium Mobile




   Vance Lucas (@vlucas)   http://brightb.it   23

Tuesday, May 31, 2011
Views
                           The DIVs of Native UIs




   Vance Lucas (@vlucas)        http://brightb.it
Tuesday, May 31, 2011
View & UI Positioning
                  Views are Stackable & Nestable

                  Similar to absolute-positioned HTML/CSS elements

                  Left, top coordinate system (0,0 = top left)

                  Smart defaults:

                        Center position, 100% of parent size

                        Transparent until BG color or image specified



   Vance Lucas (@vlucas)                http://brightb.it        25

Tuesday, May 31, 2011
Vance Lucas (@vlucas)   http://brightb.it   26

Tuesday, May 31, 2011
Stacking Views




   Vance Lucas (@vlucas)   http://brightb.it   27

Tuesday, May 31, 2011
UI Controls &
                             Widgets
                        Buttons and Tables and Pickers, oh my!




   Vance Lucas (@vlucas)             http://brightb.it
Tuesday, May 31, 2011
Titanium.UI Module
                  Bridge to native UI components

                  Everything you SEE in an app

                  Animations, dialogs, buttons, images, labels, date/
                  time pickers, scroll views, search bars, sliders,
                  switches, tabs, tables, text & input fields, toolbars,
                  view, webviews, windows, and more...




   Vance Lucas (@vlucas)             http://brightb.it       29

Tuesday, May 31, 2011
Vance Lucas (@vlucas)   http://brightb.it   30

Tuesday, May 31, 2011
JSS - JS Style Sheets
                  JSON-style properties for object creation are nice, but
                  can be repetitive when used across an entire app UI

                  Separate styles from UI component code with JSS

                  Two ways to use:

                        global.jss - Applied to ALL UI components

                        <window>.jss - Overrides for <window>.js only




   Vance Lucas (@vlucas)               http://brightb.it      31

Tuesday, May 31, 2011
JSS Example
                  Assign “id” to UI
                  component and
                  reference by id

                  Reference by type

                  Window-specific
                  rules override global
                  ones




   Vance Lucas (@vlucas)              http://brightb.it   32

Tuesday, May 31, 2011
Events
                           What to do & When to do it




   Vance Lucas (@vlucas)          http://brightb.it
Tuesday, May 31, 2011
Events and Callbacks
                  “Do X when Y happens”

                  Syntax is just like native Javascript

                  UI controls have their own events you can listen to

                        click, blur, focus, change, scroll, etc.

                  Custom events supported - “app_customevent”

                        Extremely useful for triggering activity in other
                        parts of your app from anywhere else in the app


   Vance Lucas (@vlucas)                  http://brightb.it        34

Tuesday, May 31, 2011
Event Contexts




   Vance Lucas (@vlucas)   http://brightb.it   35

Tuesday, May 31, 2011
Handling Button Clicks




   Vance Lucas (@vlucas)   http://brightb.it   36

Tuesday, May 31, 2011
Ti.API
                  TI.API

                        log /info / debug / warn / error

                        addEventListener / removeEventListener

                          global context for custom events

                        fireEvent - Trigger named event from anywhere




   Vance Lucas (@vlucas)               http://brightb.it     37

Tuesday, May 31, 2011
domains/list.js
                  Table view lists domains in local database

                  Event updates active domain on table row click

                        Passes row title (domain) with e.rowData.title




   Vance Lucas (@vlucas)                http://brightb.it      38

Tuesday, May 31, 2011
app.js - Defined Event




   Vance Lucas (@vlucas)   http://brightb.it   39

Tuesday, May 31, 2011
domains/social.js
                  Event “st_social_fetchAll” fires all fetch events...




                  ...which then update individual counts via events

   Vance Lucas (@vlucas)             http://brightb.it        40

Tuesday, May 31, 2011
Many Levels Deep...




   Vance Lucas (@vlucas)      http://brightb.it   41

Tuesday, May 31, 2011
SEMTab SEO Pro




   Vance Lucas (@vlucas)    http://brightb.it   42

Tuesday, May 31, 2011
APIs
                           The Natives are Exposed




   Vance Lucas (@vlucas)         http://brightb.it
Tuesday, May 31, 2011
Hardware & Extras
                  Accelerometer, Geo-location, Locale, Gestures,
                  Filesystem, Device Orientation, Databases, Contacts,
                  Mapping, Camera & Video, Clipboard, and more...

                  Two main ways to interact:

                        Direct APIs with methods

                        Events with callbacks




   Vance Lucas (@vlucas)               http://brightb.it   44

Tuesday, May 31, 2011
Ti.Accelerometer
                  Get x, y, z coordinates of the device

                  Listen to event with callback when fired




                  Do something with new coordinates




   Vance Lucas (@vlucas)             http://brightb.it      45

Tuesday, May 31, 2011
Ti.Database
                  Direct API interface to SQLite database

                        Pre-installed on iOS & Android devices

                  Create and delete databases

                  Allows for simple query execution and resultSet
                  traversing

                        Any query or syntax supported by SQLite




   Vance Lucas (@vlucas)               http://brightb.it         46

Tuesday, May 31, 2011
Ti.Database Setup
                  Open named database

                  Create tables with standard queries




   Vance Lucas (@vlucas)            http://brightb.it   47

Tuesday, May 31, 2011
Iterate over Results
                  Create TableView and push data into rows.
                  TableView will take care of all display & formatting




   Vance Lucas (@vlucas)            http://brightb.it       48

Tuesday, May 31, 2011
Ti.Network
                  Talk to remote servers!

                        HTTPClient

                        Bonjour Service + Browser

                        TCP Sockets



                  You will most likely be using HTTPClient a lot...



   Vance Lucas (@vlucas)               http://brightb.it    49

Tuesday, May 31, 2011
Basic HTTPClient Use




   Vance Lucas (@vlucas)   http://brightb.it   50

Tuesday, May 31, 2011
Animations
                        Easier than you might think




   Vance Lucas (@vlucas)       http://brightb.it
Tuesday, May 31, 2011
3 Components
                  Transition

                        Transformation to apply

                  Duration

                        Milliseconds

                  Callback

                        What happens after animation is complete



   Vance Lucas (@vlucas)               http://brightb.it     52

Tuesday, May 31, 2011
3 Types of Animations
                  Basic

                  2D Matrix

                  3D Matrix




   Vance Lucas (@vlucas)      http://brightb.it   53

Tuesday, May 31, 2011
Basic Animation
                  Simple property changes over duration

                        Color, background, size, position, visibility, etc.




   Vance Lucas (@vlucas)                 http://brightb.it         54

Tuesday, May 31, 2011
Basic Animation
                  Changes view background from red to black to
                  orange over 2 seconds




   Vance Lucas (@vlucas)           http://brightb.it     55

Tuesday, May 31, 2011
2D Matrix
                  Rotate, scale, skew, invert




                  Oh noes! Maths!



   Vance Lucas (@vlucas)             http://brightb.it   56

Tuesday, May 31, 2011
Proportional Rotation:




                  In radians




   Vance Lucas (@vlucas)            http://brightb.it   57

Tuesday, May 31, 2011
3D Matrix
                  Rotate, scale, skew, invert, flip - in 3D space




   Vance Lucas (@vlucas)             http://brightb.it       58

Tuesday, May 31, 2011
3D Transformations
                  Combine matrices to achieve transformations



                  Scaling                   Distance



                  Rotation




   Vance Lucas (@vlucas)           http://brightb.it     59

Tuesday, May 31, 2011
Vance Lucas (@vlucas)   http://brightb.it   60

Tuesday, May 31, 2011
2D Matrix
                  Luckily, Titanium has useful helpers...

                        scale, rotate, invert, multiply, translate

                        Automatic degree to radian conversion




   Vance Lucas (@vlucas)                 http://brightb.it           61

Tuesday, May 31, 2011
3D Matrix
                  3D Matrices also have helpers...




   Vance Lucas (@vlucas)            http://brightb.it   62

Tuesday, May 31, 2011
No Math Required!
                  Still should read up on Matrices and how they apply
                  to 3D transformations and game design

                        Will pay dividends in understanding how matrix
                        transformations work and why

                        Helps to know what operation to perform to get
                        the desired result

                          What will inverting do? multiplying?

                  There is always the “trial & error” method too...

   Vance Lucas (@vlucas)               http://brightb.it      63

Tuesday, May 31, 2011
Modules
                            Native Add-Ons




   Vance Lucas (@vlucas)     http://brightb.it
Tuesday, May 31, 2011
Custom Modules
                  Create custom modules with native code that maps
                  to Javascript APIs in Titanium

                        Android - Java

                        iOS - Obj-C

                        BlackBerry - Java




   Vance Lucas (@vlucas)                 http://brightb.it   65

Tuesday, May 31, 2011
Titanium+Plus Modules




   Vance Lucas (@vlucas)   http://brightb.it   66

Tuesday, May 31, 2011
Drawbacks
                           Watch that First Step...




   Vance Lucas (@vlucas)        http://brightb.it
Tuesday, May 31, 2011
Testing	
                  A lot of testing is “trial and error” style

                  Some UI components and options are iOS-only, and
                  cause crashes in Android

                  No warning during compile cycle for using
                  incompatible components

                        Appcelerator has said improvements are coming




   Vance Lucas (@vlucas)              http://brightb.it         68

Tuesday, May 31, 2011
Debugging
                  Debug stack traces from published app crashes are
                  USELESS, because you didn’t write the code

                  The most you can do is get support from
                  Appcelerator by sending in or posting your stack
                  traces




   Vance Lucas (@vlucas)           http://brightb.it       69

Tuesday, May 31, 2011
Sources
                           Open and Available for Use




   Vance Lucas (@vlucas)          http://brightb.it
Tuesday, May 31, 2011
Sources
                  Platform: http://appcelerator.com


                  Animation Guide: http://wiki.appcelerator.org/display/guides/Animations+in+Action


                  API Docs: http://developer.appcelerator.com/apidoc/mobile/latest/Titanium.UI.3DMatrix-object


                  Animation Images: http://www.eleqtriq.com/2010/05/css-3d-matrix-transformations/


                  Matrix Images: http://en.wikipedia.org/wiki/Matrix_(mathematics)


                  Matrix Math: http://gpwiki.org/index.php/Matrix_math




   Vance Lucas (@vlucas)                              http://brightb.it                        71

Tuesday, May 31, 2011
hello@brightb.it    (405) 595-0101


                        http://brightb.it   Oklahoma City




Tuesday, May 31, 2011

More Related Content

Similar to Cross-Platform Mobile Development with Titanium

Extreme Testing with Selenium - @hugs at Jenkins User Conference 2011
Extreme Testing with Selenium - @hugs at Jenkins User Conference 2011Extreme Testing with Selenium - @hugs at Jenkins User Conference 2011
Extreme Testing with Selenium - @hugs at Jenkins User Conference 2011hugs
 
XML Prague 2005 EXSLT
XML Prague 2005 EXSLTXML Prague 2005 EXSLT
XML Prague 2005 EXSLTjimfuller2009
 
sqlmap - security development in Python
sqlmap - security development in Pythonsqlmap - security development in Python
sqlmap - security development in PythonMiroslav Stampar
 
Interactive notebooks
Interactive notebooksInteractive notebooks
Interactive notebooksAndy Petrella
 
Building a Real-World Application with Adobe Flex 2
Building a Real-World Application with Adobe Flex 2Building a Real-World Application with Adobe Flex 2
Building a Real-World Application with Adobe Flex 2dcoletta
 
Web 2.0 and Rich Internet Applications
Web 2.0 and Rich Internet ApplicationsWeb 2.0 and Rich Internet Applications
Web 2.0 and Rich Internet ApplicationsSaurabh Narula
 
Java [modo de compatibilidad]
Java [modo de compatibilidad]Java [modo de compatibilidad]
Java [modo de compatibilidad]gilber255
 
Distributing user interfaces. 4th Distributed User Interfaces Workshop on 14t...
Distributing user interfaces. 4th Distributed User Interfaces Workshop on 14t...Distributing user interfaces. 4th Distributed User Interfaces Workshop on 14t...
Distributing user interfaces. 4th Distributed User Interfaces Workshop on 14t...Ricardo Tesoriero
 
Brief introduction Fluent UI Microsoft Design System
Brief introduction Fluent UI Microsoft Design SystemBrief introduction Fluent UI Microsoft Design System
Brief introduction Fluent UI Microsoft Design SystemDomenico Monaco
 
A Toolkit for Peer-to-Peer Distributed User Interfaces: Concepts, Implementat...
A Toolkit for Peer-to-Peer Distributed User Interfaces: Concepts, Implementat...A Toolkit for Peer-to-Peer Distributed User Interfaces: Concepts, Implementat...
A Toolkit for Peer-to-Peer Distributed User Interfaces: Concepts, Implementat...Jean Vanderdonckt
 
Podcasts, Media Sharing & RSS: Rich Media for the Masses
Podcasts, Media Sharing & RSS: Rich Media for the MassesPodcasts, Media Sharing & RSS: Rich Media for the Masses
Podcasts, Media Sharing & RSS: Rich Media for the MassesAllan Barclay
 
SkinMuseum: a museum collection management software
SkinMuseum: a museum collection management softwareSkinMuseum: a museum collection management software
SkinMuseum: a museum collection management softwareNuxeo
 

Similar to Cross-Platform Mobile Development with Titanium (20)

Extreme Testing with Selenium - @hugs at Jenkins User Conference 2011
Extreme Testing with Selenium - @hugs at Jenkins User Conference 2011Extreme Testing with Selenium - @hugs at Jenkins User Conference 2011
Extreme Testing with Selenium - @hugs at Jenkins User Conference 2011
 
Git
GitGit
Git
 
XML Prague 2005 EXSLT
XML Prague 2005 EXSLTXML Prague 2005 EXSLT
XML Prague 2005 EXSLT
 
sqlmap - security development in Python
sqlmap - security development in Pythonsqlmap - security development in Python
sqlmap - security development in Python
 
Anarchist guide to titanium ui
Anarchist guide to titanium uiAnarchist guide to titanium ui
Anarchist guide to titanium ui
 
Interactive notebooks
Interactive notebooksInteractive notebooks
Interactive notebooks
 
48 enhancing orcafordocumentnavigation
48 enhancing orcafordocumentnavigation48 enhancing orcafordocumentnavigation
48 enhancing orcafordocumentnavigation
 
Building a Real-World Application with Adobe Flex 2
Building a Real-World Application with Adobe Flex 2Building a Real-World Application with Adobe Flex 2
Building a Real-World Application with Adobe Flex 2
 
Web 2.0 and Rich Internet Applications
Web 2.0 and Rich Internet ApplicationsWeb 2.0 and Rich Internet Applications
Web 2.0 and Rich Internet Applications
 
Java [modo de compatibilidad]
Java [modo de compatibilidad]Java [modo de compatibilidad]
Java [modo de compatibilidad]
 
Java
JavaJava
Java
 
Distributing user interfaces. 4th Distributed User Interfaces Workshop on 14t...
Distributing user interfaces. 4th Distributed User Interfaces Workshop on 14t...Distributing user interfaces. 4th Distributed User Interfaces Workshop on 14t...
Distributing user interfaces. 4th Distributed User Interfaces Workshop on 14t...
 
Brief introduction Fluent UI Microsoft Design System
Brief introduction Fluent UI Microsoft Design SystemBrief introduction Fluent UI Microsoft Design System
Brief introduction Fluent UI Microsoft Design System
 
A Toolkit for Peer-to-Peer Distributed User Interfaces: Concepts, Implementat...
A Toolkit for Peer-to-Peer Distributed User Interfaces: Concepts, Implementat...A Toolkit for Peer-to-Peer Distributed User Interfaces: Concepts, Implementat...
A Toolkit for Peer-to-Peer Distributed User Interfaces: Concepts, Implementat...
 
Ch1-Unix.pptx
Ch1-Unix.pptxCh1-Unix.pptx
Ch1-Unix.pptx
 
Podcasts, Media Sharing & RSS: Rich Media for the Masses
Podcasts, Media Sharing & RSS: Rich Media for the MassesPodcasts, Media Sharing & RSS: Rich Media for the Masses
Podcasts, Media Sharing & RSS: Rich Media for the Masses
 
2011 institute jan_tech
2011 institute jan_tech2011 institute jan_tech
2011 institute jan_tech
 
2011 institute jan_tech
2011 institute jan_tech2011 institute jan_tech
2011 institute jan_tech
 
SkinMuseum: a museum collection management software
SkinMuseum: a museum collection management softwareSkinMuseum: a museum collection management software
SkinMuseum: a museum collection management software
 
Sharing knowledge 2011
Sharing knowledge 2011Sharing knowledge 2011
Sharing knowledge 2011
 

More from Vance Lucas

How to Evaluate Your App Idea
How to Evaluate Your App IdeaHow to Evaluate Your App Idea
How to Evaluate Your App IdeaVance Lucas
 
How to Build a Tech Community
How to Build a Tech CommunityHow to Build a Tech Community
How to Build a Tech CommunityVance Lucas
 
Bullet: The Functional PHP Micro-Framework
Bullet: The Functional PHP Micro-FrameworkBullet: The Functional PHP Micro-Framework
Bullet: The Functional PHP Micro-FrameworkVance Lucas
 
Stackbox CMS: Next-Generation Content Management
Stackbox CMS: Next-Generation Content ManagementStackbox CMS: Next-Generation Content Management
Stackbox CMS: Next-Generation Content ManagementVance Lucas
 
Object Oriented Apologetics
Object Oriented ApologeticsObject Oriented Apologetics
Object Oriented ApologeticsVance Lucas
 
PHP - Procedural To Object-Oriented
PHP - Procedural To Object-OrientedPHP - Procedural To Object-Oriented
PHP - Procedural To Object-OrientedVance Lucas
 
Building Data Mapper PHP5
Building Data Mapper PHP5Building Data Mapper PHP5
Building Data Mapper PHP5Vance Lucas
 

More from Vance Lucas (7)

How to Evaluate Your App Idea
How to Evaluate Your App IdeaHow to Evaluate Your App Idea
How to Evaluate Your App Idea
 
How to Build a Tech Community
How to Build a Tech CommunityHow to Build a Tech Community
How to Build a Tech Community
 
Bullet: The Functional PHP Micro-Framework
Bullet: The Functional PHP Micro-FrameworkBullet: The Functional PHP Micro-Framework
Bullet: The Functional PHP Micro-Framework
 
Stackbox CMS: Next-Generation Content Management
Stackbox CMS: Next-Generation Content ManagementStackbox CMS: Next-Generation Content Management
Stackbox CMS: Next-Generation Content Management
 
Object Oriented Apologetics
Object Oriented ApologeticsObject Oriented Apologetics
Object Oriented Apologetics
 
PHP - Procedural To Object-Oriented
PHP - Procedural To Object-OrientedPHP - Procedural To Object-Oriented
PHP - Procedural To Object-Oriented
 
Building Data Mapper PHP5
Building Data Mapper PHP5Building Data Mapper PHP5
Building Data Mapper PHP5
 

Recently uploaded

Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 

Recently uploaded (20)

Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 

Cross-Platform Mobile Development with Titanium

  • 1. Cross-Platform Mobile Development with Titanium DevTeach - June 1, 2011 Vance Lucas (@vlucas) http://brightb.it Tuesday, May 31, 2011
  • 2. Who Am I? Vance Lucas http://vancelucas.com @vlucas Brightbit http://brightb.it Mobile apps, PHP, Javascript/jQuery, Rails, Training, Consulting Vance Lucas (@vlucas) http://brightb.it 2 Tuesday, May 31, 2011
  • 3. Titanium? Open-Source native application development toolkit created by Appcelerator. Goal: Web Technologies for Native Apps Desktop (OSX / Windows / Linux) HTML / CSS / JS - Webkit Mobile (iOS / Android / Blackberry (beta)) Pure Javascript translated to native code (kinda) Vance Lucas (@vlucas) http://brightb.it 3 Tuesday, May 31, 2011
  • 4. The Titanium Promise Fulfilling the original promise of Java “Write once, run anywhere” ... not “write once, suck everywhere” Single codebase => multiple platforms Apps must look and feel like they belong on the platform and be consistent with user expectations Apps need to perform like native apps Vance Lucas (@vlucas) http://brightb.it 4 Tuesday, May 31, 2011
  • 5. What Does It Cost? NOTHING! The whole Titanium platform itself and all the tools required to build an app are free and open source: https://github.com/appcelerator What’s the Catch? Appcelerator sells support and premium modules to use in your app They also do custom development on their own platform Vance Lucas (@vlucas) http://brightb.it 5 Tuesday, May 31, 2011
  • 6. How Does it Work? Pre-Compiler Optimize, Analyze & Find Dependencies Front End Compiler Native code, project, other specific compile code, copy in native modules, package JS interpreter Platform Compiler Compile with native tools (Xcode, Android SDK) Vance Lucas (@vlucas) http://brightb.it 6 Tuesday, May 31, 2011
  • 7. Titanium Environment Vance Lucas (@vlucas) http://brightb.it 7 Tuesday, May 31, 2011
  • 8. Mobile Development Pure Javascript with custom APIs UI, Network, Map, Geo-location, Gestures, Accelerometer, Database, Filesystem, Media, etc. Javascript API calls mapped to native APIs JSON-like property description Vance Lucas (@vlucas) http://brightb.it 8 Tuesday, May 31, 2011
  • 9. Native UI Controls Controls and UI elements are native to the platform Vance Lucas (@vlucas) http://brightb.it 9 Tuesday, May 31, 2011
  • 10. Code Composition View-based and event-driven Fits Javascript perfectly iOS-style layered view hierarchy ~60% UI Construction ~20% Event Handling ~20% Business Logic Vance Lucas (@vlucas) http://brightb.it 10 Tuesday, May 31, 2011
  • 11. Windows & Application Flow Navigating your App Vance Lucas (@vlucas) http://brightb.it Tuesday, May 31, 2011
  • 12. Project Structure Resources directory has the “meat” of your project app.js is the “bootstrap” file - always the first loaded Do whatever you want after that! Vance Lucas (@vlucas) http://brightb.it 12 Tuesday, May 31, 2011
  • 13. Platform-Specifics Special iphone and android folders will be used on respective platforms & moved at compile time Vance Lucas (@vlucas) http://brightb.it 13 Tuesday, May 31, 2011
  • 14. Screen Densities iOS / iPhone (3GS vs Retina) Android (Cluster*@^#) Vance Lucas (@vlucas) http://brightb.it 14 Tuesday, May 31, 2011
  • 15. Windows Base UI structure that other views and UI widgets and components are placed on Controlled programmatically with a single JS file JS file then creates UI components and adds them to itself in layers (button here, text here, etc.) Vance Lucas (@vlucas) http://brightb.it 15 Tuesday, May 31, 2011
  • 16. Code Execution Context Vance Lucas (@vlucas) http://brightb.it 16 Tuesday, May 31, 2011
  • 17. Includes Includes are the primary way to use global variables across different contexts and windows Configuration, database, JS framework, etc. Vance Lucas (@vlucas) http://brightb.it 17 Tuesday, May 31, 2011
  • 18. Tabs Tab-based apps are most common and the easiest to make Window transitions/navigation are built-in and automatic One window per tab Can open window within tab (shows “Back” button in iOS) Vance Lucas (@vlucas) http://brightb.it 18 Tuesday, May 31, 2011
  • 19. Tabs Code Example Vance Lucas (@vlucas) http://brightb.it 19 Tuesday, May 31, 2011
  • 20. Vance Lucas (@vlucas) http://brightb.it 20 Tuesday, May 31, 2011
  • 21. Sometimes have to account for platform differences iOS has title with tabs, Android does not Vance Lucas (@vlucas) http://brightb.it 21 Tuesday, May 31, 2011
  • 22. Custom UI Much more more difficult, but very possible Have to create a stack of views and keep track of position (esp. previous for “back” button) Have to do everything by hand Listen for “back” button (Android) Transition animations etc... Vance Lucas (@vlucas) http://brightb.it 22 Tuesday, May 31, 2011
  • 23. Tweetanium Mobile Vance Lucas (@vlucas) http://brightb.it 23 Tuesday, May 31, 2011
  • 24. Views The DIVs of Native UIs Vance Lucas (@vlucas) http://brightb.it Tuesday, May 31, 2011
  • 25. View & UI Positioning Views are Stackable & Nestable Similar to absolute-positioned HTML/CSS elements Left, top coordinate system (0,0 = top left) Smart defaults: Center position, 100% of parent size Transparent until BG color or image specified Vance Lucas (@vlucas) http://brightb.it 25 Tuesday, May 31, 2011
  • 26. Vance Lucas (@vlucas) http://brightb.it 26 Tuesday, May 31, 2011
  • 27. Stacking Views Vance Lucas (@vlucas) http://brightb.it 27 Tuesday, May 31, 2011
  • 28. UI Controls & Widgets Buttons and Tables and Pickers, oh my! Vance Lucas (@vlucas) http://brightb.it Tuesday, May 31, 2011
  • 29. Titanium.UI Module Bridge to native UI components Everything you SEE in an app Animations, dialogs, buttons, images, labels, date/ time pickers, scroll views, search bars, sliders, switches, tabs, tables, text & input fields, toolbars, view, webviews, windows, and more... Vance Lucas (@vlucas) http://brightb.it 29 Tuesday, May 31, 2011
  • 30. Vance Lucas (@vlucas) http://brightb.it 30 Tuesday, May 31, 2011
  • 31. JSS - JS Style Sheets JSON-style properties for object creation are nice, but can be repetitive when used across an entire app UI Separate styles from UI component code with JSS Two ways to use: global.jss - Applied to ALL UI components <window>.jss - Overrides for <window>.js only Vance Lucas (@vlucas) http://brightb.it 31 Tuesday, May 31, 2011
  • 32. JSS Example Assign “id” to UI component and reference by id Reference by type Window-specific rules override global ones Vance Lucas (@vlucas) http://brightb.it 32 Tuesday, May 31, 2011
  • 33. Events What to do & When to do it Vance Lucas (@vlucas) http://brightb.it Tuesday, May 31, 2011
  • 34. Events and Callbacks “Do X when Y happens” Syntax is just like native Javascript UI controls have their own events you can listen to click, blur, focus, change, scroll, etc. Custom events supported - “app_customevent” Extremely useful for triggering activity in other parts of your app from anywhere else in the app Vance Lucas (@vlucas) http://brightb.it 34 Tuesday, May 31, 2011
  • 35. Event Contexts Vance Lucas (@vlucas) http://brightb.it 35 Tuesday, May 31, 2011
  • 36. Handling Button Clicks Vance Lucas (@vlucas) http://brightb.it 36 Tuesday, May 31, 2011
  • 37. Ti.API TI.API log /info / debug / warn / error addEventListener / removeEventListener global context for custom events fireEvent - Trigger named event from anywhere Vance Lucas (@vlucas) http://brightb.it 37 Tuesday, May 31, 2011
  • 38. domains/list.js Table view lists domains in local database Event updates active domain on table row click Passes row title (domain) with e.rowData.title Vance Lucas (@vlucas) http://brightb.it 38 Tuesday, May 31, 2011
  • 39. app.js - Defined Event Vance Lucas (@vlucas) http://brightb.it 39 Tuesday, May 31, 2011
  • 40. domains/social.js Event “st_social_fetchAll” fires all fetch events... ...which then update individual counts via events Vance Lucas (@vlucas) http://brightb.it 40 Tuesday, May 31, 2011
  • 41. Many Levels Deep... Vance Lucas (@vlucas) http://brightb.it 41 Tuesday, May 31, 2011
  • 42. SEMTab SEO Pro Vance Lucas (@vlucas) http://brightb.it 42 Tuesday, May 31, 2011
  • 43. APIs The Natives are Exposed Vance Lucas (@vlucas) http://brightb.it Tuesday, May 31, 2011
  • 44. Hardware & Extras Accelerometer, Geo-location, Locale, Gestures, Filesystem, Device Orientation, Databases, Contacts, Mapping, Camera & Video, Clipboard, and more... Two main ways to interact: Direct APIs with methods Events with callbacks Vance Lucas (@vlucas) http://brightb.it 44 Tuesday, May 31, 2011
  • 45. Ti.Accelerometer Get x, y, z coordinates of the device Listen to event with callback when fired Do something with new coordinates Vance Lucas (@vlucas) http://brightb.it 45 Tuesday, May 31, 2011
  • 46. Ti.Database Direct API interface to SQLite database Pre-installed on iOS & Android devices Create and delete databases Allows for simple query execution and resultSet traversing Any query or syntax supported by SQLite Vance Lucas (@vlucas) http://brightb.it 46 Tuesday, May 31, 2011
  • 47. Ti.Database Setup Open named database Create tables with standard queries Vance Lucas (@vlucas) http://brightb.it 47 Tuesday, May 31, 2011
  • 48. Iterate over Results Create TableView and push data into rows. TableView will take care of all display & formatting Vance Lucas (@vlucas) http://brightb.it 48 Tuesday, May 31, 2011
  • 49. Ti.Network Talk to remote servers! HTTPClient Bonjour Service + Browser TCP Sockets You will most likely be using HTTPClient a lot... Vance Lucas (@vlucas) http://brightb.it 49 Tuesday, May 31, 2011
  • 50. Basic HTTPClient Use Vance Lucas (@vlucas) http://brightb.it 50 Tuesday, May 31, 2011
  • 51. Animations Easier than you might think Vance Lucas (@vlucas) http://brightb.it Tuesday, May 31, 2011
  • 52. 3 Components Transition Transformation to apply Duration Milliseconds Callback What happens after animation is complete Vance Lucas (@vlucas) http://brightb.it 52 Tuesday, May 31, 2011
  • 53. 3 Types of Animations Basic 2D Matrix 3D Matrix Vance Lucas (@vlucas) http://brightb.it 53 Tuesday, May 31, 2011
  • 54. Basic Animation Simple property changes over duration Color, background, size, position, visibility, etc. Vance Lucas (@vlucas) http://brightb.it 54 Tuesday, May 31, 2011
  • 55. Basic Animation Changes view background from red to black to orange over 2 seconds Vance Lucas (@vlucas) http://brightb.it 55 Tuesday, May 31, 2011
  • 56. 2D Matrix Rotate, scale, skew, invert Oh noes! Maths! Vance Lucas (@vlucas) http://brightb.it 56 Tuesday, May 31, 2011
  • 57. Proportional Rotation: In radians Vance Lucas (@vlucas) http://brightb.it 57 Tuesday, May 31, 2011
  • 58. 3D Matrix Rotate, scale, skew, invert, flip - in 3D space Vance Lucas (@vlucas) http://brightb.it 58 Tuesday, May 31, 2011
  • 59. 3D Transformations Combine matrices to achieve transformations Scaling Distance Rotation Vance Lucas (@vlucas) http://brightb.it 59 Tuesday, May 31, 2011
  • 60. Vance Lucas (@vlucas) http://brightb.it 60 Tuesday, May 31, 2011
  • 61. 2D Matrix Luckily, Titanium has useful helpers... scale, rotate, invert, multiply, translate Automatic degree to radian conversion Vance Lucas (@vlucas) http://brightb.it 61 Tuesday, May 31, 2011
  • 62. 3D Matrix 3D Matrices also have helpers... Vance Lucas (@vlucas) http://brightb.it 62 Tuesday, May 31, 2011
  • 63. No Math Required! Still should read up on Matrices and how they apply to 3D transformations and game design Will pay dividends in understanding how matrix transformations work and why Helps to know what operation to perform to get the desired result What will inverting do? multiplying? There is always the “trial & error” method too... Vance Lucas (@vlucas) http://brightb.it 63 Tuesday, May 31, 2011
  • 64. Modules Native Add-Ons Vance Lucas (@vlucas) http://brightb.it Tuesday, May 31, 2011
  • 65. Custom Modules Create custom modules with native code that maps to Javascript APIs in Titanium Android - Java iOS - Obj-C BlackBerry - Java Vance Lucas (@vlucas) http://brightb.it 65 Tuesday, May 31, 2011
  • 66. Titanium+Plus Modules Vance Lucas (@vlucas) http://brightb.it 66 Tuesday, May 31, 2011
  • 67. Drawbacks Watch that First Step... Vance Lucas (@vlucas) http://brightb.it Tuesday, May 31, 2011
  • 68. Testing A lot of testing is “trial and error” style Some UI components and options are iOS-only, and cause crashes in Android No warning during compile cycle for using incompatible components Appcelerator has said improvements are coming Vance Lucas (@vlucas) http://brightb.it 68 Tuesday, May 31, 2011
  • 69. Debugging Debug stack traces from published app crashes are USELESS, because you didn’t write the code The most you can do is get support from Appcelerator by sending in or posting your stack traces Vance Lucas (@vlucas) http://brightb.it 69 Tuesday, May 31, 2011
  • 70. Sources Open and Available for Use Vance Lucas (@vlucas) http://brightb.it Tuesday, May 31, 2011
  • 71. Sources Platform: http://appcelerator.com Animation Guide: http://wiki.appcelerator.org/display/guides/Animations+in+Action API Docs: http://developer.appcelerator.com/apidoc/mobile/latest/Titanium.UI.3DMatrix-object Animation Images: http://www.eleqtriq.com/2010/05/css-3d-matrix-transformations/ Matrix Images: http://en.wikipedia.org/wiki/Matrix_(mathematics) Matrix Math: http://gpwiki.org/index.php/Matrix_math Vance Lucas (@vlucas) http://brightb.it 71 Tuesday, May 31, 2011
  • 72. hello@brightb.it (405) 595-0101 http://brightb.it Oklahoma City Tuesday, May 31, 2011