make action sheet come up if non paypro url has been scanned

This commit is contained in:
Marty Alcala 2016-10-14 10:33:36 -04:00
commit 73c3f1853d
5 changed files with 43 additions and 22 deletions

View file

@ -99,9 +99,15 @@ angular.module('copayApp.controllers').controller('tabScanController', function(
function handleSuccessfulScan(contents){ function handleSuccessfulScan(contents){
$log.debug('Scan returned: "' + contents + '"'); $log.debug('Scan returned: "' + contents + '"');
scannerService.pausePreview();
incomingData.redir(contents); incomingData.redir(contents);
} }
$rootScope.$on('incomingDataMenu.menuHidden', function() {
scannerService.resumePreview();
activate();
});
$scope.openSettings = function(){ $scope.openSettings = function(){
scannerService.openSettings(); scannerService.openSettings();
}; };

View file

@ -1,16 +1,20 @@
'use strict'; 'use strict';
angular.module('copayApp.directives') angular.module('copayApp.directives')
.directive('incomingDataMenu', function($timeout) { .directive('incomingDataMenu', function($timeout, $rootScope) {
return { return {
restrict: 'E', restrict: 'E',
templateUrl: 'views/includes/incomingDataMenu.html', templateUrl: 'views/includes/incomingDataMenu.html',
link: function(scope, element, attrs) { link: function(scope, element, attrs) {
console.log('incomingDataMenu constructed'); $rootScope.$on('incomingDataMenu.showMenu', function() {
$timeout(function() {
scope.showMenu = true; scope.showMenu = true;
}, 5000); });
scope.$watch('showMenu', function() {
console.log('scope.showMenu', scope.showMenu);
if(!scope.showMenu) {
$rootScope.$broadcast('incomingDataMenu.menuHidden');
}
});
} }
}; };
}); });

View file

@ -1,10 +1,14 @@
'use strict'; 'use strict';
angular.module('copayApp.services').factory('incomingData', function($log, $ionicModal, $state, $window, $timeout, bitcore, profileService, popupService, ongoingProcess, platformInfo, gettextCatalog) { angular.module('copayApp.services').factory('incomingData', function($log, $ionicModal, $state, $window, $timeout, bitcore, profileService, popupService, ongoingProcess, platformInfo, gettextCatalog, scannerService, $rootScope) {
var root = {}; var root = {};
root.redir = function(data) { root.showMenu = function() {
$rootScope.$broadcast('incomingDataMenu.showMenu');
};
root.redir = function(data, resumeScan) {
$log.debug('Processing incoming data:' +data); $log.debug('Processing incoming data:' +data);
function sanitizeUri(data) { function sanitizeUri(data) {
@ -66,6 +70,7 @@ angular.module('copayApp.services').factory('incomingData', function($log, $ioni
getPayProDetails(data, function(err, details) { getPayProDetails(data, function(err, details) {
if(err) { if(err) {
console.log('getPayProDetails err', err); console.log('getPayProDetails err', err);
root.showMenu();
return; return;
} }
console.log('paypro details', details); console.log('paypro details', details);
@ -143,12 +148,12 @@ angular.module('copayApp.services').factory('incomingData', function($log, $ioni
ongoingProcess.set('fetchingPayPro', false); ongoingProcess.set('fetchingPayPro', false);
if (err) { if (err) {
$log.warn('Could not fetch payment request:', err); // $log.warn('Could not fetch payment request:', err);
var msg = err.toString(); // var msg = err.toString();
if (msg.match('HTTP')) { // if (msg.match('HTTP')) {
msg = gettextCatalog.getString('Could not fetch payment information'); // msg = gettextCatalog.getString('Could not fetch payment information');
} // }
popupService.showAlert(msg); // popupService.showAlert(msg);
return cb(true); return cb(true);
} }

View file

@ -1,9 +1,9 @@
'use strict'; 'use strict';
angular.module('copayApp.services').service('scannerService', function($log, $timeout, platformInfo, $rootScope) { angular.module('copayApp.services').service('scannerService', function($log, $timeout, platformInfo, $rootScope, $window) {
var isDesktop = !platformInfo.isCordova; var isDesktop = !platformInfo.isCordova;
var QRScanner = window.QRScanner; var QRScanner = $window.QRScanner;
var lightEnabled = false; var lightEnabled = false;
var backCamera = true; // the plugin defaults to the back camera var backCamera = true; // the plugin defaults to the back camera
@ -55,8 +55,8 @@ angular.module('copayApp.services').service('scannerService', function($log, $ti
canEnableLight: canEnableLight, canEnableLight: canEnableLight,
canChangeCamera: canChangeCamera, canChangeCamera: canChangeCamera,
canOpenSettings: canOpenSettings canOpenSettings: canOpenSettings
} };
} };
var initializeStarted = false; var initializeStarted = false;
/** /**
@ -123,10 +123,10 @@ angular.module('copayApp.services').service('scannerService', function($log, $ti
} }
this.isInitialized = function(){ this.isInitialized = function(){
return initializeCompleted; return initializeCompleted;
} };
this.initializeStarted = function(){ this.initializeStarted = function(){
return initializeStarted; return initializeStarted;
} };
var nextHide = null; var nextHide = null;
var nextDestroy = null; var nextDestroy = null;
@ -167,6 +167,14 @@ angular.module('copayApp.services').service('scannerService', function($log, $ti
QRScanner.scan(callback); QRScanner.scan(callback);
}; };
this.pausePreview = function() {
QRScanner.pausePreview();
};
this.resumePreview = function() {
QRScanner.resumePreview();
};
/** /**
* Deactivate the QRScanner. To balance user-perceived performance and power * Deactivate the QRScanner. To balance user-perceived performance and power
* consumption, this kicks off a countdown which will "sleep" the scanner * consumption, this kicks off a countdown which will "sleep" the scanner
@ -177,7 +185,7 @@ angular.module('copayApp.services').service('scannerService', function($log, $ti
*/ */
this.deactivate = function(callback) { this.deactivate = function(callback) {
$log.debug('Deactivating scanner...'); $log.debug('Deactivating scanner...');
// QRScanner.cancelScan(); QRScanner.cancelScan();
nextHide = $timeout(_hide, hideAfterSeconds * 1000); nextHide = $timeout(_hide, hideAfterSeconds * 1000);
nextDestroy = $timeout(_destroy, destroyAfterSeconds * 1000); nextDestroy = $timeout(_destroy, destroyAfterSeconds * 1000);
}; };

View file

@ -4,7 +4,5 @@
ng-click="hide()"> ng-click="hide()">
</div> </div>
<div class="bp-action-sheet__sheet" ng-class="{'slide-up': show}"> <div class="bp-action-sheet__sheet" ng-class="{'slide-up': show}">
<!-- <img class="back-arrow" src="img/icon-back-arrow.svg" ng-click="hide()">
<div class="header">Send from</div> -->
<ng-transclude></ng-transclude> <ng-transclude></ng-transclude>
</div> </div>