Loading packages/SystemUI/src/com/android/systemui/SwipeHelper.java +44 −29 Original line number Diff line number Diff line Loading @@ -83,6 +83,7 @@ public class SwipeHelper implements Gefingerpoken { private boolean mMenuRowIntercepting; private boolean mLongPressSent; private LongPressListener mLongPressListener; private Runnable mWatchLongPress; private final long mLongPressTimeout; Loading Loading @@ -114,6 +115,10 @@ public class SwipeHelper implements Gefingerpoken { mFlingAnimationUtils = new FlingAnimationUtils(context, getMaxEscapeAnimDuration() / 1000f); } public void setLongPressListener(LongPressListener listener) { mLongPressListener = listener; } public void setDensityScale(float densityScale) { mDensityScale = densityScale; } Loading Loading @@ -252,7 +257,7 @@ public class SwipeHelper implements Gefingerpoken { } } public void cancelLongPress() { public void removeLongPressCallback() { if (mWatchLongPress != null) { mHandler.removeCallbacks(mWatchLongPress); mWatchLongPress = null; Loading @@ -276,14 +281,6 @@ public class SwipeHelper implements Gefingerpoken { mVelocityTracker.clear(); mCurrView = mCallback.getChildAtPosition(ev); // The SwipeHelper sends its own long-press, don't let the view send a dupe. // Queue up a cancelLongPress on the view a few ms after we see a down event. mHandler.post(() -> { if (mCurrView != null) { mCurrView.cancelLongPress(); } }); if (mCurrView != null) { onDownUpdate(mCurrView, ev); mCanCurrViewBeDimissed = mCallback.canChildBeDismissed(mCurrView); Loading @@ -291,20 +288,26 @@ public class SwipeHelper implements Gefingerpoken { mInitialTouchPos = getPos(ev); mPerpendicularInitialTouchPos = getPerpendicularPos(ev); mTranslation = getTranslation(mCurrView); if (mLongPressListener != null) { if (mWatchLongPress == null) { mWatchLongPress = new Runnable() { @Override public void run() { if (mCurrView != null && !mLongPressSent) { mLongPressSent = true; mCurrView.sendAccessibilityEvent( AccessibilityEvent.TYPE_VIEW_LONG_CLICKED); mCurrView.getLocationOnScreen(mTmpPos); final int x = (int) ev.getRawX() - mTmpPos[0]; final int y = (int) ev.getRawY() - mTmpPos[1]; MenuItem menuItem = null; if (mCurrView instanceof ExpandableNotificationRow) { ExpandableNotificationRow currRow = (ExpandableNotificationRow) mCurrView; currRow.setLongPressPosition(x, y); currRow.performLongClick(x, y); menuItem = ((ExpandableNotificationRow) mCurrView) .getProvider().getLongpressMenuItem(mContext); } if (menuItem != null) { mLongPressListener.onLongPress(mCurrView, x, y, menuItem); } } } Loading @@ -312,6 +315,7 @@ public class SwipeHelper implements Gefingerpoken { } mHandler.postDelayed(mWatchLongPress, mLongPressTimeout); } } break; case MotionEvent.ACTION_MOVE: Loading @@ -327,7 +331,7 @@ public class SwipeHelper implements Gefingerpoken { mDragging = true; mInitialTouchPos = getPos(ev); mTranslation = getTranslation(mCurrView); cancelLongPress(); removeLongPressCallback(); } } break; Loading @@ -339,7 +343,7 @@ public class SwipeHelper implements Gefingerpoken { mCurrView = null; mLongPressSent = false; mMenuRowIntercepting = false; cancelLongPress(); removeLongPressCallback(); if (captured) return true; break; } Loading Loading @@ -582,7 +586,7 @@ public class SwipeHelper implements Gefingerpoken { // We are not doing anything, make sure the long press callback // is not still ticking like a bomb waiting to go off. cancelLongPress(); removeLongPressCallback(); return false; } } Loading Loading @@ -730,4 +734,15 @@ public class SwipeHelper implements Gefingerpoken { */ float getFalsingThresholdFactor(); } /** * Equivalent to View.OnLongClickListener with coordinates */ public interface LongPressListener { /** * Equivalent to {@link View.OnLongClickListener#onLongClick(View)} with coordinates * @return whether the longpress was handled */ boolean onLongPress(View v, int x, int y, MenuItem item); } } packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java +0 −48 Original line number Diff line number Diff line Loading @@ -172,14 +172,6 @@ public class ExpandableNotificationRow extends ActivatableNotificationView private boolean mShowNoBackground; private ExpandableNotificationRow mNotificationParent; private OnExpandClickListener mOnExpandClickListener; // Listener will be called when receiving a long click event. // Use #setLongPressPosition to optionally assign positional data with the long press. private LongPressListener mLongPressListener; private boolean mLongPressPositionSet = false; private int mLongPressX = 0; private int mLongPressY = 0; private boolean mGroupExpansionChanging; /** Loading Loading @@ -781,16 +773,6 @@ public class ExpandableNotificationRow extends ActivatableNotificationView mOnExpandClickListener = onExpandClickListener; } public void setLongPressListener(LongPressListener longPressListener) { mLongPressListener = longPressListener; } public void setLongPressPosition(int x, int y) { mLongPressPositionSet = true; mLongPressX = x; mLongPressY = y; } @Override public void setOnClickListener(@Nullable OnClickListener l) { super.setOnClickListener(l); Loading Loading @@ -1339,25 +1321,6 @@ public class ExpandableNotificationRow extends ActivatableNotificationView mTranslateableViews.remove(mChildrenContainerStub); mTranslateableViews.remove(mGutsStub); } setOnLongClickListener((View v) -> { createMenu(); MenuItem menuItem = getProvider().getLongpressMenuItem(mContext); if (mLongPressListener != null && menuItem != null) { int x, y; if (mLongPressPositionSet) { x = mLongPressX; y = mLongPressY; } else { // No position assigned - use the center of the View x = getWidth() / 2; y = getHeight() / 2; } mLongPressPositionSet = false; return mLongPressListener.onLongPress(this, x, y, menuItem); } return false; }); } public void resetTranslation() { Loading Loading @@ -2341,15 +2304,4 @@ public class ExpandableNotificationRow extends ActivatableNotificationView protected void setChildrenContainer(NotificationChildrenContainer childrenContainer) { mChildrenContainer = childrenContainer; } /** * Equivalent to View.OnLongClickListener with coordinates */ public interface LongPressListener { /** * Equivalent to {@link View.OnLongClickListener#onLongClick(View)} with coordinates * @return whether the longpress was handled */ boolean onLongPress(View v, int x, int y, MenuItem item); } } packages/SystemUI/src/com/android/systemui/statusbar/car/CarStatusBar.java +3 −5 Original line number Diff line number Diff line Loading @@ -44,7 +44,6 @@ import com.android.systemui.fragments.FragmentHostManager; import com.android.systemui.recents.Recents; import com.android.systemui.recents.misc.SystemServicesProxy; import com.android.systemui.recents.misc.SystemServicesProxy.TaskStackListener; import com.android.systemui.statusbar.ExpandableNotificationRow; import com.android.systemui.statusbar.NotificationData; import com.android.systemui.statusbar.StatusBarState; import com.android.systemui.statusbar.phone.CollapsedStatusBarFragment; Loading Loading @@ -248,12 +247,11 @@ public class CarStatusBar extends StatusBar implements } /** * Returns the * {@link com.android.systemui.statusbar.ExpandableNotificationRow.LongPressListener} that will * be triggered when a notification card is long-pressed. * Returns the {@link com.android.systemui.SwipeHelper.LongPressListener} that will be * triggered when a notification card is long-pressed. */ @Override protected ExpandableNotificationRow.LongPressListener getNotificationLongClicker() { protected SwipeHelper.LongPressListener getNotificationLongClicker() { // For the automative use case, we do not want to the user to be able to interact with // a notification other than a regular click. As a result, just return null for the // long click listener. Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java +2 −2 Original line number Diff line number Diff line Loading @@ -703,7 +703,7 @@ public class NotificationPanelView extends PanelView implements mInitialHeightOnTouch = mQsExpansionHeight; mQsTracking = true; mIntercepting = false; mNotificationStackScroller.cancelLongPress(); mNotificationStackScroller.removeLongPressCallback(); } break; case MotionEvent.ACTION_POINTER_UP: Loading Loading @@ -739,7 +739,7 @@ public class NotificationPanelView extends PanelView implements mInitialTouchY = y; mInitialTouchX = x; mIntercepting = false; mNotificationStackScroller.cancelLongPress(); mNotificationStackScroller.removeLongPressCallback(); return true; } break; Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java +6 −7 Original line number Diff line number Diff line Loading @@ -165,6 +165,7 @@ import com.android.systemui.Interpolators; import com.android.systemui.Prefs; import com.android.systemui.R; import com.android.systemui.RecentsComponent; import com.android.systemui.SwipeHelper; import com.android.systemui.SystemUI; import com.android.systemui.SystemUIFactory; import com.android.systemui.UiOffloadThread; Loading Loading @@ -4982,7 +4983,7 @@ public class StatusBar extends SystemUI implements DemoMode, @Override public void onTouchSlopExceeded() { mStackScroller.cancelLongPress(); mStackScroller.removeLongPressCallback(); mStackScroller.checkSnoozeLeavebehind(); } Loading Loading @@ -6470,15 +6471,14 @@ public class StatusBar extends SystemUI implements DemoMode, true /* removeControls */, x, y, true /* resetMenu */); } protected ExpandableNotificationRow.LongPressListener getNotificationLongClicker() { return new ExpandableNotificationRow.LongPressListener() { protected SwipeHelper.LongPressListener getNotificationLongClicker() { return new SwipeHelper.LongPressListener() { @Override public boolean onLongPress(View v, final int x, final int y, MenuItem item) { if (!(v instanceof ExpandableNotificationRow)) { return false; } if (v.getWindowToken() == null) { Log.e(TAG, "Trying to show notification guts, but not attached to window"); return false; Loading @@ -6493,7 +6493,7 @@ public class StatusBar extends SystemUI implements DemoMode, closeAndSaveGuts(false /* removeLeavebehind */, false /* force */, true /* removeControls */, -1 /* x */, -1 /* y */, true /* resetMenu */); return true; return false; } bindGuts(row, item); NotificationGuts guts = row.getGuts(); Loading Loading @@ -6791,7 +6791,6 @@ public class StatusBar extends SystemUI implements DemoMode, row.setOnExpandClickListener(this); row.setRemoteViewClickHandler(mOnClickHandler); row.setInflationCallback(this); row.setLongPressListener(getNotificationLongClicker()); // Get the app name. // Note that Notification.Builder#bindHeaderAppName has similar logic Loading Loading
packages/SystemUI/src/com/android/systemui/SwipeHelper.java +44 −29 Original line number Diff line number Diff line Loading @@ -83,6 +83,7 @@ public class SwipeHelper implements Gefingerpoken { private boolean mMenuRowIntercepting; private boolean mLongPressSent; private LongPressListener mLongPressListener; private Runnable mWatchLongPress; private final long mLongPressTimeout; Loading Loading @@ -114,6 +115,10 @@ public class SwipeHelper implements Gefingerpoken { mFlingAnimationUtils = new FlingAnimationUtils(context, getMaxEscapeAnimDuration() / 1000f); } public void setLongPressListener(LongPressListener listener) { mLongPressListener = listener; } public void setDensityScale(float densityScale) { mDensityScale = densityScale; } Loading Loading @@ -252,7 +257,7 @@ public class SwipeHelper implements Gefingerpoken { } } public void cancelLongPress() { public void removeLongPressCallback() { if (mWatchLongPress != null) { mHandler.removeCallbacks(mWatchLongPress); mWatchLongPress = null; Loading @@ -276,14 +281,6 @@ public class SwipeHelper implements Gefingerpoken { mVelocityTracker.clear(); mCurrView = mCallback.getChildAtPosition(ev); // The SwipeHelper sends its own long-press, don't let the view send a dupe. // Queue up a cancelLongPress on the view a few ms after we see a down event. mHandler.post(() -> { if (mCurrView != null) { mCurrView.cancelLongPress(); } }); if (mCurrView != null) { onDownUpdate(mCurrView, ev); mCanCurrViewBeDimissed = mCallback.canChildBeDismissed(mCurrView); Loading @@ -291,20 +288,26 @@ public class SwipeHelper implements Gefingerpoken { mInitialTouchPos = getPos(ev); mPerpendicularInitialTouchPos = getPerpendicularPos(ev); mTranslation = getTranslation(mCurrView); if (mLongPressListener != null) { if (mWatchLongPress == null) { mWatchLongPress = new Runnable() { @Override public void run() { if (mCurrView != null && !mLongPressSent) { mLongPressSent = true; mCurrView.sendAccessibilityEvent( AccessibilityEvent.TYPE_VIEW_LONG_CLICKED); mCurrView.getLocationOnScreen(mTmpPos); final int x = (int) ev.getRawX() - mTmpPos[0]; final int y = (int) ev.getRawY() - mTmpPos[1]; MenuItem menuItem = null; if (mCurrView instanceof ExpandableNotificationRow) { ExpandableNotificationRow currRow = (ExpandableNotificationRow) mCurrView; currRow.setLongPressPosition(x, y); currRow.performLongClick(x, y); menuItem = ((ExpandableNotificationRow) mCurrView) .getProvider().getLongpressMenuItem(mContext); } if (menuItem != null) { mLongPressListener.onLongPress(mCurrView, x, y, menuItem); } } } Loading @@ -312,6 +315,7 @@ public class SwipeHelper implements Gefingerpoken { } mHandler.postDelayed(mWatchLongPress, mLongPressTimeout); } } break; case MotionEvent.ACTION_MOVE: Loading @@ -327,7 +331,7 @@ public class SwipeHelper implements Gefingerpoken { mDragging = true; mInitialTouchPos = getPos(ev); mTranslation = getTranslation(mCurrView); cancelLongPress(); removeLongPressCallback(); } } break; Loading @@ -339,7 +343,7 @@ public class SwipeHelper implements Gefingerpoken { mCurrView = null; mLongPressSent = false; mMenuRowIntercepting = false; cancelLongPress(); removeLongPressCallback(); if (captured) return true; break; } Loading Loading @@ -582,7 +586,7 @@ public class SwipeHelper implements Gefingerpoken { // We are not doing anything, make sure the long press callback // is not still ticking like a bomb waiting to go off. cancelLongPress(); removeLongPressCallback(); return false; } } Loading Loading @@ -730,4 +734,15 @@ public class SwipeHelper implements Gefingerpoken { */ float getFalsingThresholdFactor(); } /** * Equivalent to View.OnLongClickListener with coordinates */ public interface LongPressListener { /** * Equivalent to {@link View.OnLongClickListener#onLongClick(View)} with coordinates * @return whether the longpress was handled */ boolean onLongPress(View v, int x, int y, MenuItem item); } }
packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java +0 −48 Original line number Diff line number Diff line Loading @@ -172,14 +172,6 @@ public class ExpandableNotificationRow extends ActivatableNotificationView private boolean mShowNoBackground; private ExpandableNotificationRow mNotificationParent; private OnExpandClickListener mOnExpandClickListener; // Listener will be called when receiving a long click event. // Use #setLongPressPosition to optionally assign positional data with the long press. private LongPressListener mLongPressListener; private boolean mLongPressPositionSet = false; private int mLongPressX = 0; private int mLongPressY = 0; private boolean mGroupExpansionChanging; /** Loading Loading @@ -781,16 +773,6 @@ public class ExpandableNotificationRow extends ActivatableNotificationView mOnExpandClickListener = onExpandClickListener; } public void setLongPressListener(LongPressListener longPressListener) { mLongPressListener = longPressListener; } public void setLongPressPosition(int x, int y) { mLongPressPositionSet = true; mLongPressX = x; mLongPressY = y; } @Override public void setOnClickListener(@Nullable OnClickListener l) { super.setOnClickListener(l); Loading Loading @@ -1339,25 +1321,6 @@ public class ExpandableNotificationRow extends ActivatableNotificationView mTranslateableViews.remove(mChildrenContainerStub); mTranslateableViews.remove(mGutsStub); } setOnLongClickListener((View v) -> { createMenu(); MenuItem menuItem = getProvider().getLongpressMenuItem(mContext); if (mLongPressListener != null && menuItem != null) { int x, y; if (mLongPressPositionSet) { x = mLongPressX; y = mLongPressY; } else { // No position assigned - use the center of the View x = getWidth() / 2; y = getHeight() / 2; } mLongPressPositionSet = false; return mLongPressListener.onLongPress(this, x, y, menuItem); } return false; }); } public void resetTranslation() { Loading Loading @@ -2341,15 +2304,4 @@ public class ExpandableNotificationRow extends ActivatableNotificationView protected void setChildrenContainer(NotificationChildrenContainer childrenContainer) { mChildrenContainer = childrenContainer; } /** * Equivalent to View.OnLongClickListener with coordinates */ public interface LongPressListener { /** * Equivalent to {@link View.OnLongClickListener#onLongClick(View)} with coordinates * @return whether the longpress was handled */ boolean onLongPress(View v, int x, int y, MenuItem item); } }
packages/SystemUI/src/com/android/systemui/statusbar/car/CarStatusBar.java +3 −5 Original line number Diff line number Diff line Loading @@ -44,7 +44,6 @@ import com.android.systemui.fragments.FragmentHostManager; import com.android.systemui.recents.Recents; import com.android.systemui.recents.misc.SystemServicesProxy; import com.android.systemui.recents.misc.SystemServicesProxy.TaskStackListener; import com.android.systemui.statusbar.ExpandableNotificationRow; import com.android.systemui.statusbar.NotificationData; import com.android.systemui.statusbar.StatusBarState; import com.android.systemui.statusbar.phone.CollapsedStatusBarFragment; Loading Loading @@ -248,12 +247,11 @@ public class CarStatusBar extends StatusBar implements } /** * Returns the * {@link com.android.systemui.statusbar.ExpandableNotificationRow.LongPressListener} that will * be triggered when a notification card is long-pressed. * Returns the {@link com.android.systemui.SwipeHelper.LongPressListener} that will be * triggered when a notification card is long-pressed. */ @Override protected ExpandableNotificationRow.LongPressListener getNotificationLongClicker() { protected SwipeHelper.LongPressListener getNotificationLongClicker() { // For the automative use case, we do not want to the user to be able to interact with // a notification other than a regular click. As a result, just return null for the // long click listener. Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java +2 −2 Original line number Diff line number Diff line Loading @@ -703,7 +703,7 @@ public class NotificationPanelView extends PanelView implements mInitialHeightOnTouch = mQsExpansionHeight; mQsTracking = true; mIntercepting = false; mNotificationStackScroller.cancelLongPress(); mNotificationStackScroller.removeLongPressCallback(); } break; case MotionEvent.ACTION_POINTER_UP: Loading Loading @@ -739,7 +739,7 @@ public class NotificationPanelView extends PanelView implements mInitialTouchY = y; mInitialTouchX = x; mIntercepting = false; mNotificationStackScroller.cancelLongPress(); mNotificationStackScroller.removeLongPressCallback(); return true; } break; Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java +6 −7 Original line number Diff line number Diff line Loading @@ -165,6 +165,7 @@ import com.android.systemui.Interpolators; import com.android.systemui.Prefs; import com.android.systemui.R; import com.android.systemui.RecentsComponent; import com.android.systemui.SwipeHelper; import com.android.systemui.SystemUI; import com.android.systemui.SystemUIFactory; import com.android.systemui.UiOffloadThread; Loading Loading @@ -4982,7 +4983,7 @@ public class StatusBar extends SystemUI implements DemoMode, @Override public void onTouchSlopExceeded() { mStackScroller.cancelLongPress(); mStackScroller.removeLongPressCallback(); mStackScroller.checkSnoozeLeavebehind(); } Loading Loading @@ -6470,15 +6471,14 @@ public class StatusBar extends SystemUI implements DemoMode, true /* removeControls */, x, y, true /* resetMenu */); } protected ExpandableNotificationRow.LongPressListener getNotificationLongClicker() { return new ExpandableNotificationRow.LongPressListener() { protected SwipeHelper.LongPressListener getNotificationLongClicker() { return new SwipeHelper.LongPressListener() { @Override public boolean onLongPress(View v, final int x, final int y, MenuItem item) { if (!(v instanceof ExpandableNotificationRow)) { return false; } if (v.getWindowToken() == null) { Log.e(TAG, "Trying to show notification guts, but not attached to window"); return false; Loading @@ -6493,7 +6493,7 @@ public class StatusBar extends SystemUI implements DemoMode, closeAndSaveGuts(false /* removeLeavebehind */, false /* force */, true /* removeControls */, -1 /* x */, -1 /* y */, true /* resetMenu */); return true; return false; } bindGuts(row, item); NotificationGuts guts = row.getGuts(); Loading Loading @@ -6791,7 +6791,6 @@ public class StatusBar extends SystemUI implements DemoMode, row.setOnExpandClickListener(this); row.setRemoteViewClickHandler(mOnClickHandler); row.setInflationCallback(this); row.setLongPressListener(getNotificationLongClicker()); // Get the app name. // Note that Notification.Builder#bindHeaderAppName has similar logic Loading