diff --git a/src/corelib/kernel/qcoreapplication_platform.h b/src/corelib/kernel/qcoreapplication_platform.h index 15d9abc3fc3..0615cddf8f7 100644 --- a/src/corelib/kernel/qcoreapplication_platform.h +++ b/src/corelib/kernel/qcoreapplication_platform.h @@ -58,6 +58,7 @@ struct Q_CORE_EXPORT QAndroidApplication static jobject context(); static bool isActivityContext(); static int sdkVersion(); + static void hideSplashScreen(int duration = 0); }; #endif } diff --git a/src/corelib/kernel/qjnihelpers.cpp b/src/corelib/kernel/qjnihelpers.cpp index 189a4d8f6aa..343a2f424ec 100644 --- a/src/corelib/kernel/qjnihelpers.cpp +++ b/src/corelib/kernel/qjnihelpers.cpp @@ -75,7 +75,6 @@ static jobject g_jClassLoader = nullptr; static jint g_androidSdkVersion = 0; static jclass g_jNativeClass = nullptr; static jmethodID g_runPendingCppRunnablesMethodID = nullptr; -static jmethodID g_hideSplashScreenMethodID = nullptr; Q_GLOBAL_STATIC(std::deque, g_pendingRunnables); static QBasicMutex g_pendingRunnablesMutex; @@ -377,7 +376,6 @@ jint QtAndroidPrivate::initJNI(JavaVM *vm, JNIEnv *env) g_runPendingCppRunnablesMethodID = env->GetStaticMethodID(jQtNative, "runPendingCppRunnablesOnAndroidThread", "()V"); - g_hideSplashScreenMethodID = env->GetStaticMethodID(jQtNative, "hideSplashScreen", "(I)V"); g_jNativeClass = static_cast(env->NewGlobalRef(jQtNative)); env->DeleteLocalRef(jQtNative); @@ -549,11 +547,6 @@ void QtAndroidPrivate::unregisterKeyEventListener(QtAndroidPrivate::KeyEventList g_keyEventListeners()->listeners.removeOne(listener); } -void QtAndroidPrivate::hideSplashScreen(JNIEnv *env, int duration) -{ - env->CallStaticVoidMethod(g_jNativeClass, g_hideSplashScreenMethodID, duration); -} - void QtAndroidPrivate::waitForServiceSetup() { g_waitForServiceSetupSemaphore->acquire(); diff --git a/src/corelib/kernel/qjnihelpers_p.h b/src/corelib/kernel/qjnihelpers_p.h index 1a7035718ed..26072218601 100644 --- a/src/corelib/kernel/qjnihelpers_p.h +++ b/src/corelib/kernel/qjnihelpers_p.h @@ -149,14 +149,10 @@ namespace QtAndroidPrivate Q_CORE_EXPORT void registerKeyEventListener(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 int acuqireServiceSetup(int flags); Q_CORE_EXPORT void setOnBindListener(OnBindListener *listener); Q_CORE_EXPORT jobject callOnBindListener(jobject intent); - } QT_END_NAMESPACE diff --git a/src/corelib/platform/android/qandroidnativeinterface.cpp b/src/corelib/platform/android/qandroidnativeinterface.cpp index 6096d21181a..296027340a8 100644 --- a/src/corelib/platform/android/qandroidnativeinterface.cpp +++ b/src/corelib/platform/android/qandroidnativeinterface.cpp @@ -39,6 +39,7 @@ #include #include +#include QT_BEGIN_NAMESPACE @@ -93,4 +94,20 @@ int QNativeInterface::QAndroidApplication::sdkVersion() { 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("org/qtproject/qt/android/QtNative", + "hideSplashScreen", "(I)V", duration); +} + QT_END_NAMESPACE