From 5986daf1404f44eb8b08fe3bf93dfc2632b3ea51 Mon Sep 17 00:00:00 2001 From: Gustavo Maximiliano Cortez Date: Mon, 11 Jan 2016 10:29:45 -0300 Subject: [PATCH 1/5] Speed up QR code scanner for iOS --- cordova/build.sh | 6 ++++ package.json | 4 ++- src/js/controllers/walletHome.js | 3 +- src/js/directives/qrScanner.js | 52 ++++++++++++++++++-------------- 4 files changed, 39 insertions(+), 26 deletions(-) diff --git a/cordova/build.sh b/cordova/build.sh index 40c36aa6f..4a658fb5d 100755 --- a/cordova/build.sh +++ b/cordova/build.sh @@ -87,6 +87,9 @@ if [ ! -d $PROJECT ]; then cordova plugin add https://github.com/phonegap/phonegap-plugin-barcodescanner.git checkOK + cordova plugin add https://github.com/tjwoon/csZBar.git + checkOK + cordova plugin add cordova-plugin-splashscreen checkOK @@ -138,6 +141,9 @@ if [ ! -d $PROJECT ]; then cordova plugin add cordova-ios-requires-fullscreen checkOK + cordova plugin add cordova-plugin-disable-bitcode + checkOK + fi if $DBGJS diff --git a/package.json b/package.json index 7ed8e425a..403e65533 100644 --- a/package.json +++ b/package.json @@ -64,6 +64,7 @@ "angular": "^1.3.14", "angular-mocks": "^1.3.14", "bhttp": "^1.2.1", + "cordova": "^5.4.1", "grunt-karma": "^0.10.1", "grunt-karma-coveralls": "^2.5.3", "grunt-node-webkit-builder": "^1.0.2", @@ -71,6 +72,7 @@ "karma-cli": "0.0.4", "karma-coverage": "^0.2.7", "karma-jasmine": "^0.3.5", - "karma-phantomjs-launcher": "^0.1.4" + "karma-phantomjs-launcher": "^0.1.4", + "xcode": "^0.8.2" } } diff --git a/src/js/controllers/walletHome.js b/src/js/controllers/walletHome.js index c27076b7a..c17519eec 100644 --- a/src/js/controllers/walletHome.js +++ b/src/js/controllers/walletHome.js @@ -1,6 +1,6 @@ '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; $rootScope.hideMenuBar = false; @@ -24,7 +24,6 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi this.blockUx = false; this.isRateAvailable = false; this.showScanner = false; - this.isMobile = isMobile.any(); this.addr = {}; this.lockedCurrentFeePerKb = null; diff --git a/src/js/directives/qrScanner.js b/src/js/directives/qrScanner.js index 0ba7ae2a9..b711102f1 100644 --- a/src/js/directives/qrScanner.js +++ b/src/js/directives/qrScanner.js @@ -1,36 +1,42 @@ 'use strict'; angular.module('copayApp.directives') - .directive('qrScanner', ['$rootScope', '$timeout', '$modal', 'isCordova', 'gettextCatalog', - function($rootScope, $timeout, $modal, isCordova, gettextCatalog) { + .directive('qrScanner', ['$rootScope', '$timeout', '$modal', 'isCordova', 'gettextCatalog', 'isMobile', + function($rootScope, $timeout, $modal, isCordova, gettextCatalog, isMobile) { var controller = function($scope) { + var onSuccess = function(result) { + $timeout(function() { + window.plugins.spinnerDialog.hide(); + window.ignoreMobilePause = false; + }, 100); + if (!isMobile.iOS() && result.cancelled) return; + + $timeout(function() { + var data = isMobile.iOS() ? result : result.text; + $scope.onScan({ data: data }); + }, 1000); + }; + + var onError = function() { + function onError(error) { + $timeout(function() { + window.ignoreMobilePause = false; + window.plugins.spinnerDialog.hide(); + }, 100); + } + }; + $scope.cordovaOpenScanner = function() { window.ignoreMobilePause = true; window.plugins.spinnerDialog.show(null, gettextCatalog.getString('Preparing camera...'), true); $timeout(function() { - cordova.plugins.barcodeScanner.scan( - function onSuccess(result) { - $timeout(function() { - window.plugins.spinnerDialog.hide(); - window.ignoreMobilePause = false; - }, 100); - if (result.cancelled) return; - - $timeout(function() { - var data = result.text; - $scope.onScan({ data: data }); - }, 1000); - }, - function onError(error) { - $timeout(function() { - window.ignoreMobilePause = false; - window.plugins.spinnerDialog.hide(); - }, 100); - alert('Scanning error'); - } - ); + if (isMobile.iOS()) { + cloudSky.zBar.scan({}, onSuccess, onError) + } else { + cordova.plugins.barcodeScanner.scan(onSuccess, onError); + } if ($scope.beforeScan) { $scope.beforeScan(); } From c5ae5d47c30c32549d84f73b8a2cd2788476db87 Mon Sep 17 00:00:00 2001 From: Gustavo Maximiliano Cortez Date: Mon, 11 Jan 2016 10:56:14 -0300 Subject: [PATCH 2/5] Fix Android duplicated plugin --- cordova/build.sh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/cordova/build.sh b/cordova/build.sh index 4a658fb5d..0bcbe3bc9 100755 --- a/cordova/build.sh +++ b/cordova/build.sh @@ -84,11 +84,14 @@ if [ ! -d $PROJECT ]; then cordova plugin add https://github.com/florentvaldelievre/virtualartifacts-webIntent.git checkOK - cordova plugin add https://github.com/phonegap/phonegap-plugin-barcodescanner.git - checkOK - - cordova plugin add https://github.com/tjwoon/csZBar.git - checkOK + if [ $CURRENT_OS == "IOS" ] + then + cordova plugin add https://github.com/tjwoon/csZBar.git + checkOK + else + cordova plugin add https://github.com/phonegap/phonegap-plugin-barcodescanner.git + checkOK + fi cordova plugin add cordova-plugin-splashscreen checkOK From a90503ac175216ed6836c4d94e03e3da08cccf33 Mon Sep 17 00:00:00 2001 From: Gustavo Maximiliano Cortez Date: Mon, 11 Jan 2016 11:43:34 -0300 Subject: [PATCH 3/5] Adds new plugin for Android. Fix cancel --- cordova/build.sh | 21 ++++++++++++--------- src/js/directives/qrScanner.js | 20 +++++++++----------- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/cordova/build.sh b/cordova/build.sh index 0bcbe3bc9..b2f7f9a01 100755 --- a/cordova/build.sh +++ b/cordova/build.sh @@ -84,7 +84,7 @@ if [ ! -d $PROJECT ]; then cordova plugin add https://github.com/florentvaldelievre/virtualartifacts-webIntent.git checkOK - if [ $CURRENT_OS == "IOS" ] + if [ $CURRENT_OS != "WP8" ] then cordova plugin add https://github.com/tjwoon/csZBar.git checkOK @@ -135,17 +135,20 @@ if [ ! -d $PROJECT ]; then cordova plugin add cordova-plugin-file@3.0.0 checkOK - cordova plugin add cordova-plugin-touch-id && cordova prepare - checkOK + if [ $CURRENT_OS == "IOS" ] + then + cordova plugin add cordova-plugin-touch-id && cordova prepare + checkOK - cordova plugin add cordova-plugin-transport-security - checkOK + cordova plugin add cordova-plugin-transport-security + checkOK - cordova plugin add cordova-ios-requires-fullscreen - checkOK + cordova plugin add cordova-ios-requires-fullscreen + checkOK - cordova plugin add cordova-plugin-disable-bitcode - checkOK + cordova plugin add cordova-plugin-disable-bitcode + checkOK + fi fi diff --git a/src/js/directives/qrScanner.js b/src/js/directives/qrScanner.js index b711102f1..e62bfd8bd 100644 --- a/src/js/directives/qrScanner.js +++ b/src/js/directives/qrScanner.js @@ -11,29 +11,27 @@ angular.module('copayApp.directives') window.plugins.spinnerDialog.hide(); window.ignoreMobilePause = false; }, 100); - if (!isMobile.iOS() && result.cancelled) return; + if (isMobile.Windows() && result.cancelled) return; $timeout(function() { - var data = isMobile.iOS() ? result : result.text; + var data = isMobile.Windows() ? result.text : result; $scope.onScan({ data: data }); }, 1000); }; - var onError = function() { - function onError(error) { - $timeout(function() { - window.ignoreMobilePause = false; - window.plugins.spinnerDialog.hide(); - }, 100); - } + var onError = function(error) { + $timeout(function() { + window.ignoreMobilePause = false; + window.plugins.spinnerDialog.hide(); + }, 100); }; $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) + if (!isMobile.Windows()) { + cloudSky.zBar.scan({}, onSuccess, onError); } else { cordova.plugins.barcodeScanner.scan(onSuccess, onError); } From 26a53c79bb620881e49ce43f064bd36ff11def2f Mon Sep 17 00:00:00 2001 From: Gustavo Maximiliano Cortez Date: Mon, 11 Jan 2016 11:59:14 -0300 Subject: [PATCH 4/5] Fix Android beep --- Makefile | 3 --- cordova/build.sh | 19 ++++++++----------- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index 11f6cef37..535b3bb5a 100644 --- a/Makefile +++ b/Makefile @@ -53,7 +53,6 @@ ios-debug: android-prod: cordova/build.sh ANDROID --clear - cp ./etc/beep.ogg ./cordova/project/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/res/raw/beep.ogg cd cordova/project && cordova build android --release jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore ../copay.keystore -signedjar cordova/project/platforms/android/build/outputs/apk/android-release-signed.apk cordova/project/platforms/android/build/outputs/apk/android-release-unsigned.apk copay_play ../android-sdk-macosx/build-tools/21.1.1/zipalign -v 4 cordova/project/platforms/android/build/outputs/apk/android-release-signed.apk cordova/project/platforms/android/build/outputs/apk/android-release-signed-aligned.apk @@ -61,10 +60,8 @@ android-prod: android-debug: cordova/build.sh ANDROID --dbgjs --clear - cp ./etc/beep.ogg ./cordova/project/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/res/raw/beep.ogg cd cordova/project && cordova run android android-debug-fast: cordova/build.sh ANDROID --dbgjs - cp ./etc/beep.ogg ./cordova/project/plugins/phonegap-plugin-barcodescanner/src/android/LibraryProject/res/raw/beep.ogg cd cordova/project && cordova run android diff --git a/cordova/build.sh b/cordova/build.sh index b2f7f9a01..330b7e5f9 100755 --- a/cordova/build.sh +++ b/cordova/build.sh @@ -135,20 +135,17 @@ if [ ! -d $PROJECT ]; then cordova plugin add cordova-plugin-file@3.0.0 checkOK - if [ $CURRENT_OS == "IOS" ] - then - cordova plugin add cordova-plugin-touch-id && cordova prepare - checkOK + cordova plugin add cordova-plugin-touch-id && cordova prepare + checkOK - cordova plugin add cordova-plugin-transport-security - checkOK + cordova plugin add cordova-plugin-transport-security + checkOK - cordova plugin add cordova-ios-requires-fullscreen - checkOK + cordova plugin add cordova-ios-requires-fullscreen + checkOK - cordova plugin add cordova-plugin-disable-bitcode - checkOK - fi + cordova plugin add cordova-plugin-disable-bitcode + checkOK fi From 71253e0ed721432a94a4ed093e19ac4f7851912b Mon Sep 17 00:00:00 2001 From: Gustavo Maximiliano Cortez Date: Tue, 12 Jan 2016 11:40:48 -0300 Subject: [PATCH 5/5] Shows warning if using old plugin for WP8 --- cordova/build.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/cordova/build.sh b/cordova/build.sh index 330b7e5f9..54b3ebffb 100755 --- a/cordova/build.sh +++ b/cordova/build.sh @@ -89,6 +89,7 @@ if [ ! -d $PROJECT ]; then cordova plugin add https://github.com/tjwoon/csZBar.git checkOK else + echo "${OpenColor}${Green}* Using plugin phonegap-plugin-barcodescanner for Windows Phone 8 ${CloseColor}" cordova plugin add https://github.com/phonegap/phonegap-plugin-barcodescanner.git checkOK fi