diff --git a/QtAndroidToolsDemo/Main.cpp b/QtAndroidToolsDemo/Main.cpp new file mode 100644 index 0000000..139df9d --- /dev/null +++ b/QtAndroidToolsDemo/Main.cpp @@ -0,0 +1,21 @@ +#include +#include +#include +#include +#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(); +} diff --git a/QtAndroidToolsDemo/Main.qml b/QtAndroidToolsDemo/Main.qml new file mode 100644 index 0000000..be72e1a --- /dev/null +++ b/QtAndroidToolsDemo/Main.qml @@ -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 + } + } +} diff --git a/QtAndroidToolsDemo/QmlFiles.qrc b/QtAndroidToolsDemo/QmlFiles.qrc new file mode 100644 index 0000000..82013de --- /dev/null +++ b/QtAndroidToolsDemo/QmlFiles.qrc @@ -0,0 +1,7 @@ + + + Main.qml + tools/AndroidApkExpansionFiles.qml + tools/AndroidAppPermissions.qml + + diff --git a/QtAndroidToolsDemo/QtAndroidToolsDemo.pro b/QtAndroidToolsDemo/QtAndroidToolsDemo.pro new file mode 100644 index 0000000..7e4522e --- /dev/null +++ b/QtAndroidToolsDemo/QtAndroidToolsDemo.pro @@ -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) +} + diff --git a/QtAndroidToolsDemo/android/AndroidManifest.xml b/QtAndroidToolsDemo/android/AndroidManifest.xml new file mode 100644 index 0000000..7cd2158 --- /dev/null +++ b/QtAndroidToolsDemo/android/AndroidManifest.xml @@ -0,0 +1,90 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/QtAndroidToolsDemo/android/build.gradle b/QtAndroidToolsDemo/android/build.gradle new file mode 100644 index 0000000..d29c709 --- /dev/null +++ b/QtAndroidToolsDemo/android/build.gradle @@ -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 + } +} diff --git a/QtAndroidToolsDemo/icons/tools/20x20/back.png b/QtAndroidToolsDemo/icons/tools/20x20/back.png new file mode 100644 index 0000000..db43e27 Binary files /dev/null and b/QtAndroidToolsDemo/icons/tools/20x20/back.png differ diff --git a/QtAndroidToolsDemo/icons/tools/20x20/drawer.png b/QtAndroidToolsDemo/icons/tools/20x20/drawer.png new file mode 100644 index 0000000..1e974ef Binary files /dev/null and b/QtAndroidToolsDemo/icons/tools/20x20/drawer.png differ diff --git a/QtAndroidToolsDemo/icons/tools/20x20/menu.png b/QtAndroidToolsDemo/icons/tools/20x20/menu.png new file mode 100644 index 0000000..a10473d Binary files /dev/null and b/QtAndroidToolsDemo/icons/tools/20x20/menu.png differ diff --git a/QtAndroidToolsDemo/icons/tools/20x20@2/back.png b/QtAndroidToolsDemo/icons/tools/20x20@2/back.png new file mode 100644 index 0000000..c55ab31 Binary files /dev/null and b/QtAndroidToolsDemo/icons/tools/20x20@2/back.png differ diff --git a/QtAndroidToolsDemo/icons/tools/20x20@2/drawer.png b/QtAndroidToolsDemo/icons/tools/20x20@2/drawer.png new file mode 100644 index 0000000..eba3b6c Binary files /dev/null and b/QtAndroidToolsDemo/icons/tools/20x20@2/drawer.png differ diff --git a/QtAndroidToolsDemo/icons/tools/20x20@2/menu.png b/QtAndroidToolsDemo/icons/tools/20x20@2/menu.png new file mode 100644 index 0000000..649c2a0 Binary files /dev/null and b/QtAndroidToolsDemo/icons/tools/20x20@2/menu.png differ diff --git a/QtAndroidToolsDemo/icons/tools/20x20@3/back.png b/QtAndroidToolsDemo/icons/tools/20x20@3/back.png new file mode 100644 index 0000000..b228eb8 Binary files /dev/null and b/QtAndroidToolsDemo/icons/tools/20x20@3/back.png differ diff --git a/QtAndroidToolsDemo/icons/tools/20x20@3/drawer.png b/QtAndroidToolsDemo/icons/tools/20x20@3/drawer.png new file mode 100644 index 0000000..3584ed6 Binary files /dev/null and b/QtAndroidToolsDemo/icons/tools/20x20@3/drawer.png differ diff --git a/QtAndroidToolsDemo/icons/tools/20x20@3/menu.png b/QtAndroidToolsDemo/icons/tools/20x20@3/menu.png new file mode 100644 index 0000000..9554b69 Binary files /dev/null and b/QtAndroidToolsDemo/icons/tools/20x20@3/menu.png differ diff --git a/QtAndroidToolsDemo/icons/tools/20x20@4/back.png b/QtAndroidToolsDemo/icons/tools/20x20@4/back.png new file mode 100644 index 0000000..dd157e7 Binary files /dev/null and b/QtAndroidToolsDemo/icons/tools/20x20@4/back.png differ diff --git a/QtAndroidToolsDemo/icons/tools/20x20@4/drawer.png b/QtAndroidToolsDemo/icons/tools/20x20@4/drawer.png new file mode 100644 index 0000000..60d93af Binary files /dev/null and b/QtAndroidToolsDemo/icons/tools/20x20@4/drawer.png differ diff --git a/QtAndroidToolsDemo/icons/tools/20x20@4/menu.png b/QtAndroidToolsDemo/icons/tools/20x20@4/menu.png new file mode 100644 index 0000000..187c171 Binary files /dev/null and b/QtAndroidToolsDemo/icons/tools/20x20@4/menu.png differ diff --git a/QtAndroidToolsDemo/icons/tools/index.theme b/QtAndroidToolsDemo/icons/tools/index.theme new file mode 100644 index 0000000..e77b054 --- /dev/null +++ b/QtAndroidToolsDemo/icons/tools/index.theme @@ -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 diff --git a/QtAndroidToolsDemo/images/logo_falsinsoft.jpg b/QtAndroidToolsDemo/images/logo_falsinsoft.jpg new file mode 100644 index 0000000..72504f2 Binary files /dev/null and b/QtAndroidToolsDemo/images/logo_falsinsoft.jpg differ diff --git a/QtAndroidToolsDemo/qtquickcontrols2.conf b/QtAndroidToolsDemo/qtquickcontrols2.conf new file mode 100644 index 0000000..7388750 --- /dev/null +++ b/QtAndroidToolsDemo/qtquickcontrols2.conf @@ -0,0 +1,5 @@ +[Material] +Primary=#4169E1 +Accent=#4169E1 +Theme=System + diff --git a/QtAndroidToolsDemo/tools/AndroidApkExpansionFiles.qml b/QtAndroidToolsDemo/tools/AndroidApkExpansionFiles.qml new file mode 100644 index 0000000..81f0640 --- /dev/null +++ b/QtAndroidToolsDemo/tools/AndroidApkExpansionFiles.qml @@ -0,0 +1,9 @@ + +import QtQuick 2.12 +import QtQuick.Controls 2.12 + +Page { + id: page + + +} diff --git a/QtAndroidToolsDemo/tools/AndroidAppPermissions.qml b/QtAndroidToolsDemo/tools/AndroidAppPermissions.qml new file mode 100644 index 0000000..81f0640 --- /dev/null +++ b/QtAndroidToolsDemo/tools/AndroidAppPermissions.qml @@ -0,0 +1,9 @@ + +import QtQuick 2.12 +import QtQuick.Controls 2.12 + +Page { + id: page + + +}