diff --git a/android_openssl b/android_openssl
index edc0a6fb..d97317e8 160000
--- a/android_openssl
+++ b/android_openssl
@@ -1 +1 @@
-Subproject commit edc0a6fb19821d59f13087cf38c9a56932798b57
+Subproject commit d97317e856d55a2f5399f17888f1852fee8b9553
diff --git a/nymea-app/ui/Nymea.qml b/nymea-app/ui/Nymea.qml
index 631740d1..9abc3ebb 100644
--- a/nymea-app/ui/Nymea.qml
+++ b/nymea-app/ui/Nymea.qml
@@ -65,10 +65,6 @@ ApplicationWindow {
}
property alias _discovery: discovery
- onClosing: {
- rootItem.handleCloseEvent(close)
- }
-
property var supportedInterfaces: ["light", "weather", "media", "garagegate", "awning", "shutter", "blind", "powersocket", "heating", "sensor", "smartmeter", "evcharger", "accesscontrol", "button", "notifications", "inputtrigger", "outputtrigger", "gateway"]
function interfaceToString(name) {
switch(name) {
@@ -338,6 +334,32 @@ ApplicationWindow {
return s.substr(s.length-size);
}
+ // Handle the Android close event that happens when the back button is pressed
+ // It's hard to handle the key press, because we might not have focus all the time
+ // So let's handle the window's onClosing signal instad.
+ // The problem is, we cannot distinguish between the back button being pressed
+ // or the bottom swipe gesture is being used to switch apps. Let's try to figure that out
+ // by checking if the app becomes inactive right after the event. If not, it's probably a back
+ // button press and we close ourselves.
+ onClosing: {
+ if (Qt.platform.os == "android") {
+ var handled = rootItem.handleAndroidBackButton();
+ if (!handled) {
+ closeTimer.start()
+ }
+ close.accepted = false;
+ }
+ }
+ Timer {
+ id: closeTimer
+ interval: 300
+ onTriggered: Qt.quit();
+ }
+ Connections {
+ target: Qt.application
+ onStateChanged: closeTimer.stop()
+ }
+
KeyboardLoader {
id: keyboardRect
diff --git a/nymea-app/ui/RootItem.qml b/nymea-app/ui/RootItem.qml
index 7dfd8f6c..c96e5340 100644
--- a/nymea-app/ui/RootItem.qml
+++ b/nymea-app/ui/RootItem.qml
@@ -16,8 +16,8 @@ Item {
color: Material.background
}
- function handleCloseEvent(close) {
- swipeView.currentItem.handleCloseEvent(close)
+ function handleAndroidBackButton() {
+ return swipeView.currentItem.handleAndroidBackButton()
}
ListModel {
@@ -182,16 +182,15 @@ Item {
})
}
- function handleCloseEvent(close) {
- if (Qt.platform.os == "android") {
- // If we're connected, allow going back up to MainPage
- if ((engine.jsonRpcClient.connected && pageStack.depth > 1)
- // if we're not connected, only allow using the back button in wizards
- || (!engine.jsonRpcClient.connected && pageStack.depth > 3)) {
- close.accepted = false;
- pageStack.pop();
- }
+ function handleAndroidBackButton() {
+ // If we're connected, allow going back up to MainPage
+ if ((engine.jsonRpcClient.connected && pageStack.depth > 1)
+ // if we're not connected, only allow using the back button in wizards
+ || (!engine.jsonRpcClient.connected && pageStack.depth > 3)) {
+ pageStack.pop();
+ return true;
}
+ return false;
}
function setupPushNotifications(askForPermissions) {
diff --git a/packaging/android/AndroidManifest.xml b/packaging/android/AndroidManifest.xml
index 86f661d5..d182dde5 100644
--- a/packaging/android/AndroidManifest.xml
+++ b/packaging/android/AndroidManifest.xml
@@ -75,7 +75,7 @@
-
+