Hack On Firefox OS - PSES

41
Hack On Firefox OS Christophe Villeneuve @hellosct1

Transcript of Hack On Firefox OS - PSES

Page 1: Hack On Firefox OS - PSES

Hack On Firefox OS

Christophe Villeneuve@hellosct1

Page 2: Hack On Firefox OS - PSES

Qui... est Christophe Villeneuve ?

afup – lemug.fr – mysql – mariadb – drupal – demoscene – firefoxos – drupagora – phptour – forumphp – solutionlinux – demoinparis – ici et maintenant – eyrolles – editions eni – programmez – linux pratique – webriver – phptv – neuros - elephpant

Page 3: Hack On Firefox OS - PSES

Aujourd'hui

● La connaissance pour tous ● Vos besoins● Mobile ? Le Quoi !!!● La pratique

Page 4: Hack On Firefox OS - PSES

Avant (fin du 20ème siécle)

Page 5: Hack On Firefox OS - PSES

Le Web● Principes simples

– URL/HTTP/HTML

● Standards ouverts● Pas de Kit de Dév.● Pas d'autorisation● Disponible en Doc● ...

● 1ère génération

● 2ème génération

Page 6: Hack On Firefox OS - PSES

Le mobile / les smartphones

Apple Google Microsoft

Page 7: Hack On Firefox OS - PSES

Le Futur● Un web sur smartphone

Page 8: Hack On Firefox OS - PSES

Au final

Page 9: Hack On Firefox OS - PSES

Plateforme ouverte mobile

Page 10: Hack On Firefox OS - PSES

Choisir le moyen de consommer

Le market des smartphones

Supermarché

Page 11: Hack On Firefox OS - PSES

Vos besoins

● Matériels● Technique● Logiciels● Composants

Page 12: Hack On Firefox OS - PSES

Technique : les standards du web

https://developer.mozilla.org/en-US/docs/Web/Tutorials

Page 13: Hack On Firefox OS - PSES

Logiciels

● Gedit● Notepad++● Eclipse● Brackets● ...

Editeur de texte● Firefox ou autre

– Outils de Débug

– Web IDE

– Firefox OS App Manager

Navigateur

Page 14: Hack On Firefox OS - PSES

Appareils mobiles (1/2)

Alcatel One TouchFlame

ZTE Open C

GeeksPhone Intex Cloud FX

Et beaucoup d'autres disponibles :

https://www.mozilla.org/fr/firefox/os/devices/

LG Fx0

Page 15: Hack On Firefox OS - PSES

Appareils mobiles (2/2)

Samsung Nexus 4

Samsung Galaxy

Sony

Etc...

Page 16: Hack On Firefox OS - PSES

Composants → Web apps

Page 17: Hack On Firefox OS - PSES
Page 18: Hack On Firefox OS - PSES

https://mdn.mozillademos.org/files/4605/FirefoxOS.png

GONK

➢GECKO

➢GAIA

Page 19: Hack On Firefox OS - PSES

GONK✔ Couche basse

✔ Kernel Linux + Matériels

✔ Hardware 

✔ libre ou propriétaire✔ Abstraction Layer (HAL)

✔ Pas exposé le JS  ✔ Isolé de Gaia 

✔ Communication par Gecko

Architecture (1/3)

Page 20: Hack On Firefox OS - PSES

➢GONK

➢GECKO

✔ Moteur de rendu HTML5✔ Gestion des API

✔ De plus en plus complet

✔ Exécution des applications (runtime)

✔ Mécanisme de lancement dans Firefox pour HTML 5, CSS & Javascript

Architecture

Page 21: Hack On Firefox OS - PSES

➢GONK

➢GECKO➢GAIA

✔ Interface utilisateur (IHM)✔ Construction API Full Web✔ HTML 5 + open Web✔ Communique avec Gecko via des Web API✔ Les Apps sont exécutés en mode sandbox✔ Offline

✔ LocalStorage, appCache

Architecture

Page 22: Hack On Firefox OS - PSES
Page 23: Hack On Firefox OS - PSES

Architecture

Firefox OSWeb

Page 24: Hack On Firefox OS - PSES

{

  "version": "1.0",

  "name": "Batterie",

  "description": "Gestion de la batterie",

  "launch_path": "/index.html",

  "icons": {

    "48": "/img/icons/api­48.png",

    "128": "/img/icons/api­128.png",

    "512": "/img/icons/api­512.png"

  },

  "developer": {

    "name": "Christophe Villeneuve",

    "url": "http://www.hello­design.fr"

  },

    "installs_allowed_from": [

    "*"

  ],

  "appcache_path": "/cache.manifest",

  "locales": {

    "fr": {

      "description": "Gestion de la batterie",

      "developer": {

        "url": "http://www.hello­design.fr"

      }

    }

  },

  "default_locale": "en"

}

Manifest.webapp

https://developer.mozilla.org/en-US/Apps/Build/Manifest

Options possibles : - Fullscreen- Permission- Orientation- Serveur- Etc.

Page 25: Hack On Firefox OS - PSES

CACHE MANIFEST

# Version 1.0

CACHE:

/css/all.css

/js/lib/all.js

/js/all.js

/index.html

Manifest.appcache

Page 26: Hack On Firefox OS - PSES

var battery = navigator.battery || navigator.mozBattery || navigator.webkitBattery;

// définir les éléments

var indicator1 = document.getElementById('indicator1');

var indicator2 = document.getElementById('indicator2');

var batteryCharge = document.getElementById('battery­charge');

var batteryTop = document.getElementById('battery­top');

var chargeIcon = document.getElementById('battery­charging');

// Position indicateur

// 0 Initialisation, 1 batterie chargé, 2 batterie non chargé

var chargingState = 0;

Js/battery.js

Page 27: Hack On Firefox OS - PSES

if(battery.charging) {

  // batterie chargé

    if(chargingState == 1 || chargingState == 0) {

 

      batteryTop.style.backgroundColor = 'gold';

      batteryCharge.style.backgroundColor = 'gold';

      indicator2.innerHTML = "Battery is charging";

      chargeIcon.style.visibility = 'visible';

      createNotification("batterie chargé");

      // flip the chargingState flag to 2

      chargingState = 2;

    }

  } 

Js/battery.js (suite)

  } else if(!battery.charging) {

  // Batterie non chargé

    if(chargingState == 2 || chargingState == 0) {

   

      batteryTop.style.backgroundColor = 'yellow';

      batteryCharge.style.backgroundColor = 'yellow';

      indicator2.innerHTML = "Battery not charging";

      chargeIcon.style.visibility = 'hidden';

     

      createNotification("batterie non chargé");

      // flip the chargingState flag to 1

      chargingState = 1;

    }

  }

Page 28: Hack On Firefox OS - PSES

<!DOCTYPE html>

<html lang="en" manifest="manifest.appcache">

  <head>

    <meta charset="utf­8" />

    <title>Battery example</title>

    <meta content="Gestion battery" name="description" />

    <meta content="width=device­width, initial­scale=1.0" name="viewport" />

    <link href="/images/32.png" rel="icon" size="32x32" />

    <link href="/images/64.png" rel="icon" size="64x64" />

    <link href="/images/128.png" rel="icon" size="128x128" />

    <link href="/images/256.png" rel="icon" size="256x256" />

    <link href="/css/all.css" rel="stylesheet" type="text/css" />

  </head>

  <body>

    // Votre code

    <script src="/javascripts/all.js" type="text/javascript"></script>

   <button id="install">Install app on device</button>

  </body>

</html>

index.html

Page 29: Hack On Firefox OS - PSES

Tester l'application

Navigateur

Mobile

http://mdn.github.io/battery-quickstart-finished-example/

Page 30: Hack On Firefox OS - PSES

Simulateur

● Firefox OS simulator WEBIDEhttps://developer.mozilla.org/fr/docs/Outils/WebIDE

Page 31: Hack On Firefox OS - PSES

Web IDE

Page 32: Hack On Firefox OS - PSES

Résultat

Page 33: Hack On Firefox OS - PSES

Débug

Page 34: Hack On Firefox OS - PSES

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

Page 35: Hack On Firefox OS - PSES

✔ 100 % le contrôle

✔ Pas d'intermédiaire

✔ Chez vous✔ Déporté✔ Sur la market

✔ N'importe qui peut en développer une

✔ Toutes les Apps ne sont pas libres

Market... Marketplace

Page 36: Hack On Firefox OS - PSES

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

Validateur

Page 37: Hack On Firefox OS - PSES

Déployer votre API

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

Page 38: Hack On Firefox OS - PSES

Catégorie

- Informations- Pays / Langue- Média- Détails- Assistance- Info techniques- Catégories

- Informations- Pays / Langue- Média- Détails- Assistance- Info techniques- Catégories

Page 39: Hack On Firefox OS - PSES

https://marketplace.firefox.com/

Marketplace

Page 40: Hack On Firefox OS - PSES

http://marketplace.mozilla.org

http://www.mozilla.org/firefoxos

https://developer.mozilla.org/fr/Firefox_OS/Developing_Gaia

https://developer.mozilla.org/fr/Firefox_OS

http://hacks.mozilla.org

URL ?

Page 41: Hack On Firefox OS - PSES

Merci

Blog : http://firefoxos.mozfr.org