From bce77de16ce8e71e2660a3062a14403b22a99ec0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Baz=C3=A1n?= Date: Tue, 23 Aug 2016 12:01:09 -0300 Subject: [PATCH 1/4] fixing routes on settings --- public/views/preferencesLogs.html | 2 +- public/views/tab-settings.html | 2 +- public/views/termOfUse.html | 2 +- public/views/translators.html | 2 +- src/js/controllers/preferencesAltCurrency.js | 8 ++++---- src/js/controllers/preferencesLanguage.js | 6 +++--- src/js/controllers/preferencesUnit.js | 6 ++---- src/js/services/applicationService.js | 4 ++-- 8 files changed, 15 insertions(+), 17 deletions(-) diff --git a/public/views/preferencesLogs.html b/public/views/preferencesLogs.html index 6a907c3f9..6cc354449 100644 --- a/public/views/preferencesLogs.html +++ b/public/views/preferencesLogs.html @@ -2,7 +2,7 @@ Session log - diff --git a/public/views/tab-settings.html b/public/views/tab-settings.html index de055d49d..f3f812204 100644 --- a/public/views/tab-settings.html +++ b/public/views/tab-settings.html @@ -10,7 +10,7 @@ Address Book -
+
Feedback
diff --git a/public/views/termOfUse.html b/public/views/termOfUse.html index 4291ed0c7..f98907319 100644 --- a/public/views/termOfUse.html +++ b/public/views/termOfUse.html @@ -2,7 +2,7 @@ Terms of Use - diff --git a/public/views/translators.html b/public/views/translators.html index 388c27cd7..da8c182cd 100644 --- a/public/views/translators.html +++ b/public/views/translators.html @@ -2,7 +2,7 @@ Translators - diff --git a/src/js/controllers/preferencesAltCurrency.js b/src/js/controllers/preferencesAltCurrency.js index 20bdb53c9..290e5187b 100644 --- a/src/js/controllers/preferencesAltCurrency.js +++ b/src/js/controllers/preferencesAltCurrency.js @@ -1,7 +1,7 @@ 'use strict'; angular.module('copayApp.controllers').controller('preferencesAltCurrencyController', - function($scope, $log, $timeout, configService, rateService, lodash, profileService, walletService, $state) { + function($scope, $log, $state, $timeout, configService, rateService, lodash, profileService, walletService) { var next = 10; var completeAlternativeList; @@ -42,9 +42,9 @@ angular.module('copayApp.controllers').controller('preferencesAltCurrencyControl configService.set(opts, function(err) { if (err) $log.warn(err); - $state.go('preferencesGlobal'); - $scope.$emit('Local/UnitSettingUpdated'); - walletService.updateRemotePreferences(profileService.getClients(), {}, function() { + $state.go('tabs.settings'); + + walletService.updateRemotePreferences(profileService.getWallets(), {}, function() { $log.debug('Remote preferences saved'); }); }); diff --git a/src/js/controllers/preferencesLanguage.js b/src/js/controllers/preferencesLanguage.js index 2717d3e8e..1cd78702d 100644 --- a/src/js/controllers/preferencesLanguage.js +++ b/src/js/controllers/preferencesLanguage.js @@ -1,7 +1,7 @@ 'use strict'; angular.module('copayApp.controllers').controller('preferencesLanguageController', - function($scope, $log, $state, configService, profileService, uxLanguage, walletService, go) { + function($scope, $log, $state, configService, profileService, uxLanguage, walletService) { $scope.init = function() { $scope.availableLanguages = uxLanguage.getLanguages(); @@ -19,10 +19,10 @@ angular.module('copayApp.controllers').controller('preferencesLanguageController configService.set(opts, function(err) { if (err) $log.warn(err); - go.preferencesGlobal(); + $state.go('tabs.settings') uxLanguage.update(function() { - walletService.updateRemotePreferences(profileService.getClients(), {}, function() { + walletService.updateRemotePreferences(profileService.getWallets(), {}, function() { $log.debug('Remote preferences saved'); }); }); diff --git a/src/js/controllers/preferencesUnit.js b/src/js/controllers/preferencesUnit.js index b23f831cc..5fdc78aba 100644 --- a/src/js/controllers/preferencesUnit.js +++ b/src/js/controllers/preferencesUnit.js @@ -36,10 +36,8 @@ angular.module('copayApp.controllers').controller('preferencesUnitController', f configService.set(opts, function(err) { if (err) $log.warn(err); - $state.go('preferencesGlobal'); - $scope.$emit('Local/UnitSettingUpdated'); - - walletService.updateRemotePreferences(profileService.getClients(), {}, function() { + $state.go('tabs.settings'); + walletService.updateRemotePreferences(profileService.getWallets(), {}, function() { $log.debug('Remote preferences saved'); }); }); diff --git a/src/js/services/applicationService.js b/src/js/services/applicationService.js index fd4b724af..b5e80e4ea 100644 --- a/src/js/services/applicationService.js +++ b/src/js/services/applicationService.js @@ -3,8 +3,8 @@ angular.module('copayApp.services') .factory('applicationService', function($rootScope, $timeout, platformInfo, $state) { var root = {}; - var isChromeApp = platformInfo.isChromeApp; - var isNW = platformInfo.isNW; + var isChromeApp = platformInfo.isChromeApp; + var isNW = platformInfo.isNW; root.restart = function() { var hashIndex = window.location.href.indexOf('#/'); From 0a047782bbeb0b400c0b279030a25adebe1e602b Mon Sep 17 00:00:00 2001 From: Gustavo Maximiliano Cortez Date: Tue, 23 Aug 2016 12:16:05 -0300 Subject: [PATCH 2/4] New directive copy-to-clipboard multiplatform --- Gruntfile.js | 2 + bower.json | 4 +- public/views/includes/confirm-tx.html | 2 +- public/views/includes/output.html | 6 +-- public/views/modals/tx-details.html | 10 ++--- public/views/modals/txp-details.html | 2 +- public/views/preferencesInformation.html | 8 ++-- public/views/tab-receive.html | 5 ++- src/js/app.js | 2 + src/js/controllers/modals/txDetails.js | 5 --- src/js/controllers/modals/txpDetails.js | 7 +--- src/js/controllers/preferencesInformation.js | 7 ---- src/js/controllers/tab-receive.js | 33 ----------------- src/js/directives/copyToClipboard.js | 39 ++++++++++++++++++++ test/karma.conf.js | 2 + 15 files changed, 66 insertions(+), 68 deletions(-) create mode 100644 src/js/directives/copyToClipboard.js diff --git a/Gruntfile.js b/Gruntfile.js index b56a24bce..1db667f99 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -115,6 +115,8 @@ module.exports = function(grunt) { 'bower_components/angular-qrcode/angular-qrcode.js', 'bower_components/angular-gettext/dist/angular-gettext.js', 'bower_components/ng-csv/build/ng-csv.js', + 'bower_components/ionic-toast/dist/ionic-toast.bundle.min.js', + 'bower_components/angular-clipboard/angular-clipboard.js', 'bower_components/angular-mocks/angular-mocks.js', 'angular-pbkdf2/angular-pbkdf2.js', 'angular-bitcore-wallet-client/angular-bitcore-wallet-client.js' diff --git a/bower.json b/bower.json index 4a544855d..e7daba801 100644 --- a/bower.json +++ b/bower.json @@ -16,7 +16,9 @@ "ng-lodash": "0.2.3", "qrcode-decoder-js": "*", "trezor-connect": "~1.0.1", - "ng-csv": "~0.3.6" + "ng-csv": "~0.3.6", + "ionic-toast": "^0.4.1", + "angular-clipboard": "^1.4.2" }, "resolutions": { "angular": "1.5.3" diff --git a/public/views/includes/confirm-tx.html b/public/views/includes/confirm-tx.html index c4d8ce64a..b7901c4c2 100644 --- a/public/views/includes/confirm-tx.html +++ b/public/views/includes/confirm-tx.html @@ -7,7 +7,7 @@
{{tx.amountStr}}
{{tx.alternativeAmountStr}}
-
+
diff --git a/public/views/includes/output.html b/public/views/includes/output.html index 2a960a0b7..d085ecb4d 100644 --- a/public/views/includes/output.html +++ b/public/views/includes/output.html @@ -1,14 +1,14 @@ -
  • +
  • To: {{output.toAddress || output.address}}
  • -
  • +
  • Amount: {{output.amountStr}} {{output.alternativeAmountStr}}
  • -
  • +
  • Note: {{output.message}}
  • diff --git a/public/views/modals/tx-details.html b/public/views/modals/tx-details.html index a4582dfba..070f1dcda 100644 --- a/public/views/modals/tx-details.html +++ b/public/views/modals/tx-details.html @@ -25,7 +25,7 @@

    Moved

    -
    +
    {{btx.amountStr}}
    @@ -46,7 +46,7 @@
    • + copy-to-clipboard="btx.addressTo"> To @@ -89,19 +89,19 @@
    • + copy-to-clipboard="btx.feeStr"> Fee {{btx.feeStr}}
    • + copy-to-clipboard="btx.message"> Description {{btx.message}}
    • + copy-to-clipboard="btx.merchant.pr.pd.memo"> Merchant message {{btx.merchant.pr.pd.memo}} diff --git a/public/views/modals/txp-details.html b/public/views/modals/txp-details.html index 5112763ff..496f90a2c 100644 --- a/public/views/modals/txp-details.html +++ b/public/views/modals/txp-details.html @@ -16,7 +16,7 @@
      {{tx.amountStr}}
      {{tx.alternativeAmountStr}}
      - + Multiple recipients diff --git a/public/views/preferencesInformation.html b/public/views/preferencesInformation.html index 35284e468..1df331fc2 100644 --- a/public/views/preferencesInformation.html +++ b/public/views/preferencesInformation.html @@ -18,7 +18,7 @@ {{walletName}}
    -
    +
    Wallet Id {{walletId}} @@ -81,7 +81,7 @@ Extended Public Keys
    -
    +
    Copayer {{$index}}< @@ -96,7 +96,7 @@ Last Wallet Addresses
    -
    +
    {{a.address}} {{a.path}} · {{a.createdOn *1000 | amDateFormat:'MMMM Do YYYY, h:mm a' }} @@ -115,7 +115,7 @@
    Balance By Address
    -
    +
    {{a.address}} {{(a.amount/1e8).toFixed(8)}} BTC diff --git a/public/views/tab-receive.html b/public/views/tab-receive.html index f6738ef3a..956f42ae5 100644 --- a/public/views/tab-receive.html +++ b/public/views/tab-receive.html @@ -6,7 +6,7 @@ -
    +
    @@ -50,7 +50,8 @@ Error: {{addrError}}
    - {{generatingAddress ? '...' : addr}} + ... + {{addr}}
    diff --git a/src/js/app.js b/src/js/app.js index 3e32f68ba..d4cd8448c 100644 --- a/src/js/app.js +++ b/src/js/app.js @@ -5,6 +5,8 @@ var modules = [ 'monospaced.qrcode', 'gettext', 'ionic', + 'ionic-toast', + 'angular-clipboard', 'ngLodash', 'ngCsv', 'bwcModule', diff --git a/src/js/controllers/modals/txDetails.js b/src/js/controllers/modals/txDetails.js index af965d34a..84ca22954 100644 --- a/src/js/controllers/modals/txDetails.js +++ b/src/js/controllers/modals/txDetails.js @@ -85,11 +85,6 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio return n.substring(0, 4); }; - $scope.copyToClipboard = function(addr, $event) { - if (!addr) return; - self.copyToClipboard(addr, $event); - }; - $scope.cancel = function() { $scope.txDetailsModal.hide(); }; diff --git a/src/js/controllers/modals/txpDetails.js b/src/js/controllers/modals/txpDetails.js index 3cb586fa0..5e9b89f8a 100644 --- a/src/js/controllers/modals/txpDetails.js +++ b/src/js/controllers/modals/txpDetails.js @@ -8,7 +8,7 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi var now = Math.floor(Date.now() / 1000); $scope.loading = null; - + $scope.copayerId = $scope.wallet.credentials.copayerId; $scope.isShared = $scope.wallet.credentials.n > 1; $scope.canSign = $scope.wallet.canSign() || $scope.wallet.isPrivKeyExternal(); @@ -187,11 +187,6 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi }); }; - $scope.copyToClipboard = function(addr, $event) { - if (!addr) return; - self.copyToClipboard(addr, $event); - }; - $scope.close = function(txp) { $scope.loading = null; if (txp) { diff --git a/src/js/controllers/preferencesInformation.js b/src/js/controllers/preferencesInformation.js index 1ee39ba21..ac2f205bc 100644 --- a/src/js/controllers/preferencesInformation.js +++ b/src/js/controllers/preferencesInformation.js @@ -113,13 +113,6 @@ angular.module('copayApp.controllers').controller('preferencesInformation', save('#202020'); }; - $scope.copyToClipboard = function(data) { - if ($scope.isCordova) { - window.cordova.plugins.clipboard.copy(data); - window.plugins.toast.showShortCenter(gettextCatalog.getString('Copied to clipboard')); - } - }; - $scope.scan = function() { walletService.startScan(wallet); $state.go('tabs.home'); diff --git a/src/js/controllers/tab-receive.js b/src/js/controllers/tab-receive.js index 50c80bcbd..28ede85ad 100644 --- a/src/js/controllers/tab-receive.js +++ b/src/js/controllers/tab-receive.js @@ -32,39 +32,6 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi }); } - $scope.copyToClipboard = function(addr, $event) { - - var showPopover = function() { - - $ionicPopover.fromTemplateUrl('views/includes/copyToClipboard.html', { - scope: $scope - }).then(function(popover) { - $scope.popover = popover; - $scope.popover.show($event); - }); - - $scope.close = function() { - $scope.popover.hide(); - } - - $timeout(function() { - $scope.popover.hide(); //close the popover after 0.7 seconds - }, 700); - - $scope.$on('$destroy', function() { - $scope.popover.remove(); - }); - }; - - if ($scope.isCordova) { - window.cordova.plugins.clipboard.copy(addr); - window.plugins.toast.showShortCenter(gettextCatalog.getString('Copied to clipboard')); - } else if ($scope.isNW) { - nodeWebkit.writeToClipboard(addr); - showPopover($event); - } - }; - $scope.shareAddress = function(addr) { if ($scope.isCordova) { window.plugins.socialsharing.share('bitcoin:' + addr, null, null, null); diff --git a/src/js/directives/copyToClipboard.js b/src/js/directives/copyToClipboard.js new file mode 100644 index 000000000..50165b70a --- /dev/null +++ b/src/js/directives/copyToClipboard.js @@ -0,0 +1,39 @@ +'use strict'; + +angular.module('copayApp.directives') + .directive('copyToClipboard', function(platformInfo, gettextCatalog, ionicToast, clipboard) { + return { + restrict: 'A', + scope: { + copyToClipboard: '=copyToClipboard' + }, + link: function(scope, elem, attrs, ctrl) { + var isCordova = platformInfo.isCordova; + var isChromeApp = platformInfo.isChromeApp; + var isNW = platformInfo.isNW; + elem.bind('mouseover', function() { + elem.css('cursor', 'pointer'); + }); + + var msg = gettextCatalog.getString('Copied to clipboard'); + elem.bind('click', function() { + var data = scope.copyToClipboard; + if (isCordova) { + window.cordova.plugins.clipboard.copy(data); + window.plugins.toast.showShortCenter(msg); + } else if (isNW) { + nodeWebkit.writeToClipboard(data); + scope.$apply(function() { + ionicToast.show(msg, 'bottom', false, 1000); + }); + } else if (clipboard.supported) { + clipboard.copyText(data); + scope.$apply(function() { + ionicToast.show(msg, 'bottom', false, 1000); + }); + } + }); + } + } + }); + diff --git a/test/karma.conf.js b/test/karma.conf.js index 0756f48fb..8274b222f 100644 --- a/test/karma.conf.js +++ b/test/karma.conf.js @@ -24,6 +24,8 @@ module.exports = function(config) { 'bower_components/angular-qrcode/angular-qrcode.js', 'bower_components/angular-gettext/dist/angular-gettext.js', 'bower_components/ng-csv/build/ng-csv.js', + 'bower_components/ionic-toast/dist/ionic-toast.bundle.min.js', + 'bower_components/angular-clipboard/angular-clipboard.js', 'bower_components/angular-mocks/angular-mocks.js', 'angular-pbkdf2/angular-pbkdf2.js', 'angular-bitcore-wallet-client/angular-bitcore-wallet-client.js', From b04fe9d5958a314fb24e163b252668f07533d805 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Baz=C3=A1n?= Date: Tue, 23 Aug 2016 12:38:21 -0300 Subject: [PATCH 3/4] hidden balance feature --- public/views/walletDetails.html | 2 +- src/js/controllers/walletDetails.js | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/public/views/walletDetails.html b/public/views/walletDetails.html index 3836efb03..44d1c8e66 100644 --- a/public/views/walletDetails.html +++ b/public/views/walletDetails.html @@ -45,7 +45,7 @@
    -
    +
    {{status.totalBalanceStr}}
    {{status.totalBalanceAlternative}} {{status.alternativeIsoCode}}
    diff --git a/src/js/controllers/walletDetails.js b/src/js/controllers/walletDetails.js index 5352bda8c..bc0700ca3 100644 --- a/src/js/controllers/walletDetails.js +++ b/src/js/controllers/walletDetails.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('copayApp.controllers').controller('walletDetailsController', function($scope, $rootScope, $interval, $timeout, $filter, $log, $ionicModal, $ionicPopover, $ionicNavBarDelegate, $state, $stateParams, bwcError, profileService, lodash, configService, gettext, gettextCatalog, platformInfo, walletService) { +angular.module('copayApp.controllers').controller('walletDetailsController', function($scope, $rootScope, $interval, $timeout, $filter, $log, $ionicModal, $ionicPopover, $ionicNavBarDelegate, $state, $stateParams, bwcError, profileService, lodash, configService, gettext, gettextCatalog, platformInfo, walletService, storageService) { var isCordova = platformInfo.isCordova; var isWP = platformInfo.isWP; @@ -11,9 +11,7 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun var HISTORY_SHOW_LIMIT = 10; - $scope.openSearchModal = function() { - var wallet = profileService.getWallet($stateParams.walletId); $scope.color = wallet.color; $ionicModal.fromTemplateUrl('views/modals/search.html', { @@ -113,9 +111,17 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun $scope.updateTxHistory(); } + var hideBalance = function() { + storageService.getHideBalanceFlag(wallet.credentials.walletId, function(err, shouldHideBalance) { + if (err) $scope.shouldHideBalance = false; + else $scope.shouldHideBalance = (shouldHideBalance == 'true') ? true : false; + }); + } + $scope.hideToggle = function() { - console.log('[walletDetails.js.70:hideToogle:] TODO'); //TODO - }; + $scope.shouldHideBalance = !$scope.shouldHideBalance; + storageService.setHideBalanceFlag(wallet.credentials.walletId, $scope.shouldHideBalance.toString(), function() {}); + } var currentTxHistoryPage; var wallet; @@ -129,6 +135,7 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun $scope.requiresMultipleSignatures = wallet.credentials.m > 1; $scope.newTx = false; + hideBalance(); $ionicNavBarDelegate.title(wallet.name); $scope.updateAll(); From 6ce5bad7b20abe670904b36d8f83159421c46f24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Baz=C3=A1n?= Date: Tue, 23 Aug 2016 13:02:16 -0300 Subject: [PATCH 4/4] no error if already exist --- app-template/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app-template/Makefile b/app-template/Makefile index 75f80b060..2e81223e7 100644 --- a/app-template/Makefile +++ b/app-template/Makefile @@ -20,7 +20,7 @@ ios: $(WORKDIR)ios android: project-android mkdir -p android/platforms/android/res/xml/ - mkdir $(WORKDIR)android/scripts + mkdir -p $(WORKDIR)android/scripts cp -R scripts/* $(WORKDIR)android/scripts cp android/build-extras.gradle $(WORKDIR)android/platforms/android/build-extras.gradle cp android/project.properties $(WORKDIR)android/platforms/android/project.properties