From 94e6dd7dac86c96c3b320eec3afa1b72a81c1731 Mon Sep 17 00:00:00 2001 From: Sebastiaan Pasma Date: Tue, 10 Jul 2018 11:08:03 +0200 Subject: [PATCH] clipboard features --- src/js/controllers/tab-send-v2.js | 20 +++++++++++++++----- src/sass/views/tab-send-v2.scss | 17 +++++++++++------ www/views/tab-send-v2.html | 2 +- 3 files changed, 27 insertions(+), 12 deletions(-) diff --git a/src/js/controllers/tab-send-v2.js b/src/js/controllers/tab-send-v2.js index 624acb5bb..5c75957c4 100644 --- a/src/js/controllers/tab-send-v2.js +++ b/src/js/controllers/tab-send-v2.js @@ -2,6 +2,7 @@ angular.module('copayApp.controllers').controller('tabSendV2Controller', function($scope, $rootScope, $log, $timeout, $ionicScrollDelegate, addressbookService, profileService, lodash, $state, walletService, incomingData, popupService, platformInfo, bwcError, gettextCatalog, scannerService, configService, bitcoinCashJsService, $ionicNavBarDelegate, clipboardService) { var clipboardHasAddress = false; + var clipboardHasContent = false; $scope.addContact = function() { $state.go('tabs.settings').then(function() { @@ -12,19 +13,28 @@ angular.module('copayApp.controllers').controller('tabSendV2Controller', functio }; $scope.pasteClipboard = function() { - clipboardService.readFromClipboard(function(text) { - $scope.formData.search = text; - $scope.findContact($scope.formData.search); - }); - } + if ($scope.clipboardHasAddress || $scope.clipboardHasContent) { + clipboardService.readFromClipboard(function(text) { + $scope.formData.search = text; + $scope.findContact($scope.formData.search); + }); + } + }; $scope.$on("$ionicView.enter", function(event, data) { clipboardService.readFromClipboard(function(text) { + if (text.length > 200) { + text = text.substring(0, 200); + } + $scope.clipboardHasAddress = false; + $scope.clipboardHasContent = false; if ((text.indexOf('bitcoincash:') === 0 || text[0] === 'C' || text[0] === 'H' || text[0] === 'p' || text[0] === 'q') && text.replace('bitcoincash:', '').length === 42) { // CashAddr $scope.clipboardHasAddress = true; } else if ((text[0] === "1" || text[0] === "3" || text.substring(0, 3) === "bc1") && text.length >= 26 && text.length <= 35) { // Legacy Addresses $scope.clipboardHasAddress = true; + } else if (text.length > 1) { + $scope.clipboardHasContent = true; } }); diff --git a/src/sass/views/tab-send-v2.scss b/src/sass/views/tab-send-v2.scss index a44973285..630828ae0 100644 --- a/src/sass/views/tab-send-v2.scss +++ b/src/sass/views/tab-send-v2.scss @@ -62,7 +62,10 @@ display: inline-block; margin-bottom: 4px; } - &.contains-address { + &.contains-address, &.contains-content { + .address { + display: none; + } background: #FAB915; color: #FFF !important; border: 0; @@ -70,11 +73,13 @@ .icon { background: url(../img/icon-clipboard-paste-white.svg); } - .address { - display: inline; - } - .non-address { - display: none; + &.contains-address { + .address { + display: inline; + } + .non-address { + display: none; + } } } } diff --git a/www/views/tab-send-v2.html b/www/views/tab-send-v2.html index b42784957..510633a3a 100644 --- a/www/views/tab-send-v2.html +++ b/www/views/tab-send-v2.html @@ -15,7 +15,7 @@
-