diff --git a/CHANGELOG.md b/CHANGELOG.md index 6408bc455..081206075 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ - core: avoid crash with corrupted cloud storage +- mobile/Android: add logfiles as attachment to support emails - planner: make ESC (cancel plan) work when moving handles - dive list: make dive guide visible in dive list [#3382] - general: rename dive master to dive guide diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp index bff3ebc70..18052b2b9 100644 --- a/mobile-widgets/qmlmanager.cpp +++ b/mobile-widgets/qmlmanager.cpp @@ -263,7 +263,8 @@ QMLManager::QMLManager() : appendTextToLog("Successfully opened logfile " + appLogFileName + " at " + QDateTime::currentDateTime().toString()); // if we were able to write the overall logfile, also write the libdivecomputer logfile - QString libdcLogFileName = appLogFileName.replace("/subsurface.log", "/libdivecomputer.log"); + QString libdcLogFileName = appLogFileName; + libdcLogFileName = libdcLogFileName.replace("/subsurface.log", "/libdivecomputer.log"); // remove the existing libdivecomputer logfile so we don't copy an old one by mistake QFile libdcLog(libdcLogFileName); libdcLog.remove(); @@ -491,8 +492,25 @@ void QMLManager::copyAppLogToClipboard() bool QMLManager::createSupportEmail() { + QString messageBody = "Please describe your issue here and keep the logs below:\n\n\n\n"; +#if defined(Q_OS_ANDROID) + // let's use our nifty Java shareFile function + QAndroidJniObject activity = QtAndroid::androidActivity(); + if (activity.isValid()) { + QAndroidJniObject applogfilepath = QAndroidJniObject::fromString(appLogFileName); + QAndroidJniObject libdcfilepath = QAndroidJniObject::fromString(logfile_name); + bool success = activity.callMethod("shareFiles", + "(Ljava/lang/String;Ljava/lang/String;)Z", // two string arguments, return bool + applogfilepath.object(), libdcfilepath.object()); + qDebug() << __FUNCTION__ << "shareFiles" << (success ? "succeeded" : "failed"); + if (success) + return true; + } + qDebug() << __FUNCTION__ << "failed to share the logFiles via intent, use the fall-back mail body method"; +#endif QString mailToLink = "mailto:in-app-support@subsurface-divelog.org?subject=Subsurface-mobile support request"; - mailToLink += "&body=Please describe your issue here and keep the logs below:\n\n\n\n"; + mailToLink += "&body="; + mailToLink += messageBody; mailToLink += getCombinedLogs(); if (QDesktopServices::openUrl(QUrl(mailToLink))) { appendTextToLog("OS accepted support email");