mobile UI: ensure download page is shown if started by plug-in event

The order of execution of the various routines is a bit counter intuitive.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2020-03-09 10:51:34 -07:00
parent 174bb91326
commit 8138279a04

View file

@ -710,14 +710,18 @@ if you have network connectivity and want to sync your data to cloud storage."),
if (visible) { if (visible) {
pageStack.clear() pageStack.clear()
diveList.visible = false diveList.visible = false
} else {
pageStack.push(diveList)
} }
} }
Component.onCompleted: { Component.onCompleted: {
if (!visible) { if (!visible) {
showDiveList() manager.appendTextToLog("StartPage completed - showing the dive list")
showPage(diveList) // we want to make sure that gets on the stack
manager.appendTextToLog("if we got started by a plugged in device, switch to download page -- pluggedInDeviceName = " + pluggedInDeviceName)
if (pluggedInDeviceName !== "")
// if we were started with a dive computer plugged in,
// immediately switch to download page
showDownloadForPluggedInDevice()
} }
} }
} }
@ -818,6 +822,9 @@ if you have network connectivity and want to sync your data to cloud storage."),
} }
function showDownloadForPluggedInDevice() { function showDownloadForPluggedInDevice() {
// don't add this unless the dive list is already shown
if (pageIndex(diveList) === -1)
return
manager.appendTextToLog("plugged in device name changed to " + pluggedInDeviceName) manager.appendTextToLog("plugged in device name changed to " + pluggedInDeviceName)
/* if we recognized the device, we'll pass in a triple of ComboBox indeces as "vendor;product;connection" */ /* if we recognized the device, we'll pass in a triple of ComboBox indeces as "vendor;product;connection" */
var vendorProductConnection = pluggedInDeviceName.split(';') var vendorProductConnection = pluggedInDeviceName.split(';')
@ -825,7 +832,6 @@ if you have network connectivity and want to sync your data to cloud storage."),
showDownloadPage(vendorProductConnection[0], vendorProductConnection[1], vendorProductConnection[2]) showDownloadPage(vendorProductConnection[0], vendorProductConnection[1], vendorProductConnection[2])
else else
showDownloadPage() showDownloadPage()
manager.appendTextToLog("done showing download page")
} }
onPluggedInDeviceNameChanged: { onPluggedInDeviceNameChanged: {
@ -834,6 +840,9 @@ if you have network connectivity and want to sync your data to cloud storage."),
manager.appendTextToLog("Download page requested by Android Intent, but adding/editing dive; no action taken") manager.appendTextToLog("Download page requested by Android Intent, but adding/editing dive; no action taken")
} else { } else {
// we want to show the downloads page // we want to show the downloads page
// note that if Subsurface-mobile was started because a USB device was plugged in, this is run too early;
// we catch this in the function below and instead switch to the download page in the completion signal
// handler for the startPage
showDownloadForPluggedInDevice() showDownloadForPluggedInDevice()
} }
} }