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

Commit

Permalink
Revert "Merge pull request #29094 from wilsonpage/1137013-v2.2"
Browse files Browse the repository at this point in the history
This reverts commit 7f1dab8, reversing
changes made to 7024dd4.
  • Loading branch information
rvandermeulen committed Mar 26, 2015
1 parent e59ac06 commit cf9c885
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 122 deletions.
59 changes: 1 addition & 58 deletions apps/camera/js/controllers/camera.js
Expand Up @@ -87,31 +87,9 @@ CameraController.prototype.bindEvents = function() {
settings.hdr.on('change:selected', this.setHDR);
settings.hdr.on('change:selected', this.onHDRChange);

// Key events
window.addEventListener('keydown', this.onKeyDown);

debug('events bound');
};

/**
* When the device's hardware keys
* are pressed we can control the
* camera.
*
* @param {Event} e
* @private
*/
CameraController.prototype.onKeyDown = function(e) {
switch (e.key.toLowerCase()) {
case 'volumedown':
case 'volumeup':
case 'camera':
return this.onCaptureKey(e);
case 'mozcamerafocusadjust':
return this.onFocusKey();
}
};

/**
* Check to see if we're in the middle of a share activity,
* and if so, prevent the camera app from loading the hardware.
Expand All @@ -124,41 +102,6 @@ CameraController.prototype.onVisible = function() {
this.camera.load();
};

/**
* Take picture or start/end recording
* when a capture hardware key is invoked.
*
* Calling `.preventDefault()` prevents
* the default system operation
* (eg. changing volume level). We
* only call it when capture request
* succeeds.
*
* We don't want to .preventDefault() when
* the preview-gallery is open as the
* user may want to change the volume
* of a video being played back.
*
* @param {Event} e
* @private
*/
CameraController.prototype.onCaptureKey = function(e) {
debug('on capture key', e);
if (this.capture() !== false) { e.preventDefault(); }
};

/**
* Focus the camera when a focus
* hardware key is invoked.
*
* @param {Event} e
* @private
*/
CameraController.prototype.onFocusKey = function(e) {
debug('on focus key', e);
this.camera.focus.focus();
};

/**
* Configure the 'cameras' setting using the
* `cameraList` data given by the camera hardware
Expand Down Expand Up @@ -227,7 +170,7 @@ CameraController.prototype.capture = function() {
}

var position = this.app.geolocation.position;
return this.camera.capture({ position: position });
this.camera.capture({ position: position });
};

/**
Expand Down
5 changes: 2 additions & 3 deletions apps/camera/js/lib/camera/camera.js
Expand Up @@ -698,10 +698,9 @@ Camera.prototype.pickThumbnailSize = function(thumbnailSizes, pictureSize) {
* - `position` {Object} - geolocation to store in EXIF
*
* @param {Object} options
* @public
* public
*/
Camera.prototype.capture = function(options) {
if (!this.mozCamera) { return false; }
switch (this.mode) {
case 'picture': this.takePicture(options); break;
case 'video': this.toggleRecording(options); break;
Expand All @@ -718,7 +717,7 @@ Camera.prototype.capture = function(options) {
* @param {Object} options
*/
Camera.prototype.takePicture = function(options) {
debug('take picture', options);
debug('take picture');
this.busy();

var rotation = this.orientation.get();
Expand Down
5 changes: 1 addition & 4 deletions apps/camera/js/lib/camera/focus.js
Expand Up @@ -206,10 +206,7 @@ Focus.prototype.focusOnLargestFace = function(faces) {
* @private
*/
Focus.prototype.focus = function(done) {
if (!this.mozCamera) { return; }
done = done || function() {};
var self = this;

this.suspendContinuousFocus(10000);
if (this.mozCamera.focusMode !== 'auto') {
done();
Expand Down Expand Up @@ -322,4 +319,4 @@ Focus.prototype.updateFocusArea = function(rect, done) {
this.focus(done);
};

});
});
57 changes: 0 additions & 57 deletions apps/camera/test/unit/controllers/camera_test.js
Expand Up @@ -194,63 +194,6 @@ suite('controllers/camera', function() {
});
});

suite('CameraController#onKeyDown', function() {
var captureSpy;
setup(function() {
this.keys = {
camera: 'camera',
volumeup: 'volumeup',
volumedown: 'volumedown',
focus: 'mozcamerafocusadjust',
};

this.event = {
key: undefined,
preventDefault: sinon.spy()
};

this.camera.focus = {
focus: this.sinon.spy()
};
});

test('camera button triggers capture', function() {
this.event.key = 'camera';
this.controller.onKeyDown(this.event);
sinon.assert.called(this.camera.capture);
});

test('volume up button triggers capture', function() {
this.event.key = 'volumeup';
this.controller.onKeyDown(this.event);
sinon.assert.called(this.camera.capture);
});

test('volume down button triggers capture', function() {
this.event.key = 'volumedown';
this.controller.onKeyDown(this.event);
sinon.assert.called(this.camera.capture);
});

test('camera focus button triggers focus', function() {
this.event.key = 'mozcamerafocusadjust';
this.controller.onKeyDown(this.event);
sinon.assert.called(this.camera.focus.focus);
});

test('It calls preventDefault if the capture call doesn\'t return false', function() {
this.camera.capture.returns(false);
this.event.key = 'volumedown';
this.controller.onKeyDown(this.event);
sinon.assert.notCalled(this.event.preventDefault);

this.camera.capture.returns(undefined);
this.event.key = 'volumedown';
this.controller.onKeyDown(this.event);
sinon.assert.called(this.event.preventDefault);
});
});

suite('CameraController#setMode()', function() {
test('It sets the flash mode', function() {
this.controller.setMode();
Expand Down

0 comments on commit cf9c885

Please sign in to comment.