summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java9
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/bar/BubbleBarExpandedView.java3
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/bar/BubbleBarExpandedViewDragController.kt40
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/bar/BubbleBarLayerView.java34
4 files changed, 70 insertions, 16 deletions
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java
index e74e578dc213..249f52bd6156 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java
@@ -1280,7 +1280,14 @@ public class BubbleController implements ConfigurationChangeListener,
* Dismiss bubble if it exists and remove it from the stack
*/
public void dismissBubble(Bubble bubble, @Bubbles.DismissReason int reason) {
- mBubbleData.dismissBubbleWithKey(bubble.getKey(), reason);
+ dismissBubble(bubble.getKey(), reason);
+ }
+
+ /**
+ * Dismiss bubble with given key if it exists and remove it from the stack
+ */
+ public void dismissBubble(String key, @Bubbles.DismissReason int reason) {
+ mBubbleData.dismissBubbleWithKey(key, reason);
}
/**
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/bar/BubbleBarExpandedView.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/bar/BubbleBarExpandedView.java
index 50e1f7311ce0..d073f1df938a 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/bar/BubbleBarExpandedView.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/bar/BubbleBarExpandedView.java
@@ -67,7 +67,6 @@ public class BubbleBarExpandedView extends FrameLayout implements BubbleTaskView
private boolean mIsOverflow;
private BubbleTaskViewHelper mBubbleTaskViewHelper;
private BubbleBarMenuViewController mMenuViewController;
- private BubbleBarExpandedViewDragController mDragController;
private @Nullable Supplier<Rect> mLayerBoundsSupplier;
private @Nullable Listener mListener;
@@ -181,8 +180,6 @@ public class BubbleBarExpandedView extends FrameLayout implements BubbleTaskView
mHandleView.setOnClickListener(view -> {
mMenuViewController.showMenu(true /* animated */);
});
-
- mDragController = new BubbleBarExpandedViewDragController(this);
}
public BubbleBarHandleView getHandleView() {
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/bar/BubbleBarExpandedViewDragController.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/bar/BubbleBarExpandedViewDragController.kt
index 933794be071e..4ea18f78f5b2 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/bar/BubbleBarExpandedViewDragController.kt
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/bar/BubbleBarExpandedViewDragController.kt
@@ -19,29 +19,47 @@ package com.android.wm.shell.bubbles.bar
import android.animation.Animator
import android.animation.AnimatorListenerAdapter
import android.graphics.PointF
+import android.graphics.Rect
import android.view.MotionEvent
import android.view.View
import com.android.wm.shell.animation.Interpolators
+import com.android.wm.shell.common.bubbles.DismissView
import com.android.wm.shell.common.bubbles.RelativeTouchListener
/** Controller for handling drag interactions with [BubbleBarExpandedView] */
-class BubbleBarExpandedViewDragController(private val expandedView: BubbleBarExpandedView) {
+class BubbleBarExpandedViewDragController(
+ private val expandedView: BubbleBarExpandedView,
+ private val dismissView: DismissView,
+ private val onDismissed: () -> Unit
+) {
init {
expandedView.handleView.setOnTouchListener(HandleDragListener())
}
+ private fun finishDrag(x: Float, y: Float, viewInitialX: Float, viewInitialY: Float) {
+ val dismissCircleBounds = Rect().apply { dismissView.circle.getBoundsOnScreen(this) }
+ if (dismissCircleBounds.contains(x.toInt(), y.toInt())) {
+ onDismissed()
+ } else {
+ resetExpandedViewPosition(viewInitialX, viewInitialY)
+ }
+ dismissView.hide()
+ }
+
private fun resetExpandedViewPosition(initialX: Float, initialY: Float) {
- val listener = object : AnimatorListenerAdapter() {
- override fun onAnimationStart(animation: Animator) {
- expandedView.isAnimating = true
- }
+ val listener =
+ object : AnimatorListenerAdapter() {
+ override fun onAnimationStart(animation: Animator) {
+ expandedView.isAnimating = true
+ }
- override fun onAnimationEnd(animation: Animator) {
- expandedView.isAnimating = false
+ override fun onAnimationEnd(animation: Animator) {
+ expandedView.isAnimating = false
+ }
}
- }
- expandedView.animate()
+ expandedView
+ .animate()
.translationX(initialX)
.translationY(initialY)
.setDuration(RESET_POSITION_ANIM_DURATION)
@@ -74,6 +92,7 @@ class BubbleBarExpandedViewDragController(private val expandedView: BubbleBarExp
) {
expandedView.translationX = expandedViewRestPosition.x + dx
expandedView.translationY = expandedViewRestPosition.y + dy
+ dismissView.show()
}
override fun onUp(
@@ -86,11 +105,12 @@ class BubbleBarExpandedViewDragController(private val expandedView: BubbleBarExp
velX: Float,
velY: Float
) {
- resetExpandedViewPosition(expandedViewRestPosition.x, expandedViewRestPosition.y)
+ finishDrag(ev.rawX, ev.rawY, expandedViewRestPosition.x, expandedViewRestPosition.y)
}
override fun onCancel(v: View, ev: MotionEvent, viewInitialX: Float, viewInitialY: Float) {
resetExpandedViewPosition(expandedViewRestPosition.x, expandedViewRestPosition.y)
+ dismissView.hide()
}
}
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/bar/BubbleBarLayerView.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/bar/BubbleBarLayerView.java
index 92cb436528cc..bdb0e206e490 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/bar/BubbleBarLayerView.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/bar/BubbleBarLayerView.java
@@ -31,17 +31,21 @@ import android.view.ViewTreeObserver;
import android.view.WindowManager;
import android.widget.FrameLayout;
+import com.android.wm.shell.R;
import com.android.wm.shell.bubbles.BubbleController;
import com.android.wm.shell.bubbles.BubbleOverflow;
import com.android.wm.shell.bubbles.BubblePositioner;
import com.android.wm.shell.bubbles.BubbleViewProvider;
+import com.android.wm.shell.bubbles.Bubbles;
import com.android.wm.shell.bubbles.DeviceConfig;
+import com.android.wm.shell.bubbles.DismissViewUtils;
+import com.android.wm.shell.common.bubbles.DismissView;
+
+import kotlin.Unit;
import java.util.Objects;
import java.util.function.Consumer;
-import kotlin.Unit;
-
/**
* Similar to {@link com.android.wm.shell.bubbles.BubbleStackView}, this view is added to window
* manager to display bubbles. However, it is only used when bubbles are being displayed in
@@ -63,7 +67,11 @@ public class BubbleBarLayerView extends FrameLayout
@Nullable
private BubbleViewProvider mExpandedBubble;
+ @Nullable
private BubbleBarExpandedView mExpandedView;
+ @Nullable
+ private BubbleBarExpandedViewDragController mDragController;
+ private DismissView mDismissView;
private @Nullable Consumer<String> mUnBubbleConversationCallback;
// TODO(b/273310265) - currently the view is always on the right, need to update for RTL.
@@ -101,6 +109,8 @@ public class BubbleBarLayerView extends FrameLayout
mScrimView.setBackgroundDrawable(new ColorDrawable(
getResources().getColor(android.R.color.system_neutral1_1000)));
+ setUpDismissView();
+
setOnClickListener(view -> hideMenuOrCollapse());
}
@@ -196,6 +206,13 @@ public class BubbleBarLayerView extends FrameLayout
}
});
+ mDragController = new BubbleBarExpandedViewDragController(mExpandedView, mDismissView,
+ () -> {
+ mBubbleController.dismissBubble(mExpandedBubble.getKey(),
+ Bubbles.DISMISS_USER_GESTURE);
+ return Unit.INSTANCE;
+ });
+
addView(mExpandedView, new FrameLayout.LayoutParams(width, height));
}
@@ -227,6 +244,7 @@ public class BubbleBarLayerView extends FrameLayout
mAnimationHelper.animateCollapse(() -> removeView(viewToRemove));
mBubbleController.getSysuiProxy().onStackExpandChanged(false);
mExpandedView = null;
+ mDragController = null;
setTouchDelegate(null);
showScrim(false);
}
@@ -252,6 +270,18 @@ public class BubbleBarLayerView extends FrameLayout
mUnBubbleConversationCallback = unBubbleConversationCallback;
}
+ private void setUpDismissView() {
+ if (mDismissView != null) {
+ removeView(mDismissView);
+ }
+ mDismissView = new DismissView(getContext());
+ DismissViewUtils.setup(mDismissView);
+ int elevation = getResources().getDimensionPixelSize(R.dimen.bubble_elevation);
+
+ addView(mDismissView);
+ mDismissView.setElevation(elevation);
+ }
+
/** Hides the current modal education/menu view, expanded view or collapses the bubble stack */
private void hideMenuOrCollapse() {
if (mEducationViewController.isEducationVisible()) {