Wallet backup: copy to clipboard or sent by email

This commit is contained in:
Gustavo Maximiliano Cortez 2015-01-22 14:34:36 -03:00
parent 02444a9c43
commit e3d260883c
3 changed files with 44 additions and 5 deletions

View File

@ -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

View File

@ -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);
};
});

View File

@ -56,19 +56,26 @@
<button class="primary expand" ng-click="downloadWalletBackup()" ng-disabled="loading"
ng-show="!isSafari && !isCordova"><i class="fi-download"></i> Download backup</button>
<button class="primary expand" ng-click="viewWalletBackup()" ng-disabled="loading"
ng-show="isSafari || isCordova"><i class="fi-eye"></i> View Backup</button>
ng-show="isSafari && !isCordova"><i class="fi-eye"></i> View Backup</button>
<div ng-show="isCordova">
<h4>Backup options</h4>
<button class="primary expand"
ng-click="copyWalletBackup()"><i class="fi-clipboard-pencil"></i> Copy to clipboard</button>
<button class="primary expand"
ng-click="sendWalletBackup()"><i class="fi-mail"></i> Send by email</button>
</div>
</div>
</div>
<div class="row" ng-show="backupWalletPlainText">
<div class="row m20b" ng-show="backupWalletPlainText">
<div class="large-12 columns">
<h3>Copy backup in a safe place</h3>
<div class="input">
<textarea class="show-for-large-up" readonly rows="7">{{backupWalletPlainText}}</textarea>
<textarea class="hide-for-large-up" rows="12">{{backupWalletPlainText}}</textarea>
<i class="icon-compose"></i>
</div>
<div translate class="m10t size-12 text-gray text-right">
<div translate class="size-12 text-gray text-right">
<i class="icon-compose"></i>
Copy this text as it is in a safe place (notepad or email)
</div>
</div>