From 3c353fdbcb0bb07a58ba0eb4d61afe5780d80425 Mon Sep 17 00:00:00 2001 From: Javier Date: Mon, 12 Sep 2016 15:04:12 -0300 Subject: [PATCH 1/3] show receive tips --- public/views/modals/receive-tips.html | 15 +++++++++++++++ public/views/modals/scan-tips.html | 15 +++++++++++++++ src/js/controllers/modals/receiveTips.js | 11 +++++++++++ src/js/controllers/tab-receive.js | 15 ++++++++++++++- src/js/services/storageService.js | 8 ++++++++ 5 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 public/views/modals/receive-tips.html create mode 100644 public/views/modals/scan-tips.html create mode 100644 src/js/controllers/modals/receiveTips.js diff --git a/public/views/modals/receive-tips.html b/public/views/modals/receive-tips.html new file mode 100644 index 000000000..b148acd35 --- /dev/null +++ b/public/views/modals/receive-tips.html @@ -0,0 +1,15 @@ + + + + + + + +
+

Receive bitcoin by sharing your address

+

Other bitcoin users can scan this code to send you money

+
+
+
diff --git a/public/views/modals/scan-tips.html b/public/views/modals/scan-tips.html new file mode 100644 index 000000000..07ef9e5c7 --- /dev/null +++ b/public/views/modals/scan-tips.html @@ -0,0 +1,15 @@ + + + + + + + +
+

Receive bitcoin by sharing your address

+

Other bitcoin users can scan this code to send you money

+
+
+
diff --git a/src/js/controllers/modals/receiveTips.js b/src/js/controllers/modals/receiveTips.js new file mode 100644 index 000000000..5412a614b --- /dev/null +++ b/src/js/controllers/modals/receiveTips.js @@ -0,0 +1,11 @@ +'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(); + $scope.receiveTipsModal.remove(); + }); + } +}); diff --git a/src/js/controllers/tab-receive.js b/src/js/controllers/tab-receive.js index 3a03d090a..25ceb5964 100644 --- a/src/js/controllers/tab-receive.js +++ b/src/js/controllers/tab-receive.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('copayApp.controllers').controller('tabReceiveController', function($scope, $timeout, $log, platformInfo, walletService, profileService, configService, lodash, gettextCatalog, popupService) { +angular.module('copayApp.controllers').controller('tabReceiveController', function($scope, $timeout, $log, $ionicModal, storageService, platformInfo, walletService, profileService, configService, lodash, gettextCatalog, popupService) { $scope.isCordova = platformInfo.isCordova; @@ -10,6 +10,19 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi }); $scope.isCordova = platformInfo.isCordova; $scope.isNW = platformInfo.isNW; + + storageService.getReceiveTipsAccepted(function(err, accepted) { + if (err || accepted) return; + + $timeout(function() { + $ionicModal.fromTemplateUrl('views/modals/receive-tips.html', { + scope: $scope + }).then(function(modal) { + $scope.receiveTipsModal = modal; + $scope.receiveTipsModal.show(); + }); + }, 1000); + }); } $scope.$on('Wallet/Changed', function(event, wallet) { diff --git a/src/js/services/storageService.js b/src/js/services/storageService.js index a498dfb89..b41b63834 100644 --- a/src/js/services/storageService.js +++ b/src/js/services/storageService.js @@ -342,6 +342,14 @@ angular.module('copayApp.services') }); }; + root.setReceiveTipsAccepted = function(val, cb) { + storage.set('receiveTips', val, cb); + }; + + root.getReceiveTipsAccepted = function(cb) { + storage.get('receiveTips', cb); + }; + root.setAmazonGiftCards = function(network, gcs, cb) { storage.set('amazonGiftCards-' + network, gcs, cb); }; From 091ae73e2d33c4f1253d35c6375e94ce158fb721 Mon Sep 17 00:00:00 2001 From: Javier Date: Mon, 12 Sep 2016 16:41:04 -0300 Subject: [PATCH 2/3] show scan tips --- public/views/modals/scan-tips.html | 8 ++++---- src/js/controllers/modals/receiveTips.js | 1 - src/js/controllers/modals/scanTips.js | 11 +++++++++++ src/js/controllers/modals/scanner.js | 25 +++++++++++++++++++++++- src/js/controllers/tab-receive.js | 8 ++++++-- src/js/services/storageService.js | 8 ++++++++ 6 files changed, 53 insertions(+), 8 deletions(-) create mode 100644 src/js/controllers/modals/scanTips.js diff --git a/public/views/modals/scan-tips.html b/public/views/modals/scan-tips.html index 07ef9e5c7..512b60327 100644 --- a/public/views/modals/scan-tips.html +++ b/public/views/modals/scan-tips.html @@ -1,15 +1,15 @@ - + -
-

Receive bitcoin by sharing your address

-

Other bitcoin users can scan this code to send you money

+

Scan the code to pay with bitcoin

+

QR codes could also contain a bitcoin wallet invitation, or an URL

diff --git a/src/js/controllers/modals/receiveTips.js b/src/js/controllers/modals/receiveTips.js index 5412a614b..2297be7a4 100644 --- a/src/js/controllers/modals/receiveTips.js +++ b/src/js/controllers/modals/receiveTips.js @@ -5,7 +5,6 @@ angular.module('copayApp.controllers').controller('receiveTipsController', funct $log.debug('Receive tips accepted'); storageService.setReceiveTipsAccepted(true, function(err) { $scope.receiveTipsModal.hide(); - $scope.receiveTipsModal.remove(); }); } }); diff --git a/src/js/controllers/modals/scanTips.js b/src/js/controllers/modals/scanTips.js new file mode 100644 index 000000000..a82f70554 --- /dev/null +++ b/src/js/controllers/modals/scanTips.js @@ -0,0 +1,11 @@ +'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(); + }); + } +}); diff --git a/src/js/controllers/modals/scanner.js b/src/js/controllers/modals/scanner.js index c1bccb708..f92b2d14f 100644 --- a/src/js/controllers/modals/scanner.js +++ b/src/js/controllers/modals/scanner.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('copayApp.controllers').controller('scannerController', function($scope, $timeout) { +angular.module('copayApp.controllers').controller('scannerController', function($scope, $timeout, storageService, $ionicModal) { // QR code Scanner var video; @@ -73,6 +73,29 @@ angular.module('copayApp.controllers').controller('scannerController', function( }; $scope.init = function() { + storageService.getScanTipsAccepted(function(err, accepted) { + if (err) $log.warn(err); + if (accepted) { + scannerInit(); + return; + } + + $timeout(function() { + $ionicModal.fromTemplateUrl('views/modals/scan-tips.html', { + scope: $scope + }).then(function(modal) { + $scope.scanTipsModal = modal; + $scope.scanTipsModal.show(); + }); + }, 1000); + }); + }; + + $scope.$on('TipsModalClosed', function(event) { + scannerInit(); + }); + + function scannerInit() { setScanner(); $timeout(function() { if ($scope.beforeScan) { diff --git a/src/js/controllers/tab-receive.js b/src/js/controllers/tab-receive.js index 25ceb5964..2fa2147f6 100644 --- a/src/js/controllers/tab-receive.js +++ b/src/js/controllers/tab-receive.js @@ -10,9 +10,13 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi }); $scope.isCordova = platformInfo.isCordova; $scope.isNW = platformInfo.isNW; + $scope.checkTips(); + } + $scope.checkTips = function() { storageService.getReceiveTipsAccepted(function(err, accepted) { - if (err || accepted) return; + if (err) $log.warn(err); + if (accepted) return; $timeout(function() { $ionicModal.fromTemplateUrl('views/modals/receive-tips.html', { @@ -23,7 +27,7 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi }); }, 1000); }); - } + }; $scope.$on('Wallet/Changed', function(event, wallet) { if (!wallet) { diff --git a/src/js/services/storageService.js b/src/js/services/storageService.js index b41b63834..5e23c7114 100644 --- a/src/js/services/storageService.js +++ b/src/js/services/storageService.js @@ -342,6 +342,14 @@ angular.module('copayApp.services') }); }; + root.setScanTipsAccepted = function(val, cb) { + storage.set('scanTips', val, cb); + }; + + root.getScanTipsAccepted = function(cb) { + storage.get('scanTips', cb); + }; + root.setReceiveTipsAccepted = function(val, cb) { storage.set('receiveTips', val, cb); }; From 11865c25efec66a076f8bf995fee5eba5dd7c88e Mon Sep 17 00:00:00 2001 From: Javier Date: Mon, 12 Sep 2016 17:59:36 -0300 Subject: [PATCH 3/3] not available for mobile --- src/js/controllers/modals/scanner.js | 8 +++++++- src/js/controllers/tab-receive.js | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/js/controllers/modals/scanner.js b/src/js/controllers/modals/scanner.js index f92b2d14f..6616d505a 100644 --- a/src/js/controllers/modals/scanner.js +++ b/src/js/controllers/modals/scanner.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('copayApp.controllers').controller('scannerController', function($scope, $timeout, storageService, $ionicModal) { +angular.module('copayApp.controllers').controller('scannerController', function($scope, $timeout, storageService, $ionicModal, platformInfo) { // QR code Scanner var video; @@ -73,6 +73,12 @@ angular.module('copayApp.controllers').controller('scannerController', function( }; $scope.init = function() { + if (platformInfo.isCordova) scannerInit(); + else checkTips(); + }; + + function checkTips() { + //TODO addapt tips to the new QR plugin (mobile) storageService.getScanTipsAccepted(function(err, accepted) { if (err) $log.warn(err); if (accepted) { diff --git a/src/js/controllers/tab-receive.js b/src/js/controllers/tab-receive.js index 2fa2147f6..187d3822e 100644 --- a/src/js/controllers/tab-receive.js +++ b/src/js/controllers/tab-receive.js @@ -8,9 +8,9 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi $scope.wallets = profileService.getWallets({ onlyComplete: true }); - $scope.isCordova = platformInfo.isCordova; $scope.isNW = platformInfo.isNW; - $scope.checkTips(); + $scope.isCordova = platformInfo.isCordova; + if (!$scope.isCordova) $scope.checkTips(); } $scope.checkTips = function() {