From 226244617018e138c8c57699c1ebbfc1150e68f0 Mon Sep 17 00:00:00 2001 From: DonLakeFlyer Date: Sat, 30 May 2020 14:14:56 -0700 Subject: [PATCH] Tweaks to iOS storage location to support display in Files app --- ChangeLog.md | 6 +++++- ios/iOS-Info.plist | 3 ++- src/Settings/AppSettings.cc | 22 ++++++++++++-------- src/api/QGCCorePlugin.cc | 41 +++++++++++++++---------------------- 4 files changed, 36 insertions(+), 36 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 004837b79..2b4787fc5 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -13,7 +13,11 @@ Note: This file only contains high level features or important fixes. ## 4.0 -## 4.0.7 - Not yet released +## 4.0.8 - Not yet released + +* iOS: Modify QGC file storage location to support new Files app + +## 4.0.7 - Stable * Fix video page sizing * Virtual Joystick: Fix right stick centering. Fix/add support for rover/sub reverse throttle support. diff --git a/ios/iOS-Info.plist b/ios/iOS-Info.plist index 042cab652..6b7513cea 100644 --- a/ios/iOS-Info.plist +++ b/ios/iOS-Info.plist @@ -86,5 +86,6 @@ UIFileSharingEnabled - + LSSupportsOpeningDocumentsInPlace + diff --git a/src/Settings/AppSettings.cc b/src/Settings/AppSettings.cc index 5d090049c..7a6ffbd73 100644 --- a/src/Settings/AppSettings.cc +++ b/src/Settings/AppSettings.cc @@ -53,23 +53,27 @@ DECLARE_SETTINGGROUP(App, "") SettingsFact* savePathFact = qobject_cast(savePath()); QString appName = qgcApp()->applicationName(); #ifdef __mobile__ - // Mobile builds always use the runtime generated location for savePath. The reason is that for example on iOS the save path includes - // a UID for the app in it. When you then update the app that UID could change which in turn makes any saved value invalid. - if (true) { + // Mobile builds always use the runtime generated location for savePath. + bool userHasModifiedSavePath = false; #else - if (savePathFact->rawValue().toString().isEmpty() && _nameToMetaDataMap[savePathName]->rawDefaultValue().toString().isEmpty()) { + bool userHasModifiedSavePath = !savePathFact->rawValue().toString().isEmpty() || !_nameToMetaDataMap[savePathName]->rawDefaultValue().toString().isEmpty(); #endif + + if (!userHasModifiedSavePath) { #ifdef __mobile__ -#ifdef __ios__ - QDir rootDir = QDir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)); -#else + #ifdef __ios__ + // This will expose the directories directly to the File iOs app + QDir rootDir = QDir(QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation)); + savePathFact->setRawValue(rootDir.absolutePath()); + #else QDir rootDir = QDir(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation)); -#endif + savePathFact->setRawValue(rootDir.filePath(appName)); + #endif savePathFact->setVisible(false); #else QDir rootDir = QDir(QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation)); -#endif savePathFact->setRawValue(rootDir.filePath(appName)); +#endif } connect(savePathFact, &Fact::rawValueChanged, this, &AppSettings::savePathsChanged); diff --git a/src/api/QGCCorePlugin.cc b/src/api/QGCCorePlugin.cc index 43857410a..7ae9ea4dc 100644 --- a/src/api/QGCCorePlugin.cc +++ b/src/api/QGCCorePlugin.cc @@ -339,8 +339,7 @@ bool QGCCorePlugin::overrideSettingsGroupVisibility(QString name) bool QGCCorePlugin::adjustSettingMetaData(const QString& settingsGroup, FactMetaData& metaData) { - if (settingsGroup != AppSettings::settingsGroup) { - // All changes refer to AppSettings + if (settingsGroup == AppSettings::settingsGroup) { #if !defined(QGC_ENABLE_PAIRING) //-- If we don't support pairing, disable it. if (metaData.name() == AppSettings::usePairingName) { @@ -349,36 +348,28 @@ bool QGCCorePlugin::adjustSettingMetaData(const QString& settingsGroup, FactMeta return false; } #endif - return true; - } - //-- Default Palette - if (metaData.name() == AppSettings::indoorPaletteName) { - QVariant outdoorPalette; + //-- Default Palette + if (metaData.name() == AppSettings::indoorPaletteName) { + QVariant outdoorPalette; #if defined (__mobile__) - outdoorPalette = 0; + outdoorPalette = 0; #else - outdoorPalette = 1; + outdoorPalette = 1; #endif - metaData.setRawDefaultValue(outdoorPalette); - return true; - //-- Auto Save Telemetry Logs - } else if (metaData.name() == AppSettings::telemetrySaveName) { + metaData.setRawDefaultValue(outdoorPalette); + return true; + } + #if defined (__mobile__) - metaData.setRawDefaultValue(false); - return true; -#else - metaData.setRawDefaultValue(true); - return true; -#endif -#if defined(__ios__) - } else if (metaData.name() == AppSettings::savePathName) { - QString appName = qgcApp()->applicationName(); - QDir rootDir = QDir(QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation)); - metaData.setRawDefaultValue(rootDir.filePath(appName)); - return false; + if (metaData.name() == AppSettings::telemetrySaveName) { + // Mobile devices have limited storage so don't turn on telemtry saving by default + metaData.setRawDefaultValue(false); + return true; + } #endif } + return true; // Show setting in ui } -- 2.22.0