Commit 294e0948 authored by Matthieu Bruel's avatar Matthieu Bruel
Browse files

Fix v0.4.6 for Androids:

- ignore fix for Issue #306
- correct Database::defaultDatabasePath() for mobile devices...
- remove constexpr that seems to be problematic on arvm libs?
- don't write settings in Qrop destructor as it could not be executed on Android..
parent f01c0b2c
......@@ -103,6 +103,10 @@ if (ANDROID)
AndroidExtras
REQUIRED
)
# TO BE UPDATED FOR AUTO BUILD OR OTHER ENV... (openssl needed for QropNews)
message(STATUS "Adding openssl libs from local mb env...")
include(/home/bruel/android/android_openssl/CMakeLists.txt)
endif()
include_directories(lib)
......
......@@ -41,7 +41,7 @@
QString Database::defaultDatabasePath()
{
#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS)
return FileSystem::rootPath();
return QString("%1/qrop.sqlite").arg(FileSystem::rootPath());
#else
const QDir writeDir = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
if (!writeDir.mkpath("."))
......
......@@ -35,10 +35,8 @@ Qrop::Qrop(QObject *parent)
Qrop::~Qrop()
{
Database::close();
if (m_news->areRead())
m_settings.setValue("lastNewsUpdate", m_news->lastUpdate().toString(Qt::ISODate));
m_settings.sync();
Database::close();
qDebug() << "Qrop properly deleted!";
}
......@@ -86,6 +84,11 @@ bool Qrop::saveDatabase(const QUrl &from, const QUrl &to)
return false;
}
void Qrop::markNewsAsRead()
{
m_settings.setValue("lastNewsUpdate", m_news->lastUpdate().toString(Qt::ISODate));
}
bool Qrop::newReleaseAvailable(const QString &lastOnlineVersion)
{
QRegularExpression versionRegExp("^(\\d+)\\.(\\d+)\\.(\\d+)$");
......
......@@ -52,6 +52,8 @@ public:
inline Q_INVOKABLE bool isMobileDevice() { return m_buildInfo->isMobileDevice(); }
inline Q_INVOKABLE QropNews *news() const { return m_news; }
Q_INVOKABLE void markNewsAsRead();
inline QNetworkAccessManager &networkManager() { return m_networkManager; }
inline Q_INVOKABLE BuildInfo *buildInfo() const { return m_buildInfo; }
......
......@@ -26,13 +26,19 @@
#include <QJsonArray>
#include <QJsonObject>
const char *QropNews::s_newsJsonBaseLink =
"https://framagit.org/ah/qrop/-/raw/master/news/qrop_news"; //!< we add "_<lang>.json"
const char *QropNews::s_newsJsonContentType = "text/plain";
const char *QropNews::s_qropDownloadURL = "https://qrop.frama.io/fr/download/";
const char *QropNews::s_defaultLanguage = "en";
QropNews::QropNews(QObject *parent)
: QObject(parent)
, m_lang()
, m_mainText()
, m_lastRelease()
, m_numberOfUnreadNews(0)
, m_markAsRead(false)
, m_defaultLangTried(false)
{
}
......
......@@ -32,12 +32,11 @@ class CORESHARED_EXPORT QropNews : public QObject
Q_PROPERTY(QString mainText READ mainText CONSTANT FINAL)
Q_PROPERTY(QString toHtml READ toHtml CONSTANT FINAL)
static constexpr const char *s_newsJsonBaseLink =
"https://framagit.org/ah/qrop/-/raw/master/news/qrop_news"; //!< we add "_<lang>.json"
static constexpr const char *s_newsJsonContentType = "text/plain";
static constexpr const char *s_qropDownloadURL = "https://qrop.frama.io/fr/download/";
static const char *s_newsJsonBaseLink;
static const char *s_newsJsonContentType;
static const char *s_qropDownloadURL;
static constexpr const char *s_defaultLanguage = "en";
static const char *s_defaultLanguage;
typedef struct News {
const QDate date;
......@@ -69,9 +68,6 @@ public:
Q_INVOKABLE void fetchNews();
inline Q_INVOKABLE int numberOfUnreadNews() const { return m_numberOfUnreadNews; }
inline Q_INVOKABLE void markAsRead(bool read) { m_markAsRead = read; }
inline bool areRead() const { return m_markAsRead; }
signals:
void newsReceived();
......@@ -89,7 +85,6 @@ private:
QString m_lastRelease;
QVector<News *> m_news;
ushort m_numberOfUnreadNews;
bool m_markAsRead;
bool m_defaultLangTried;
};
......
......@@ -53,8 +53,10 @@ Popup {
}
onClosed: {
if (markNewsAsRead.checked)
if (markNewsAsRead.checked) {
window.displayNewsBadges("");
cppQrop.markNewsAsRead();
}
}
SwipeView {
......@@ -174,7 +176,6 @@ Popup {
id: markNewsAsRead
text: qsTr("Mark news as read")
anchors.horizontalCenter: parent.horizontalCenter
onToggled: cppQrop.news().markAsRead(checked);
}
}
}
......
......@@ -63,12 +63,16 @@ ApplicationWindow {
Component.onCompleted: {
if (firstDatabaseFile === "")
firstDatabaseFile = cppRemote.defaultDatabaseUrl();
firstDatabaseFile = cppQrop.defaultDatabaseUrl();
if (currentDatabase === 0)
currentDatabase = 1;
if (lastFolder === "")
lastFolder = '%1%2'.arg(cppQrop.isMobileDevice() ? "" : "file://").arg(FileSystem.rootPath);
//print("QML: currentDatabase: "+currentDatabase+", firstDatabaseFile: "+firstDatabaseFile+", secondDatabaseFile: "+secondDatabaseFile);
if (cppQrop.isMobileDevice())
return; // only full screen on Android devices
if (mainSettings.windowFullScreen)
window.visibility = Window.FullScreen;
else {
......@@ -86,7 +90,7 @@ ApplicationWindow {
}
Component.onDestruction: {
if (!mainSettings.windowFullScreen) {
if (!cppQrop.isMobileDevice() && !mainSettings.windowFullScreen) {
mainSettings.windowX = window.x;
mainSettings.windowY = window.y;
mainSettings.windowHeight = window.height;
......@@ -114,6 +118,9 @@ ApplicationWindow {
}
function toggleFullScreen() {
if (cppQrop.isMobileDevice())
return; // only full screen on Android devices
if (window.visibility === Window.FullScreen) {
window.visibility = Window.Windowed;
mainSettings.windowFullScreen = false;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment