diff --git a/public/views/includes/menu.html b/public/views/includes/menu.html index 179c52e58..30b53cdb9 100644 --- a/public/views/includes/menu.html +++ b/public/views/includes/menu.html @@ -1,7 +1,6 @@ -
+
-
+ diff --git a/public/views/includes/topbar.html b/public/views/includes/topbar.html index 68b6e56ce..1e0e8a7c0 100644 --- a/public/views/includes/topbar.html +++ b/public/views/includes/topbar.html @@ -10,7 +10,7 @@
- diff --git a/public/views/walletHome.html b/public/views/walletHome.html index ca934676f..572983e93 100644 --- a/public/views/walletHome.html +++ b/public/views/walletHome.html @@ -224,7 +224,7 @@
- diff --git a/src/css/mobile.css b/src/css/mobile.css index afd980a94..9a4fa1465 100644 --- a/src/css/mobile.css +++ b/src/css/mobile.css @@ -275,7 +275,6 @@ a.missing-copayers { .sidebar li { overflow: hidden; - padding: 1rem 0.7rem; border-bottom: 1px solid #f1f3f5; } @@ -327,15 +326,12 @@ a.missing-copayers { vertical-align: middle; font-weight: 300; border-bottom: transparent; - padding: 0; color: #A5B2BF; + padding: 1rem 0.7rem; } .sidebar ul.off-canvas-list li a i { vertical-align: middle; -} - -.sidebar ul.off-canvas-list li a i { opacity: 0.6; } @@ -774,3 +770,9 @@ textarea:focus -webkit-transform: translate3d(-100%, 0, 0) !important; transform: translate3d(-100%, 0, 0) !important; } + +/* removes 300ms in IE */ +-ms-touch-action: manipulation; /* IE10 / +touch-action: manipulation; /* IE11+ */ + + diff --git a/src/js/controllers/index.js b/src/js/controllers/index.js index f094c12f4..9a9514b3b 100644 --- a/src/js/controllers/index.js +++ b/src/js/controllers/index.js @@ -95,6 +95,8 @@ angular.module('copayApp.controllers').controller('indexController', function($r self.isComplete = fc.isComplete(); self.txps = []; self.copayers = []; + self.updateColor(); + go.walletHome(); storageService.getBackupFlag(self.walletId, function(err, val) { self.needsBackup = self.network == 'testnet' ? false : !val; @@ -103,10 +105,17 @@ angular.module('copayApp.controllers').controller('indexController', function($r }); }; - self.setTab = function(tab) { - if (self.tab === tab) + self.setTab = function(tab, reset, tries) { + tries = tries || 0; + if (self.tab === tab && !reset) return; + if (! document.getElementById('menu-' + tab) && ++tries<5) { + return $timeout(function() { + self.setTab(tab,reset); + }, 300); + } + if (!self.tab) self.tab = 'walletHome'; @@ -257,7 +266,6 @@ angular.module('copayApp.controllers').controller('indexController', function($r }; self.openWallet = function() { var fc = profileService.focusedClient; - self.updateColor(); $timeout(function() { $rootScope.$apply(); self.setOngoingProcess('openingWallet', true); @@ -406,8 +414,8 @@ angular.module('copayApp.controllers').controller('indexController', function($r }); if (used) { $log.debug('Address ' + addr + ' was used. Cleaning Cache.') - $rootScope.$emit('Local/NeedNewAddress', err); storageService.clearLastAddress(self.walletId, function(err) { + $rootScope.$emit('Local/NeedNewAddress', err); if (cb) return cb(); }); }; @@ -553,17 +561,27 @@ angular.module('copayApp.controllers').controller('indexController', function($r go.walletHome(); }); + self.debouncedUpdate = lodash.throttle(function() { + self.updateAll(); + self.updateTxHistory(); + }, 4000, {leading: false, trailing: true}); + + + // No need ot listing to Local/Resume since + // reconnection and Local/Online will be triggered lodash.each(['Local/Online', 'Local/Resume'], function(eventName) { $rootScope.$on(eventName, function(event) { - $log.debug('### Online event'); - self.isOffline = false; - self.updateAll(); - self.updateTxHistory(); + $log.debug('### ' + eventName + ' event'); + self.debouncedUpdate(); }); }); + $rootScope.$on('Local/Online', function(event) { + self.isOffline = false; + }); + $rootScope.$on('Local/Offline', function(event) { - $log.debug('Offline event'); + $log.debug('### Offline event'); self.isOffline = true; $timeout(function() { $rootScope.$apply(); @@ -686,8 +704,8 @@ angular.module('copayApp.controllers').controller('indexController', function($r self.updateTxHistory(); }); - $rootScope.$on('Local/SetTab', function(event, tab) { - self.setTab(tab); + $rootScope.$on('Local/SetTab', function(event, tab, reset) { + self.setTab(tab, reset); }); $rootScope.$on('Local/NeedsPassword', function(event, isSetup, cb) { diff --git a/src/js/controllers/sidebar.js b/src/js/controllers/sidebar.js index ba5350b69..f48a725ab 100644 --- a/src/js/controllers/sidebar.js +++ b/src/js/controllers/sidebar.js @@ -21,8 +21,8 @@ angular.module('copayApp.controllers').controller('sidebarController', self.switchWallet = function(wid) { self.walletSelection = false; - profileService.setAndStoreFocus(wid, function() {}); - go.walletHome(); + profileService.setAndStoreFocus(wid, function() { + }); }; self.toggleWalletSelection = function() { diff --git a/src/js/controllers/walletHome.js b/src/js/controllers/walletHome.js index c832510fa..b4802cfac 100644 --- a/src/js/controllers/walletHome.js +++ b/src/js/controllers/walletHome.js @@ -25,33 +25,51 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi this.isMobile = isMobile.any(); var disableScannerListener = $rootScope.$on('dataScanned', function(event, data) { - $scope.$emit('Local/SetTab', 'send'); self.setForm(data); + $rootScope.$emit('Local/SetTab', 'send'); }); var disablePaymentUriListener = $rootScope.$on('paymentUri', function(event, uri) { $timeout(function() { - $scope.$emit('Local/SetTab', 'send'); + $rootScope.$emit('Local/SetTab', 'send'); self.setForm(uri); }, 100); }); var disableAddrListener = $rootScope.$on('Local/NeedNewAddress', function() { - self.getAddress(); + self.setNewAddress(); }); var disableFocusListener = $rootScope.$on('Local/NewFocusedWallet', function() { + self.addr = null; self.resetForm(); }); + var disableOnlineListener = $rootScope.$on('Local/Online', function() { + // This is needed then the apps go to sleep + $timeout(function() { + self.bindTouchDown(); + }, 2000); + }); + + var disableResumeListener = $rootScope.$on('Local/Resume', function() { + // This is needed then the apps go to sleep + $timeout(function() { + self.bindTouchDown(); + }, 2000); + }); + + + var disableTabListener = $rootScope.$on('Local/TabChanged', function(e, tab) { + // This will slow down switch, do not add things here! switch (tab) { + case 'receive': + // just to be sure we have an address + self.setAddress(); + break; case 'send': self.resetError(); - self.setInputs(); - case 'receive': - self.getAddress(); - break; }; }); @@ -61,6 +79,8 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi disablePaymentUriListener(); disableTabListener(); disableFocusListener(); + disableResumeListener(); + disableOnlineListener(); $rootScope.hideMenuBar = false; }); @@ -267,17 +287,17 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi }); modalInstance.result.then(function(txp) { + $scope.$emit('Local/TxProposalAction'); if (txp) { + self.setOngoingProcess(); txStatus.notify(txp); } - $scope.$emit('Local/TxProposalAction'); }); }; // Receive - - this.newAddress = function() { + this.setNewAddress = function() { var fc = profileService.focusedClient; self.generatingAddress = true; fc.createAddress(function(err, addr) { @@ -297,16 +317,19 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi }); }; - this.getAddress = function() { + this.setAddress = function() { + if (self.addr) + return; + var fc = profileService.focusedClient; $timeout(function() { storageService.getLastAddress(fc.credentials.walletId, function(err, addr) { if (addr) { self.addr = addr; + $scope.$digest(); } else { - self.newAddress(); + self.setNewAddress(); } - $scope.$digest(); }); }); }; @@ -345,10 +368,29 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi this.error = this.success = null; }; + this.bindTouchDown = function(tries) { + var self = this; + tries = tries || 0; + if (tries > 5) return; + var e = document.getElementById('menu-walletHome'); + if (!e) return $timeout(function() { + self.bindTouchDown(++tries); + }, 500); - var hideMenuBar = lodash.debounce(function(hide) { + // on touchdown elements + $log.debug('Binding touchstart elements...'); + ['menu-walletHome', 'menu-send', 'menu-receive', 'menu-history'].forEach(function(id) { + var e = document.getElementById(id); + if (e) e.addEventListener('touchstart', function() { + angular.element(e).triggerHandler('click'); + }); + }); + } + + this.hideMenuBar = lodash.debounce(function(hide) { if (hide) { $rootScope.hideMenuBar = true; + this.bindTouchDown(); } else { $rootScope.hideMenuBar = false; } @@ -358,7 +400,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi this.formFocus = function(what) { if (isCordova && !this.isWindowsPhoneApp) { - hideMenuBar(what); + this.hideMenuBar(what); } if (!this.isWindowsPhoneApp) return @@ -379,7 +421,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi }, 1); }; - this.setInputs = function() { + this.setSendFormInputs = function() { var unitToSat = this.unitToSatoshi; var satToUnit = 1 / unitToSat; /** @@ -454,16 +496,17 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi if (isCordova) { if (name) { + window.plugins.spinnerDialog.hide(); window.plugins.spinnerDialog.show(null, name + '...', true); } else { window.plugins.spinnerDialog.hide(); } } else { + self.onGoingProcess = name; $timeout(function() { - self.onGoingProcess = name; $rootScope.$apply(); }); - } + }; }; this.submitForm = function() { @@ -532,22 +575,21 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi if (signedTx.status == 'accepted') { self.setOngoingProcess('Broadcasting transaction'); fc.broadcastTxProposal(signedTx, function(err, btx) { + self.setOngoingProcess(); if (err) { - self.setOngoingProcess(); $scope.error = 'Transaction not broadcasted. Please try again.'; $scope.$digest(); - return; + return cb(err); } $scope.$emit('Local/TxProposalAction'); txStatus.notify(btx, function() { - self.setOngoingProcess(); return cb(); }); }); } else { + self.setOngoingProcess(); $scope.$emit('Local/TxProposalAction'); txStatus.notify(signedTx, function() { - self.setOngoingProcess(); return cb(); }); } @@ -790,4 +832,9 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi return actions.hasOwnProperty('create'); }; + // Startup events + this.bindTouchDown(); + this.setAddress(); + this.setSendFormInputs(); + }); diff --git a/src/js/init.js b/src/js/init.js index 21cd08a5e..ba6e36e0d 100644 --- a/src/js/init.js +++ b/src/js/init.js @@ -18,6 +18,8 @@ angular.element(document).ready(function() { }, false); document.addEventListener('resume', function() { + +console.log('[init.js.21] RESUME'); //TODO if (!window.ignoreMobilePause) { window.location = '#/cordova/resume'; } @@ -31,10 +33,6 @@ angular.element(document).ready(function() { document.addEventListener('offline', function() { window.location = '#/cordova/offline'; }, false); - // - // document.addEventListener("online", function() { - // window.location = '#/cordoba/online'; - // }, false); // Back button event document.addEventListener('backbutton', function() { diff --git a/src/js/routes.js b/src/js/routes.js index 5218d468d..42d2a19e1 100644 --- a/src/js/routes.js +++ b/src/js/routes.js @@ -443,16 +443,13 @@ angular url: '/cordova/:status', views: { 'main': { - controller: function($scope, $stateParams, go) { + controller: function($rootScope, $stateParams, go) { switch ($stateParams.status) { case 'resume': - $scope.$emit('Local/Resume'); + $rootScope.$emit('Local/Resume'); break; - // case 'online': - // // $scope.$emit('Local/Online'); - // break; case 'offline': - $scope.$emit('Local/Offline'); + $rootScope.$emit('Local/Offline'); break; }; go.walletHome(); @@ -506,6 +503,7 @@ angular importLegacy: 12 }; + $rootScope.$on('$stateChangeSuccess', function() { $rootScope.$emit('Animation/Disable'); }); diff --git a/src/js/services/go.js b/src/js/services/go.js index d7139b00e..c47791546 100644 --- a/src/js/services/go.js +++ b/src/js/services/go.js @@ -55,7 +55,7 @@ angular.module('copayApp.services').factory('go', function($window, $rootScope, root.path('copayers'); } else { root.path('walletHome', function() { - $rootScope.$emit('Local/SetTab', 'walletHome'); + $rootScope.$emit('Local/SetTab', 'walletHome', true); }); } };