From 806142bbcffad1d8056c7d4710be4277df8f04fb Mon Sep 17 00:00:00 2001 From: PliablePixels Date: Wed, 29 Jul 2015 18:11:59 -0400 Subject: fixed back button behavior for Android - it first opens the main menu, then exits --- www/js/app.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'www/js') diff --git a/www/js/app.js b/www/js/app.js index 042db8e3..d90a25c0 100644 --- a/www/js/app.js +++ b/www/js/app.js @@ -10,7 +10,8 @@ angular.module('zmApp', [ 'tc.chartjs', 'zmApp.controllers', 'fileLogger', - 'angular-carousel', 'angularAwesomeSlider' + 'angular-carousel', + 'angularAwesomeSlider' //'angularAwesomeSlider' ]) @@ -289,6 +290,8 @@ angular.module('zmApp', [ ZMDataModel.init(); + + var loginData = ZMDataModel.getLogin(); if (ZMDataModel.isLoggedIn()) { @@ -300,11 +303,19 @@ angular.module('zmApp', [ } // This code takes care of trapping the Android back button - // and takes it to the menu. FIXME: For some reason, isOpen of Side - // MenuDelegate always returns False, so I don't know - // when its on or off, so can't exit the app if its on + // and takes it to the menu. + $ionicPlatform.registerBackButtonAction(function(e) { + e.preventDefault(); + if (!$ionicSideMenuDelegate.isOpenLeft()) { + $ionicSideMenuDelegate.toggleLeft(); + console.log ("Status of SIDE MENU IS : " + $ionicSideMenuDelegate.isOpen()); + } else { + navigator.app.exitApp(); + } + }, 1000); + -- cgit v1.2.3