diff --git a/src/js/controllers/addresses.js b/src/js/controllers/addresses.js index e347d816a..9b31e431f 100644 --- a/src/js/controllers/addresses.js +++ b/src/js/controllers/addresses.js @@ -1,8 +1,9 @@ 'use strict'; -angular.module('copayApp.controllers').controller('addressesController', function($scope, $stateParams, $state, $timeout, $ionicScrollDelegate, configService, popupService, gettextCatalog, ongoingProcess, lodash, profileService, walletService) { +angular.module('copayApp.controllers').controller('addressesController', function($scope, $stateParams, $state, $timeout, $ionicHistory, $ionicPopover, $ionicScrollDelegate, configService, popupService, gettextCatalog, ongoingProcess, lodash, profileService, walletService, platformInfo) { var UNUSED_ADDRESS_LIMIT = 5; var BALANCE_ADDRESS_LIMIT = 5; + var MENU_ITEM_HEIGHT = 55; var config; var unitName; var unitToSatoshi; @@ -11,6 +12,8 @@ angular.module('copayApp.controllers').controller('addressesController', functio var withBalance; $scope.showInfo = false; $scope.showMore = false; + $scope.allAddressesView = false; + $scope.isCordova = platformInfo.isCordova; $scope.wallet = profileService.getWallet($stateParams.walletId); function init() { @@ -111,6 +114,79 @@ angular.module('copayApp.controllers').controller('addressesController', functio }); }; + $scope.showMenu = function(allAddresses, $event) { + var scanObj = { + text: gettextCatalog.getString('Scan addresses for funds'), + action: scan, + }; + + var sendAddressesObj = { + text: gettextCatalog.getString('Send addresses by email'), + action: sendByEmail, + } + + $scope.items = allAddresses ? [sendAddressesObj] : [scanObj]; + $scope.height = $scope.items.length * MENU_ITEM_HEIGHT; + + $ionicPopover.fromTemplateUrl('views/includes/menu-popover.html', { + scope: $scope + }).then(function(popover) { + $scope.menu = popover; + $scope.menu.show($event); + }); + }; + + var scan = function() { + walletService.startScan($scope.wallet); + $scope.menu.hide(); + $ionicHistory.clearHistory(); + $state.go('tabs.home'); + }; + + var sendByEmail = function() { + function formatDate(ts) { + var dateObj = new Date(ts * 1000); + if (!dateObj) { + $log.debug('Error formating a date'); + return 'DateError'; + } + if (!dateObj.toJSON()) { + return ''; + } + return dateObj.toJSON(); + }; + + ongoingProcess.set('sendingByEmail', true); + $timeout(function() { + var body = 'Copay Wallet "' + $scope.walletName + '" Addresses\n Only Main Addresses are shown.\n\n'; + body += "\n"; + body += $scope.allAddresses.map(function(v) { + return ('* ' + v.address + ' ' + 'xpub' + v.path.substring(1) + ' ' + formatDate(v.createdOn)); + }).join("\n"); + ongoingProcess.set('sendingByEmail', false); + + window.plugins.socialsharing.shareViaEmail( + body, + 'Copay Addresses', + null, // TO: must be null or an array + null, // CC: must be null or an array + null, // BCC: must be null or an array + null, // FILES: can be null, a string, or an array + function() {}, + function() {} + ); + + $scope.menu.hide(); + }); + }; + + $scope.$on("$ionicView.beforeEnter", function(event, data) { + $scope.allAddressesView = data.stateName == 'tabs.receive.allAddresses' ? true : false; + $timeout(function() { + $scope.$apply(); + }); + }); + $scope.$on("$ionicView.afterEnter", function(event, data) { config = configService.getSync().wallet.settings; unitToSatoshi = config.unitToSatoshi; diff --git a/src/js/controllers/preferencesInformation.js b/src/js/controllers/preferencesInformation.js index ac649c56b..983b9cef8 100644 --- a/src/js/controllers/preferencesInformation.js +++ b/src/js/controllers/preferencesInformation.js @@ -1,59 +1,15 @@ 'use strict'; angular.module('copayApp.controllers').controller('preferencesInformation', - function($scope, $log, $timeout, $ionicHistory, platformInfo, lodash, profileService, configService, $stateParams, walletService, $state) { - var base = 'xpub'; + function($scope, $log, $ionicHistory, platformInfo, lodash, profileService, configService, $stateParams, $state) { var wallet = profileService.getWallet($stateParams.walletId); var walletId = wallet.id; var config = configService.getSync(); - var b = 1; + var colorCounter = 1; + var BLACK_WALLET_COLOR = '#202020'; $scope.isCordova = platformInfo.isCordova; config.colorFor = config.colorFor || {}; - $scope.sendAddrs = function() { - function formatDate(ts) { - var dateObj = new Date(ts * 1000); - if (!dateObj) { - $log.debug('Error formating a date'); - return 'DateError'; - } - if (!dateObj.toJSON()) { - return ''; - } - return dateObj.toJSON(); - }; - - $timeout(function() { - walletService.getMainAddresses(wallet, {}, function(err, addrs) { - if (err) { - $log.warn(err); - return; - }; - - var body = 'Copay Wallet "' + $scope.walletName + '" Addresses\n Only Main Addresses are shown.\n\n'; - body += "\n"; - body += addrs.map(function(v) { - return ('* ' + v.address + ' ' + base + v.path.substring(1) + ' ' + formatDate(v.createdOn)); - }).join("\n"); - - window.plugins.socialsharing.shareViaEmail( - body, - 'Copay Addresses', - null, // TO: must be null or an array - null, // CC: must be null or an array - null, // BCC: must be null or an array - null, // FILES: can be null, a string, or an array - function() {}, - function() {} - ); - - $timeout(function() { - $scope.$apply(); - }); - }); - }); - }; - $scope.saveBlack = function() { function save(color) { var opts = { @@ -68,14 +24,8 @@ angular.module('copayApp.controllers').controller('preferencesInformation', }); }; - if (b != 5) return b++; - save('#202020'); - }; - - $scope.scan = function() { - walletService.startScan(wallet); - $ionicHistory.removeBackView(); - $state.go('tabs.home'); + if (colorCounter != 5) return colorCounter++; + save(BLACK_WALLET_COLOR); }; $scope.$on("$ionicView.enter", function(event, data) { diff --git a/src/js/services/onGoingProcess.js b/src/js/services/onGoingProcess.js index 02e007861..0d6977173 100644 --- a/src/js/services/onGoingProcess.js +++ b/src/js/services/onGoingProcess.js @@ -36,6 +36,7 @@ angular.module('copayApp.services').factory('ongoingProcess', function($log, $ti 'sendingFeedback': gettext('Sending feedback...'), 'generatingNewAddress': gettext('Generating new address...'), 'gettingAddresses': gettext('Getting addresses...'), + 'sendingByEmail': gettext('Preparing addresses...'), }; root.clear = function() { diff --git a/src/sass/views/includes/menu-popover.scss b/src/sass/views/includes/menu-popover.scss new file mode 100644 index 000000000..93139b42d --- /dev/null +++ b/src/sass/views/includes/menu-popover.scss @@ -0,0 +1,12 @@ +#menu-popover { + border-radius: 5px; + .list { + .item { + cursor: pointer; + cursor: hand; + &:hover { + background-color: #E4E2E2; + } + } + } +} diff --git a/src/sass/views/tab-receive.scss b/src/sass/views/tab-receive.scss index ead483f40..a9e8cc300 100644 --- a/src/sass/views/tab-receive.scss +++ b/src/sass/views/tab-receive.scss @@ -115,7 +115,6 @@ .item { padding-top: 5px; padding-bottom: 5px; - display: inline-block; font-size: .7rem; @media(min-width:350px){ font-size:.9rem; diff --git a/src/sass/views/views.scss b/src/sass/views/views.scss index d6e41d122..08bcddf5e 100644 --- a/src/sass/views/views.scss +++ b/src/sass/views/views.scss @@ -27,6 +27,7 @@ @import "export"; @import "import"; @import "join"; +@import "includes/menu-popover"; @import "includes/walletActivity"; @import "includes/wallets"; @import "includes/modals/modals"; diff --git a/www/views/addresses.html b/www/views/addresses.html index dc3dd9e2a..ff070b946 100644 --- a/www/views/addresses.html +++ b/www/views/addresses.html @@ -3,10 +3,15 @@ {{'Wallet Addresses' | translate}} + + + -