Merge changes Iac617598,I59fe4951,I374dc97a,Id882cff6,Ie3b4c571, ... into sc-v2-dev am: 3708e854a9
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/16072876 Change-Id: I5b3167a308be3fac8fa3d9049a49d8d6e91dfce6
This commit is contained in:
@@ -1526,6 +1526,24 @@ public class NotificationPanelViewController extends PanelViewController {
|
|||||||
mNotificationStackScrollLayoutController.resetScrollPosition();
|
mNotificationStackScrollLayoutController.resetScrollPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Collapses the panel. */
|
||||||
|
public void collapsePanel(boolean animate, boolean delayed, float speedUpFactor) {
|
||||||
|
boolean waiting = false;
|
||||||
|
if (animate && !isFullyCollapsed()) {
|
||||||
|
collapse(delayed, speedUpFactor);
|
||||||
|
waiting = true;
|
||||||
|
} else {
|
||||||
|
resetViews(false /* animate */);
|
||||||
|
setExpandedFraction(0); // just in case
|
||||||
|
}
|
||||||
|
if (!waiting) {
|
||||||
|
// it's possible that nothing animated, so we replicate the termination
|
||||||
|
// conditions of panelExpansionChanged here
|
||||||
|
// TODO(b/200063118): This can likely go away in a future refactor CL.
|
||||||
|
mBar.updateState(STATE_CLOSED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void collapse(boolean delayed, float speedUpFactor) {
|
public void collapse(boolean delayed, float speedUpFactor) {
|
||||||
if (!canPanelBeCollapsed()) {
|
if (!canPanelBeCollapsed()) {
|
||||||
@@ -2967,7 +2985,7 @@ public class NotificationPanelViewController extends PanelViewController {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onExpandingFinished() {
|
protected void onExpandingFinished() {
|
||||||
super.onExpandingFinished();
|
mScrimController.onExpandingFinished();
|
||||||
mNotificationStackScrollLayoutController.onExpansionStopped();
|
mNotificationStackScrollLayoutController.onExpansionStopped();
|
||||||
mHeadsUpManager.onExpandingFinished();
|
mHeadsUpManager.onExpandingFinished();
|
||||||
mConversationNotificationManager.onNotificationPanelExpandStateChanged(isFullyCollapsed());
|
mConversationNotificationManager.onNotificationPanelExpandStateChanged(isFullyCollapsed());
|
||||||
@@ -3042,6 +3060,7 @@ public class NotificationPanelViewController extends PanelViewController {
|
|||||||
protected void onTrackingStarted() {
|
protected void onTrackingStarted() {
|
||||||
mFalsingCollector.onTrackingStarted(!mKeyguardStateController.canDismissLockScreen());
|
mFalsingCollector.onTrackingStarted(!mKeyguardStateController.canDismissLockScreen());
|
||||||
super.onTrackingStarted();
|
super.onTrackingStarted();
|
||||||
|
mScrimController.onTrackingStarted();
|
||||||
if (mQsFullyExpanded) {
|
if (mQsFullyExpanded) {
|
||||||
mQsExpandImmediate = true;
|
mQsExpandImmediate = true;
|
||||||
if (!mShouldUseSplitNotificationShade) {
|
if (!mShouldUseSplitNotificationShade) {
|
||||||
@@ -3052,6 +3071,7 @@ public class NotificationPanelViewController extends PanelViewController {
|
|||||||
mAffordanceHelper.animateHideLeftRightIcon();
|
mAffordanceHelper.animateHideLeftRightIcon();
|
||||||
}
|
}
|
||||||
mNotificationStackScrollLayoutController.onPanelTrackingStarted();
|
mNotificationStackScrollLayoutController.onPanelTrackingStarted();
|
||||||
|
cancelPendingPanelCollapse();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -3241,7 +3261,7 @@ public class NotificationPanelViewController extends PanelViewController {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onClosingFinished() {
|
protected void onClosingFinished() {
|
||||||
super.onClosingFinished();
|
mStatusBar.onClosingFinished();
|
||||||
setClosingWithAlphaFadeout(false);
|
setClosingWithAlphaFadeout(false);
|
||||||
mMediaHierarchyManager.closeGuts();
|
mMediaHierarchyManager.closeGuts();
|
||||||
}
|
}
|
||||||
@@ -3671,13 +3691,27 @@ public class NotificationPanelViewController extends PanelViewController {
|
|||||||
mNotificationStackScrollLayoutController.setScrollingEnabled(b);
|
mNotificationStackScrollLayoutController.setScrollingEnabled(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Runnable mHideExpandedRunnable;
|
||||||
|
private final Runnable mMaybeHideExpandedRunnable = new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (getExpansionFraction() == 0.0f) {
|
||||||
|
mView.post(mHideExpandedRunnable);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize objects instead of injecting to avoid circular dependencies.
|
* Initialize objects instead of injecting to avoid circular dependencies.
|
||||||
|
*
|
||||||
|
* @param hideExpandedRunnable a runnable to run when we need to hide the expanded panel.
|
||||||
*/
|
*/
|
||||||
public void initDependencies(
|
public void initDependencies(
|
||||||
StatusBar statusBar,
|
StatusBar statusBar,
|
||||||
|
Runnable hideExpandedRunnable,
|
||||||
NotificationShelfController notificationShelfController) {
|
NotificationShelfController notificationShelfController) {
|
||||||
setStatusBar(statusBar);
|
setStatusBar(statusBar);
|
||||||
|
mHideExpandedRunnable = hideExpandedRunnable;
|
||||||
mNotificationStackScrollLayoutController.setShelfController(notificationShelfController);
|
mNotificationStackScrollLayoutController.setShelfController(notificationShelfController);
|
||||||
mNotificationShelfController = notificationShelfController;
|
mNotificationShelfController = notificationShelfController;
|
||||||
mLockscreenShadeTransitionController.bindController(notificationShelfController);
|
mLockscreenShadeTransitionController.bindController(notificationShelfController);
|
||||||
@@ -3733,6 +3767,45 @@ public class NotificationPanelViewController extends PanelViewController {
|
|||||||
|
|
||||||
private long mLastTouchDownTime = -1L;
|
private long mLastTouchDownTime = -1L;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onTouchForwardedFromStatusBar(MotionEvent event) {
|
||||||
|
// TODO(b/202981994): Move the touch debugging in this method to a central location.
|
||||||
|
// (Right now, it's split between StatusBar and here.)
|
||||||
|
|
||||||
|
// If panels aren't enabled, ignore the gesture and don't pass it down to the
|
||||||
|
// panel view.
|
||||||
|
if (!mCommandQueue.panelsEnabled()) {
|
||||||
|
if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
||||||
|
Log.v(
|
||||||
|
TAG,
|
||||||
|
String.format(
|
||||||
|
"onTouchForwardedFromStatusBar: "
|
||||||
|
+ "panel disabled, ignoring touch at (%d,%d)",
|
||||||
|
(int) event.getX(),
|
||||||
|
(int) event.getY()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the view that would receive the touch is disabled, just have status bar eat
|
||||||
|
// the gesture.
|
||||||
|
if (event.getAction() == MotionEvent.ACTION_DOWN && !mView.isEnabled()) {
|
||||||
|
Log.v(TAG,
|
||||||
|
String.format(
|
||||||
|
"onTouchForwardedFromStatusBar: "
|
||||||
|
+ "panel view disabled, eating touch at (%d,%d)",
|
||||||
|
(int) event.getX(),
|
||||||
|
(int) event.getY()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return mView.dispatchTouchEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onInterceptTouchEvent(MotionEvent event) {
|
public boolean onInterceptTouchEvent(MotionEvent event) {
|
||||||
if (mBlockTouches || mQs.disallowPanelTouches()) {
|
if (mBlockTouches || mQs.disallowPanelTouches()) {
|
||||||
@@ -3744,7 +3817,7 @@ public class NotificationPanelViewController extends PanelViewController {
|
|||||||
if (mStatusBar.isBouncerShowing()) {
|
if (mStatusBar.isBouncerShowing()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (mBar.panelEnabled()
|
if (mCommandQueue.panelsEnabled()
|
||||||
&& !mNotificationStackScrollLayoutController.isLongPressInProgress()
|
&& !mNotificationStackScrollLayoutController.isLongPressInProgress()
|
||||||
&& mHeadsUpTouchHelper.onInterceptTouchEvent(event)) {
|
&& mHeadsUpTouchHelper.onInterceptTouchEvent(event)) {
|
||||||
mMetricsLogger.count(COUNTER_PANEL_OPEN, 1);
|
mMetricsLogger.count(COUNTER_PANEL_OPEN, 1);
|
||||||
@@ -4568,6 +4641,11 @@ public class NotificationPanelViewController extends PanelViewController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Removes any pending runnables that would collapse the panel. */
|
||||||
|
public void cancelPendingPanelCollapse() {
|
||||||
|
mView.removeCallbacks(mMaybeHideExpandedRunnable);
|
||||||
|
}
|
||||||
|
|
||||||
private final PanelBar.PanelStateChangeListener mPanelStateChangeListener =
|
private final PanelBar.PanelStateChangeListener mPanelStateChangeListener =
|
||||||
new PanelBar.PanelStateChangeListener() {
|
new PanelBar.PanelStateChangeListener() {
|
||||||
|
|
||||||
@@ -4582,6 +4660,14 @@ public class NotificationPanelViewController extends PanelViewController {
|
|||||||
if (state == STATE_OPEN && mCurrentState != state) {
|
if (state == STATE_OPEN && mCurrentState != state) {
|
||||||
mView.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
|
mView.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
|
||||||
}
|
}
|
||||||
|
if (state == STATE_OPENING) {
|
||||||
|
mStatusBar.makeExpandedVisible(false);
|
||||||
|
}
|
||||||
|
if (state == STATE_CLOSED) {
|
||||||
|
// Close the status bar in the next frame so we can show the end of the
|
||||||
|
// animation.
|
||||||
|
mView.post(mMaybeHideExpandedRunnable);
|
||||||
|
}
|
||||||
mCurrentState = state;
|
mCurrentState = state;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -4589,4 +4675,10 @@ public class NotificationPanelViewController extends PanelViewController {
|
|||||||
public PanelBar.PanelStateChangeListener getPanelStateChangeListener() {
|
public PanelBar.PanelStateChangeListener getPanelStateChangeListener() {
|
||||||
return mPanelStateChangeListener;
|
return mPanelStateChangeListener;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** Returns the handler that the status bar should forward touches to. */
|
||||||
|
public PhoneStatusBarView.TouchEventHandler getStatusBarTouchEventHandler() {
|
||||||
|
return getTouchHandler()::onTouchForwardedFromStatusBar;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ import android.os.Bundle;
|
|||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.MotionEvent;
|
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
@@ -53,11 +52,18 @@ public abstract class PanelBar extends FrameLayout {
|
|||||||
public static final int STATE_OPENING = 1;
|
public static final int STATE_OPENING = 1;
|
||||||
public static final int STATE_OPEN = 2;
|
public static final int STATE_OPEN = 2;
|
||||||
|
|
||||||
private PanelViewController mPanel;
|
|
||||||
@Nullable private PanelStateChangeListener mPanelStateChangeListener;
|
@Nullable private PanelStateChangeListener mPanelStateChangeListener;
|
||||||
private int mState = STATE_CLOSED;
|
private int mState = STATE_CLOSED;
|
||||||
private boolean mTracking;
|
private boolean mTracking;
|
||||||
|
|
||||||
|
/** Updates the panel state if necessary. */
|
||||||
|
public void updateState(@PanelState int state) {
|
||||||
|
if (DEBUG) LOG("update state: %d -> %d", mState, state);
|
||||||
|
if (mState != state) {
|
||||||
|
go(state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void go(@PanelState int state) {
|
private void go(@PanelState int state) {
|
||||||
if (DEBUG) LOG("go state: %d -> %d", mState, state);
|
if (DEBUG) LOG("go state: %d -> %d", mState, state);
|
||||||
mState = state;
|
mState = state;
|
||||||
@@ -97,54 +103,11 @@ public abstract class PanelBar extends FrameLayout {
|
|||||||
super.onFinishInflate();
|
super.onFinishInflate();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Set the PanelViewController */
|
|
||||||
public void setPanel(PanelViewController pv) {
|
|
||||||
mPanel = pv;
|
|
||||||
pv.setBar(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Sets the listener that will be notified of panel state changes. */
|
/** Sets the listener that will be notified of panel state changes. */
|
||||||
public void setPanelStateChangeListener(PanelStateChangeListener listener) {
|
public void setPanelStateChangeListener(PanelStateChangeListener listener) {
|
||||||
mPanelStateChangeListener = listener;
|
mPanelStateChangeListener = listener;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean panelEnabled() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onTouchEvent(MotionEvent event) {
|
|
||||||
// Allow subclasses to implement enable/disable semantics
|
|
||||||
if (!panelEnabled()) {
|
|
||||||
if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
|
||||||
Log.v(TAG, String.format("onTouch: all panels disabled, ignoring touch at (%d,%d)",
|
|
||||||
(int) event.getX(), (int) event.getY()));
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
|
||||||
final PanelViewController panel = mPanel;
|
|
||||||
if (panel == null) {
|
|
||||||
// panel is not there, so we'll eat the gesture
|
|
||||||
Log.v(TAG, String.format("onTouch: no panel for touch at (%d,%d)",
|
|
||||||
(int) event.getX(), (int) event.getY()));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
boolean enabled = panel.isEnabled();
|
|
||||||
if (DEBUG) LOG("PanelBar.onTouch: state=%d ACTION_DOWN: panel %s %s", mState, panel,
|
|
||||||
(enabled ? "" : " (disabled)"));
|
|
||||||
if (!enabled) {
|
|
||||||
// panel is disabled, so we'll eat the gesture
|
|
||||||
Log.v(TAG, String.format(
|
|
||||||
"onTouch: panel (%s) is disabled, ignoring touch at (%d,%d)",
|
|
||||||
panel, (int) event.getX(), (int) event.getY()));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return mPanel == null || mPanel.getView().dispatchTouchEvent(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param frac the fraction from the expansion in [0, 1]
|
* @param frac the fraction from the expansion in [0, 1]
|
||||||
* @param expanded whether the panel is currently expanded; this is independent from the
|
* @param expanded whether the panel is currently expanded; this is independent from the
|
||||||
@@ -162,7 +125,6 @@ public abstract class PanelBar extends FrameLayout {
|
|||||||
if (expanded) {
|
if (expanded) {
|
||||||
if (mState == STATE_CLOSED) {
|
if (mState == STATE_CLOSED) {
|
||||||
go(STATE_OPENING);
|
go(STATE_OPENING);
|
||||||
onPanelPeeked();
|
|
||||||
}
|
}
|
||||||
fullyClosed = false;
|
fullyClosed = false;
|
||||||
fullyOpened = frac >= 1f;
|
fullyOpened = frac >= 1f;
|
||||||
@@ -171,44 +133,16 @@ public abstract class PanelBar extends FrameLayout {
|
|||||||
go(STATE_OPEN);
|
go(STATE_OPEN);
|
||||||
} else if (fullyClosed && !mTracking && mState != STATE_CLOSED) {
|
} else if (fullyClosed && !mTracking && mState != STATE_CLOSED) {
|
||||||
go(STATE_CLOSED);
|
go(STATE_CLOSED);
|
||||||
onPanelCollapsed();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SPEW) LOG("panelExpansionChanged: end state=%d [%s%s ]", mState,
|
if (SPEW) LOG("panelExpansionChanged: end state=%d [%s%s ]", mState,
|
||||||
fullyOpened?" fullyOpened":"", fullyClosed?" fullyClosed":"");
|
fullyOpened?" fullyOpened":"", fullyClosed?" fullyClosed":"");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void collapsePanel(boolean animate, boolean delayed, float speedUpFactor) {
|
|
||||||
boolean waiting = false;
|
|
||||||
PanelViewController pv = mPanel;
|
|
||||||
if (animate && !pv.isFullyCollapsed()) {
|
|
||||||
pv.collapse(delayed, speedUpFactor);
|
|
||||||
waiting = true;
|
|
||||||
} else {
|
|
||||||
pv.resetViews(false /* animate */);
|
|
||||||
pv.setExpandedFraction(0); // just in case
|
|
||||||
}
|
|
||||||
if (DEBUG) LOG("collapsePanel: animate=%s waiting=%s", animate, waiting);
|
|
||||||
if (!waiting && mState != STATE_CLOSED) {
|
|
||||||
// it's possible that nothing animated, so we replicate the termination
|
|
||||||
// conditions of panelExpansionChanged here
|
|
||||||
go(STATE_CLOSED);
|
|
||||||
onPanelCollapsed();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onPanelPeeked() {
|
|
||||||
if (DEBUG) LOG("onPanelPeeked");
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isClosed() {
|
public boolean isClosed() {
|
||||||
return mState == STATE_CLOSED;
|
return mState == STATE_CLOSED;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onPanelCollapsed() {
|
|
||||||
if (DEBUG) LOG("onPanelCollapsed");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onTrackingStarted() {
|
public void onTrackingStarted() {
|
||||||
mTracking = true;
|
mTracking = true;
|
||||||
}
|
}
|
||||||
@@ -217,14 +151,6 @@ public abstract class PanelBar extends FrameLayout {
|
|||||||
mTracking = false;
|
mTracking = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onExpandingFinished() {
|
|
||||||
if (DEBUG) LOG("onExpandingFinished");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onClosingFinished() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/** An interface that will be notified of panel state changes. */
|
/** An interface that will be notified of panel state changes. */
|
||||||
public interface PanelStateChangeListener {
|
public interface PanelStateChangeListener {
|
||||||
/** Called when the state changes. */
|
/** Called when the state changes. */
|
||||||
|
|||||||
@@ -185,10 +185,9 @@ public abstract class PanelViewController {
|
|||||||
protected final SysuiStatusBarStateController mStatusBarStateController;
|
protected final SysuiStatusBarStateController mStatusBarStateController;
|
||||||
protected final AmbientState mAmbientState;
|
protected final AmbientState mAmbientState;
|
||||||
protected final LockscreenGestureLogger mLockscreenGestureLogger;
|
protected final LockscreenGestureLogger mLockscreenGestureLogger;
|
||||||
|
private final TouchHandler mTouchHandler;
|
||||||
|
|
||||||
protected void onExpandingFinished() {
|
protected abstract void onExpandingFinished();
|
||||||
mBar.onExpandingFinished();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void onExpandingStarted() {
|
protected void onExpandingStarted() {
|
||||||
}
|
}
|
||||||
@@ -226,6 +225,7 @@ public abstract class PanelViewController {
|
|||||||
mView = view;
|
mView = view;
|
||||||
mStatusBarKeyguardViewManager = statusBarKeyguardViewManager;
|
mStatusBarKeyguardViewManager = statusBarKeyguardViewManager;
|
||||||
mLockscreenGestureLogger = lockscreenGestureLogger;
|
mLockscreenGestureLogger = lockscreenGestureLogger;
|
||||||
|
mTouchHandler = createTouchHandler();
|
||||||
mView.addOnAttachStateChangeListener(new View.OnAttachStateChangeListener() {
|
mView.addOnAttachStateChangeListener(new View.OnAttachStateChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onViewAttachedToWindow(View v) {
|
public void onViewAttachedToWindow(View v) {
|
||||||
@@ -238,7 +238,7 @@ public abstract class PanelViewController {
|
|||||||
});
|
});
|
||||||
|
|
||||||
mView.addOnLayoutChangeListener(createLayoutChangeListener());
|
mView.addOnLayoutChangeListener(createLayoutChangeListener());
|
||||||
mView.setOnTouchListener(createTouchHandler());
|
mView.setOnTouchListener(mTouchHandler);
|
||||||
mView.setOnConfigurationChangedListener(createOnConfigurationChangedListener());
|
mView.setOnConfigurationChangedListener(createOnConfigurationChangedListener());
|
||||||
|
|
||||||
mResources = mView.getResources();
|
mResources = mView.getResources();
|
||||||
@@ -289,6 +289,10 @@ public abstract class PanelViewController {
|
|||||||
: mTouchSlop;
|
: mTouchSlop;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected TouchHandler getTouchHandler() {
|
||||||
|
return mTouchHandler;
|
||||||
|
}
|
||||||
|
|
||||||
private void addMovement(MotionEvent event) {
|
private void addMovement(MotionEvent event) {
|
||||||
// Add movement to velocity tracker using raw screen X and Y coordinates instead
|
// Add movement to velocity tracker using raw screen X and Y coordinates instead
|
||||||
// of window coordinates because the window frame may be moving at the same time.
|
// of window coordinates because the window frame may be moving at the same time.
|
||||||
@@ -448,6 +452,7 @@ public abstract class PanelViewController {
|
|||||||
protected void onTrackingStopped(boolean expand) {
|
protected void onTrackingStopped(boolean expand) {
|
||||||
mTracking = false;
|
mTracking = false;
|
||||||
mBar.onTrackingStopped(expand);
|
mBar.onTrackingStopped(expand);
|
||||||
|
mStatusBar.onTrackingStopped(expand);
|
||||||
updatePanelExpansionAndVisibility();
|
updatePanelExpansionAndVisibility();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -455,6 +460,7 @@ public abstract class PanelViewController {
|
|||||||
endClosing();
|
endClosing();
|
||||||
mTracking = true;
|
mTracking = true;
|
||||||
mBar.onTrackingStarted();
|
mBar.onTrackingStarted();
|
||||||
|
mStatusBar.onTrackingStarted();
|
||||||
notifyExpandingStarted();
|
notifyExpandingStarted();
|
||||||
updatePanelExpansionAndVisibility();
|
updatePanelExpansionAndVisibility();
|
||||||
}
|
}
|
||||||
@@ -927,10 +933,7 @@ public abstract class PanelViewController {
|
|||||||
mView.removeCallbacks(mFlingCollapseRunnable);
|
mView.removeCallbacks(mFlingCollapseRunnable);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void onClosingFinished() {
|
protected abstract void onClosingFinished();
|
||||||
mBar.onClosingFinished();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
protected void startUnlockHintAnimation() {
|
protected void startUnlockHintAnimation() {
|
||||||
|
|
||||||
@@ -1153,23 +1156,28 @@ public abstract class PanelViewController {
|
|||||||
return mView;
|
return mView;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isEnabled() {
|
|
||||||
return mView.isEnabled();
|
|
||||||
}
|
|
||||||
|
|
||||||
public OnLayoutChangeListener createLayoutChangeListener() {
|
public OnLayoutChangeListener createLayoutChangeListener() {
|
||||||
return new OnLayoutChangeListener();
|
return new OnLayoutChangeListener();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected TouchHandler createTouchHandler() {
|
protected abstract TouchHandler createTouchHandler();
|
||||||
return new TouchHandler();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected OnConfigurationChangedListener createOnConfigurationChangedListener() {
|
protected OnConfigurationChangedListener createOnConfigurationChangedListener() {
|
||||||
return new OnConfigurationChangedListener();
|
return new OnConfigurationChangedListener();
|
||||||
}
|
}
|
||||||
|
|
||||||
public class TouchHandler implements View.OnTouchListener {
|
public abstract class TouchHandler implements View.OnTouchListener {
|
||||||
|
/**
|
||||||
|
* Method called when a touch has occurred on {@link PhoneStatusBarView}.
|
||||||
|
*
|
||||||
|
* Touches that occur on the status bar view may have ramifications for the notification
|
||||||
|
* panel (e.g. a touch that pulls down the shade could start on the status bar), so we need
|
||||||
|
* to notify the panel controller when these touches occur.
|
||||||
|
*
|
||||||
|
* Returns true if the event was handled and false otherwise.
|
||||||
|
*/
|
||||||
|
public abstract boolean onTouchForwardedFromStatusBar(MotionEvent event);
|
||||||
|
|
||||||
public boolean onInterceptTouchEvent(MotionEvent event) {
|
public boolean onInterceptTouchEvent(MotionEvent event) {
|
||||||
if (mInstantExpanding || !mNotificationsDragEnabled || mTouchDisabled || (mMotionAborted
|
if (mInstantExpanding || !mNotificationsDragEnabled || mTouchDisabled || (mMotionAborted
|
||||||
&& event.getActionMasked() != MotionEvent.ACTION_DOWN)) {
|
&& event.getActionMasked() != MotionEvent.ACTION_DOWN)) {
|
||||||
@@ -1435,4 +1443,8 @@ public abstract class PanelViewController {
|
|||||||
private void cancelJankMonitoring(int cuj) {
|
private void cancelJankMonitoring(int cuj) {
|
||||||
InteractionJankMonitor.getInstance().cancel(cuj);
|
InteractionJankMonitor.getInstance().cancel(cuj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected float getExpansionFraction() {
|
||||||
|
return mExpandedFraction;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ import android.content.res.Configuration;
|
|||||||
import android.graphics.Point;
|
import android.graphics.Point;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.util.EventLog;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.util.Pair;
|
import android.util.Pair;
|
||||||
import android.view.DisplayCutout;
|
import android.view.DisplayCutout;
|
||||||
@@ -37,7 +36,6 @@ import android.view.accessibility.AccessibilityEvent;
|
|||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
|
|
||||||
import com.android.systemui.Dependency;
|
import com.android.systemui.Dependency;
|
||||||
import com.android.systemui.EventLogTags;
|
|
||||||
import com.android.systemui.R;
|
import com.android.systemui.R;
|
||||||
import com.android.systemui.plugins.DarkIconDispatcher;
|
import com.android.systemui.plugins.DarkIconDispatcher;
|
||||||
import com.android.systemui.plugins.DarkIconDispatcher.DarkReceiver;
|
import com.android.systemui.plugins.DarkIconDispatcher.DarkReceiver;
|
||||||
@@ -55,14 +53,6 @@ public class PhoneStatusBarView extends PanelBar {
|
|||||||
StatusBar mBar;
|
StatusBar mBar;
|
||||||
|
|
||||||
private ScrimController mScrimController;
|
private ScrimController mScrimController;
|
||||||
private Runnable mHideExpandedRunnable = new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
if (mPanelFraction == 0.0f) {
|
|
||||||
mBar.makeExpandedInvisible();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
private DarkReceiver mBattery;
|
private DarkReceiver mBattery;
|
||||||
private DarkReceiver mClock;
|
private DarkReceiver mClock;
|
||||||
private int mRotationOrientation = -1;
|
private int mRotationOrientation = -1;
|
||||||
@@ -76,15 +66,12 @@ public class PhoneStatusBarView extends PanelBar {
|
|||||||
@Nullable
|
@Nullable
|
||||||
private List<StatusBar.ExpansionChangedListener> mExpansionChangedListeners;
|
private List<StatusBar.ExpansionChangedListener> mExpansionChangedListeners;
|
||||||
@Nullable
|
@Nullable
|
||||||
private PanelExpansionStateChangedListener mPanelExpansionStateChangedListener;
|
private TouchEventHandler mTouchEventHandler;
|
||||||
|
|
||||||
private PanelEnabledProvider mPanelEnabledProvider;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draw this many pixels into the left/right side of the cutout to optimally use the space
|
* Draw this many pixels into the left/right side of the cutout to optimally use the space
|
||||||
*/
|
*/
|
||||||
private int mCutoutSideNudge = 0;
|
private int mCutoutSideNudge = 0;
|
||||||
private boolean mHeadsUpVisible;
|
|
||||||
|
|
||||||
public PhoneStatusBarView(Context context, AttributeSet attrs) {
|
public PhoneStatusBarView(Context context, AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
@@ -100,8 +87,8 @@ public class PhoneStatusBarView extends PanelBar {
|
|||||||
mExpansionChangedListeners = listeners;
|
mExpansionChangedListeners = listeners;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setPanelExpansionStateChangedListener(PanelExpansionStateChangedListener listener) {
|
void setTouchEventHandler(TouchEventHandler handler) {
|
||||||
mPanelExpansionStateChangedListener = listener;
|
mTouchEventHandler = handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setScrimController(ScrimController scrimController) {
|
public void setScrimController(ScrimController scrimController) {
|
||||||
@@ -177,15 +164,6 @@ public class PhoneStatusBarView extends PanelBar {
|
|||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean panelEnabled() {
|
|
||||||
if (mPanelEnabledProvider == null) {
|
|
||||||
Log.e(TAG, "panelEnabledProvider is null; defaulting to super class.");
|
|
||||||
return super.panelEnabled();
|
|
||||||
}
|
|
||||||
return mPanelEnabledProvider.panelEnabled();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onRequestSendAccessibilityEventInternal(View child, AccessibilityEvent event) {
|
public boolean onRequestSendAccessibilityEventInternal(View child, AccessibilityEvent event) {
|
||||||
if (super.onRequestSendAccessibilityEventInternal(child, event)) {
|
if (super.onRequestSendAccessibilityEventInternal(child, event)) {
|
||||||
@@ -201,80 +179,32 @@ public class PhoneStatusBarView extends PanelBar {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPanelPeeked() {
|
|
||||||
super.onPanelPeeked();
|
|
||||||
mBar.makeExpandedVisible(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPanelCollapsed() {
|
|
||||||
super.onPanelCollapsed();
|
|
||||||
// Close the status bar in the next frame so we can show the end of the animation.
|
|
||||||
post(mHideExpandedRunnable);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removePendingHideExpandedRunnables() {
|
|
||||||
removeCallbacks(mHideExpandedRunnable);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onTouchEvent(MotionEvent event) {
|
public boolean onTouchEvent(MotionEvent event) {
|
||||||
boolean barConsumedEvent = mBar.interceptTouchEvent(event);
|
mBar.onTouchEvent(event);
|
||||||
|
if (mTouchEventHandler == null) {
|
||||||
if (DEBUG_GESTURES) {
|
Log.w(
|
||||||
if (event.getActionMasked() != MotionEvent.ACTION_MOVE) {
|
TAG,
|
||||||
EventLog.writeEvent(EventLogTags.SYSUI_PANELBAR_TOUCH,
|
String.format(
|
||||||
event.getActionMasked(), (int) event.getX(), (int) event.getY(),
|
"onTouch: No touch handler provided; eating gesture at (%d,%d)",
|
||||||
barConsumedEvent ? 1 : 0);
|
(int) event.getX(),
|
||||||
|
(int) event.getY()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
return mTouchEventHandler.handleTouchEvent(event);
|
||||||
|
|
||||||
return barConsumedEvent || super.onTouchEvent(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onTrackingStarted() {
|
|
||||||
super.onTrackingStarted();
|
|
||||||
mBar.onTrackingStarted();
|
|
||||||
mScrimController.onTrackingStarted();
|
|
||||||
removePendingHideExpandedRunnables();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onClosingFinished() {
|
|
||||||
super.onClosingFinished();
|
|
||||||
mBar.onClosingFinished();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onTrackingStopped(boolean expand) {
|
|
||||||
super.onTrackingStopped(expand);
|
|
||||||
mBar.onTrackingStopped(expand);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onExpandingFinished() {
|
|
||||||
super.onExpandingFinished();
|
|
||||||
mScrimController.onExpandingFinished();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onInterceptTouchEvent(MotionEvent event) {
|
public boolean onInterceptTouchEvent(MotionEvent event) {
|
||||||
return mBar.interceptTouchEvent(event) || super.onInterceptTouchEvent(event);
|
mBar.onTouchEvent(event);
|
||||||
|
return super.onInterceptTouchEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void panelExpansionChanged(float frac, boolean expanded) {
|
public void panelExpansionChanged(float frac, boolean expanded) {
|
||||||
super.panelExpansionChanged(frac, expanded);
|
super.panelExpansionChanged(frac, expanded);
|
||||||
if ((frac == 0 || frac == 1)) {
|
|
||||||
if (mPanelExpansionStateChangedListener != null) {
|
|
||||||
mPanelExpansionStateChangedListener.onPanelExpansionStateChanged();
|
|
||||||
} else {
|
|
||||||
Log.w(TAG, "No PanelExpansionStateChangedListener provided.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mExpansionChangedListeners != null) {
|
if (mExpansionChangedListeners != null) {
|
||||||
for (StatusBar.ExpansionChangedListener listener : mExpansionChangedListeners) {
|
for (StatusBar.ExpansionChangedListener listener : mExpansionChangedListeners) {
|
||||||
listener.onExpansionChanged(frac, expanded);
|
listener.onExpansionChanged(frac, expanded);
|
||||||
@@ -282,11 +212,6 @@ public class PhoneStatusBarView extends PanelBar {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Set the {@link PanelEnabledProvider} to use. */
|
|
||||||
public void setPanelEnabledProvider(PanelEnabledProvider panelEnabledProvider) {
|
|
||||||
mPanelEnabledProvider = panelEnabledProvider;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void updateResources() {
|
public void updateResources() {
|
||||||
mCutoutSideNudge = getResources().getDimensionPixelSize(
|
mCutoutSideNudge = getResources().getDimensionPixelSize(
|
||||||
R.dimen.display_cutout_margin_consumption);
|
R.dimen.display_cutout_margin_consumption);
|
||||||
@@ -366,15 +291,14 @@ public class PhoneStatusBarView extends PanelBar {
|
|||||||
getPaddingBottom());
|
getPaddingBottom());
|
||||||
}
|
}
|
||||||
|
|
||||||
/** An interface that will provide whether panel is enabled. */
|
/**
|
||||||
interface PanelEnabledProvider {
|
* A handler repsonsible for all touch event handling on the status bar.
|
||||||
/** Returns true if the panel is enabled and false otherwise. */
|
*
|
||||||
boolean panelEnabled();
|
* The handler will be notified each time {@link this#onTouchEvent} is called, and the return
|
||||||
}
|
* value from the handler will be returned from {@link this#onTouchEvent}.
|
||||||
|
**/
|
||||||
/** A listener that will be notified when a panel's expansion state may have changed. */
|
public interface TouchEventHandler {
|
||||||
public interface PanelExpansionStateChangedListener {
|
/** Called each time {@link this#onTouchEvent} is called. */
|
||||||
/** Called when a panel's expansion state may have changed. */
|
boolean handleTouchEvent(MotionEvent event);
|
||||||
void onPanelExpansionStateChanged();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,19 +26,15 @@ import com.android.systemui.util.ViewController
|
|||||||
/** Controller for [PhoneStatusBarView]. */
|
/** Controller for [PhoneStatusBarView]. */
|
||||||
class PhoneStatusBarViewController(
|
class PhoneStatusBarViewController(
|
||||||
view: PhoneStatusBarView,
|
view: PhoneStatusBarView,
|
||||||
commandQueue: CommandQueue,
|
|
||||||
statusBarMoveFromCenterAnimationController: StatusBarMoveFromCenterAnimationController?,
|
statusBarMoveFromCenterAnimationController: StatusBarMoveFromCenterAnimationController?,
|
||||||
panelExpansionStateChangedListener: PhoneStatusBarView.PanelExpansionStateChangedListener,
|
touchEventHandler: PhoneStatusBarView.TouchEventHandler,
|
||||||
) : ViewController<PhoneStatusBarView>(view) {
|
) : ViewController<PhoneStatusBarView>(view) {
|
||||||
|
|
||||||
override fun onViewAttached() {}
|
override fun onViewAttached() {}
|
||||||
override fun onViewDetached() {}
|
override fun onViewDetached() {}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
mView.setPanelEnabledProvider {
|
mView.setTouchEventHandler(touchEventHandler)
|
||||||
commandQueue.panelsEnabled()
|
|
||||||
}
|
|
||||||
mView.setPanelExpansionStateChangedListener(panelExpansionStateChangedListener)
|
|
||||||
|
|
||||||
statusBarMoveFromCenterAnimationController?.let { animationController ->
|
statusBarMoveFromCenterAnimationController?.let { animationController ->
|
||||||
val statusBarLeftSide: View = mView.findViewById(R.id.status_bar_left_side)
|
val statusBarLeftSide: View = mView.findViewById(R.id.status_bar_left_side)
|
||||||
|
|||||||
@@ -128,7 +128,8 @@ public class ShadeControllerImpl implements ShadeController {
|
|||||||
mNotificationShadeWindowController.setNotificationShadeFocusable(false);
|
mNotificationShadeWindowController.setNotificationShadeFocusable(false);
|
||||||
|
|
||||||
getStatusBar().getNotificationShadeWindowViewController().cancelExpandHelper();
|
getStatusBar().getNotificationShadeWindowViewController().cancelExpandHelper();
|
||||||
getStatusBarView().collapsePanel(true /* animate */, delayed, speedUpFactor);
|
getNotificationPanelViewController()
|
||||||
|
.collapsePanel(true /* animate */, delayed, speedUpFactor);
|
||||||
} else if (mBubblesOptional.isPresent()) {
|
} else if (mBubblesOptional.isPresent()) {
|
||||||
mBubblesOptional.get().collapseStack();
|
mBubblesOptional.get().collapseStack();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -902,6 +902,7 @@ public class StatusBar extends SystemUI implements
|
|||||||
mExpansionChangedListeners = new ArrayList<>();
|
mExpansionChangedListeners = new ArrayList<>();
|
||||||
addExpansionChangedListener(
|
addExpansionChangedListener(
|
||||||
(expansion, expanded) -> mScrimController.setRawPanelExpansionFraction(expansion));
|
(expansion, expanded) -> mScrimController.setRawPanelExpansionFraction(expansion));
|
||||||
|
addExpansionChangedListener(this::onPanelExpansionChanged);
|
||||||
|
|
||||||
mBubbleExpandListener =
|
mBubbleExpandListener =
|
||||||
(isExpanding, key) -> mContext.getMainExecutor().execute(() -> {
|
(isExpanding, key) -> mContext.getMainExecutor().execute(() -> {
|
||||||
@@ -1167,7 +1168,6 @@ public class StatusBar extends SystemUI implements
|
|||||||
PhoneStatusBarView oldStatusBarView = mStatusBarView;
|
PhoneStatusBarView oldStatusBarView = mStatusBarView;
|
||||||
mStatusBarView = (PhoneStatusBarView) statusBarFragment.getView();
|
mStatusBarView = (PhoneStatusBarView) statusBarFragment.getView();
|
||||||
mStatusBarView.setBar(this);
|
mStatusBarView.setBar(this);
|
||||||
mStatusBarView.setPanel(mNotificationPanelViewController);
|
|
||||||
mStatusBarView.setPanelStateChangeListener(
|
mStatusBarView.setPanelStateChangeListener(
|
||||||
mNotificationPanelViewController.getPanelStateChangeListener());
|
mNotificationPanelViewController.getPanelStateChangeListener());
|
||||||
mStatusBarView.setScrimController(mScrimController);
|
mStatusBarView.setScrimController(mScrimController);
|
||||||
@@ -1176,6 +1176,8 @@ public class StatusBar extends SystemUI implements
|
|||||||
sendInitialExpansionAmount(listener);
|
sendInitialExpansionAmount(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mNotificationPanelViewController.setBar(mStatusBarView);
|
||||||
|
|
||||||
StatusBarMoveFromCenterAnimationController moveFromCenterAnimation = null;
|
StatusBarMoveFromCenterAnimationController moveFromCenterAnimation = null;
|
||||||
if (mUnfoldTransitionConfig.isEnabled()) {
|
if (mUnfoldTransitionConfig.isEnabled()) {
|
||||||
moveFromCenterAnimation = mMoveFromCenterAnimation.get();
|
moveFromCenterAnimation = mMoveFromCenterAnimation.get();
|
||||||
@@ -1183,9 +1185,9 @@ public class StatusBar extends SystemUI implements
|
|||||||
mPhoneStatusBarViewController =
|
mPhoneStatusBarViewController =
|
||||||
new PhoneStatusBarViewController(
|
new PhoneStatusBarViewController(
|
||||||
mStatusBarView,
|
mStatusBarView,
|
||||||
mCommandQueue,
|
|
||||||
moveFromCenterAnimation,
|
moveFromCenterAnimation,
|
||||||
this::onPanelExpansionStateChanged);
|
mNotificationPanelViewController.getStatusBarTouchEventHandler()
|
||||||
|
);
|
||||||
mPhoneStatusBarViewController.init();
|
mPhoneStatusBarViewController.init();
|
||||||
|
|
||||||
mBatteryMeterViewController = new BatteryMeterViewController(
|
mBatteryMeterViewController = new BatteryMeterViewController(
|
||||||
@@ -1317,6 +1319,7 @@ public class StatusBar extends SystemUI implements
|
|||||||
|
|
||||||
mNotificationPanelViewController.initDependencies(
|
mNotificationPanelViewController.initDependencies(
|
||||||
this,
|
this,
|
||||||
|
this::makeExpandedInvisible,
|
||||||
mNotificationShelfController);
|
mNotificationShelfController);
|
||||||
|
|
||||||
BackDropView backdrop = mNotificationShadeWindowView.findViewById(R.id.backdrop);
|
BackDropView backdrop = mNotificationShadeWindowView.findViewById(R.id.backdrop);
|
||||||
@@ -1454,7 +1457,8 @@ public class StatusBar extends SystemUI implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onPanelExpansionStateChanged() {
|
private void onPanelExpansionChanged(float frac, boolean expanded) {
|
||||||
|
if (frac == 0 || frac == 1) {
|
||||||
if (getNavigationBarView() != null) {
|
if (getNavigationBarView() != null) {
|
||||||
getNavigationBarView().onStatusBarPanelStateChanged();
|
getNavigationBarView().onStatusBarPanelStateChanged();
|
||||||
}
|
}
|
||||||
@@ -1462,6 +1466,7 @@ public class StatusBar extends SystemUI implements
|
|||||||
getNotificationPanelViewController().updateSystemUiStateFlags();
|
getNotificationPanelViewController().updateSystemUiStateFlags();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
@@ -2158,7 +2163,8 @@ public class StatusBar extends SystemUI implements
|
|||||||
|
|
||||||
public void animateCollapseQuickSettings() {
|
public void animateCollapseQuickSettings() {
|
||||||
if (mState == StatusBarState.SHADE) {
|
if (mState == StatusBarState.SHADE) {
|
||||||
mStatusBarView.collapsePanel(true, false /* delayed */, 1.0f /* speedUpFactor */);
|
mNotificationPanelViewController.collapsePanel(
|
||||||
|
true, false /* delayed */, 1.0f /* speedUpFactor */);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2171,7 +2177,7 @@ public class StatusBar extends SystemUI implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Ensure the panel is fully collapsed (just in case; bug 6765842, 7260868)
|
// Ensure the panel is fully collapsed (just in case; bug 6765842, 7260868)
|
||||||
mStatusBarView.collapsePanel(/*animate=*/ false, false /* delayed*/,
|
mNotificationPanelViewController.collapsePanel(/*animate=*/ false, false /* delayed*/,
|
||||||
1.0f /* speedUpFactor */);
|
1.0f /* speedUpFactor */);
|
||||||
|
|
||||||
mNotificationPanelViewController.closeQs();
|
mNotificationPanelViewController.closeQs();
|
||||||
@@ -2205,7 +2211,10 @@ public class StatusBar extends SystemUI implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean interceptTouchEvent(MotionEvent event) {
|
/** Called when a touch event occurred on {@link PhoneStatusBarView}. */
|
||||||
|
public void onTouchEvent(MotionEvent event) {
|
||||||
|
// TODO(b/202981994): Move this touch debugging to a central location. (Right now, it's
|
||||||
|
// split between NotificationPanelViewController and here.)
|
||||||
if (DEBUG_GESTURES) {
|
if (DEBUG_GESTURES) {
|
||||||
if (event.getActionMasked() != MotionEvent.ACTION_MOVE) {
|
if (event.getActionMasked() != MotionEvent.ACTION_MOVE) {
|
||||||
EventLog.writeEvent(EventLogTags.SYSUI_STATUSBAR_TOUCH,
|
EventLog.writeEvent(EventLogTags.SYSUI_STATUSBAR_TOUCH,
|
||||||
@@ -2237,7 +2246,6 @@ public class StatusBar extends SystemUI implements
|
|||||||
event.getAction() == MotionEvent.ACTION_CANCEL;
|
event.getAction() == MotionEvent.ACTION_CANCEL;
|
||||||
setInteracting(StatusBarManager.WINDOW_STATUS_BAR, !upOrCancel || mExpandedVisible);
|
setInteracting(StatusBarManager.WINDOW_STATUS_BAR, !upOrCancel || mExpandedVisible);
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean isSameStatusBarState(int state) {
|
boolean isSameStatusBarState(int state) {
|
||||||
@@ -4465,7 +4473,7 @@ public class StatusBar extends SystemUI implements
|
|||||||
mNavigationBarController.touchAutoDim(mDisplayId);
|
mNavigationBarController.touchAutoDim(mDisplayId);
|
||||||
Trace.beginSection("StatusBar#updateKeyguardState");
|
Trace.beginSection("StatusBar#updateKeyguardState");
|
||||||
if (mState == StatusBarState.KEYGUARD && mStatusBarView != null) {
|
if (mState == StatusBarState.KEYGUARD && mStatusBarView != null) {
|
||||||
mStatusBarView.removePendingHideExpandedRunnables();
|
mNotificationPanelViewController.cancelPendingPanelCollapse();
|
||||||
}
|
}
|
||||||
updateDozingState();
|
updateDozingState();
|
||||||
checkBarModes();
|
checkBarModes();
|
||||||
|
|||||||
@@ -536,7 +536,7 @@ public class StatusBarCommandQueueCallbacks implements CommandQueue.Callbacks {
|
|||||||
}
|
}
|
||||||
if (mStatusBar.getStatusBarView() != null) {
|
if (mStatusBar.getStatusBarView() != null) {
|
||||||
if (!showing && mStatusBarStateController.getState() == StatusBarState.SHADE) {
|
if (!showing && mStatusBarStateController.getState() == StatusBarState.SHADE) {
|
||||||
mStatusBar.getStatusBarView().collapsePanel(
|
mNotificationPanelViewController.collapsePanel(
|
||||||
false /* animate */, false /* delayed */, 1.0f /* speedUpFactor */);
|
false /* animate */, false /* delayed */, 1.0f /* speedUpFactor */);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -450,6 +450,7 @@ public class NotificationPanelViewControllerTest extends SysuiTestCase {
|
|||||||
mControlsComponent);
|
mControlsComponent);
|
||||||
mNotificationPanelViewController.initDependencies(
|
mNotificationPanelViewController.initDependencies(
|
||||||
mStatusBar,
|
mStatusBar,
|
||||||
|
() -> {},
|
||||||
mNotificationShelfController);
|
mNotificationShelfController);
|
||||||
mNotificationPanelViewController.setHeadsUpManager(mHeadsUpManager);
|
mNotificationPanelViewController.setHeadsUpManager(mHeadsUpManager);
|
||||||
mNotificationPanelViewController.setBar(mPanelBar);
|
mNotificationPanelViewController.setBar(mPanelBar);
|
||||||
@@ -517,6 +518,51 @@ public class NotificationPanelViewControllerTest extends SysuiTestCase {
|
|||||||
assertThat(mNotificationPanelViewController.isTrackingBlocked()).isFalse();
|
assertThat(mNotificationPanelViewController.isTrackingBlocked()).isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void onTouchForwardedFromStatusBar_panelsNotEnabled_returnsFalseAndNoViewEvent() {
|
||||||
|
when(mCommandQueue.panelsEnabled()).thenReturn(false);
|
||||||
|
|
||||||
|
boolean returnVal = mTouchHandler.onTouchForwardedFromStatusBar(
|
||||||
|
MotionEvent.obtain(0L, 0L, MotionEvent.ACTION_DOWN, 0f, 0f, 0));
|
||||||
|
|
||||||
|
assertThat(returnVal).isFalse();
|
||||||
|
verify(mView, never()).dispatchTouchEvent(any());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void onTouchForwardedFromStatusBar_viewNotEnabled_returnsTrueAndNoViewEvent() {
|
||||||
|
when(mCommandQueue.panelsEnabled()).thenReturn(true);
|
||||||
|
when(mView.isEnabled()).thenReturn(false);
|
||||||
|
|
||||||
|
boolean returnVal = mTouchHandler.onTouchForwardedFromStatusBar(
|
||||||
|
MotionEvent.obtain(0L, 0L, MotionEvent.ACTION_DOWN, 0f, 0f, 0));
|
||||||
|
|
||||||
|
assertThat(returnVal).isTrue();
|
||||||
|
verify(mView, never()).dispatchTouchEvent(any());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void onTouchForwardedFromStatusBar_viewNotEnabledButIsMoveEvent_viewReceivesEvent() {
|
||||||
|
when(mCommandQueue.panelsEnabled()).thenReturn(true);
|
||||||
|
when(mView.isEnabled()).thenReturn(false);
|
||||||
|
MotionEvent event = MotionEvent.obtain(0L, 0L, MotionEvent.ACTION_MOVE, 0f, 0f, 0);
|
||||||
|
|
||||||
|
mTouchHandler.onTouchForwardedFromStatusBar(event);
|
||||||
|
|
||||||
|
verify(mView).dispatchTouchEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void onTouchForwardedFromStatusBar_panelAndViewEnabled_viewReceivesEvent() {
|
||||||
|
when(mCommandQueue.panelsEnabled()).thenReturn(true);
|
||||||
|
when(mView.isEnabled()).thenReturn(true);
|
||||||
|
MotionEvent event = MotionEvent.obtain(0L, 0L, MotionEvent.ACTION_DOWN, 0f, 0f, 0);
|
||||||
|
|
||||||
|
mTouchHandler.onTouchForwardedFromStatusBar(event);
|
||||||
|
|
||||||
|
verify(mView).dispatchTouchEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testA11y_initializeNode() {
|
public void testA11y_initializeNode() {
|
||||||
AccessibilityNodeInfo nodeInfo = new AccessibilityNodeInfo();
|
AccessibilityNodeInfo nodeInfo = new AccessibilityNodeInfo();
|
||||||
|
|||||||
@@ -17,13 +17,13 @@
|
|||||||
package com.android.systemui.statusbar.phone
|
package com.android.systemui.statusbar.phone
|
||||||
|
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
|
import android.view.MotionEvent
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.FrameLayout
|
import android.widget.FrameLayout
|
||||||
import androidx.test.filters.SmallTest
|
import androidx.test.filters.SmallTest
|
||||||
import androidx.test.platform.app.InstrumentationRegistry
|
import androidx.test.platform.app.InstrumentationRegistry
|
||||||
import com.android.systemui.R
|
import com.android.systemui.R
|
||||||
import com.android.systemui.SysuiTestCase
|
import com.android.systemui.SysuiTestCase
|
||||||
import com.android.systemui.statusbar.CommandQueue
|
|
||||||
import com.android.systemui.util.mockito.any
|
import com.android.systemui.util.mockito.any
|
||||||
import com.google.common.truth.Truth.assertThat
|
import com.google.common.truth.Truth.assertThat
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
@@ -31,15 +31,14 @@ import org.junit.Test
|
|||||||
import org.mockito.Mock
|
import org.mockito.Mock
|
||||||
import org.mockito.Mockito.`when`
|
import org.mockito.Mockito.`when`
|
||||||
import org.mockito.Mockito.verify
|
import org.mockito.Mockito.verify
|
||||||
|
import org.mockito.Mockito.mock
|
||||||
import org.mockito.MockitoAnnotations
|
import org.mockito.MockitoAnnotations
|
||||||
|
|
||||||
@SmallTest
|
@SmallTest
|
||||||
class PhoneStatusBarViewControllerTest : SysuiTestCase() {
|
class PhoneStatusBarViewControllerTest : SysuiTestCase() {
|
||||||
|
|
||||||
private val stateChangeListener = TestStateChangedListener()
|
private val touchEventHandler = TestTouchEventHandler()
|
||||||
|
|
||||||
@Mock
|
|
||||||
private lateinit var commandQueue: CommandQueue
|
|
||||||
@Mock
|
@Mock
|
||||||
private lateinit var panelViewController: PanelViewController
|
private lateinit var panelViewController: PanelViewController
|
||||||
@Mock
|
@Mock
|
||||||
@@ -63,58 +62,41 @@ class PhoneStatusBarViewControllerTest : SysuiTestCase() {
|
|||||||
val parent = FrameLayout(mContext) // add parent to keep layout params
|
val parent = FrameLayout(mContext) // add parent to keep layout params
|
||||||
view = LayoutInflater.from(mContext)
|
view = LayoutInflater.from(mContext)
|
||||||
.inflate(R.layout.status_bar, parent, false) as PhoneStatusBarView
|
.inflate(R.layout.status_bar, parent, false) as PhoneStatusBarView
|
||||||
view.setPanel(panelViewController)
|
|
||||||
view.setScrimController(scrimController)
|
view.setScrimController(scrimController)
|
||||||
|
view.setBar(mock(StatusBar::class.java))
|
||||||
}
|
}
|
||||||
|
|
||||||
controller = PhoneStatusBarViewController(
|
controller = PhoneStatusBarViewController(
|
||||||
view,
|
view,
|
||||||
commandQueue,
|
|
||||||
null,
|
null,
|
||||||
stateChangeListener
|
touchEventHandler,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun constructor_setsPanelEnabledProviderOnView() {
|
fun constructor_setsTouchHandlerOnView() {
|
||||||
var providerUsed = false
|
val event = MotionEvent.obtain(0L, 0L, MotionEvent.ACTION_DOWN, 0f, 0f, 0)
|
||||||
`when`(commandQueue.panelsEnabled()).then {
|
|
||||||
providerUsed = true
|
|
||||||
true
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the constructor correctly set a [PanelEnabledProvider], then it should be used
|
view.onTouchEvent(event)
|
||||||
// when [PhoneStatusBarView.panelEnabled] is called.
|
|
||||||
view.panelEnabled()
|
|
||||||
|
|
||||||
assertThat(providerUsed).isTrue()
|
assertThat(touchEventHandler.lastEvent).isEqualTo(event)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun constructor_moveFromCenterAnimationIsNotNull_moveFromCenterAnimationInitialized() {
|
fun constructor_moveFromCenterAnimationIsNotNull_moveFromCenterAnimationInitialized() {
|
||||||
controller = PhoneStatusBarViewController(
|
controller = PhoneStatusBarViewController(
|
||||||
view, commandQueue, moveFromCenterAnimation, stateChangeListener
|
view, moveFromCenterAnimation, touchEventHandler
|
||||||
)
|
)
|
||||||
|
|
||||||
verify(moveFromCenterAnimation).init(any(), any())
|
verify(moveFromCenterAnimation).init(any(), any())
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
private class TestTouchEventHandler : PhoneStatusBarView.TouchEventHandler {
|
||||||
fun constructor_setsExpansionStateChangedListenerOnView() {
|
var lastEvent: MotionEvent? = null
|
||||||
assertThat(stateChangeListener.stateChangeCalled).isFalse()
|
override fun handleTouchEvent(event: MotionEvent?): Boolean {
|
||||||
|
lastEvent = event
|
||||||
// If the constructor correctly set the listener, then it should be used when
|
return false
|
||||||
// [PhoneStatusBarView.panelExpansionChanged] is called.
|
|
||||||
view.panelExpansionChanged(0f, false)
|
|
||||||
|
|
||||||
assertThat(stateChangeListener.stateChangeCalled).isTrue()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class TestStateChangedListener : PhoneStatusBarView.PanelExpansionStateChangedListener {
|
|
||||||
var stateChangeCalled: Boolean = false
|
|
||||||
|
|
||||||
override fun onPanelExpansionStateChanged() {
|
|
||||||
stateChangeCalled = true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package com.android.systemui.statusbar.phone
|
package com.android.systemui.statusbar.phone
|
||||||
|
|
||||||
|
import android.view.MotionEvent
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.test.filters.SmallTest
|
import androidx.test.filters.SmallTest
|
||||||
import com.android.systemui.SysuiTestCase
|
import com.android.systemui.SysuiTestCase
|
||||||
@@ -48,63 +49,25 @@ class PhoneStatusBarViewTest : SysuiTestCase() {
|
|||||||
`when`(panelViewController.view).thenReturn(panelView)
|
`when`(panelViewController.view).thenReturn(panelView)
|
||||||
|
|
||||||
view = PhoneStatusBarView(mContext, null)
|
view = PhoneStatusBarView(mContext, null)
|
||||||
view.setPanel(panelViewController)
|
|
||||||
view.setScrimController(scrimController)
|
view.setScrimController(scrimController)
|
||||||
view.setBar(statusBar)
|
view.setBar(statusBar)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun panelEnabled_providerReturnsTrue_returnsTrue() {
|
fun panelExpansionChanged_expansionChangeListenerNotified() {
|
||||||
view.setPanelEnabledProvider { true }
|
val listener = TestExpansionChangedListener()
|
||||||
|
view.setExpansionChangedListeners(listOf(listener))
|
||||||
|
val fraction = 0.4f
|
||||||
|
val isExpanded = true
|
||||||
|
|
||||||
assertThat(view.panelEnabled()).isTrue()
|
view.panelExpansionChanged(fraction, isExpanded)
|
||||||
|
|
||||||
|
assertThat(listener.fraction).isEqualTo(fraction)
|
||||||
|
assertThat(listener.isExpanded).isEqualTo(isExpanded)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun panelEnabled_providerReturnsFalse_returnsFalse() {
|
fun panelExpansionChanged_noListeners_noCrash() {
|
||||||
view.setPanelEnabledProvider { false }
|
|
||||||
|
|
||||||
assertThat(view.panelEnabled()).isFalse()
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
fun panelEnabled_noProvider_noCrash() {
|
|
||||||
view.panelEnabled()
|
|
||||||
// No assert needed, just testing no crash
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
fun panelExpansionChanged_fracZero_stateChangeListenerNotified() {
|
|
||||||
val listener = TestExpansionStateChangedListener()
|
|
||||||
view.setPanelExpansionStateChangedListener(listener)
|
|
||||||
|
|
||||||
view.panelExpansionChanged(0f, false)
|
|
||||||
|
|
||||||
assertThat(listener.stateChangeCalled).isTrue()
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
fun panelExpansionChanged_fracOne_stateChangeListenerNotified() {
|
|
||||||
val listener = TestExpansionStateChangedListener()
|
|
||||||
view.setPanelExpansionStateChangedListener(listener)
|
|
||||||
|
|
||||||
view.panelExpansionChanged(1f, false)
|
|
||||||
|
|
||||||
assertThat(listener.stateChangeCalled).isTrue()
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
fun panelExpansionChanged_fracHalf_stateChangeListenerNotNotified() {
|
|
||||||
val listener = TestExpansionStateChangedListener()
|
|
||||||
view.setPanelExpansionStateChangedListener(listener)
|
|
||||||
|
|
||||||
view.panelExpansionChanged(0.5f, false)
|
|
||||||
|
|
||||||
assertThat(listener.stateChangeCalled).isFalse()
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
fun panelExpansionChanged_noStateChangeListener_noCrash() {
|
|
||||||
view.panelExpansionChanged(1f, false)
|
view.panelExpansionChanged(1f, false)
|
||||||
// No assert needed, just testing no crash
|
// No assert needed, just testing no crash
|
||||||
}
|
}
|
||||||
@@ -144,17 +107,52 @@ class PhoneStatusBarViewTest : SysuiTestCase() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun panelStateChanged_noListener_noCrash() {
|
fun onTouchEvent_listenerNotified() {
|
||||||
view.panelExpansionChanged(1f, true)
|
val handler = TestTouchEventHandler()
|
||||||
|
view.setTouchEventHandler(handler)
|
||||||
|
|
||||||
|
val event = MotionEvent.obtain(0L, 0L, MotionEvent.ACTION_DOWN, 0f, 0f, 0)
|
||||||
|
view.onTouchEvent(event)
|
||||||
|
|
||||||
|
assertThat(handler.lastEvent).isEqualTo(event)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun onTouchEvent_listenerReturnsTrue_viewReturnsTrue() {
|
||||||
|
val handler = TestTouchEventHandler()
|
||||||
|
view.setTouchEventHandler(handler)
|
||||||
|
val event = MotionEvent.obtain(0L, 0L, MotionEvent.ACTION_DOWN, 0f, 0f, 0)
|
||||||
|
|
||||||
|
handler.returnValue = true
|
||||||
|
|
||||||
|
assertThat(view.onTouchEvent(event)).isTrue()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun onTouchEvent_listenerReturnsFalse_viewReturnsFalse() {
|
||||||
|
val handler = TestTouchEventHandler()
|
||||||
|
view.setTouchEventHandler(handler)
|
||||||
|
val event = MotionEvent.obtain(0L, 0L, MotionEvent.ACTION_DOWN, 0f, 0f, 0)
|
||||||
|
|
||||||
|
handler.returnValue = false
|
||||||
|
|
||||||
|
assertThat(view.onTouchEvent(event)).isFalse()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun onTouchEvent_noListener_noCrash() {
|
||||||
|
view.onTouchEvent(MotionEvent.obtain(0L, 0L, MotionEvent.ACTION_DOWN, 0f, 0f, 0))
|
||||||
// No assert needed, just testing no crash
|
// No assert needed, just testing no crash
|
||||||
}
|
}
|
||||||
|
|
||||||
private class TestExpansionStateChangedListener
|
private class TestExpansionChangedListener
|
||||||
: PhoneStatusBarView.PanelExpansionStateChangedListener {
|
: StatusBar.ExpansionChangedListener {
|
||||||
var stateChangeCalled: Boolean = false
|
var fraction: Float = 0f
|
||||||
|
var isExpanded: Boolean = false
|
||||||
|
|
||||||
override fun onPanelExpansionStateChanged() {
|
override fun onExpansionChanged(expansion: Float, expanded: Boolean) {
|
||||||
stateChangeCalled = true
|
this.fraction = expansion
|
||||||
|
this.isExpanded = expanded
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -164,4 +162,13 @@ class PhoneStatusBarViewTest : SysuiTestCase() {
|
|||||||
this.state = state
|
this.state = state
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class TestTouchEventHandler : PhoneStatusBarView.TouchEventHandler {
|
||||||
|
var lastEvent: MotionEvent? = null
|
||||||
|
var returnValue: Boolean = false
|
||||||
|
override fun handleTouchEvent(event: MotionEvent?): Boolean {
|
||||||
|
lastEvent = event
|
||||||
|
return returnValue
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user