MauiKit Controls

mauiandroid.h
1/*
2 * Copyright 2018 Camilo Higuita <milo.h@aol.com>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Library General Public License as
6 * published by the Free Software Foundation; either version 2, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details
13 *
14 * You should have received a copy of the GNU Library General Public
15 * License along with this program; if not, write to the
16 * Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 */
19
20#pragma once
21
22#include <QObject>
23#include <QQmlEngine>
24
25// #include <QAndroidActivityResultReceiver>
26#include <QJniEnvironment>
27#include <QJniObject>
28#include <QObject>
29#include <QString>
30#include <QStringList>
31#include <QVariantList>
32#include <QPermission>
33#include <QStandardPaths>
34
35#include "abstractplatform.h"
36
37/**
38 * @brief The MAUIAndroid class
39 */
40class Q_DECL_EXPORT MAUIAndroid : public AbstractPlatform
41{
43 QML_NAMED_ELEMENT(Android)
44 QML_SINGLETON
45 // Q_DISABLE_COPY(MAUIAndroid)
46 // Q_DISABLE_MOVE(MAUIAndroid)
47
48public:
49 explicit MAUIAndroid(QObject *parent = nullptr);
50
51 // static MAUIAndroid *instance()
52 // {
53 // if (m_instance)
54 // return m_instance;
55
56 // m_instance = new MAUIAndroid;
57 // return m_instance;
58 // }
59
60 /**
61 * @brief fileChooser
62 */
63 static void fileChooser();
64
65 static QVariantList transform(const QJniObject &obj);
66 static QVariantMap createVariantMap(jobject data);
67
68private:
69 // static MAUIAndroid *m_instance;
70 void handleActivityResult(int receiverRequestCode, int resultCode, const QJniObject &data);
71
72
73public Q_SLOTS:
74
75 /**
76 * @brief statusbarColor
77 * @param bg
78 * @param light
79 */
80 static void statusbarColor(const QString &bg, const bool &light);
81
82 /**
83 * @brief navBarColor
84 * @param bg
85 * @param light
86 */
87 static void navBarColor(const QString &bg, const bool &light);
88
89 /**
90 * @brief shareFiles
91 * @param urls
92 */
93 void shareFiles(const QList<QUrl> &urls) override final;
94
95 /**
96 * @brief shareText
97 * @param text
98 */
99 void shareText(const QString &text) override final;
100
101 /**
102 * @brief shareLink
103 * @param link
104 */
105 static void shareLink(const QString &link);
106
107 /**
108 * @brief openUrl
109 * @param url
110 */
111 static void openUrl(const QUrl &url);
112
113 /**
114 * @brief homePath
115 * @return
116 */
117 static QString homePath();
118 static QString getStandardPath(QStandardPaths::StandardLocation path);
119
120 /**
121 * @brief sdDirs
122 * @return
123 */
124 static QStringList sdDirs();
125
126 bool hasKeyboard() override final;
127 bool hasMouse() override final;
128
129 static bool checkRunTimePermissions(const QStringList &permissions);
130
132 /**
133 * @brief folderPicked
134 * @param path
135 */
137
138 // AbstractPlatform interface
139public Q_SLOTS:
140 bool darkModeEnabled() override final;
141};
142
143//namespace PATHS
144//{
145//const QString HomePath = MAUIAndroid::homePath();
146//const QString PicturesPath = HomePath + "/" + QJniObject::getStaticObjectField("android/os/Environment", "DIRECTORY_PICTURES", "Ljava/lang/String;").toString();
147//const QString DownloadsPath = HomePath + "/" + QJniObject::getStaticObjectField("android/os/Environment", "DIRECTORY_DOWNLOADS", "Ljava/lang/String;").toString();
148//const QString DocumentsPath = HomePath + "/" + QJniObject::getStaticObjectField("android/os/Environment", "DIRECTORY_DOCUMENTS", "Ljava/lang/String;").toString();
149//const QString MusicPath = HomePath + "/" + QJniObject::getStaticObjectField("android/os/Environment", "DIRECTORY_MUSIC", "Ljava/lang/String;").toString();
150//const QString VideosPath = HomePath + "/" + QJniObject::getStaticObjectField("android/os/Environment", "DIRECTORY_MOVIES", "Ljava/lang/String;").toString();
151//}
152
virtual bool hasMouse()=0
hasMouse
virtual void shareText(const QString &urls)=0
shareText
virtual void shareFiles(const QList< QUrl > &urls)=0
shareFiles
virtual bool hasKeyboard()=0
hasKeyboard
void folderPicked(QString path)
folderPicked
static void shareLink(const QString &link)
shareLink
static QString homePath()
homePath
static void openUrl(const QUrl &url)
openUrl
static QStringList sdDirs()
sdDirs
static void navBarColor(const QString &bg, const bool &light)
navBarColor
static void fileChooser()
fileChooser
static void statusbarColor(const QString &bg, const bool &light)
statusbarColor
QObject(QObject *parent)
Q_OBJECTQ_OBJECT
Q_SIGNALSQ_SIGNALS
Q_SLOTSQ_SLOTS
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri May 2 2025 11:57:11 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.