Fixed
Status Update
Comments
ap...@google.com <ap...@google.com> #2
Project: platform/frameworks/support
Branch: androidx-main
commit 45b68bbb181cd8aa3e04fc2025bb42f854a21a29
Author: Jeremy Woods <jbwoods@google.com>
Date: Wed Aug 09 22:54:43 2023
Fix an issue with popping the last back stack entry
When using predictive back if you pop the last entry on the back stack,
attempting to go back to the first fragment, the app will skip the first
fragment and then destroy the activity.
This happens because when predictive back starts a back gesture, the
transition in progress is no longer includes as part of the back stack
count, which cause the fragment manager to prematurely disabled its
onBackCallback thinking that it has no entries and then it finishes the
activity instead of going back.
We should ensure we continue to consider the transitioning operations as
part of the back stack while transitioning.
RelNote: "Fixed an issue with predictive back that causes the Activity
to be finished, before ever seeing the first fragment in the fragment
manager."
Test: added PredictiveBackTest
Bug: 295231788
Fixes: 295168369
Change-Id: I0664b44dd7f6dc49bafb932e3ae47f1aba483fd6
A fragment/fragment/src/androidTest/java/androidx/fragment/app/PredictiveBackTest.kt
M fragment/fragment/src/main/java/androidx/fragment/app/FragmentManager.java
https://android-review.googlesource.com/2701995
Branch: androidx-main
commit 45b68bbb181cd8aa3e04fc2025bb42f854a21a29
Author: Jeremy Woods <jbwoods@google.com>
Date: Wed Aug 09 22:54:43 2023
Fix an issue with popping the last back stack entry
When using predictive back if you pop the last entry on the back stack,
attempting to go back to the first fragment, the app will skip the first
fragment and then destroy the activity.
This happens because when predictive back starts a back gesture, the
transition in progress is no longer includes as part of the back stack
count, which cause the fragment manager to prematurely disabled its
onBackCallback thinking that it has no entries and then it finishes the
activity instead of going back.
We should ensure we continue to consider the transitioning operations as
part of the back stack while transitioning.
RelNote: "Fixed an issue with predictive back that causes the Activity
to be finished, before ever seeing the first fragment in the fragment
manager."
Test: added PredictiveBackTest
Bug: 295231788
Fixes: 295168369
Change-Id: I0664b44dd7f6dc49bafb932e3ae47f1aba483fd6
A fragment/fragment/src/androidTest/java/androidx/fragment/app/PredictiveBackTest.kt
M fragment/fragment/src/main/java/androidx/fragment/app/FragmentManager.java
jb...@google.com <jb...@google.com> #3
This has been fixed internally and will be in the Fragment 1.7.0-alpha03
release.
Description
If you add Fragment A to the fragment manager without adding to back stack then you add fragment B to the fragment manager with adding to the back stack. When you attempt to use either System or Gesture back to go back to Fragment A, fragment manager incorrectly finishes the Activity.
The reason for this is that when fragment manager starts the predictive back gesture, it immediately removes the transitioning operation from the back stack, then updates the enabled state of its onBackPressedCallback causing it to be disabled. Since there are no enabled callbacks in the onBackPressedDispatcher, it immediately finishes the Activity.
We should still considering the transitioning operation as part of the backstack until it completes.