From e3d260883c0388edd986f6c2f890ffc29ad3e29b Mon Sep 17 00:00:00 2001 From: Gustavo Maximiliano Cortez Date: Thu, 22 Jan 2015 14:34:36 -0300 Subject: [PATCH] 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)