Merge branch 'ref/design' of github.com:bitpay/bitpay-wallet into feature/new-qrscanner-permissions

This commit is contained in:
Jason Dreyzehner 2016-10-11 03:15:07 -04:00
commit f1a849c5d8
36 changed files with 344 additions and 284 deletions

View file

@ -92,6 +92,8 @@ angular.module('copayApp.controllers').controller('amountController', function($
$scope.pushDigit = function(digit) {
if ($scope.amount && $scope.amount.length >= LENGTH_EXPRESSION_LIMIT) return;
if ($scope.amount.indexOf('.') > -1 && digit == '.') return;
if($scope.showAlternativeAmount && $scope.amount.indexOf('.') > -1 && $scope.amount[$scope.amount.indexOf('.') + 2]) return;
$scope.amount = ($scope.amount + digit).replace('..', '.');
checkFontSize();

View file

@ -27,7 +27,7 @@ angular.module('copayApp.controllers').controller('backupController',
});
};
$scope.initFlow = function() {
$scope.setFlow = function(step) {
if (!keys) return;
var words = keys.mnemonic;
@ -39,7 +39,7 @@ angular.module('copayApp.controllers').controller('backupController',
$scope.useIdeograms = words.indexOf("\u3000") >= 0;
$scope.data.passphrase = null;
$scope.customWords = [];
$scope.step = 1;
$scope.step = step || 1;
$scope.selectComplete = false;
$scope.backupError = false;
@ -72,10 +72,10 @@ angular.module('copayApp.controllers').controller('backupController',
var showBackupResult = function() {
if ($scope.backupError) {
var title = gettextCatalog.getString('Uh oh...');
var title = 'Uh oh...';
var message = gettextCatalog.getString("It's important that you write your backup phrase down correctly. If something happens to your wallet, you'll need this backup to recover your money. Please review your backup and try again.");
popupService.showAlert(title, message, function() {
$scope.goToStep(1);
$scope.setFlow(2);
})
} else {
openConfirmBackupModal();
@ -151,7 +151,7 @@ angular.module('copayApp.controllers').controller('backupController',
$scope.goToStep = function(n) {
if (n == 1)
$scope.initFlow();
$scope.setFlow();
if (n == 2)
$scope.step = 2;
if (n == 3) {
@ -203,7 +203,7 @@ angular.module('copayApp.controllers').controller('backupController',
}
$scope.credentialsEncrypted = false;
keys = k;
$scope.initFlow();
$scope.setFlow();
});
});

View file

@ -41,14 +41,20 @@ angular.module('copayApp.controllers').controller('confirmController', function(
var networkName = (new bitcore.Address($scope.toAddress)).network.name;
$scope.network = networkName;
$scope.notAvailable = false;
$scope.insuffientFunds = false;
$scope.noMatchingWallet = false;
var wallets = profileService.getWallets({
onlyComplete: true,
network: networkName,
});
if (!wallets || !wallets.length) {
$scope.noMatchingWallet = true;
}
var filteredWallets = [];
var index = 0;
var index = 0, enoughFunds = false;
lodash.each(wallets, function(w) {
walletService.getStatus(w, {}, function(err, status) {
@ -56,15 +62,20 @@ angular.module('copayApp.controllers').controller('confirmController', function(
$log.error(err);
} else {
if (!status.availableBalanceSat) $log.debug('No balance available in: ' + w.name);
if (status.availableBalanceSat > $scope.toAmount) filteredWallets.push(w);
if (status.availableBalanceSat > $scope.toAmount) {
filteredWallets.push(w);
enoughFunds = true;
}
}
if (++index == wallets.length) {
if (!lodash.isEmpty(filteredWallets)) {
$scope.wallets = lodash.clone(filteredWallets);
$scope.notAvailable = false;
} else {
$scope.notAvailable = true;
if (!enoughFunds)
$scope.insuffientFunds = true;
$log.warn('No wallet available to make the payment');
}
}

View file

@ -37,9 +37,24 @@ angular.module('copayApp.controllers').controller('createController',
};
$scope.showAdvChange = function() {
$scope.showAdv = !$scope.showAdv;
$scope.resizeView();
};
$scope.resizeView = function() {
$timeout(function() {
$ionicScrollDelegate.resize();
}, 10);
});
checkPasswordFields();
};
function checkPasswordFields() {
if (!$scope.encrypt) {
$scope.formData.passphrase = $scope.formData.createPassphrase = $scope.formData.passwordSaved = null;
$timeout(function() {
$scope.$apply();
});
}
};
function updateRCSelect(n) {
@ -160,7 +175,6 @@ angular.module('copayApp.controllers').controller('createController',
function _create(opts) {
ongoingProcess.set('creatingWallet', true);
$timeout(function() {
profileService.createWallet(opts, function(err, client) {
ongoingProcess.set('creatingWallet', false);
if (err) {
@ -173,11 +187,12 @@ angular.module('copayApp.controllers').controller('createController',
$log.debug('Remote preferences saved for:' + client.credentials.walletId)
});
if ($scope.seedSource.id == 'set') {
profileService.setBackupFlag(client.credentials.walletId);
}
$ionicHistory.removeBackView();
if (!client.isComplete()) {
$ionicHistory.nextViewOptions({
disableAnimate: true
@ -188,8 +203,7 @@ angular.module('copayApp.controllers').controller('createController',
walletId: client.credentials.walletId
});
}, 100);
}
else $state.go('tabs.home')
} else $state.go('tabs.home');
});
}, 100);
}

View file

@ -1,9 +1,20 @@
'use strict';
angular.module('copayApp.controllers').controller('exportController',
function($scope, $timeout, $log, $ionicHistory, backupService, walletService, storageService, profileService, platformInfo, gettextCatalog, $state, $stateParams, popupService) {
function($scope, $timeout, $log, $ionicHistory, $ionicScrollDelegate, backupService, walletService, storageService, profileService, platformInfo, gettextCatalog, $state, $stateParams, popupService) {
var wallet = profileService.getWallet($stateParams.walletId);
$scope.showAdvChange = function() {
$scope.showAdv = !$scope.showAdv;
$scope.resizeView();
};
$scope.resizeView = function() {
$timeout(function() {
$ionicScrollDelegate.resize();
});
};
var init = function() {
$scope.formData = {};
$scope.isEncrypted = wallet.isPrivKeyEncrypted();

View file

@ -1,7 +1,7 @@
'use strict';
angular.module('copayApp.controllers').controller('joinController',
function($scope, $rootScope, $timeout, $state, $ionicHistory, profileService, configService, storageService, applicationService, gettext, gettextCatalog, lodash, ledger, trezor, platformInfo, derivationPathHelper, ongoingProcess, walletService, $log, $stateParams, popupService) {
function($scope, $rootScope, $timeout, $state, $ionicHistory, $ionicScrollDelegate, profileService, configService, storageService, applicationService, gettext, gettextCatalog, lodash, ledger, trezor, platformInfo, derivationPathHelper, ongoingProcess, walletService, $log, $stateParams, popupService) {
var isChromeApp = platformInfo.isChromeApp;
var isDevel = platformInfo.isDevel;
@ -12,6 +12,26 @@ angular.module('copayApp.controllers').controller('joinController',
$scope.derivationPath = derivationPathHelper.default;
$scope.account = 1;
$scope.showAdvChange = function() {
$scope.showAdv = !$scope.showAdv;
$scope.resizeView();
};
$scope.resizeView = function() {
$timeout(function() {
$ionicScrollDelegate.resize();
});
checkPasswordFields();
};
function checkPasswordFields() {
if (!$scope.encrypt) {
$scope.passphrase = $scope.createPassphrase = $scope.passwordSaved = null;
$timeout(function() {
$scope.$apply();
});
}
};
this.onQrCodeScanned = function(data) {
$scope.secret = data;
@ -156,11 +176,10 @@ angular.module('copayApp.controllers').controller('joinController',
$state.transitionTo('tabs.copayers', {
walletId: client.credentials.walletId
});
}, 100);
}
else $state.go('tabs.home')
});
} else $state.go('tabs.home');
});
}, 100);
});
};
updateSeedSourceSelect();

View file

@ -1,10 +0,0 @@
'use strict';
angular.module('copayApp.controllers').controller('receiveTipsController', function($scope, $log, storageService) {
$scope.close = function() {
$log.debug('Receive tips accepted');
storageService.setReceiveTipsAccepted(true, function(err) {
$scope.receiveTipsModal.hide();
});
}
});

View file

@ -1,11 +0,0 @@
'use strict';
angular.module('copayApp.controllers').controller('scanTipsController', function($scope, $log, storageService) {
$scope.close = function() {
$log.debug('Scan tips accepted');
storageService.setScanTipsAccepted(true, function(err) {
$scope.$emit('TipsModalClosed', function() {});
$scope.scanTipsModal.hide();
});
}
});

View file

@ -1,13 +1,32 @@
'use strict';
angular.module('copayApp.controllers').controller('notificationsController', function($scope, $state, $stateParams, profileService) {
angular.module('copayApp.controllers').controller('notificationsController', function($scope, $state, $timeout, $stateParams, profileService, configService) {
$scope.$on("$ionicView.enter", function(event, data) {
$scope.walletId = data.stateParams.walletId;
});
$scope.walletId = $stateParams.walletId;
$scope.allowNotif = function() {
profileService.pushNotificationsInit();
$timeout(function() {
profileService.pushNotificationsInit();
});
$state.go('onboarding.backupRequest', {
walletId: $scope.walletId
});
}
$scope.disableNotif = function() {
var opts = {
pushNotifications: {
enabled: false
}
};
configService.set(opts, function(err) {
if (err) $log.warn(err);
$state.go('onboarding.backupRequest', {
walletId: $scope.walletId
});
});
};
});

View file

@ -1,28 +1,40 @@
'use strict';
angular.module('copayApp.controllers').controller('tourController',
function($scope, $state, $log, $timeout, $filter, ongoingProcess, profileService, rateService) {
function($scope, $state, $log, $timeout, $filter, ongoingProcess, platformInfo, profileService, rateService) {
var tries = 0;
var isCordova = platformInfo.isCordova;
var isWP = platformInfo.isWP;
var usePushNotifications = isCordova && !isWP;
$scope.init = function() {
$scope.data = {
index: 0
};
$scope.options = {
loop: false,
effect: 'flip',
speed: 500,
spaceBetween: 100
}
$scope.data = {
index: 0
};
rateService.whenAvailable(function() {
var localCurrency = 'USD';
var btcAmount = 1;
var rate = rateService.toFiat(btcAmount * 1e8, localCurrency);
$scope.localCurrencySymbol = '$';
$scope.localCurrencyPerBtc = $filter('formatFiatAmount')(parseFloat(rate.toFixed(2), 10));
$scope.options = {
loop: false,
effect: 'flip',
speed: 500,
spaceBetween: 100
}
$scope.$on("$ionicSlides.sliderInitialized", function(event, data) {
$scope.slider = data.slider;
});
$scope.$on("$ionicSlides.slideChangeStart", function(event, data) {
$scope.data.index = data.slider.activeIndex;
});
$scope.$on("$ionicSlides.slideChangeEnd", function(event, data) {});
$scope.$on("$ionicView.enter", function(event, data) {
rateService.whenAvailable(function() {
var localCurrency = 'USD';
var btcAmount = 1;
var rate = rateService.toFiat(btcAmount * 1e8, localCurrency);
$scope.localCurrencySymbol = '$';
$scope.localCurrencyPerBtc = $filter('formatFiatAmount')(parseFloat(rate.toFixed(2), 10));
});
});
$scope.createDefaultWallet = function() {
@ -33,21 +45,22 @@ angular.module('copayApp.controllers').controller('tourController',
return $timeout(function() {
$log.warn('Retrying to create default wallet......');
if (tries == 3) {
tries == 0;
return $scope.createDefaultWallet();
} else {
tries += 1;
return $scope.createDefaultWallet();
}
return $scope.createDefaultWallet();
}, 3000);
};
ongoingProcess.set('creatingWallet', false);
var wallet = walletClient;
$state.go('onboarding.collectEmail', {
fromOnboarding: true,
walletId: wallet.credentials.walletId
});
var walletId = wallet.credentials.walletId;
if (!usePushNotifications) {
$state.go('onboarding.backupRequest', {
walletId: walletId
});
}
else {
$state.go('onboarding.notifications', {
walletId: walletId
});
}
});
};
@ -60,14 +73,4 @@ angular.module('copayApp.controllers').controller('tourController',
if ($scope.data.index != 2) $scope.slider.slideNext();
else $state.go('onboarding.welcome');
}
$scope.$on("$ionicSlides.sliderInitialized", function(event, data) {
$scope.slider = data.slider;
});
$scope.$on("$ionicSlides.slideChangeStart", function(event, data) {
$scope.data.index = data.slider.activeIndex;
});
$scope.$on("$ionicSlides.slideChangeEnd", function(event, data) {});
});

View file

@ -6,6 +6,11 @@ angular.module('copayApp.controllers').controller('preferencesController',
var walletId = wallet.credentials.walletId;
$scope.wallet = wallet;
$scope.encryptEnabled = {
value: walletService.isEncrypted(wallet)
};
$scope.encryptChange = function() {
if (!wallet) return;
var val = $scope.encryptEnabled.value;
@ -18,6 +23,9 @@ angular.module('copayApp.controllers').controller('preferencesController',
// ToDo show error?
$scope.encryptEnabled.value = false;
$timeout(function() {
$scope.$apply();
});
return;
}
profileService.updateCredentials(JSON.parse(wallet.export()), function() {
@ -32,6 +40,9 @@ angular.module('copayApp.controllers').controller('preferencesController',
// ToDo show error?
$scope.encryptEnabled.value = true;
$timeout(function() {
$scope.$apply();
});
return;
}
profileService.updateCredentials(JSON.parse(wallet.export()), function() {
@ -64,9 +75,7 @@ angular.module('copayApp.controllers').controller('preferencesController',
var config = configService.getSync();
$scope.encryptEnabled = {
value: walletService.isEncrypted(wallet)
};
if (wallet.isPrivKeyExternal)
$scope.externalSource = wallet.getPrivKeyExternalSourceName() == 'ledger' ? 'Ledger' : 'Trezor';

View file

@ -9,13 +9,17 @@ angular.module('copayApp.controllers').controller('preferencesNotificationsContr
var isCordova = platformInfo.isCordova;
var isIOS = platformInfo.isIOS;
$scope.appName = $window.appConfig.nameCase;
$scope.PNEnabledByUser = true;
$scope.isIOSApp = isIOS && isCordova;
if ($scope.isIOSApp) {
cordova.plugins.diagnostic.isRemoteNotificationsEnabled(function(isEnabled) {
$scope.PNEnabledByUser = isEnabled;
$scope.$digest();
});
try {
PushNotification.hasPermission(function(data) {
$scope.PNEnabledByUser = data.isEnabled;
});
} catch(e) {
$log.error(e);
};
}
$scope.pushNotifications = {
@ -23,15 +27,8 @@ angular.module('copayApp.controllers').controller('preferencesNotificationsContr
};
};
$scope.openSettings = function() {
cordova.plugins.diagnostic.switchToSettings(function() {
$log.debug('switched to settings');
}, function(err) {
$log.debug(err);
});
};
$scope.pushNotificationsChange = function() {
if (!$scope.pushNotifications) return;
var opts = {
pushNotifications: {
enabled: $scope.pushNotifications.value
@ -39,9 +36,9 @@ angular.module('copayApp.controllers').controller('preferencesNotificationsContr
};
configService.set(opts, function(err) {
if (opts.pushNotifications.enabled)
pushNotificationsService.enableNotifications(profileService.walletClients);
profileService.pushNotificationsInit();
else
pushNotificationsService.disableNotifications(profileService.walletClients);
pushNotificationsService.disableNotifications(profileService.getWallets());
if (err) $log.debug(err);
});
};

View file

@ -12,6 +12,12 @@ angular.module('copayApp.controllers').controller('tabHomeController',
$scope.name = $window.appConfig.nameCase;
$scope.homeTip = $stateParams.fromOnboarding;
if(!$scope.homeTip){
storageService.getHomeTipAccepted(function(error, value){
$scope.homeTip = (value == 'false') ? false : true;
});
}
$scope.openNotificationModal = function(n) {
wallet = profileService.getWallet(n.walletId);
@ -164,11 +170,8 @@ angular.module('copayApp.controllers').controller('tabHomeController',
};
$scope.hideHomeTip = function() {
$scope.homeTip = null;
$state.transitionTo($state.current, null, {
reload: true,
inherit: false,
notify: false
storageService.setHomeTipAccepted(false, function(error, value){
$scope.homeTip = false;
});
};

View file

@ -5,21 +5,6 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi
$scope.isCordova = platformInfo.isCordova;
$scope.isNW = platformInfo.isNW;
$scope.checkTips = function(force) {
storageService.getReceiveTipsAccepted(function(err, accepted) {
if (err) $log.warn(err);
if (accepted && !force) return;
$timeout(function() {
$ionicModal.fromTemplateUrl('views/modals/receive-tips.html', {
scope: $scope
}).then(function(modal) {
$scope.receiveTipsModal = modal;
$scope.receiveTipsModal.show();
});
}, force ? 1 : 1000);
});
};
$scope.shareAddress = function(addr) {
if ($scope.generatingAddress) return;
@ -84,7 +69,6 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi
});
};
if (!$scope.isCordova) $scope.checkTips();
$scope.$on('Wallet/Changed', function(event, wallet) {
if (!wallet) {
$log.debug('No wallet provided');