Make Qt for Android configurable without 'desktopservices' support
Put all URL open handling behind desktopservices-feature flag. Move the few remaining function (desktopEnvironment()) a bit to keep #ifdeffery simple. Fixes: QTBUG-135722 Pick-to: 6.8 Change-Id: Id210f99f905719b8c5dc0a5fa5ac3cf10181ae84 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io> (cherry picked from commit bed78605e7611252a784e7501806518edba32f0e) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
00b28640a2
commit
a4cc41c33b
@ -1482,6 +1482,6 @@ qt_configure_add_report_entry(
|
||||
)
|
||||
qt_configure_add_report_entry(
|
||||
TYPE ERROR
|
||||
MESSAGE "The desktopservices feature is required on macOS, iOS, and Android and cannot be disabled."
|
||||
CONDITION (APPLE OR ANDROID) AND NOT QT_FEATURE_desktopservices
|
||||
MESSAGE "The desktopservices feature is required on macOS and iOS, and cannot be disabled."
|
||||
CONDITION APPLE AND NOT QT_FEATURE_desktopservices
|
||||
)
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
#include "qandroidplatformservices.h"
|
||||
|
||||
#if QT_CONFIG(desktopservices)
|
||||
#include <QDebug>
|
||||
#include <QDesktopServices>
|
||||
#include <QFile>
|
||||
@ -11,17 +12,21 @@
|
||||
#include <QtCore/QJniObject>
|
||||
#include <QtCore/qcoreapplication.h>
|
||||
#include <QtCore/qscopedvaluerollback.h>
|
||||
#endif
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
using namespace QtJniTypes;
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
#if QT_CONFIG(desktopservices)
|
||||
static constexpr auto s_defaultScheme = "file"_L1;
|
||||
static constexpr auto s_defaultProvider = "qtprovider"_L1;
|
||||
#endif
|
||||
|
||||
QAndroidPlatformServices::QAndroidPlatformServices()
|
||||
{
|
||||
#if QT_CONFIG(desktopservices)
|
||||
m_actionView = QJniObject::getStaticObjectField("android/content/Intent", "ACTION_VIEW",
|
||||
"Ljava/lang/String;")
|
||||
.toString();
|
||||
@ -40,6 +45,12 @@ QAndroidPlatformServices::QAndroidPlatformServices()
|
||||
},
|
||||
Qt::QueuedConnection);
|
||||
}
|
||||
#endif // QT_CONFIG(desktopservices)
|
||||
}
|
||||
|
||||
QByteArray QAndroidPlatformServices::desktopEnvironment() const
|
||||
{
|
||||
return QByteArray("Android");
|
||||
}
|
||||
|
||||
Q_DECLARE_JNI_CLASS(FileProvider, "androidx/core/content/FileProvider");
|
||||
@ -47,6 +58,7 @@ Q_DECLARE_JNI_CLASS(PackageManager, "android/content/pm/PackageManager");
|
||||
Q_DECLARE_JNI_CLASS(PackageInfo, "android/content/pm/PackageInfo");
|
||||
Q_DECLARE_JNI_CLASS(ProviderInfo, "android/content/pm/ProviderInfo");
|
||||
|
||||
#if QT_CONFIG(desktopservices)
|
||||
bool QAndroidPlatformServices::openUrl(const QUrl &theUrl)
|
||||
{
|
||||
QUrl url(theUrl);
|
||||
@ -159,11 +171,6 @@ bool QAndroidPlatformServices::openDocument(const QUrl &url)
|
||||
return openUrl(url);
|
||||
}
|
||||
|
||||
QByteArray QAndroidPlatformServices::desktopEnvironment() const
|
||||
{
|
||||
return QByteArray("Android");
|
||||
}
|
||||
|
||||
bool QAndroidPlatformServices::handleNewIntent(JNIEnv *env, jobject intent)
|
||||
{
|
||||
Q_UNUSED(env);
|
||||
@ -178,5 +185,6 @@ bool QAndroidPlatformServices::handleNewIntent(JNIEnv *env, jobject intent)
|
||||
QScopedValueRollback<QUrl> rollback(m_handlingUrl, url);
|
||||
return QDesktopServices::openUrl(url);
|
||||
}
|
||||
#endif // QT_CONFIG(desktopservices)
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
@ -13,16 +13,19 @@
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QAndroidPlatformServices : public QObject,
|
||||
public QPlatformServices,
|
||||
public QtAndroidPrivate::NewIntentListener
|
||||
public QPlatformServices
|
||||
#if QT_CONFIG(desktopservices)
|
||||
, public QtAndroidPrivate::NewIntentListener
|
||||
#endif
|
||||
{
|
||||
public:
|
||||
QAndroidPlatformServices();
|
||||
|
||||
bool openUrl(const QUrl &url) override;
|
||||
bool openDocument(const QUrl &url) override;
|
||||
QByteArray desktopEnvironment() const override;
|
||||
|
||||
#if QT_CONFIG(desktopservices)
|
||||
bool openUrl(const QUrl &url) override;
|
||||
bool openDocument(const QUrl &url) override;
|
||||
bool handleNewIntent(JNIEnv *env, jobject intent) override;
|
||||
|
||||
private:
|
||||
@ -38,6 +41,7 @@ private:
|
||||
private:
|
||||
QUrl m_handlingUrl;
|
||||
QString m_actionView;
|
||||
#endif
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
Loading…
x
Reference in New Issue
Block a user