Move hideSplashScreen() from qjnihelpers_p to QNativeInterface
Hiding the splash screen require one JNI call instead of having to keep it as a global in qjnihelpers, and since it's not really easy to have a cross platform way for it it makes sense to have it under QNativeInterface. The alternative is probably removing it altogether since it's not useful often. Task-number: QTBUG-90500 Change-Id: I9b375c52afbf07e1ddd7957c1ec60af5c258f404 Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
This commit is contained in:
parent
fcbba3c622
commit
b621edddd5
@ -58,6 +58,7 @@ struct Q_CORE_EXPORT QAndroidApplication
|
|||||||
static jobject context();
|
static jobject context();
|
||||||
static bool isActivityContext();
|
static bool isActivityContext();
|
||||||
static int sdkVersion();
|
static int sdkVersion();
|
||||||
|
static void hideSplashScreen(int duration = 0);
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,6 @@ static jobject g_jClassLoader = nullptr;
|
|||||||
static jint g_androidSdkVersion = 0;
|
static jint g_androidSdkVersion = 0;
|
||||||
static jclass g_jNativeClass = nullptr;
|
static jclass g_jNativeClass = nullptr;
|
||||||
static jmethodID g_runPendingCppRunnablesMethodID = nullptr;
|
static jmethodID g_runPendingCppRunnablesMethodID = nullptr;
|
||||||
static jmethodID g_hideSplashScreenMethodID = nullptr;
|
|
||||||
Q_GLOBAL_STATIC(std::deque<QtAndroidPrivate::Runnable>, g_pendingRunnables);
|
Q_GLOBAL_STATIC(std::deque<QtAndroidPrivate::Runnable>, g_pendingRunnables);
|
||||||
static QBasicMutex g_pendingRunnablesMutex;
|
static QBasicMutex g_pendingRunnablesMutex;
|
||||||
|
|
||||||
@ -377,7 +376,6 @@ jint QtAndroidPrivate::initJNI(JavaVM *vm, JNIEnv *env)
|
|||||||
g_runPendingCppRunnablesMethodID = env->GetStaticMethodID(jQtNative,
|
g_runPendingCppRunnablesMethodID = env->GetStaticMethodID(jQtNative,
|
||||||
"runPendingCppRunnablesOnAndroidThread",
|
"runPendingCppRunnablesOnAndroidThread",
|
||||||
"()V");
|
"()V");
|
||||||
g_hideSplashScreenMethodID = env->GetStaticMethodID(jQtNative, "hideSplashScreen", "(I)V");
|
|
||||||
g_jNativeClass = static_cast<jclass>(env->NewGlobalRef(jQtNative));
|
g_jNativeClass = static_cast<jclass>(env->NewGlobalRef(jQtNative));
|
||||||
env->DeleteLocalRef(jQtNative);
|
env->DeleteLocalRef(jQtNative);
|
||||||
|
|
||||||
@ -549,11 +547,6 @@ void QtAndroidPrivate::unregisterKeyEventListener(QtAndroidPrivate::KeyEventList
|
|||||||
g_keyEventListeners()->listeners.removeOne(listener);
|
g_keyEventListeners()->listeners.removeOne(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtAndroidPrivate::hideSplashScreen(JNIEnv *env, int duration)
|
|
||||||
{
|
|
||||||
env->CallStaticVoidMethod(g_jNativeClass, g_hideSplashScreenMethodID, duration);
|
|
||||||
}
|
|
||||||
|
|
||||||
void QtAndroidPrivate::waitForServiceSetup()
|
void QtAndroidPrivate::waitForServiceSetup()
|
||||||
{
|
{
|
||||||
g_waitForServiceSetupSemaphore->acquire();
|
g_waitForServiceSetupSemaphore->acquire();
|
||||||
|
@ -149,14 +149,10 @@ namespace QtAndroidPrivate
|
|||||||
Q_CORE_EXPORT void registerKeyEventListener(KeyEventListener *listener);
|
Q_CORE_EXPORT void registerKeyEventListener(KeyEventListener *listener);
|
||||||
Q_CORE_EXPORT void unregisterKeyEventListener(KeyEventListener *listener);
|
Q_CORE_EXPORT void unregisterKeyEventListener(KeyEventListener *listener);
|
||||||
|
|
||||||
Q_CORE_EXPORT void hideSplashScreen(JNIEnv *env, int duration = 0);
|
|
||||||
|
|
||||||
|
|
||||||
Q_CORE_EXPORT void waitForServiceSetup();
|
Q_CORE_EXPORT void waitForServiceSetup();
|
||||||
Q_CORE_EXPORT int acuqireServiceSetup(int flags);
|
Q_CORE_EXPORT int acuqireServiceSetup(int flags);
|
||||||
Q_CORE_EXPORT void setOnBindListener(OnBindListener *listener);
|
Q_CORE_EXPORT void setOnBindListener(OnBindListener *listener);
|
||||||
Q_CORE_EXPORT jobject callOnBindListener(jobject intent);
|
Q_CORE_EXPORT jobject callOnBindListener(jobject intent);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
@ -39,6 +39,7 @@
|
|||||||
|
|
||||||
#include <QtCore/qcoreapplication.h>
|
#include <QtCore/qcoreapplication.h>
|
||||||
#include <QtCore/private/qjnihelpers_p.h>
|
#include <QtCore/private/qjnihelpers_p.h>
|
||||||
|
#include <QtCore/qjniobject.h>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
@ -93,4 +94,20 @@ int QNativeInterface::QAndroidApplication::sdkVersion()
|
|||||||
{
|
{
|
||||||
return QtAndroidPrivate::androidSdkVersion();
|
return QtAndroidPrivate::androidSdkVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn void QNativeInterface::QAndroidApplication::hideSplashScreen(int duration)
|
||||||
|
|
||||||
|
Hides the splash screen by using a fade effect for the given \a duration.
|
||||||
|
If \a duration is not provided (default is 0) the splash screen is hidden
|
||||||
|
immedetiately after the app starts.
|
||||||
|
|
||||||
|
\since 6.2
|
||||||
|
*/
|
||||||
|
void QNativeInterface::QAndroidApplication::hideSplashScreen(int duration)
|
||||||
|
{
|
||||||
|
QJniObject::callStaticMethod<void>("org/qtproject/qt/android/QtNative",
|
||||||
|
"hideSplashScreen", "(I)V", duration);
|
||||||
|
}
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
Loading…
x
Reference in New Issue
Block a user