From e3d260883c0388edd986f6c2f890ffc29ad3e29b Mon Sep 17 00:00:00 2001 From: Gustavo Maximiliano Cortez Date: Thu, 22 Jan 2015 14:34:36 -0300 Subject: [PATCH 1/4] Wallet backup: copy to clipboard or sent by email --- cordova/build.sh | 9 +++++++++ js/controllers/more.js | 25 ++++++++++++++++++++++++- views/more.html | 15 +++++++++++---- 3 files changed, 44 insertions(+), 5 deletions(-) diff --git a/cordova/build.sh b/cordova/build.sh index 4dc2ea957..321545ae3 100755 --- a/cordova/build.sh +++ b/cordova/build.sh @@ -100,6 +100,15 @@ if [ ! -d $PROJECT ]; then cordova plugin add org.apache.cordova.inappbrowser checkOK + cordova plugin add nl.x-services.plugins.toast && cordova prepare + checkOK + + cordova plugin add https://github.com/VersoSolutions/CordovaClipboard + checkOK + + cordova plugin add https://github.com/katzer/cordova-plugin-email-composer.git + checkOK + fi if $DBGJS diff --git a/js/controllers/more.js b/js/controllers/more.js index 36f8e5159..242284a6d 100644 --- a/js/controllers/more.js +++ b/js/controllers/more.js @@ -142,8 +142,31 @@ angular.module('copayApp.controllers').controller('MoreController', }; $scope.viewWalletBackup = function() { - $scope.backupWalletPlainText = backupService.walletEncrypted(w); + $scope.loading = true; + $timeout(function() { + $scope.backupWalletPlainText = backupService.walletEncrypted(w); + }, 100); }; + $scope.copyWalletBackup = function() { + var ew = backupService.walletEncrypted(w); + window.cordova.plugins.clipboard.copy(ew); + window.plugins.toast.showShortCenter('Copied to clipboard'); + }; + + $scope.sendWalletBackup = function() { + window.plugins.toast.showShortCenter('Preparing backup...'); + var name = (w.name || w.id); + var ew = backupService.walletEncrypted(w); + var filename = name + '-keybackup.json.aes'; + var properties = { + subject: 'Copay Wallet Backup: ' + name, + body: 'Here is the encrypted backup of the wallet ' + + name + ': \n\n' + ew + + '\n\n To import this backup, copy all text between {...}, inclusive the symbols {}', + isHtml: false + }; + window.plugin.email.open(properties); + }; }); diff --git a/views/more.html b/views/more.html index 2bcb1cccd..2e5664139 100644 --- a/views/more.html +++ b/views/more.html @@ -56,19 +56,26 @@ + ng-show="isSafari && !isCordova"> View Backup +
+

Backup options

+ + +
-
+

Copy backup in a safe place

-
-
+
+ Copy this text as it is in a safe place (notepad or email)
From 53a72781239029f9c3a539010c1196b5a16b842e Mon Sep 17 00:00:00 2001 From: Gustavo Maximiliano Cortez Date: Thu, 22 Jan 2015 14:44:27 -0300 Subject: [PATCH 2/4] show quota info only for remote wallets --- views/profile.html | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/views/profile.html b/views/profile.html index 96577c9a5..e7ad836aa 100644 --- a/views/profile.html +++ b/views/profile.html @@ -33,18 +33,20 @@
-
- -
-
-
- Your current server usage quotas are: {{perItem}}kB per wallet and up to {{nrWallets}} wallets. +
+
+ +
+
+
+ Your current server usage quotas are: {{perItem}}kB per wallet and up to {{nrWallets}} wallets. +
+
+ Confirm your email address to increase storage usage limits. +
-
- Confirm your email address to increase storage usage limits. -
-
-
+
+
From b2ddca45691b434c40f81aa72fd8b850b031f556 Mon Sep 17 00:00:00 2001 From: Gustavo Maximiliano Cortez Date: Thu, 22 Jan 2015 15:08:19 -0300 Subject: [PATCH 3/4] Profile backup: copy to clipboard or send by email --- js/controllers/more.js | 3 +- js/controllers/profile.js | 25 +++++++++++++++-- views/more.html | 2 +- views/profile.html | 58 +++++++++++++++++++++++++-------------- 4 files changed, 62 insertions(+), 26 deletions(-) diff --git a/js/controllers/more.js b/js/controllers/more.js index 242284a6d..f271ce7e6 100644 --- a/js/controllers/more.js +++ b/js/controllers/more.js @@ -158,12 +158,11 @@ angular.module('copayApp.controllers').controller('MoreController', window.plugins.toast.showShortCenter('Preparing backup...'); var name = (w.name || w.id); var ew = backupService.walletEncrypted(w); - var filename = name + '-keybackup.json.aes'; var properties = { subject: 'Copay Wallet Backup: ' + name, body: 'Here is the encrypted backup of the wallet ' + name + ': \n\n' + ew - + '\n\n To import this backup, copy all text between {...}, inclusive the symbols {}', + + '\n\n To import this backup, copy all text between {...}, including the symbols {}', isHtml: false }; window.plugin.email.open(properties); diff --git a/js/controllers/profile.js b/js/controllers/profile.js index be37345a2..52bc5149b 100644 --- a/js/controllers/profile.js +++ b/js/controllers/profile.js @@ -12,10 +12,31 @@ angular.module('copayApp.controllers').controller('ProfileController', function( }; $scope.viewProfileBackup = function() { - $scope.backupProfilePlainText = backupService.profileEncrypted($rootScope.iden); - $scope.hideViewProfileBackup = true; + $scope.loading = true; + $timeout(function() { + $scope.backupProfilePlainText = backupService.profileEncrypted($rootScope.iden); + }, 100); }; + $scope.copyProfileBackup = function() { + var ep = backupService.profileEncrypted($rootScope.iden); + window.cordova.plugins.clipboard.copy(ep); + window.plugins.toast.showShortCenter('Copied to clipboard'); + }; + + $scope.sendProfileBackup = function() { + window.plugins.toast.showShortCenter('Preparing backup...'); + var name = $rootScope.iden.fullName; + var ep = backupService.profileEncrypted($rootScope.iden); + var properties = { + subject: 'Copay Profile Backup: ' + name, + body: 'Here is the encrypted backup of the profile ' + + name + ': \n\n' + ep + + '\n\n To import this backup, copy all text between {...}, including the symbols {}', + isHtml: false + }; + window.plugin.email.open(properties); + }; $scope.init = function() { if ($rootScope.quotaPerItem) { diff --git a/views/more.html b/views/more.html index 2e5664139..58301d014 100644 --- a/views/more.html +++ b/views/more.html @@ -56,7 +56,7 @@ + ng-show="isSafari && !isCordova"> View backup

Backup options

-
+
+
+ + +
+

Backup options

+ + +
+
+
+ +
+
+

Copy backup in a safe place

+
+ + +
+
+ + Copy this text as it is in a safe place (notepad or email) +
+
+
+ +
From 608fed438663a23b2138aaf6d47ce5bfbf0efeac Mon Sep 17 00:00:00 2001 From: Gustavo Maximiliano Cortez Date: Thu, 22 Jan 2015 17:12:55 -0300 Subject: [PATCH 4/4] copy address to clipboard on mobile --- js/controllers/receive.js | 18 +++++++++++++----- views/modals/qr-address.html | 14 ++++++++++---- views/receive.html | 2 +- 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/js/controllers/receive.js b/js/controllers/receive.js index 07aa6b6d8..ddb125490 100644 --- a/js/controllers/receive.js +++ b/js/controllers/receive.js @@ -1,17 +1,20 @@ 'use strict'; angular.module('copayApp.controllers').controller('ReceiveController', - function($scope, $rootScope, $timeout, $modal) { + function($scope, $rootScope, $timeout, $modal, isCordova) { $scope.newAddr = function() { var w = $rootScope.wallet; - $scope.loading = true; var lastAddr = w.generateAddress(null); $scope.setAddressList(); $scope.addr = lastAddr; - $timeout(function() { - $scope.loading = false; - }, 1); + }; + + $scope.copyAddress = function(addr) { + if (isCordova) { + window.cordova.plugins.clipboard.copy(addr); + window.plugins.toast.showShortCenter('Copied to clipboard'); + } }; $scope.init = function() { @@ -32,8 +35,13 @@ angular.module('copayApp.controllers').controller('ReceiveController', }; $scope.openAddressModal = function(address) { + var scope = $scope; var ModalInstanceCtrl = function($scope, $modalInstance, address) { $scope.address = address; + $scope.isCordova = isCordova; + $scope.copyAddress = function(addr) { + scope.copyAddress(addr); + }; $scope.cancel = function() { $modalInstance.dismiss('cancel'); diff --git a/views/modals/qr-address.html b/views/modals/qr-address.html index 78444bfa0..8654a2e96 100644 --- a/views/modals/qr-address.html +++ b/views/modals/qr-address.html @@ -1,13 +1,19 @@ -
- +
+ -
+
- {{address.address}} change + {{addr}} change
({{label}})
+
+ +
diff --git a/views/receive.html b/views/receive.html index d76f3387d..abf765ce3 100644 --- a/views/receive.html +++ b/views/receive.html @@ -10,7 +10,7 @@

My Bitcoin address:

-
+

{{addr}}