Skip to content

Commit

Permalink
Minor formatting changes
Browse files Browse the repository at this point in the history
  • Loading branch information
nbradbury committed Jan 16, 2025
1 parent fc308cf commit e1aac0d
Showing 1 changed file with 6 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package org.wordpress.android.util.extensions

import android.os.Build
import android.view.View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
import android.view.View.SYSTEM_UI_FLAG_LAYOUT_STABLE
import android.view.View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR
import android.view.View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
import android.view.Window
Expand Down Expand Up @@ -52,16 +50,10 @@ fun Window.setEdgeToEdgeContentDisplay(isEnabled: Boolean) {
WindowCompat.setDecorFitsSystemWindows(this, decorFitsSystemWindows)
}

@Suppress("DEPRECATION")
fun Window.showFullScreen() {
decorView.systemUiVisibility = decorView.systemUiVisibility.let {
it or SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or SYSTEM_UI_FLAG_LAYOUT_STABLE
}
}

@Suppress("DEPRECATION")
fun Window.setWindowStatusBarColor(color: Int) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM) { // Android 15+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM) {
// Android 15+
decorView.setOnApplyWindowInsetsListener { view, insets ->
val statusBarInsets = insets.getInsets(WindowInsets.Type.statusBars())
view.setBackgroundColor(color)
Expand All @@ -70,7 +62,7 @@ fun Window.setWindowStatusBarColor(color: Int) {
insets
}
} else {
// For Android 14 and below
// Android 14-
statusBarColor = color
val windowInsetsController = WindowInsetsControllerCompat(this, decorView)
windowInsetsController.isAppearanceLightStatusBars = ColorUtils.isColorLight(statusBarColor)
Expand All @@ -83,7 +75,8 @@ fun Window.setWindowStatusBarColor(color: Int) {

@Suppress("DEPRECATION")
fun Window.setWindowNavigationBarColor(color: Int) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM) { // Android 15+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM) {
// Android 15+
decorView.setOnApplyWindowInsetsListener { view, insets ->
view.setBackgroundColor(color)
// Adjust padding to avoid overlap
Expand All @@ -92,7 +85,7 @@ fun Window.setWindowNavigationBarColor(color: Int) {
insets
}
} else {
// For Android 14 and below
// Android 14-
val windowInsetsController = WindowInsetsControllerCompat(this, decorView)
navigationBarColor = color
windowInsetsController.isAppearanceLightNavigationBars = ColorUtils.isColorLight(navigationBarColor)
Expand Down

0 comments on commit e1aac0d

Please sign in to comment.