Fix backup for iOS

This commit is contained in:
Gustavo Maximiliano Cortez 2014-10-16 15:10:13 -03:00
commit 74174f9775
6 changed files with 44 additions and 7 deletions

View file

@ -128,6 +128,13 @@ input:-webkit-autofill, textarea:-webkit-autofill, select:-webkit-autofill, inpu
-webkit-box-shadow: 0 0 0px 1000px white inset;
}
.backup-plain-text {
font-size: 10px;
border: 1px solid #ccc;
padding: 10px;
margin: 10px 0;
}
.status {
font-weight: 700;
-moz-box-shadow: inset 0px -1px 1px 0px rgba(159,47,34,0.30);

View file

@ -5,6 +5,15 @@ angular.module('copayApp.controllers').controller('CopayersController',
$scope.isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0;
$scope.hideAdv = true;
$scope.sendEmail = function(backupPlainText) {
var w = $rootScope.wallet;
var link = 'mailto:'
+ '?subject=' + escape(backupService.getFilename(w))
+ '&body=' + escape(backupPlainText) + '';
window.location.href = link;
};
$scope.skipBackup = function() {
var w = $rootScope.wallet;
w.setBackupReady(true);

View file

@ -27,6 +27,15 @@ angular.module('copayApp.controllers').controller('MoreController',
decimals: 8
}];
$scope.sendEmail = function(backupPlainText) {
var w = $rootScope.wallet;
var link = 'mailto:'
+ '?subject=' + escape(backupService.getFilename(w))
+ '&body=' + escape(backupPlainText) + '';
window.location.href = link;
};
$scope.selectedAlternative = {
name: w.settings.alternativeName,
isoCode: w.settings.alternativeIsoCode

View file

@ -17,11 +17,15 @@ BackupService.prototype.getBackup = function(wallet) {
return wallet.toEncryptedObj();
};
BackupService.prototype.download = function(wallet) {
var ew = this.getBackup(wallet);
BackupService.prototype.getFilename = function(wallet) {
var walletName = this.getName(wallet);
var copayerName = this.getCopayer(wallet);
var filename = (copayerName ? copayerName + '-' : '') + walletName + '-keybackup.json.aes';
return (copayerName ? copayerName + '-' : '') + walletName + '-keybackup.json.aes';
};
BackupService.prototype.download = function(wallet) {
var ew = this.getBackup(wallet);
var filename = this.getFilename(wallet);
this.notifications.success('Backup created', 'Encrypted backup file saved');
var blob = new Blob([ew], {

View file

@ -120,12 +120,16 @@
<span translate>yet to backup the wallet.</span>
</button>
<div ng-show="backupPlainText">
<textarea readonly rows="5">{{backupPlainText}}</textarea>
<div class="show-for-large-up">
<textarea readonly rows="5">{{backupPlainText}}</textarea>
<span translate class="size-12">Copy to clipboard</span> <span class="btn-copy" clip-copy="backupPlainText"> </span>
<div translate class="m10v size-12 text-gray text-right">Copy this text as it is in a safe place (notepad or email)</div>
</div>
<div class="hide-for-large-up m10b">
<span translate class="size-12">Copy this text as it is in a safe place (notepad or email)</span>
<div class="ellipsis backup-plain-text">{{backupPlainText}}</div>
<button class="button secondary m0"
ng-click="sendEmail(backupPlainText)" translate>Send by Email</button>
<div translate class="m10v size-12">Warning: Chrome for iOS remove some symbols from backup, please use only Safari on iOS</div>
</div>
</div>
<button class="button primary right m0"

View file

@ -10,12 +10,16 @@
<a translate class="button primary m0" ng-click="viewBackup()"
ng-show="isSafari && !hideViewBackup">View Backup</a>
<div ng-show="backupPlainText">
<textarea readonly rows="5">{{backupPlainText}}</textarea>
<div class="show-for-large-up">
<textarea readonly rows="5">{{backupPlainText}}</textarea>
<span translate class="size-12">Copy to clipboard</span> <span class="btn-copy" clip-copy="backupPlainText"> </span>
<div translate class="m10t size-12 text-gray text-right">Copy this text as it is in a safe place (notepad or email)</div>
</div>
<div class="hide-for-large-up">
<span translate class="size-12">Copy this text as it is in a safe place (notepad or email)</span>
<div class="ellipsis backup-plain-text">{{backupPlainText}}</div>
<button class="button secondary m0"
ng-click="sendEmail(backupPlainText)" translate>Send by Email</button>
<div translate class="m10v size-12">Warning: Chrome for iOS removes some symbols from backup when opening Gmail client, please use only Safari on iOS (it open native Email application)</div>
</div>
</div>
</div>