From 68b6d8d5d892f99429f626f07a13c022a7f330a9 Mon Sep 17 00:00:00 2001 From: wilsonshih Date: Tue, 2 Apr 2024 17:12:50 +0800 Subject: [PATCH] Do not overwrite activity theme after receive splash screen view. From api 33[1], the polish transfer splash screen view action was move to Shell, so there won't overwrite activity's theme after setOnExitAnimationListener called. [1]: Ibb353d350fa2921188c8c4b54f8e029ee3869c16 Bug: 331563980 Test: add enableEdgeToEdge in activity's onCreate, verify activity's theme won't be affected by onExitAnimatinListener. Change-Id: I10587b7ce8e859720de74952a8b227c1b9fc349c --- .../java/androidx/core/splashscreen/SplashScreen.kt | 12 ++++++++---- .../core/splashscreen/SplashScreenViewProvider.kt | 10 ++++++---- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/core/core-splashscreen/src/main/java/androidx/core/splashscreen/SplashScreen.kt b/core/core-splashscreen/src/main/java/androidx/core/splashscreen/SplashScreen.kt index a750a9b555c31..1e24dd7322ec7 100644 --- a/core/core-splashscreen/src/main/java/androidx/core/splashscreen/SplashScreen.kt +++ b/core/core-splashscreen/src/main/java/androidx/core/splashscreen/SplashScreen.kt @@ -425,9 +425,11 @@ class SplashScreen private constructor(activity: Activity) { override fun install() { setPostSplashScreenTheme(activity.theme, TypedValue()) - (activity.window.decorView as ViewGroup).setOnHierarchyChangeListener( - hierarchyListener - ) + if (SDK_INT < 33) { + (activity.window.decorView as ViewGroup).setOnHierarchyChangeListener( + hierarchyListener + ) + } } override fun setKeepOnScreenCondition(keepOnScreenCondition: KeepOnScreenCondition) { @@ -454,7 +456,9 @@ class SplashScreen private constructor(activity: Activity) { exitAnimationListener: OnExitAnimationListener ) { activity.splashScreen.setOnExitAnimationListener { splashScreenView -> - applyAppSystemUiTheme() + if (SDK_INT < 33) { + applyAppSystemUiTheme() + } val splashScreenViewProvider = SplashScreenViewProvider(splashScreenView, activity) exitAnimationListener.onSplashScreenExit(splashScreenViewProvider) } diff --git a/core/core-splashscreen/src/main/java/androidx/core/splashscreen/SplashScreenViewProvider.kt b/core/core-splashscreen/src/main/java/androidx/core/splashscreen/SplashScreenViewProvider.kt index 782051816c51a..1ce8a15b44bd5 100644 --- a/core/core-splashscreen/src/main/java/androidx/core/splashscreen/SplashScreenViewProvider.kt +++ b/core/core-splashscreen/src/main/java/androidx/core/splashscreen/SplashScreenViewProvider.kt @@ -133,10 +133,12 @@ public class SplashScreenViewProvider internal constructor(ctx: Activity) { override fun remove() { platformView.remove() - ThemeUtils.Api31.applyThemesSystemBarAppearance( - activity.theme, - activity.window.decorView - ) + if (Build.VERSION.SDK_INT < 33) { + ThemeUtils.Api31.applyThemesSystemBarAppearance( + activity.theme, + activity.window.decorView + ) + } } } }