Skip to content
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

Upgrade DrawerLayout to 1.2.0 and simplify code #4412

Merged
merged 3 commits into from May 10, 2024

Conversation

cbeyls
Copy link
Contributor

@cbeyls cbeyls commented May 3, 2024

The main benefit of upgrading to version 1.2.0 of DrawerLayout is to properly support predictive back animations: when initiating a back gesture on API 33+, the DrawerLayout will animate automatically to handle back navigation automatically. The predictive back animation of the menu however depends on NavigationView which is not used in the project.

In addition to the upgrade, simplify DrawerLayout integration:

  • Forward key events to the DrawerLayout so it can intercept them and close itself when needed.
  • Don't handle the DrawerLayout closing manually using the OnBackPressedCallback anymore. This is not necessary since the back event will now be intercepted by the DrawerLayout when needed before reaching the OnBackPressedDispatcher.
  • Remove legacy fix for DrawerLayout staying open after Activity recreation.

@connyduck
Copy link
Collaborator

properly support predictive back animations: when initiating a back gesture on API 33+, the DrawerLayout will animate automatically

That would be super cool but it doesn't do anything here (Api 34 emulator, predictive back enabled, this branch) 🙁

Screen_recording_20240510_161254.mp4

# Conflicts:
#	gradle/libs.versions.toml
@cbeyls
Copy link
Contributor Author

cbeyls commented May 10, 2024

properly support predictive back animations: when initiating a back gesture on API 33+, the DrawerLayout will animate automatically

That would be super cool but it doesn't do anything here (Api 34 emulator, predictive back enabled, this branch) 🙁
Screen_recording_20240510_161254.mp4

Indeed it turns out the DrawerLayout properly handles the back gesture but the animation part is handled by NavigationView from the Material Components library. Tusky uses the MaterialDrawer library from Mike Penz instead, which doesn't support this feature (even in the newest version apparently).

It's still worth the change for the simpler code I think.

Copy link
Collaborator

@connyduck connyduck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, definitely

@connyduck connyduck merged commit 11d18e1 into tuskyapp:develop May 10, 2024
3 checks passed
@cbeyls cbeyls deleted the chore/drawerlayout_1.2.0 branch May 10, 2024 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants