From 43ed2e122487aba5303cd575c23227fdb27a940f Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Sat, 26 Feb 2022 18:17:07 +0000 Subject: [PATCH] Android: use a sharable location for our files The first location we should try is one that allows us to share files. In theory this should work on every device, but we do have a few fall-backs, just in case. This also moves the Android specific include to the top which seems much more standard. Signed-off-by: Dirk Hohndel --- core/android.cpp | 3 ++- mobile-widgets/qmlmanager.cpp | 9 +++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/core/android.cpp b/core/android.cpp index 34d4ac46e..478bb8d86 100644 --- a/core/android.cpp +++ b/core/android.cpp @@ -48,7 +48,8 @@ bool subsurface_ignore_font(const char *font) static const char *system_default_path_append(const char *append) { // Qt appears to find a working path for us - let's just go with that - QString path = QStandardPaths::standardLocations(QStandardPaths::DataLocation).first(); + // AppDataLocation allows potential sharing of the files we put there + QString path = QStandardPaths::standardLocations(QStandardPaths::AppDataLocation).first(); if (append) path += QString("/%1").arg(append); diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp index c85aa0965..bff3ebc70 100644 --- a/mobile-widgets/qmlmanager.cpp +++ b/mobile-widgets/qmlmanager.cpp @@ -55,6 +55,7 @@ #include "commands/command.h" #if defined(Q_OS_ANDROID) +#include #include "core/serial_usb_android.h" std::vector androidSerialDevices; @@ -230,9 +231,11 @@ QMLManager::QMLManager() : #if defined(Q_OS_ANDROID) || defined(Q_OS_IOS) #if defined(Q_OS_ANDROID) - // on Android we first try the GenericDataLocation (typically /storage/emulated/0) and if that fails - // (as happened e.g. on a Sony Xperia phone) we try several other default locations, with the TempLocation as last resort + // on Android we first try the AppDataLocation (which allows sharing of files), then the + // GenericDataLocation (typically /storage/emulated/0), and if that fails (as happened e.g. on a + // Sony Xperia phone) we try several other default locations, with the TempLocation as last resort QStringList fileLocations = + QStandardPaths::standardLocations(QStandardPaths::AppDataLocation) + QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation) + QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation) + QStandardPaths::standardLocations(QStandardPaths::DownloadLocation) + @@ -1826,8 +1829,6 @@ void QMLManager::writeToAppLogFile(QString logText) //HACK to color the system bar on Android, use qtandroidextras and call the appropriate Java methods //this code is based on code in the Kirigami example app for Android (under LGPL-2) Copyright 2017 Marco Martin -#include - // there doesn't appear to be an include that defines these in an easily accessible way // WindowManager.LayoutParams #define FLAG_TRANSLUCENT_STATUS 0x04000000