Fix translucent navbar for Android 10 #38
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When the status bar is not hidden (i.e.
StfalconImageViewer.Builder().withHiddenStatusBar(false)
), past behavior was for thenavigation bar to be translucent. On Android 10 (SDK 29), it is opaque
black. See screenshot below, Android 9 on left and Android 10 on right
This patch restores and improves upon past behavior for Android 10 by
ensuring a fully transparent nav bar when gesture controls are enabled
(and using the system-provided translucent scrim when 3-button navigation
is enabled). See screenshot below, Android 9 on left,
Android 10 center and right with three-button and gesture navigation.
I'm not 100% sure I've done this in the optimal way, but here's what I've found:
To achieve this we need to switch from using
android:windowTranslucentNavigation to using android:navigationBarColor.
On Android 10, it appears android:windowDrawsSystemBarBackgrounds
must be set for android:navigationBarColor to have any affect.
(I wonder if this is related to using an AlertDialog.)
android:windowDrawsSystemBarBackgrounds is not supported in SDK < 21,
whereas this library supports SDK >= 19, so I've created a separate
styles.xml file for SDK >= 29.
Setting systemUiVisibility flags appears to be necessary to get
the transparent nav bar effect. It seems that setting
android:windowTranslucentNavigation was providing the same effect
as setting these flags, but now it needs to be done manually for
SDK >= 29 as android:windowTranslucentNavigation is not set.