F0x1d / LogFox

Yet another LogCat reader for Android
GNU General Public License v3.0
605 stars 32 forks source link

[Bug] Broken navigation bar background #129

Closed Jesse205 closed 4 months ago

Jesse205 commented 4 months ago
Snipaste_2024-06-30_18-07-46

The navigation bar in the BottomSheet is not clear. I previously submitted a PR to fix this issue. On the dev branch, logfox uses the ComponentActivity.enableEdgeToEdge recommended by Google, but it does not take into account the situation in the BottomSheet

Jesse205 commented 4 months ago

Translated

Situations to Consider

System Behaviors

  1. Light-colored status bars have been supported since Android 6.0 (LogFox's minsdk is 24, so this situation can be disregarded)
  2. Light-colored navigation bars have been supported since Android 8.0
  3. Huawei devices have gray icons as the default for the navigation bar
  4. The background of the status bar on Xiaomi devices with FLAG_TRANSLUCENT_STATUS is fully transparent (LogFox's minsdk is 24, so this situation can be disregarded)
  5. On devices that do not support dynamic color gesture navigation, if isNavigationBarContrastEnforced is enabled, the small white bar will also be given a semi-transparent background
  6. On devices that support dynamic color gesture navigation, if isNavigationBarContrastEnforced is enabled, the small white bar will not be given a semi-transparent background, but the navigation bar will be given a semi-transparent white/black background (which does not match the window background and looks particularly ugly)
  7. In Android 15, navigationBarColor and statusBarColor have been deprecated, and apps will always be displayed in EdgeToEdge mode.
  8. The navigation bar may appear on the left, right, or bottom of the screen.

My Thoughts

  1. Always enable layoutInDisplayCutoutMode to maintain consistency with Android 15
  2. If the device supports light-colored navigation bars, create an empty View at the bottom of the layout specifically to serve as the background for the navigation bar. If the user enables gesture navigation, hide or set this View to transparent (this can also solve the animation issue when showing or hiding the bottom navigation bar); if the device does not support light-colored navigation bars, directly set the navigation bar to semi-transparent black.
  3. Avoid gray backgrounds as much as possible (as old Huawei devices may not be able to see clearly)
  4. Avoid using FLAG_TRANSLUCENT_STATUS as much as possible (as old Xiaomi devices may not be able to see clearly)

Origin content

要考虑的情况

系统行为

  1. 亮色状态栏从Android 6.0开始支持(LogFox的minsdk为24,所以可以不考虑这个情况)
  2. 亮色导航栏从Android 8.0开始支持
  3. 华为设备的导航栏默认为灰色图标
  4. 小米设备的状态栏的FLAG_TRANSLUCENT_STATUS的背景为完全透明(LogFox的minsdk为24,所以可以不考虑这个情况)
  5. 在不支持动态颜色手势导航的设备,如果启用了isNavigationBarContrastEnforced,小白条也会被添加半透明背景
  6. 在支持动态颜色手势导航的设备,如果启用了isNavigationBarContrastEnforced,小白条不会被添加半透明背景,但导航栏会被添加一个白色\黑色的半透明背景 (并非匹配窗口背景,特别丑)
  7. Android 15 中,navigationBarColorstatusBarColor 已被弃用,应用始终会以EdgeToEdge方式显示。
  8. 导航栏可能会出现在屏幕左侧、右侧、底部

我的想法

  1. 要始终启用layoutInDisplayCutoutMode,与Android15保持一致
  2. 设备支持亮色导航栏,在布局底部建立一个空白View,专门充当导航栏的背景,如果用户启用了手势导航或者,就将这个View隐藏或者设置为透明(这样也可以解决显示或者隐藏底部导航栏时候导航栏颜色的动画);如果设备不支持亮色导航栏,就直接将导航栏设置为半透明黑色
  3. 尽量避免灰色背景(华为旧设备会看不清)
  4. 尽量避免使用FLAG_TRANSLUCENT_STATUS(小米旧设备会看不清)