Skip to content

Commit

Permalink
Merge pull request mozilla-b2g#24370 from timdream/lockscreen-slide-u…
Browse files Browse the repository at this point in the history
…nlock

Bug 1062549 - Introduce a slideHide state, allow slide to reset, r=snowmantw
  • Loading branch information
timdream committed Sep 24, 2014
2 parents 8756efc + 4582216 commit 1832737
Show file tree
Hide file tree
Showing 8 changed files with 83 additions and 15 deletions.
1 change: 1 addition & 0 deletions apps/system/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@
<script defer src="/shared/js/lockscreen_connection_info_manager.js"></script>
<script defer src="js/lockscreen.js"></script>
<script defer src="js/lockscreen_state_slideshow.js"></script>
<script defer src="js/lockscreen_state_slidehide.js"></script>
<script defer src="js/lockscreen_state_keypadshow.js"></script>
<script defer src="js/lockscreen_state_keypadrising.js"></script>
<script defer src="js/lockscreen_state_keypadhiding.js"></script>
Expand Down
2 changes: 2 additions & 0 deletions apps/system/js/lockscreen_state_keypadshow.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
// Copy from the original switching method.
this.lockScreen.overlay.classList.add('no-transition');
this.lockScreen.overlay.dataset.panel = 'passcode';
// Resetting slider when it get hidden by the passcode keypad
this.lockScreen._unlocker.reset();
// XXX: Because when it's 'success', the keyboard would be hidden.
// This should be fixed: we should manage the show/hide with other
// CSS flags.
Expand Down
15 changes: 13 additions & 2 deletions apps/system/js/lockscreen_state_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
*/

/* global SettingsListener, System */
/* global LockScreenStateSlideShow, LockScreenStateKeypadShow */
/* global LockScreenStateSlideShow, LockScreenStateSlideHide */
/* global LockScreenStateKeypadShow */
/* global LockScreenStateKeypadHiding, LockScreenStateKeypadRising */
/* global LockScreenStatePanelHide */
/* global LockScreenStateLogger */
Expand Down Expand Up @@ -90,6 +91,7 @@
// these states.
this.states = {
slideShow: (new LockScreenStateSlideShow()).start(this.lockScreen),
slideHide: (new LockScreenStateSlideHide()).start(this.lockScreen),
keypadShow: (new LockScreenStateKeypadShow()).start(this.lockScreen),
keypadHiding: (new LockScreenStateKeypadHiding()).start(this.lockScreen),
keypadRising: (new LockScreenStateKeypadRising()).start(this.lockScreen),
Expand Down Expand Up @@ -143,10 +145,19 @@
screenOn: true,
unlocking: false
},
['panelHide'],
['panelHide', 'slideHide'],
this.states.slideShow,
'Resume from screen off');

this.registerRule({
passcodeEnabled: false,
screenOn: true,
unlocking: true
},
['slideShow'],
this.states.slideHide,
'When it activate to unlock without passcode, unlock and animates.');

this.registerRule({
passcodeEnabled: true,
passcodeTimeout: true,
Expand Down
38 changes: 38 additions & 0 deletions apps/system/js/lockscreen_state_slidehide.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
Copyright 2012, Mozilla Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

/* global Promise */

'use strict';

/**
* This state would guarantee the LockScreen plays the animation.
*/
(function(exports) {

var LockScreenStateSlideHide = function() {};
LockScreenStateSlideHide.prototype.start = function lsssh_start(lockScreen) {
this.type = 'slideHide';
this.lockScreen = lockScreen;
return this;
};

LockScreenStateSlideHide.prototype.transferTo =
function lsssh_transferTo() {
return Promise.resolve();
};
exports.LockScreenStateSlideHide = LockScreenStateSlideHide;
})(window);
2 changes: 2 additions & 0 deletions apps/system/js/lockscreen_state_slideshow.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
// Clear passcode while the keypad is hiding.
this.lockScreen.passCodeEntered = '';
this.lockScreen.updatePassCodeUI();
// Resetting slider before we want to show it again
this.lockScreen._unlocker.reset();
// Copy from the original switching method.
this.lockScreen.overlay.classList.add('no-transition');
this.lockScreen.overlay.dataset.panel = 'main';
Expand Down
1 change: 1 addition & 0 deletions apps/system/test/unit/lockscreen_state_manager_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ suite('system/LockScreenStateManager', function() {
};
};
window.LockScreenStateSlideShow =
window.LockScreenStateSlideHide =
window.LockScreenStatePanelHide =
window.LockScreenStateKeypadShow =
window.LockScreenStateKeypadHiding =
Expand Down
17 changes: 17 additions & 0 deletions apps/system/test/unit/lockscreen_state_slidehide_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/* global LockScreenStateSlideHide */

'use strict';
requireApp('system/js/lockscreen_state_slidehide.js');
suite('sytem/LockScreenStateSlideHide', function() {
var subject;
var mockLockScreen;
setup(function() {
mockLockScreen = {
overlay: document.createElement('div')
};
subject = (new LockScreenStateSlideHide()).start(mockLockScreen);
});
test('it would resolve as expected', function(done) {
subject.transferTo().then(done, done);
});
});
22 changes: 9 additions & 13 deletions shared/js/lockscreen_slide.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,14 @@
this.states.initialized = true;
};

LockScreenSlidePrototype.reset = function lss_reset() {
this._clearCanvas();
this._drawTrack();
this._resetHandle();
this._resetArrows();
this._drawIconBG();
};

/**
* Overwrite settings recursively.
*
Expand Down Expand Up @@ -577,24 +585,12 @@
function lss_onSlideEnd() {

var isLeft = this.states.touch.pageX - this.center.x < 0;
var bounceEnd = (function _bounceEnd() {
this._clearCanvas();
this._drawTrack();
this._resetHandle();
this._resetArrows();
this._drawIconBG();
}).bind(this);

if (false === this.states.slideReachEnd) {
this._bounceBack(this.states.touch.pageX, bounceEnd);
this._bounceBack(this.states.touch.pageX);
} else {
var intention = isLeft ? 'lockscreenslide-activate-left' :
'lockscreenslide-activate-right';
this.publish(intention);

// Restore it only after screen changed.
var appLaunchDelay = 400;
setTimeout(bounceEnd, appLaunchDelay);
}

this.publish('lockscreenslide-unlocking-stop');
Expand Down

0 comments on commit 1832737

Please sign in to comment.