@@ -37,8 +37,9 @@ import android.os.Bundle
3737import android.view.View
3838import android.view.WindowInsetsController
3939import androidx.activity.ComponentActivity
40+ import androidx.core.content.ContextCompat
4041import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
41- import androidx.core.view.ViewCompat
42+ import androidx.core.view.WindowCompat
4243
4344/* *
4445 * Base activity that sets the Nordic theme and the Splash Screen.
@@ -56,6 +57,8 @@ abstract class NordicActivity : ComponentActivity() {
5657 setTheme(R .style.NordicTheme )
5758 super .onCreate(savedInstanceState)
5859
60+ setDecorFitsSystemWindows(true )
61+
5962 val view = window.decorView
6063 if (! isDarkMode()) {
6164 if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .R ) {
@@ -85,6 +88,15 @@ abstract class NordicActivity : ComponentActivity() {
8588 }
8689 }
8790
91+ fun setDecorFitsSystemWindows (decorFitsSystemWindows : Boolean ) {
92+ if (! decorFitsSystemWindows) {
93+ WindowCompat .setDecorFitsSystemWindows(window, false )
94+ window.statusBarColor = ContextCompat .getColor(this , android.R .color.transparent)
95+ } else {
96+ window.statusBarColor = ContextCompat .getColor(this , R .color.statusBarColor)
97+ }
98+ }
99+
88100 fun isDarkMode (): Boolean {
89101 val darkModeFlag = resources.configuration.uiMode and Configuration .UI_MODE_NIGHT_MASK
90102 return darkModeFlag == Configuration .UI_MODE_NIGHT_YES
0 commit comments