From dd382de0dd850fe7f96209e278104b1f859d184b Mon Sep 17 00:00:00 2001 From: Javier Date: Thu, 2 Jun 2016 11:09:40 -0300 Subject: [PATCH] rebase --- src/js/controllers/disclaimer.js | 7 +- src/js/controllers/modals/customAmount.js | 8 +- src/js/controllers/modals/txpDetails.js | 4 +- src/js/controllers/walletHome.js | 223 ---------------------- src/js/routes.js | 6 +- 5 files changed, 10 insertions(+), 238 deletions(-) diff --git a/src/js/controllers/disclaimer.js b/src/js/controllers/disclaimer.js index 542f5ee8d..9d56c1d26 100644 --- a/src/js/controllers/disclaimer.js +++ b/src/js/controllers/disclaimer.js @@ -1,12 +1,7 @@ 'use strict'; angular.module('copayApp.controllers').controller('disclaimerController', -<<<<<<< e68d1d87ec5d6c817929721a32f43cefc88aa290 - function($scope, $timeout, $log, profileService, applicationService, gettextCatalog, uxLanguage, go) { -======= - function($scope, $timeout, $log, $ionicSideMenuDelegate, profileService, isCordova, applicationService, gettextCatalog, uxLanguage, go) { - ->>>>>>> do not allow drag side bar in disclaimer screen + function($scope, $timeout, $log, $ionicSideMenuDelegate, profileService, applicationService, gettextCatalog, uxLanguage, go) { var self = this; self.tries = 0; $scope.creatingProfile = true; diff --git a/src/js/controllers/modals/customAmount.js b/src/js/controllers/modals/customAmount.js index 8222a1c69..091394bcc 100644 --- a/src/js/controllers/modals/customAmount.js +++ b/src/js/controllers/modals/customAmount.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('copayApp.controllers').controller('customAmountController', function($scope, $timeout, $filter, isCordova, isMobile, rateService) { +angular.module('copayApp.controllers').controller('customAmountController', function($scope, $timeout, $filter, platformInfo, rateService) { var self = $scope.self; $scope.unitName = self.unitName; @@ -12,7 +12,7 @@ angular.module('copayApp.controllers').controller('customAmountController', func $scope.unitDecimals = self.unitDecimals; var satToUnit = 1 / self.unitToSatoshi; $scope.showAlternative = false; - $scope.isCordova = isCordova; + $scope.isCordova = platformInfo.isCordova; Object.defineProperty($scope, "_customAlternative", { @@ -68,8 +68,8 @@ angular.module('copayApp.controllers').controller('customAmountController', func }; $scope.shareAddress = function(uri) { - if (isCordova) { - if (isMobile.Android() || isMobile.Windows()) { + if (platformInfo.isCordova) { + if (platformInfo.isAndroid || platformInfo.isWP) { window.ignoreMobilePause = true; } window.plugins.socialsharing.share(uri, null, null, null); diff --git a/src/js/controllers/modals/txpDetails.js b/src/js/controllers/modals/txpDetails.js index ea021b758..a59289682 100644 --- a/src/js/controllers/modals/txpDetails.js +++ b/src/js/controllers/modals/txpDetails.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('copayApp.controllers').controller('txpDetailsController', function($scope, $rootScope, $timeout, $interval, txStatus, $ionicScrollDelegate, txFormatService, fingerprintService, bwsError, isChromeApp, gettextCatalog, lodash, profileService, walletService) { +angular.module('copayApp.controllers').controller('txpDetailsController', function($scope, $rootScope, $timeout, $interval, platformInfo, txStatus, $ionicScrollDelegate, txFormatService, fingerprintService, bwsError, gettextCatalog, lodash, profileService, walletService) { var self = $scope.self; var tx = $scope.tx; var copayers = $scope.copayers; @@ -131,7 +131,7 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi }; function checkPaypro() { - if (tx.payProUrl && !isChromeApp) { + if (tx.payProUrl && !platformInfo.isChromeApp) { fc.fetchPayPro({ payProUrl: tx.payProUrl, }, function(err, paypro) { diff --git a/src/js/controllers/walletHome.js b/src/js/controllers/walletHome.js index 88d3bbbe9..022e74dd8 100644 --- a/src/js/controllers/walletHome.js +++ b/src/js/controllers/walletHome.js @@ -931,226 +931,3 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi } }); -out(function() { - $rootScope.$digest(); -}, 1); -return cb(true); -} - -self._paypro = paypro; -self.setForm(paypro.toAddress, (paypro.amount * satToUnit).toFixed(self.unitDecimals), paypro.memo); -_paymentTimeControl(paypro.expires); -return cb(); -}); -}, 1); -}; - -function _paymentTimeControl(expirationTime) { - self.paymentExpired = false; - setExpirationTime(); - - self.countDown = $interval(function() { - setExpirationTime(); - }, 1000); - - function setExpirationTime() { - var now = Math.floor(Date.now() / 1000); - if (now > expirationTime) { - setExpiredValues(); - return; - } - - var totalSecs = expirationTime - now; - var m = Math.floor(totalSecs / 60); - var s = totalSecs % 60; - self.remainingTimeStr = ('0' + m).slice(-2) + ":" + ('0' + s).slice(-2); - }; - - function setExpiredValues() { - self.paymentExpired = true; - self.remainingTimeStr = null; - self._paypro = null; - self.error = gettext('Cannot sign: The payment request has expired'); - if (self.countDown) $interval.cancel(self.countDown); - }; -}; - -this.setFromUri = function(uri) { - var self = this; - - function sanitizeUri(uri) { - // Fixes when a region uses comma to separate decimals - var regex = /[\?\&]amount=(\d+([\,\.]\d+)?)/i; - var match = regex.exec(uri); - if (!match || match.length === 0) { - return uri; - } - var value = match[0].replace(',', '.'); - var newUri = uri.replace(regex, value); - return newUri; - }; - - var satToUnit = 1 / this.unitToSatoshi; - - // URI extensions for Payment Protocol with non-backwards-compatible request - if ((/^bitcoin:\?r=[\w+]/).exec(uri)) { - uri = decodeURIComponent(uri.replace('bitcoin:?r=', '')); - this.setFromPayPro(uri, function(err) { - if (err) { - return err; - } - }); - } else { - uri = sanitizeUri(uri); - - if (!bitcore.URI.isValid(uri)) { - return uri; - } - var parsed = new bitcore.URI(uri); - - var addr = parsed.address ? parsed.address.toString() : ''; - var message = parsed.message; - - var amount = parsed.amount ? - (parsed.amount.toFixed(0) * satToUnit).toFixed(this.unitDecimals) : 0; - - - if (parsed.r) { - this.setFromPayPro(parsed.r, function(err) { - if (err && addr && amount) { - self.setForm(addr, amount, message); - return addr; - } - }); - } else { - this.setForm(addr, amount, message); - return addr; - } - } - -}; - -this.onAddressChange = function(value) { - this.resetError(); - if (!value) return ''; - - if (this._paypro) - return value; - - if (value.indexOf('bitcoin:') === 0) { - return this.setFromUri(value); - } else if (/^https?:\/\//.test(value)) { - return this.setFromPayPro(value); - } else { - return value; - } -}; - -// History - -function strip(number) { - return (parseFloat(number.toPrecision(12))); -} - -this.getUnitName = function() { - return this.unitName; -}; - -this.getAlternativeIsoCode = function() { - return this.alternativeIsoCode; -}; - -this.openTxModal = function(tx) { - $rootScope.$emit('Local/TxModal', tx); -}; - -this.hasAction = function(actions, action) { - return actions.hasOwnProperty('create'); -}; - -this.sendMax = function(availableBalanceSat) { - if (availableBalanceSat == 0) { - this.error = gettext("Cannot create transaction. Insufficient funds"); - return; - } - - var self = this; - var fc = profileService.focusedClient; - this.error = null; - this.setOngoingProcess(gettextCatalog.getString('Calculating fee')); - - feeService.getCurrentFeeValue(function(err, feePerKb) { - if (err || !lodash.isNumber(feePerKb)) { - self.setOngoingProcess(); - self.error = gettext('Could not get fee value'); - return; - } - - var opts = {}; - opts.feePerKb = feePerKb; - opts.returnInputs = true; - var config = configService.getSync(); - opts.excludeUnconfirmedUtxos = !config.wallet.spendUnconfirmed; - self.setOngoingProcess(gettextCatalog.getString('Retrieving inputs information')); - - fc.getSendMaxInfo(opts, function(err, resp) { - self.setOngoingProcess(); - if (err) { - self.error = err; - $scope.$apply(); - return; - } - - if (resp.amount == 0) { - self.error = gettext("Not enough funds for fee"); - $scope.$apply(); - return; - } - - var msg = gettextCatalog.getString("{{fee}} will be deducted for bitcoin networking fees", { - fee: profileService.formatAmount(resp.fee) + ' ' + self.unitName - }); - - var warningMsg = verifyExcludedUtxos(); - - if (!lodash.isEmpty(warningMsg)) - msg += '. \n' + warningMsg; - - confirmDialog.show(msg, function(confirmed) { - if (confirmed) { - self.sendMaxInfo = resp; - var amount = parseFloat((resp.amount * self.satToUnit).toFixed(self.unitDecimals)); - self.setForm(null, amount, null); - } else { - self.resetForm(); - } - }); - - function verifyExcludedUtxos() { - var warningMsg = []; - if (resp.utxosBelowFee > 0) { - warningMsg.push(gettextCatalog.getString("Note: a total of {{amountBelowFeeStr}} were excluded. These funds come from UTXOs smaller than the network fee provided.", { - amountBelowFeeStr: profileService.formatAmount(resp.amountBelowFee) + ' ' + self.unitName - })); - } - if (resp.utxosAboveMaxSize > 0) { - warningMsg.push(gettextCatalog.getString("Note: a total of {{amountAboveMaxSizeStr}} were excluded. The maximum size allowed for a transaction was exceeded", { - amountAboveMaxSizeStr: profileService.formatAmount(resp.amountAboveMaxSize) + ' ' + self.unitName - })); - } - return warningMsg.join('\n'); - } - }); - }); -}; - -/* Start setup */ -lodash.assign(self, vanillaScope); - -this.bindTouchDown(); -if (profileService.focusedClient) { - this.setAddress(); - this.setSendFormInputs(); -} - -}); diff --git a/src/js/routes.js b/src/js/routes.js index 1e9629af6..d8d0c92a9 100644 --- a/src/js/routes.js +++ b/src/js/routes.js @@ -20,12 +20,12 @@ angular $urlRouterProvider.otherwise('/'); $logProvider.debugEnabled(true); - $provide.decorator('$log', ['$delegate', 'isDevel', - function($delegate, isDevel) { + $provide.decorator('$log', ['$delegate', 'platformInfo', + function($delegate, platformInfo) { var historicLog = historicLogProvider.$get(); ['debug', 'info', 'warn', 'error', 'log'].forEach(function(level) { - if (isDevel && level == 'error') return; + if (platformInfo.isDevel && level == 'error') return; var orig = $delegate[level]; $delegate[level] = function() {