diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml index d7cb09e53706c..2d58f1b932674 100644 --- a/packages/SystemUI/res/values/dimens.xml +++ b/packages/SystemUI/res/values/dimens.xml @@ -1121,6 +1121,9 @@ 16dp 4dp + + 8dp 180dp diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExpandedView.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExpandedView.java index 74db2a929f611..900b6623e1e4d 100644 --- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExpandedView.java +++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExpandedView.java @@ -35,6 +35,7 @@ import android.content.res.TypedArray; import android.graphics.Color; import android.graphics.Insets; import android.graphics.Point; +import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.graphics.drawable.ShapeDrawable; import android.os.RemoteException; @@ -93,6 +94,9 @@ public class BubbleExpandedView extends LinearLayout implements View.OnClickList private int mPointerWidth; private int mPointerHeight; private ShapeDrawable mPointerDrawable; + private Rect mTempRect = new Rect(); + private int[] mTempLoc = new int[2]; + private int mExpandedViewTouchSlop; private Bubble mBubble; private PackageManager mPm; @@ -166,9 +170,10 @@ public class BubbleExpandedView extends LinearLayout implements View.OnClickList mDisplaySize = new Point(); WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); wm.getDefaultDisplay().getSize(mDisplaySize); - mMinHeight = getResources().getDimensionPixelSize( - R.dimen.bubble_expanded_default_height); - mPointerMargin = getResources().getDimensionPixelSize(R.dimen.bubble_pointer_margin); + Resources res = getResources(); + mMinHeight = res.getDimensionPixelSize(R.dimen.bubble_expanded_default_height); + mPointerMargin = res.getDimensionPixelSize(R.dimen.bubble_pointer_margin); + mExpandedViewTouchSlop = res.getDimensionPixelSize(R.dimen.bubble_expanded_view_slop); } @Override @@ -374,6 +379,35 @@ public class BubbleExpandedView extends LinearLayout implements View.OnClickList return mDisplaySize.y - windowLocation[1] - mSettingsIconHeight; } + /** + * Whether the provided x, y values (in raw coordinates) are in a touchable area of the + * expanded view. + * + * The touchable areas are the ActivityView (plus some slop around it) and the manage button. + */ + boolean intersectingTouchableContent(int rawX, int rawY) { + mTempRect.setEmpty(); + if (mActivityView != null) { + mTempLoc = mActivityView.getLocationOnScreen(); + mTempRect.set(mTempLoc[0] - mExpandedViewTouchSlop, + mTempLoc[1] - mExpandedViewTouchSlop, + mTempLoc[0] + mActivityView.getWidth() + mExpandedViewTouchSlop, + mTempLoc[1] + mActivityView.getHeight() + mExpandedViewTouchSlop); + } + if (mTempRect.contains(rawX, rawY)) { + return true; + } + mTempLoc = mSettingsIcon.getLocationOnScreen(); + mTempRect.set(mTempLoc[0], + mTempLoc[1], + mTempLoc[0] + mSettingsIcon.getWidth(), + mTempLoc[1] + mSettingsIcon.getHeight()); + if (mTempRect.contains(rawX, rawY)) { + return true; + } + return false; + } + @Override public void onClick(View view) { if (mBubble == null) { diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java index 0b915e2f0d002..8bd30525433c7 100644 --- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java +++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java @@ -412,8 +412,6 @@ public class BubbleStackView extends FrameLayout { mBubbleContainer.bringToFront(); setOnApplyWindowInsetsListener((View view, WindowInsets insets) -> { - final int keyboardHeight = insets.getSystemWindowInsetBottom() - - insets.getStableInsetBottom(); if (!mIsExpanded || mIsExpansionAnimating) { return view.onApplyWindowInsets(insets); } @@ -509,18 +507,6 @@ public class BubbleStackView extends FrameLayout { getViewTreeObserver().removeOnPreDrawListener(mViewUpdater); } - @Override - public boolean onInterceptTouchEvent(MotionEvent ev) { - float x = ev.getRawX(); - float y = ev.getRawY(); - // If we're expanded only intercept if the tap is outside of the widget container - if (mIsExpanded && isIntersecting(mExpandedViewContainer, x, y)) { - return false; - } else { - return isIntersecting(mBubbleContainer, x, y); - } - } - @Override public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) { super.onInitializeAccessibilityNodeInfoInternal(info); @@ -831,21 +817,23 @@ public class BubbleStackView extends FrameLayout { float y = event.getRawY(); if (mIsExpanded) { if (isIntersecting(mBubbleContainer, x, y)) { + // Could be tapping or dragging a bubble while expanded for (int i = 0; i < mBubbleContainer.getChildCount(); i++) { BubbleView view = (BubbleView) mBubbleContainer.getChildAt(i); if (isIntersecting(view, x, y)) { return view; } } - } else if (isIntersecting(mExpandedViewContainer, x, y)) { - return mExpandedViewContainer; } - // Outside parts of view we care about. + BubbleExpandedView bev = (BubbleExpandedView) mExpandedViewContainer.getChildAt(0); + if (bev.intersectingTouchableContent((int) x, (int) y)) { + return bev; + } + // Outside of the parts we care about. return null; } else if (mFlyout.getVisibility() == VISIBLE && isIntersecting(mFlyout, x, y)) { return mFlyout; } - // If it wasn't an individual bubble in the expanded state, or the flyout, it's the stack. return this; } diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleTouchHandler.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleTouchHandler.java index 194db6694843d..4240e06a8800e 100644 --- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleTouchHandler.java +++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleTouchHandler.java @@ -95,6 +95,15 @@ class BubbleTouchHandler implements View.OnTouchListener { return false; } + if (!(mTouchedView instanceof BubbleView) + && !(mTouchedView instanceof BubbleStackView) + && !(mTouchedView instanceof BubbleFlyoutView)) { + // Not touching anything touchable, but we shouldn't collapse (e.g. touching edge + // of expanded view). + resetForNextGesture(); + return false; + } + final boolean isStack = mStack.equals(mTouchedView); final boolean isFlyout = mStack.getFlyoutView().equals(mTouchedView); final float rawX = event.getRawX();