diff --git a/apps/camera/js/app.js b/apps/camera/js/app.js index 85800739c9e1..4150ae643947 100644 --- a/apps/camera/js/app.js +++ b/apps/camera/js/app.js @@ -5,27 +5,22 @@ define(function(require, exports, module) { * Dependencies */ -var performanceTesting = require('performanceTesting'); var NotificationView = require('views/notification'); var ViewfinderView = require('views/viewfinder'); var orientation = require('lib/orientation'); var ControlsView = require('views/controls'); var FocusRing = require('views/focus-ring'); var ZoomBarView = require('views/zoom-bar'); -var lockscreen = require('lib/lock-screen'); -var constants = require('config/camera'); var bindAll = require('lib/bind-all'); var model = require('vendor/model'); var debug = require('debug')('app'); var HudView = require('views/hud'); var bind = require('lib/bind'); -var dcf = require('lib/dcf'); /** * Locals */ -var LOCATION_PROMPT_DELAY = constants.PROMPT_DELAY; var unbind = bind.unbind; // Mixin model methods @@ -57,7 +52,6 @@ function App(options) { this.controllers = options.controllers; this.geolocation = options.geolocation; this.activity = options.activity; - this.config = options.config; this.settings = options.settings; this.storage = options.storage; this.camera = options.camera; @@ -72,20 +66,15 @@ function App(options) { * @public */ App.prototype.boot = function() { - if (this.didBoot) { - return; - } - + if (this.didBoot) { return; } this.initializeViews(); this.runControllers(); this.injectViews(); this.bindEvents(); - this.miscStuff(); this.configureL10n(); this.emit('boot'); - debug('booted'); - this.didBoot = true; + debug('booted'); }; App.prototype.teardown = function() { @@ -118,6 +107,11 @@ App.prototype.runControllers = function() { debug('controllers run'); }; +/** + * Initialize views. + * + * @private + */ App.prototype.initializeViews = function() { debug('initializing views'); this.views.viewfinder = new ViewfinderView(); @@ -129,6 +123,11 @@ App.prototype.initializeViews = function() { debug('views initialized'); }; +/** + * Put views in the DOM. + * + * @private + */ App.prototype.injectViews = function() { debug('injecting views'); this.views.viewfinder.appendTo(this.el); @@ -143,6 +142,7 @@ App.prototype.injectViews = function() { /** * Attaches event handlers. * + * @private */ App.prototype.bindEvents = function() { this.storage.once('checked:healthy', this.geolocationWatch); @@ -151,8 +151,6 @@ App.prototype.bindEvents = function() { bind(this.el, 'click', this.onClick); this.on('focus', this.onFocus); this.on('blur', this.onBlur); - this.on('previewgallery:opened', lockscreen.enableTimeout); - this.on('previewgallery:closed', lockscreen.disableTimeout); debug('events bound'); }; @@ -176,8 +174,7 @@ App.prototype.unbindEvents = function() { * app was minimised */ App.prototype.onFocus = function() { - var ms = LOCATION_PROMPT_DELAY; - setTimeout(this.geolocationWatch, ms); + this.geolocationWatch(); this.storage.check(); orientation.start(); debug('focus'); @@ -200,18 +197,19 @@ App.prototype.onClick = function() { }; /** - * Begins watching location - * if not within a pending - * activity and the app - * isn't currently hidden. + * Begins watching location if not within + * a pending activity and the app isn't + * currently hidden. + * + * Watching is delayed by the `promptDelay` + * defined in settings. * + * @private */ App.prototype.geolocationWatch = function() { + var delay = this.settings.geolocation.get('promptDelay'); var shouldWatch = !this.activity.active && !this.doc.hidden; - if (shouldWatch) { - this.geolocation.watch(); - debug('geolocation watched'); - } + if (shouldWatch) { setTimeout(this.geolocation.watch, delay); } }; /** @@ -234,7 +232,7 @@ App.prototype.onVisibilityChange = function() { * @private */ App.prototype.onBeforeUnload = function() { - this.views.viewfinder.setPreviewStream(null); + this.views.viewfinder.stopStream(); this.emit('beforeunload'); debug('beforeunload'); }; @@ -256,43 +254,4 @@ App.prototype.configureL10n = function() { if (complete) { this.emit('localized'); } }; -/** - * Miscalaneous tasks to be - * run when the app first - * starts. - * - * TODO: Eventually this function - * will be removed, and all this - * logic will sit in specific places. - * - */ -App.prototype.miscStuff = function() { - var camera = this.camera; - var focusTimeout; - var self = this; - - // TODO: Should probably be - // moved to a focusRing controller - camera.on('change:focus', function(value) { - self.views.focusRing.setState(value); - clearTimeout(focusTimeout); - - if (value === 'fail') { - focusTimeout = setTimeout(function() { - self.views.focusRing.setState(null); - }, 1000); - } - }); - - - dcf.init(); - performanceTesting.dispatch('initialising-camera-preview'); - - // Prevent the phone - // from going to sleep. - lockscreen.disableTimeout(); - - debug('misc stuff done'); -}; - }); diff --git a/apps/camera/js/config/camera.js b/apps/camera/js/config/camera.js index 328583407742..d539685afb1d 100644 --- a/apps/camera/js/config/camera.js +++ b/apps/camera/js/config/camera.js @@ -1,31 +1,16 @@ define(function(require, exports, module) { 'use strict'; +/** + * This file is @deprecated! + * Please use config/settings.js instead. + */ + /** * Exports */ module.exports = { - CAMERA_MODE_TYPE: { - PICTURE: 'picture', - VIDEO: 'video' - }, - - STORAGE_STATE_TYPE: { - INIT: 0, - AVAILABLE: 1, - NOCARD: 2, - UNMOUNTED: 3, - CAPACITY: 4 - }, - - FOCUS_MODE_TYPE: { - MANUALLY_TRIGGERED: 'auto', - CONTINUOUS_CAMERA: 'continuous-picture', - CONTINUOUS_VIDEO: 'continuous-video' - }, - - PROMPT_DELAY: 2000, // The minimum available disk space to start recording a video. RECORD_SPACE_MIN: 1024 * 1024 * 2, diff --git a/apps/camera/js/config/settings.js b/apps/camera/js/config/settings.js index a7954b8ce49a..3bf921b34372 100644 --- a/apps/camera/js/config/settings.js +++ b/apps/camera/js/config/settings.js @@ -17,6 +17,9 @@ module.exports = { healthy: 100 } }, + geolocation: { + promptDelay: 2000 + }, mode: { options: [ { diff --git a/apps/camera/js/controllers/camera.js b/apps/camera/js/controllers/camera.js index 7bac07368d2c..4dc0ade300a0 100644 --- a/apps/camera/js/controllers/camera.js +++ b/apps/camera/js/controllers/camera.js @@ -15,7 +15,6 @@ var bindAll = require('lib/bind-all'); exports = module.exports = function(app) { return new CameraController(app); }; exports.CameraController = CameraController; - /** * Initialize a new `CameraController` * @@ -46,15 +45,14 @@ CameraController.prototype.bindEvents = function() { // don't have to depend directly on camera camera.on('change:videoElapsed', app.firer('camera:recorderTimeUpdate')); camera.on('change:capabilities', this.app.setter('capabilities')); + camera.on('change:focus', this.app.firer('camera:focuschanged')); + camera.on('filesizelimitreached', this.onFileSizeLimitReached); camera.on('configured', app.firer('camera:configured')); camera.on('change:recording', app.setter('recording')); camera.on('shutter', app.firer('camera:shutter')); camera.on('loaded', app.firer('camera:loaded')); camera.on('ready', app.firer('camera:ready')); camera.on('busy', app.firer('camera:busy')); - - // Camera - camera.on('filesizelimitreached', this.onFileSizeLimitReached); camera.on('newimage', this.onNewImage); camera.on('newvideo', this.onNewVideo); @@ -67,6 +65,7 @@ CameraController.prototype.bindEvents = function() { app.on('settings:configured', this.onSettingsConfigured); app.on('change:batteryStatus', this.onBatteryStatusChange); + // Settings settings.recorderProfiles.on('change:selected', this.onRecorderProfileChange); settings.pictureSizes.on('change:selected', this.onPictureSizeChange); settings.flashModes.on('change:selected', this.onFlashModeChange); @@ -281,20 +280,10 @@ CameraController.prototype.setFlashMode = function() { }; CameraController.prototype.onBlur = function() { - var recording = this.camera.get('recording'); - var camera = this.camera; - - if (recording) { - camera.stopRecording(); - } - - this.viewfinder.stopPreview(); - camera.set('previewActive', false); - camera.set('focus', 'none'); - camera.release(); - - this.viewfinder.setPreviewStream(null); - + this.camera.stopRecording(); + this.camera.set('previewActive', false); + this.camera.set('focus', 'none'); + this.camera.release(); debug('torn down'); }; diff --git a/apps/camera/js/controllers/preview-gallery.js b/apps/camera/js/controllers/preview-gallery.js index 114fc1fe6c45..4dc5ced094d4 100644 --- a/apps/camera/js/controllers/preview-gallery.js +++ b/apps/camera/js/controllers/preview-gallery.js @@ -24,9 +24,7 @@ var THUMBNAIL_HEIGHT = 54 * window.devicePixelRatio; * Exports */ -exports = module.exports = function(app) { - return new PreviewGalleryController(app); -}; +module.exports = function(app) { return new PreviewGalleryController(app); }; module.exports.PreviewGalleryController = PreviewGalleryController; function PreviewGalleryController(app) { @@ -40,12 +38,10 @@ function PreviewGalleryController(app) { } PreviewGalleryController.prototype.bindEvents = function() { + this.storage.on('itemdeleted', this.onItemDeleted); this.app.on('preview', this.openPreview); this.app.on('newmedia', this.onNewMedia); this.app.on('blur', this.onBlur); - - this.storage.on('itemdeleted', this.onItemDeleted); - debug('events bound'); }; @@ -77,6 +73,7 @@ PreviewGalleryController.prototype.openPreview = function() { this.view.set('secure-mode', secureMode); this.view.open(); + this.app.set('previewGalleryOpen', true); this.previewItem(); }; @@ -94,6 +91,8 @@ PreviewGalleryController.prototype.closePreview = function() { this.view.destroy(); this.view = null; } + + this.app.set('previewGalleryOpen', false); this.app.emit('previewgallery:closed'); }; @@ -108,7 +107,7 @@ PreviewGalleryController.prototype.onGalleryButtonClick = function() { // The button shouldn't even be visible in this case, but // let's be really sure here. if (this.app.inSecureMode) { return; } - + var MozActivity = window.MozActivity; // Launch the gallery with an activity @@ -142,7 +141,7 @@ PreviewGalleryController.prototype.shareCurrentItem = function() { }; /** - * Delete the current item + * Delete the current item * when the delete button is pressed. * @private */ diff --git a/apps/camera/js/controllers/viewfinder.js b/apps/camera/js/controllers/viewfinder.js index ba41525019f3..a2306ae48f04 100644 --- a/apps/camera/js/controllers/viewfinder.js +++ b/apps/camera/js/controllers/viewfinder.js @@ -7,6 +7,7 @@ define(function(require, exports, module) { var debug = require('debug')('controller:viewfinder'); var bindAll = require('lib/bind-all'); + /** * Exports */ @@ -27,71 +28,170 @@ function ViewfinderController(app) { this.activity = app.activity; this.settings = app.settings; this.viewfinder = app.views.viewfinder; + this.focusRing = app.views.focusRing; this.bindEvents(); this.configure(); debug('initialized'); } +/** + * Initial configuration. + * + * @private + */ ViewfinderController.prototype.configure = function() { this.configureScaleType(); this.configureGrid(); }; +/** + * Configure the viewfinder scale type, + * aspect fill/fit, depending on setting. + * + * @private + */ ViewfinderController.prototype.configureScaleType = function() { var scaleType = this.app.settings.viewfinder.get('scaleType'); this.viewfinder.scaleType = scaleType; debug('set scale type: %s', scaleType); }; +/** + * Show/hide grid depending on currently + * selected option. + * + * @private + */ ViewfinderController.prototype.configureGrid = function() { var grid = this.app.settings.grid.selected('key'); this.viewfinder.set('grid', grid); }; +/** + * Hides the viewfinder frame-grid. + * + * @private + */ ViewfinderController.prototype.hideGrid = function() { this.viewfinder.set('grid', 'off'); }; +/** + * Bind to relavant events. + * + * @private + */ ViewfinderController.prototype.bindEvents = function() { this.app.settings.grid.on('change:selected', this.viewfinder.setter('grid')); this.viewfinder.on('click', this.app.firer('viewfinder:click')); this.viewfinder.on('pinchChange', this.onPinchChange); - this.app.on('camera:configured', this.loadStream); - this.app.on('camera:configured', this.updatePreview); + this.camera.on('zoomchanged', this.onZoomChanged); + this.app.on('camera:focuschanged', this.focusRing.setState); + this.app.on('camera:configured', this.onCameraConfigured); this.app.on('camera:shutter', this.viewfinder.shutter); - this.app.on('settings:opened', this.hideGrid); + this.app.on('previewgallery:closed', this.startStream); + this.app.on('previewgallery:opened', this.stopStream); this.app.on('settings:closed', this.configureGrid); - this.camera.on('zoomChange', this.onZoomChange); + this.app.on('settings:opened', this.hideGrid); + this.app.on('blur', this.stopStream); }; -ViewfinderController.prototype.loadStream = function() { +/** + * Perform required viewfinder configuration + * once the camera has configured. + * + * @private + */ +ViewfinderController.prototype.onCameraConfigured = function() { + this.startStream(); + this.configurePreview(); + this.configureZoom(); + + // BUG: We have to use a 300ms timeout here + // to conceal a Gecko rendering bug whereby the + // video element appears not to have painted the + // newly set dimensions before fading in. + // https://bugzilla.mozilla.org/show_bug.cgi?id=982230 + setTimeout(this.viewfinder.fadeIn, 300); +}; + +/** + * Start the viewfinder stream flowing + * with the current camera configuration. + * + * This indirectly enforces a screen wakelock, + * meaning the device is unable to go to sleep. + * + * We don't want the stream to start flowing if + * the preview-gallery is open, as this prevents + * the device falling asleep. + * + * @private + */ +ViewfinderController.prototype.startStream = function() { + if (this.app.get('previewGalleryOpen')) { return; } this.camera.loadStreamInto(this.viewfinder.els.video); + debug('stream started'); }; -ViewfinderController.prototype.updatePreview = function() { +/** + * Stop the preview stream flowing. + * + * This indirectly removes the wakelock + * that is magically enforced by the + * flowing camera stream. Meaning the + * device is able to go to sleep. + * + * @private + */ +ViewfinderController.prototype.stopStream = function() { + this.viewfinder.stopStream(); + debug('stream stopped'); +}; + +/** + * Configure the size and postion + * of the preview video stream. + * + * @private + */ +ViewfinderController.prototype.configurePreview = function() { var camera = this.app.settings.cameras.selected('key'); var isFrontCamera = camera === 'front'; var sensorAngle = this.camera.getSensorAngle(); - this.viewfinder.updatePreview(this.camera.previewSize(), sensorAngle, - isFrontCamera); - - var enableZoom = this.camera.isZoomSupported() && - this.app.settings.zoom.enabled(); - if (enableZoom) { - this.viewfinder.enableZoom(this.camera.getMinimumZoom(), - this.camera.getMaximumZoom()); - } else { + var previewSize = this.camera.previewSize(); + + this.viewfinder.updatePreview(previewSize, sensorAngle, isFrontCamera); +}; + +/** + * Configures the viewfinder + * to the current camera. + * + * @private + */ +ViewfinderController.prototype.configureZoom = function() { + var zoomSupported = this.camera.isZoomSupported(); + var zoomEnabled = this.app.settings.zoom.enabled(); + var enableZoom = zoomSupported && zoomEnabled; + + if (!enableZoom) { this.viewfinder.disableZoom(); + return; } - // BUG: We have to use a 300ms timeout here - // to conceal a Gecko rendering bug whereby the - // video element appears not to have painted the - // newly set dimensions before fading in. - // https://bugzilla.mozilla.org/show_bug.cgi?id=982230 - setTimeout(this.viewfinder.fadeIn, 300); + var minimumZoom = this.camera.getMinimumZoom(); + var maximumZoom = this.camera.getMaximumZoom(); + + this.viewfinder.enableZoom(minimumZoom, maximumZoom); }; +/** + * Updates the zoom level on the camera + * when the pinch changes. + * + * @private + */ ViewfinderController.prototype.onPinchChange = function(zoom) { this.camera.setZoom(zoom); }; @@ -105,7 +205,7 @@ ViewfinderController.prototype.onPinchChange = function(zoom) { * * @param {Number} zoom */ -ViewfinderController.prototype.onZoomChange = function(zoom) { +ViewfinderController.prototype.onZoomChanged = function(zoom) { var zoomPreviewAdjustment = this.camera.getZoomPreviewAdjustment(); this.viewfinder.setZoomPreviewAdjustment(zoomPreviewAdjustment); this.viewfinder.setZoom(zoom); diff --git a/apps/camera/js/controllers/zoom-bar.js b/apps/camera/js/controllers/zoom-bar.js index 182ba63d2a6f..b4e9f18dfcee 100644 --- a/apps/camera/js/controllers/zoom-bar.js +++ b/apps/camera/js/controllers/zoom-bar.js @@ -32,7 +32,7 @@ function ZoomBarController(app) { ZoomBarController.prototype.bindEvents = function() { this.zoomBar.on('change', this.onChange); - this.camera.on('zoomChange', this.onZoomChange); + this.camera.on('zoomchanged', this.onZoomChanged); this.viewfinder.on('pinchStart', this.onPinchStart); this.viewfinder.on('pinchEnd', this.onPinchEnd); }; @@ -45,7 +45,7 @@ ZoomBarController.prototype.onChange = function(value) { this.camera.setZoom(zoom); }; -ZoomBarController.prototype.onZoomChange = function(zoom) { +ZoomBarController.prototype.onZoomChanged = function(zoom) { var minimumZoom = this.camera.getMinimumZoom(); var maximumZoom = this.camera.getMaximumZoom(); var range = maximumZoom - minimumZoom; diff --git a/apps/camera/js/lib/camera.js b/apps/camera/js/lib/camera.js index e6e02e644d47..79cd82e839ec 100644 --- a/apps/camera/js/lib/camera.js +++ b/apps/camera/js/lib/camera.js @@ -64,6 +64,7 @@ function Camera(options) { * Plugs Video Stream into Video Element. * * @param {Elmement} videoElement + * @public */ Camera.prototype.loadStreamInto = function(videoElement) { debug('loading stream into element'); @@ -86,38 +87,96 @@ Camera.prototype.loadStreamInto = function(videoElement) { debug('stream loaded into video'); }; -Camera.prototype.load = function() { +/** + * Loads the currently selected camera. + * + * There are cases whereby the camera + * may still be 'releasing' its hardware. + * If this is the case we wait for the + * release process to finish, then attempt + * to load again. + * + * @public + */ +Camera.prototype.load = function(done) { debug('load camera'); - // If hardware is still pending for release - // we're not allowed to request a new caemera - if (this.cameraReleasePending) { - debug('camera not loaded: hardware unavailable'); - return; - } var selectedCamera = this.get('selectedCamera'); var loadingNewCamera = selectedCamera !== this.lastLoadedCamera; - this.lastLoadedCamera = selectedCamera; + var self = this; + this.emit('busy'); + // If hardware is still being released + // we're not allowed to request the camera. + if (this.releasing) { + debug('wait for camera release'); + this.once('released', function() { self.load(done); }); + return; + } + + // Don't re-load hardware if selected camera is the same if (this.mozCamera && !loadingNewCamera) { - this.gotCamera(this.mozCamera); + this.configureCamera(this.mozCamera); + debug('camera not changed'); + done(); return; } - // If a camera is already loaded, - // it must be 'released' first. - if (this.mozCamera) { this.release(this.requestCamera); } - else { this.requestCamera(); } + // If a camera is already loaded, it must be 'released' first. + if (this.mozCamera) { + this.release(ready); + } else { + ready(); + } + + function ready() { + self.requestCamera(selectedCamera, done); + self.lastLoadedCamera = selectedCamera; + } }; -Camera.prototype.requestCamera = function() { - var selectedCamera = this.get('selectedCamera'); - navigator.mozCameras.getCamera(selectedCamera, {}, this.gotCamera); +/** + * Requests the mozCamera object, + * then configures it. + * + * @param {String} camera 'front'|'back' + * @private + */ +Camera.prototype.requestCamera = function(camera, done) { + done = done || function() {}; + + var self = this; + navigator.mozCameras.getCamera(camera, {}, onSuccess, onError); + + function onSuccess(mozCamera) { + debug('successfully got mozCamera'); + self.configureCamera(mozCamera); + done(); + } + + function onError(err) { + debug('error requesting camera'); + done(err); + } + + debug('camera requested'); }; -Camera.prototype.gotCamera = function(mozCamera) { - debug('got camera'); +/** + * Configures the newly recieved + * mozCamera object. + * + * Setting the 'cababilities' key + * triggers 'change' callback inside + * the CameraController that sets the + * app up for the new camera. + * + * @param {MozCamera} mozCamera + * @private + */ +Camera.prototype.configureCamera = function(mozCamera) { + debug('configuring camera'); var capabilities = mozCamera.capabilities; this.mozCamera = mozCamera; this.mozCamera.onShutter = this.onShutter; @@ -125,6 +184,7 @@ Camera.prototype.gotCamera = function(mozCamera) { this.mozCamera.onRecorderStateChange = this.onRecorderStateChange; this.configureFocus(capabilities.focusModes); this.set('capabilities', this.formatCapabilities(capabilities)); + debug('configured camera'); }; Camera.prototype.formatCapabilities = function(capabilities) { @@ -229,37 +289,31 @@ Camera.prototype.setFlashMode = function(key) { */ Camera.prototype.release = function(done) { done = done || function() {}; + var self = this; + // Ignore if there is no loaded camera if (!this.mozCamera) { done(); return; } - var self = this; // The hardware is not available during // the release process - this.cameraReleasePending = true; this.mozCamera.release(onSuccess, onError); + this.releasing = true; this.mozCamera = null; function onSuccess() { - self.cameraReleasePending = false; - // If the app is in foreground it reloads the camera - // This is needed in case the user exits and enters - // the application quickly. We have to wait until - // the previous camera has been released to request - // a new one. - if(!document.hidden) { - self.load(); - } + self.releasing = false; + self.emit('released'); debug('successfully released'); done(); } - function onError() { - self.cameraReleasePending = false; + function onError(err) { debug('failed to release hardware'); - done(); + self.releasing = false; + done(err); } }; @@ -836,7 +890,7 @@ Camera.prototype.getZoom = function() { Camera.prototype.setZoom = function(zoom) { this.mozCamera.zoom = zoom; - this.emit('zoomChange', zoom); + this.emit('zoomchanged', zoom); }; Camera.prototype.getZoomPreviewAdjustment = function() { diff --git a/apps/camera/js/lib/dcf.js b/apps/camera/js/lib/dcf.js index c3ad9bffdb67..c5e07f8389e2 100644 --- a/apps/camera/js/lib/dcf.js +++ b/apps/camera/js/lib/dcf.js @@ -10,6 +10,7 @@ define(function(require, exports, module) { */ var asyncStorage = require('asyncStorage'); +var debug = require('debug')('dcf'); var format = require('format'); /** @@ -28,6 +29,7 @@ var dcfConfig = { }; exports.init = function() { + debug('initializing'); asyncStorage.getItem(dcfConfig.key, function(value) { dcfConfigLoaded = true; dcfConfig.seq = value ? value : defaultSeq; @@ -39,6 +41,8 @@ exports.init = function() { exports.createDCFFilename(args.storage, args.type, args.callback); deferredArgs = null; } + + debug('initialized'); }); }; diff --git a/apps/camera/js/lib/geo-location.js b/apps/camera/js/lib/geo-location.js index c79a2f7d02e3..c36afce584e1 100644 --- a/apps/camera/js/lib/geo-location.js +++ b/apps/camera/js/lib/geo-location.js @@ -1,6 +1,12 @@ define(function(require, exports, module) { 'use strict'; +/** + * Dependencies + */ + +var debug = require('debug')('geolocation'); + /** * Locals */ @@ -29,10 +35,12 @@ function GeoLocation() { /** * Watches device location. * + * @public */ GeoLocation.prototype.watch = function() { if (!this.watcher) { this.watcher = geolocation.watchPosition(this.setPosition); + debug('started watching'); } }; @@ -40,16 +48,19 @@ GeoLocation.prototype.watch = function() { * Stops watching * device location. * + * @public */ GeoLocation.prototype.stopWatching = function() { geolocation.clearWatch(this.watcher); this.watcher = null; + debug('stopped watching'); }; /** * Updates the stored * position object. * + * @private */ GeoLocation.prototype.setPosition = function(position) { this.position = { diff --git a/apps/camera/js/lib/lock-screen.js b/apps/camera/js/lib/lock-screen.js deleted file mode 100644 index 0d0148b5016f..000000000000 --- a/apps/camera/js/lib/lock-screen.js +++ /dev/null @@ -1,35 +0,0 @@ -define(function(require, exports, module) { -'use strict'; - -/** - * Locals - */ - -var screenLock; - -/** - * Stops the device - * from going to sleep. - * - */ -exports.disableTimeout = function() { - if (!screenLock) { - screenLock = navigator.requestWakeLock('screen'); - } -}; - -/** - * Removes the wake lock - * meaning the device will - * once again sleep after - * usual timeout. - * - */ -exports.enableTimeout = function() { - if (screenLock) { - screenLock.unlock(); - screenLock = null; - } -}; - -}); diff --git a/apps/camera/js/lib/storage.js b/apps/camera/js/lib/storage.js index 6638e8a57a00..e04b2e4d926f 100644 --- a/apps/camera/js/lib/storage.js +++ b/apps/camera/js/lib/storage.js @@ -5,9 +5,15 @@ define(function(require, exports, module) { * Dependencies */ -var createFilename = require('lib/dcf').createDCFFilename; var debug = require('debug')('storage'); var events = require('vendor/evt'); +var dcf = require('lib/dcf'); + +/** + * Locals + */ + +var createFilename = dcf.createDCFFilename; /** * Expose `Storage` @@ -26,6 +32,7 @@ function Storage() { this.image = navigator.getDeviceStorage('pictures'); this.image.addEventListener('change', this.onStorageChange); this.createVideoFilepath = this.createVideoFilepath.bind(this); + dcf.init(); debug('initialized'); } diff --git a/apps/camera/js/views/viewfinder.js b/apps/camera/js/views/viewfinder.js index 31985313323e..dd0dea360ba4 100644 --- a/apps/camera/js/views/viewfinder.js +++ b/apps/camera/js/views/viewfinder.js @@ -169,7 +169,7 @@ module.exports = View.extend({ * pinch-to-zoom gestures can correctly adjust the current zoom * level in the event that the zoom level is changed outside of * the pinch-to-zoom gesture (e.g.: ZoomBar). This gets called - * when the `Camera` emits a `zoomChange` event. + * when the `Camera` emits a `zoomchanged` event. */ setZoom: function(zoom) { if (!isZoomEnabled) { @@ -182,28 +182,15 @@ module.exports = View.extend({ /** * Adjust the scale of the