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..f271ce7e6 100644 --- a/js/controllers/more.js +++ b/js/controllers/more.js @@ -142,8 +142,30 @@ 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 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 {...}, 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/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 @@ -
It's important to backup your profile so that you can recover it in case of disaster. The backup will include all your profile's wallets
-