Enforce system bar contrast in older API levels

This commit is contained in:
vfsfitvnm 2022-08-27 12:11:10 +02:00
parent 45810496e7
commit c4122ddd9c

View file

@ -7,6 +7,7 @@ import android.content.ServiceConnection
import android.content.SharedPreferences
import android.graphics.Bitmap
import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.os.IBinder
import androidx.activity.ComponentActivity
@ -44,6 +45,7 @@ import androidx.compose.runtime.staticCompositionLocalOf
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.toArgb
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import androidx.core.view.WindowCompat
@ -368,6 +370,16 @@ class MainActivity : ComponentActivity() {
isAppearanceLightStatusBars = !isDark
isAppearanceLightNavigationBars = !isDark
}
if (Build.VERSION.SDK_INT < 23) {
window.statusBarColor =
(if (isDark) Color.Transparent else Color.Black.copy(alpha = 0.2f)).toArgb()
}
if (Build.VERSION.SDK_INT < 26) {
window.navigationBarColor =
(if (isDark) Color.Transparent else Color.Black.copy(alpha = 0.2f)).toArgb()
}
}
}