Fix bubble position when dragged to dismiss view
When moving a bubble to dismiss view, use the drag translation x methods to set the translation x values. When bubble is moved to the dismiss view, the container will animate back to the initial position. And we need to account for this while bubble is in the dismiss view. Bug: 339659499 Flag: com.android.wm.shell.enable_bubble_bar Test: manual, drag bubble to other side and then to dismiss view, observe that bar moves back to original side and bubble is at the center of the dismiss view Change-Id: I4c6e1be2dcd1180d985ceafccfc0f18466549347
This commit is contained in:
@@ -24,6 +24,7 @@ import android.view.ViewConfiguration;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.dynamicanimation.animation.FloatPropertyCompat;
|
||||
|
||||
import com.android.launcher3.taskbar.TaskbarActivityContext;
|
||||
import com.android.wm.shell.common.bubbles.BaseBubblePinController.LocationChangeListener;
|
||||
@@ -38,6 +39,37 @@ import com.android.wm.shell.common.bubbles.BubbleBarLocation;
|
||||
* Restores initial position of dragged view if released outside of the dismiss target.
|
||||
*/
|
||||
public class BubbleDragController {
|
||||
|
||||
/**
|
||||
* Property to update dragged bubble x-translation value.
|
||||
* <p>
|
||||
* When applied to {@link BubbleView}, will use set the translation through
|
||||
* {@link BubbleView#getDragTranslationX()} and {@link BubbleView#setDragTranslationX(float)}
|
||||
* methods.
|
||||
* <p>
|
||||
* When applied to {@link BubbleBarView}, will use {@link View#getTranslationX()} and
|
||||
* {@link View#setTranslationX(float)}.
|
||||
*/
|
||||
public static final FloatPropertyCompat<View> DRAG_TRANSLATION_X = new FloatPropertyCompat<>(
|
||||
"dragTranslationX") {
|
||||
@Override
|
||||
public float getValue(View view) {
|
||||
if (view instanceof BubbleView bubbleView) {
|
||||
return bubbleView.getDragTranslationX();
|
||||
}
|
||||
return view.getTranslationX();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(View view, float value) {
|
||||
if (view instanceof BubbleView bubbleView) {
|
||||
bubbleView.setDragTranslationX(value);
|
||||
} else {
|
||||
view.setTranslationX(value);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private final TaskbarActivityContext mActivity;
|
||||
private BubbleBarController mBubbleBarController;
|
||||
private BubbleBarViewController mBubbleBarViewController;
|
||||
|
||||
Reference in New Issue
Block a user