From e519517167651d1cf5697bb81f1946947c9a483a Mon Sep 17 00:00:00 2001 From: Gustavo Maximiliano Cortez Date: Mon, 20 Feb 2017 11:54:39 -0300 Subject: [PATCH 1/3] Removes unused files --- src/js/services/addonManager.js | 34 ---------------------------- src/js/services/addressService.js | 7 ------ src/js/services/confirmDialog.js | 37 ------------------------------- 3 files changed, 78 deletions(-) delete mode 100644 src/js/services/addonManager.js delete mode 100644 src/js/services/addressService.js delete mode 100644 src/js/services/confirmDialog.js diff --git a/src/js/services/addonManager.js b/src/js/services/addonManager.js deleted file mode 100644 index ce1f85d49..000000000 --- a/src/js/services/addonManager.js +++ /dev/null @@ -1,34 +0,0 @@ -'use strict'; - -angular.module('copayApp.services').service('addonManager', function (lodash) { - var addons = []; - - this.registerAddon = function (addonSpec) { - addons.push(addonSpec); - }; - - this.addonMenuItems = function () { - return lodash.map(addons, function (addonSpec) { - return addonSpec.menuItem; - }); - }; - - this.addonViews = function () { - return lodash.map(addons, function (addonSpec) { - return addonSpec.view; - }); - }; - - this.formatPendingTxp = function (txp) { - lodash.each(addons, function (addon) { - if (addon.formatPendingTxp) { - addon.formatPendingTxp(txp); - } - }); - }; - - this.txTemplateUrl = function() { - var addon = lodash.find(addons, 'txTemplateUrl'); - return addon ? addon.txTemplateUrl() : null; - } -}); diff --git a/src/js/services/addressService.js b/src/js/services/addressService.js deleted file mode 100644 index 6df0a71a0..000000000 --- a/src/js/services/addressService.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; -'use strict'; -angular.module('copayApp.services') - .factory('addressService', function(storageService, profileService, $log, $timeout, lodash, bwcError, gettextCatalog) { - var root = {}; - return root; - }); diff --git a/src/js/services/confirmDialog.js b/src/js/services/confirmDialog.js deleted file mode 100644 index 90e71f381..000000000 --- a/src/js/services/confirmDialog.js +++ /dev/null @@ -1,37 +0,0 @@ - -'use strict'; - -angular.module('copayApp.services').factory('confirmDialog', function($log, $timeout, profileService, configService, gettextCatalog, platformInfo) { - var root = {}; - - - var acceptMsg = gettextCatalog.getString('Accept'); - var cancelMsg = gettextCatalog.getString('Cancel'); - var confirmMsg = gettextCatalog.getString('Confirm'); - - root.show = function(msg, cb) { - if (platformInfo.isCordova) { - navigator.notification.confirm( - msg, - function(buttonIndex) { - if (buttonIndex == 1) { - $timeout(function() { - return cb(true); - }, 1); - } else { - return cb(false); - } - }, - confirmMsg, [acceptMsg, cancelMsg] - ); - } else if (platformInfo.isChromeApp) { - // No feedback, alert/confirm not supported. - return cb(true); - } else { - return cb(confirm(msg)); - } - }; - - return root; -}); - From d27a77cb1f058dabbb1eef41b7e82306587d708a Mon Sep 17 00:00:00 2001 From: Gustavo Maximiliano Cortez Date: Mon, 20 Feb 2017 11:55:48 -0300 Subject: [PATCH 2/3] Fix app initialisation --- src/js/routes.js | 169 +++++++++++++++++++++++------------------------ 1 file changed, 83 insertions(+), 86 deletions(-) diff --git a/src/js/routes.js b/src/js/routes.js index c86c521b6..10dc45706 100644 --- a/src/js/routes.js +++ b/src/js/routes.js @@ -1096,101 +1096,98 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr uxLanguage.init(); $ionicPlatform.ready(function() { - if (platformInfo.isCordova) { + if (screen.width < 768) + screen.lockOrientation('portrait'); - if (screen.width < 768) - screen.lockOrientation('portrait'); - - if (window.cordova && window.cordova.plugins && window.cordova.plugins.Keyboard) { - cordova.plugins.Keyboard.hideKeyboardAccessoryBar(false); - cordova.plugins.Keyboard.disableScroll(true); - } - - window.addEventListener('native.keyboardshow', function() { - document.body.classList.add('keyboard-open'); - }); - - $ionicPlatform.registerBackButtonAction(function(e) { - - //from root tabs view - var matchHome = $ionicHistory.currentStateName() == 'tabs.home' ? true : false; - var matchReceive = $ionicHistory.currentStateName() == 'tabs.receive' ? true : false; - var matchScan = $ionicHistory.currentStateName() == 'tabs.scan' ? true : false; - var matchSend = $ionicHistory.currentStateName() == 'tabs.send' ? true : false; - var matchSettings = $ionicHistory.currentStateName() == 'tabs.settings' ? true : false; - var fromTabs = matchHome | matchReceive | matchScan | matchSend | matchSettings; - - //onboarding with no back views - var matchWelcome = $ionicHistory.currentStateName() == 'onboarding.welcome' ? true : false; - var matchCollectEmail = $ionicHistory.currentStateName() == 'onboarding.collectEmail' ? true : false; - var matchBackupRequest = $ionicHistory.currentStateName() == 'onboarding.backupRequest' ? true : false; - var matchNotifications = $ionicHistory.currentStateName() == 'onboarding.notifications' ? true : false; - - var fromOnboarding = matchCollectEmail | matchBackupRequest | matchNotifications | matchWelcome; - - if ($ionicHistory.backView() && !fromTabs && !fromOnboarding) { - $ionicHistory.goBack(); - } else - if ($rootScope.backButtonPressedOnceToExit) { - ionic.Platform.exitApp(); - } else { - $rootScope.backButtonPressedOnceToExit = true; - window.plugins.toast.showShortBottom(gettextCatalog.getString('Press again to exit')); - $timeout(function() { - $rootScope.backButtonPressedOnceToExit = false; - }, 3000); - } - e.preventDefault(); - }, 101); - - $ionicPlatform.on('pause', function() { - // Nothing to do - }); - - $ionicPlatform.on('resume', function() { - // Nothing to do - }); - - $ionicPlatform.on('menubutton', function() { - window.location = '#/preferences'; - }); + if (window.cordova && window.cordova.plugins && window.cordova.plugins.Keyboard) { + cordova.plugins.Keyboard.hideKeyboardAccessoryBar(false); + cordova.plugins.Keyboard.disableScroll(true); } - $log.info('Init profile...'); - // Try to open local profile - profileService.loadAndBindProfile(function(err) { - $ionicHistory.nextViewOptions({ - disableAnimate: true - }); - if (err) { - if (err.message && err.message.match('NOPROFILE')) { - $log.debug('No profile... redirecting'); + window.addEventListener('native.keyboardshow', function() { + document.body.classList.add('keyboard-open'); + }); + + $ionicPlatform.registerBackButtonAction(function(e) { + + //from root tabs view + var matchHome = $ionicHistory.currentStateName() == 'tabs.home' ? true : false; + var matchReceive = $ionicHistory.currentStateName() == 'tabs.receive' ? true : false; + var matchScan = $ionicHistory.currentStateName() == 'tabs.scan' ? true : false; + var matchSend = $ionicHistory.currentStateName() == 'tabs.send' ? true : false; + var matchSettings = $ionicHistory.currentStateName() == 'tabs.settings' ? true : false; + var fromTabs = matchHome | matchReceive | matchScan | matchSend | matchSettings; + + //onboarding with no back views + var matchWelcome = $ionicHistory.currentStateName() == 'onboarding.welcome' ? true : false; + var matchCollectEmail = $ionicHistory.currentStateName() == 'onboarding.collectEmail' ? true : false; + var matchBackupRequest = $ionicHistory.currentStateName() == 'onboarding.backupRequest' ? true : false; + var matchNotifications = $ionicHistory.currentStateName() == 'onboarding.notifications' ? true : false; + + var fromOnboarding = matchCollectEmail | matchBackupRequest | matchNotifications | matchWelcome; + + if ($ionicHistory.backView() && !fromTabs && !fromOnboarding) { + $ionicHistory.goBack(); + } else + if ($rootScope.backButtonPressedOnceToExit) { + ionic.Platform.exitApp(); + } else { + $rootScope.backButtonPressedOnceToExit = true; + window.plugins.toast.showShortBottom(gettextCatalog.getString('Press again to exit')); + $timeout(function() { + $rootScope.backButtonPressedOnceToExit = false; + }, 3000); + } + e.preventDefault(); + }, 101); + + $ionicPlatform.on('pause', function() { + // Nothing to do + }); + + $ionicPlatform.on('resume', function() { + // Nothing to do + }); + + $ionicPlatform.on('menubutton', function() { + window.location = '#/preferences'; + }); + }); + + $log.info('Init profile...'); + // Try to open local profile + profileService.loadAndBindProfile(function(err) { + $ionicHistory.nextViewOptions({ + disableAnimate: true + }); + if (err) { + if (err.message && err.message.match('NOPROFILE')) { + $log.debug('No profile... redirecting'); + $state.go('onboarding.welcome'); + } else if (err.message && err.message.match('NONAGREEDDISCLAIMER')) { + if (lodash.isEmpty(profileService.getWallets())) { + $log.debug('No wallets and no disclaimer... redirecting'); $state.go('onboarding.welcome'); - } else if (err.message && err.message.match('NONAGREEDDISCLAIMER')) { - if (lodash.isEmpty(profileService.getWallets())) { - $log.debug('No wallets and no disclaimer... redirecting'); - $state.go('onboarding.welcome'); - } else { - $log.debug('Display disclaimer... redirecting'); - $state.go('onboarding.disclaimer', { - resume: true - }); - } } else { - throw new Error(err); // TODO + $log.debug('Display disclaimer... redirecting'); + $state.go('onboarding.disclaimer', { + resume: true + }); } } else { - profileService.storeProfileIfDirty(); - $log.debug('Profile loaded ... Starting UX.'); - scannerService.gentleInitialize(); - $state.go('tabs.home'); + throw new Error(err); // TODO } + } else { + profileService.storeProfileIfDirty(); + $log.debug('Profile loaded ... Starting UX.'); + scannerService.gentleInitialize(); + $state.go('tabs.home'); + } - // After everything have been loaded, initialize handler URL - $timeout(function() { - openURLService.init(); - }, 1000); - }); + // After everything have been loaded, initialize handler URL + $timeout(function() { + openURLService.init(); + }, 1000); }); if (platformInfo.isNW) { From ae63ae145d39495d854cfa3f71df9a48fadd5fbb Mon Sep 17 00:00:00 2001 From: Gustavo Maximiliano Cortez Date: Mon, 20 Feb 2017 11:56:11 -0300 Subject: [PATCH 3/3] Removes hasClick --- src/js/controllers/modals/txpDetails.js | 1 - src/js/services/platformInfo.js | 16 ---------------- www/views/modals/txp-details.html | 4 ++-- 3 files changed, 2 insertions(+), 19 deletions(-) diff --git a/src/js/controllers/modals/txpDetails.js b/src/js/controllers/modals/txpDetails.js index 5c58d3447..01ab9277b 100644 --- a/src/js/controllers/modals/txpDetails.js +++ b/src/js/controllers/modals/txpDetails.js @@ -14,7 +14,6 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi $scope.canSign = $scope.wallet.canSign() || $scope.wallet.isPrivKeyExternal(); $scope.color = $scope.wallet.color; $scope.data = {}; - $scope.hasClick = platformInfo.hasClick; $scope.displayAmount = getDisplayAmount($scope.tx.amountStr); $scope.displayUnit = getDisplayUnit($scope.tx.amountStr); initActionList(); diff --git a/src/js/services/platformInfo.js b/src/js/services/platformInfo.js index 6a8def4be..f634e8f0f 100644 --- a/src/js/services/platformInfo.js +++ b/src/js/services/platformInfo.js @@ -39,21 +39,5 @@ angular.module('copayApp.services').factory('platformInfo', function($window) { ret.isChromeApp = $window.chrome && chrome.runtime && chrome.runtime.id && !ret.isNW; ret.isDevel = !ret.isMobile && !ret.isChromeApp && !ret.isNW; - ret.hasClick = false; - - if ($window.sessionStorage.getItem('hasClick')) { - ret.hasClick = true; - } - - $window.addEventListener('mousedown', function() { - ret.hasClick = true; - $window.sessionStorage.setItem('hasClick', 'true'); - }); - - $window.addEventListener('touchstart', function() { - ret.hasClick = false; - $window.sessionStorage.removeItem('hasClick'); - }); - return ret; }); diff --git a/www/views/modals/txp-details.html b/www/views/modals/txp-details.html index a37cdc7b7..962b4b0d5 100644 --- a/www/views/modals/txp-details.html +++ b/www/views/modals/txp-details.html @@ -163,13 +163,13 @@ {{buttonText}}