Skip to content

Commit c0eed65

Browse files
authored
Fix splashscreen not showing <= API 30 (#4889)
Task/Issue URL: https://app.asana.com/0/1207908166761516/1206826738295232/f ### Description The splashscreen was not showing on devices on devices <= API 30. To fix this I used the [spashscreen-compat](https://developer.android.com/develop/ui/views/launch/splash-screen/migrate#library) library and removed the need for dedicated splashscreen styles on API 31+ as the compat library will take of that for us. The splashscreen is very quick on a warm start on <= API 30 (see the demos) but I don’t think it’s worth adding any kind of artificial delay to show it for a longer period. ### Steps to test this PR If you have a device that’s <= API 31 to test then please do! Unfortunately I do not have a device on hand at that API level. - [x] Pick a device <= API 31 (preferably not an emulator) - [x] Install the app - [x] Run the app - [x] Check that the splashscreen shows - [x] Pick a device > API 30 (preferably not an emulator) - [x] Install the app - [x] Run the app - [x] Ensure the splashscreen is still present ### UI changes API 26 before shown as a demo for all devices < 30 I’ve provided some before videos on actual devices on >= API 30 | Before | After | |---|---| | <video width="630" height="300" src="https://github.com/user-attachments/assets/96865454-d52f-422d-ac47-3bb2c9192693"></video> | <video width="630" height="300" src="https://github.com/user-attachments/assets/e2b61703-29a5-4bc0-b860-42e228712faf"></video> | | | <video width="630" height="300" src="https://github.com/user-attachments/assets/697d51c5-e631-425f-924b-fdbc961c9501"></video> | | | <video width="630" height="300" src="https://github.com/user-attachments/assets/8517e14e-92de-44ac-8fac-2690f1349c34"></video> | | | <video width="630" height="300" src="https://github.com/user-attachments/assets/64a840c7-b1ea-4b33-922d-f08e5ce89135"></video> | | <video width="630" height="300" src="https://github.com/user-attachments/assets/1baf0195-2a4d-42e8-9eb0-f83548ed4de3"></video> | <video width="630" height="300" src="https://github.com/user-attachments/assets/843a5c23-4c41-4b92-9a79-90307c095409"></video> | | <video width="630" height="300" src="https://github.com/user-attachments/assets/074121e5-a8be-4d60-9336-826b09235406"></video> | <video width="630" height="300" src="https://github.com/user-attachments/assets/93d696a8-2d7d-4ff8-9d79-ed1df495be63"></video> | | | <video width="630" height="300" src="https://github.com/user-attachments/assets/5517bb27-d4ac-45c7-8e2a-c67e98e1a51f"></video> | | <video width="630" height="300" src="https://github.com/user-attachments/assets/f5b1f5a6-d026-4b32-a4cd-0668b9cdd016"></video> | <video width="630" height="300" src="https://github.com/user-attachments/assets/d74dd3b5-8976-4f13-9537-930a79c1a4b2"></video> | | <video width="630" height="300" src="https://github.com/user-attachments/assets/a2cb8dbf-20fc-41ff-9db3-c61108917fce"></video> | <video width="630" height="300" src="https://github.com/user-attachments/assets/7ff9bcbf-a689-4e67-bdc1-42f081d00ad7"></video> | | | <video width="630" height="300" src="https://github.com/user-attachments/assets/01ee9ea5-f9af-4b87-8429-86604a8017ab"></video> |
1 parent 4d9c7b3 commit c0eed65

File tree

8 files changed

+28
-53
lines changed

8 files changed

+28
-53
lines changed

app/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,7 @@ dependencies {
388388

389389
// Android KTX
390390
implementation AndroidX.core.ktx
391+
implementation AndroidX.core.splashscreen
391392
implementation AndroidX.fragment.ktx
392393

393394
// ViewModel and LiveData

app/src/main/java/com/duckduckgo/app/launch/LaunchBridgeActivity.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package com.duckduckgo.app.launch
1818

1919
import android.os.Bundle
20+
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
2021
import androidx.lifecycle.lifecycleScope
2122
import com.duckduckgo.anvil.annotations.InjectWith
2223
import com.duckduckgo.app.browser.BrowserActivity
@@ -32,7 +33,10 @@ class LaunchBridgeActivity : DuckDuckGoActivity() {
3233
private val viewModel: LaunchViewModel by bindViewModel()
3334

3435
override fun onCreate(savedInstanceState: Bundle?) {
36+
val splashScreen = installSplashScreen()
3537
super.onCreate(savedInstanceState)
38+
splashScreen.setKeepOnScreenCondition { true }
39+
3640
setContentView(R.layout.activity_launch)
3741

3842
configureObservers()

common/common-ui/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ dependencies {
4646
implementation AndroidX.appCompat
4747
implementation Google.android.material
4848
implementation AndroidX.constraintLayout
49+
implementation AndroidX.core.splashscreen
4950
implementation AndroidX.recyclerView
5051
implementation AndroidX.lifecycle.viewModelKtx
5152
// just to get the dagger annotations

common/common-ui/src/main/res/values-night-v31/design-system-theming.xml

Lines changed: 0 additions & 23 deletions
This file was deleted.

common/common-ui/src/main/res/values-night/design-system-theming.xml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,12 @@
1515
-->
1616

1717
<resources xmlns:tools="http://schemas.android.com/tools">
18-
<style name="Theme.DuckDuckGo.SplashScreen" parent="Theme.DuckDuckGo.Dark" />
18+
<style name="Theme.DuckDuckGo.SplashScreen" parent="Theme.DuckDuckGo.Splash">
19+
<item name="android:statusBarColor">@color/black</item>
20+
<item name="android:windowLightStatusBar">false</item>
21+
<item name="android:navigationBarColor">@color/black</item>
22+
23+
<item name="windowSplashScreenBackground">@color/black</item>
24+
<item name="postSplashScreenTheme">@style/Theme.DuckDuckGo.Dark</item>
25+
</style>
1926
</resources>

common/common-ui/src/main/res/values-v31/design-system-theming.xml

Lines changed: 0 additions & 28 deletions
This file was deleted.

common/common-ui/src/main/res/values/design-system-theming.xml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,18 @@
296296
<item name="daxColorPrimaryIcon">@color/white</item>
297297
</style>
298298

299-
<style name="Theme.DuckDuckGo.SplashScreen" parent="Theme.DuckDuckGo.Light"/>
299+
<style name="Theme.DuckDuckGo.SplashScreen" parent="Theme.DuckDuckGo.Splash">
300+
<item name="android:statusBarColor">@color/whiteFive</item>
301+
<item name="android:windowLightStatusBar">true</item>
302+
<item name="android:navigationBarColor">@color/whiteFive</item>
303+
304+
<item name="windowSplashScreenBackground">@color/whiteFive</item>
305+
<item name="postSplashScreenTheme">@style/Theme.DuckDuckGo.Light</item>
306+
</style>
307+
308+
<style name="Theme.DuckDuckGo.Splash" parent="Theme.SplashScreen">
309+
<item name="windowSplashScreenAnimatedIcon">@drawable/ic_dax_splash_screen_icon</item>
310+
</style>
300311

301312
<style name="Theme.AppCompat.Transparent.NoActionBar" parent="Theme.AppCompat.Light.NoActionBar">
302313
<item name="android:windowIsTranslucent">true</item>

versions.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ version.androidx.constraintlayout=2.1.4
1919

2020
version.androidx.biometric=1.1.0
2121

22+
version.androidx.core-splashscreen=1.0.1
23+
2224
version.androidx.datastore=1.1.1
2325

2426
version.androidx.localbroadcastmanager=1.1.0

0 commit comments

Comments
 (0)