Android: Allow timeout to fade out splash screen
Change-Id: I7b24f4d402da7f74b4c983467008ff4c19fc3b1b Task-number: QTBUG-59200 Reviewed-by: BogDan Vatra <bogdan@kdab.com>
This commit is contained in:
parent
8d0b46c3ae
commit
0d34f0c9df
@ -62,6 +62,9 @@ import android.util.Base64;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
import android.util.TypedValue;
|
||||
import android.view.animation.AccelerateInterpolator;
|
||||
import android.view.animation.AlphaAnimation;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.ContextMenu;
|
||||
import android.view.ContextMenu.ContextMenuInfo;
|
||||
import android.view.KeyCharacterMap;
|
||||
@ -1016,11 +1019,37 @@ public class QtActivityDelegate
|
||||
}
|
||||
|
||||
public void hideSplashScreen()
|
||||
{
|
||||
hideSplashScreen(0);
|
||||
}
|
||||
|
||||
public void hideSplashScreen(final int duration)
|
||||
{
|
||||
if (m_splashScreen == null)
|
||||
return;
|
||||
|
||||
if (duration <= 0) {
|
||||
m_layout.removeView(m_splashScreen);
|
||||
m_splashScreen = null;
|
||||
return;
|
||||
}
|
||||
|
||||
final Animation fadeOut = new AlphaAnimation(1, 0);
|
||||
fadeOut.setInterpolator(new AccelerateInterpolator());
|
||||
fadeOut.setDuration(duration);
|
||||
|
||||
fadeOut.setAnimationListener(new Animation.AnimationListener() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animation animation) { hideSplashScreen(0); }
|
||||
|
||||
@Override
|
||||
public void onAnimationRepeat(Animation animation) {}
|
||||
|
||||
@Override
|
||||
public void onAnimationStart(Animation animation) {}
|
||||
});
|
||||
|
||||
m_splashScreen.startAnimation(fadeOut);
|
||||
}
|
||||
|
||||
|
||||
|
@ -764,13 +764,13 @@ public class QtNative
|
||||
});
|
||||
}
|
||||
|
||||
private static void hideSplashScreen()
|
||||
private static void hideSplashScreen(final int duration)
|
||||
{
|
||||
runAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (m_activityDelegate != null)
|
||||
m_activityDelegate.hideSplashScreen();
|
||||
m_activityDelegate.hideSplashScreen(duration);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -406,7 +406,7 @@ jint QtAndroidPrivate::initJNI(JavaVM *vm, JNIEnv *env)
|
||||
g_runPendingCppRunnablesMethodID = env->GetStaticMethodID(jQtNative,
|
||||
"runPendingCppRunnablesOnAndroidThread",
|
||||
"()V");
|
||||
g_hideSplashScreenMethodID = env->GetStaticMethodID(jQtNative, "hideSplashScreen", "()V");
|
||||
g_hideSplashScreenMethodID = env->GetStaticMethodID(jQtNative, "hideSplashScreen", "(I)V");
|
||||
g_jNativeClass = static_cast<jclass>(env->NewGlobalRef(jQtNative));
|
||||
env->DeleteLocalRef(jQtNative);
|
||||
|
||||
@ -566,9 +566,9 @@ void QtAndroidPrivate::unregisterKeyEventListener(QtAndroidPrivate::KeyEventList
|
||||
g_keyEventListeners()->listeners.removeOne(listener);
|
||||
}
|
||||
|
||||
void QtAndroidPrivate::hideSplashScreen(JNIEnv *env)
|
||||
void QtAndroidPrivate::hideSplashScreen(JNIEnv *env, int duration)
|
||||
{
|
||||
env->CallStaticVoidMethod(g_jNativeClass, g_hideSplashScreenMethodID);
|
||||
env->CallStaticVoidMethod(g_jNativeClass, g_hideSplashScreenMethodID, duration);
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
@ -140,7 +140,7 @@ namespace QtAndroidPrivate
|
||||
Q_CORE_EXPORT void registerKeyEventListener(KeyEventListener *listener);
|
||||
Q_CORE_EXPORT void unregisterKeyEventListener(KeyEventListener *listener);
|
||||
|
||||
Q_CORE_EXPORT void hideSplashScreen(JNIEnv *env);
|
||||
Q_CORE_EXPORT void hideSplashScreen(JNIEnv *env, int duration = 0);
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
Loading…
x
Reference in New Issue
Block a user