Revert "Scan handling"

This commit is contained in:
Matias Alejo Garcia 2016-10-22 23:28:24 -03:00 committed by GitHub
commit 641091e7d9
25 changed files with 129 additions and 511 deletions

View file

@ -15,7 +15,6 @@ angular.module('copayApp.controllers').controller('confirmController', function(
$scope.toEmail = data.stateParams.toEmail;
$scope.description = data.stateParams.description;
$scope.paypro = data.stateParams.paypro;
$scope._paypro = $scope.paypro;
$scope.paymentExpired = {
value: false
};
@ -26,6 +25,13 @@ angular.module('copayApp.controllers').controller('confirmController', function(
});
var initConfirm = function() {
if ($scope.paypro) {
return setFromPayPro($scope.paypro, function(err) {
if (err && !isChromeApp) {
popupService.showAlert(gettext('Could not fetch payment'));
}
});
}
// TODO (URL , etc)
if (!$scope.toAddress || !$scope.toAmount) {
$log.error('Bad params at amount');
@ -94,10 +100,6 @@ angular.module('copayApp.controllers').controller('confirmController', function(
$scope.alternativeAmountStr = v;
});
if($scope.paypro) {
_paymentTimeControl($scope.paypro.expires);
}
$timeout(function() {
$scope.$apply();
}, 100);
@ -147,6 +149,56 @@ angular.module('copayApp.controllers').controller('confirmController', function(
return amountStr.split(' ')[1];
}
var setFromPayPro = function(uri, cb) {
if (!cb) cb = function() {};
var wallet = profileService.getWallets({
onlyComplete: true
})[0];
if (!wallet) return cb();
if (isChromeApp) {
popupService.showAlert(gettextCatalog.getString('Payment Protocol not supported on Chrome App'));
return cb(true);
}
$log.debug('Fetch PayPro Request...', uri);
ongoingProcess.set('fetchingPayPro', true);
wallet.fetchPayPro({
payProUrl: uri,
}, function(err, paypro) {
ongoingProcess.set('fetchingPayPro', false);
if (err) {
$log.warn('Could not fetch payment request:', err);
var msg = err.toString();
if (msg.match('HTTP')) {
msg = gettextCatalog.getString('Could not fetch payment information');
}
popupService.showAlert(msg);
return cb(true);
}
if (!paypro.verified) {
$log.warn('Failed to verify payment protocol signatures');
popupService.showAlert(gettextCatalog.getString('Payment Protocol Invalid'));
return cb(true);
}
$scope.toAmount = paypro.amount;
$scope.toAddress = paypro.toAddress;
$scope.description = paypro.memo;
$scope.paypro = null;
$scope._paypro = paypro;
_paymentTimeControl(paypro.expires);
return initConfirm();
});
};
function _paymentTimeControl(expirationTime) {
$scope.paymentExpired.value = false;
setExpirationTime();
@ -167,7 +219,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
var m = Math.floor(totalSecs / 60);
var s = totalSecs % 60;
$scope.remainingTimeStr.value = ('0' + m).slice(-2) + ":" + ('0' + s).slice(-2);
}
};
function setExpiredValues() {
$scope.paymentExpired.value = true;
@ -176,8 +228,8 @@ angular.module('copayApp.controllers').controller('confirmController', function(
$timeout(function() {
$scope.$apply();
});
}
}
};
};
function setWallet(wallet, delayed) {
var stop;
@ -205,7 +257,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
});
}, delayed ? 2000 : 1);
}
}
};
var setSendError = function(msg) {
$scope.sendStatus = '';
@ -242,7 +294,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
var msg = 'Amount too big';
$log.warn(msg);
return setSendError(msg);
}
};
outputs.push({
'toAddress': toAddress,
@ -261,9 +313,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
txp.outputs = outputs;
txp.message = description;
if(paypro) {
txp.payProUrl = paypro.url;
}
txp.payProUrl = paypro;
txp.excludeUnconfirmedUtxos = config.spendUnconfirmed ? false : true;
txp.feeLevel = config.settings && config.settings.feeLevel ? config.settings.feeLevel : 'normal';
txp.dryRun = dryRun;
@ -299,7 +349,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
var wallet = $scope.wallet;
if (!wallet) {
return setSendError(gettextCatalog.getString('No wallet selected'));
}
};
if (!wallet.canSign() && !wallet.isPrivKeyExternal()) {
$log.info('No signing proposal: No private key');

View file

@ -58,7 +58,6 @@ angular.module('copayApp.controllers').controller('tabScanController', function(
$scope.$on("$ionicView.afterEnter", function() {
// try initializing and refreshing status any time the view is entered
scannerService.gentleInitialize();
scannerService.resumePreview();
});
function activate(){
@ -96,15 +95,9 @@ angular.module('copayApp.controllers').controller('tabScanController', function(
function handleSuccessfulScan(contents){
$log.debug('Scan returned: "' + contents + '"');
scannerService.pausePreview();
incomingData.redir(contents);
}
$rootScope.$on('incomingDataMenu.menuHidden', function() {
scannerService.resumePreview();
activate();
});
$scope.openSettings = function(){
scannerService.openSettings();
};
@ -133,7 +126,7 @@ angular.module('copayApp.controllers').controller('tabScanController', function(
$scope.canGoBack = function(){
return $state.params.passthroughMode;
};
}
function goBack(){
$ionicHistory.nextViewOptions({
disableAnimate: true

View file

@ -61,7 +61,7 @@ angular.module('copayApp.controllers').controller('tabSendController', function(
$scope.openScanner = function() {
$state.go('tabs.scan');
};
}
$scope.showMore = function() {
currentContactsPage++;