This repository has been archived by the owner on Nov 3, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12414 from alivedise/bugzilla/905116_master_v7
Bug 905116 - Implement Homescreen Window + Homescreen Launcher, r=timdream
- Loading branch information
Showing
17 changed files
with
985 additions
and
353 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
(function(window) { | ||
var currentManifestURL = ''; | ||
var instance = undefined; | ||
var _inited = false; | ||
|
||
var HomescreenLauncher = { | ||
ready: false, | ||
|
||
get origin() { | ||
// We don't really care the origin of homescreen, | ||
// and it may change when we swap the homescreen app. | ||
// So we use a fixed string here. | ||
// XXX: We shall change WindowManager to use manifestURL | ||
// to identify an app. | ||
// See http://bugzil.la/913323 | ||
return 'homescreen'; | ||
}, | ||
|
||
init: function hl_init() { | ||
if (_inited) | ||
return; | ||
|
||
_inited = true; | ||
|
||
var self = this; | ||
if (Applications.ready) { | ||
this.fetchSettings(); | ||
} else { | ||
window.addEventListener('applicationready', function onAppReady() { | ||
window.removeEventListener('applicationready', onAppReady); | ||
self.fetchSettings(); | ||
}); | ||
} | ||
|
||
window.addEventListener('trusteduishow', this); | ||
window.addEventListener('trusteduihide', this); | ||
}, | ||
|
||
handleEvent: function hl_handleEvent(evt) { | ||
switch (evt.type) { | ||
case 'trusteduishow': | ||
this.getHomescreen().toggle(true); | ||
break; | ||
case 'trusteduihide': | ||
this.getHomescreen().toggle(false); | ||
break; | ||
} | ||
}, | ||
|
||
fetchSettings: function hl_fetchSettings() { | ||
var self = this; | ||
SettingsListener.observe('homescreen.manifestURL', '', | ||
function onRetrievingHomescreenManifestURL(value) { | ||
var previousManifestURL = currentManifestURL; | ||
currentManifestURL = value; | ||
if (typeof(instance) !== 'undefined') { | ||
if (previousManifestURL !== '' && | ||
previousManifestURL !== currentManifestURL) { | ||
instance.kill(); | ||
instance = new HomescreenWindow(value); | ||
// Dispatch 'homescreen is changed' event. | ||
window.dispatchEvent(new CustomEvent('homescreen-changed')); | ||
} else { | ||
instance.ensure(); | ||
} | ||
} | ||
|
||
self.ready = true; | ||
window.dispatchEvent(new CustomEvent('homescreen-ready')); | ||
}); | ||
}, | ||
|
||
getHomescreen: function hl_getHomescreen() { | ||
if (currentManifestURL === '') { | ||
console.warn('HomescreenLauncher: not ready right now.'); | ||
return null; | ||
} | ||
if (typeof instance == 'undefined') { | ||
instance = new HomescreenWindow(currentManifestURL); | ||
return instance; | ||
} else { | ||
instance.ensure(); | ||
return instance; | ||
} | ||
} | ||
}; | ||
|
||
window.HomescreenLauncher = HomescreenLauncher; | ||
}(this)); |
Oops, something went wrong.