Loading packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java +0 −20 Original line number Diff line number Diff line Loading @@ -718,13 +718,6 @@ public class BubbleController implements ConfigurationController.ConfigurationLi return mBubbleData.isExpanded(); } /** * Tell the stack of bubbles to expand. */ public void expandStack() { mBubbleData.setExpanded(true); } /** * Tell the stack of bubbles to collapse. */ Loading Loading @@ -753,12 +746,6 @@ public class BubbleController implements ConfigurationController.ConfigurationLi return (isSummary && isSuppressedSummary) || isBubbleAndSuppressed; } @VisibleForTesting void selectBubble(String key) { Bubble bubble = mBubbleData.getBubbleWithKey(key); mBubbleData.setSelectedBubble(bubble); } void promoteBubbleFromOverflow(Bubble bubble) { bubble.setInflateSynchronously(mInflateSynchronously); mBubbleData.promoteBubbleFromOverflow(bubble, mStackView, mBubbleIconFactory); Loading @@ -777,13 +764,6 @@ public class BubbleController implements ConfigurationController.ConfigurationLi } } /** * Tell the stack of bubbles to be dismissed, this will remove all of the bubbles in the stack. */ void dismissStack(@DismissReason int reason) { mBubbleData.dismissAll(reason); } /** * Directs a back gesture at the bubble stack. When opened, the current expanded bubble * is forwarded a back key down/up pair. Loading packages/SystemUI/src/com/android/systemui/bubbles/BubbleData.java +13 −0 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import android.content.Context; import android.service.notification.NotificationListenerService; import android.util.Log; import android.util.Pair; import android.view.View; import androidx.annotation.Nullable; Loading Loading @@ -751,6 +752,7 @@ public class BubbleData { } @VisibleForTesting(visibility = PRIVATE) @Nullable Bubble getBubbleWithKey(String key) { for (int i = 0; i < mBubbles.size(); i++) { Bubble bubble = mBubbles.get(i); Loading @@ -761,6 +763,17 @@ public class BubbleData { return null; } @Nullable Bubble getBubbleWithView(View view) { for (int i = 0; i < mBubbles.size(); i++) { Bubble bubble = mBubbles.get(i); if (bubble.getIconView() != null && bubble.getIconView().equals(view)) { return bubble; } } return null; } @VisibleForTesting(visibility = PRIVATE) Bubble getOverflowBubbleWithKey(String key) { for (int i = 0; i < mOverflowBubbles.size(); i++) { Loading packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java +287 −235 File changed.Preview size limit exceeded, changes collapsed. Show changes packages/SystemUI/src/com/android/systemui/bubbles/BubbleTouchHandler.javadeleted 100644 → 0 +0 −221 Original line number Diff line number Diff line /* * Copyright (C) 2012 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.systemui.bubbles; import android.content.Context; import android.graphics.PointF; import android.view.MotionEvent; import android.view.VelocityTracker; import android.view.View; import android.view.ViewConfiguration; import com.android.systemui.Dependency; /** * Handles interpreting touches on a {@link BubbleStackView}. This includes expanding, collapsing, * dismissing, and flings. */ class BubbleTouchHandler implements View.OnTouchListener { private final PointF mTouchDown = new PointF(); private final PointF mViewPositionOnTouchDown = new PointF(); private final BubbleStackView mStack; private final BubbleData mBubbleData; private BubbleController mController = Dependency.get(BubbleController.class); private boolean mMovedEnough; private int mTouchSlopSquared; private VelocityTracker mVelocityTracker; /** View that was initially touched, when we received the first ACTION_DOWN event. */ private View mTouchedView; BubbleTouchHandler(BubbleStackView stackView, BubbleData bubbleData, Context context) { final int touchSlop = ViewConfiguration.get(context).getScaledTouchSlop(); mTouchSlopSquared = touchSlop * touchSlop; mBubbleData = bubbleData; mStack = stackView; } @Override public boolean onTouch(View v, MotionEvent event) { final int action = event.getActionMasked(); // If we aren't currently in the process of touching a view, figure out what we're touching. // It'll be the stack, an individual bubble, or nothing. if (mTouchedView == null) { mTouchedView = mStack.getTargetView(event); } // If this is an ACTION_OUTSIDE event, or the stack reported that we aren't touching // anything, collapse the stack. if (action == MotionEvent.ACTION_OUTSIDE || mTouchedView == null) { mBubbleData.setExpanded(false); mStack.hideStackUserEducation(false /* fromExpansion */); resetForNextGesture(); return false; } if (!(mTouchedView instanceof BadgedImageView) && !(mTouchedView instanceof BubbleStackView) && !(mTouchedView instanceof BubbleFlyoutView)) { // Not touching anything touchable, but we shouldn't collapse (e.g. touching edge // of expanded view). mStack.maybeShowManageEducation(false); resetForNextGesture(); return false; } final boolean isStack = mStack.equals(mTouchedView); final boolean isFlyout = mStack.getFlyoutView().equals(mTouchedView); final float rawX = event.getRawX(); final float rawY = event.getRawY(); // The coordinates of the touch event, in terms of the touched view's position. final float viewX = mViewPositionOnTouchDown.x + rawX - mTouchDown.x; final float viewY = mViewPositionOnTouchDown.y + rawY - mTouchDown.y; switch (action) { case MotionEvent.ACTION_DOWN: trackMovement(event); mTouchDown.set(rawX, rawY); mStack.onGestureStart(); if (isStack) { mViewPositionOnTouchDown.set(mStack.getStackPosition()); // Dismiss the entire stack if it's released in the dismiss target. mStack.setReleasedInDismissTargetAction( () -> mController.dismissStack(BubbleController.DISMISS_USER_GESTURE)); mStack.onDragStart(); mStack.passEventToMagnetizedObject(event); } else if (isFlyout) { mStack.onFlyoutDragStart(); } else { mViewPositionOnTouchDown.set( mTouchedView.getTranslationX(), mTouchedView.getTranslationY()); // Dismiss only the dragged-out bubble if it's released in the target. final String individualBubbleKey = ((BadgedImageView) mTouchedView).getKey(); mStack.setReleasedInDismissTargetAction(() -> { final Bubble bubble = mBubbleData.getBubbleWithKey(individualBubbleKey); // bubble can be null if the user is in the middle of // dismissing the bubble, but the app also sent a cancel if (bubble != null) { mController.removeBubble(bubble.getEntry(), BubbleController.DISMISS_USER_GESTURE); } }); mStack.onBubbleDragStart(mTouchedView); mStack.passEventToMagnetizedObject(event); } break; case MotionEvent.ACTION_MOVE: trackMovement(event); final float deltaX = rawX - mTouchDown.x; final float deltaY = rawY - mTouchDown.y; if ((deltaX * deltaX) + (deltaY * deltaY) > mTouchSlopSquared && !mMovedEnough) { mMovedEnough = true; } if (mMovedEnough) { if (isFlyout) { mStack.onFlyoutDragged(deltaX); } else if (!mStack.passEventToMagnetizedObject(event)) { // If the magnetic target doesn't consume the event, drag the stack or // bubble. if (isStack) { mStack.onDragged(viewX, viewY); } else { mStack.onBubbleDragged(mTouchedView, viewX, viewY); } } } break; case MotionEvent.ACTION_CANCEL: resetForNextGesture(); break; case MotionEvent.ACTION_UP: trackMovement(event); mVelocityTracker.computeCurrentVelocity(/* maxVelocity */ 1000); final float velX = mVelocityTracker.getXVelocity(); final float velY = mVelocityTracker.getYVelocity(); if (isFlyout && mMovedEnough) { mStack.onFlyoutDragFinished(rawX - mTouchDown.x /* deltaX */, velX); } else if (isFlyout) { if (!mBubbleData.isExpanded() && !mMovedEnough) { mStack.onFlyoutTapped(); } } else if (mMovedEnough) { if (!mStack.passEventToMagnetizedObject(event)) { // If the magnetic target didn't consume the event, tell the stack to finish // the drag. if (isStack) { mStack.onDragFinish(viewX, viewY, velX, velY); } else { mStack.onBubbleDragFinish(mTouchedView, viewX, viewY, velX, velY); } } } else if (mTouchedView == mStack.getExpandedBubbleView()) { mBubbleData.setExpanded(false); } else if (isStack) { mStack.onStackTapped(); } else { final String key = ((BadgedImageView) mTouchedView).getKey(); if (key == BubbleOverflow.KEY) { mStack.showOverflow(); } else { mStack.expandBubble(mBubbleData.getBubbleWithKey(key)); } } resetForNextGesture(); break; } return true; } /** Clears all touch-related state. */ private void resetForNextGesture() { if (mVelocityTracker != null) { mVelocityTracker.recycle(); mVelocityTracker = null; } mTouchedView = null; mMovedEnough = false; mStack.onGestureFinished(); } private void trackMovement(MotionEvent event) { if (mVelocityTracker == null) { mVelocityTracker = VelocityTracker.obtain(); } mVelocityTracker.addMovement(event); } } packages/SystemUI/src/com/android/systemui/bubbles/animation/ExpandedAnimationController.java +9 −2 Original line number Diff line number Diff line Loading @@ -252,8 +252,14 @@ public class ExpandedAnimationController mSpringToTouchOnNextMotionEvent = true; } /** Prepares the given bubble to be dragged out. */ public void prepareForBubbleDrag(View bubble, MagnetizedObject.MagneticTarget target) { /** * Prepares the given bubble view to be dragged out, using the provided magnetic target and * listener. */ public void prepareForBubbleDrag( View bubble, MagnetizedObject.MagneticTarget target, MagnetizedObject.MagnetListener listener) { mLayout.cancelAnimationsOnView(bubble); bubble.setTranslationZ(Short.MAX_VALUE); Loading @@ -277,6 +283,7 @@ public class ExpandedAnimationController } }; mMagnetizedBubbleDraggingOut.addTarget(target); mMagnetizedBubbleDraggingOut.setMagnetListener(listener); mMagnetizedBubbleDraggingOut.setHapticsEnabled(true); mMagnetizedBubbleDraggingOut.setFlingToTargetMinVelocity(FLING_TO_DISMISS_MIN_VELOCITY); } Loading Loading
packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java +0 −20 Original line number Diff line number Diff line Loading @@ -718,13 +718,6 @@ public class BubbleController implements ConfigurationController.ConfigurationLi return mBubbleData.isExpanded(); } /** * Tell the stack of bubbles to expand. */ public void expandStack() { mBubbleData.setExpanded(true); } /** * Tell the stack of bubbles to collapse. */ Loading Loading @@ -753,12 +746,6 @@ public class BubbleController implements ConfigurationController.ConfigurationLi return (isSummary && isSuppressedSummary) || isBubbleAndSuppressed; } @VisibleForTesting void selectBubble(String key) { Bubble bubble = mBubbleData.getBubbleWithKey(key); mBubbleData.setSelectedBubble(bubble); } void promoteBubbleFromOverflow(Bubble bubble) { bubble.setInflateSynchronously(mInflateSynchronously); mBubbleData.promoteBubbleFromOverflow(bubble, mStackView, mBubbleIconFactory); Loading @@ -777,13 +764,6 @@ public class BubbleController implements ConfigurationController.ConfigurationLi } } /** * Tell the stack of bubbles to be dismissed, this will remove all of the bubbles in the stack. */ void dismissStack(@DismissReason int reason) { mBubbleData.dismissAll(reason); } /** * Directs a back gesture at the bubble stack. When opened, the current expanded bubble * is forwarded a back key down/up pair. Loading
packages/SystemUI/src/com/android/systemui/bubbles/BubbleData.java +13 −0 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import android.content.Context; import android.service.notification.NotificationListenerService; import android.util.Log; import android.util.Pair; import android.view.View; import androidx.annotation.Nullable; Loading Loading @@ -751,6 +752,7 @@ public class BubbleData { } @VisibleForTesting(visibility = PRIVATE) @Nullable Bubble getBubbleWithKey(String key) { for (int i = 0; i < mBubbles.size(); i++) { Bubble bubble = mBubbles.get(i); Loading @@ -761,6 +763,17 @@ public class BubbleData { return null; } @Nullable Bubble getBubbleWithView(View view) { for (int i = 0; i < mBubbles.size(); i++) { Bubble bubble = mBubbles.get(i); if (bubble.getIconView() != null && bubble.getIconView().equals(view)) { return bubble; } } return null; } @VisibleForTesting(visibility = PRIVATE) Bubble getOverflowBubbleWithKey(String key) { for (int i = 0; i < mOverflowBubbles.size(); i++) { Loading
packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java +287 −235 File changed.Preview size limit exceeded, changes collapsed. Show changes
packages/SystemUI/src/com/android/systemui/bubbles/BubbleTouchHandler.javadeleted 100644 → 0 +0 −221 Original line number Diff line number Diff line /* * Copyright (C) 2012 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.systemui.bubbles; import android.content.Context; import android.graphics.PointF; import android.view.MotionEvent; import android.view.VelocityTracker; import android.view.View; import android.view.ViewConfiguration; import com.android.systemui.Dependency; /** * Handles interpreting touches on a {@link BubbleStackView}. This includes expanding, collapsing, * dismissing, and flings. */ class BubbleTouchHandler implements View.OnTouchListener { private final PointF mTouchDown = new PointF(); private final PointF mViewPositionOnTouchDown = new PointF(); private final BubbleStackView mStack; private final BubbleData mBubbleData; private BubbleController mController = Dependency.get(BubbleController.class); private boolean mMovedEnough; private int mTouchSlopSquared; private VelocityTracker mVelocityTracker; /** View that was initially touched, when we received the first ACTION_DOWN event. */ private View mTouchedView; BubbleTouchHandler(BubbleStackView stackView, BubbleData bubbleData, Context context) { final int touchSlop = ViewConfiguration.get(context).getScaledTouchSlop(); mTouchSlopSquared = touchSlop * touchSlop; mBubbleData = bubbleData; mStack = stackView; } @Override public boolean onTouch(View v, MotionEvent event) { final int action = event.getActionMasked(); // If we aren't currently in the process of touching a view, figure out what we're touching. // It'll be the stack, an individual bubble, or nothing. if (mTouchedView == null) { mTouchedView = mStack.getTargetView(event); } // If this is an ACTION_OUTSIDE event, or the stack reported that we aren't touching // anything, collapse the stack. if (action == MotionEvent.ACTION_OUTSIDE || mTouchedView == null) { mBubbleData.setExpanded(false); mStack.hideStackUserEducation(false /* fromExpansion */); resetForNextGesture(); return false; } if (!(mTouchedView instanceof BadgedImageView) && !(mTouchedView instanceof BubbleStackView) && !(mTouchedView instanceof BubbleFlyoutView)) { // Not touching anything touchable, but we shouldn't collapse (e.g. touching edge // of expanded view). mStack.maybeShowManageEducation(false); resetForNextGesture(); return false; } final boolean isStack = mStack.equals(mTouchedView); final boolean isFlyout = mStack.getFlyoutView().equals(mTouchedView); final float rawX = event.getRawX(); final float rawY = event.getRawY(); // The coordinates of the touch event, in terms of the touched view's position. final float viewX = mViewPositionOnTouchDown.x + rawX - mTouchDown.x; final float viewY = mViewPositionOnTouchDown.y + rawY - mTouchDown.y; switch (action) { case MotionEvent.ACTION_DOWN: trackMovement(event); mTouchDown.set(rawX, rawY); mStack.onGestureStart(); if (isStack) { mViewPositionOnTouchDown.set(mStack.getStackPosition()); // Dismiss the entire stack if it's released in the dismiss target. mStack.setReleasedInDismissTargetAction( () -> mController.dismissStack(BubbleController.DISMISS_USER_GESTURE)); mStack.onDragStart(); mStack.passEventToMagnetizedObject(event); } else if (isFlyout) { mStack.onFlyoutDragStart(); } else { mViewPositionOnTouchDown.set( mTouchedView.getTranslationX(), mTouchedView.getTranslationY()); // Dismiss only the dragged-out bubble if it's released in the target. final String individualBubbleKey = ((BadgedImageView) mTouchedView).getKey(); mStack.setReleasedInDismissTargetAction(() -> { final Bubble bubble = mBubbleData.getBubbleWithKey(individualBubbleKey); // bubble can be null if the user is in the middle of // dismissing the bubble, but the app also sent a cancel if (bubble != null) { mController.removeBubble(bubble.getEntry(), BubbleController.DISMISS_USER_GESTURE); } }); mStack.onBubbleDragStart(mTouchedView); mStack.passEventToMagnetizedObject(event); } break; case MotionEvent.ACTION_MOVE: trackMovement(event); final float deltaX = rawX - mTouchDown.x; final float deltaY = rawY - mTouchDown.y; if ((deltaX * deltaX) + (deltaY * deltaY) > mTouchSlopSquared && !mMovedEnough) { mMovedEnough = true; } if (mMovedEnough) { if (isFlyout) { mStack.onFlyoutDragged(deltaX); } else if (!mStack.passEventToMagnetizedObject(event)) { // If the magnetic target doesn't consume the event, drag the stack or // bubble. if (isStack) { mStack.onDragged(viewX, viewY); } else { mStack.onBubbleDragged(mTouchedView, viewX, viewY); } } } break; case MotionEvent.ACTION_CANCEL: resetForNextGesture(); break; case MotionEvent.ACTION_UP: trackMovement(event); mVelocityTracker.computeCurrentVelocity(/* maxVelocity */ 1000); final float velX = mVelocityTracker.getXVelocity(); final float velY = mVelocityTracker.getYVelocity(); if (isFlyout && mMovedEnough) { mStack.onFlyoutDragFinished(rawX - mTouchDown.x /* deltaX */, velX); } else if (isFlyout) { if (!mBubbleData.isExpanded() && !mMovedEnough) { mStack.onFlyoutTapped(); } } else if (mMovedEnough) { if (!mStack.passEventToMagnetizedObject(event)) { // If the magnetic target didn't consume the event, tell the stack to finish // the drag. if (isStack) { mStack.onDragFinish(viewX, viewY, velX, velY); } else { mStack.onBubbleDragFinish(mTouchedView, viewX, viewY, velX, velY); } } } else if (mTouchedView == mStack.getExpandedBubbleView()) { mBubbleData.setExpanded(false); } else if (isStack) { mStack.onStackTapped(); } else { final String key = ((BadgedImageView) mTouchedView).getKey(); if (key == BubbleOverflow.KEY) { mStack.showOverflow(); } else { mStack.expandBubble(mBubbleData.getBubbleWithKey(key)); } } resetForNextGesture(); break; } return true; } /** Clears all touch-related state. */ private void resetForNextGesture() { if (mVelocityTracker != null) { mVelocityTracker.recycle(); mVelocityTracker = null; } mTouchedView = null; mMovedEnough = false; mStack.onGestureFinished(); } private void trackMovement(MotionEvent event) { if (mVelocityTracker == null) { mVelocityTracker = VelocityTracker.obtain(); } mVelocityTracker.addMovement(event); } }
packages/SystemUI/src/com/android/systemui/bubbles/animation/ExpandedAnimationController.java +9 −2 Original line number Diff line number Diff line Loading @@ -252,8 +252,14 @@ public class ExpandedAnimationController mSpringToTouchOnNextMotionEvent = true; } /** Prepares the given bubble to be dragged out. */ public void prepareForBubbleDrag(View bubble, MagnetizedObject.MagneticTarget target) { /** * Prepares the given bubble view to be dragged out, using the provided magnetic target and * listener. */ public void prepareForBubbleDrag( View bubble, MagnetizedObject.MagneticTarget target, MagnetizedObject.MagnetListener listener) { mLayout.cancelAnimationsOnView(bubble); bubble.setTranslationZ(Short.MAX_VALUE); Loading @@ -277,6 +283,7 @@ public class ExpandedAnimationController } }; mMagnetizedBubbleDraggingOut.addTarget(target); mMagnetizedBubbleDraggingOut.setMagnetListener(listener); mMagnetizedBubbleDraggingOut.setHapticsEnabled(true); mMagnetizedBubbleDraggingOut.setFlingToTargetMinVelocity(FLING_TO_DISMISS_MIN_VELOCITY); } Loading