Speed up QR code scanner for iOS

This commit is contained in:
Gustavo Maximiliano Cortez 2016-01-11 10:29:45 -03:00
parent 5f332a2315
commit 5986daf140
No known key found for this signature in database
GPG Key ID: 15EDAD8D9F2EB1AF
4 changed files with 39 additions and 26 deletions

View File

@ -87,6 +87,9 @@ if [ ! -d $PROJECT ]; then
cordova plugin add https://github.com/phonegap/phonegap-plugin-barcodescanner.git cordova plugin add https://github.com/phonegap/phonegap-plugin-barcodescanner.git
checkOK checkOK
cordova plugin add https://github.com/tjwoon/csZBar.git
checkOK
cordova plugin add cordova-plugin-splashscreen cordova plugin add cordova-plugin-splashscreen
checkOK checkOK
@ -138,6 +141,9 @@ if [ ! -d $PROJECT ]; then
cordova plugin add cordova-ios-requires-fullscreen cordova plugin add cordova-ios-requires-fullscreen
checkOK checkOK
cordova plugin add cordova-plugin-disable-bitcode
checkOK
fi fi
if $DBGJS if $DBGJS

View File

@ -64,6 +64,7 @@
"angular": "^1.3.14", "angular": "^1.3.14",
"angular-mocks": "^1.3.14", "angular-mocks": "^1.3.14",
"bhttp": "^1.2.1", "bhttp": "^1.2.1",
"cordova": "^5.4.1",
"grunt-karma": "^0.10.1", "grunt-karma": "^0.10.1",
"grunt-karma-coveralls": "^2.5.3", "grunt-karma-coveralls": "^2.5.3",
"grunt-node-webkit-builder": "^1.0.2", "grunt-node-webkit-builder": "^1.0.2",
@ -71,6 +72,7 @@
"karma-cli": "0.0.4", "karma-cli": "0.0.4",
"karma-coverage": "^0.2.7", "karma-coverage": "^0.2.7",
"karma-jasmine": "^0.3.5", "karma-jasmine": "^0.3.5",
"karma-phantomjs-launcher": "^0.1.4" "karma-phantomjs-launcher": "^0.1.4",
"xcode": "^0.8.2"
} }
} }

View File

@ -1,6 +1,6 @@
'use strict'; 'use strict';
angular.module('copayApp.controllers').controller('walletHomeController', function($scope, $rootScope, $timeout, $filter, $modal, $log, notification, txStatus, isCordova, profileService, lodash, configService, rateService, storageService, bitcore, isChromeApp, gettext, gettextCatalog, nodeWebkit, addressService, ledger, bwsError, confirmDialog, txFormatService, animationService, addressbookService, go, feeService) { angular.module('copayApp.controllers').controller('walletHomeController', function($scope, $rootScope, $timeout, $filter, $modal, $log, notification, txStatus, isCordova, isMobile, profileService, lodash, configService, rateService, storageService, bitcore, isChromeApp, gettext, gettextCatalog, nodeWebkit, addressService, ledger, bwsError, confirmDialog, txFormatService, animationService, addressbookService, go, feeService) {
var self = this; var self = this;
$rootScope.hideMenuBar = false; $rootScope.hideMenuBar = false;
@ -24,7 +24,6 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
this.blockUx = false; this.blockUx = false;
this.isRateAvailable = false; this.isRateAvailable = false;
this.showScanner = false; this.showScanner = false;
this.isMobile = isMobile.any();
this.addr = {}; this.addr = {};
this.lockedCurrentFeePerKb = null; this.lockedCurrentFeePerKb = null;

View File

@ -1,36 +1,42 @@
'use strict'; 'use strict';
angular.module('copayApp.directives') angular.module('copayApp.directives')
.directive('qrScanner', ['$rootScope', '$timeout', '$modal', 'isCordova', 'gettextCatalog', .directive('qrScanner', ['$rootScope', '$timeout', '$modal', 'isCordova', 'gettextCatalog', 'isMobile',
function($rootScope, $timeout, $modal, isCordova, gettextCatalog) { function($rootScope, $timeout, $modal, isCordova, gettextCatalog, isMobile) {
var controller = function($scope) { var controller = function($scope) {
$scope.cordovaOpenScanner = function() { var onSuccess = function(result) {
window.ignoreMobilePause = true;
window.plugins.spinnerDialog.show(null, gettextCatalog.getString('Preparing camera...'), true);
$timeout(function() {
cordova.plugins.barcodeScanner.scan(
function onSuccess(result) {
$timeout(function() { $timeout(function() {
window.plugins.spinnerDialog.hide(); window.plugins.spinnerDialog.hide();
window.ignoreMobilePause = false; window.ignoreMobilePause = false;
}, 100); }, 100);
if (result.cancelled) return; if (!isMobile.iOS() && result.cancelled) return;
$timeout(function() { $timeout(function() {
var data = result.text; var data = isMobile.iOS() ? result : result.text;
$scope.onScan({ data: data }); $scope.onScan({ data: data });
}, 1000); }, 1000);
}, };
var onError = function() {
function onError(error) { function onError(error) {
$timeout(function() { $timeout(function() {
window.ignoreMobilePause = false; window.ignoreMobilePause = false;
window.plugins.spinnerDialog.hide(); window.plugins.spinnerDialog.hide();
}, 100); }, 100);
alert('Scanning error');
} }
); };
$scope.cordovaOpenScanner = function() {
window.ignoreMobilePause = true;
window.plugins.spinnerDialog.show(null, gettextCatalog.getString('Preparing camera...'), true);
$timeout(function() {
if (isMobile.iOS()) {
cloudSky.zBar.scan({}, onSuccess, onError)
} else {
cordova.plugins.barcodeScanner.scan(onSuccess, onError);
}
if ($scope.beforeScan) { if ($scope.beforeScan) {
$scope.beforeScan(); $scope.beforeScan();
} }