@nativue/core 0.11.0 → 0.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -19,7 +19,6 @@ import android.view.View
|
|
|
19
19
|
import android.view.ViewGroup
|
|
20
20
|
import android.view.WindowInsets
|
|
21
21
|
import android.view.WindowInsetsAnimation
|
|
22
|
-
import android.view.WindowInsetsController
|
|
23
22
|
import android.graphics.Insets
|
|
24
23
|
import android.view.inputmethod.EditorInfo
|
|
25
24
|
import android.view.inputmethod.InputMethodManager
|
|
@@ -184,9 +183,7 @@ class Bridge(private val activity: Activity, private val rootView: RootView) {
|
|
|
184
183
|
// Content not in the window now, like a hidden <Modal>'s, is repainted too.
|
|
185
184
|
nodesById.values.forEach { applyThemeColors(it.view) }
|
|
186
185
|
// The theme set them when the window was created; it isn't recreated (configChanges has uiMode).
|
|
187
|
-
|
|
188
|
-
WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS
|
|
189
|
-
activity.window.insetsController?.setSystemBarsAppearance(if (ThemeColors.isDark) 0 else lightBars, lightBars)
|
|
186
|
+
SystemBars.setLight(activity.window, !ThemeColors.isDark)
|
|
190
187
|
evaluate { runtime?.call("__colorSchemeChanged", colorScheme()) }
|
|
191
188
|
}
|
|
192
189
|
|
|
@@ -18,6 +18,7 @@ open class NativueActivity : Activity() {
|
|
|
18
18
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
19
19
|
super.onCreate(savedInstanceState)
|
|
20
20
|
SoLoader.init(this, false) // Yoga loads its native library through it
|
|
21
|
+
SystemBars.drawBehind(window)
|
|
21
22
|
ThemeColors.update(this)
|
|
22
23
|
|
|
23
24
|
val rootView = RootView(this)
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
package dev.nativue
|
|
2
|
+
|
|
3
|
+
import android.graphics.Color
|
|
4
|
+
import android.os.Build
|
|
5
|
+
import android.view.View
|
|
6
|
+
import android.view.Window
|
|
7
|
+
import android.view.WindowInsetsController
|
|
8
|
+
import android.view.WindowManager
|
|
9
|
+
|
|
10
|
+
/** The status and navigation bars: transparent, over the screens, with icons that contrast with them. */
|
|
11
|
+
@Suppress("DEPRECATION") // the APIs older Android versions need
|
|
12
|
+
object SystemBars {
|
|
13
|
+
/**
|
|
14
|
+
* Screens draw under the bars, which SafeAreaView and headers pad for: the default from Android 15,
|
|
15
|
+
* and the same on older versions instead of a gray status bar.
|
|
16
|
+
*/
|
|
17
|
+
fun drawBehind(window: Window) {
|
|
18
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM) return
|
|
19
|
+
|
|
20
|
+
window.setDecorFitsSystemWindows(false)
|
|
21
|
+
window.statusBarColor = Color.TRANSPARENT
|
|
22
|
+
window.navigationBarColor = Color.TRANSPARENT
|
|
23
|
+
window.attributes.layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** Dark icons on light screens, light icons on dark ones. */
|
|
27
|
+
fun setLight(window: Window, isLight: Boolean) {
|
|
28
|
+
val lightBars = WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS or
|
|
29
|
+
WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS
|
|
30
|
+
window.insetsController?.setSystemBarsAppearance(if (isLight) lightBars else 0, lightBars)
|
|
31
|
+
|
|
32
|
+
// Android 11 keeps the theme's light-bar flags over setSystemBarsAppearance: they're set too.
|
|
33
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) return
|
|
34
|
+
|
|
35
|
+
val decorView = window.decorView
|
|
36
|
+
val flags = View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR or View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR
|
|
37
|
+
decorView.systemUiVisibility =
|
|
38
|
+
if (isLight) decorView.systemUiVisibility or flags else decorView.systemUiVisibility and flags.inv()
|
|
39
|
+
}
|
|
40
|
+
}
|