Replace NPVC with an interface in HeadsUpTouchHelper
Eliminates a circular dependency and reduces NPVC's public API Fixes: 273782136 Test: presubmits Change-Id: I70915ce5f1e8658cce6dcfb3914334d4db23f857
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user