Øredev2013 - FirefoxOS - the platform HTML5 deserves

61
FIREFOX OS The platform HTML5 deserves Christian Heilmann (@codepo8) Øredev, Malmø, 7/11/13
  • date post

    12-Sep-2014
  • Category

    Education

  • view

    4.999
  • download

    1

description

Screencast on YouTube: https://www.youtube.com/watch?v=GJ_5JKG4nFI Firefox OS is a new operating system aimed at emerging markets to replace feature phones with HTML5 based Smartphones whilst still being affordable. In this talk you'll see its architecture, how to take part in it and what it means to the evolution of HTML5 as a platform. A lot of promises have been made, here you can see HTML5 working without having to jump through hoops and abstractions.

Transcript of Øredev2013 - FirefoxOS - the platform HTML5 deserves

Page 1: Øredev2013 - FirefoxOS - the platform HTML5 deserves

FIREFOX OSThe platform HTML5 deserves

Christian Heilmann (@codepo8) Øredev, Malmø, 7/11/13

Page 2: Øredev2013 - FirefoxOS - the platform HTML5 deserves

BENEFITS OF HTML5

★ In-built distribution - the web

★ Simple technologies used by lots of developers

★ Evolution of existing practices

★ Open, independent, standardised

Page 3: Øredev2013 - FirefoxOS - the platform HTML5 deserves

PROMISES OF HTML5

Page 4: Øredev2013 - FirefoxOS - the platform HTML5 deserves

LOCKOUT

Page 5: Øredev2013 - FirefoxOS - the platform HTML5 deserves

FIREFOX OS

Page 6: Øredev2013 - FirefoxOS - the platform HTML5 deserves

SOME FACTS…★ Released in eight countries: Spain, Poland, Venezuela,

Colombia, Peru, Uruguay, Mexico, Brasil (more soon)

★ 18 mobile operator partners, 6 hardware partners

★ Hardware options: Alcatel One Touch Fire, ZTE Open, Geeksphone Keon, Geeksphone Peak, LG Fireweb…

★ Aimed at emerging markets/low end market

★ Aimed to be an alternative to feature phones and unavailable closed environments.

★ Open source - it is all on GitHub

Page 8: Øredev2013 - FirefoxOS - the platform HTML5 deserves

ARCHITECTURE

Linux/Gonk (ADB enabled)

Gecko rendering engine

Third Party HTML5 Apps

Web APIs / Web Actitivies

GAIA

Page 9: Øredev2013 - FirefoxOS - the platform HTML5 deserves

- + =

Page 10: Øredev2013 - FirefoxOS - the platform HTML5 deserves

PREDICTABLE HTML5 SUPPORT

Page 11: Øredev2013 - FirefoxOS - the platform HTML5 deserves

SECURITY

Page 12: Øredev2013 - FirefoxOS - the platform HTML5 deserves

AVOIDING USER OVERLOAD…

http://smus.com/installable-webapps/

Page 13: Øredev2013 - FirefoxOS - the platform HTML5 deserves

APPLICATION MANIFEST{ "version": "1.0", "name": "MozillaBall", "description": "Exciting Open Web development action!", "icons": { "16": "/img/icon-16.png", "48": "/img/icon-48.png", "128": "/img/icon-128.png" }, "developer": { "name": "Mozilla Labs", "url": "http://mozillalabs.com" }, "installs_allowed_from": ["*"], "appcache_path": "/cache.manifest", "locales": { "es": { "description": "¡Acción abierta emocionante del desarrollo del Web!", "developer": { "url": "http://es.mozillalabs.com/" } } }, "default_locale": "en" }

Page 14: Øredev2013 - FirefoxOS - the platform HTML5 deserves

Privileged Web App

More access, more responsibility

Web Content

Regular web content

APPLICATIONS

Installed Web App

A regular web app

Certified Web App

Device-critical applications

Page 16: Øredev2013 - FirefoxOS - the platform HTML5 deserves

PERMISSIONS

"permissions": { "contacts": { "description": "Required for autocompletion in the share screen", "access": "readcreate" }, "alarms": { "description": "Required to schedule notifications" } }

Page 17: Øredev2013 - FirefoxOS - the platform HTML5 deserves

WEB APIS

Page 18: Øredev2013 - FirefoxOS - the platform HTML5 deserves

WEB APIS (FOR ALL)

Vibration API (W3C)

Screen Orientation

Geolocation API

Mouse Lock API (W3C)

Open WebApps

Network Information API (W3C)

Battery Status API (W3C)

Alarm API

Web Activities

Push Notifications API

WebFM API

WebPayment

IndexedDB (W3C)

Ambient light sensor

Proximity sensor

Notification

Page 19: Øredev2013 - FirefoxOS - the platform HTML5 deserves

BATTERY STATUS API

Page 20: Øredev2013 - FirefoxOS - the platform HTML5 deserves

BATTERY STATUS API

var battery = navigator.battery; if (battery) { var batteryLevel = Math.round(battery.level * 100) + "%", charging = (battery.charging)? "" : "not ", chargingTime = parseInt(battery.chargingTime / 60, 10), dischargingTime = parseInt(battery.dischargingTime / 60, 10); // Set events battery.addEventListener("levelchange", setStatus, false); battery.addEventListener("chargingchange", setStatus, false); battery.addEventListener("chargingtimechange", setStatus, false); battery.addEventListener("dischargingtimechange", setStatus, false); }

Page 21: Øredev2013 - FirefoxOS - the platform HTML5 deserves

SCREEN ORIENTATION API

Page 22: Øredev2013 - FirefoxOS - the platform HTML5 deserves

SCREEN ORIENTATION API

// Portrait mode: screen.mozLockOrientation("portrait"); /* Possible values: "landscape" "portrait" "landscape-primary" "landscape-secondary" "portrait-primary" "portrait-secondary" */

Page 23: Øredev2013 - FirefoxOS - the platform HTML5 deserves

VIBRATION API

Page 24: Øredev2013 - FirefoxOS - the platform HTML5 deserves

VIBRATION API

// Vibrate for one second navigator.vibrate(1000); // Vibration pattern [vibrationTime, pause,…] navigator.vibrate([200, 100, 200, 100]); // Vibrate for 5 seconds navigator.vibrate(5000); // Turn off vibration navigator.vibrate(0);

Page 25: Øredev2013 - FirefoxOS - the platform HTML5 deserves

NETWORK INFORMATION API

Page 26: Øredev2013 - FirefoxOS - the platform HTML5 deserves

NETWORK INFORMATION API

var connection = window.navigator.mozConnection, online = connection.bandwidth > 0, metered = connection.metered;

Page 27: Øredev2013 - FirefoxOS - the platform HTML5 deserves

☼ AMBIENT LIGHT EVENTS

Page 28: Øredev2013 - FirefoxOS - the platform HTML5 deserves

AMBIENT LIGHT EVENTS

window.addEventListener("devicelight", function (event) { // The level of the ambient light in lux // The lux values for "dim" typically begin below 50, // and the values for "bright" begin above 10000 console.log(event.value); });

Page 29: Øredev2013 - FirefoxOS - the platform HTML5 deserves

PAGE VISIBILITY

Page 30: Øredev2013 - FirefoxOS - the platform HTML5 deserves

PAGE VISIBILITY

document.addEventListener("visibilitychange", function () { if (document.hidden) { console.log("App is hidden"); } else { console.log("App has focus"); } });

Page 31: Øredev2013 - FirefoxOS - the platform HTML5 deserves

WEB APIS (PRIVILEGED APPS)

Device Storage API

Browser API

TCP Socket API

Contacts API

systemXHR

Page 32: Øredev2013 - FirefoxOS - the platform HTML5 deserves

CONTACTS API

Page 33: Øredev2013 - FirefoxOS - the platform HTML5 deserves

CONTACTS API

var contact = new mozContact(); contact.init({name: "Tom"}); var request = navigator.mozContacts.save(contact); request.onsuccess = function() { console.log("Success"); }; request.onerror = function() { console.log("Error") };

Page 34: Øredev2013 - FirefoxOS - the platform HTML5 deserves

!

WebTelephony

WebSMS

Idle API

Settings API

Power Management API

Mobile Connection API

WiFi Information API

WEB APIS (CERTIFIED APPS)!

WebBluetooth

Permissions API

Network Stats API

Camera API

Time/Clock API

Attention screen

Voicemail

Page 35: Øredev2013 - FirefoxOS - the platform HTML5 deserves

CERTIFIED APPS = THE OS :)

Page 36: Øredev2013 - FirefoxOS - the platform HTML5 deserves

CERTIFIED APPS = THE OS :)Dialer !Contacts !Settings !SMS !Web browser !Gallery !Video Player !Music Player !E-mail (POP, IMAP) !Calendar

Alarm Clock !Camera !Notes !First Run Experience !Notifications !Home Screen !Mozilla Marketplace !System Updater !Localization Support

Page 37: Øredev2013 - FirefoxOS - the platform HTML5 deserves

WEB ACTIVITIES

Page 38: Øredev2013 - FirefoxOS - the platform HTML5 deserves
Page 39: Øredev2013 - FirefoxOS - the platform HTML5 deserves

GET A PHOTO?

var getphoto = new MozActivity({ name: "pick", data: { type: ["image/png", "image/jpeg"], "image/jpg"] } }); !getphoto.onsuccess = function () { var img = document.createElement("img"); if (this.result.blob.type.indexOf("image") != -1) { img.src = window.URL.createObjectURL(this.result.blob); }};getphoto.onerror = function () { // error};

Page 40: Øredev2013 - FirefoxOS - the platform HTML5 deserves

FIREFOX OS + ANDROID!

Page 41: Øredev2013 - FirefoxOS - the platform HTML5 deserves

APP DISTRIBUTION

Page 42: Øredev2013 - FirefoxOS - the platform HTML5 deserves

FIREFOX OS MARKETPLACE

https://marketplace.firefox.com/

Page 43: Øredev2013 - FirefoxOS - the platform HTML5 deserves

INSTALL FROM THE WEB…

Page 44: Øredev2013 - FirefoxOS - the platform HTML5 deserves

DYNAMIC APP WEB SEARCH

Page 45: Øredev2013 - FirefoxOS - the platform HTML5 deserves

DEVELOPMENT ENVIRONMENT

Page 46: Øredev2013 - FirefoxOS - the platform HTML5 deserves

DEVELOPER ENVIRONMENT

Page 47: Øredev2013 - FirefoxOS - the platform HTML5 deserves

FIREFOX OS BOILERPLATE APP

https://github.com/robnyman/Firefox-OS-Boilerplate-App

Page 48: Øredev2013 - FirefoxOS - the platform HTML5 deserves

PROTOTYPING WITH JSFIDDLE

https://hacks.mozilla.org/2013/08/using-jsfiddle-to-prototype-firefox-os-apps/

1. Write your code as a JSFiddle

2. Append /webapp.manifest to your Fiddle URL and paste this link into the Firefox OS simulator to install the app

3. Alternatively, append /fxos.html to your Fiddle URL to get an install page like a typical Firefox OS hosted application

Page 49: Øredev2013 - FirefoxOS - the platform HTML5 deserves

BUILDING BLOCKS?

Page 50: Øredev2013 - FirefoxOS - the platform HTML5 deserves

CERTIFIED APPS BUILDING BLOCKS

http://buildingfirefoxos.com/

Page 51: Øredev2013 - FirefoxOS - the platform HTML5 deserves

CERTIFIED APPS BUILDING BLOCKS

http://buildingfirefoxos.com/

Page 52: Øredev2013 - FirefoxOS - the platform HTML5 deserves

MOZILLA BRICK

http://mozilla.github.io/brick/

Page 53: Øredev2013 - FirefoxOS - the platform HTML5 deserves

WHAT’S COOKING?

Page 54: Øredev2013 - FirefoxOS - the platform HTML5 deserves

MORE WEB APIS…

Resource lock API

UDP Datagram Socket API

Peer to Peer API

WebNFC

WebUSB

HTTP-cache API

Calendar API

Spellcheck API

LogAPI

Keyboard/IME API

WebRTC

FileHandle API

Sync API

Page 55: Øredev2013 - FirefoxOS - the platform HTML5 deserves

APPMAKER!

Resource lock API

UDP Datagram Socket API

Peer to Peer API

WebNFC

WebUSB

HTTP-cache API

Calendar API

Spellcheck API

LogAPI

Keyboard/IME API

WebRTC

FileHandle API

Sync API

Page 56: Øredev2013 - FirefoxOS - the platform HTML5 deserves

RESOURCES

Page 57: Øredev2013 - FirefoxOS - the platform HTML5 deserves

https://marketplace.firefox.com/developers/

DEVELOPER HUB

Page 58: Øredev2013 - FirefoxOS - the platform HTML5 deserves

https://hacks.mozilla.org/category/firefox-os/

MOZILLA DEVELOPER BLOG

Page 59: Øredev2013 - FirefoxOS - the platform HTML5 deserves

https://hacks.mozilla.org/category/videoseries/

FIREFOX OS VIDEO SERIES

Page 60: Øredev2013 - FirefoxOS - the platform HTML5 deserves

https://developer.mozilla.org/en/docs/Mozilla/Firefox_OS

FIREFOX OS WIKI

Page 61: Øredev2013 - FirefoxOS - the platform HTML5 deserves

THANKS! CHRIS HEILMANN @CODEPO8