From a3be9379c24eddd7bc549b82c5641dcc57bc3dbd Mon Sep 17 00:00:00 2001 From: Kevin Whitaker <eyecreate@eyecreate.org> Date: Sun, 28 Jun 2020 21:25:44 -0400 Subject: [PATCH] add support for building app on android. --- CMakeLists.txt | 2 +- android-build.sh | 4 + packaging/android/AndroidManifest.xml | 98 +++++++++++++++++++ packaging/android/res/drawable/logo.xml | 14 +++ .../android/res/drawable/splash_logo.xml | 11 +++ packaging/android/res/values/apptheme.xml | 6 ++ src/CMakeLists.txt | 4 + 7 files changed, 138 insertions(+), 1 deletion(-) create mode 100644 android-build.sh create mode 100644 packaging/android/AndroidManifest.xml create mode 100644 packaging/android/res/drawable/logo.xml create mode 100644 packaging/android/res/drawable/splash_logo.xml create mode 100644 packaging/android/res/values/apptheme.xml diff --git a/CMakeLists.txt b/CMakeLists.txt index 86d0849..5067b8f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,7 @@ include(FeatureSummary) ################# set KDE specific information ################# -find_package(ECM 0.0.8 REQUIRED NO_MODULE) +find_package(ECM ${KF5_MIN_VERSION} REQUIRED NO_MODULE) # where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR}) diff --git a/android-build.sh b/android-build.sh new file mode 100644 index 0000000..cf1b4c8 --- /dev/null +++ b/android-build.sh @@ -0,0 +1,4 @@ +#!/bin/bash +ROOT_DIR=$(dirname $(realpath -s $0)) +mkdir -p $ROOT_DIR/builds +docker run --rm -it -v $ROOT_DIR:/home/user/src/qf kdeorg/android-sdk bash -c "git clone --depth 1 kde:sysadmin/ci-tooling;/opt/helpers/build-kde-project kcoreaddons Frameworks -DBUILD_TESTING=OFF; /opt/helpers/build-kde-project kirigami Frameworks -DBUILD_TESTING=OFF;/opt/helpers/build-cmake qf qf -DQTANDROID_EXPORTED_TARGET=qiflora -DANDROID_APK_DIR=/home/user/src/qf/packaging/android -DANDROID_APK_OUTPUT_DIR=/home/user/src/qf/builds;make -C /home/user/build-arm/qf create-apk;make -C /home/user/build-arm64/qf create-apk" diff --git a/packaging/android/AndroidManifest.xml b/packaging/android/AndroidManifest.xml new file mode 100644 index 0000000..14ed834 --- /dev/null +++ b/packaging/android/AndroidManifest.xml @@ -0,0 +1,98 @@ +<?xml version='1.0' encoding='utf-8'?> +<manifest package="org.eyecreate.qiflora" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="1.0" android:versionCode="1" android:installLocation="auto"> + <uses-sdk android:minSdkVersion="21" android:targetSdkVersion="28"/> + + <!-- The following comment will be replaced upon deployment with default permissions based on the dependencies of the application. + Remove the comment if you do not require these default permissions. --> + <uses-permission android:name="android.permission.INTERNET" /> + <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> + <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> + <uses-permission android:name="android.permission.BLUETOOTH" /> + <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" /> + <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> + + <!-- The following comment will be replaced upon deployment with default features based on the dependencies of the application. + Remove the comment if you do not require these default features. --> + + + <supports-screens android:largeScreens="true" android:normalScreens="true" android:anyDensity="true" android:smallScreens="true"/> + + <application android:hardwareAccelerated="true" android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="QiFlora" android:icon="@drawable/logo"> + <activity android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation|mcc|mnc" + android:name="org.qtproject.qt5.android.bindings.QtActivity" + android:label="QiFlora" + android:icon="@drawable/logo" + android:theme="@style/AppTheme" + android:screenOrientation="unspecified" + android:launchMode="singleTop"> + <intent-filter> + <action android:name="android.intent.action.MAIN"/> + <category android:name="android.intent.category.LAUNCHER"/> + </intent-filter> + + <!-- Application arguments --> + <!-- meta-data android:name="android.app.arguments" android:value="arg1 arg2 arg3"/ --> + <!-- Application arguments --> + + <meta-data android:name="android.app.lib_name" android:value="qiflora"/> + <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"/> + <!-- Deploy Qt libs as part of package --> + <meta-data android:name="android.app.bundle_local_qt_libs" android:value="1"/> + + <!-- Run with local libs --> + <meta-data android:name="android.app.use_local_qt_libs" android:value="1"/> + <meta-data android:name="android.app.libs_prefix" android:value="/data/local/tmp/qt/"/> + <meta-data android:name="android.app.load_local_libs_resource_id" android:resource="@array/load_local_libs"/> + <meta-data android:name="android.app.load_local_jars" android:value="jar/QtAndroid.jar:jar/QtAndroidBearer.jar:jar/QtAndroidBluetooth.jar"/> + <meta-data android:name="android.app.static_init_classes" android:value="org.qtproject.qt5.android.bluetooth.QtBluetoothBroadcastReceiver"/> + <!-- Used to specify custom system library path to run with local system libs --> + <!-- <meta-data android:name="android.app.system_libs_prefix" android:value="/system/lib/"/> --> + <!-- 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"/> + <meta-data android:value="@string/unsupported_android_version" android:name="android.app.unsupported_android_version"/> + <!-- Messages maps --> + + <!-- Splash screen --> + <!-- Orientation-specific (portrait/landscape) data is checked first. If not available for current orientation, + then android.app.splash_screen_drawable. For best results, use together with splash_screen_sticky and + use hideSplashScreen() with a fade-out animation from Qt Android Extras to hide the splash screen when you + are done populating your window with content. --> + <!-- meta-data android:name="android.app.splash_screen_drawable_portrait" android:resource="@drawable/logo_portrait" / --> + <!-- meta-data android:name="android.app.splash_screen_drawable_landscape" android:resource="@drawable/logo_landscape" / --> + <meta-data android:name="android.app.splash_screen_drawable" android:resource="@drawable/splash_logo"/> + <!-- meta-data android:name="android.app.splash_screen_sticky" android:value="true"/ --> + <!-- Splash screen --> + + <!-- Background running --> + <!-- Warning: changing this value to true may cause unexpected crashes if the + application still try to draw after + "applicationStateChanged(Qt::ApplicationSuspended)" + signal is sent! --> + <meta-data android:name="android.app.background_running" android:value="false"/> + <!-- Background running --> + + <!-- auto screen scale factor --> + <meta-data android:name="android.app.auto_screen_scale_factor" android:value="false"/> + <!-- auto screen scale factor --> + + <!-- extract android style --> + <!-- available android:values : + * default - In most cases this will be the same as "full", but it can also be something else if needed, e.g., for compatibility reasons + * full - useful QWidget & Quick Controls 1 apps + * minimal - useful for Quick Controls 2 apps, it is much faster than "full" + * none - useful for apps that don't use any of the above Qt modules + --> + <meta-data android:name="android.app.extract_android_style" android:value="default"/> + <!-- extract android style --> + </activity> + + <!-- For adding service(s) please check: https://wiki.qt.io/AndroidServices --> + + </application> + +</manifest> diff --git a/packaging/android/res/drawable/logo.xml b/packaging/android/res/drawable/logo.xml new file mode 100644 index 0000000..bbba605 --- /dev/null +++ b/packaging/android/res/drawable/logo.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="utf-8"?> +<vector xmlns:android="http://schemas.android.com/apk/res/android" + android:width="400.174dp" + android:height="400.174dp" + android:viewportWidth="400.174" + android:viewportHeight="400.174"> + + <path + android:fillColor="#45B549" + android:pathData="M201.38,88.422c113.12-12.44,149.88-84,150-84c1.856-3.567,6.252-4.953,9.819-3.097 c1.799,0.936,3.126,2.581,3.661,4.537c37.6,127.52,17.08,215.44-26.08,267.6c-16.709,20.331-38.11,36.296-62.36,46.52 c-22.339,9.474-46.587,13.584-70.8,12c-46.36-3.24-88.68-28-108.32-72.36c-5.032-11.34-8.284-23.388-9.64-35.72 c-2.743-24.717,2.083-49.685,13.84-71.6c12.622-23.385,32.719-41.863,57.08-52.48C172.173,93.833,186.611,89.988,201.38,88.422 L201.38,88.422z" /> + <path + android:fillColor="#009549" + android:pathData="M350.58,7.102c0.099-4.019,3.437-7.198,7.456-7.099c4.019,0.099,7.198,3.437,7.099,7.456 c-0.007,0.296-0.033,0.59-0.076,0.883c0,0.36-6.36,84-88,168.64l-0.76,0.8c-19.18,19.673-40.226,37.436-62.84,53.04l49.04,9.12 c3.909,0.943,6.313,4.876,5.37,8.784c-0.854,3.538-4.189,5.902-7.81,5.536l-64-12c-58.36,36.96-157.28,71.08-165.92,151.6 c-0.535,3.985-4.199,6.782-8.184,6.247c-3.793-0.509-6.544-3.868-6.296-7.687c10.32-96.52,108.4-121.36,174.56-163.56l0.92-0.6 c26.403-16.71,50.861-36.311,72.92-58.44l-5.8-57.4c-0.535-3.985,2.262-7.649,6.247-8.184s7.649,2.262,8.184,6.247 c0.022,0.165,0.039,0.331,0.049,0.497l4.4,44.56C345.18,79.142,350.54,7.422,350.58,7.102L350.58,7.102z" /> +</vector> \ No newline at end of file diff --git a/packaging/android/res/drawable/splash_logo.xml b/packaging/android/res/drawable/splash_logo.xml new file mode 100644 index 0000000..9e77064 --- /dev/null +++ b/packaging/android/res/drawable/splash_logo.xml @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="utf-8"?> +<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> + <item> + <shape android:shape="rectangle" > + <solid android:color="#FF1fca05"/> + </shape> + </item> + <item android:width="256dp" android:height="256dp" android:gravity="center" android:drawable=" + @drawable/logo"> + </item> +</layer-list> diff --git a/packaging/android/res/values/apptheme.xml b/packaging/android/res/values/apptheme.xml new file mode 100644 index 0000000..1a0b7bb --- /dev/null +++ b/packaging/android/res/values/apptheme.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <style name="AppTheme" parent="@android:style/Theme.DeviceDefault.Light.NoActionBar"> + <item name="android:windowBackground">@drawable/splash_logo</item> + </style> +</resources> diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 62d1271..fabc210 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -6,6 +6,10 @@ set(qiflora_SRCS main.cpp ) +if (CMAKE_SYSTEM_NAME STREQUAL "Android") + kirigami_package_breeze_icons(ICONS view-refresh help-about filename-bpm-amarok colors-chromablue quickopen contrast window-close mail-sent globe) +endif() + qt5_add_resources(RESOURCES resources.qrc) add_executable(qiflora ${qiflora_SRCS} ${RESOURCES}) target_link_libraries(qiflora Qt5::Core Qt5::Qml Qt5::Quick Qt5::Svg Qt5::Bluetooth Qt5::Charts KF5::CoreAddons) -- GitLab