Skip to content

Commit 0cedb76

Browse files
committed
Upload file
1 parent 37171a0 commit 0cedb76

1 file changed

Lines changed: 28 additions & 16 deletions

File tree

pio/src/main/java/com/tool/tree/SplashActivity.kt

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import java.io.BufferedReader
3232
import java.io.DataOutputStream
3333
import java.io.File
3434
import java.util.Locale
35+
import android.util.TypedValue
3536

3637
class SplashActivity : AppCompatActivity() {
3738

@@ -82,22 +83,33 @@ class SplashActivity : AppCompatActivity() {
8283
}
8384
}
8485

85-
private fun applyTheme() {
86-
val bgColor = ContextCompat.getColor(this, R.color.splash_bg_color)
87-
88-
window.statusBarColor = bgColor
89-
window.navigationBarColor = bgColor
90-
91-
val controller = WindowCompat.getInsetsController(window, window.decorView)
92-
93-
val isDark =
94-
(resources.configuration.uiMode and
95-
Configuration.UI_MODE_NIGHT_MASK) ==
96-
Configuration.UI_MODE_NIGHT_YES
97-
98-
controller?.isAppearanceLightStatusBars = !isDark
99-
controller?.isAppearanceLightNavigationBars = !isDark
100-
}
86+
private fun getThemeColor(attr: Int): Int {
87+
val typedValue = TypedValue()
88+
theme.resolveAttribute(attr, typedValue, true)
89+
90+
return if (typedValue.resourceId != 0) {
91+
getColor(typedValue.resourceId)
92+
} else {
93+
typedValue.data
94+
}
95+
}
96+
97+
private fun applyTheme() {
98+
val bgColor = getThemeColor(android.R.attr.windowBackground)
99+
100+
window.statusBarColor = bgColor
101+
window.navigationBarColor = bgColor
102+
103+
val controller = WindowCompat.getInsetsController(window, window.decorView)
104+
105+
val isDark =
106+
(resources.configuration.uiMode and
107+
Configuration.UI_MODE_NIGHT_MASK) ==
108+
Configuration.UI_MODE_NIGHT_YES
109+
110+
controller?.isAppearanceLightStatusBars = !isDark
111+
controller?.isAppearanceLightNavigationBars = !isDark
112+
}
101113

102114
// =================== AGREEMENT ===================
103115
private fun showAgreementDialog() {

0 commit comments

Comments
 (0)