Loading packages/SystemUI/plugin/src/com/android/systemui/plugins/statusbar/NotificationMenuRowPlugin.java +8 −3 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ package com.android.systemui.plugins.statusbar; import android.content.Context; import android.service.notification.StatusBarNotification; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; Loading @@ -37,7 +38,7 @@ import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin.MenuItem public interface NotificationMenuRowPlugin extends Plugin { public static final String ACTION = "com.android.systemui.action.PLUGIN_NOTIFICATION_MENU_ROW"; public static final int VERSION = 2; public static final int VERSION = 3; @ProvidesInterface(version = OnMenuEventListener.VERSION) public interface OnMenuEventListener { Loading Loading @@ -77,7 +78,7 @@ public interface NotificationMenuRowPlugin extends Plugin { public void setAppName(String appName); public void createMenu(ViewGroup parent); public void createMenu(ViewGroup parent, StatusBarNotification sbn); public View getMenuView(); Loading @@ -89,10 +90,14 @@ public interface NotificationMenuRowPlugin extends Plugin { public void onHeightUpdate(); public void onNotificationUpdated(); public void onNotificationUpdated(StatusBarNotification sbn); public boolean onTouchEvent(View view, MotionEvent ev, float velocity); public default boolean onInterceptTouchEvent(View view, MotionEvent ev) { return false; } public default boolean useDefaultMenuItems() { return false; } Loading packages/SystemUI/src/com/android/systemui/SwipeHelper.java +15 −5 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ import android.view.View; import android.view.ViewConfiguration; import android.view.accessibility.AccessibilityEvent; import com.android.systemui.classifier.FalsingManager; import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin; import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin.MenuItem; import com.android.systemui.statusbar.ExpandableNotificationRow; import com.android.systemui.statusbar.FlingAnimationUtils; Loading Loading @@ -81,6 +82,7 @@ public class SwipeHelper implements Gefingerpoken { private float mDensityScale; private float mTranslation = 0; private boolean mMenuRowIntercepting; private boolean mLongPressSent; private LongPressListener mLongPressListener; private Runnable mWatchLongPress; Loading Loading @@ -265,6 +267,10 @@ public class SwipeHelper implements Gefingerpoken { @Override public boolean onInterceptTouchEvent(final MotionEvent ev) { if (mCurrView instanceof ExpandableNotificationRow) { NotificationMenuRowPlugin nmr = ((ExpandableNotificationRow) mCurrView).getProvider(); mMenuRowIntercepting = nmr.onInterceptTouchEvent(mCurrView, ev); } final int action = ev.getAction(); switch (action) { Loading Loading @@ -300,7 +306,10 @@ public class SwipeHelper implements Gefingerpoken { menuItem = ((ExpandableNotificationRow) mCurrView) .getProvider().getLongpressMenuItem(mContext); } mLongPressListener.onLongPress(mCurrView, x, y, menuItem); if (menuItem != null) { mLongPressListener.onLongPress(mCurrView, x, y, menuItem); } } } }; Loading Loading @@ -330,15 +339,16 @@ public class SwipeHelper implements Gefingerpoken { case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: final boolean captured = (mDragging || mLongPressSent); final boolean captured = (mDragging || mLongPressSent || mMenuRowIntercepting); mDragging = false; mCurrView = null; mLongPressSent = false; mMenuRowIntercepting = false; removeLongPressCallback(); if (captured) return true; break; } return mDragging || mLongPressSent; return mDragging || mLongPressSent || mMenuRowIntercepting; } /** Loading Loading @@ -557,11 +567,11 @@ public class SwipeHelper implements Gefingerpoken { @Override public boolean onTouchEvent(MotionEvent ev) { if (mLongPressSent) { if (mLongPressSent && !mMenuRowIntercepting) { return true; } if (!mDragging) { if (!mDragging && !mMenuRowIntercepting) { if (mCallback.getChildAtPosition(ev) != null) { // We are dragging directly over a card, make sure that we also catch the gesture Loading packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java +3 −3 Original line number Diff line number Diff line Loading @@ -352,7 +352,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView mShowingPublicInitialized = false; updateNotificationColor(); if (mMenuRow != null) { mMenuRow.onNotificationUpdated(); mMenuRow.onNotificationUpdated(mStatusBarNotification); } if (mIsSummaryWithChildren) { mChildrenContainer.recreateNotificationHeader(mExpandClickListener); Loading Loading @@ -831,7 +831,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView public NotificationMenuRowPlugin createMenu() { if (mMenuRow.getMenuView() == null) { mMenuRow.createMenu(this); mMenuRow.createMenu(this, mStatusBarNotification); mMenuRow.setAppName(mAppName); FrameLayout.LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); Loading Loading @@ -866,7 +866,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView if (oldMenu != null) { int menuIndex = indexOfChild(oldMenu); removeView(oldMenu); mMenuRow.createMenu(ExpandableNotificationRow.this); mMenuRow.createMenu(ExpandableNotificationRow.this, mStatusBarNotification); mMenuRow.setAppName(mAppName); addView(mMenuRow.getMenuView(), menuIndex); } Loading packages/SystemUI/src/com/android/systemui/statusbar/NotificationMenuRow.java +2 −2 Original line number Diff line number Diff line Loading @@ -129,7 +129,7 @@ public class NotificationMenuRow implements NotificationMenuRowPlugin, View.OnCl } @Override public void createMenu(ViewGroup parent) { public void createMenu(ViewGroup parent, StatusBarNotification sbn) { mParent = (ExpandableNotificationRow) parent; createMenuViews(true /* resetState */); } Loading @@ -150,7 +150,7 @@ public class NotificationMenuRow implements NotificationMenuRowPlugin, View.OnCl } @Override public void onNotificationUpdated() { public void onNotificationUpdated(StatusBarNotification sbn) { if (mMenuContainer == null) { // Menu hasn't been created yet, no need to do anything. return; Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationMenuRowTest.java +3 −3 Original line number Diff line number Diff line Loading @@ -42,7 +42,7 @@ public class NotificationMenuRowTest extends LeakCheckedTest { @Test public void testAttachDetach() { NotificationMenuRowPlugin row = new NotificationMenuRow(mContext); row.createMenu(null); row.createMenu(null, null); ViewUtils.attachView(row.getMenuView()); TestableLooper.get(this).processAllMessages(); ViewUtils.detachView(row.getMenuView()); Loading @@ -52,9 +52,9 @@ public class NotificationMenuRowTest extends LeakCheckedTest { @Test public void testRecreateMenu() { NotificationMenuRowPlugin row = new NotificationMenuRow(mContext); row.createMenu(null); row.createMenu(null, null); assertTrue(row.getMenuView() != null); row.createMenu(null); row.createMenu(null, null); assertTrue(row.getMenuView() != null); } } Loading
packages/SystemUI/plugin/src/com/android/systemui/plugins/statusbar/NotificationMenuRowPlugin.java +8 −3 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ package com.android.systemui.plugins.statusbar; import android.content.Context; import android.service.notification.StatusBarNotification; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; Loading @@ -37,7 +38,7 @@ import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin.MenuItem public interface NotificationMenuRowPlugin extends Plugin { public static final String ACTION = "com.android.systemui.action.PLUGIN_NOTIFICATION_MENU_ROW"; public static final int VERSION = 2; public static final int VERSION = 3; @ProvidesInterface(version = OnMenuEventListener.VERSION) public interface OnMenuEventListener { Loading Loading @@ -77,7 +78,7 @@ public interface NotificationMenuRowPlugin extends Plugin { public void setAppName(String appName); public void createMenu(ViewGroup parent); public void createMenu(ViewGroup parent, StatusBarNotification sbn); public View getMenuView(); Loading @@ -89,10 +90,14 @@ public interface NotificationMenuRowPlugin extends Plugin { public void onHeightUpdate(); public void onNotificationUpdated(); public void onNotificationUpdated(StatusBarNotification sbn); public boolean onTouchEvent(View view, MotionEvent ev, float velocity); public default boolean onInterceptTouchEvent(View view, MotionEvent ev) { return false; } public default boolean useDefaultMenuItems() { return false; } Loading
packages/SystemUI/src/com/android/systemui/SwipeHelper.java +15 −5 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ import android.view.View; import android.view.ViewConfiguration; import android.view.accessibility.AccessibilityEvent; import com.android.systemui.classifier.FalsingManager; import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin; import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin.MenuItem; import com.android.systemui.statusbar.ExpandableNotificationRow; import com.android.systemui.statusbar.FlingAnimationUtils; Loading Loading @@ -81,6 +82,7 @@ public class SwipeHelper implements Gefingerpoken { private float mDensityScale; private float mTranslation = 0; private boolean mMenuRowIntercepting; private boolean mLongPressSent; private LongPressListener mLongPressListener; private Runnable mWatchLongPress; Loading Loading @@ -265,6 +267,10 @@ public class SwipeHelper implements Gefingerpoken { @Override public boolean onInterceptTouchEvent(final MotionEvent ev) { if (mCurrView instanceof ExpandableNotificationRow) { NotificationMenuRowPlugin nmr = ((ExpandableNotificationRow) mCurrView).getProvider(); mMenuRowIntercepting = nmr.onInterceptTouchEvent(mCurrView, ev); } final int action = ev.getAction(); switch (action) { Loading Loading @@ -300,7 +306,10 @@ public class SwipeHelper implements Gefingerpoken { menuItem = ((ExpandableNotificationRow) mCurrView) .getProvider().getLongpressMenuItem(mContext); } mLongPressListener.onLongPress(mCurrView, x, y, menuItem); if (menuItem != null) { mLongPressListener.onLongPress(mCurrView, x, y, menuItem); } } } }; Loading Loading @@ -330,15 +339,16 @@ public class SwipeHelper implements Gefingerpoken { case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: final boolean captured = (mDragging || mLongPressSent); final boolean captured = (mDragging || mLongPressSent || mMenuRowIntercepting); mDragging = false; mCurrView = null; mLongPressSent = false; mMenuRowIntercepting = false; removeLongPressCallback(); if (captured) return true; break; } return mDragging || mLongPressSent; return mDragging || mLongPressSent || mMenuRowIntercepting; } /** Loading Loading @@ -557,11 +567,11 @@ public class SwipeHelper implements Gefingerpoken { @Override public boolean onTouchEvent(MotionEvent ev) { if (mLongPressSent) { if (mLongPressSent && !mMenuRowIntercepting) { return true; } if (!mDragging) { if (!mDragging && !mMenuRowIntercepting) { if (mCallback.getChildAtPosition(ev) != null) { // We are dragging directly over a card, make sure that we also catch the gesture Loading
packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java +3 −3 Original line number Diff line number Diff line Loading @@ -352,7 +352,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView mShowingPublicInitialized = false; updateNotificationColor(); if (mMenuRow != null) { mMenuRow.onNotificationUpdated(); mMenuRow.onNotificationUpdated(mStatusBarNotification); } if (mIsSummaryWithChildren) { mChildrenContainer.recreateNotificationHeader(mExpandClickListener); Loading Loading @@ -831,7 +831,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView public NotificationMenuRowPlugin createMenu() { if (mMenuRow.getMenuView() == null) { mMenuRow.createMenu(this); mMenuRow.createMenu(this, mStatusBarNotification); mMenuRow.setAppName(mAppName); FrameLayout.LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); Loading Loading @@ -866,7 +866,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView if (oldMenu != null) { int menuIndex = indexOfChild(oldMenu); removeView(oldMenu); mMenuRow.createMenu(ExpandableNotificationRow.this); mMenuRow.createMenu(ExpandableNotificationRow.this, mStatusBarNotification); mMenuRow.setAppName(mAppName); addView(mMenuRow.getMenuView(), menuIndex); } Loading
packages/SystemUI/src/com/android/systemui/statusbar/NotificationMenuRow.java +2 −2 Original line number Diff line number Diff line Loading @@ -129,7 +129,7 @@ public class NotificationMenuRow implements NotificationMenuRowPlugin, View.OnCl } @Override public void createMenu(ViewGroup parent) { public void createMenu(ViewGroup parent, StatusBarNotification sbn) { mParent = (ExpandableNotificationRow) parent; createMenuViews(true /* resetState */); } Loading @@ -150,7 +150,7 @@ public class NotificationMenuRow implements NotificationMenuRowPlugin, View.OnCl } @Override public void onNotificationUpdated() { public void onNotificationUpdated(StatusBarNotification sbn) { if (mMenuContainer == null) { // Menu hasn't been created yet, no need to do anything. return; Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationMenuRowTest.java +3 −3 Original line number Diff line number Diff line Loading @@ -42,7 +42,7 @@ public class NotificationMenuRowTest extends LeakCheckedTest { @Test public void testAttachDetach() { NotificationMenuRowPlugin row = new NotificationMenuRow(mContext); row.createMenu(null); row.createMenu(null, null); ViewUtils.attachView(row.getMenuView()); TestableLooper.get(this).processAllMessages(); ViewUtils.detachView(row.getMenuView()); Loading @@ -52,9 +52,9 @@ public class NotificationMenuRowTest extends LeakCheckedTest { @Test public void testRecreateMenu() { NotificationMenuRowPlugin row = new NotificationMenuRow(mContext); row.createMenu(null); row.createMenu(null, null); assertTrue(row.getMenuView() != null); row.createMenu(null); row.createMenu(null, null); assertTrue(row.getMenuView() != null); } }