Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Bug 1047143 - close aps entering task-manager, exitToApp to open/restore
Browse files Browse the repository at this point in the history
* Fix assumption that home event means homescreen opens in SoundManager,
* Remove appwillopen handler in AttentionScreen, applaunch will suffice
* Also listen for search app's requestforeground event
  • Loading branch information
sfoster committed Aug 26, 2014
1 parent 91d744b commit 450be07
Show file tree
Hide file tree
Showing 18 changed files with 402 additions and 147 deletions.
4 changes: 2 additions & 2 deletions apps/system/js/app_transition_controller.js
Expand Up @@ -232,7 +232,7 @@
this.app.reviveBrowser();
this.app.launchTime = Date.now();
this.app.fadeIn();
this.app.setVisible(true);
this.app.requestForeground();

// TODO:
// May have orientation manager to deal with lock orientation request.
Expand All @@ -250,7 +250,7 @@
this.resetTransition();
this.app.element.removeAttribute('aria-hidden');
this.app.element.classList.add('active');
this.app.setVisible(true);
this.app.requestForeground();

// TODO:
// May have orientation manager to deal with lock orientation request.
Expand Down
13 changes: 10 additions & 3 deletions apps/system/js/app_window.js
Expand Up @@ -1886,8 +1886,9 @@
*/
AppWindow.prototype.enterTaskManager = function aw_enterTaskManager() {
this._dirtyStyleProperties = {};
if (this.element) {
if (this.element && this.transitionController) {
this.element.classList.add('in-task-manager');
this.close( this.isActive() ? 'to-cardview' : 'immediate' );
}
};

Expand All @@ -1897,8 +1898,10 @@
AppWindow.prototype.leaveTaskManager = function aw_leaveTaskManager() {
if (this.element) {
this.element.classList.remove('in-task-manager');
this.unapplyStyle(this._dirtyStyleProperties);
this._dirtyStyleProperties = null;
if (this._dirtyStyleProperties) {
this.unapplyStyle(this._dirtyStyleProperties);
this._dirtyStyleProperties = null;
}
}
};

Expand Down Expand Up @@ -1975,5 +1978,9 @@
win.focus();
};

AppWindow.prototype.requestForeground = function aw_requestForeground() {
this.publish('requestforeground');
};

exports.AppWindow = AppWindow;
}(window));
3 changes: 2 additions & 1 deletion apps/system/js/app_window_manager.js
Expand Up @@ -208,7 +208,7 @@

appNext.open(immediateTranstion ? 'immediate' :
((switching === true) ? 'invoked' : openAnimation));
if (appCurrent) {
if (appCurrent && appCurrent.instanceID !== appNext.instanceID) {
appCurrent.close(immediateTranstion ? 'immediate' :
((switching === true) ? 'invoking' : closeAnimation));
} else {
Expand Down Expand Up @@ -552,6 +552,7 @@
this._activeApp.getTopMostWindow().blur();
}
break;

case 'sheetstransitionstart':
if (document.mozFullScreen) {
document.mozCancelFullScreen();
Expand Down
9 changes: 0 additions & 9 deletions apps/system/js/attention_screen.js
Expand Up @@ -49,7 +49,6 @@ var AttentionScreen = {
window.addEventListener('home', this.hide.bind(this));
window.addEventListener('holdhome', this.hide.bind(this));
window.addEventListener('global-search-request', this.hide.bind(this));
window.addEventListener('appwillopen', this.appOpenHandler.bind(this));
window.addEventListener('launchapp', this.appLaunchHandler.bind(this));
window.addEventListener('emergencyalert', this.hide.bind(this));

Expand Down Expand Up @@ -85,14 +84,6 @@ var AttentionScreen = {
}
},

appOpenHandler: function as_appHandler(evt) {
// If the user presses the home button we will still hide the attention
// screen. But in the case of an app crash we'll keep it fully open
if (!evt.detail.isHomescreen) {
this.hide();
}
},

appLaunchHandler: function as_appLaunchHandler(evt) {
if (!evt.detail.stayBackground) {
this.hide();
Expand Down
5 changes: 5 additions & 0 deletions apps/system/js/card.js
Expand Up @@ -182,6 +182,8 @@

this._fetchElements();
this._registerEvents();

this.app.enterTaskManager();
this.publish('rendered');
return elem;
};
Expand Down Expand Up @@ -222,6 +224,9 @@
if (element && element.parentNode) {
element.parentNode.removeChild(element);
}
if (this.app) {
this.app.leaveTaskManager();
}
this.element = this.manager = this.app = null;
this.publish('destroyed');
};
Expand Down
6 changes: 3 additions & 3 deletions apps/system/js/sound_manager.js
Expand Up @@ -229,7 +229,7 @@
window.addEventListener('appopen', this);
window.addEventListener('ftudone', this);
window.addEventListener('holdhome', this);
window.addEventListener('home', this);
window.addEventListener('homescreenopening', this);
window.addEventListener('homescreenopened', this);

this.initVibrationUserPref();
Expand Down Expand Up @@ -265,7 +265,7 @@
window.removeEventListener('appopen', this);
window.removeEventListener('ftudone', this);
window.removeEventListener('holdhome', this);
window.removeEventListener('home', this);
window.removeEventListener('homescreenopening', this);
window.removeEventListener('homescreenopened', this);
};

Expand Down Expand Up @@ -323,7 +323,7 @@
case 'holdhome':
CustomDialog.hide();
break;
case 'home':
case 'homescreenopening':
case 'homescreenopened':
this.homescreenVisible = true;
CustomDialog.hide();
Expand Down
6 changes: 5 additions & 1 deletion apps/system/js/stack_manager.js
Expand Up @@ -196,6 +196,10 @@ var StackManager = {
}
break;
case 'home':
// only handle home events if task manager is not visible
if (window.taskManager && window.taskManager.isShown()) {
return;
}
this._moveToTop(this.position);
this.position = -1;
this.commitClose();
Expand Down Expand Up @@ -267,7 +271,7 @@ var StackManager = {
if (sConfig.instanceID == instanceID) {
this._stack.splice(i, 1);

if (i <= this.position && this.position > 0) {
if (i <= this.position && this.position >= 0) {
this.position--;
}
return;
Expand Down
5 changes: 0 additions & 5 deletions apps/system/js/task_card.js
Expand Up @@ -80,7 +80,6 @@
*/
TaskCard.prototype.render = function tc_render() {
Card.prototype.render.call(this);
this.app.enterTaskManager();
return this.element;
};

Expand All @@ -95,10 +94,6 @@
* @memberof TaskCard.prototype
*/
TaskCard.prototype.destroy = function tc_destroy() {
var app = this.app;
if (app) {
app.leaveTaskManager();
}
Card.prototype.destroy.call(this);
};

Expand Down

0 comments on commit 450be07

Please sign in to comment.