html for the mobile web, firefox os - all things open - 2014-10-22

57
HTML for the Mobile Web All Things Open Firefox OS 2014-10-22 Frédéric Harper Sr. Technical Evangelist @ Mozilla @fharper | outofcomfortzone.net Creative Commons: https://ic.kr/p/5HzQsy

Upload: frederic-harper

Post on 29-Nov-2014

237 views

Category:

Technology


2 download

DESCRIPTION

Firefox OS is a new operating system for mobile phones to bring web connectivity to those who can not get top-of-the-line smartphones. By harvesting the principles of what made the web great and giving developers access to the hardware directly through web standards it will be the step we need to make a real open and affordable mobile web a reality. In this talk, Frédéric Harper from Mozilla will show how Firefox OS works, how to build apps for it and how end users will benefit from this open alternative to other platforms.

TRANSCRIPT

Page 1: HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22

HTML for the Mobile Web

All Things Open

Firefox OS

2014-10-22

Frédéric Harper

Sr. Technical Evangelist @ Mozilla

@fharper | outofcomfortzone.net

Crea

tive

Com

mon

s: h

ttps

://fl

ic.k

r/p/

5HzQ

sy

Page 2: HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22

Creative Commons: http://j.mp/1hCZYIe

Page 3: HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22

Creative Commons: http://j.mp/1ljZuJC

Page 4: HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22
Page 5: HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22
Page 6: HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22

38 billion devices connected in 2020

ABI Research - 2013-05-09 - http://j.mp/38billion

Page 7: HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22

Creative Commons: http://j.mp/1gP4X4K

Page 8: HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22
Page 9: HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22

What you deserve

Page 10: HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22
Page 11: HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22

Built with the Web

Using HTML5, CSS3 and JavaScript

with a number of APIs

to build apps.

Page 12: HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22

It’s open source

Page 13: HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22

Some facts

•  Available in more than 24 countries

•  Primarly aimed at emerging & low

end markets

Page 14: HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22

Some of the devices

Page 15: HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22
Page 16: HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22
Page 17: HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22
Page 18: HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22
Page 19: HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22
Page 20: HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22

A Firefox OS app?

§  Creating a hosted or packaged app

§  Using §  Vanilla HTML5

§  Librairies…

§  Regular API

§  Privileged API

§  Certified API

Page 21: HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22

HTML5 + manifest (JSON) = Firefox OS app {

"version": “42",

"name": ”My amazing app",

"launch_path": "/index.html",

"description": ”My super amazing app do super amazing things",

"icons": {

"16": "/images/logo16.png”,},

"developer": {

"name": ”Frédéric Harper",

"url": "http://outofcomfortzone.net",

},

"default_locale": "en",

"permissions": {

"geolocation": {

"description": ”Get the long/lat of the user"

}

}

}

Page 22: HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22

DEMO Firefox OS + App Manager + Emberjs todomvc

Page 23: HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22

Web APIs

Page 24: HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22

Web APIs – Regular •  Alarm API •  Ambient light sensor •  Archive API •  Battery Status API •  Geolocation API •  IndexedDB •  Network Information API •  Notifications API

•  Open WebApps •  Proximity sensor •  Push API •  Screen Orientation •  Vibration API •  Web Activities •  WebFM API •  WebPayment

packaged

hosted

Page 25: HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22

Ambient Light Sensor

Page 26: HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22

Ambient Light Sensor

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 27: HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22

DEMO Boilerplate – Ambient Light Sensor

Page 28: HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22

Battery Status

Page 29: HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22

Battery Status

var battery = navigator.battery;

if (battery) {

var batteryLevel = Math.round(battery.level * 100) + "%",

 

charging = (battery.charging)? “yes" : "no",

chargingTime = parseInt(battery.chargingTime / 60, 10,

dischargingTime = parseInt(battery.dischargingTime / 60, 10);

 

battery.addEventListener("levelchange", setStatus, false);

battery.addEventListener("chargingchange", setStatus, false);

battery.addEventListener("chargingtimechange", setStatus, false);

}

Page 30: HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22

Web APIs – Privileged •  Browser API •  Contacts API •  Device Storage API •  systemXHR •  TCP Socket API

packaged

Page 31: HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22

Browser

Page 32: HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22

Browser

<div>

<span id='location-bar'></span>

<button onclick='go_button_clicked()'>Go</button>

</div>

<div id='load-status'></div>

<div id='security-status'></div>

<img id='favicon'>

<div id='title'></div>

<iframe mozbrowser src=‘yoursite.com' id='browser'></iframe>

Page 33: HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22

Browser

addEventListener('mozbrowserloadstart', function(e) {

//Do stuff

});

/*

Possible values:

"mozbrowserloadstart“ "mozbrowserloadend"

"mozbrowserlocationchange“ "mozbrowsertitlechange"

"mozbrowsericonchange“ "mozbrowsersecuritychange"

"mozbrowsercontextmenu“ "mozbrowsererror"

"mozbrowserkeyevent“ "mozbrowsershowmodalprompt"

"mozbrowseropenwindow“ "mozbrowserclose"

*/

Page 34: HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22

Web APIs – Certified •  Camera API •  Idle API •  Mobile Connection API •  Network Stats API •  Permissions API •  Power Management API •  Settings API •  Time/Clock API

•  Voicemail •  WebBluetooth •  WebSMS •  WebTelephony •  WiFi Information API

OS/OEM

Page 35: HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22

Web Activities

Page 36: HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22

Web Activities •  browse •  configure •  costcontrol •  dial •  Open •  new

•  mail •  websms/sms •  webcontacts/contact

•  pick •  record •  save-bookmark •  share •  view •  update

packaged

hosted

Page 37: HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22

Pick var activity = new MozActivity({

name: "pick",

//Provide the data required

//by the filter of the activity

data: {

type: "image/jpeg"

}

});

Page 38: HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22

Pick activity.onsuccess = function () {

var img = document.createElement("img");

if (this.result.blob.type.indexOf("image") != -1) {

img.src = window.URL.createObjectURL(this.result.blob);

}

};

activity.onerror = function () {

//error

};

Page 39: HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22

Dial var call = new MozActivity({

name: "dial",

data: {

number: "+46777888999"

}

});

Page 40: HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22

Web Activity Received Handler "activities": {

"pick": {

"filters": {

"type": ["image/jpeg", "image/png"]

},

"disposition": "inline",

"returnValue": true,

"href": "/index.html#pick"

}

}

Page 41: HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22

Don’t forget to handle it! navigator.mozSetMessageHandler('activity', function(activityRequest) {

var option = activityRequest.source;

if (activityRequest.source.name === "pick") {

// Do something to handle the activity

if (picture) {

activityRequest.postResult(picture);

}

else {

activityRequest.postError("Unable to provide a picture");

}

}

});

Page 42: HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22

Creative Commons: http://j.mp/1iZHGAW

Page 43: HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22

Creative Commons: https://flic.kr/p/4mJnLg

Page 44: HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22

How to start

Page 45: HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22

Creative Commons: http://j.mp/1iquK8Q

Page 46: HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22

Creative Commons: http://j.mp/Ilm7wx

Page 47: HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22

Phonegap & Cordova

& <3

Page 48: HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22

Plugins implementation

http://mozilla-cordova.github.io/

Page 49: HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22

Simplicity…

Page 50: HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22

Firefox Web Developer Tools

Page 51: HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22
Page 52: HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22
Page 53: HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22

Creative Commons: http://j.mp/1gIdcPF

To infinity, and beyond…

Page 54: HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22

More Web APIs & features

•  Calendar API

•  FileHandle API Sync API

•  Keyboard/IME API WebRTC

•  HTTP-cache API

•  Peer to Peer API

•  Spellcheck API LogAPI

•  Resource lock API

•  UDP Datagram Socket API

•  WebNFC

•  WebUSB

Page 55: HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22

Next time you’ll build a mobile app Think about HTML5 & Firefox OS

Page 56: HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22

Resources Firefox OS Simulator http://j.mp/fxosSimulator Firefox OS App Manager http://j.mp/fxosAppManager Mozilla Developer Network https://developer.mozilla.org

StackOverflow forum http://j.mp/fxosStackOverflow Firefox OS Boilerplate http://j.mp/fxosBoilerplate

Page 57: HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22

Frédéric Harper

[email protected]

@fharper

http://hacks.mozilla.org

http://outofcomfortzone.net