diff --git a/public/views/includes/backupLaterPopup.html b/public/views/includes/backupLaterPopup.html index 91d28fd13..5e6304755 100644 --- a/public/views/includes/backupLaterPopup.html +++ b/public/views/includes/backupLaterPopup.html @@ -1,10 +1,10 @@

Without a backup, you could lose money

If something happens to this device, this app is deleted, or your password forgotten, neither you nor Bitpay can revoer your funds. - -
diff --git a/public/views/includes/backupWarningPopup.html b/public/views/includes/backupWarningPopup.html index a8e3cd9c1..fbe1b79fd 100644 --- a/public/views/includes/backupWarningPopup.html +++ b/public/views/includes/backupWarningPopup.html @@ -1,7 +1,7 @@

Screenshots are not secure

if you take a screenshot, your backup may be viewed by others apps. You can make a safe backup with paper and a pen. -
diff --git a/public/views/onboarding/backupWarning.html b/public/views/onboarding/backupWarning.html index aeef8f7d0..0a5a4086d 100644 --- a/public/views/onboarding/backupWarning.html +++ b/public/views/onboarding/backupWarning.html @@ -2,7 +2,7 @@ diff --git a/public/views/onboarding/collectEmail.html b/public/views/onboarding/collectEmail.html index a539eaaa0..eb5bda54b 100644 --- a/public/views/onboarding/collectEmail.html +++ b/public/views/onboarding/collectEmail.html @@ -1,14 +1,14 @@ - - + + - - - Wallet Created - Where would you like to receive email notifications about payments + + Wallet Created + Where would you like to receive email notifications about payments
diff --git a/public/views/onboarding/terms.html b/public/views/onboarding/terms.html index a69ffa564..49861a15e 100644 --- a/public/views/onboarding/terms.html +++ b/public/views/onboarding/terms.html @@ -1,9 +1,9 @@ - Terms of Use + {{'Terms of Use' | translate}} diff --git a/public/views/onboarding/tour.html b/public/views/onboarding/tour.html index be57326b9..0261a14c1 100644 --- a/public/views/onboarding/tour.html +++ b/public/views/onboarding/tour.html @@ -1,14 +1,14 @@ - Get Started + {{'Get Started' | translate}} - @@ -23,7 +23,7 @@

Just scan the code to pay

- @@ -39,7 +39,7 @@

The exchange rate changes with the market

- @@ -55,7 +55,7 @@

Not even BitPay can access it

- diff --git a/public/views/onboarding/welcome.html b/public/views/onboarding/welcome.html index dbcde98e3..21d9018cf 100644 --- a/public/views/onboarding/welcome.html +++ b/public/views/onboarding/welcome.html @@ -1,13 +1,12 @@ - +
-

bitpay

- +

bitpay

Take control of your money - get started with bitcoin - +
diff --git a/public/views/tab-import-file.html b/public/views/tab-import-file.html index 437251135..e0069afa8 100644 --- a/public/views/tab-import-file.html +++ b/public/views/tab-import-file.html @@ -1,6 +1,6 @@ - + - diff --git a/public/views/tab-import-hardware.html b/public/views/tab-import-hardware.html index 9a85f29f7..041f3d499 100644 --- a/public/views/tab-import-hardware.html +++ b/public/views/tab-import-hardware.html @@ -1,6 +1,6 @@ - + - diff --git a/public/views/tab-import-phrase.html b/public/views/tab-import-phrase.html index c0255a2c7..42d4525fd 100644 --- a/public/views/tab-import-phrase.html +++ b/public/views/tab-import-phrase.html @@ -1,6 +1,6 @@ - + - diff --git a/src/js/controllers/backController.js b/src/js/controllers/backController.js new file mode 100644 index 000000000..285f8f630 --- /dev/null +++ b/src/js/controllers/backController.js @@ -0,0 +1,19 @@ +'use strict'; + +angular.module('copayApp.controllers').controller('backController', function($scope, $state, $stateParams, platformInfo) { + + var isCordova = platformInfo.isCordova; + var isWP = platformInfo.isWP; + var usePushNotifications = isCordova && !isWP; + + $scope.importGoBack = function() { + if ($stateParams.fromOnboarding) $state.go('onboarding.welcome'); + else $state.go('add.main'); + }; + + $scope.onboardingMailSkip = function() { + if (!usePushNotifications) $state.go('onboarding.backupRequest'); + else $state.go('onboarding.notifications'); + } + +}); diff --git a/src/js/controllers/backup.js b/src/js/controllers/backup.js index 83178813c..27ad27aba 100644 --- a/src/js/controllers/backup.js +++ b/src/js/controllers/backup.js @@ -1,7 +1,7 @@ 'use strict'; angular.module('copayApp.controllers').controller('backupController', - function($rootScope, $scope, $timeout, $log, $state, $stateParams, $ionicPopup, $ionicNavBarDelegate, uxLanguage, lodash, fingerprintService, platformInfo, configService, profileService, bwcService, walletService, ongoingProcess) { + function($rootScope, $scope, $timeout, $log, $state, $stateParams, $ionicPopup, $ionicNavBarDelegate, uxLanguage, lodash, fingerprintService, platformInfo, configService, profileService, bwcService, walletService, ongoingProcess, storageService) { var wallet = profileService.getWallet($stateParams.walletId); $ionicNavBarDelegate.title(wallet.credentials.walletName); $scope.n = wallet.n; @@ -136,8 +136,11 @@ angular.module('copayApp.controllers').controller('backupController', } } - $rootScope.$emit('Local/BackupDone'); - return cb(); + $log.debug('Backup done'); + storageService.setBackupFlag(wallet.credentials.walletId, function(err) { + $log.debug('Backup stored'); + return cb(); + }); }, 1); }; diff --git a/src/js/controllers/create.js b/src/js/controllers/create.js index edf5085b8..1a1ec2dd2 100644 --- a/src/js/controllers/create.js +++ b/src/js/controllers/create.js @@ -1,7 +1,7 @@ 'use strict'; angular.module('copayApp.controllers').controller('createController', - function($scope, $rootScope, $timeout, $log, lodash, $state, profileService, configService, gettext, ledger, trezor, platformInfo, derivationPathHelper, ongoingProcess, walletService) { + function($scope, $rootScope, $timeout, $log, lodash, $state, profileService, configService, gettext, ledger, trezor, platformInfo, derivationPathHelper, ongoingProcess, walletService, storageService) { var isChromeApp = platformInfo.isChromeApp; var isCordova = platformInfo.isCordova; @@ -184,7 +184,10 @@ angular.module('copayApp.controllers').controller('createController', if (self.seedSourceId == 'set') { $timeout(function() { - $rootScope.$emit('Local/BackupDone'); + $log.debug('Backup done'); + storageService.setBackupFlag(wallet.credentials.walletId, function(err) { + $log.debug('Backup stored'); + }); }, 1); } $state.go('tabs.home') diff --git a/src/js/controllers/disclaimer.js b/src/js/controllers/disclaimer.js deleted file mode 100644 index 9ce990011..000000000 --- a/src/js/controllers/disclaimer.js +++ /dev/null @@ -1,69 +0,0 @@ -'use strict'; - -angular.module('copayApp.controllers').controller('disclaimerController', - function($scope, $rootScope, $timeout, $log, $ionicSideMenuDelegate, profileService, applicationService, gettextCatalog, uxLanguage, $state, storageService, gettext, platformInfo, ongoingProcess) { - var tries = 0; - var isCordova = platformInfo.isCordova; - - ongoingProcess.set('creatingWallet', true); - - var create = function(opts) { - opts = opts || {}; - $log.debug('Creating profile'); - - profileService.create(opts, function(err) { - if (err) { - $log.warn(err); - $scope.error = err; - $scope.$apply(); - - return $timeout(function() { - $log.warn('Retrying to create profile......'); - if (tries == 3) { - tries == 0; - return create({ - noWallet: true - }); - } else { - tries += 1; - return create(); - } - }, 3000); - }; - $scope.error = ""; - ongoingProcess.set('creatingWallet', false); - }); - }; - - $scope.init = function(opts) { - $ionicSideMenuDelegate.canDragContent(false); - $scope.lang = uxLanguage.currentLanguage; - - storageService.getProfile(function(err, profile) { - if (!profile) { - create(opts); - } else { - $log.info('There is already a profile'); - ongoingProcess.set('creatingWallet', false); - profileService.bindProfile(profile, function(err) { - if (!err || !err.message || !err.message.match('NONAGREEDDISCLAIMER')) { - $log.debug('Disclaimer already accepted at #disclaimer. Redirect to Wallet Home.'); - $ionicSideMenuDelegate.canDragContent(true); - $state.go('tabs.home'); - } - }); - } - }); - }; - - $scope.accept = function() { - profileService.setDisclaimerAccepted(function(err) { - if (err) $log.error(err); - else { - $ionicSideMenuDelegate.canDragContent(true); - $rootScope.$emit('disclaimerAccepted'); - $state.go('tabs.home'); - } - }); - }; - }); diff --git a/src/js/controllers/import.js b/src/js/controllers/import.js index 6e4b4deab..cb24f92cc 100644 --- a/src/js/controllers/import.js +++ b/src/js/controllers/import.js @@ -15,10 +15,6 @@ angular.module('copayApp.controllers').controller('importController', $scope.account = 1; $scope.importErr = false; - $scope.goBack = function() { - $ionicHistory.goBack(); - }; - var updateSeedSourceSelect = function() { $scope.seedOptions = []; @@ -114,6 +110,11 @@ angular.module('copayApp.controllers').controller('importController', }); $rootScope.$emit('Local/WalletImported', client.credentials.walletId); + if ($stateParams.fromOnboarding) + profileService.setDisclaimerAccepted(function(err) { + if (err) $log.error(err); + }); + $state.go('tabs.home'); }); }, 100); @@ -141,6 +142,11 @@ angular.module('copayApp.controllers').controller('importController', }); $rootScope.$emit('Local/WalletImported', client.credentials.walletId); + if ($stateParams.fromOnboarding) + profileService.setDisclaimerAccepted(function(err) { + if (err) $log.error(err); + }); + $state.go('tabs.home'); }); }, 100); @@ -161,6 +167,11 @@ angular.module('copayApp.controllers').controller('importController', }); } $rootScope.$emit('Local/WalletImported', walletId); + if ($stateParams.fromOnboarding) + profileService.setDisclaimerAccepted(function(err) { + if (err) $log.error(err); + }); + $state.go('tabs.home'); }); }, 100); @@ -190,6 +201,11 @@ angular.module('copayApp.controllers').controller('importController', }); $rootScope.$emit('Local/WalletImported', client.credentials.walletId); + if ($stateParams.fromOnboarding) + profileService.setDisclaimerAccepted(function(err) { + if (err) $log.error(err); + }); + $state.go('tabs.home'); }); }, 100); @@ -324,6 +340,11 @@ angular.module('copayApp.controllers').controller('importController', $log.debug('Remote preferences saved for:' + wallet.walletId) }); $rootScope.$emit('Local/WalletImported', wallet.walletId); + if ($stateParams.fromOnboarding) + profileService.setDisclaimerAccepted(function(err) { + if (err) $log.error(err); + }); + $state.go('tabs.home'); }); }, 100); @@ -401,6 +422,12 @@ angular.module('copayApp.controllers').controller('importController', $log.debug('Remote preferences saved for:' + wallet.walletId) }); $rootScope.$emit('Local/WalletImported', wallet.walletId); + + if ($stateParams.fromOnboarding) + profileService.setDisclaimerAccepted(function(err) { + if (err) $log.error(err); + }); + $state.go('tabs.home'); }); }, 100); diff --git a/src/js/controllers/onboarding/backupWarning.js b/src/js/controllers/onboarding/backupWarning.js index f0b7c4978..9067b1bf6 100644 --- a/src/js/controllers/onboarding/backupWarning.js +++ b/src/js/controllers/onboarding/backupWarning.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('copayApp.controllers').controller('backupWarningController', function($scope, $state, $ionicPopup, profileService) { +angular.module('copayApp.controllers').controller('backupWarningController', function($scope, $state, $ionicPopup, $stateParams, profileService) { $scope.openPopup = function() { var backupWarningPopup = $ionicPopup.show({ @@ -10,12 +10,10 @@ angular.module('copayApp.controllers').controller('backupWarningController', fun $scope.close = function() { backupWarningPopup.close(); - var wallet = profileService.getWallets()[0]; $state.go('wallet.backup', { - walletId: wallet.credentials.walletId, + walletId: $stateParams.walletId, fromOnboarding: true }) }; } - }); diff --git a/src/js/controllers/onboarding/collectEmail.js b/src/js/controllers/onboarding/collectEmail.js index 8fda2d4df..220c349e5 100644 --- a/src/js/controllers/onboarding/collectEmail.js +++ b/src/js/controllers/onboarding/collectEmail.js @@ -6,11 +6,6 @@ angular.module('copayApp.controllers').controller('collectEmailController', func var isWP = platformInfo.isWP; var usePushNotifications = isCordova && !isWP; - $scope.skip = function() { - if (!usePushNotifications) $state.go('onboarding.backupRequest'); - else $state.go('onboarding.notifications'); - } - $scope.save = function(form) { var wallet = profileService.getWallet($stateParams.walletId); var email = $scope.email || ''; diff --git a/src/js/controllers/onboarding/tour.js b/src/js/controllers/onboarding/tour.js index 662b0431d..c5b69bde3 100644 --- a/src/js/controllers/onboarding/tour.js +++ b/src/js/controllers/onboarding/tour.js @@ -2,8 +2,9 @@ angular.module('copayApp.controllers').controller('tourController', function($scope, $state, $log, $timeout, ongoingProcess, profileService) { - $scope.init = function() { + var tries = 0; + $scope.init = function() { $scope.data = { index: 0 }; @@ -16,33 +17,25 @@ angular.module('copayApp.controllers').controller('tourController', } }; - $scope.createProfile = function(opts) { - var tries = 0; - opts = opts || {}; - $log.debug('Creating profile'); + $scope.createDefaultWallet = function() { ongoingProcess.set('creatingWallet', true); - profileService.create(opts, function(err) { + profileService.createDefaultWallet(function(err, walletClient) { if (err) { $log.warn(err); - $scope.error = err; - $scope.$apply(); return $timeout(function() { - $log.warn('Retrying to create profile......'); + $log.warn('Retrying to create default wallet......'); if (tries == 3) { tries == 0; - return $scope.createProfile({ - noWallet: true - }); + return $scope.createDefaultWallet(); } else { tries += 1; - return $scope.createProfile(); + return $scope.createDefaultWallet(); } }, 3000); }; - $scope.error = ""; ongoingProcess.set('creatingWallet', false); - var wallet = profileService.getWallets()[0]; + var wallet = walletClient; $state.go('onboarding.collectEmail', { walletId: wallet.credentials.walletId }); diff --git a/src/js/controllers/onboarding/welcomeController.js b/src/js/controllers/onboarding/welcomeController.js new file mode 100644 index 000000000..b6e529a11 --- /dev/null +++ b/src/js/controllers/onboarding/welcomeController.js @@ -0,0 +1,18 @@ +'use strict'; + +angular.module('copayApp.controllers').controller('welcomeController', function($scope, $state, $timeout, $log, $ionicPopup, profileService) { + + $scope.goImport = function() { + $state.go('add.import.phrase', { + fromOnboarding: true + }); + }; + + $scope.createProfile = function() { + $log.debug('Creating profile'); + profileService.createProfile(function(err) { + if (err) $log.warn(err); + }); + }; + +}); diff --git a/src/js/routes.js b/src/js/routes.js index 36d1f9edc..c12c61be6 100644 --- a/src/js/routes.js +++ b/src/js/routes.js @@ -412,7 +412,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr } }) .state('add.import', { - url: '/import', + url: '/import/:fromOnboarding', abstract: true, views: { 'add': { @@ -554,7 +554,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr */ .state('onboarding', { - url: '/onboarding', + url: '/onboarding/:walletId', abstract: true, template: '' }) diff --git a/src/js/services/profileService.js b/src/js/services/profileService.js index 44c38b697..3026753f9 100644 --- a/src/js/services/profileService.js +++ b/src/js/services/profileService.js @@ -367,26 +367,6 @@ angular.module('copayApp.services') }, 50); }; - // Creates the default Copay profile and its wallet - root.createDefaultProfile = function(opts, cb) { - var p = Profile.create(); - - if (opts.noWallet) { - return cb(null, p); - } - - opts.m = 1; - opts.n = 1; - opts.network = 'livenet'; - - doCreateWallet(opts, function(err, walletClient) { - if (err) return cb(err); - - p.addWallet(JSON.parse(walletClient.export())); - return cb(null, p); - }); - }; - // create and store a wallet root.createWallet = function(opts, cb) { doCreateWallet(opts, function(err, walletClient, secret) { @@ -633,26 +613,33 @@ angular.module('copayApp.services') }); }; - root.create = function(opts, cb) { - $log.info('Creating profile', opts); + root.createProfile = function(cb) { + $log.info('Creating profile'); var defaults = configService.getDefaults(); configService.get(function(err) { - root.createDefaultProfile(opts, function(err, p) { - if (err) return cb(err); + if (err) $log.debug(err); - storageService.storeNewProfile(p, function(err) { - if (err) return cb(err); - root.bindProfile(p, function(err) { - // ignore NONAGREEDDISCLAIMER - if (err && err.toString().match('NONAGREEDDISCLAIMER')) return cb(); - return cb(err); - }); + var p = Profile.create(); + storageService.storeNewProfile(p, function(err) { + if (err) return cb(err); + root.bindProfile(p, function(err) { + // ignore NONAGREEDDISCLAIMER + if (err && err.toString().match('NONAGREEDDISCLAIMER')) return cb(); + return cb(err); }); }); }); }; + root.createDefaultWallet = function(cb) { + var opts = {}; + opts.m = 1; + opts.n = 1; + opts.network = 'livenet'; + root.createWallet(opts, cb); + }; + root.setDisclaimerAccepted = function(cb) { root.profile.disclaimerAccepted = true; storageService.storeProfile(root.profile, function(err) {