-
-
Notifications
You must be signed in to change notification settings - Fork 389
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Full support for Android 15, edge-to-edge mode on Android 15 #4897
base: develop
Are you sure you want to change the base?
Conversation
Looks complicated. :-) Some views need fine-tuning with this, I guess. |
There is a weird bug on this branch, when switching to a tab for the first time, it stays empty until touched. Can anybody else reproduce that? |
(contentView.layoutParams as ViewGroup.MarginLayoutParams).leftMargin = displayCutoutInsets.left | ||
(contentView.layoutParams as ViewGroup.MarginLayoutParams).rightMargin = displayCutoutInsets.right | ||
|
||
WindowInsetsCompat.Builder(insets) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's probably simpler and more future-proof to build the new insets by calling insets.inset(insets.left, 0, insets.right, 0)
, which will modify all the inset types at once.
val displayCutoutInsets = insets.getInsets(displayCutout()) | ||
// use padding for system bar insets so they get our background color and margin for cutout insets to turn them black | ||
contentView.updatePadding(left = systemBarInsets.left, right = systemBarInsets.right) | ||
(contentView.layoutParams as ViewGroup.MarginLayoutParams).leftMargin = displayCutoutInsets.left |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The proper way to update layout params is to set the layout params on the View again after modifying them, otherwise changes may not be visible if the view is already laid out. updateLayoutParams()
extension method does that for you.
About the dependencies that were blocked because they require API 35: it's perfectly safe to upgrade the compileSdk version to be compatible with new Google libraries without changing the targetSdk version. You can always implement the new enforced behaviors later. Androidx libraries actually check both the platform SDK int and the target SDK version to ensure the correct behavior is applied. |
Can you post a screenshot to show horizontal padding and insets in landscape mode? I'm curious to see how the drawer menu looks like and where it's drawn. |
Edge-to-edge mode means that we now draw under the status bar and the navigation bar and need to make sure we don't overlap with them. Previously the system would do that for us, and we would only provide the color we want the bars in.
For the edge-to-edge mode there are two Apis that are important:
fitsSystemWindows
- some Widgets, mostly from the Material library, automatically handle system insets if you set this attribute on them to trueViewCompat.setOnApplyWindowInsetsListener
- this allows you to manually handle the various insets. By returning new insets from the callback it is possible to tell the system which ones are handled and which ones should be taken care of by another view.In most places edge-to-edge was straightforward to implement, except in
ComposeActivity
,AccountActivity
andMainActivity
which required a more custom approach, and a hacky solution to make landscape mode work inBaseActivity
.There is also the
ViewCompat.setWindowInsetsAnimationCallback
Api which allows animating with moving insets. I used that inLoginActivity
andComposeActivity
to animate the Views together with the keyboard.On Android Versions below 15 (Api <= 34) Tusky will look almost the same as before. I think the only exception is the main bottom bar, which is now slighty larger. We customized it to be smaller than the default, but in edge-to-edge mode the height needs to be
wrap_content
or it won't handle insets correctly.Screenshots: