Skip to content

Commit

Permalink
Resolve #55
Browse files Browse the repository at this point in the history
  • Loading branch information
xb2016 committed Apr 22, 2024
1 parent 6afe32b commit 5d0e59f
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions app/src/main/java/com/hippo/ehviewer/ui/scene/BaseScene.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import android.annotation.SuppressLint
import android.content.res.Configuration
import android.content.res.Resources
import android.content.res.Resources.Theme
import android.os.Build
import android.os.Bundle
import android.os.Parcelable
import android.util.SparseArray
Expand Down Expand Up @@ -162,11 +163,22 @@ abstract class BaseScene : SceneFragment() {
drawerView = null
}

@Suppress("DEPRECATION")
fun setLightStatusBar(set: Boolean) {
val activity = requireActivity()
val insetsController = WindowCompat.getInsetsController(activity.window, activity.window.decorView)
insetsController.isAppearanceLightStatusBars =
set && (activity.resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_YES <= 0)
val decorView = activity.window.decorView
val isLight = set && (activity.resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_YES) <= 0
// https://github.com/EhViewer-NekoInverter/EhViewer/issues/55
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.Q) {
WindowCompat.getInsetsController(activity.window, decorView).isAppearanceLightStatusBars = isLight
} else {
val flags = decorView.systemUiVisibility
decorView.systemUiVisibility = if (isLight) {
flags or View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
} else {
flags and View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR.inv()
}
}
needWhiteStatusBar = set
}

Expand Down

0 comments on commit 5d0e59f

Please sign in to comment.