adding test modal for pin
This commit is contained in:
parent
d1a2c2bbbf
commit
9bb12e91f5
5 changed files with 127 additions and 53 deletions
12
src/js/controllers/modals/pintest.js
Normal file
12
src/js/controllers/modals/pintest.js
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
angular.module('copayApp.controllers').controller('pinTestController', function($scope, applicationService) {
|
||||||
|
|
||||||
|
$scope.goodPin = function() {
|
||||||
|
applicationService.successfullUnlocked = true;
|
||||||
|
$scope.pintestview.hide();
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.badPin = function() {};
|
||||||
|
|
||||||
|
});
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('copayApp.controllers').controller('pinController', function($state, $interval, $stateParams, $ionicHistory, $timeout, $scope, $log, configService, appConfigService) {
|
angular.module('copayApp.controllers').controller('pinController', function($state, $interval, $stateParams, $ionicHistory, $timeout, $scope, $log, configService, appConfigService, applicationService) {
|
||||||
var ATTEMPT_LIMIT = 3;
|
var ATTEMPT_LIMIT = 3;
|
||||||
var ATTEMPT_LOCK_OUT_TIME = 5 * 60;
|
var ATTEMPT_LOCK_OUT_TIME = 5 * 60;
|
||||||
var currentPin;
|
var currentPin;
|
||||||
|
|
@ -126,7 +126,12 @@ angular.module('copayApp.controllers').controller('pinController', function($sta
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'check':
|
case 'check':
|
||||||
if (isMatch(currentPin)) return $scope.close();
|
if (isMatch(currentPin)) {
|
||||||
|
console.log("##################################### CHECKING");
|
||||||
|
applicationService.successfullUnlocked = true;
|
||||||
|
$scope.close();
|
||||||
|
return;
|
||||||
|
}
|
||||||
showError();
|
showError();
|
||||||
checkAttempts();
|
checkAttempts();
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
111
src/js/routes.js
111
src/js/routes.js
|
|
@ -1135,7 +1135,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.run(function($rootScope, $state, $location, $log, $timeout, startupService, fingerprintService, $ionicHistory, $ionicPlatform, $window, appConfigService, lodash, platformInfo, profileService, uxLanguage, gettextCatalog, openURLService, storageService, scannerService, configService, /* plugins START HERE => */ coinbaseService, glideraService, amazonService, bitpayCardService) {
|
.run(function($rootScope, $state, $location, $log, $timeout, startupService, fingerprintService, $ionicHistory, $ionicPlatform, $window, appConfigService, lodash, platformInfo, profileService, uxLanguage, gettextCatalog, openURLService, storageService, scannerService, configService, /* plugins START HERE => */ coinbaseService, glideraService, amazonService, bitpayCardService, applicationService) {
|
||||||
|
|
||||||
uxLanguage.init();
|
uxLanguage.init();
|
||||||
|
|
||||||
|
|
@ -1196,55 +1196,56 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
function checkAndApplyLock(onResume) {
|
// function checkAndApplyLock(onResume) {
|
||||||
var defaultView = 'tabs.home';
|
// var defaultView = 'tabs.home';
|
||||||
|
//
|
||||||
if (!platformInfo.isCordova && !platformInfo.isDevel) {
|
// if (!platformInfo.isCordova && !platformInfo.isDevel) {
|
||||||
goTo(defaultView);
|
// goTo(defaultView);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if (onResume) {
|
// if (onResume) {
|
||||||
var now = Math.floor(Date.now() / 1000);
|
// var now = Math.floor(Date.now() / 1000);
|
||||||
if (now < openURLService.unlockUntil) {
|
// if (now < openURLService.unlockUntil) {
|
||||||
openURLService.unlockUntil = null;
|
// openURLService.unlockUntil = null;
|
||||||
$log.debug('Skip startup locking');
|
// $log.debug('Skip startup locking');
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
function goTo(nextView) {
|
// function goTo(nextView) {
|
||||||
nextView = nextView || defaultView;
|
// nextView = nextView || defaultView;
|
||||||
$state.transitionTo(nextView, {
|
// $state.transitionTo(nextView, {
|
||||||
action: 'check'
|
// action: 'check'
|
||||||
}).then(function() {
|
// }).then(function() {
|
||||||
if (nextView == 'lockedView')
|
// if (nextView == 'lockedView')
|
||||||
$ionicHistory.clearHistory();
|
// $ionicHistory.clearHistory();
|
||||||
});
|
// });
|
||||||
};
|
// };
|
||||||
|
//
|
||||||
startupService.ready();
|
// startupService.ready();
|
||||||
|
//
|
||||||
configService.whenAvailable(function(config) {
|
// configService.whenAvailable(function(config) {
|
||||||
var lockMethod = config.lock && config.lock.method;
|
// var lockMethod = config.lock && config.lock.method;
|
||||||
$log.debug('App Lock:' + (lockMethod || 'no'));
|
// $log.debug('App Lock:' + (lockMethod || 'no'));
|
||||||
|
//
|
||||||
if (lockMethod == 'fingerprint' && fingerprintService.isAvailable()) {
|
// if (lockMethod == 'fingerprint' && fingerprintService.isAvailable()) {
|
||||||
fingerprintService.check('unlockingApp', function(err) {
|
// fingerprintService.check('unlockingApp', function(err) {
|
||||||
if (err)
|
// if (err)
|
||||||
goTo('lockedView');
|
// goTo('lockedView');
|
||||||
else if ($ionicHistory.currentStateName() == 'lockedView' || !onResume)
|
// else if ($ionicHistory.currentStateName() == 'lockedView' || !onResume)
|
||||||
goTo('tabs.home');
|
// goTo('tabs.home');
|
||||||
});
|
// });
|
||||||
} else if (lockMethod == 'pin') {
|
// } else if (lockMethod == 'pin') {
|
||||||
goTo('pin');
|
// goTo('pin');
|
||||||
} else {
|
// } else {
|
||||||
goTo(defaultView);
|
// goTo(defaultView);
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
|
|
||||||
$ionicPlatform.on('resume', function() {
|
$ionicPlatform.on('resume', function() {
|
||||||
checkAndApplyLock(true);
|
applicationService.successfullUnlocked = false;
|
||||||
|
// checkAndApplyLock(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
$ionicPlatform.on('menubutton', function() {
|
$ionicPlatform.on('menubutton', function() {
|
||||||
|
|
@ -1287,8 +1288,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
||||||
disableAnimate: true,
|
disableAnimate: true,
|
||||||
historyRoot: true
|
historyRoot: true
|
||||||
});
|
});
|
||||||
|
$state.transitionTo('tabs.home');
|
||||||
checkAndApplyLock();
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
// After everything have been loaded, initialize handler URL
|
// After everything have been loaded, initialize handler URL
|
||||||
|
|
@ -1316,5 +1316,16 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
||||||
$log.debug('Route change from:', fromState.name || '-', ' to:', toState.name);
|
$log.debug('Route change from:', fromState.name || '-', ' to:', toState.name);
|
||||||
$log.debug(' toParams:' + JSON.stringify(toParams || {}));
|
$log.debug(' toParams:' + JSON.stringify(toParams || {}));
|
||||||
$log.debug(' fromParams:' + JSON.stringify(fromParams || {}));
|
$log.debug(' fromParams:' + JSON.stringify(fromParams || {}));
|
||||||
|
configService.whenAvailable(function(config) {
|
||||||
|
var lockMethod = config.lock && config.lock.method;
|
||||||
|
console.log(lockMethod);
|
||||||
|
console.log("########################");
|
||||||
|
if (!lockMethod || lockMethod == 'none') return;
|
||||||
|
|
||||||
|
if (!applicationService.successfullUnlocked && !applicationService.pinIsOpen) {
|
||||||
|
console.log("################################# OPEN PIN MODAL");
|
||||||
|
applicationService.pinModal();
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,11 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
angular.module('copayApp.services')
|
angular.module('copayApp.services')
|
||||||
.factory('applicationService', function($rootScope, $timeout, $ionicHistory, platformInfo, $state) {
|
.factory('applicationService', function($rootScope, $timeout, $ionicHistory, $ionicModal, platformInfo, $state) {
|
||||||
var root = {};
|
var root = {};
|
||||||
|
|
||||||
|
root.successfullUnlocked = false;
|
||||||
|
root.pinIsOpen = false;
|
||||||
|
|
||||||
var isChromeApp = platformInfo.isChromeApp;
|
var isChromeApp = platformInfo.isChromeApp;
|
||||||
var isNW = platformInfo.isNW;
|
var isNW = platformInfo.isNW;
|
||||||
|
|
||||||
|
|
@ -33,5 +36,38 @@ angular.module('copayApp.services')
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
root.pinModal = function() {
|
||||||
|
|
||||||
|
root.pinIsOpen = true;
|
||||||
|
root.successfullUnlocked = false;
|
||||||
|
var scope = $rootScope.$new(true);
|
||||||
|
$ionicModal.fromTemplateUrl('views/modals/pintestview.html', {
|
||||||
|
scope: scope,
|
||||||
|
animation: 'slide-in-up',
|
||||||
|
backdropClickToClose: false,
|
||||||
|
hardwareBackButtonClose: false
|
||||||
|
}).then(function(modal) {
|
||||||
|
scope.pintestview = modal;
|
||||||
|
scope.pintestview.show();
|
||||||
|
});
|
||||||
|
scope.openModal = function() {
|
||||||
|
scope.modal.show();
|
||||||
|
};
|
||||||
|
scope.closeModal = function() {
|
||||||
|
scope.modal.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
|
||||||
|
});
|
||||||
|
}
|
||||||
return root;
|
return root;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
10
www/views/modals/pintestview.html
Normal file
10
www/views/modals/pintestview.html
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
<ion-modal-view ng-controller="pinTestController">
|
||||||
|
<ion-content>
|
||||||
|
<button class="button button-positive" ng-click="goodPin()">
|
||||||
|
BIEN PUESTO
|
||||||
|
</button>
|
||||||
|
<button class="button button-positive" ng-click="badPin()">
|
||||||
|
MAL PUESTO
|
||||||
|
</button>
|
||||||
|
</ion-content>
|
||||||
|
</ion-modal-view>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue