Port to Android
This commit is contained in:
parent
42ab8a676a
commit
26c57d45d7
@ -15,15 +15,31 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_D
|
||||
include(ECMSetupVersion)
|
||||
include(ECMGenerateHeaders)
|
||||
include(KDEInstallDirs)
|
||||
include(KDEClangFormat)
|
||||
include(KDECMakeSettings)
|
||||
include(ECMPoQmTools)
|
||||
include(KDECompilerSettings NO_POLICY_SCOPE)
|
||||
|
||||
find_package(Qt5 REQUIRED NO_MODULE COMPONENTS Core Quick Test Gui Svg QuickControls2 Sql)
|
||||
find_package(Qt5 REQUIRED NO_MODULE COMPONENTS Core Quick Test Gui QuickControls2 Sql)
|
||||
find_package(KF5 REQUIRED COMPONENTS CoreAddons Syndication Config I18n)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
if (ANDROID)
|
||||
find_package(Qt5 REQUIRED COMPONENTS Svg)
|
||||
find_package(KF5 REQUIRED COMPONENTS Kirigami2)
|
||||
else()
|
||||
find_package(Qt5 REQUIRED COMPONENTS Widgets)
|
||||
endif()
|
||||
|
||||
add_definitions(-DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_TO_ASCII -DQT_NO_URL_CAST_FROM_STRING)
|
||||
add_definitions(-DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT)
|
||||
add_definitions(-DQT_USE_QSTRINGBUILDER)
|
||||
add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x050d00)
|
||||
|
||||
install(PROGRAMS org.kde.mobile.alligator.desktop DESTINATION ${KDE_INSTALL_APPDIR})
|
||||
install(FILES org.kde.mobile.alligator.appdata.xml DESTINATION ${KDE_INSTALL_METAINFODIR})
|
||||
|
||||
add_subdirectory(src)
|
||||
|
||||
feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)
|
||||
|
||||
file(GLOB_RECURSE ALL_CLANG_FORMAT_SOURCE_FILES src/*.cpp src/*.h)
|
||||
kde_clang_format(${ALL_CLANG_FORMAT_SOURCE_FILES})
|
||||
|
56
android/AndroidManifest.xml
Normal file
56
android/AndroidManifest.xml
Normal file
@ -0,0 +1,56 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<!--
|
||||
- SPDX-License-Identifier: BSD-2-Clause
|
||||
- SPDX-FileCopyrightText: 2020 Nicolas Fella <nicolas.fella@gmx.de>
|
||||
- SPDX-FileCopyrightText: 2020 Volker Krause <vkrause@kde.org>
|
||||
-->
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="org.kde.alligator"
|
||||
android:versionName="0.0.1"
|
||||
android:versionCode="1587503687"
|
||||
android:installLocation="auto">
|
||||
<application android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="Alligator">
|
||||
<activity android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation"
|
||||
android:name="org.qtproject.qt5.android.bindings.QtActivity"
|
||||
android:label="Alligator"
|
||||
android:windowSoftInputMode="adjustResize"
|
||||
android:launchMode="singleTop">
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
</intent-filter>
|
||||
|
||||
<meta-data android:name="android.app.lib_name" android:value="alligator"/>
|
||||
<meta-data android:name="android.app.qt_sources_resource_id" android:resource="@array/qt_sources"/>
|
||||
<meta-data android:name="android.app.repository" android:value="default"/>
|
||||
<meta-data android:name="android.app.qt_libs_resource_id" android:resource="@array/qt_libs"/>
|
||||
<meta-data android:name="android.app.bundled_libs_resource_id" android:resource="@array/bundled_libs"/>
|
||||
<meta-data android:name="android.app.extract_android_style" android:value="minimal"/>
|
||||
|
||||
<!-- Deploy Qt libs as part of package -->
|
||||
<meta-data android:name="android.app.bundle_local_qt_libs" android:value="-- %%BUNDLE_LOCAL_QT_LIBS%% --"/>
|
||||
<meta-data android:name="android.app.load_local_libs_resource_id" android:resource="@array/load_local_libs"/>
|
||||
<!-- Run with local libs -->
|
||||
<meta-data android:name="android.app.use_local_qt_libs" android:value="-- %%USE_LOCAL_QT_LIBS%% --"/>
|
||||
<meta-data android:name="android.app.libs_prefix" android:value="/data/local/tmp/qt/"/>
|
||||
<meta-data android:name="android.app.load_local_libs" android:value="-- %%INSERT_LOCAL_LIBS%% --"/>
|
||||
<meta-data android:name="android.app.load_local_jars" android:value="-- %%INSERT_LOCAL_JARS%% --"/>
|
||||
<meta-data android:name="android.app.static_init_classes" android:value="-- %%INSERT_INIT_CLASSES%% --"/>
|
||||
<!-- Messages maps -->
|
||||
<meta-data android:value="@string/ministro_not_found_msg" android:name="android.app.ministro_not_found_msg"/>
|
||||
<meta-data android:value="@string/ministro_needed_msg" android:name="android.app.ministro_needed_msg"/>
|
||||
<meta-data android:value="@string/fatal_error_msg" android:name="android.app.fatal_error_msg"/>
|
||||
|
||||
<!-- Background running -->
|
||||
<meta-data android:name="android.app.background_running" android:value="false"/>
|
||||
|
||||
<!-- auto screen scale factor -->
|
||||
<meta-data android:name="android.app.auto_screen_scale_factor" android:value="true"/>
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="28"/>
|
||||
<supports-screens android:largeScreens="true" android:normalScreens="true" android:anyDensity="true" android:smallScreens="true"/>
|
||||
|
||||
</manifest>
|
@ -5,11 +5,28 @@ set(alligator_SRCS
|
||||
fetcher.cpp
|
||||
database.cpp
|
||||
resources.qrc
|
||||
)
|
||||
)
|
||||
|
||||
kconfig_add_kcfg_files(alligator_SRCS alligatorsettings.kcfgc GENERATE_MOC)
|
||||
|
||||
add_executable(alligator ${alligator_SRCS})
|
||||
target_link_libraries(alligator Qt5::Core Qt5::Qml Qt5::Quick Qt5::Svg Qt5::Sql KF5::Syndication KF5::CoreAddons KF5::ConfigGui KF5::I18n)
|
||||
target_link_libraries(alligator PRIVATE Qt5::Core Qt5::Qml Qt5::Quick Qt5::Sql KF5::Syndication KF5::CoreAddons KF5::ConfigGui KF5::I18n)
|
||||
|
||||
if(ANDROID)
|
||||
target_link_libraries(alligator PRIVATE
|
||||
KF5::Kirigami2
|
||||
Qt5::Svg
|
||||
)
|
||||
|
||||
kirigami_package_breeze_icons(ICONS
|
||||
bookmark-remove
|
||||
bookmark-new
|
||||
delete
|
||||
settings-configure
|
||||
help-about
|
||||
)
|
||||
else()
|
||||
target_link_libraries(alligator PRIVATE Qt5::Widgets)
|
||||
endif()
|
||||
|
||||
install(TARGETS alligator ${KF5_INSTALL_TARGETS_DEFAULT_ARGS})
|
||||
|
@ -35,7 +35,6 @@ Database::Database()
|
||||
QString databasePath = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
|
||||
QDir(databasePath).mkpath(databasePath);
|
||||
db.setDatabaseName(databasePath + QStringLiteral("/database.db3"));
|
||||
qDebug() << "Opening database " << databasePath + "/database.db3";
|
||||
db.open();
|
||||
|
||||
if(!migrate()) {
|
||||
@ -106,8 +105,8 @@ void Database::cleanup() {
|
||||
qint64 sinceEpoch = dateTime.toSecsSinceEpoch();
|
||||
|
||||
QSqlQuery query;
|
||||
query.prepare("DELETE FROM Entries WHERE updated < :sinceEpoch;");
|
||||
query.bindValue(":sinceEpoch", sinceEpoch);
|
||||
query.prepare(QStringLiteral("DELETE FROM Entries WHERE updated < :sinceEpoch;"));
|
||||
query.bindValue(QStringLiteral(":sinceEpoch"), sinceEpoch);
|
||||
execute(query);
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@
|
||||
EntryListModel::EntryListModel(QObject *parent)
|
||||
: QSqlTableModel(parent)
|
||||
{
|
||||
setTable("entries");
|
||||
setTable(QStringLiteral("entries"));
|
||||
setSort(Updated, Qt::DescendingOrder);
|
||||
setEditStrategy(OnFieldChange);
|
||||
select();
|
||||
@ -70,5 +70,5 @@ QString EntryListModel::feed() const
|
||||
|
||||
void EntryListModel::fetch()
|
||||
{
|
||||
Fetcher::instance().fetch(m_feed);
|
||||
Fetcher::instance().fetch(QUrl(m_feed));
|
||||
}
|
||||
|
@ -31,7 +31,7 @@
|
||||
FeedListModel::FeedListModel(QObject *parent)
|
||||
: QSqlTableModel(parent)
|
||||
{
|
||||
setTable("Feeds");
|
||||
setTable(QStringLiteral("Feeds"));
|
||||
setSort(0, Qt::AscendingOrder);
|
||||
setEditStrategy(OnFieldChange);
|
||||
select();
|
||||
@ -58,7 +58,7 @@ void FeedListModel::addFeed(QString url)
|
||||
QSqlRecord rec = record();
|
||||
rec.setValue(0, url);
|
||||
rec.setValue(1, url);
|
||||
rec.setValue(2, "");
|
||||
rec.setValue(2, QStringLiteral(""));
|
||||
|
||||
insertRecord(-1, rec);
|
||||
|
||||
|
18
src/main.cpp
18
src/main.cpp
@ -18,13 +18,19 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifdef Q_OS_ANDROID
|
||||
#include <QGuiApplication>
|
||||
#else
|
||||
#include <QApplication>
|
||||
#endif
|
||||
|
||||
#include <QQmlApplicationEngine>
|
||||
#include <QQuickView>
|
||||
#include <QQmlContext>
|
||||
|
||||
#include <KAboutData>
|
||||
#include <KLocalizedString>
|
||||
#include <KLocalizedContext>
|
||||
|
||||
#include "entryListModel.h"
|
||||
#include "feedListModel.h"
|
||||
@ -32,10 +38,17 @@
|
||||
#include "alligatorsettings.h"
|
||||
#include "feed.h"
|
||||
|
||||
Q_DECL_EXPORT int main(int argc, char *argv[])
|
||||
#ifdef Q_OS_ANDROID
|
||||
Q_DECL_EXPORT
|
||||
#endif
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||
#ifdef Q_OS_ANDROID
|
||||
QGuiApplication app(argc, argv);
|
||||
#else
|
||||
QApplication app(argc, argv);
|
||||
#endif
|
||||
|
||||
QCoreApplication::setOrganizationName(QStringLiteral("KDE"));
|
||||
QCoreApplication::setOrganizationDomain(QStringLiteral("kde.org"));
|
||||
QCoreApplication::setApplicationName(QStringLiteral("Alligator"));
|
||||
@ -45,6 +58,7 @@ Q_DECL_EXPORT int main(int argc, char *argv[])
|
||||
qmlRegisterType<EntryListModel>("org.kde.alligator", 1, 0, "EntryListModel");
|
||||
|
||||
QQmlApplicationEngine engine;
|
||||
engine.rootContext()->setContextObject(new KLocalizedContext(&engine));
|
||||
|
||||
KAboutData about(QStringLiteral("alligator"), i18n("Alligator"), QStringLiteral("0.1"), i18n("Feed Reader"),
|
||||
KAboutLicense::GPL, i18n("© 2020 KDE Community"));
|
||||
|
Loading…
x
Reference in New Issue
Block a user