Fixed
Status Update
Comments
d....@gmail.com <d....@gmail.com> #2
Project: platform/frameworks/support
Branch: androidx-main
commit b6c7c78f9e7476b468dafe9d5f7dec6794d47f09
Author: Shahd AbuDaghash <shahddaghash@google.com>
Date: Mon Nov 27 11:16:51 2023
Introduce DecayAnimation in AnchoredDraggable
Decay animation allows more realistic settling of a component. This is performed by now passing a `DecayAnimationSpec` parameter to AnchoredDraggable and using it when animating to the target. The new animation implementation will be added in a chain CL.
Bug: 288084801
Test: Tests will be added in a chain CL
Relnote: This change adds a `decayAnimationSpec` parameter to AnchoredDraggable allowing to use decay animation when settling to one of the anchors. The change also includes renaming the existing `animationSpec` to `snapAnimationSpec` to help understanding the use case of each spec.
Change-Id: I44ccd408d919328fd6504d31d8db59cf1d07de43
M compose/foundation/foundation/api/current.txt
M compose/foundation/foundation/api/restricted_current.txt
M compose/foundation/foundation/samples/src/main/java/androidx/compose/foundation/samples/AnchoredDraggableSample.kt
M compose/foundation/foundation/src/androidInstrumentedTest/kotlin/androidx/compose/foundation/anchoredDraggable/AnchoredDraggableGestureTest.kt
M compose/foundation/foundation/src/androidInstrumentedTest/kotlin/androidx/compose/foundation/anchoredDraggable/AnchoredDraggableStateTest.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/gestures/AnchoredDraggable.kt
https://android-review.googlesource.com/2847074
Branch: androidx-main
commit b6c7c78f9e7476b468dafe9d5f7dec6794d47f09
Author: Shahd AbuDaghash <shahddaghash@google.com>
Date: Mon Nov 27 11:16:51 2023
Introduce DecayAnimation in AnchoredDraggable
Decay animation allows more realistic settling of a component. This is performed by now passing a `DecayAnimationSpec` parameter to AnchoredDraggable and using it when animating to the target. The new animation implementation will be added in a chain CL.
Bug: 288084801
Test: Tests will be added in a chain CL
Relnote: This change adds a `decayAnimationSpec` parameter to AnchoredDraggable allowing to use decay animation when settling to one of the anchors. The change also includes renaming the existing `animationSpec` to `snapAnimationSpec` to help understanding the use case of each spec.
Change-Id: I44ccd408d919328fd6504d31d8db59cf1d07de43
M compose/foundation/foundation/api/current.txt
M compose/foundation/foundation/api/restricted_current.txt
M compose/foundation/foundation/samples/src/main/java/androidx/compose/foundation/samples/AnchoredDraggableSample.kt
M compose/foundation/foundation/src/androidInstrumentedTest/kotlin/androidx/compose/foundation/anchoredDraggable/AnchoredDraggableGestureTest.kt
M compose/foundation/foundation/src/androidInstrumentedTest/kotlin/androidx/compose/foundation/anchoredDraggable/AnchoredDraggableStateTest.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/gestures/AnchoredDraggable.kt
am...@google.com <am...@google.com> #3
Project: platform/frameworks/support
Branch: androidx-main
commit 365993d1a90c27704b71f6bee042a1749314a4b1
Author: Shahd AbuDaghash <shahddaghash@google.com>
Date: Tue Nov 28 10:49:56 2023
Add tests for Animation in AnchoredDraggable
Added tests to check for different settling behaviors.
Bug: 288084801
Test: Added tests to verify behavior.
Change-Id: I369b30c69f7c29f676ae0671fef25c38ff3c74cb
M compose/foundation/foundation/src/androidInstrumentedTest/kotlin/androidx/compose/foundation/anchoredDraggable/AnchoredDraggableStateTest.kt
https://android-review.googlesource.com/2847475
Branch: androidx-main
commit 365993d1a90c27704b71f6bee042a1749314a4b1
Author: Shahd AbuDaghash <shahddaghash@google.com>
Date: Tue Nov 28 10:49:56 2023
Add tests for Animation in AnchoredDraggable
Added tests to check for different settling behaviors.
Bug: 288084801
Test: Added tests to verify behavior.
Change-Id: I369b30c69f7c29f676ae0671fef25c38ff3c74cb
M compose/foundation/foundation/src/androidInstrumentedTest/kotlin/androidx/compose/foundation/anchoredDraggable/AnchoredDraggableStateTest.kt
an...@gmail.com <an...@gmail.com> #4
Project: platform/frameworks/support
Branch: androidx-main
commit ff1a600df5f4d8ae21a75d8e3e0f24d6c5c2faee
Author: Shahd AbuDaghash <shahddaghash@google.com>
Date: Mon Nov 27 15:51:12 2023
Modify settle function to perform decay animation if possible
When settling, a check will be performed to see if natural decay animation can be used. If not so, a target animation will be used. The consumed velocity is returned to the settle function, which could be used to show an overscroll effect.
Bug: 288084801
Test: Tests will be added in a chain CL.
Relnote: This change introduces a new `animateToWithDecay` function that naturally decays if possible. It takes the target value and the initial velocity. The `animateTo` functions no longer takes a velocity, but passes the available velocity in `lastVelocity` to animation, as it is concerned with reaching the target. If users need to pass a certain velocity for animation, they can use `animateToWithDecay` function.
Change-Id: I465dbd826e3969b784d08c65425f4bbda3de8493
M compose/foundation/foundation/api/current.txt
M compose/foundation/foundation/api/restricted_current.txt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/gestures/AnchoredDraggable.kt
https://android-review.googlesource.com/2847576
Branch: androidx-main
commit ff1a600df5f4d8ae21a75d8e3e0f24d6c5c2faee
Author: Shahd AbuDaghash <shahddaghash@google.com>
Date: Mon Nov 27 15:51:12 2023
Modify settle function to perform decay animation if possible
When settling, a check will be performed to see if natural decay animation can be used. If not so, a target animation will be used. The consumed velocity is returned to the settle function, which could be used to show an overscroll effect.
Bug: 288084801
Test: Tests will be added in a chain CL.
Relnote: This change introduces a new `animateToWithDecay` function that naturally decays if possible. It takes the target value and the initial velocity. The `animateTo` functions no longer takes a velocity, but passes the available velocity in `lastVelocity` to animation, as it is concerned with reaching the target. If users need to pass a certain velocity for animation, they can use `animateToWithDecay` function.
Change-Id: I465dbd826e3969b784d08c65425f4bbda3de8493
M compose/foundation/foundation/api/current.txt
M compose/foundation/foundation/api/restricted_current.txt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/gestures/AnchoredDraggable.kt
am...@google.com <am...@google.com> #5
Project: platform/frameworks/support
Branch: androidx-main
commit 01142ddd5b14eb33e5145c4e72e6619a5c100fe4
Author: Shahd AbuDaghash <shahddaghash@google.com>
Date: Thu Dec 21 12:34:00 2023
Introduce Overscroll in AnchoredDraggable
Adding overscroll support to AnchoredDraggable by giving the ability to pass a customized overscrollEffect object to AnchoredDraggable.
Bug: 288084801
Relnote: An OverscrollEffect has been introduced to allow for custom overscroll effects in anchoredDraggable. To retrieve the consumed velocity after animation, the consumed velocity is returned from the settle function.
Test: Added tests to verify behavior
Change-Id: I100683fe7473b1e5ff317ab22245a2b0a25bd549
M compose/foundation/foundation/api/current.txt
M compose/foundation/foundation/api/restricted_current.txt
M compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/AnchoredDraggableDemo.kt
M compose/foundation/foundation/samples/src/main/java/androidx/compose/foundation/samples/AnchoredDraggableSample.kt
A compose/foundation/foundation/src/androidInstrumentedTest/kotlin/androidx/compose/foundation/anchoredDraggable/AnchoredDraggableOverscrollTest.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/gestures/AnchoredDraggable.kt
https://android-review.googlesource.com/2888106
Branch: androidx-main
commit 01142ddd5b14eb33e5145c4e72e6619a5c100fe4
Author: Shahd AbuDaghash <shahddaghash@google.com>
Date: Thu Dec 21 12:34:00 2023
Introduce Overscroll in AnchoredDraggable
Adding overscroll support to AnchoredDraggable by giving the ability to pass a customized overscrollEffect object to AnchoredDraggable.
Bug: 288084801
Relnote: An OverscrollEffect has been introduced to allow for custom overscroll effects in anchoredDraggable. To retrieve the consumed velocity after animation, the consumed velocity is returned from the settle function.
Test: Added tests to verify behavior
Change-Id: I100683fe7473b1e5ff317ab22245a2b0a25bd549
M compose/foundation/foundation/api/current.txt
M compose/foundation/foundation/api/restricted_current.txt
M compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/AnchoredDraggableDemo.kt
M compose/foundation/foundation/samples/src/main/java/androidx/compose/foundation/samples/AnchoredDraggableSample.kt
A compose/foundation/foundation/src/androidInstrumentedTest/kotlin/androidx/compose/foundation/anchoredDraggable/AnchoredDraggableOverscrollTest.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/gestures/AnchoredDraggable.kt
d....@gmail.com <d....@gmail.com> #6
Project: platform/frameworks/support
Branch: androidx-main
commit 0f071d797bccf7eff2a23e408928ca76640af782
Author: Shahd AbuDaghash <shahddaghash@google.com>
Date: Wed Nov 29 18:34:09 2023
Migrates AnchoredDraggable to Modifier.Node
Migrates AnchoredDraggable to Modifier.Node. This helps in adding Overscroll effect in AnchoredDraggable.
Bug: 288084801
Test: Added tests to verify behavior
Change-Id: I3f3338cd71763972c4b70f2e06c97e85285b0035
M compose/foundation/foundation/src/androidInstrumentedTest/kotlin/androidx/compose/foundation/anchoredDraggable/AnchoredDraggableGestureTest.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/gestures/AnchoredDraggable.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/gestures/Draggable.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/gestures/Draggable2D.kt
https://android-review.googlesource.com/2852691
Branch: androidx-main
commit 0f071d797bccf7eff2a23e408928ca76640af782
Author: Shahd AbuDaghash <shahddaghash@google.com>
Date: Wed Nov 29 18:34:09 2023
Migrates AnchoredDraggable to Modifier.Node
Migrates AnchoredDraggable to Modifier.Node. This helps in adding Overscroll effect in AnchoredDraggable.
Bug: 288084801
Test: Added tests to verify behavior
Change-Id: I3f3338cd71763972c4b70f2e06c97e85285b0035
M compose/foundation/foundation/src/androidInstrumentedTest/kotlin/androidx/compose/foundation/anchoredDraggable/AnchoredDraggableGestureTest.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/gestures/AnchoredDraggable.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/gestures/Draggable.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/gestures/Draggable2D.kt
d....@gmail.com <d....@gmail.com> #7
This issue is marked as fixed, but there is still no replacement for ResistanceConfig
.
How should we properly migrate it?
am...@google.com <am...@google.com> #8
Can we document this / update the migration guide?
d....@gmail.com <d....@gmail.com> #9
Hi,
As I said above, this is not fixed and you can easily test this with the project of my first post, just by changing the support library version. I can create another issue if necessary, but I think this should not be marked as "released".
As I said above, this is not fixed and you can easily test this with the project of my first post, just by changing the support library version. I can create another issue if necessary, but I think this should not be marked as "released".
do...@gmail.com <do...@gmail.com> #10
Agree with #9. Got the same problem here. reverting to 25.0.1.
gi...@gmail.com <gi...@gmail.com> #11
Same issue here. Frequency of the problem went down a bit, but it still happens.
tw...@gmail.com <tw...@gmail.com> #12
Same issue when using .replace() instead of .remove(). 25.1.1
mr...@gmail.com <mr...@gmail.com> #13
Remove setCustomAnimations(...) could fix this bug
[Deleted User] <[Deleted User]> #14
Thank you #4, you helped me work around this bug! This bug is indeed still there even in 25.3.1
[Deleted User] <[Deleted User]> #15
This bug is still there in 25.4.0 and 26.0.1. Might need to revert to 25.3.1
[Deleted User] <[Deleted User]> #16
This is an app-breaking issue, still present in 26.0.1.
Using the latest 26 API you might find the following activity-level fix helpful, put it in Activity onCreate:
getSupportFragmentManager().registerFragmentLifecycleCallbacks(fixFragmentLifecycleCallbacks, true);
Put this in your activity:
private final FragmentManager.FragmentLifecycleCallbacks fixFragmentLifecycleCallbacks = new FragmentManager.FragmentLifecycleCallbacks() {
@Override
public void onFragmentStopped(FragmentManager fm, Fragment f) {
ViewGroup vg = getParentContainer(f);
if (vg != null) {
//https://issuetracker.google.com/issues/37130477
// Workaround as this is not fixed as of 26.0.1. The previous working version was 25.3.1.
// To reproduce this issue, find any fragment transaction with an animation that takes time.
// As soon as the fragment transaction starts, quickly press the recent tasks button
// to minimise the app. See that when you return there is a "Ghost fragment" and the
// view is now unusable.
vg.clearDisappearingChildren();
}
}
@Nullable
private ViewGroup getParentContainer(Fragment f) {
View fv = f.getView();
if (fv != null) {
ViewParent vp = fv.getParent();
if (vp instanceof ViewGroup) {
return (ViewGroup) vp;
}
}
return null;
}
};
Using the latest 26 API you might find the following activity-level fix helpful, put it in Activity onCreate:
getSupportFragmentManager().registerFragmentLifecycleCallbacks(fixFragmentLifecycleCallbacks, true);
Put this in your activity:
private final FragmentManager.FragmentLifecycleCallbacks fixFragmentLifecycleCallbacks = new FragmentManager.FragmentLifecycleCallbacks() {
@Override
public void onFragmentStopped(FragmentManager fm, Fragment f) {
ViewGroup vg = getParentContainer(f);
if (vg != null) {
//
// Workaround as this is not fixed as of 26.0.1. The previous working version was 25.3.1.
// To reproduce this issue, find any fragment transaction with an animation that takes time.
// As soon as the fragment transaction starts, quickly press the recent tasks button
// to minimise the app. See that when you return there is a "Ghost fragment" and the
// view is now unusable.
vg.clearDisappearingChildren();
}
}
@Nullable
private ViewGroup getParentContainer(Fragment f) {
View fv = f.getView();
if (fv != null) {
ViewParent vp = fv.getParent();
if (vp instanceof ViewGroup) {
return (ViewGroup) vp;
}
}
return null;
}
};
[Deleted User] <[Deleted User]> #17
You can of course register the above generically app-wide, using Application.ActivityLifecycleCallbacks, and the onActivityCreated callback it gives you:
In your application:
app.registerActivityLifecycleCallbacks(lifecycleCallbacks);
Elsewhere in your application:
private final Application.ActivityLifecycleCallbacks lifecycleCallbacks = new Application.ActivityLifecycleCallbacks() {
@Override
public void onActivityCreated(Activity activity, Bundle bundle) {
// Note that AppCompatActivity extends FragmentActivity
if (activity instanceof FragmentActivity) {
FragmentActivity supportActivity = (FragmentActivity) activity;
FragmentManager fm = supportActivity.getSupportFragmentManager();
fm.registerFragmentLifecycleCallbacks(fixFragmentLifecycleCallbacks, true);
}
}
...
};
In your application:
app.registerActivityLifecycleCallbacks(lifecycleCallbacks);
Elsewhere in your application:
private final Application.ActivityLifecycleCallbacks lifecycleCallbacks = new Application.ActivityLifecycleCallbacks() {
@Override
public void onActivityCreated(Activity activity, Bundle bundle) {
// Note that AppCompatActivity extends FragmentActivity
if (activity instanceof FragmentActivity) {
FragmentActivity supportActivity = (FragmentActivity) activity;
FragmentManager fm = supportActivity.getSupportFragmentManager();
fm.registerFragmentLifecycleCallbacks(fixFragmentLifecycleCallbacks, true);
}
}
...
};
Description
Version used: 25.1.0
Theme used: Theme.AppCompat.Light.DarkActionBar
Devices/Android versions reproduced on: every devices I tested on, for example : Sony Xperia Z3 tablet, Samsung Galaxy Tab S2.
It seems related to other issues being reported about fragment replace transactions, but this one does not use the replace method.
Steps to reproduce :
- Add a fragment with a simple transaction :
getSupportFragmentManager()
.beginTransaction()
.setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out)
.add(R.id.fragment_container, new TestFragment())
.commit()
- Remove the fragment using a simple remove, and just after start a new activity :
final Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.fragment_container);
if (fragment != null) {
getSupportFragmentManager()
.beginTransaction()
.setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out)
.remove(fragment)
.commit();
startActivity(new Intent(this, MainActivity.class));
}
- Go back to the old activity
What should happen : the fragment that was added should not be here anymore.
What happens : the fragment is still here. But the thing is it's only some sort of "ghost view" : it's impossible to reach it in debug using the view hierarchy. I even tried to activate the debug option "show layout bounds", which does not shows the bound on the fragment view. The view is not clickable, if I call removeAllViews() on the container it's still here.
Another thing : even with this view still here, if I re-add a fragment it will be added below the "ghost view". Everything works, but the old view is still here.
I attached a sample project to reproduce this issue. The "remove fragment" button is just here to validate the behaviour without starting another activity. You can see the bug using :
- "Add fragment"
- "Remove fragment and start activity"
- Press the back button
The old fragment is still here. If you press the add fragment button, another fragment will appear behing the old fragment, which should not be possible.
If you use the "show layout bounds" option, the bug is really visible :
- Start from scratch (kill the app)
- "Add fragment"
- Enable the "show layout bounds" option.
- "Remove fragment and start activity"
- Press the back button
Here everything seems normal except for the fragment still being here. But if you disable the "show layout bounds" option, the fragment view will stay unchanged, with layout bounds displayed. As if it were a cached view not recognized by the system.
I also attached a screenshot of this behavior. You can see the "show layout bounds" option is disabled, but it still shows on the fragment view.
All this does not happen with support lib 25.0.1.