File tree Expand file tree Collapse file tree
simplified-ui-screen/src/main/java/org/nypl/simplified/ui/screen Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11package org.nypl.simplified.ui.screen
22
3+ import android.app.Activity
4+ import android.content.res.Configuration
35import android.os.Build
46import android.view.View
57import androidx.core.view.ViewCompat
@@ -32,6 +34,33 @@ object ScreenEdgeToEdgeFix {
3234 view.setPadding(padLeft, padTop, padRight, padBottom)
3335 insets
3436 }
37+
38+ /*
39+ * Google want to pretend that they don't have a status bar, whilst also clearly having
40+ * status bar icons. To facilitate this delusion, we have to set the status bar (that we
41+ * don't have) to light or dark depending on the day/night mode. This is necessary so that
42+ * we don't end up with black icons on a black background, and so on.
43+ */
44+
45+ val configuration =
46+ rootView.resources.configuration
47+ val context =
48+ rootView.context
49+
50+ if (context is Activity ) {
51+ val isNightMode =
52+ (configuration.uiMode and Configuration .UI_MODE_NIGHT_MASK ) == Configuration .UI_MODE_NIGHT_YES
53+ val decor =
54+ context.window.decorView
55+
56+ if (isNightMode) {
57+ decor.systemUiVisibility =
58+ View .SYSTEM_UI_FLAG_LAYOUT_STABLE or View .SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
59+ } else {
60+ decor.systemUiVisibility =
61+ View .SYSTEM_UI_FLAG_LAYOUT_STABLE or View .SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or View .SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
62+ }
63+ }
3564 }
3665 }
3766}
You can’t perform that action at this time.
0 commit comments