Added basic structure demo app
21
QtAndroidToolsDemo/Main.cpp
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#include <QGuiApplication>
|
||||||
|
#include <QQmlApplicationEngine>
|
||||||
|
#include <QQuickStyle>
|
||||||
|
#include <QIcon>
|
||||||
|
#include "../QtAndroidTools/QtAndroidTools.h"
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||||
|
QQuickStyle::setStyle("Material");
|
||||||
|
QIcon::setThemeName("tools");
|
||||||
|
QGuiApplication app(argc, argv);
|
||||||
|
QQmlApplicationEngine engine;
|
||||||
|
|
||||||
|
QtAndroidTools::InitializeQmlTools();
|
||||||
|
|
||||||
|
engine.load(QUrl(QStringLiteral("qrc:/Main.qml")));
|
||||||
|
if(engine.rootObjects().isEmpty()) return -1;
|
||||||
|
|
||||||
|
return app.exec();
|
||||||
|
}
|
143
QtAndroidToolsDemo/Main.qml
Normal file
@ -0,0 +1,143 @@
|
|||||||
|
|
||||||
|
import QtQuick 2.11
|
||||||
|
import QtQuick.Layouts 1.12
|
||||||
|
import QtQuick.Controls 2.12
|
||||||
|
import QtQuick.Controls.Material 2.12
|
||||||
|
import QtQuick.Controls.Universal 2.12
|
||||||
|
|
||||||
|
ApplicationWindow {
|
||||||
|
id: window
|
||||||
|
visible: true
|
||||||
|
width: 360
|
||||||
|
height: 520
|
||||||
|
title: "QtAndroidTools Demo"
|
||||||
|
|
||||||
|
header: ToolBar {
|
||||||
|
Material.foreground: "white"
|
||||||
|
|
||||||
|
RowLayout {
|
||||||
|
spacing: 20
|
||||||
|
anchors.fill: parent
|
||||||
|
|
||||||
|
ToolButton {
|
||||||
|
icon.name: stackView.depth > 1 ? "back" : "drawer"
|
||||||
|
onClicked: {
|
||||||
|
if (stackView.depth > 1) {
|
||||||
|
stackView.pop()
|
||||||
|
listView.currentIndex = -1
|
||||||
|
} else {
|
||||||
|
drawer.open()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Label {
|
||||||
|
id: titleLabel
|
||||||
|
text: listView.currentItem ? listView.currentItem.text : "Android Tools"
|
||||||
|
font.pixelSize: 20
|
||||||
|
elide: Label.ElideRight
|
||||||
|
horizontalAlignment: Qt.AlignHCenter
|
||||||
|
verticalAlignment: Qt.AlignVCenter
|
||||||
|
Layout.fillWidth: true
|
||||||
|
}
|
||||||
|
|
||||||
|
ToolButton {
|
||||||
|
icon.name: "menu"
|
||||||
|
onClicked: optionsMenu.open()
|
||||||
|
|
||||||
|
Menu {
|
||||||
|
id: optionsMenu
|
||||||
|
x: parent.width - width
|
||||||
|
transformOrigin: Menu.TopRight
|
||||||
|
|
||||||
|
MenuItem {
|
||||||
|
text: "About"
|
||||||
|
onTriggered: aboutDialog.open()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Drawer {
|
||||||
|
id: drawer
|
||||||
|
width: Math.min(window.width, window.height) / 3 * 2
|
||||||
|
height: window.height
|
||||||
|
interactive: stackView.depth === 1
|
||||||
|
|
||||||
|
ListView {
|
||||||
|
id: listView
|
||||||
|
|
||||||
|
focus: true
|
||||||
|
currentIndex: -1
|
||||||
|
anchors.fill: parent
|
||||||
|
|
||||||
|
delegate: ItemDelegate {
|
||||||
|
width: parent.width
|
||||||
|
text: model.title
|
||||||
|
highlighted: ListView.isCurrentItem
|
||||||
|
onClicked: {
|
||||||
|
listView.currentIndex = index
|
||||||
|
stackView.push(model.source)
|
||||||
|
drawer.close()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
model: ListModel {
|
||||||
|
ListElement { title: "AppPermissions"; source: "qrc:/tools/AndroidAppPermissions.qml" }
|
||||||
|
ListElement { title: "ApkExpansionFiles"; source: "qrc:/tools/AndroidApkExpansionFiles.qml" }
|
||||||
|
}
|
||||||
|
|
||||||
|
ScrollIndicator.vertical: ScrollIndicator { }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
StackView {
|
||||||
|
id: stackView
|
||||||
|
anchors.fill: parent
|
||||||
|
|
||||||
|
initialItem: Pane {
|
||||||
|
id: pane
|
||||||
|
|
||||||
|
Image {
|
||||||
|
id: logo
|
||||||
|
width: pane.availableWidth / 2
|
||||||
|
height: pane.availableHeight / 2
|
||||||
|
anchors.centerIn: parent
|
||||||
|
anchors.verticalCenterOffset: -50
|
||||||
|
fillMode: Image.PreserveAspectFit
|
||||||
|
source: "images/logo_falsinsoft.jpg"
|
||||||
|
}
|
||||||
|
|
||||||
|
Label {
|
||||||
|
text: "Small collections of tools for manage some Android features from Qt and QML app"
|
||||||
|
anchors.margins: 20
|
||||||
|
anchors.top: logo.bottom
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.right: parent.right
|
||||||
|
horizontalAlignment: Label.AlignHCenter
|
||||||
|
verticalAlignment: Label.AlignVCenter
|
||||||
|
wrapMode: Label.Wrap
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Dialog {
|
||||||
|
id: aboutDialog
|
||||||
|
modal: true
|
||||||
|
focus: true
|
||||||
|
title: "About"
|
||||||
|
x: (window.width - width) / 2
|
||||||
|
y: window.height / 6
|
||||||
|
width: Math.min(window.width, window.height) / 3 * 2
|
||||||
|
contentHeight: aboutColumn.height
|
||||||
|
|
||||||
|
Label {
|
||||||
|
width: aboutDialog.availableWidth
|
||||||
|
text: "Copyright (c) 2018 Fabio Falsini\n\n"
|
||||||
|
+ "https://falsinsoft.blogspot.com"
|
||||||
|
wrapMode: Label.Wrap
|
||||||
|
font.pixelSize: 12
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
7
QtAndroidToolsDemo/QmlFiles.qrc
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<RCC>
|
||||||
|
<qresource prefix="/">
|
||||||
|
<file>Main.qml</file>
|
||||||
|
<file>tools/AndroidApkExpansionFiles.qml</file>
|
||||||
|
<file>tools/AndroidAppPermissions.qml</file>
|
||||||
|
</qresource>
|
||||||
|
</RCC>
|
26
QtAndroidToolsDemo/QtAndroidToolsDemo.pro
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
QT += quick quickcontrols2
|
||||||
|
CONFIG += c++11
|
||||||
|
|
||||||
|
TARGET = QtAndroidToolsDemo
|
||||||
|
TEMPLATE = app
|
||||||
|
|
||||||
|
SOURCES += \
|
||||||
|
Main.cpp
|
||||||
|
|
||||||
|
RESOURCES += \
|
||||||
|
QmlFiles.qrc \
|
||||||
|
qtquickcontrols2.conf \
|
||||||
|
icons/tools/index.theme \
|
||||||
|
$$files(icons/*.png, true) \
|
||||||
|
$$files(images/*.jpg)
|
||||||
|
|
||||||
|
DISTFILES += \
|
||||||
|
android/AndroidManifest.xml \
|
||||||
|
android/build.gradle
|
||||||
|
|
||||||
|
android
|
||||||
|
{
|
||||||
|
ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android
|
||||||
|
include(../QtAndroidTools/QtAndroidTools.pri)
|
||||||
|
}
|
||||||
|
|
90
QtAndroidToolsDemo/android/AndroidManifest.xml
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<manifest package="com.falsinsoft.QtAndroidToolsDemo" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="1.0" android:versionCode="1" android:installLocation="auto">
|
||||||
|
<application android:hardwareAccelerated="true" android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="-- %%INSERT_APP_NAME%% --">
|
||||||
|
<activity android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation|mcc|mnc|density" android:name="org.qtproject.qt5.android.bindings.QtActivity" android:label="-- %%INSERT_APP_NAME%% --" 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="-- %%INSERT_APP_LIB_NAME%% --"/>
|
||||||
|
<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="-- %%BUNDLE_LOCAL_QT_LIBS%% --"/>
|
||||||
|
<meta-data android:name="android.app.bundled_in_lib_resource_id" android:resource="@array/bundled_in_lib"/>
|
||||||
|
<meta-data android:name="android.app.bundled_in_assets_resource_id" android:resource="@array/bundled_in_assets"/>
|
||||||
|
<!-- 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%% --"/>
|
||||||
|
<!-- 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"/>
|
||||||
|
<!-- Messages maps -->
|
||||||
|
|
||||||
|
<!-- Splash screen -->
|
||||||
|
<!-- meta-data android:name="android.app.splash_screen_drawable" android:resource="@drawable/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 -->
|
||||||
|
|
||||||
|
<service android:name="com.falsinsoft.QtAndroidTools.ApkExpansionDownloaderService"/>
|
||||||
|
<receiver android:name="com.falsinsoft.QtAndroidTools.ApkExpansionDownloaderAlarmReceiver"/>
|
||||||
|
|
||||||
|
</application>
|
||||||
|
|
||||||
|
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="26"/>
|
||||||
|
<supports-screens android:largeScreens="true" android:normalScreens="true" android:anyDensity="true" android:smallScreens="true"/>
|
||||||
|
|
||||||
|
<!-- 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. -->
|
||||||
|
<!-- %%INSERT_PERMISSIONS -->
|
||||||
|
|
||||||
|
<!-- 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. -->
|
||||||
|
<!-- %%INSERT_FEATURES -->
|
||||||
|
|
||||||
|
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
|
||||||
|
<uses-permission android:name="com.android.vending.CHECK_LICENSE"/>
|
||||||
|
<uses-permission android:name="android.permission.WAKE_LOCK"/>
|
||||||
|
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
|
||||||
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
|
||||||
|
<uses-permission android:name="android.permission.INTERNET"/>
|
||||||
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||||
|
</manifest>
|
58
QtAndroidToolsDemo/android/build.gradle
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
google()
|
||||||
|
jcenter()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
classpath 'com.android.tools.build:gradle:3.2.0'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
google()
|
||||||
|
jcenter()
|
||||||
|
}
|
||||||
|
|
||||||
|
apply plugin: 'com.android.application'
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||||
|
implementation 'com.android.support:support-v4:24.+'
|
||||||
|
}
|
||||||
|
|
||||||
|
android {
|
||||||
|
/*******************************************************
|
||||||
|
* The following variables:
|
||||||
|
* - androidBuildToolsVersion,
|
||||||
|
* - androidCompileSdkVersion
|
||||||
|
* - qt5AndroidDir - holds the path to qt android files
|
||||||
|
* needed to build any Qt application
|
||||||
|
* on Android.
|
||||||
|
*
|
||||||
|
* are defined in gradle.properties file. This file is
|
||||||
|
* updated by QtCreator and androiddeployqt tools.
|
||||||
|
* Changing them manually might break the compilation!
|
||||||
|
*******************************************************/
|
||||||
|
|
||||||
|
compileSdkVersion androidCompileSdkVersion.toInteger()
|
||||||
|
|
||||||
|
buildToolsVersion androidBuildToolsVersion
|
||||||
|
|
||||||
|
sourceSets {
|
||||||
|
main {
|
||||||
|
manifest.srcFile 'AndroidManifest.xml'
|
||||||
|
java.srcDirs = [qt5AndroidDir + '/src', 'src', 'java']
|
||||||
|
aidl.srcDirs = [qt5AndroidDir + '/src', 'src', 'aidl']
|
||||||
|
res.srcDirs = [qt5AndroidDir + '/res', 'res']
|
||||||
|
resources.srcDirs = ['src']
|
||||||
|
renderscript.srcDirs = ['src']
|
||||||
|
assets.srcDirs = ['assets']
|
||||||
|
jniLibs.srcDirs = ['libs']
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
lintOptions {
|
||||||
|
abortOnError false
|
||||||
|
}
|
||||||
|
}
|
BIN
QtAndroidToolsDemo/icons/tools/20x20/back.png
Normal file
After Width: | Height: | Size: 220 B |
BIN
QtAndroidToolsDemo/icons/tools/20x20/drawer.png
Normal file
After Width: | Height: | Size: 123 B |
BIN
QtAndroidToolsDemo/icons/tools/20x20/menu.png
Normal file
After Width: | Height: | Size: 123 B |
BIN
QtAndroidToolsDemo/icons/tools/20x20@2/back.png
Normal file
After Width: | Height: | Size: 289 B |
BIN
QtAndroidToolsDemo/icons/tools/20x20@2/drawer.png
Normal file
After Width: | Height: | Size: 126 B |
BIN
QtAndroidToolsDemo/icons/tools/20x20@2/menu.png
Normal file
After Width: | Height: | Size: 158 B |
BIN
QtAndroidToolsDemo/icons/tools/20x20@3/back.png
Normal file
After Width: | Height: | Size: 351 B |
BIN
QtAndroidToolsDemo/icons/tools/20x20@3/drawer.png
Normal file
After Width: | Height: | Size: 130 B |
BIN
QtAndroidToolsDemo/icons/tools/20x20@3/menu.png
Normal file
After Width: | Height: | Size: 193 B |
BIN
QtAndroidToolsDemo/icons/tools/20x20@4/back.png
Normal file
After Width: | Height: | Size: 452 B |
BIN
QtAndroidToolsDemo/icons/tools/20x20@4/drawer.png
Normal file
After Width: | Height: | Size: 131 B |
BIN
QtAndroidToolsDemo/icons/tools/20x20@4/menu.png
Normal file
After Width: | Height: | Size: 223 B |
24
QtAndroidToolsDemo/icons/tools/index.theme
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
[Icon Theme]
|
||||||
|
Name=tools
|
||||||
|
Comment=tools icons
|
||||||
|
|
||||||
|
Directories=20x20,20x20@2,20x20@3,20x20@4
|
||||||
|
|
||||||
|
[20x20]
|
||||||
|
Size=20
|
||||||
|
Type=Fixed
|
||||||
|
|
||||||
|
[20x20@2]
|
||||||
|
Size=20
|
||||||
|
Scale=2
|
||||||
|
Type=Fixed
|
||||||
|
|
||||||
|
[20x20@3]
|
||||||
|
Size=20
|
||||||
|
Scale=3
|
||||||
|
Type=Fixed
|
||||||
|
|
||||||
|
[20x20@4]
|
||||||
|
Size=20
|
||||||
|
Scale=4
|
||||||
|
Type=Fixed
|
BIN
QtAndroidToolsDemo/images/logo_falsinsoft.jpg
Normal file
After Width: | Height: | Size: 18 KiB |
5
QtAndroidToolsDemo/qtquickcontrols2.conf
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
[Material]
|
||||||
|
Primary=#4169E1
|
||||||
|
Accent=#4169E1
|
||||||
|
Theme=System
|
||||||
|
|
9
QtAndroidToolsDemo/tools/AndroidApkExpansionFiles.qml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
|
||||||
|
import QtQuick 2.12
|
||||||
|
import QtQuick.Controls 2.12
|
||||||
|
|
||||||
|
Page {
|
||||||
|
id: page
|
||||||
|
|
||||||
|
|
||||||
|
}
|
9
QtAndroidToolsDemo/tools/AndroidAppPermissions.qml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
|
||||||
|
import QtQuick 2.12
|
||||||
|
import QtQuick.Controls 2.12
|
||||||
|
|
||||||
|
Page {
|
||||||
|
id: page
|
||||||
|
|
||||||
|
|
||||||
|
}
|