Handle back-button on Android devices

This commit is contained in:
Gustavo Maximiliano Cortez 2015-09-30 14:14:15 -03:00
commit 9d816c20f5
No known key found for this signature in database
GPG key ID: 15EDAD8D9F2EB1AF
3 changed files with 60 additions and 10 deletions

View file

@ -444,13 +444,20 @@ angular
}
})
.state('cordova', {
url: '/cordova/:status',
url: '/cordova/:status/:isHome',
views: {
'main': {
controller: function($rootScope, $stateParams, $timeout, go) {
controller: function($rootScope, $state, $stateParams, $timeout, go, isCordova) {
switch ($stateParams.status) {
case 'resume':
$rootScope.$emit('Local/Resume');
$rootScope.$emit('Local/Resume');
break;
case 'backbutton':
if (isCordova && $stateParams.isHome == 'true' && !$rootScope.modalOpened) {
navigator.app.exitApp();
} else {
$rootScope.$emit('closeModal');
}
break;
};
$timeout(function() {
@ -528,7 +535,6 @@ angular
$rootScope.$on('$stateChangeStart', function(event, toState, toParams, fromState, fromParams) {
if (!profileService.profile && toState.needProfile) {
// Give us time to open / create the profile