diff --git a/src/js/controllers/lockSetup.js b/src/js/controllers/lockSetup.js index 9613abaac..fc4470bcc 100644 --- a/src/js/controllers/lockSetup.js +++ b/src/js/controllers/lockSetup.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('copayApp.controllers').controller('lockSetupController', function($state, $scope, $timeout, $log, configService, gettextCatalog, fingerprintService, profileService, lodash, applicationService) { +angular.module('copayApp.controllers').controller('lockSetupController', function($state, $rootScope, $scope, $timeout, $log, configService, gettextCatalog, fingerprintService, profileService, lodash, applicationService) { function init() { $scope.options = [ @@ -53,7 +53,7 @@ angular.module('copayApp.controllers').controller('lockSetupController', functio o.disabled = false; }); - // HACK: Disable untill we allow to change between methods directly + // HACK: Disable until we allow to change between methods directly if (fingerprintService.isAvailable()) { switch (savedMethod) { case 'pin': @@ -121,6 +121,7 @@ angular.module('copayApp.controllers').controller('lockSetupController', functio switch (method) { case 'pin': applicationService.pinModal('disable'); + initMethodSelector(); break; case 'fingerprint': fingerprintService.check('unlockingApp', function(err) { @@ -135,6 +136,7 @@ angular.module('copayApp.controllers').controller('lockSetupController', functio switch (method) { case 'pin': applicationService.pinModal('setup'); + initMethodSelector(); break; case 'fingerprint': saveConfig('fingerprint'); @@ -155,4 +157,9 @@ angular.module('copayApp.controllers').controller('lockSetupController', functio initMethodSelector(); }); }; + + $rootScope.$on('pinModalClosed', function() { + initMethodSelector(); + }); + }); diff --git a/src/js/controllers/modals/pin.js b/src/js/controllers/modals/pin.js index a580d0442..1e2acfb2b 100644 --- a/src/js/controllers/modals/pin.js +++ b/src/js/controllers/modals/pin.js @@ -5,10 +5,11 @@ angular.module('copayApp.controllers').controller('pinController', function($sta var ATTEMPT_LOCK_OUT_TIME = 5 * 60; var currentPin; currentPin = $scope.confirmPin = ''; - console.log("############################11111"); + $scope.match = $scope.error = $scope.disableButtons = false; $scope.currentAttempts = 0; $scope.appName = appConfigService.name; + configService.whenAvailable(function(config) { if (!config.lock) return; $scope.bannedUntil = config.lock.bannedUntil || null; @@ -104,8 +105,6 @@ angular.module('copayApp.controllers').controller('pinController', function($sta }; $scope.save = function() { - console.log("##################################### CHECKING"); - console.log($scope.action); if (!$scope.isComplete()) return; var savedMethod = getSavedMethod(); @@ -123,7 +122,6 @@ angular.module('copayApp.controllers').controller('pinController', function($sta break; case 'check': if (isMatch(currentPin)) { - console.log("##################################### CHECKING"); applicationService.successfullUnlocked = true; $scope.hideModal(); return; @@ -206,15 +204,4 @@ angular.module('copayApp.controllers').controller('pinController', function($sta lockTimeControl(bannedUntil); }); }; - - // $scope.close = function(delay) { - // $timeout(function() { - // var shouldReturn = $ionicHistory.viewHistory().backView && $ionicHistory.viewHistory().backView.stateName != 'starting'; - // - // if (shouldReturn) - // $ionicHistory.goBack() - // else - // $state.go('tabs.home'); - // }, delay || 1); - // }; }); diff --git a/src/js/routes.js b/src/js/routes.js index 4b1cdf416..5394d9ff3 100644 --- a/src/js/routes.js +++ b/src/js/routes.js @@ -1183,58 +1183,8 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr // Nothing to do }); - - // function checkAndApplyLock(onResume) { - // var defaultView = 'tabs.home'; - // - // if (!platformInfo.isCordova && !platformInfo.isDevel) { - // goTo(defaultView); - // } - // - // if (onResume) { - // var now = Math.floor(Date.now() / 1000); - // if (now < openURLService.unlockUntil) { - // openURLService.unlockUntil = null; - // $log.debug('Skip startup locking'); - // return; - // } - // } - // - // function goTo(nextView) { - // nextView = nextView || defaultView; - // $state.transitionTo(nextView, { - // action: 'check' - // }).then(function() { - // if (nextView == 'lockedView') - // $ionicHistory.clearHistory(); - // }); - // }; - // - // startupService.ready(); - // - // configService.whenAvailable(function(config) { - // var lockMethod = config.lock && config.lock.method; - // $log.debug('App Lock:' + (lockMethod || 'no')); - // - // if (lockMethod == 'fingerprint' && fingerprintService.isAvailable()) { - // fingerprintService.check('unlockingApp', function(err) { - // if (err) - // goTo('lockedView'); - // else if ($ionicHistory.currentStateName() == 'lockedView' || !onResume) - // goTo('tabs.home'); - // }); - // } else if (lockMethod == 'pin') { - // goTo('pin'); - // } else { - // goTo(defaultView); - // } - // }); - // } - $ionicPlatform.on('resume', function() { - applicationService.successfullUnlocked = false; - applicationService.pinModal('check'); - // checkAndApplyLock(true); + applicationService.appLockModal('check'); }); $ionicPlatform.on('menubutton', function() { @@ -1305,14 +1255,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr $log.debug('Route change from:', fromState.name || '-', ' to:', toState.name); $log.debug(' toParams:' + JSON.stringify(toParams || {})); $log.debug(' fromParams:' + JSON.stringify(fromParams || {})); - configService.whenAvailable(function(config) { - var lockMethod = config.lock && config.lock.method; - if (!lockMethod || lockMethod == 'none') return; - if (!applicationService.successfullUnlocked && !applicationService.pinIsOpen) { - console.log("################################# OPEN PIN MODAL"); - applicationService.pinModal('check'); - } - }); + if (!applicationService.successfullUnlocked) applicationService.appLockModal('check'); }); }); diff --git a/src/js/services/applicationService.js b/src/js/services/applicationService.js index 5c7bee379..c1c6584a3 100644 --- a/src/js/services/applicationService.js +++ b/src/js/services/applicationService.js @@ -1,10 +1,10 @@ 'use strict'; angular.module('copayApp.services') - .factory('applicationService', function($rootScope, $timeout, $ionicHistory, $ionicModal, platformInfo, $state) { + .factory('applicationService', function($rootScope, $timeout, $ionicHistory, $ionicModal, platformInfo, fingerprintService, openURLService, configService, $state) { var root = {}; root.successfullUnlocked = false; - root.pinIsOpen = false; + root.pinModalIsOpen = false; var isChromeApp = platformInfo.isChromeApp; var isNW = platformInfo.isNW; @@ -36,17 +36,24 @@ angular.module('copayApp.services') } }; - root.pinModal = function(action) { + root.fingerprintModal = function() { + fingerprintService.check('unlockingApp', function(err) { + if (err) { + root.fingerprintModal(); + return; + } + root.successfullUnlocked = true; + }); + }; + + root.pinModal = function(action) { + if (root.pinModalIsOpen) return; - root.pinIsOpen = true; - root.successfullUnlocked = false; var scope = $rootScope.$new(true); - console.log(action); - console.log("###########################111"); scope.action = action; $ionicModal.fromTemplateUrl('views/modals/pin.html', { scope: scope, - animation: 'slide-in-up', + animation: 'none', backdropClickToClose: false, hardwareBackButtonClose: false }).then(function(modal) { @@ -54,22 +61,25 @@ angular.module('copayApp.services') scope.openModal(); }); scope.openModal = function() { + root.pinModalIsOpen = true; scope.pinModal.show(); }; scope.hideModal = function() { + scope.$emit('pinModalClosed'); + root.pinModalIsOpen = false; scope.pinModal.hide(); }; - // Cleanup the modal when we're done with it! - scope.$on('$destroy', function() { - scope.modal.remove(); - }); - // Execute action on hide modal - scope.$on('modal.hidden', function() { - // Execute action - }); - // Execute action on remove modal - scope.$on('modal.removed', function() { - // Execute action + }; + + root.appLockModal = function(action) { + + configService.whenAvailable(function(config) { + var lockMethod = config.lock && config.lock.method; + if (!lockMethod || lockMethod == 'none') return; + + if (lockMethod == 'fingerprint' && fingerprintService.isAvailable()) root.fingerprintModal(); + if (lockMethod == 'pin') root.pinModal(action); + }); } return root; diff --git a/src/js/services/openURL.js b/src/js/services/openURL.js index 8e6a768cf..45e7748c7 100644 --- a/src/js/services/openURL.js +++ b/src/js/services/openURL.js @@ -1,14 +1,9 @@ 'use strict'; angular.module('copayApp.services').factory('openURLService', function($rootScope, $ionicHistory, $document, $log, $state, platformInfo, lodash, profileService, incomingData, appConfigService) { - var DELAY_UNLOCK_TIME = 2 * 60; var root = {}; - root.unlockUntil = null; - var handleOpenURL = function(args) { - root.unlockUntil = Math.floor(Date.now() / 1000) + DELAY_UNLOCK_TIME; - $log.debug('Set unlock time until: ' + root.unlockUntil); $log.info('Handling Open URL: ' + JSON.stringify(args)); // Stop it from caching the first view as one to return when the app opens diff --git a/src/sass/views/pin.scss b/src/sass/views/pin.scss index 3d695f185..8a3547de8 100644 --- a/src/sass/views/pin.scss +++ b/src/sass/views/pin.scss @@ -1,14 +1,8 @@ #pin { background-color: #FAFAFA; - .bar.bar-clear { - background-color: transparent; - border: none; - .back-button .icon:before { - color: #2d3f50; - } - } .content { text-align: center; + position: fixed; width: 100%; height: 100%; .app-icon {