Subsurface-mobile on Android: change the splash screen methodology

This is based on post by Ben Laud
https://medium.com/@benlaud/complete-guide-to-make-a-splash-screen-for-your-qml-android-application-567ca3bc70af

It creates a theme that uses a splash drawable that Android will show
immediately when the application is launched. And then starts the QML
application with visibility set to false adn only makes it visible (and replace
the splash screen) once initialization is finished.

We still get a little flicker with the switch from splash to start page to dive
list, but over all the experience is hugely improved. And the bug that the
splash screen stays around when starting Subsurface-mobile in landscape also
appears to be fixed.

Fixes #994

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2016-01-19 12:42:58 -08:00
parent f466ee61da
commit 04e994b575
5 changed files with 40 additions and 2 deletions

View file

@ -14,6 +14,7 @@
android:name="org.qtproject.qt5.android.bindings.QtActivity" android:name="org.qtproject.qt5.android.bindings.QtActivity"
android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|locale|fontScale|keyboard|keyboardHidden|navigation" android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|locale|fontScale|keyboard|keyboardHidden|navigation"
android:label="@string/app_name" android:label="@string/app_name"
android:theme="@style/AppTheme"
android:launchMode="singleTop" android:launchMode="singleTop"
android:screenOrientation="unspecified" > android:screenOrientation="unspecified" >
<intent-filter> <intent-filter>
@ -77,7 +78,8 @@
<!-- Splash screen --> <!-- Splash screen -->
<meta-data android:name="android.app.splash_screen_drawable" android:resource="@drawable/subsurface_mobile_splash" /> <!-- <meta-data android:name="android.app.splash_screen_drawable" android:resource="@drawable/subsurface_mobile_splash" /> -->
<meta-data android:name="android.app.splash_screen_drawable" android:resource="@drawable/splash" />
<!-- Splash screen --> <!-- Splash screen -->
</activity> </activity>

View file

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle" >
<solid android:color="#000000FF"/>
</shape>
</item>
<item>
<bitmap android:src="@drawable/subsurface_mobile_splash"
android:gravity="center" />
</item>
</layer-list>

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 KiB

View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme" parent="@android:style/Theme.DeviceDefault.Light.NoActionBar">
<item name="android:windowBackground">@drawable/splash</item>
</style>
</resources>

View file

@ -17,7 +17,8 @@ MobileComponents.ApplicationWindow {
id: fontMetrics id: fontMetrics
} }
visible: true visible: false
opacity: 0
globalDrawer: MobileComponents.GlobalDrawer { globalDrawer: MobileComponents.GlobalDrawer {
title: "Subsurface" title: "Subsurface"
@ -200,6 +201,14 @@ MobileComponents.ApplicationWindow {
initialPage: DiveList { initialPage: DiveList {
anchors.fill: detailsPage anchors.fill: detailsPage
id: diveDetails id: diveDetails
opacity: 0
Behavior on opacity {
NumberAnimation {
duration: 200
easing.type: Easing.OutQuad
}
}
} }
QMLManager { QMLManager {
@ -244,5 +253,14 @@ MobileComponents.ApplicationWindow {
Component.onCompleted: { Component.onCompleted: {
manager.finishSetup(); manager.finishSetup();
rootItem.visible = true
diveDetails.opacity = 1
rootItem.opacity = 1
}
Behavior on opacity {
NumberAnimation {
duration: 200
easing.type: Easing.OutQuad
}
} }
} }