Navigation bar buttons are visible.#20963
Conversation
sanjaysargam
left a comment
There was a problem hiding this comment.
Thanks for the PR @Galal-20 .
Tested in my Xiamo, works perfectly
There was a problem hiding this comment.
I don't feel the second commit is necessary and I would push to drop it unless you noticed/profiled a significant difference. I suspect it's less than a millisecond in perf for additional code complexity, UI tags etc...
The accessor can stay if you like it. I'd consider defining withInsets { } for even more brevity
Please test on API 29 (Android 10) and API 24.
There are differences in the navigation bar implementation on API 30 and 26
I have simplified the implementation by removing the caching and UI tags as suggested. I tested API 29 Android 10 and 24, it's good pr.mp4 |
david-allison
left a comment
There was a problem hiding this comment.
Awesome! Please squash commit 2 and 3
| viewModel.showingAnswer.collectLatestIn(lifecycleScope) { isAnswerShown -> | ||
| if (isAnswerShown) { | ||
| insetsController.hide(WindowInsetsCompat.Type.ime()) | ||
| withInsets { hide(WindowInsetsCompat.Type.ime()) } |
There was a problem hiding this comment.
no need for a single line - with makes sense for multi-line
| } | ||
|
|
||
| with(requireAnkiActivity().windowInsetsController) { | ||
| withInsets { |
| fun FragmentActivity.doOnImeHidden(block: () -> Unit) { | ||
| val view = window.decorView | ||
| windowInsetsControllerCompat.hide(WindowInsetsCompat.Type.ime()) | ||
| withInsets { hide(WindowInsetsCompat.Type.ime()) } |
| ) | ||
| // hide system bars | ||
| with(WindowInsetsControllerCompat(window, window.decorView)) { | ||
| with(requireAnkiActivity().windowInsetsController) { |
There was a problem hiding this comment.
Surprised this isn't using withInsets, but OK
| val insetsController = windowInsetsControllerCompat | ||
| if (hasFocus) { | ||
| insetsController.show(WindowInsetsCompat.Type.ime()) | ||
| } else { | ||
| insetsController.hide(WindowInsetsCompat.Type.ime()) | ||
| } |
There was a problem hiding this comment.
nit: windowInsetsControllerCompat.show(WindowInsetsCompat.Type.ime()) and remove the var, it's called once on each code path
refactor: Cache and centralize WindowInsetsControllerCompat access - Use cached extension properties to avoid redundant allocations. - Ensure efficient reuse during theme changes and UI updates.
9caa2b0 to
068f90b
Compare
Purpose / Description
On some devices, especially Xiaomi devices running MIUI/HyperOS and Android 12 , the navigation bar buttons Back, Home, and Recent were either completely barely visible when the app was in Light Mode.
This happened because when the backdrop was light such as white or light gray, the system did not instantly change the navigation bar icons to a dark color.
Fixes
Approach
How Has This Been Tested?
Checklist