From 41cc509d47ecc675a9a893e9137fb10674de205d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Baz=C3=A1n?= Date: Mon, 15 Aug 2016 17:42:04 -0300 Subject: [PATCH] refactor settings tab --- public/index.html | 1 - public/views/feedback.html | 12 ++ public/views/preferencesAbout.html | 83 +++++++------- public/views/preferencesAltCurrency.html | 21 ++-- public/views/preferencesFee.html | 62 +++++------ public/views/preferencesLanguage.html | 44 ++++---- public/views/preferencesLogs.html | 49 ++++----- public/views/preferencesUnit.html | 26 +++-- public/views/tab-settings.html | 91 +++++++++++++++- public/views/termOfUse.html | 28 +++-- public/views/translators.html | 67 ++++++------ src/js/controllers/preferencesAltCurrency.js | 8 +- src/js/controllers/preferencesFee.js | 18 +-- src/js/controllers/preferencesGlobal.js | 12 +- src/js/controllers/preferencesLanguage.js | 8 +- src/js/controllers/preferencesLogs.js | 43 ++++---- src/js/controllers/preferencesUnit.js | 7 +- src/js/controllers/tab-settings.js | 109 +++++++++++++++++++ src/js/routes.js | 15 ++- src/js/services/feeService.js | 8 +- src/js/services/go.js | 2 +- 21 files changed, 462 insertions(+), 252 deletions(-) create mode 100644 public/views/feedback.html create mode 100644 src/js/controllers/tab-settings.js diff --git a/public/index.html b/public/index.html index 568e37814..a126db2a6 100644 --- a/public/index.html +++ b/public/index.html @@ -20,7 +20,6 @@ - diff --git a/public/views/feedback.html b/public/views/feedback.html new file mode 100644 index 000000000..ff62217b6 --- /dev/null +++ b/public/views/feedback.html @@ -0,0 +1,12 @@ + + + feedback + +   + + + + diff --git a/public/views/preferencesAbout.html b/public/views/preferencesAbout.html index b1e845597..c80d2abca 100644 --- a/public/views/preferencesAbout.html +++ b/public/views/preferencesAbout.html @@ -1,42 +1,43 @@ -
-
- -
-

Release Information

-
-
    -
  • - Version - - v{{v.version}} - -
  • -
  • - Commit hash - - #{{v.commitHash}} - -
  • -
+ + + About Copay + +   +   + + +
+ Release information
- -

-
    -
  • - - Terms of Use -
  • -
  • - - Translators -
  • -
  • - - Session log -
  • -
- -
+
+ + Version + + v{{v.version}} + +
+
+ + Commit hash + + #{{v.commitHash}} + +
+
+
+
+ + Terms of Use +
+
+ + Translators +
+
+ + Session log +
+ + diff --git a/public/views/preferencesAltCurrency.html b/public/views/preferencesAltCurrency.html index 71bcd61a3..1c3eb7db2 100644 --- a/public/views/preferencesAltCurrency.html +++ b/public/views/preferencesAltCurrency.html @@ -1,12 +1,14 @@ -
-
- -
-

- + + + Alternative Currency + +   +   + - {{altCurrency.name}} -
- + diff --git a/public/views/preferencesFee.html b/public/views/preferencesFee.html index e5f16f2ff..e8d5ebaff 100644 --- a/public/views/preferencesFee.html +++ b/public/views/preferencesFee.html @@ -1,39 +1,27 @@ -
-
-
-

-
-
-
- -
-
- Loading... -
+ + + Preferences fee + +   +   + + + +
+ Loading...
-
- - {{feeOpts[fee.level]|translate}} - - -
-
-
- Average confirmation time: {{fee.nbBlocks * 10}} minutes. + {{feeOpts[fee.level]|translate}} + +
+
+ Average confirmation time: {{fee.nbBlocks * 10}} minutes. +
+ Current fee rate for this policy: {{fee.feePerKBUnit}}/kiB
- Current fee rate for this policy: {{fee.feePerKBUnit}}/kiB -
-
- -
-
- Bitcoin transactions may include a fee collected by miners on the network. The higher the fee, the greater the incentive a miner has to include that transaction in a block. Current fees are determined based on network load and the selected policy. -
-
-
- -
+
+ Bitcoin transactions may include a fee collected by miners on the network. The higher the fee, the greater the incentive a miner has to include that transaction in a block. Current fees are determined based on network load and the selected policy. +
+ + diff --git a/public/views/preferencesLanguage.html b/public/views/preferencesLanguage.html index d1d050a0d..2f91c9cb5 100644 --- a/public/views/preferencesLanguage.html +++ b/public/views/preferencesLanguage.html @@ -1,24 +1,20 @@ -
-
- -
-

- - {{lang.name}} - - -
-
-

- All contributions to Copay's translation are welcome. Sign up at crowdin.com and join the Copay project at - https://crowdin.com/project/copay. -

- - Don't see your language on Crowdin? Contact the Owner on Crowdin! We'd love to support your language. - -
-
- -
+ + + Languages + +   + + + {{lang.name}} + + All contributions to Copay's translation are welcome. Sign up at crowdin.com and join the Copay project at + https://crowdin.com/project/copay. + + Don't see your language on Crowdin? Contact the Owner on Crowdin! We'd love to support your language. + + + diff --git a/public/views/preferencesLogs.html b/public/views/preferencesLogs.html index aca235e8a..51238b476 100644 --- a/public/views/preferencesLogs.html +++ b/public/views/preferencesLogs.html @@ -1,27 +1,22 @@ -
-
- - - -
-

- -
- - -
    -
  • - - - {{l.msg}} - -
  • -
-
-
+ + + Session log + +   +   + + + +
    +
  • + + {{l.msg}} + +
  • +
+
+
diff --git a/public/views/preferencesUnit.html b/public/views/preferencesUnit.html index fa5e2c286..262889c6c 100644 --- a/public/views/preferencesUnit.html +++ b/public/views/preferencesUnit.html @@ -1,11 +1,15 @@ -
-
- -
-

- - {{unit.shortName}} - -
+ + + Unit + +   +   + + + {{unit.shortName}} + + + diff --git a/public/views/tab-settings.html b/public/views/tab-settings.html index cc4f21e3f..8b1eace8f 100644 --- a/public/views/tab-settings.html +++ b/public/views/tab-settings.html @@ -1,6 +1,89 @@ + + + Global Settings + + +
+
+
+
+ + Address Book +
+
+ + Feedback +
+
+
+ Preferences +
+
+
+ + Language + + {{currentLanguageName|translate}} + +
+
+ + Unit + + {{unitName}} + +
+
+ + Alternative Currency + + {{selectedAlternative.name}} + +
+
+ + Bitcoin Network Fee Policy + + {{feeOpts[currentFeeLevel]|translate}} + +
+
+
+
+ Notifications +
+ + Enable push notifications + +
+
Push notifications for Copay are currently disabled. Enable them in the Settings app.
+
    +
  • Open Settings app
  • +
+
+
+
+ Exchanges +
+ + Enable Glidera Service + - - -

Welcome to Settings

+ + Enable Coinbase Service + +
+
+ Others +
+
+ + Use Unconfirmed Funds + +
+ + About Copay +
+
- + diff --git a/public/views/termOfUse.html b/public/views/termOfUse.html index e3890f2ea..ad094b3c7 100644 --- a/public/views/termOfUse.html +++ b/public/views/termOfUse.html @@ -1,16 +1,20 @@ -
-
-
-

-

+ + + Terms of Use + +   +   + + +

+

- -
+
+
diff --git a/public/views/translators.html b/public/views/translators.html index 30343cd76..ffbfa1ec1 100644 --- a/public/views/translators.html +++ b/public/views/translators.html @@ -1,32 +1,35 @@ -
-
- -
-

Translation Credits

-
    -
  • kinoshitajonaJapanese
  • -
  • KirvxFrench
  • -
  • saschadGerman
  • -
  • cmgustavo83Spanish
  • -
  • RussianNeuroMancerRussian
  • -
  • HostFatItalian
  • -
  • xm2hiChinese
  • -
  • Pirx1618Polish
  • -
  • mareksipCzech
  • -
-
-
-

- All contributions to Copay's translation are welcome. Sign up at crowdin.com and join the Copay project at - https://crowdin.com/project/copay. -

- - Don't see your language on Crowdin? Contact the Owner on Crowdin! We'd love to support your language. - -
-
-
-
+ + + Translators + +   + + +

Translation Credits

+
    +
  • kinoshitajonaJapanese
  • +
  • KirvxFrench
  • +
  • saschadGerman
  • +
  • cmgustavo83Spanish
  • +
  • RussianNeuroMancerRussian
  • +
  • HostFatItalian
  • +
  • xm2hiChinese
  • +
  • Pirx1618Polish
  • +
  • mareksipCzech
  • +
+
+
+

+ All contributions to Copay's translation are welcome. Sign up at crowdin.com and join the Copay project at + https://crowdin.com/project/copay. +

+ + Don't see your language on Crowdin? Contact the Owner on Crowdin! We'd love to support your language. + +
+
+
+
diff --git a/src/js/controllers/preferencesAltCurrency.js b/src/js/controllers/preferencesAltCurrency.js index 8ad0e9a06..5f0581f18 100644 --- a/src/js/controllers/preferencesAltCurrency.js +++ b/src/js/controllers/preferencesAltCurrency.js @@ -3,13 +3,15 @@ angular.module('copayApp.controllers').controller('preferencesAltCurrencyController', function($scope, $log, $timeout, configService, rateService, lodash, go, profileService, walletService) { - var config = configService.getSync(); var next = 10; var completeAlternativeList; - $scope.currentCurrency = config.wallet.settings.alternativeIsoCode; - $scope.listComplete = false; $scope.init = function() { + + var config = configService.getSync(); + $scope.currentCurrency = config.wallet.settings.alternativeIsoCode; + $scope.listComplete = false; + rateService.whenAvailable(function() { completeAlternativeList = rateService.listAlternatives(); lodash.remove(completeAlternativeList, function(c) { diff --git a/src/js/controllers/preferencesFee.js b/src/js/controllers/preferencesFee.js index 110cb0a1e..b0591a6ce 100644 --- a/src/js/controllers/preferencesFee.js +++ b/src/js/controllers/preferencesFee.js @@ -2,14 +2,16 @@ angular.module('copayApp.controllers').controller('preferencesFeeController', function($scope, $timeout, configService, feeService) { - $scope.loading = true; - feeService.getFeeLevels(function(levels) { - $scope.loading = false; - $scope.feeOpts = feeService.feeOpts; - $scope.currentFeeLevel = feeService.getCurrentFeeLevel(); - $scope.feeLevels = levels; - $scope.$apply(); - }); + $scope.init = function() { + $scope.loading = true; + feeService.getFeeLevels(function(levels) { + $scope.loading = false; + $scope.feeOpts = feeService.feeOpts; + $scope.currentFeeLevel = feeService.getCurrentFeeLevel(); + $scope.feeLevels = levels; + $scope.$apply(); + }); + } $scope.save = function(newFee) { var opts = { diff --git a/src/js/controllers/preferencesGlobal.js b/src/js/controllers/preferencesGlobal.js index 4fee4d878..0c8ec7f78 100644 --- a/src/js/controllers/preferencesGlobal.js +++ b/src/js/controllers/preferencesGlobal.js @@ -3,14 +3,14 @@ angular.module('copayApp.controllers').controller('preferencesGlobalController', function($scope, $rootScope, $log, configService, uxLanguage, platformInfo, pushNotificationsService, profileService, feeService) { - var isCordova = platformInfo.isCordova; - - if (isCordova && StatusBar.isVisible) { - StatusBar.backgroundColorByHexString("#4B6178"); - } - $scope.init = function() { var config = configService.getSync(); + var isCordova = platformInfo.isCordova; + + if (isCordova && StatusBar.isVisible) { + StatusBar.backgroundColorByHexString("#4B6178"); + } + $scope.unitName = config.wallet.settings.unitName; $scope.currentLanguageName = uxLanguage.getCurrentLanguageName(); $scope.selectedAlternative = { diff --git a/src/js/controllers/preferencesLanguage.js b/src/js/controllers/preferencesLanguage.js index 0e44492d1..2717d3e8e 100644 --- a/src/js/controllers/preferencesLanguage.js +++ b/src/js/controllers/preferencesLanguage.js @@ -1,10 +1,12 @@ 'use strict'; angular.module('copayApp.controllers').controller('preferencesLanguageController', - function($scope, $log, configService, profileService, uxLanguage, walletService, go) { + function($scope, $log, $state, configService, profileService, uxLanguage, walletService, go) { - $scope.availableLanguages = uxLanguage.getLanguages(); - $scope.currentLanguage = uxLanguage.getCurrentLanguage(); + $scope.init = function() { + $scope.availableLanguages = uxLanguage.getLanguages(); + $scope.currentLanguage = uxLanguage.getCurrentLanguage(); + } $scope.save = function(newLang) { var opts = { diff --git a/src/js/controllers/preferencesLogs.js b/src/js/controllers/preferencesLogs.js index d08681664..6db095b6e 100644 --- a/src/js/controllers/preferencesLogs.js +++ b/src/js/controllers/preferencesLogs.js @@ -1,25 +1,28 @@ 'use strict'; angular.module('copayApp.controllers').controller('preferencesLogs', -function(historicLog) { - this.logs = historicLog.get(); + function($scope, historicLog) { - this.sendLogs = function() { - var body = 'Copay Session Logs\n Be careful, this could contain sensitive private data\n\n'; - body += '\n\n'; - body += this.logs.map(function(v) { - return v.msg; - }).join('\n'); + $scope.init = function() { + $scope.logs = historicLog.get(); + } - window.plugins.socialsharing.shareViaEmail( - body, - 'Copay Logs', - null, // TO: must be null or an array - null, // CC: must be null or an array - null, // BCC: must be null or an array - null, // FILES: can be null, a string, or an array - function() {}, - function() {} - ); - }; -}); + $scope.sendLogs = function() { + var body = 'Copay Session Logs\n Be careful, this could contain sensitive private data\n\n'; + body += '\n\n'; + body += $scope.logs.map(function(v) { + return v.msg; + }).join('\n'); + + window.plugins.socialsharing.shareViaEmail( + body, + 'Copay Logs', + null, // TO: must be null or an array + null, // CC: must be null or an array + null, // BCC: must be null or an array + null, // FILES: can be null, a string, or an array + function() {}, + function() {} + ); + }; + }); diff --git a/src/js/controllers/preferencesUnit.js b/src/js/controllers/preferencesUnit.js index 3572f441e..c74efc0de 100644 --- a/src/js/controllers/preferencesUnit.js +++ b/src/js/controllers/preferencesUnit.js @@ -2,9 +2,10 @@ angular.module('copayApp.controllers').controller('preferencesUnitController', function($scope, $log, configService, go, walletService, profileService) { - var config = configService.getSync(); - - $scope.currentUnit = config.wallet.settings.unitCode; + $scope.init = function() { + var config = configService.getSync(); + $scope.currentUnit = config.wallet.settings.unitCode; + } $scope.unitList = [ { diff --git a/src/js/controllers/tab-settings.js b/src/js/controllers/tab-settings.js new file mode 100644 index 000000000..e697dc887 --- /dev/null +++ b/src/js/controllers/tab-settings.js @@ -0,0 +1,109 @@ +'use strict'; + +angular.module('copayApp.controllers').controller('tabSettingsController', function($scope, $rootScope, $log, $ionicModal, lodash, configService, uxLanguage, platformInfo, pushNotificationsService, profileService, feeService) { + + $scope.init = function() { + + var config = configService.getSync(); + var isCordova = platformInfo.isCordova; + var isWP = platformInfo.isWP; + var isIOS = platformInfo.isIOS; + + $scope.unitName = config.wallet.settings.unitName; + $scope.currentLanguageName = uxLanguage.getCurrentLanguageName(); + $scope.selectedAlternative = { + name: config.wallet.settings.alternativeName, + isoCode: config.wallet.settings.alternativeIsoCode + }; + $scope.feeOpts = feeService.feeOpts; + $scope.currentFeeLevel = feeService.getCurrentFeeLevel(); + $scope.usePushNotifications = isCordova && !isWP; + $scope.PNEnabledByUser = true; + $scope.isIOSApp = isIOS && isCordova; + if ($scope.isIOSApp) { + cordova.plugins.diagnostic.isRemoteNotificationsEnabled(function(isEnabled) { + $scope.PNEnabledByUser = isEnabled; + $scope.$digest(); + }); + } + $scope.spendUnconfirmed = config.wallet.spendUnconfirmed; + $scope.glideraEnabled = config.glidera.enabled; + $scope.coinbaseEnabled = config.coinbase.enabled; + $scope.pushNotifications = config.pushNotifications.enabled; + if (isCordova && StatusBar.isVisible) { + StatusBar.backgroundColorByHexString("#4B6178"); + } + $scope.otherWallets = lodash.filter(profileService.getWallets(self.network), function(w) { + return w.id != self.walletId; + }); + }; + + $scope.openAddressbookModal = function() { + + $ionicModal.fromTemplateUrl('views/modals/addressbook.html', { + scope: $scope + }).then(function(modal) { + $scope.addressbookModal = modal; + $scope.addressbookModal.show(); + }); + }; + + + $scope.openSettings = function() { + cordova.plugins.diagnostic.switchToSettings(function() { + $log.debug('switched to settings'); + }, function(err) { + $log.debug(err); + }); + } + + $scope.spendUnconfirmedChange = function() { + var opts = { + wallet: { + spendUnconfirmed: $scope.spendUnconfirmed + } + }; + configService.set(opts, function(err) { + $rootScope.$emit('Local/SpendUnconfirmedUpdated', $scope.spendUnconfirmed); + if (err) $log.debug(err); + }); + }; + + $scope.pushNotificationsChange = function() { + var opts = { + pushNotifications: { + enabled: $scope.pushNotifications + } + }; + configService.set(opts, function(err) { + if (opts.pushNotifications.enabled) + pushNotificationsService.enableNotifications(profileService.walletClients); + else + pushNotificationsService.disableNotifications(profileService.walletClients); + if (err) $log.debug(err); + }); + }; + + $scope.glideraChange = function() { + var opts = { + glidera: { + enabled: $scope.glideraEnabled + } + }; + configService.set(opts, function(err) { + if (err) $log.debug(err); + }); + }; + + $scope.coinbaseChange = function() { + var opts = { + coinbase: { + enabled: $scope.coinbaseEnabled + } + }; + configService.set(opts, function(err) { + if (err) $log.debug(err); + }); + }; + +}); diff --git a/src/js/routes.js b/src/js/routes.js index 82f2c28e8..8fbb2c2a6 100644 --- a/src/js/routes.js +++ b/src/js/routes.js @@ -160,11 +160,16 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr }, } }) - - - - - .state('unsupported', { + .state('feedback', { + url: '/feedback', + needProfile: true, + views: { + 'main': { + templateUrl: 'views/feedback.html', + }, + } + }) + .state('unsupported', { url: '/unsupported', needProfile: false, views: { diff --git a/src/js/services/feeService.js b/src/js/services/feeService.js index c046c1829..cf7288feb 100644 --- a/src/js/services/feeService.js +++ b/src/js/services/feeService.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('copayApp.services').factory('feeService', function($log, bwcService, profileService, configService, gettext, lodash) { +angular.module('copayApp.services').factory('feeService', function($log, bwcService, walletService, configService, gettext, lodash) { var root = {}; // Constant fee options to translate @@ -16,7 +16,7 @@ angular.module('copayApp.services').factory('feeService', function($log, bwcServ }; root.getCurrentFeeValue = function(cb) { - var fc = profileService.focusedClient; + var fc = walletService.focusedClient; var feeLevel = root.getCurrentFeeLevel(); fc.getFeeLevels(fc.credentials.network, function(err, levels) { @@ -49,8 +49,8 @@ angular.module('copayApp.services').factory('feeService', function($log, bwcServ if (errLivenet || errTestnet) $log.debug('Could not get dynamic fee'); else { for (var i = 0; i < 4; i++) { - levelsLivenet[i]['feePerKBUnit'] = profileService.formatAmount(levelsLivenet[i].feePerKB) + ' ' + unitName; - levelsTestnet[i]['feePerKBUnit'] = profileService.formatAmount(levelsTestnet[i].feePerKB) + ' ' + unitName; + levelsLivenet[i]['feePerKBUnit'] = walletService.formatAmount(levelsLivenet[i].feePerKB) + ' ' + unitName; + levelsTestnet[i]['feePerKBUnit'] = walletService.formatAmount(levelsTestnet[i].feePerKB) + ' ' + unitName; } } diff --git a/src/js/services/go.js b/src/js/services/go.js index 52f00de33..af3bc8d13 100644 --- a/src/js/services/go.js +++ b/src/js/services/go.js @@ -56,7 +56,7 @@ angular.module('copayApp.services').factory('go', function($window, $ionicSideMe }; root.preferencesGlobal = function() { - $state.transitionTo('preferencesGlobal'); + $state.transitionTo('tabs.settings'); }; root.reload = function() {