From 085b5ff0dbe34f355dd8012e8a76c4d6e9aa0aec Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Mon, 30 Mar 2020 09:43:18 -0700 Subject: mobile: improve Android back key behavior There are two places where we try to prevemt unintended app exits. Once, in the onBackRequested signal handler on the dive list. This was missing special handling for the situation where one of the drawers was open. The second place is the onClosing signal handler in main.qml. Naively I thought that this was enough to catch all cases where we were about to exit the app, but apparently an explicit manager.quit() is a bit too forceful and doesn't get to that signal handler. With this commit we check for open drawers in both places. Belts and suspenders, I guess. Signed-off-by: Dirk Hohndel --- mobile-widgets/qml/DiveList.qml | 10 +++++++++- mobile-widgets/qml/main.qml | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'mobile-widgets/qml') diff --git a/mobile-widgets/qml/DiveList.qml b/mobile-widgets/qml/DiveList.qml index 76e8a52f9..b8cb553c7 100644 --- a/mobile-widgets/qml/DiveList.qml +++ b/mobile-widgets/qml/DiveList.qml @@ -491,7 +491,15 @@ Kirigami.ScrollablePage { event.accepted = true; } if (!startPage.visible) { - if (Qt.platform.os != "ios") { + if (globalDrawer.visible) { + globalDrawer.close() + event.accepted = true + } + if (contextDrawer.visible) { + contextDrawer.close() + event.accepted = true + } + if (event.accepted === false && Qt.platform.os !== "ios") { manager.quit() } // let's make sure Kirigami doesn't quit on our behalf diff --git a/mobile-widgets/qml/main.qml b/mobile-widgets/qml/main.qml index 1de83eb3f..243978c46 100644 --- a/mobile-widgets/qml/main.qml +++ b/mobile-widgets/qml/main.qml @@ -881,6 +881,7 @@ if you have network connectivity and want to sync your data to cloud storage."), manager.appInitialized() } onClosing: { + // this duplicates the check that is already in the onBackRequested signal handler of the DiveList if (globalDrawer.visible) { globalDrawer.close() close.accepted = false -- cgit v1.2.3-70-g09d2