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

Commit

Permalink
Merge pull request #17623 from justindarc/camera-new-features+bug988118
Browse files Browse the repository at this point in the history
Bug 988118 - Gaia unit test failures on TBPL due to the camera merge
  • Loading branch information
dmarcos committed Mar 26, 2014
2 parents b3c9800 + 7c0d5d0 commit e328318
Show file tree
Hide file tree
Showing 101 changed files with 7,261 additions and 1,912 deletions.
9 changes: 8 additions & 1 deletion apps/camera/build/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@ var utils = require('utils');
var config = require('./customizeConfig.js');
var DEFAULT_VALUE = {
maxImagePixelSize: 5 * 1024 * 1024,
maxSnapshotPixelSize: 5 * 1024 * 1024
maxSnapshotPixelSize: 5 * 1024 * 1024,

// An estimated JPEG compression ratio expected from an average photo. Use
// a default assumption of 8:1 compression for high quality. This default
// value is derived from sample images taken with a variety of devices.
//
// Reference: http://en.wikipedia.org/wiki/JPEG#Effects_of_JPEG_compression
avgJpegCompressionRatio: 8
};
var CameraAppBuilder = function() {
};
Expand Down
9 changes: 6 additions & 3 deletions apps/camera/build/customizeConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ function customizeMaximumImageSize(customize) {
'//\n' +
'// {\n' +
'// "maxImagePixelSize": 6000000,\n' +
'// "maxSnapshotPixelSize": 4000000 }\n' +
'// "maxSnapshotPixelSize": 4000000, \n' +
'// "avgJpegCompressionRatio": 24 \n' +
'// }\n' +
'//\n' +
'// Optionally, you can also define variables to specify the\n' +
Expand All @@ -26,7 +27,9 @@ function customizeMaximumImageSize(customize) {
'var CONFIG_MAX_IMAGE_PIXEL_SIZE = ' +
customize.maxImagePixelSize + ';\n' +
'var CONFIG_MAX_SNAPSHOT_PIXEL_SIZE = ' +
customize.maxSnapshotPixelSize + ';\n';
customize.maxSnapshotPixelSize + ';\n' +
'var CONFIG_AVG_JPEG_COMPRESSION_RATIO = ' +
customize.avgJpegCompressionRatio + ';\n';

if (customize.requiredEXIFPreviewSize) {
content +=
Expand All @@ -42,4 +45,4 @@ function customizeMaximumImageSize(customize) {
return content;
}

exports.customizeMaximumImageSize = customizeMaximumImageSize;
exports.customizeMaximumImageSize = customizeMaximumImageSize;
17 changes: 1 addition & 16 deletions apps/camera/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
-->

<!-- <script defer src="/shared/js/l10n.js"></script> -->
<!-- <script defer src="/shared/js/l10n_date.js"></script> -->
<!-- <script defer src="/shared/js/lazy_l10n.js"></script> -->
<!-- <script defer src="/shared/js/async_storage.js"></script> -->
<!-- <script defer src="/shared/js/media/jpeg_metadata_parser.js"></script> -->
<!-- <script defer src="/shared/js/media/get_video_rotation.js"></script> -->
Expand All @@ -28,20 +26,7 @@

<link rel="stylesheet" type="text/css" href="style/main.css" />
</head>
<body class="filmstriphidden">

<!-- see filmstrip.js and filmstrip.css for these elements -->
<div id="filmstrip" class="filmstrip"></div>
<div id="preview" class="preview offscreen">
<div id="frame-container" class="frame-container"> <!-- media frame rotates inside this -->
<div id="media-frame" class="media-frame"></div> <!-- image or video here -->
</div>
<footer id="preview-controls" class="preview-controls"> <!-- camera, delete, share buttons -->
<a id="camera-button" class="camera-button button"></a>
<a id="delete-button" class="delete-button button"></a>
<a id="share-button" class="share-button button"></a>
</footer>
</div>
<body>
<script src="js/startup.js"></script>
</body>
</html>
71 changes: 37 additions & 34 deletions apps/camera/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ define(function(require, exports, module) {

var performanceTesting = require('performanceTesting');
var ViewfinderView = require('views/viewfinder');
var RecordingTimerView = require('views/recording-timer');
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 broadcast = require('lib/broadcast');
var bindAll = require('lib/bind-all');
var model = require('vendor/model');
var debug = require('debug')('app');
var LazyL10n = require('LazyL10n');
var HudView = require('views/hud');
var bind = require('lib/bind');
var dcf = require('lib/dcf');
Expand Down Expand Up @@ -56,7 +56,6 @@ function App(options) {
this.inSecureMode = (this.win.location.hash === '#secure');
this.controllers = options.controllers;
this.geolocation = options.geolocation;
this.filmstrip = options.filmstrip;
this.activity = options.activity;
this.config = options.config;
this.settings = options.settings;
Expand All @@ -79,6 +78,7 @@ App.prototype.boot = function() {
this.injectViews();
this.bindEvents();
this.miscStuff();
this.l10n();
this.emit('boot');
debug('booted');
};
Expand All @@ -100,32 +100,42 @@ App.prototype.teardown = function() {
*/
App.prototype.runControllers = function() {
debug('running controllers');
this.filmstrip = this.filmstrip(this);
this.controllers.settings(this);
this.controllers.activity(this);
this.controllers.timer(this);
this.controllers.camera(this);
this.controllers.viewfinder(this);
this.controllers.recordingTimer(this);
this.controllers.indicators(this);
this.controllers.previewGallery(this);
this.controllers.controls(this);
this.controllers.confirm(this);
this.controllers.overlay(this);
this.controllers.sounds(this);
this.controllers.hud(this);
this.controllers.zoomBar(this);
debug('controllers run');
};

App.prototype.initializeViews = function() {
debug('initializing views');
this.views.viewfinder = new ViewfinderView();
this.views.controls = new ControlsView();
this.views.recordingTimer = new RecordingTimerView();
this.views.focusRing = new FocusRing();
this.views.controls = new ControlsView();
this.views.hud = new HudView();
this.views.zoomBar = new ZoomBarView();
debug('views initialized');
};

App.prototype.injectViews = function() {
this.views.hud.appendTo(this.el);
this.views.controls.appendTo(this.el);
debug('injecting views');
this.views.viewfinder.appendTo(this.el);
this.views.recordingTimer.appendTo(this.el);
this.views.focusRing.appendTo(this.el);
this.views.controls.appendTo(this.el);
this.views.hud.appendTo(this.el);
this.views.zoomBar.appendTo(this.el);
debug('views injected');
};

Expand All @@ -138,9 +148,10 @@ App.prototype.bindEvents = function() {
bind(this.doc, 'visibilitychange', this.onVisibilityChange);
bind(this.win, 'beforeunload', this.onBeforeUnload);
bind(this.el, 'click', this.onClick);
//this.on('change', this.onStateChange);
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');
};

Expand Down Expand Up @@ -227,6 +238,23 @@ App.prototype.onBeforeUnload = function() {
debug('beforeunload');
};

/**
* Initialize l10n 'localized' listener.
*
* Sometimes it may have completed
* before we reach this point, meaning
* we will have missed the 'localized'
* event. In this case, we emit the
* 'localized' event manually.
*
* @private
*/
App.prototype.l10n = function() {
var complete = navigator.mozL10n.readyState === 'complete';
bind(this.win, 'localized', this.firer('localized'));
if (complete) { this.emit('localized'); }
};

/**
* Miscalaneous tasks to be
* run when the app first
Expand Down Expand Up @@ -256,38 +284,13 @@ App.prototype.miscStuff = function() {
});


if (!navigator.mozCameras) {
// TODO: Need to clarify what we
// should do in this condition.
}

dcf.init();
performanceTesting.dispatch('initialising-camera-preview');

// Prevent the phone
// from going to sleep.
lockscreen.disableTimeout();

// This must be tidied, but the
// important thing is it's out
// of camera.js
LazyL10n.get(function() {
dcf.init();
performanceTesting.dispatch('startup-path-done');
});

// The screen wakelock should be on
// at all times except when the
// filmstrip preview is shown.
broadcast.on('filmstripItemPreview', function() {
lockscreen.enableTimeout();
});

// When the filmstrip preview is hidden
// we can enable the again.
broadcast.on('filmstripPreviewHide', function() {
lockscreen.disableTimeout();
});

debug('misc stuff done');
};

Expand Down
Loading

0 comments on commit e328318

Please sign in to comment.