diff options
| author | 2023-03-15 15:49:41 -0400 | |
|---|---|---|
| committer | 2023-03-20 13:40:14 +0000 | |
| commit | f6e77e12f2e68b3d5be12dc04e8d0b02dc21a414 (patch) | |
| tree | 7d9872027f27adfac04006f63502660f9b1f5b72 | |
| parent | 4a3b5e4b1e55ce2ce25445475c7ace4dac49fe4d (diff) | |
Replace NPVC with an interface in HeadsUpTouchHelper
Eliminates a circular dependency and reduces NPVC's public API
Fixes: 273782136
Test: presubmits
Change-Id: I70915ce5f1e8658cce6dcfb3914334d4db23f857
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java | 44 | ||||
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpTouchHelper.java | 28 |
2 files changed, 51 insertions, 21 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java index 1c3e0112967e..3c61432acc54 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java +++ b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java @@ -2897,15 +2897,7 @@ public final class NotificationPanelViewController implements Dumpable { mHeadsUpManager.addListener(mOnHeadsUpChangedListener); mHeadsUpTouchHelper = new HeadsUpTouchHelper(headsUpManager, mNotificationStackScrollLayoutController.getHeadsUpCallback(), - NotificationPanelViewController.this); - } - - public void setTrackedHeadsUp(ExpandableNotificationRow pickedChild) { - if (pickedChild != null) { - updateTrackingHeadsUp(pickedChild); - mExpandingFromHeadsUp = true; - } - // otherwise we update the state when the expansion is finished + new HeadsUpNotificationViewControllerImpl()); } private void onClosingFinished() { @@ -2953,7 +2945,8 @@ public final class NotificationPanelViewController implements Dumpable { } /** Called when a HUN is dragged up or down to indicate the starting height for shade motion. */ - public void setHeadsUpDraggingStartingHeight(int startHeight) { + @VisibleForTesting + void setHeadsUpDraggingStartingHeight(int startHeight) { mHeadsUpStartHeight = startHeight; float scrimMinFraction; if (mSplitShadeEnabled) { @@ -2987,10 +2980,6 @@ public final class NotificationPanelViewController implements Dumpable { mScrimController.setPanelScrimMinFraction(mMinFraction); } - public void clearNotificationEffects() { - mCentralSurfaces.clearNotificationEffects(); - } - private boolean isPanelVisibleBecauseOfHeadsUp() { return (mHeadsUpManager.hasPinnedHeadsUp() || mHeadsUpAnimatingAway) && mBarState == StatusBarState.SHADE; @@ -5133,6 +5122,33 @@ public final class NotificationPanelViewController implements Dumpable { } } + private final class HeadsUpNotificationViewControllerImpl implements + HeadsUpTouchHelper.HeadsUpNotificationViewController { + @Override + public void setHeadsUpDraggingStartingHeight(int startHeight) { + NotificationPanelViewController.this.setHeadsUpDraggingStartingHeight(startHeight); + } + + @Override + public void setTrackedHeadsUp(ExpandableNotificationRow pickedChild) { + if (pickedChild != null) { + updateTrackingHeadsUp(pickedChild); + mExpandingFromHeadsUp = true; + } + // otherwise we update the state when the expansion is finished + } + + @Override + public void startExpand(float x, float y, boolean startTracking, float expandedHeight) { + startExpandMotion(x, y, startTracking, expandedHeight); + } + + @Override + public void clearNotificationEffects() { + mCentralSurfaces.clearNotificationEffects(); + } + } + private final class ShadeAccessibilityDelegate extends AccessibilityDelegate { @Override public void onInitializeAccessibilityNodeInfo(View host, diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpTouchHelper.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpTouchHelper.java index 90d0b697337a..16c2e36af6b8 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpTouchHelper.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpTouchHelper.java @@ -21,7 +21,6 @@ import android.view.MotionEvent; import android.view.ViewConfiguration; import com.android.systemui.Gefingerpoken; -import com.android.systemui.shade.NotificationPanelViewController; import com.android.systemui.statusbar.notification.collection.NotificationEntry; import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow; import com.android.systemui.statusbar.notification.row.ExpandableView; @@ -31,21 +30,21 @@ import com.android.systemui.statusbar.notification.row.ExpandableView; */ public class HeadsUpTouchHelper implements Gefingerpoken { - private HeadsUpManagerPhone mHeadsUpManager; - private Callback mCallback; + private final HeadsUpManagerPhone mHeadsUpManager; + private final Callback mCallback; private int mTrackingPointer; - private float mTouchSlop; + private final float mTouchSlop; private float mInitialTouchX; private float mInitialTouchY; private boolean mTouchingHeadsUpView; private boolean mTrackingHeadsUp; private boolean mCollapseSnoozes; - private NotificationPanelViewController mPanel; + private final HeadsUpNotificationViewController mPanel; private ExpandableNotificationRow mPickedChild; public HeadsUpTouchHelper(HeadsUpManagerPhone headsUpManager, Callback callback, - NotificationPanelViewController notificationPanelView) { + HeadsUpNotificationViewController notificationPanelView) { mHeadsUpManager = headsUpManager; mCallback = callback; mPanel = notificationPanelView; @@ -116,7 +115,7 @@ public class HeadsUpTouchHelper implements Gefingerpoken { int startHeight = (int) (mPickedChild.getActualHeight() + mPickedChild.getTranslationY()); mPanel.setHeadsUpDraggingStartingHeight(startHeight); - mPanel.startExpandMotion(x, y, true /* startTracking */, startHeight); + mPanel.startExpand(x, y, true /* startTracking */, startHeight); // This call needs to be after the expansion start otherwise we will get a // flicker of one frame as it's not expanded yet. mHeadsUpManager.unpinAll(true); @@ -181,4 +180,19 @@ public class HeadsUpTouchHelper implements Gefingerpoken { boolean isExpanded(); Context getContext(); } + + /** The controller for a view that houses heads up notifications. */ + public interface HeadsUpNotificationViewController { + /** Called when a HUN is dragged to indicate the starting height for shade motion. */ + void setHeadsUpDraggingStartingHeight(int startHeight); + + /** Sets notification that is being expanded. */ + void setTrackedHeadsUp(ExpandableNotificationRow expandableNotificationRow); + + /** Called when a MotionEvent is about to trigger expansion. */ + void startExpand(float newX, float newY, boolean startTracking, float expandedHeight); + + /** Clear any effects that were added for the expansion. */ + void clearNotificationEffects(); + } } |