Merge branch 'ref/design' of https://github.com/bitpay/bitpay-wallet into feature/onboarding_last_steps

# Conflicts:
#	src/js/controllers/backup.js
This commit is contained in:
Jamal Jackson 2016-09-29 14:51:12 -04:00
commit 19a3e9afdc
85 changed files with 1579 additions and 1003 deletions

View file

@ -0,0 +1,113 @@
'use strict';
angular.module('copayApp.controllers').controller('advancedSettingsController', function($scope, $rootScope, $log, $window, lodash, configService, uxLanguage, platformInfo, pushNotificationsService, profileService, feeService) {
var updateConfig = function() {
var config = configService.getSync();
$scope.spendUnconfirmed = {
value: config.wallet.spendUnconfirmed
};
$scope.bitpayCardEnabled = {
value: config.bitpayCard.enabled
};
$scope.amazonEnabled = {
value: config.amazon.enabled
};
$scope.glideraEnabled = {
value: config.glidera.enabled
};
$scope.coinbaseEnabled = {
value: config.coinbase.enabled
};
$scope.recentTransactionsEnabled = {
value: config.recentTransactions.enabled
};
$scope.frequentlyUsedEnabled = {
value: config.frequentlyUsed.enabled
};
};
$scope.spendUnconfirmedChange = function() {
var opts = {
wallet: {
spendUnconfirmed: $scope.spendUnconfirmed.value
}
};
configService.set(opts, function(err) {
if (err) $log.debug(err);
});
};
$scope.bitpayCardChange = function() {
var opts = {
bitpayCard: {
enabled: $scope.bitpayCardEnabled.value
}
};
configService.set(opts, function(err) {
if (err) $log.debug(err);
});
};
$scope.amazonChange = function() {
var opts = {
amazon: {
enabled: $scope.amazonEnabled.value
}
};
configService.set(opts, function(err) {
if (err) $log.debug(err);
});
};
$scope.glideraChange = function() {
var opts = {
glidera: {
enabled: $scope.glideraEnabled.value
}
};
configService.set(opts, function(err) {
if (err) $log.debug(err);
});
};
$scope.coinbaseChange = function() {
var opts = {
coinbase: {
enabled: $scope.coinbaseEnabled.value
}
};
configService.set(opts, function(err) {
if (err) $log.debug(err);
});
};
$scope.recentTransactionsChange = function() {
var opts = {
recentTransactions: {
enabled: $scope.recentTransactionsEnabled.value
}
};
configService.set(opts, function(err) {
if (err) $log.debug(err);
});
};
$scope.frequentlyUsedChange = function() {
var opts = {
frequentlyUsed: {
enabled: $scope.frequentlyUsedEnabled.value
}
};
configService.set(opts, function(err) {
if (err) $log.debug(err);
});
};
$scope.$on("$ionicView.enter", function(event, data) {
updateConfig();
});
});

View file

@ -1,6 +1,6 @@
'use strict';
angular.module('copayApp.controllers').controller('amountController', function($rootScope, $scope, $filter, $timeout, $ionicScrollDelegate, gettextCatalog, platformInfo, lodash, configService, rateService, $stateParams, $window, $state, $log, txFormatService) {
angular.module('copayApp.controllers').controller('amountController', function($rootScope, $scope, $filter, $timeout, $ionicScrollDelegate, gettextCatalog, platformInfo, lodash, configService, rateService, $stateParams, $window, $state, $log, txFormatService, ongoingProcess, bitpayCardService, popupService) {
var unitToSatoshi;
var satToUnit;
@ -10,18 +10,20 @@ angular.module('copayApp.controllers').controller('amountController', function($
var SMALL_FONT_SIZE_LIMIT = 13;
var LENGTH_EXPRESSION_LIMIT = 19;
$scope.isWallet = $stateParams.isWallet;
$scope.toAddress = $stateParams.toAddress;
$scope.toName = $stateParams.toName;
$scope.toEmail = $stateParams.toEmail;
$scope.$on('$ionicView.beforeLeave', function() {
$scope.$on('$ionicView.leave', function() {
angular.element($window).off('keydown');
});
$scope.$on("$ionicView.beforeEnter", function(event, data) {
if (!$stateParams.toAddress) {
$scope.isWallet = data.stateParams.isWallet;
$scope.isCard = data.stateParams.isCard;
$scope.toAddress = data.stateParams.toAddress;
$scope.toName = data.stateParams.toName;
$scope.toEmail = data.stateParams.toEmail;
$scope.showAlternativeAmount = !!$scope.isCard;
if (!$scope.isCard && !$stateParams.toAddress) {
$log.error('Bad params at amount')
throw ('bad params');
}
@ -60,6 +62,8 @@ angular.module('copayApp.controllers').controller('amountController', function($
satToBtc = 1 / 100000000;
unitDecimals = config.unitDecimals;
$scope.resetAmount();
// in SAT ALWAYS
if ($stateParams.toAmount) {
$scope.amount = (($stateParams.toAmount) * satToUnit).toFixed(unitDecimals);
@ -69,7 +73,7 @@ angular.module('copayApp.controllers').controller('amountController', function($
$timeout(function() {
$ionicScrollDelegate.resize();
}, 100);
}, 10);
});
$scope.toggleAlternative = function() {
@ -95,7 +99,6 @@ angular.module('copayApp.controllers').controller('amountController', function($
};
$scope.pushOperator = function(operator) {
console.log('[amount.js.90:operator:]', operator); //TODO
if (!$scope.amount || $scope.amount.length == 0) return;
$scope.amount = _pushOperator($scope.amount);
@ -183,14 +186,50 @@ angular.module('copayApp.controllers').controller('amountController', function($
$scope.finish = function() {
var _amount = evaluate(format($scope.amount));
var amount = $scope.showAlternativeAmount ? fromFiat(_amount).toFixed(unitDecimals) : _amount.toFixed(unitDecimals);
$state.transitionTo('tabs.send.confirm', {
isWallet: $scope.isWallet,
toAmount: amount * unitToSatoshi,
toAddress: $scope.toAddress,
toName: $scope.toName,
toEmail: $scope.toEmail
});
if ($scope.isCard) {
var amountUSD = $scope.showAlternativeAmount ? _amount : $filter('formatFiatAmount')(toFiat(_amount));
var dataSrc = {
amount: amountUSD,
currency: 'USD'
};
ongoingProcess.set('Processing Transaction...', true);
$timeout(function() {
bitpayCardService.topUp(dataSrc, function(err, invoiceId) {
if (err) {
ongoingProcess.set('Processing Transaction...', false);
popupService.showAlert(gettextCatalog.getString('Error'), bwcError.msg(err));
return;
}
bitpayCardService.getInvoice(invoiceId, function(err, data) {
ongoingProcess.set('Processing Transaction...', false);
if (err) {
popupService.showAlert(gettextCatalog.getString('Error'), bwcError.msg(err));
return;
}
var payProUrl = data.paymentUrls.BIP73;
$state.transitionTo('tabs.bitpayCard.confirm', {
isCard: $scope.isCard,
toName: $scope.toName,
paypro: payProUrl
});
});
});
});
} else {
var amount = $scope.showAlternativeAmount ? fromFiat(_amount).toFixed(unitDecimals) : _amount.toFixed(unitDecimals);
$state.transitionTo('tabs.send.confirm', {
isWallet: $scope.isWallet,
toAmount: amount * unitToSatoshi,
toAddress: $scope.toAddress,
toName: $scope.toName,
toEmail: $scope.toEmail
});
}
};
});

View file

@ -3,15 +3,14 @@
angular.module('copayApp.controllers').controller('bitpayCardController', function($scope, $timeout, $log, lodash, bitpayCardService, configService, profileService, walletService, ongoingProcess, pbkdf2Service, moment, popupService, gettextCatalog, bwcError) {
var self = this;
var wallet;
$scope.dateRange = 'last30Days';
$scope.network = bitpayCardService.getEnvironment();
$scope.$on('Wallet/Changed', function(event, w) {
if (lodash.isEmpty(w)) {
$log.debug('No wallet provided');
return;
}
wallet = w;
$log.debug('Wallet changed: ' + w.name);
bitpayCardService.getCacheData(function(err, data) {
if (err || lodash.isEmpty(data)) return;
$scope.bitpayCardCached = true;
self.bitpayCardTransactionHistory = data.transactions;
self.bitpayCardCurrentBalance = data.balance;
});
var processTransactions = function(invoices, history) {
@ -89,6 +88,14 @@ angular.module('copayApp.controllers').controller('bitpayCardController', functi
self.bitpayCardTransactionHistory = processTransactions(invoices, history.transactionList);
self.bitpayCardCurrentBalance = history.currentCardBalance;
var cacheData = {
balance: self.bitpayCardCurrentBalance,
transactions: self.bitpayCardTransactionHistory
};
bitpayCardService.setCacheData(cacheData, function(err) {
if (err) $log.error(err);
});
});
});
}
@ -98,103 +105,11 @@ angular.module('copayApp.controllers').controller('bitpayCardController', functi
});
};
this.init = function() {
$scope.dateRange = 'last30Days';
$scope.network = bitpayCardService.getEnvironment();
$scope.wallets = profileService.getWallets({
network: $scope.network,
onlyComplete: true
});
self.update();
wallet = $scope.wallets[0];
if (wallet && wallet.credentials.n > 1)
self.isMultisigWallet = true;
};
this.sendFunds = function() {
if (lodash.isEmpty(wallet)) return;
if (!wallet.canSign() && !wallet.isPrivKeyExternal()) {
$log.info('No signing proposal: No private key');
popupService.showAlert(gettextCatalog.getString('Error'), bwcError.msg('MISSING_PRIVATE_KEY'));
return;
}
var dataSrc = {
amount: $scope.fiat,
currency: 'USD'
};
var outputs = [];
var config = configService.getSync();
var configWallet = config.wallet;
var walletSettings = configWallet.settings;
ongoingProcess.set('Processing Transaction...', true);
$timeout(function() {
bitpayCardService.topUp(dataSrc, function(err, invoiceId) {
if (err) {
ongoingProcess.set('Processing Transaction...', false);
popupService.showAlert(gettextCatalog.getString('Error'), bwcError.msg(err));
return;
}
bitpayCardService.getInvoice(invoiceId, function(err, data) {
var address, comment, amount;
address = data.bitcoinAddress;
amount = parseInt((data.btcPrice * 100000000).toFixed(0));
comment = data.itemDesc;
outputs.push({
'toAddress': address,
'amount': amount,
'message': comment
});
var txp = {
toAddress: address,
amount: amount,
outputs: outputs,
message: comment,
payProUrl: null,
excludeUnconfirmedUtxos: configWallet.spendUnconfirmed ? false : true,
feeLevel: walletSettings.feeLevel || 'normal'
};
walletService.createTx(wallet, txp, function(err, createdTxp) {
ongoingProcess.set('Processing Transaction...', false);
if (err) {
popupService.showAlert(gettextCatalog.getString('Error'), bwcError.msg(err));
return;
}
walletService.publishAndSign(wallet, createdTxp, function(err, tx) {
if (err) {
popupService.showAlert(gettextCatalog.getString('Error'), bwcError.msg(err));
return;
}
self.update();
$scope.addFunds = false;
$timeout(function() {
$scope.$digest();
});
});
});
});
});
}, 100);
};
this.authenticate = function() {
this.authenticate = function(email, password) {
var data = {
emailAddress : $scope.email,
hashedPassword : pbkdf2Service.pbkdf2Sync($scope.password, '..............', 200, 64).toString('hex')
emailAddress : email,
hashedPassword : pbkdf2Service.pbkdf2Sync(password, '..............', 200, 64).toString('hex')
};
// POST /authenticate
@ -215,10 +130,10 @@ angular.module('copayApp.controllers').controller('bitpayCardController', functi
});
};
this.authenticate2FA = function() {
this.authenticate2FA = function(twoFactorCode) {
var data = {
twoFactorCode : $scope.twoFactorCode
twoFactorCode : twoFactorCode
};
self.authenticating = true;
@ -258,5 +173,9 @@ angular.module('copayApp.controllers').controller('bitpayCardController', functi
return tx.description;
};
$scope.$on("$ionicView.beforeEnter", function(event, data){
self.update();
});
});

View file

@ -1,18 +1,18 @@
'use strict';
angular.module('copayApp.controllers').controller('confirmController', function($rootScope, $scope, $filter, $timeout, $ionicScrollDelegate, gettextCatalog, walletService, platformInfo, lodash, configService, rateService, $stateParams, $window, $state, $log, profileService, bitcore, $ionicPopup, gettext, txFormatService, ongoingProcess, $ionicModal, $ionicHistory, popupService) {
angular.module('copayApp.controllers').controller('confirmController', function($rootScope, $scope, $filter, $timeout, $ionicScrollDelegate, gettextCatalog, walletService, platformInfo, lodash, configService, rateService, $stateParams, $window, $state, $log, profileService, bitcore, gettext, txFormatService, ongoingProcess, $ionicModal, popupService) {
var cachedTxp = {};
var isChromeApp = platformInfo.isChromeApp;
$scope.isWallet = $stateParams.isWallet;
$scope.toAmount = $stateParams.toAmount;
$scope.toAddress = $stateParams.toAddress;
$scope.toName = $stateParams.toName;
$scope.toEmail = $stateParams.toEmail;
$scope.description = $stateParams.description;
$scope.paypro = $stateParams.paypro;
$scope.$on("$ionicView.enter", function(event, data) {
$scope.$on("$ionicView.beforeEnter", function(event, data) {
$scope.isWallet = data.stateParams.isWallet;
$scope.isCard = data.stateParams.isCard;
$scope.toAmount = data.stateParams.toAmount;
$scope.toAddress = data.stateParams.toAddress;
$scope.toName = data.stateParams.toName;
$scope.toEmail = data.stateParams.toEmail;
$scope.description = data.stateParams.description;
$scope.paypro = data.stateParams.paypro;
initConfirm();
});
@ -243,7 +243,8 @@ angular.module('copayApp.controllers').controller('confirmController', function(
walletService.createTx(wallet, txp, function(err, ctxp) {
if (err) {
return setSendError(err);
setSendError(err);
return cb(err);
}
return cb(null, ctxp);
});
@ -312,8 +313,4 @@ angular.module('copayApp.controllers').controller('confirmController', function(
if (err) return setSendError(err);
});
};
$scope.cancel = function() {
$state.go('tabs.send');
};
});

View file

@ -1,7 +1,7 @@
'use strict';
angular.module('copayApp.controllers').controller('copayersController',
function($scope, $log, $ionicNavBarDelegate, $timeout, $stateParams, $state, $rootScope, $ionicHistory, lodash, profileService, walletService, popupService, platformInfo, gettextCatalog, ongoingProcess) {
function($scope, $log, $timeout, $stateParams, $state, $rootScope, $ionicHistory, lodash, profileService, walletService, popupService, platformInfo, gettextCatalog, ongoingProcess) {
$scope.$on("$ionicView.beforeEnter", function(event, data) {
init();

View file

@ -37,7 +37,9 @@ angular.module('copayApp.controllers').controller('createController',
};
$scope.showAdvChange = function() {
$ionicScrollDelegate.resize();
$timeout(function() {
$ionicScrollDelegate.resize();
}, 10);
};
function updateRCSelect(n) {

View file

@ -1,7 +1,7 @@
'use strict';
angular.module('copayApp.controllers').controller('importController',
function($scope, $timeout, $log, $state, $stateParams, profileService, configService, sjcl, ledger, trezor, derivationPathHelper, platformInfo, bwcService, ongoingProcess, walletService, popupService, gettextCatalog) {
function($scope, $timeout, $log, $state, $stateParams, $ionicHistory, profileService, configService, sjcl, ledger, trezor, derivationPathHelper, platformInfo, bwcService, ongoingProcess, walletService, popupService, gettextCatalog) {
var isChromeApp = platformInfo.isChromeApp;
var isDevel = platformInfo.isDevel;

View file

@ -1,7 +1,7 @@
'use strict';
angular.module('copayApp.controllers').controller('joinController',
function($scope, $rootScope, $timeout, $state, profileService, configService, storageService, applicationService, gettext, gettextCatalog, lodash, ledger, trezor, platformInfo, derivationPathHelper, ongoingProcess, walletService, $log, $stateParams, popupService) {
function($scope, $rootScope, $timeout, $state, $ionicHistory, profileService, configService, storageService, applicationService, gettext, gettextCatalog, lodash, ledger, trezor, platformInfo, derivationPathHelper, ongoingProcess, walletService, $log, $stateParams, popupService) {
var isChromeApp = platformInfo.isChromeApp;
var isDevel = platformInfo.isDevel;
@ -146,7 +146,19 @@ angular.module('copayApp.controllers').controller('joinController',
$log.debug('Remote preferences saved for:' + client.credentials.walletId)
});
$ionicHistory.removeBackView();
$state.go('tabs.home');
if (!client.isComplete()) {
$ionicHistory.nextViewOptions({
disableAnimate: true
});
$state.go('tabs.home');
$timeout(function() {
$state.transitionTo('tabs.copayers', {
walletId: client.credentials.walletId
});
}, 100);
}
else $state.go('tabs.home')
});
}, 100);
};

View file

@ -14,7 +14,9 @@ angular.module('copayApp.controllers').controller('searchController', function($
window.plugins.toast.hide();
currentTxHistoryPage = 0;
throttleSearch(search);
$ionicScrollDelegate.resize();
$timeout(function() {
$ionicScrollDelegate.resize();
}, 10);
}
var throttleSearch = lodash.throttle(function(search) {

View file

@ -73,6 +73,8 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio
time: $scope.btx.time,
description: actionDescriptions['broadcasted'],
});
$scope.actionList.reverse();
};
$scope.showCommentPopup = function() {
@ -126,6 +128,9 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio
$scope.rateDate = res.fetchedOn;
$scope.rateStr = res.rate + ' ' + $scope.alternativeIsoCode;
$scope.alternativeAmountStr = $filter('formatFiatAmount')(alternativeAmountBtc * res.rate) + ' ' + $scope.alternativeIsoCode;
$timeout(function() {
$scope.$apply();
});
}
});
};

View file

@ -1,15 +1,27 @@
'use strict';
angular.module('copayApp.controllers').controller('txStatusController', function($scope, $timeout, $state, $ionicHistory, $log, addressbookService) {
angular.module('copayApp.controllers').controller('txStatusController', function($scope, $timeout, $state, $stateParams, $ionicHistory, $log, addressbookService) {
if ($scope.cb) $timeout($scope.cb, 100);
$scope.fromSendTab = $ionicHistory.viewHistory().backView.stateName === "tabs.send.amount" || "tabs.send";
var previousView = $ionicHistory.viewHistory().backView && $ionicHistory.viewHistory().backView.stateName;
$scope.fromSendTab = previousView.match(/tabs.send/) ? true : false;
$scope.fromBitPayCard = previousView.match(/tabs.bitpayCard/) ? true : false;
$scope.fromPayPro = $stateParams.paypro ? true : false;
$scope.cancel = function() {
$scope.txStatusModal.hide();
if ($scope.fromSendTab) {
$ionicHistory.removeBackView();
$state.go('tabs.home');
$state.go('tabs.send');
$timeout(function() {
$state.transitionTo('tabs.home');
}, 100);
} else if ($scope.fromBitPayCard) {
$ionicHistory.removeBackView();
$timeout(function() {
$state.transitionTo('tabs.bitpayCard');
}, 100);
}
};
@ -21,7 +33,7 @@ angular.module('copayApp.controllers').controller('txStatusController', function
});
$ionicHistory.removeBackView();
$state.go('tabs.send.addressbook', {
fromSendTab: true,
fromSendTab: $scope.fromSendTab,
addressbookEntry: addressbookEntry
});
}

View file

@ -7,6 +7,7 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi
var isGlidera = $scope.isGlidera;
var GLIDERA_LOCK_TIME = 6 * 60 * 60;
var now = Math.floor(Date.now() / 1000);
var countDown;
$scope.init = function() {
$scope.loading = null;
@ -18,6 +19,7 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi
$scope.data = {};
initActionList();
checkPaypro();
}
function initActionList() {
@ -47,14 +49,14 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi
by: action.copayerName
});
});
$scope.actionList.reverse();
};
$scope.$on('accepted', function(event) {
$scope.sign();
});
checkPaypro();
// ToDo: use tx.customData instead of tx.message
if (tx.message === 'Glidera transaction' && isGlidera) {
tx.isGlidera = true;
@ -145,7 +147,7 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi
paymentTimeControl(tx.paypro.expires);
$timeout(function() {
$ionicScrollDelegate.resize();
}, 100);
}, 10);
});
}
};
@ -154,7 +156,7 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi
$scope.paymentExpired = false;
setExpirationTime();
self.countDown = $interval(function() {
countDown = $interval(function() {
setExpirationTime();
}, 1000);
@ -162,7 +164,7 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi
var now = Math.floor(Date.now() / 1000);
if (now > expirationTime) {
$scope.paymentExpired = true;
if (self.countDown) $interval.cancel(self.countDown);
if (countDown) $interval.cancel(countDown);
return;
}
var totalSecs = expirationTime - now;

View file

@ -1,6 +1,6 @@
'use strict';
angular.module('copayApp.controllers').controller('backupRequestController', function($scope, $state, $stateParams, $ionicPopup, popupService, gettextCatalog) {
angular.module('copayApp.controllers').controller('backupRequestController', function($scope, $state, $stateParams, popupService, gettextCatalog) {
$scope.walletId = $stateParams.walletId;

View file

@ -1,24 +1,35 @@
'use strict';
angular.module('copayApp.controllers').controller('backupWarningController', function($scope, $state, $timeout, $stateParams, $ionicPopup, profileService, $ionicModal) {
angular.module('copayApp.controllers').controller('backupWarningController', function($scope, $state, $timeout, $stateParams, profileService, $ionicModal) {
$scope.walletId = $stateParams.walletId;
$scope.openPopup = function() {
$ionicModal.fromTemplateUrl('views/includes/screenshotWarningModal.html', {
scope: $scope,
backdropClickToClose: false,
hardwareBackButtonClose: false
}).then(function(modal) {
$scope.warningModal = modal;
$scope.warningModal.show();
});
scope: $scope,
backdropClickToClose: false,
hardwareBackButtonClose: false
}).then(function(modal) {
$scope.warningModal = modal;
$scope.warningModal.show();
});
$scope.close = function() {
$scope.warningModal.hide();
$state.go('onboarding.backup', {
walletId: $stateParams.walletId,
fromOnboarding: true
});
if ($stateParams.from == 'onboarding.backupRequest')
$state.go('onboarding.backup', {
walletId: $stateParams.walletId
});
else
$state.go($stateParams.from + '.backup', {
walletId: $stateParams.walletId
});
};
}
$scope.goBack = function() {
$state.go($stateParams.from, {
walletId: $stateParams.walletId
});
};
});

View file

@ -1,6 +1,6 @@
'use strict';
angular.module('copayApp.controllers').controller('welcomeController', function($scope, $state, $timeout, $log, $ionicPopup, profileService) {
angular.module('copayApp.controllers').controller('welcomeController', function($scope, $state, $timeout, $log, profileService) {
$scope.goImport = function(code) {
$state.go('onboarding.import', {

View file

@ -1,11 +1,9 @@
'use strict';
angular.module('copayApp.controllers').controller('preferencesAbout',
function($scope, $window, $ionicNavBarDelegate, gettextCatalog, externalLinkService) {
$scope.$on("$ionicView.beforeEnter", function(event, data){
$ionicNavBarDelegate.title(gettextCatalog.getString('About') + ' ' + $window.appConfig.nameCase);
});
function($scope, $window, gettextCatalog, externalLinkService) {
$scope.title = gettextCatalog.getString('About') + ' ' + $window.appConfig.nameCase;
$scope.version = $window.version;
$scope.commitHash = $window.commitHash;
$scope.name = $window.appConfig.gitHubRepoName;

View file

@ -1,7 +1,7 @@
'use strict';
angular.module('copayApp.controllers').controller('preferencesBitpayCardController',
function($scope, $state, $timeout, bitpayCardService, popupService) {
function($scope, $state, $timeout, $ionicHistory, bitpayCardService, popupService) {
$scope.logout = function() {
var title = 'Are you sure you would like to log out of your Bitpay Card account?';
@ -12,8 +12,9 @@ angular.module('copayApp.controllers').controller('preferencesBitpayCardControll
var logout = function() {
bitpayCardService.logout(function() {
$ionicHistory.removeBackView();
$timeout(function() {
$state.go('bitpayCard.main');
$state.go('tabs.home');
}, 100);
});
};

View file

@ -4,7 +4,7 @@ angular.module('copayApp.controllers').controller('preferencesDeleteWalletContro
function($scope, $stateParams, $ionicHistory, gettextCatalog, lodash, profileService, $state, ongoingProcess, popupService) {
var wallet = profileService.getWallet($stateParams.walletId);
$scope.alias = lodash.isEqual(wallet.name, wallet.credentials.walletName) ? null : wallet.name + ' ';
$scope.walletName = '[' + wallet.credentials.walletName + ']';
$scope.walletName = wallet.credentials.walletName;
$scope.showDeletePopup = function() {
var title = gettextCatalog.getString('Warning!');

View file

@ -114,9 +114,9 @@ angular.module('copayApp.controllers').controller('preferencesInformation',
}
$scope.addrs = last10;
$timeout(function() {
$ionicScrollDelegate.resize();
$scope.$apply();
});
$ionicScrollDelegate.resize();
}, 10);
});
});

View file

@ -0,0 +1,52 @@
'use strict';
angular.module('copayApp.controllers').controller('preferencesNotificationsController',
function($scope, $rootScope, $log, $window, lodash, configService, uxLanguage, platformInfo, pushNotificationsService, profileService, feeService) {
var updateConfig = function() {
var config = configService.getSync();
var isCordova = platformInfo.isCordova;
var isIOS = platformInfo.isIOS;
$scope.PNEnabledByUser = true;
$scope.isIOSApp = isIOS && isCordova;
if ($scope.isIOSApp) {
cordova.plugins.diagnostic.isRemoteNotificationsEnabled(function(isEnabled) {
$scope.PNEnabledByUser = isEnabled;
$scope.$digest();
});
}
$scope.pushNotifications = {
value: config.pushNotifications.enabled
};
};
$scope.openSettings = function() {
cordova.plugins.diagnostic.switchToSettings(function() {
$log.debug('switched to settings');
}, function(err) {
$log.debug(err);
});
};
$scope.pushNotificationsChange = function() {
var opts = {
pushNotifications: {
enabled: $scope.pushNotifications.value
}
};
configService.set(opts, function(err) {
if (opts.pushNotifications.enabled)
pushNotificationsService.enableNotifications(profileService.walletClients);
else
pushNotificationsService.disableNotifications(profileService.walletClients);
if (err) $log.debug(err);
});
};
$scope.$on("$ionicView.enter", function(event, data) {
updateConfig();
});
});

View file

@ -1,7 +1,7 @@
'use strict';
angular.module('copayApp.controllers').controller('tabHomeController',
function($rootScope, $timeout, $scope, $state, $stateParams, $ionicModal, $ionicScrollDelegate, gettextCatalog, lodash, popupService, ongoingProcess, profileService, walletService, configService, $log, platformInfo, storageService, txpModalService, $window) {
function($rootScope, $timeout, $scope, $state, $stateParams, $ionicModal, $ionicScrollDelegate, gettextCatalog, lodash, popupService, ongoingProcess, profileService, walletService, configService, $log, platformInfo, storageService, txpModalService, $window, bitpayCardService) {
var wallet;
$scope.externalServices = {};
$scope.bitpayCardEnabled = true; // TODO
@ -76,7 +76,7 @@ angular.module('copayApp.controllers').controller('tabHomeController',
});
}
$state.go('tabs.details', {
$state.go('tabs.wallet', {
walletId: wallet.credentials.walletId
});
};
@ -88,11 +88,10 @@ angular.module('copayApp.controllers').controller('tabHomeController',
if (err) $log.error(err);
$scope.txps = txps;
$scope.txpsN = n;
$ionicScrollDelegate.resize();
$timeout(function() {
$ionicScrollDelegate.resize();
$scope.$apply();
}, 1);
}, 10);
})
};
@ -118,6 +117,7 @@ angular.module('copayApp.controllers').controller('tabHomeController',
});
});
if (!$scope.recentTransactionsEnabled) return;
$scope.fetchingNotifications = true;
profileService.getNotifications({
limit: 3
@ -128,11 +128,11 @@ angular.module('copayApp.controllers').controller('tabHomeController',
}
$scope.fetchingNotifications = false;
$scope.notifications = n;
$ionicScrollDelegate.resize();
$timeout(function() {
$ionicScrollDelegate.resize();
$scope.$apply();
}, 1);
}, 10);
})
};
@ -145,6 +145,9 @@ angular.module('copayApp.controllers').controller('tabHomeController',
return;
}
wallet.status = status;
updateTxps();
if (!$scope.recentTransactionsEnabled) return;
$scope.fetchingNotifications = true;
profileService.getNotifications({
@ -156,8 +159,6 @@ angular.module('copayApp.controllers').controller('tabHomeController',
return;
}
$scope.notifications = notifications;
updateTxps();
})
});
};
@ -175,11 +176,20 @@ angular.module('copayApp.controllers').controller('tabHomeController',
lodash.each(['AmazonGiftCards', 'BitpayCard', 'BuyAndSell'], function(service) {
storageService.getNextStep(service, function(err, value) {
$scope.externalServices[service] = value ? true : false;
$ionicScrollDelegate.resize();
$timeout(function() {
$ionicScrollDelegate.resize();
}, 10);
});
});
};
$scope.shouldHideNextSteps = function() {
$scope.hideNextSteps = !$scope.hideNextSteps;
$timeout(function() {
$ionicScrollDelegate.resize();
}, 10);
};
var listeners = [
$rootScope.$on('bwsEvent', function(e, walletId, type, n) {
var wallet = profileService.getWallet(walletId);
@ -198,12 +208,27 @@ angular.module('copayApp.controllers').controller('tabHomeController',
});
});
var bitpayCardCache = function() {
bitpayCardService.getCacheData(function(err, data) {
if (err ||  lodash.isEmpty(data)) return;
$scope.bitpayCard = data;
});
};
$scope.$on("$ionicView.enter", function(event, data) {
$scope.bitpayCard = null;
configService.whenAvailable(function() {
var config = configService.getSync();
var isWindowsPhoneApp = platformInfo.isWP && platformInfo.isCordova;
$scope.hideNextSteps = false;
$scope.glideraEnabled = config.glidera.enabled && !isWindowsPhoneApp;
$scope.coinbaseEnabled = config.coinbase.enabled && !isWindowsPhoneApp;
$scope.amazonEnabled = config.amazon.enabled;
$scope.bitpayCardEnabled = config.bitpayCard.enabled;
$scope.nextStepEnabled = $scope.glideraEnabled || $scope.coinbaseEnabled || $scope.amazonEnabled || $scope.bitpayCardEnabled;
$scope.recentTransactionsEnabled = config.recentTransactions.enabled;
if ($scope.bitpayCardEnabled) bitpayCardCache();
});
$scope.nextStep();
$scope.updateAllWallets();

View file

@ -1,6 +1,6 @@
'use strict';
angular.module('copayApp.controllers').controller('tabReceiveController', function($scope, $timeout, $log, $ionicModal, storageService, platformInfo, walletService, profileService, configService, lodash, gettextCatalog, popupService) {
angular.module('copayApp.controllers').controller('tabReceiveController', function($scope, $timeout, $log, $ionicModal, $state, $ionicHistory, storageService, platformInfo, walletService, profileService, configService, lodash, gettextCatalog, popupService) {
$scope.isCordova = platformInfo.isCordova;
$scope.isNW = platformInfo.isNW;
@ -29,29 +29,25 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi
};
$scope.setAddress = function(forceNew) {
if ($scope.generatingAddress) return;
if ($scope.generatingAddress || !$scope.wallet.isComplete()) return;
$scope.addr = null;
$scope.generatingAddress = true;
$timeout(function() {
walletService.getAddress($scope.wallet, forceNew, function(err, addr) {
$scope.generatingAddress = false;
if (err || lodash.isEmpty(addr)) {
popupService.showAlert(gettextCatalog.getString('Error'), err || gettextCatalog.getString('Address is empty'));
return;
}
if (err) popupService.showAlert(gettextCatalog.getString('Error'), err);
$scope.addr = addr;
if ($scope.wallet.showBackupNeededModal) $scope.openBackupNeededModal();
$scope.$apply();
});
}, 1);
}, 100);
};
$scope.$on("$ionicView.beforeEnter", function(event, data) {
if (!$scope.isCordova) $scope.checkTips();
$scope.wallets = profileService.getWallets({
onlyComplete: true
});
$scope.wallets = profileService.getWallets();
$scope.$on('Wallet/Changed', function(event, wallet) {
if (!wallet) {
$log.debug('No wallet provided');
@ -62,4 +58,46 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi
$scope.setAddress();
});
});
$scope.goCopayers = function() {
$ionicHistory.removeBackView();
$ionicHistory.nextViewOptions({
disableAnimate: true
});
$state.go('tabs.home');
$timeout(function() {
$state.transitionTo('tabs.copayers', {
walletId: $scope.wallet.credentials.walletId
});
}, 100);
};
$scope.openBackupNeededModal = function() {
$ionicModal.fromTemplateUrl('views/includes/backupNeededPopup.html', {
scope: $scope,
backdropClickToClose: false,
hardwareBackButtonClose: false
}).then(function(modal) {
$scope.BackupNeededModal = modal;
$scope.BackupNeededModal.show();
});
};
$scope.close = function() {
$scope.BackupNeededModal.hide();
$scope.BackupNeededModal.remove();
profileService.setBackupNeededModalFlag($scope.wallet.credentials.walletId);
};
$scope.doBackup = function() {
$scope.close();
$scope.goToBackupFlow();
};
$scope.goToBackupFlow = function() {
$state.go('tabs.receive.backupWarning', {
from: 'tabs.receive',
walletId: $scope.wallet.credentials.walletId
});
}
});

View file

@ -1,8 +1,10 @@
'use strict';
angular.module('copayApp.controllers').controller('tabSendController', function($scope, $log, $timeout, addressbookService, profileService, lodash, $state, walletService, incomingData) {
angular.module('copayApp.controllers').controller('tabSendController', function($scope, $log, $timeout, $ionicScrollDelegate, addressbookService, profileService, lodash, $state, walletService, incomingData, popupService) {
var originalList;
var CONTACTS_SHOW_LIMIT = 10;
var currentContactsPage = 0;
var updateList = function() {
originalList = [];
@ -11,6 +13,7 @@ angular.module('copayApp.controllers').controller('tabSendController', function(
onlyComplete: true
});
$scope.hasWallets = lodash.isEmpty(wallets) ? false : true;
$scope.oneWallet = wallets.length == 1;
lodash.each(wallets, function(v) {
originalList.push({
@ -27,9 +30,9 @@ angular.module('copayApp.controllers').controller('tabSendController', function(
if (err) $log.error(err);
$scope.hasContacts = lodash.isEmpty(ab) ? false : true;
var contacts = [];
var completeContacts = [];
lodash.each(ab, function(v, k) {
contacts.push({
completeContacts.push({
name: lodash.isObject(v) ? v.name : v,
address: k,
email: lodash.isObject(v) ? v.email : null,
@ -39,15 +42,23 @@ angular.module('copayApp.controllers').controller('tabSendController', function(
});
});
var contacts = completeContacts.slice(0, (currentContactsPage + 1) * CONTACTS_SHOW_LIMIT);
$scope.contactsShowMore = completeContacts.length > contacts.length;
originalList = originalList.concat(contacts);
$scope.list = lodash.clone(originalList);
$timeout(function() {
$ionicScrollDelegate.resize();
$scope.$apply();
}, 1);
}, 10);
});
};
$scope.showMore = function() {
currentContactsPage++;
updateList();
};
$scope.findContact = function(search) {
if (incomingData.redir(search)) {
@ -86,8 +97,16 @@ angular.module('copayApp.controllers').controller('tabSendController', function(
});
};
$scope.$on("$ionicView.beforeEnter", function(event, data){
$scope.formData = { search: null };
$scope.onQrCodeScanned = function(data) {
if (!incomingData.redir(data)) {
popupService.showAlert(null, gettextCatalog.getString('Invalid data'));
}
};
$scope.$on("$ionicView.beforeEnter", function(event, data) {
$scope.formData = {
search: null
};
updateList();
});

View file

@ -9,6 +9,8 @@ angular.module('copayApp.controllers').controller('tabSettingsController', funct
var isWP = platformInfo.isWP;
var isIOS = platformInfo.isIOS;
$scope.usePushNotifications = isCordova && !isWP;
$scope.appName = $window.appConfig.nameCase;
$scope.unitName = config.wallet.settings.unitName;
@ -19,87 +21,13 @@ angular.module('copayApp.controllers').controller('tabSettingsController', funct
};
$scope.feeOpts = feeService.feeOpts;
$scope.currentFeeLevel = feeService.getCurrentFeeLevel();
$scope.usePushNotifications = isCordova && !isWP;
$scope.PNEnabledByUser = true;
$scope.isIOSApp = isIOS && isCordova;
if ($scope.isIOSApp) {
cordova.plugins.diagnostic.isRemoteNotificationsEnabled(function(isEnabled) {
$scope.PNEnabledByUser = isEnabled;
$scope.$digest();
});
}
$scope.spendUnconfirmed = {
value: config.wallet.spendUnconfirmed
};
$scope.glideraEnabled = {
value: config.glidera.enabled
};
$scope.coinbaseEnabled = config.coinbase.enabled;
$scope.pushNotifications = {
value: config.pushNotifications.enabled
};
$scope.otherWallets = lodash.filter(profileService.getWallets(self.network), function(w) {
return w.id != self.walletId;
});
$scope.wallets = profileService.getWallets();
};
$scope.openSettings = function() {
cordova.plugins.diagnostic.switchToSettings(function() {
$log.debug('switched to settings');
}, function(err) {
$log.debug(err);
});
};
$scope.spendUnconfirmedChange = function() {
var opts = {
wallet: {
spendUnconfirmed: $scope.spendUnconfirmed.value
}
};
configService.set(opts, function(err) {
if (err) $log.debug(err);
});
};
$scope.pushNotificationsChange = function() {
var opts = {
pushNotifications: {
enabled: $scope.pushNotifications.value
}
};
configService.set(opts, function(err) {
if (opts.pushNotifications.enabled)
pushNotificationsService.enableNotifications(profileService.walletClients);
else
pushNotificationsService.disableNotifications(profileService.walletClients);
if (err) $log.debug(err);
});
};
$scope.glideraChange = function() {
var opts = {
glidera: {
enabled: $scope.glideraEnabled.value
}
};
configService.set(opts, function(err) {
if (err) $log.debug(err);
});
};
$scope.coinbaseChange = function() {
var opts = {
coinbase: {
enabled: $scope.coinbaseEnabled
}
};
configService.set(opts, function(err) {
if (err) $log.debug(err);
});
};
$scope.$on("$ionicView.enter", function(event, data) {
updateConfig();
});

View file

@ -1,12 +1,10 @@
'use strict';
angular.module('copayApp.controllers').controller('tabsController', function($log, $scope, $stateParams, $ionicModal, $timeout, incomingData) {
angular.module('copayApp.controllers').controller('tabsController', function($rootScope, $log, $scope, $state, $stateParams, $timeout, incomingData, lodash, popupService) {
$scope.onScan = function(data) {
if (!incomingData.redir(data)) {
$ionicPopup.alert({
title: 'Invalid data',
});
popupService.showAlert(null, gettextCatalog.getString('Invalid data'));
}
}
@ -22,6 +20,34 @@ angular.module('copayApp.controllers').controller('tabsController', function($lo
$timeout(function() {
$scope.$apply();
}, 1);
}
};
var hideTabsViews = [
'tabs.send.amount',
'tabs.send.confirm',
'tabs.send.addressbook',
'tabs.addressbook',
'tabs.addressbook.add',
'tabs.addressbook.view',
'tabs.preferences.backupWarning',
'tabs.preferences.backup',
'tabs.receive.backupWarning',
'tabs.receive.backup',
'tabs.bitpayCard.amount',
'tabs.bitpayCard.confirm',
];
$rootScope.$on('$ionicView.beforeEnter', function() {
$rootScope.hideTabs = false;
var currentState = $state.current.name;
lodash.each(hideTabsViews, function(view) {
if (currentState === view) {
$rootScope.hideTabs = true;
}
});
});
});

View file

@ -1,6 +1,6 @@
'use strict';
angular.module('copayApp.controllers').controller('walletDetailsController', function($scope, $rootScope, $interval, $timeout, $filter, $log, $ionicModal, $ionicPopover, $ionicNavBarDelegate, $state, $stateParams, profileService, lodash, configService, gettext, gettextCatalog, platformInfo, walletService, $ionicPopup, txpModalService, externalLinkService) {
angular.module('copayApp.controllers').controller('walletDetailsController', function($scope, $rootScope, $interval, $timeout, $filter, $log, $ionicModal, $ionicPopover, $state, $stateParams, profileService, lodash, configService, gettextCatalog, platformInfo, walletService, txpModalService, externalLinkService, popupService) {
var isCordova = platformInfo.isCordova;
var isWP = platformInfo.isWP;
var isAndroid = platformInfo.isAndroid;
@ -204,15 +204,13 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun
wallet = profileService.getWallet($stateParams.walletId);
/* Set color for header bar */
$rootScope.walletDetailsColor = wallet.color;
$rootScope.walletDetailsName = wallet.name;
$scope.walletDetailsColor = wallet.color;
$scope.walletDetailsName = wallet.name;
$scope.wallet = wallet;
$scope.requiresMultipleSignatures = wallet.credentials.m > 1;
$scope.newTx = false;
$ionicNavBarDelegate.title(wallet.name);
$scope.updateAll(function() {
if ($stateParams.txid) {
var tx = lodash.find($scope.completeTxHistory, {
@ -221,9 +219,7 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun
if (tx) {
$scope.openTxModal(tx);
} else {
$ionicPopup.alert({
title: gettext('TX not available'),
});
popupService.showAlert(null, gettextCatalog.getString('TX not available'));
}
} else if ($stateParams.txpId) {
var txp = lodash.find($scope.txps, {
@ -232,9 +228,7 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun
if (txp) {
$scope.openTxpModal(txp);
} else {
$ionicPopup.alert({
title: gettext('Proposal not longer available'),
});
popupService.showAlert(null, gettextCatalog.getString('Proposal not longer available'));
}
}
});

View file

@ -150,10 +150,10 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
*
*/
.state('tabs.details', {
url: '/details/{walletId}/{fromOnboarding}',
.state('tabs.wallet', {
url: '/wallet/{walletId}/{fromOnboarding}',
views: {
'tab-home': {
'tab-home@tabs': {
controller: 'walletDetailsController',
templateUrl: 'views/walletDetails.html'
}
@ -166,7 +166,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
.state('tabs.activity', {
url: '/activity',
views: {
'tab-home': {
'tab-home@tabs': {
controller: 'activityController',
templateUrl: 'views/activity.html',
}
@ -175,7 +175,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
.state('tabs.proposals', {
url: '/proposals',
views: {
'tab-home': {
'tab-home@tabs': {
controller: 'proposalsController',
templateUrl: 'views/proposals.html',
}
@ -191,6 +191,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
.state('tabs', {
url: '/tabs',
abstract: true,
controller: 'tabsController',
templateUrl: 'views/tabs.html'
})
.state('tabs.home', {
@ -236,7 +237,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
*
*/
.state('tabs.send.amount', {
.state('tabs.send.amount', {
url: '/amount/:isWallet/:toAddress/:toName/:toEmail',
views: {
'tab-send@tabs': {
@ -317,7 +318,16 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
*
*/
.state('tabs.language', {
.state('tabs.notifications', {
url: '/notifications',
views: {
'tab-settings@tabs': {
controller: 'preferencesNotificationsController',
templateUrl: 'views/preferencesNotifications.html'
}
}
})
.state('tabs.language', {
url: '/language',
views: {
'tab-settings@tabs': {
@ -389,6 +399,15 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
}
}
})
.state('tabs.advanced', {
url: '/advanced',
views: {
'tab-settings@tabs': {
controller: 'advancedSettingsController',
templateUrl: 'views/advancedSettings.html'
}
}
})
/*
*
@ -432,6 +451,14 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
}
}
})
.state('tabs.preferences.backupWarning', {
url: '/backupWarning/:from',
views: {
'tab-settings@tabs': {
templateUrl: 'views/backupWarning.html'
}
}
})
.state('tabs.preferences.backup', {
url: '/backup',
views: {
@ -551,7 +578,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
/*
*
*TO DO
* Copayers
*
*/
@ -565,6 +592,30 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
}
})
/*
*
* Back flow from receive
*
*/
.state('tabs.receive.backupWarning', {
url: '/backupWarning/:from/:walletId',
views: {
'tab-receive@tabs': {
templateUrl: 'views/backupWarning.html'
}
}
})
.state('tabs.receive.backup', {
url: '/backup/:walletId',
views: {
'tab-receive@tabs': {
controller: 'backupController',
templateUrl: 'views/backup.html'
}
}
})
/*
*
* Onboarding
@ -617,15 +668,15 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
}
})
.state('onboarding.backupWarning', {
url: '/backupWarning/:walletId',
url: '/backupWarning/:from/:walletId',
views: {
'onboarding': {
templateUrl: 'views/onboarding/backupWarning.html'
templateUrl: 'views/backupWarning.html'
}
}
})
.state('onboarding.backup', {
url: '/backup/:walletId/:fromOnboarding',
url: '/backup/:walletId',
views: {
'onboarding': {
templateUrl: 'views/backup.html',
@ -785,29 +836,44 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
}
})
/*
*
* BitPay Card
*
*/
/*
*
* BitPay Card
*
*/
.state('bitpayCard', {
url: '/bitpayCard',
abstract: true,
template: '<ion-nav-view name="bitpayCard"></ion-nav-view>'
})
.state('bitpayCard.main', {
url: '/main',
.state('tabs.bitpayCard', {
url: '/bitpay-card',
views: {
'bitpayCard': {
'tab-home@tabs': {
controller: 'bitpayCardController',
controllerAs: 'bitpayCard',
templateUrl: 'views/bitpayCard.html'
}
}
})
.state('bitpayCard.preferences', {
.state('tabs.bitpayCard.amount', {
url: '/amount/:isCard/:toName',
views: {
'tab-home@tabs': {
controller: 'amountController',
templateUrl: 'views/amount.html'
}
}
})
.state('tabs.bitpayCard.confirm', {
url: '/confirm/:isCard/:toAddress/:toName/:toAmount/:toEmail/:description/:paypro',
views: {
'tab-home@tabs': {
controller: 'confirmController',
templateUrl: 'views/confirm.html'
}
}
})
.state('tabs.bitpayCard.preferences', {
url: '/preferences',
views: {
'bitpayCard': {
'tab-home@tabs': {
templateUrl: 'views/preferencesBitpayCard.html'
}
}
@ -944,6 +1010,8 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
$log.debug('Route change from:', fromState.name || '-', ' to:', toState.name);
$log.debug(' toParams:' + JSON.stringify(toParams || {}));
$log.debug(' fromParams:' + JSON.stringify(fromParams || {}));
if (!toState.name.match(/onboarding/)) return;
var state = {};
state.name = toState.name;
state.toParams = toParams;

View file

@ -187,8 +187,38 @@ angular.module('copayApp.services').factory('bitpayCardService', function($http,
});
};
root.getCacheData = function(cb) {
_setCredentials();
storageService.getBitpayCardCache(credentials.NETWORK, function(err, data) {
if (err) return cb(err);
if (lodash.isString(data)) {
data = JSON.parse(data);
}
data = data || {};
return cb(null, data);
});
};
root.setCacheData = function(data, cb) {
_setCredentials();
data = JSON.stringify(data);
storageService.setBitpayCardCache(credentials.NETWORK, data, function(err) {
if (err) return cb(err);
return cb();
});
};
root.removeCacheData = function(cb) {
_setCredentials();
storageService.removeBitpayCardCache(credentials.NETWORK, function(err) {
if (err) return cb(err);
return cb();
});
};
root.logout = function(cb) {
_setCredentials();
root.removeCacheData(function() {});
storageService.removeBitpayCard(credentials.NETWORK, function(err) {
$http(_getBitPay('/visa-api/logout')).then(function(data) {
$log.info('BitPay Logout: SUCCESS');

View file

@ -39,10 +39,28 @@ angular.module('copayApp.services').factory('configService', function(storageSer
},
coinbase: {
enabled: true,
enabled: false, //disable coinbase for this release
testnet: false
},
bitpayCard: {
enabled: true
},
amazon: {
enabled: true
},
//Experimental Features
recentTransactions: {
enabled: false //disabled by default
},
frequentlyUsed: {
enabled: true
},
rates: {
url: 'https://insight.bitpay.com:443/api/rates',
},
@ -111,6 +129,18 @@ angular.module('copayApp.services').factory('configService', function(storageSer
if (!configCache.coinbase) {
configCache.coinbase = defaultConfig.coinbase;
}
if (!configCache.amazon) {
configCache.amazon = defaultConfig.amazon;
}
if (!configCache.bitpayCard) {
configCache.bitpayCard = defaultConfig.bitpayCard;
}
if (!configCache.recentTransactions) {
configCache.recentTransactions = defaultConfig.recentTransactions;
}
if (!configCache.frequentlyUsed) {
configCache.frequentlyUsed = defaultConfig.frequentlyUsed;
}
if (!configCache.pushNotifications) {
configCache.pushNotifications = defaultConfig.pushNotifications;
}

View file

@ -1,6 +1,6 @@
'use strict';
angular.module('copayApp.services')
.factory('profileService', function profileServiceFactory($rootScope, $timeout, $filter, $log, sjcl, lodash, storageService, bwcService, configService, pushNotificationsService, gettext, gettextCatalog, bwcError, uxLanguage, platformInfo, $ionicHistory, txFormatService, $state) {
.factory('profileService', function profileServiceFactory($rootScope, $timeout, $filter, $log, sjcl, lodash, storageService, bwcService, configService, pushNotificationsService, gettext, gettextCatalog, bwcError, uxLanguage, platformInfo, txFormatService, $state) {
var isChromeApp = platformInfo.isChromeApp;
@ -38,6 +38,22 @@ angular.module('copayApp.services')
});
}
root.setBackupNeededModalFlag = function(walletId) {
storageService.setBackupNeededModalFlag(walletId, true, function(err) {
if (err) $log.error(err);
$log.debug('Backup warning modal flag stored');
root.wallet[walletId].showBackupNeededModal = false;
});
};
function _showBackupNeededModal(wallet, cb) {
storageService.getBackupNeededModalFlag(wallet.credentials.walletId, function(err, val) {
if (err) $log.error(err);
if (val) return cb(false);
return cb(true);
});
};
root.setBackupFlag = function(walletId) {
storageService.setBackupFlag(walletId, function(err) {
if (err) $log.error(err);
@ -101,6 +117,11 @@ angular.module('copayApp.services')
wallet.balanceHidden = val;
});
_showBackupNeededModal(wallet, function(val) {
if (wallet.needsBackup) wallet.showBackupNeededModal = val;
else wallet.showBackupNeededModal = false;
});
wallet.removeAllListeners();
wallet.on('report', function(n) {
@ -759,21 +780,11 @@ angular.module('copayApp.services')
var TIME_STAMP = 60 * 60 * 24 * 7;
var MAX = 100;
var typeFilter1 = {
'NewBlock': 1,
'BalanceUpdated': 1,
'NewOutgoingTxByThirdParty': 1,
'NewAddress': 1,
'TxProposalFinallyAccepted': 1,
'TxProposalFinallyRejected': 1,
var typeFilter = {
'NewOutgoingTx': 1,
'NewIncomingTx': 1
};
var typeFilter2 = {
'TxProposalAcceptedBy': 1,
'TxProposalRejectedBy': 1,
'NewTxProposal': 1,
}
var w = root.getWallets();
if (lodash.isEmpty(w)) return cb();
@ -822,7 +833,7 @@ angular.module('copayApp.services')
x.action = function() {
// TODO?
// $state.go('tabs.details', {
// $state.go('tabs.wallet', {
// walletId: x.walletId,
// txpId: x.txpId,
// txid: x.txid,
@ -874,15 +885,9 @@ angular.module('copayApp.services')
var n;
n = lodash.filter(wallet.cachedActivity.n, function(x) {
return !typeFilter1[x.type];
return typeFilter[x.type];
});
if (wallet.m == 1) {
n = lodash.filter(n, function(x) {
return !typeFilter2[x.type];
});
}
var idToName = {};
if (wallet.cachedStatus) {
lodash.each(wallet.cachedStatus.wallet.copayers, function(c) {

View file

@ -337,6 +337,18 @@ angular.module('copayApp.services')
storage.remove('bitpayCard-' + network, cb);
};
root.setBitpayCardCache = function(network, data, cb) {
storage.set('bitpayCardCache-' + network, data, cb);
};
root.getBitpayCardCache = function(network, cb) {
storage.get('bitpayCardCache-' + network, cb);
};
root.removeBitpayCardCache = function(network, cb) {
storage.remove('bitpayCardCache-' + network, cb);
};
root.removeAllWalletData = function(walletId, cb) {
root.clearLastAddress(walletId, function(err) {
if (err) return cb(err);
@ -365,6 +377,14 @@ angular.module('copayApp.services')
storage.get('receiveTips', cb);
};
root.setBackupNeededModalFlag = function(walletId, val, cb) {
storage.set('showBackupNeededModal-' + walletId, val, cb);
};
root.getBackupNeededModalFlag = function(walletId, cb) {
storage.get('showBackupNeededModal-' + walletId, cb);
};
root.setAmazonGiftCards = function(network, gcs, cb) {
storage.set('amazonGiftCards-' + network, gcs, cb);
};

View file

@ -1,150 +0,0 @@
'use strict';
/*
* This is a modification from https://github.com/angular/angular.js/blob/master/src/ngTouch/swipe.js
*/
angular.module('copayApp.services')
.factory('$swipe', [
function() {
// The total distance in any direction before we make the call on swipe vs. scroll.
var MOVE_BUFFER_RADIUS = 10;
var POINTER_EVENTS = {
'touch': {
start: 'touchstart',
move: 'touchmove',
end: 'touchend',
cancel: 'touchcancel'
}
};
function getCoordinates(event) {
var originalEvent = event.originalEvent || event;
var touches = originalEvent.touches && originalEvent.touches.length ? originalEvent.touches : [originalEvent];
var e = (originalEvent.changedTouches && originalEvent.changedTouches[0]) || touches[0];
return {
x: e.clientX,
y: e.clientY
};
}
function getEvents(pointerTypes, eventType) {
var res = [];
angular.forEach(pointerTypes, function(pointerType) {
var eventName = POINTER_EVENTS[pointerType][eventType];
if (eventName) {
res.push(eventName);
}
});
return res.join(' ');
}
return {
/**
* @ngdoc method
* @name $swipe#bind
*
* @description
* The main method of `$swipe`. It takes an element to be watched for swipe motions, and an
* object containing event handlers.
* The pointer types that should be used can be specified via the optional
* third argument, which is an array of strings `'mouse'` and `'touch'`. By default,
* `$swipe` will listen for `mouse` and `touch` events.
*
* The four events are `start`, `move`, `end`, and `cancel`. `start`, `move`, and `end`
* receive as a parameter a coordinates object of the form `{ x: 150, y: 310 }`.
*
* `start` is called on either `mousedown` or `touchstart`. After this event, `$swipe` is
* watching for `touchmove` or `mousemove` events. These events are ignored until the total
* distance moved in either dimension exceeds a small threshold.
*
* Once this threshold is exceeded, either the horizontal or vertical delta is greater.
* - If the horizontal distance is greater, this is a swipe and `move` and `end` events follow.
* - If the vertical distance is greater, this is a scroll, and we let the browser take over.
* A `cancel` event is sent.
*
* `move` is called on `mousemove` and `touchmove` after the above logic has determined that
* a swipe is in progress.
*
* `end` is called when a swipe is successfully completed with a `touchend` or `mouseup`.
*
* `cancel` is called either on a `touchcancel` from the browser, or when we begin scrolling
* as described above.
*
*/
bind: function(element, eventHandlers, pointerTypes) {
// Absolute total movement, used to control swipe vs. scroll.
var totalX, totalY;
// Coordinates of the start position.
var startCoords;
// Last event's position.
var lastPos;
// Whether a swipe is active.
var active = false;
pointerTypes = pointerTypes || ['touch'];
element.on(getEvents(pointerTypes, 'start'), function(event) {
startCoords = getCoordinates(event);
active = true;
totalX = 0;
totalY = 0;
lastPos = startCoords;
eventHandlers['start'] && eventHandlers['start'](startCoords, event);
});
var events = getEvents(pointerTypes, 'cancel');
if (events) {
element.on(events, function(event) {
active = false;
eventHandlers['cancel'] && eventHandlers['cancel'](event);
});
}
element.on(getEvents(pointerTypes, 'move'), function(event) {
if (!active) return;
// Android will send a touchcancel if it thinks we're starting to scroll.
// So when the total distance (+ or - or both) exceeds 10px in either direction,
// we either:
// - On totalX > totalY, we send preventDefault() and treat this as a swipe.
// - On totalY > totalX, we let the browser handle it as a scroll.
if (!startCoords) return;
var coords = getCoordinates(event);
totalX += Math.abs(coords.x - lastPos.x);
totalY += Math.abs(coords.y - lastPos.y);
lastPos = coords;
if (totalX < MOVE_BUFFER_RADIUS && totalY < MOVE_BUFFER_RADIUS) {
return;
}
// One of totalX or totalY has exceeded the buffer, so decide on swipe vs. scroll.
if (totalY > totalX) {
// Allow native scrolling to take over.
active = false;
eventHandlers['cancel'] && eventHandlers['cancel'](event);
return;
} else {
// Prevent the browser from scrolling.
event.preventDefault();
eventHandlers['move'] && eventHandlers['move'](coords, event);
}
});
element.on(getEvents(pointerTypes, 'end'), function(event) {
if (!active) return;
active = false;
eventHandlers['end'] && eventHandlers['end'](getCoordinates(event), event);
});
}
};
}
]);

View file

@ -792,29 +792,16 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
root.getAddress = function(wallet, forceNew, cb) {
var firstStep;
if (forceNew) {
firstStep = storageService.clearLastAddress;
} else {
firstStep = function(walletId, cb) {
return cb();
};
}
firstStep(wallet.id, function(err) {
storageService.getLastAddress(wallet.id, function(err, addr) {
if (err) return cb(err);
storageService.getLastAddress(wallet.id, function(err, addr) {
if (err) return cb(err);
if (!forceNew && addr) return cb(null, addr);
if (addr) return cb(null, addr);
createAddress(wallet, function(err, addr) {
createAddress(wallet, function(err, _addr) {
if (err) return cb(err, addr);
storageService.storeLastAddress(wallet.id, _addr, function() {
if (err) return cb(err);
storageService.storeLastAddress(wallet.id, addr, function() {
if (err) return cb(err);
return cb(null, addr);
});
return cb(null, _addr);
});
});
});
@ -833,32 +820,12 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
// An alert dialog
var askPassword = function(name, title, cb) {
var scope = $rootScope.$new(true);
scope.data = [];
var pass = $ionicPopup.show({
template: '<input type="password" ng-model="data.pass">',
title: title,
subTitle: name,
scope: scope,
buttons: [{
text: 'Cancel'
}, {
text: '<b>OK</b>',
type: 'button-positive',
onTap: function(e) {
if (!scope.data.pass) {
//don't allow the user to close unless he enters wifi password
e.preventDefault();
return;
}
return scope.data.pass;
}
}]
});
pass.then(function(res) {
return cb(res);
var opts = {
inputType: 'password'
};
popupService.showPrompt(title, name, opts, function(res) {
if (!res) return cb();
if (res) return cb(res)
});
};