Firefox OS/Stingray/Hybrid Widget Model: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
Line 26: Line 26:
* supporting libraries, like spatial navigation, selection border.
* supporting libraries, like spatial navigation, selection border.
* app list
* app list
* applications


=== Widget Editor ===
=== Widget Editor ===

Revision as of 03:55, 28 April 2014

Hybrid Widget Model

Hybrid Widget Model means homescreen has more power and responsibilities. A homescreen app may manage and host widgets in itself no longer needing system app's support, unlike 2-layered widget model. All apps opened by homescreen app are still managed and hosted by system app.

Limitations

  • Users cannot have multiple instances of the same widget with different configurations (need new API support)
  • A widget cannot open new screen, excepting using mozApps.getSelf().launch()

Prerequisite

The homescreen app of hybrid widget model may depends on the following bugs. We need all of permission bugs fixed to have a privileged homescreen app. We will create a certified homescreen app when they are not ready.

permission bugs

  • bug 899994 mozApp.mgmt: query installed app list, listen app install/uninstall events, use "app://" protocol, etc.
  • no bug embed-apps: assign iframe mozApp attribute to grant permissions.
  • bug 819882 open-remote-window: window.open(url, "remote");

wallpaper

  • bug 900551 Settings API -- for getting wallpaper image
  • bug 917416 Let Homescreen App draw the wallpaper

other gecko bugs

Item List

Homescreen Base

  • supporting libraries, like spatial navigation, selection border.
  • app list
  • applications

Widget Editor

  • layout editor for customizing widget position
  • widget editor for choosing widget
  • persistence module for saving the editing result

Widget Manager

  • widget life-cycle management

Build System

  • pack and build correct homescreen
  • change default homescreen

Sample Widgets

  • 2048

Others

Class Definition Style

Class definition should use the following convention:

 /* global BrowserConfigHelper, WidgetWindow, Applications */
 'use strict';
 
 (function(exports) {
 
   var WidgetFactory = function() {
   };
 
   WidgetFactory.prototype = {
     createWidget: function(args) {
       var manifestURL = args.widgetOrigin + '/manifest.webapp';
       var appInfo = Applications.getByManifestURL(manifestURL);
       if (!appInfo.manifest) {
         return;
       }
       
       var appURL = args.widgetOrigin + (args.widgetEntryPoint ?
         appInfo.manifest.entry_points[args.widgetEntryPoint].launch_path :
         appInfo.manifest.launch_path);
       
       var config = new BrowserConfigHelper(appURL, manifestURL);
       
       var widgetOverlay =
         document.getElementsByClassName('widget-overlay')[0];
       var app = new WidgetWindow(config, widgetOverlay);
       // XXX: Separate styles.
       app.setStyle(args);
       this.publish('launchwidget', app.instanceID);
       
       return app;
     },
     
     publish: function wf_publish(event, detail) {
       var evt = document.createEvent('CustomEvent');
       evt.initCustomEvent(event, true, false, detail);
       window.dispatchEvent(evt);
     }
   };
   
   exports.WidgetFactory = WidgetFactory;
 }(window));