Merge "Move NotificationListContainer out of NSSL."

This commit is contained in:
TreeHugger Robot
2020-08-12 21:38:13 +00:00
committed by Android (Google) Code Review
9 changed files with 296 additions and 127 deletions

View File

@@ -180,8 +180,7 @@ import javax.inject.Named;
* A layout which handles a dynamic amount of notifications and presents them in a scrollable stack.
*/
public class NotificationStackScrollLayout extends ViewGroup implements ScrollAdapter,
NotificationListContainer, ConfigurationListener, Dumpable,
DynamicPrivacyController.Listener {
ConfigurationListener, Dumpable, DynamicPrivacyController.Listener {
public static final float BACKGROUND_ALPHA_DIMMED = 0.7f;
private static final String TAG = "StackScroller";
@@ -213,6 +212,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
private float mExpandedHeight;
private int mOwnScrollY;
private View mScrollAnchorView;
private int mScrollAnchorViewY;
private int mMaxLayoutHeight;
@@ -545,6 +545,19 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
updateDecorViews(useDarkText);
};
private final ExpandableView.OnHeightChangedListener mOnChildHeightChangedListener =
new ExpandableView.OnHeightChangedListener() {
@Override
public void onHeightChanged(ExpandableView view, boolean needsAnimation) {
onChildHeightChanged(view, needsAnimation);
}
@Override
public void onReset(ExpandableView view) {
onChildHeightReset(view);
}
};
@Inject
public NotificationStackScrollLayout(
@Named(VIEW_CONTEXT) Context context,
@@ -576,7 +589,6 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
mLockscreenUserManager = notificationLockscreenUserManager;
mNotificationGutsManager = notificationGutsManager;
mHeadsUpManager = headsUpManager;
mHeadsUpManager.addListener(mRoundnessManager);
mHeadsUpManager.setAnimationStateHandler(this::setHeadsUpGoingAwayAnimationsAllowed);
mKeyguardBypassController = keyguardBypassController;
mFalsingManager = falsingManager;
@@ -608,9 +620,6 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
res.getBoolean(R.bool.config_drawNotificationBackground);
mFadeNotificationsOnDismiss =
res.getBoolean(R.bool.config_fadeNotificationsOnDismiss);
mRoundnessManager.setAnimatedChildren(mChildrenToAddAnimated);
mRoundnessManager.setOnRoundingChangedCallback(this::invalidate);
addOnExpandedHeightChangedListener(mRoundnessManager::setExpanded);
mLockscreenUserManager.addUserChangedListener(mLockscreenUserChangeListener);
setOutlineProvider(mOutlineProvider);
@@ -637,13 +646,8 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
tunerService.addTunable((key, newValue) -> {
if (key.equals(HIGH_PRIORITY)) {
mHighPriorityBeforeSpeedBump = "1".equals(newValue);
} else if (key.equals(Settings.Secure.NOTIFICATION_DISMISS_RTL)) {
updateDismissRtlSetting("1".equals(newValue));
} else if (key.equals(Settings.Secure.NOTIFICATION_HISTORY_ENABLED)) {
updateFooter();
}
}, HIGH_PRIORITY, Settings.Secure.NOTIFICATION_DISMISS_RTL,
Settings.Secure.NOTIFICATION_HISTORY_ENABLED);
}, HIGH_PRIORITY);
mFeatureFlags = featureFlags;
mNotifPipeline = notifPipeline;
@@ -693,7 +697,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
}
}
private void updateDismissRtlSetting(boolean dismissRtl) {
void updateDismissRtlSetting(boolean dismissRtl) {
mDismissRtl = dismissRtl;
for (int i = 0; i < getChildCount(); i++) {
View child = getChildAt(i);
@@ -834,7 +838,6 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
Dependency.get(ConfigurationController.class).removeCallback(this);
}
@Override
@ShadeViewRefactor(RefactorComponent.SHADE_VIEW)
public NotificationSwipeActionHelper getSwipeActionHelper() {
return mSwipeHelper;
@@ -1150,14 +1153,16 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
mNoAmbient = noAmbient;
}
@Override
@ShadeViewRefactor(RefactorComponent.STATE_RESOLVER)
public void setChildLocationsChangedListener(
NotificationLogger.OnChildLocationsChangedListener listener) {
mListener = listener;
}
@Override
public void setScrollAnchorView(View scrollAnchorView) {
mScrollAnchorView = scrollAnchorView;
}
@ShadeViewRefactor(RefactorComponent.LAYOUT_ALGORITHM)
public boolean isInVisibleLocation(NotificationEntry entry) {
ExpandableNotificationRow row = entry.getRow();
@@ -1856,7 +1861,6 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
}
}
@Override
@ShadeViewRefactor(RefactorComponent.ADAPTER)
public ViewGroup getViewParentForNotification(NotificationEntry entry) {
return this;
@@ -2546,7 +2550,6 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
previous);
}
@Override
@ShadeViewRefactor(RefactorComponent.SHADE_VIEW)
public boolean hasPulsingNotifications() {
return mPulsing;
@@ -3050,7 +3053,6 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
}
@ShadeViewRefactor(RefactorComponent.STATE_RESOLVER)
@Override
public void cleanUpViewStateForEntry(NotificationEntry entry) {
View child = entry.getRow();
if (child == mSwipeHelper.getTranslatingParentView()) {
@@ -3317,7 +3319,9 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
@ShadeViewRefactor(RefactorComponent.SHADE_VIEW)
public void onViewAdded(View child) {
super.onViewAdded(child);
onViewAddedInternal((ExpandableView) child);
if (child instanceof ExpandableView) {
onViewAddedInternal((ExpandableView) child);
}
}
@ShadeViewRefactor(RefactorComponent.STATE_RESOLVER)
@@ -3350,9 +3354,9 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
}
@ShadeViewRefactor(RefactorComponent.COORDINATOR)
private void onViewAddedInternal(ExpandableView child) {
void onViewAddedInternal(ExpandableView child) {
child.setOnHeightChangedListener(mOnChildHeightChangedListener);
updateHideSensitiveForChild(child);
child.setOnHeightChangedListener(this);
generateAddAnimation(child, false /* fromMoreCard */);
updateAnimationState(child);
updateChronometerForChild(child);
@@ -3374,18 +3378,11 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
child.setHideSensitiveForIntrinsicHeight(mAmbientState.isHideSensitive());
}
@Override
@ShadeViewRefactor(RefactorComponent.SHADE_VIEW)
public void notifyGroupChildRemoved(ExpandableView row, ViewGroup childrenContainer) {
onViewRemovedInternal(row, childrenContainer);
}
@Override
@ShadeViewRefactor(RefactorComponent.SHADE_VIEW)
public void notifyGroupChildAdded(ExpandableView row) {
onViewAddedInternal(row);
}
@ShadeViewRefactor(RefactorComponent.STATE_RESOLVER)
public void setAnimationsEnabled(boolean animationsEnabled) {
mAnimationsEnabled = animationsEnabled;
@@ -3410,33 +3407,29 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
}
@ShadeViewRefactor(RefactorComponent.STATE_RESOLVER)
private void updateAnimationState(View child) {
void updateAnimationState(View child) {
updateAnimationState((mAnimationsEnabled || hasPulsingNotifications())
&& (mIsExpanded || isPinnedHeadsUp(child)), child);
}
@Override
@ShadeViewRefactor(RefactorComponent.SHADE_VIEW)
public void setExpandingNotification(ExpandableNotificationRow row) {
void setExpandingNotification(ExpandableNotificationRow row) {
mAmbientState.setExpandingNotification(row);
requestChildrenUpdate();
}
@Override
@ShadeViewRefactor(RefactorComponent.ADAPTER)
public void bindRow(ExpandableNotificationRow row) {
void bindRow(ExpandableNotificationRow row) {
row.setHeadsUpAnimatingAwayListener(animatingAway -> {
mRoundnessManager.onHeadsupAnimatingAwayChanged(row, animatingAway);
mHeadsUpAppearanceController.updateHeader(row.getEntry());
});
}
@Override
public boolean containsView(View v) {
return v.getParent() == this;
}
@Override
@ShadeViewRefactor(RefactorComponent.STATE_RESOLVER)
public void applyExpandAnimationParams(ExpandAnimationParameters params) {
mAmbientState.setExpandAnimationTopChange(params == null ? 0 : params.getTopChange());
@@ -3452,12 +3445,11 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
}
@ShadeViewRefactor(RefactorComponent.STATE_RESOLVER)
public boolean isAddOrRemoveAnimationPending() {
boolean isAddOrRemoveAnimationPending() {
return mNeedsAnimation
&& (!mChildrenToAddAnimated.isEmpty() || !mChildrenToRemoveAnimated.isEmpty());
}
@Override
@ShadeViewRefactor(RefactorComponent.STATE_RESOLVER)
public void generateAddAnimation(ExpandableView child, boolean fromMoreCard) {
if (mIsExpanded && mAnimationsEnabled && !mChangePositionInProgress && !isFullyHidden()) {
@@ -3475,7 +3467,6 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
}
}
@Override
@ShadeViewRefactor(RefactorComponent.STATE_RESOLVER)
public void changeViewPosition(ExpandableView child, int newIndex) {
Assert.isMainThread();
@@ -4471,12 +4462,12 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
}
@ShadeViewRefactor(RefactorComponent.COORDINATOR)
public int getEmptyBottomMargin() {
int getEmptyBottomMargin() {
return Math.max(mMaxLayoutHeight - mContentHeight, 0);
}
@ShadeViewRefactor(RefactorComponent.SHADE_VIEW)
public void checkSnoozeLeavebehind() {
void checkSnoozeLeavebehind() {
if (mCheckForLeavebehind) {
mNotificationGutsManager.closeAndSaveGuts(true /* removeLeavebehind */,
false /* force */, false /* removeControls */, -1 /* x */, -1 /* y */,
@@ -4486,19 +4477,19 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
}
@ShadeViewRefactor(RefactorComponent.SHADE_VIEW)
public void resetCheckSnoozeLeavebehind() {
void resetCheckSnoozeLeavebehind() {
mCheckForLeavebehind = true;
}
@ShadeViewRefactor(RefactorComponent.STATE_RESOLVER)
public void onExpansionStarted() {
void onExpansionStarted() {
mIsExpansionChanging = true;
mAmbientState.setExpansionChanging(true);
checkSnoozeLeavebehind();
}
@ShadeViewRefactor(RefactorComponent.STATE_RESOLVER)
public void onExpansionStopped() {
void onExpansionStopped() {
mIsExpansionChanging = false;
resetCheckSnoozeLeavebehind();
mAmbientState.setExpansionChanging(false);
@@ -4547,20 +4538,20 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
}
@ShadeViewRefactor(RefactorComponent.STATE_RESOLVER)
public void onPanelTrackingStarted() {
void onPanelTrackingStarted() {
mPanelTracking = true;
mAmbientState.setPanelTracking(true);
resetExposedMenuView(true /* animate */, true /* force */);
}
@ShadeViewRefactor(RefactorComponent.STATE_RESOLVER)
public void onPanelTrackingStopped() {
void onPanelTrackingStopped() {
mPanelTracking = false;
mAmbientState.setPanelTracking(false);
}
@ShadeViewRefactor(RefactorComponent.STATE_RESOLVER)
public void resetScrollPosition() {
void resetScrollPosition() {
mScroller.abortAnimation();
if (ANCHOR_SCROLLING) {
// TODO: once we're recycling this will need to modify the adapter position instead
@@ -4601,15 +4592,14 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
}
@ShadeViewRefactor(RefactorComponent.COORDINATOR)
private void updateChronometerForChild(View child) {
void updateChronometerForChild(View child) {
if (child instanceof ExpandableNotificationRow) {
ExpandableNotificationRow row = (ExpandableNotificationRow) child;
row.setChronometerRunning(mIsExpanded);
}
}
@Override
public void onHeightChanged(ExpandableView view, boolean needsAnimation) {
void onChildHeightChanged(ExpandableView view, boolean needsAnimation) {
updateContentHeight();
updateScrollPositionOnExpandInBottom(view);
clampScrollPosition();
@@ -4632,8 +4622,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
requestChildrenUpdate();
}
@Override
public void onReset(ExpandableView view) {
void onChildHeightReset(ExpandableView view) {
updateAnimationState(view);
updateChronometerForChild(view);
}
@@ -4674,13 +4663,13 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
}
@ShadeViewRefactor(RefactorComponent.SHADE_VIEW)
public void setOnHeightChangedListener(
void setOnHeightChangedListener(
ExpandableView.OnHeightChangedListener onHeightChangedListener) {
this.mOnHeightChangedListener = onHeightChangedListener;
}
@ShadeViewRefactor(RefactorComponent.STATE_RESOLVER)
public void onChildAnimationFinished() {
void onChildAnimationFinished() {
setAnimationRunning(false);
requestChildrenUpdate();
runAnimationFinishedRunnables();
@@ -4724,7 +4713,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
* See {@link AmbientState#setDimmed}.
*/
@ShadeViewRefactor(RefactorComponent.SHADE_VIEW)
public void setDimmed(boolean dimmed, boolean animate) {
void setDimmed(boolean dimmed, boolean animate) {
dimmed &= onKeyguard();
mAmbientState.setDimmed(dimmed);
if (animate && mAnimationsEnabled) {
@@ -4789,7 +4778,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
* See {@link AmbientState#setActivatedChild}.
*/
@ShadeViewRefactor(RefactorComponent.SHADE_VIEW)
public void setActivatedChild(ActivatableNotificationView activatedChild) {
void setActivatedChild(ActivatableNotificationView activatedChild) {
mAmbientState.setActivatedChild(activatedChild);
if (mAnimationsEnabled) {
mActivateNeedsAnimation = true;
@@ -4865,7 +4854,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
* @param lightTheme True if light theme should be used.
*/
@ShadeViewRefactor(RefactorComponent.DECORATOR)
public void updateDecorViews(boolean lightTheme) {
private void updateDecorViews(boolean lightTheme) {
if (lightTheme == mUsingLightTheme) {
return;
}
@@ -4880,7 +4869,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
}
@ShadeViewRefactor(RefactorComponent.SHADE_VIEW)
public void goToFullShade(long delay) {
void goToFullShade(long delay) {
mGoToFullShadeNeedsAnimation = true;
mGoToFullShadeDelay = delay;
mNeedsAnimation = true;
@@ -4893,13 +4882,13 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
}
@ShadeViewRefactor(RefactorComponent.COORDINATOR)
public void setIntrinsicPadding(int intrinsicPadding) {
void setIntrinsicPadding(int intrinsicPadding) {
mIntrinsicPadding = intrinsicPadding;
mAmbientState.setIntrinsicPadding(intrinsicPadding);
}
@ShadeViewRefactor(RefactorComponent.COORDINATOR)
public int getIntrinsicPadding() {
int getIntrinsicPadding() {
return mIntrinsicPadding;
}
@@ -4933,7 +4922,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
* animation curve.
*/
@ShadeViewRefactor(RefactorComponent.SHADE_VIEW)
public void setHideAmount(float linearHideAmount, float interpolatedHideAmount) {
void setHideAmount(float linearHideAmount, float interpolatedHideAmount) {
mLinearHideAmount = linearHideAmount;
mInterpolatedHideAmount = interpolatedHideAmount;
boolean wasFullyHidden = mAmbientState.isFullyHidden();
@@ -4975,7 +4964,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
}
@ShadeViewRefactor(RefactorComponent.STATE_RESOLVER)
public void notifyHideAnimationStart(boolean hide) {
void notifyHideAnimationStart(boolean hide) {
// We only swap the scaling factor if we're fully hidden or fully awake to avoid
// interpolation issues when playing with the power button.
if (mInterpolatedHideAmount == 0 || mInterpolatedHideAmount == 1) {
@@ -5003,7 +4992,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
}
@ShadeViewRefactor(RefactorComponent.SHADE_VIEW)
public void setFooterView(@NonNull FooterView footerView) {
void setFooterView(@NonNull FooterView footerView) {
int index = -1;
if (mFooterView != null) {
index = indexOfChild(mFooterView);
@@ -5014,7 +5003,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
}
@ShadeViewRefactor(RefactorComponent.SHADE_VIEW)
public void setEmptyShadeView(EmptyShadeView emptyShadeView) {
void setEmptyShadeView(EmptyShadeView emptyShadeView) {
int index = -1;
if (mEmptyShadeView != null) {
index = indexOfChild(mEmptyShadeView);
@@ -5025,7 +5014,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
}
@ShadeViewRefactor(RefactorComponent.SHADE_VIEW)
public void updateEmptyShadeView(boolean visible) {
void updateEmptyShadeView(boolean visible) {
mEmptyShadeView.setVisible(visible, mIsExpanded && mAnimationsEnabled);
int oldTextRes = mEmptyShadeView.getTextResource();
@@ -5209,33 +5198,28 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
}
}
@Override
@ShadeViewRefactor(RefactorComponent.SHADE_VIEW)
public int getContainerChildCount() {
return getChildCount();
}
@Override
@ShadeViewRefactor(RefactorComponent.SHADE_VIEW)
public View getContainerChildAt(int i) {
return getChildAt(i);
}
@Override
@ShadeViewRefactor(RefactorComponent.SHADE_VIEW)
public void removeContainerView(View v) {
Assert.isMainThread();
removeView(v);
}
@Override
@ShadeViewRefactor(RefactorComponent.SHADE_VIEW)
public void addContainerView(View v) {
Assert.isMainThread();
addView(v);
}
@Override
public void addContainerViewAt(View v, int index) {
Assert.isMainThread();
addView(v, index);
@@ -5277,7 +5261,6 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
requestChildrenUpdate();
}
@Override
public void setWillExpand(boolean willExpand) {
mWillExpand = willExpand;
}
@@ -5742,7 +5725,6 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
}
}
@Override
public void setNotificationActivityStarter(
NotificationActivityStarter notificationActivityStarter) {
mNotificationActivityStarter = notificationActivityStarter;
@@ -5900,6 +5882,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
public void setController(
NotificationStackScrollLayoutController notificationStackScrollLayoutController) {
mController = notificationStackScrollLayoutController;
mController.getNoticationRoundessManager().setAnimatedChildren(mChildrenToAddAnimated);
}
public NotificationStackScrollLayoutController getController() {
@@ -6000,7 +5983,6 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
}
}
@Override
@ShadeViewRefactor(RefactorComponent.SHADE_VIEW)
public void resetExposedMenuView(boolean animate, boolean force) {
mSwipeHelper.resetExposedMenuView(animate, force);
@@ -6752,7 +6734,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
}
changedRow.setChildrenExpanded(expanded, animated);
if (!mGroupExpandedForMeasure) {
onHeightChanged(changedRow, false /* needsAnimation */);
onChildHeightChanged(changedRow, false /* needsAnimation */);
}
runAfterAnimationFinished(new Runnable() {
@Override

View File

@@ -17,22 +17,29 @@
package com.android.systemui.statusbar.notification.stack;
import static com.android.systemui.Dependency.ALLOW_NOTIFICATION_LONG_PRESS_NAME;
import static com.android.systemui.statusbar.phone.NotificationIconAreaController.HIGH_PRIORITY;
import android.graphics.PointF;
import android.provider.Settings;
import android.view.Display;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowInsets;
import android.widget.FrameLayout;
import com.android.systemui.plugins.statusbar.NotificationSwipeActionHelper;
import com.android.systemui.statusbar.NotificationShelfController;
import com.android.systemui.statusbar.RemoteInputController;
import com.android.systemui.statusbar.notification.ActivityLaunchAnimator;
import com.android.systemui.statusbar.notification.NotificationActivityStarter;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
import com.android.systemui.statusbar.notification.logging.NotificationLogger;
import com.android.systemui.statusbar.notification.row.ActivatableNotificationView;
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
import com.android.systemui.statusbar.notification.row.ExpandableView;
import com.android.systemui.statusbar.notification.row.NotificationGutsManager;
import com.android.systemui.statusbar.phone.HeadsUpAppearanceController;
import com.android.systemui.statusbar.phone.HeadsUpManagerPhone;
import com.android.systemui.statusbar.phone.HeadsUpTouchHelper;
import com.android.systemui.statusbar.phone.NotificationGroupManager;
import com.android.systemui.statusbar.phone.NotificationIconAreaController;
@@ -40,6 +47,7 @@ import com.android.systemui.statusbar.phone.NotificationPanelViewController;
import com.android.systemui.statusbar.phone.ScrimController;
import com.android.systemui.statusbar.phone.StatusBar;
import com.android.systemui.statusbar.phone.dagger.StatusBarComponent;
import com.android.systemui.tuner.TunerService;
import java.util.function.BiConsumer;
@@ -53,14 +61,25 @@ import javax.inject.Named;
public class NotificationStackScrollLayoutController {
private final boolean mAllowLongPress;
private final NotificationGutsManager mNotificationGutsManager;
private final HeadsUpManagerPhone mHeadsUpManager;
private final NotificationRoundnessManager mNotificationRoundnessManager;
private final TunerService mTunerService;
private final NotificationListContainerImpl mNotificationListContainer =
new NotificationListContainerImpl();
private NotificationStackScrollLayout mView;
@Inject
public NotificationStackScrollLayoutController(
@Named(ALLOW_NOTIFICATION_LONG_PRESS_NAME) boolean allowLongPress,
NotificationGutsManager notificationGutsManager) {
NotificationGutsManager notificationGutsManager,
HeadsUpManagerPhone headsUpManager,
NotificationRoundnessManager notificationRoundnessManager,
TunerService tunerService) {
mAllowLongPress = allowLongPress;
mNotificationGutsManager = notificationGutsManager;
mHeadsUpManager = headsUpManager;
mNotificationRoundnessManager = notificationRoundnessManager;
mTunerService = tunerService;
}
public void attach(NotificationStackScrollLayout view) {
@@ -70,6 +89,17 @@ public class NotificationStackScrollLayoutController {
if (mAllowLongPress) {
mView.setLongPressListener(mNotificationGutsManager::openGuts);
}
mHeadsUpManager.addListener(mNotificationRoundnessManager); // TODO: why is this here?
mNotificationRoundnessManager.setOnRoundingChangedCallback(mView::invalidate);
mView.addOnExpandedHeightChangedListener(mNotificationRoundnessManager::setExpanded);
mTunerService.addTunable((key, newValue) -> {
if (key.equals(Settings.Secure.NOTIFICATION_DISMISS_RTL)) {
mView.updateDismissRtlSetting("1".equals(newValue));
}
}, HIGH_PRIORITY, Settings.Secure.NOTIFICATION_DISMISS_RTL);
}
public void addOnExpandedHeightChangedListener(BiConsumer<Float, Float> listener) {
@@ -457,10 +487,6 @@ public class NotificationStackScrollLayoutController {
mView.onUpdateRowStates();
}
public boolean hasPulsingNotifications() {
return mView.hasPulsingNotifications();
}
public ActivatableNotificationView getActivatedChild() {
return mView.getActivatedChild();
}
@@ -537,4 +563,151 @@ public class NotificationStackScrollLayoutController {
public float calculateGapHeight(ExpandableView previousView, ExpandableView child, int count) {
return mView.calculateGapHeight(previousView, child, count);
}
public NotificationRoundnessManager getNoticationRoundessManager() {
return mNotificationRoundnessManager;
}
public NotificationListContainer getNotificationListContainer() {
return mNotificationListContainer;
}
private class NotificationListContainerImpl implements NotificationListContainer {
@Override
public void setChildTransferInProgress(boolean childTransferInProgress) {
mView.setChildTransferInProgress(childTransferInProgress);
}
@Override
public void changeViewPosition(ExpandableView child, int newIndex) {
mView.changeViewPosition(child, newIndex);
}
@Override
public void notifyGroupChildAdded(ExpandableView row) {
mView.onViewAddedInternal(row);
}
@Override
public void notifyGroupChildRemoved(ExpandableView row, ViewGroup childrenContainer) {
mView.notifyGroupChildRemoved(row, childrenContainer);
}
@Override
public void generateAddAnimation(ExpandableView child, boolean fromMoreCard) {
mView.generateAddAnimation(child, fromMoreCard);
}
@Override
public void generateChildOrderChangedEvent() {
mView.generateChildOrderChangedEvent();
}
@Override
public int getContainerChildCount() {
return mView.getContainerChildCount();
}
@Override
public void setNotificationActivityStarter(
NotificationActivityStarter notificationActivityStarter) {
mView.setNotificationActivityStarter(notificationActivityStarter);
}
@Override
public View getContainerChildAt(int i) {
return mView.getContainerChildAt(i);
}
@Override
public void removeContainerView(View v) {
mView.removeContainerView(v);
}
@Override
public void addContainerView(View v) {
mView.addContainerView(v);
}
@Override
public void addContainerViewAt(View v, int index) {
mView.addContainerViewAt(v, index);
}
@Override
public void setMaxDisplayedNotifications(int maxNotifications) {
mView.setMaxDisplayedNotifications(maxNotifications);
}
@Override
public ViewGroup getViewParentForNotification(NotificationEntry entry) {
return mView.getViewParentForNotification(entry);
}
@Override
public void resetExposedMenuView(boolean animate, boolean force) {
mView.resetExposedMenuView(animate, force);
}
@Override
public NotificationSwipeActionHelper getSwipeActionHelper() {
return mView.getSwipeActionHelper();
}
@Override
public void cleanUpViewStateForEntry(NotificationEntry entry) {
mView.cleanUpViewStateForEntry(entry);
}
@Override
public void setChildLocationsChangedListener(
NotificationLogger.OnChildLocationsChangedListener listener) {
}
public boolean hasPulsingNotifications() {
return mView.hasPulsingNotifications();
}
@Override
public boolean isInVisibleLocation(NotificationEntry entry) {
return mView.isInVisibleLocation(entry);
}
@Override
public void onHeightChanged(ExpandableView view, boolean needsAnimation) {
mView.onChildHeightChanged(view, needsAnimation);
}
@Override
public void onReset(ExpandableView view) {
mView.onChildHeightReset(view);
}
@Override
public void bindRow(ExpandableNotificationRow row) {
mView.bindRow(row);
}
@Override
public void applyExpandAnimationParams(
ActivityLaunchAnimator.ExpandAnimationParameters params) {
mView.applyExpandAnimationParams(params);
}
@Override
public void setExpandingNotification(ExpandableNotificationRow row) {
mView.setExpandingNotification(row);
}
@Override
public boolean containsView(View v) {
return mView.containsView(v);
}
@Override
public void setWillExpand(boolean willExpand) {
mView.setWillExpand(willExpand);
}
}
}

View File

@@ -3074,7 +3074,8 @@ public class NotificationPanelViewController extends PanelViewController {
}
public boolean hasPulsingNotifications() {
return mNotificationStackScrollLayoutController.hasPulsingNotifications();
return mNotificationStackScrollLayoutController
.getNotificationListContainer().hasPulsingNotifications();
}
public ActivatableNotificationView getActivatedChild() {
@@ -3259,6 +3260,10 @@ public class NotificationPanelViewController extends PanelViewController {
return new OnConfigurationChangedListener();
}
public NotificationStackScrollLayoutController getNotificationStackScrollLayoutController() {
return mNotificationStackScrollLayoutController;
}
private class OnHeightChangedListener implements ExpandableView.OnHeightChangedListener {
@Override
public void onHeightChanged(ExpandableView view, boolean needsAnimation) {

View File

@@ -210,6 +210,7 @@ import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow
import com.android.systemui.statusbar.notification.row.NotificationGutsManager;
import com.android.systemui.statusbar.notification.stack.NotificationListContainer;
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout;
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController;
import com.android.systemui.statusbar.phone.dagger.StatusBarComponent;
import com.android.systemui.statusbar.phone.dagger.StatusBarPhoneModule;
import com.android.systemui.statusbar.policy.BatteryController;
@@ -646,6 +647,7 @@ public class StatusBar extends SystemUI implements DemoMode,
private final BubbleController.BubbleExpandListener mBubbleExpandListener;
private ActivityIntentHelper mActivityIntentHelper;
private NotificationStackScrollLayoutController mStackScrollerController;
/**
* Public constructor for StatusBar.
@@ -1016,9 +1018,11 @@ public class StatusBar extends SystemUI implements DemoMode,
// TODO: Deal with the ugliness that comes from having some of the statusbar broken out
// into fragments, but the rest here, it leaves some awkward lifecycle and whatnot.
mStackScroller = mNotificationShadeWindowView.findViewById(
R.id.notification_stack_scroller);
NotificationListContainer notifListContainer = (NotificationListContainer) mStackScroller;
mStackScrollerController =
mNotificationPanelViewController.getNotificationStackScrollLayoutController();
mStackScroller = mStackScrollerController.getView();
NotificationListContainer notifListContainer =
mStackScrollerController.getNotificationListContainer();
mNotificationLogger.setUpWithContainer(notifListContainer);
// TODO: make this injectable. Currently that would create a circular dependency between
@@ -1301,13 +1305,15 @@ public class StatusBar extends SystemUI implements DemoMode,
mActivityLaunchAnimator = new ActivityLaunchAnimator(
mNotificationShadeWindowViewController, this, mNotificationPanelViewController,
mNotificationShadeDepthControllerLazy.get(),
(NotificationListContainer) mStackScroller, mContext.getMainExecutor());
mStackScrollerController.getNotificationListContainer(),
mContext.getMainExecutor());
// TODO: inject this.
mPresenter = new StatusBarNotificationPresenter(mContext, mNotificationPanelViewController,
mHeadsUpManager, mNotificationShadeWindowView, mStackScroller, mDozeScrimController,
mScrimController, mActivityLaunchAnimator, mDynamicPrivacyController,
mKeyguardStateController, mKeyguardIndicationController,
mHeadsUpManager, mNotificationShadeWindowView, mStackScrollerController,
mDozeScrimController, mScrimController, mActivityLaunchAnimator,
mDynamicPrivacyController, mKeyguardStateController,
mKeyguardIndicationController,
this /* statusBar */, mShadeController, mCommandQueue, mInitController,
mNotificationInterruptStateProvider);
@@ -1321,16 +1327,13 @@ public class StatusBar extends SystemUI implements DemoMode,
.setNotificationPresenter(mPresenter)
.setNotificationPanelViewController(mNotificationPanelViewController)
.build();
((NotificationListContainer) mStackScroller)
.setNotificationActivityStarter(mNotificationActivityStarter);
mStackScroller.setNotificationActivityStarter(mNotificationActivityStarter);
mGutsManager.setNotificationActivityStarter(mNotificationActivityStarter);
mNotificationsController.initialize(
this,
mPresenter,
(NotificationListContainer) mStackScroller,
mStackScrollerController.getNotificationListContainer(),
mNotificationActivityStarter,
mPresenter);
}

View File

@@ -30,7 +30,6 @@ import android.service.vr.IVrStateCallbacks;
import android.util.Log;
import android.util.Slog;
import android.view.View;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityManager;
import android.widget.TextView;
@@ -71,7 +70,7 @@ import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow
import com.android.systemui.statusbar.notification.row.NotificationGutsManager;
import com.android.systemui.statusbar.notification.row.NotificationGutsManager.OnSettingsClickListener;
import com.android.systemui.statusbar.notification.row.NotificationInfo.CheckSaveListener;
import com.android.systemui.statusbar.notification.stack.NotificationListContainer;
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController;
import com.android.systemui.statusbar.phone.LockscreenGestureLogger.LockscreenUiEvent;
import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.statusbar.policy.KeyguardStateController;
@@ -133,7 +132,7 @@ public class StatusBarNotificationPresenter implements NotificationPresenter,
NotificationPanelViewController panel,
HeadsUpManagerPhone headsUp,
NotificationShadeWindowView statusBarWindow,
ViewGroup stackScroller,
NotificationStackScrollLayoutController stackScrollerController,
DozeScrimController dozeScrimController,
ScrimController scrimController,
ActivityLaunchAnimator activityLaunchAnimator,
@@ -155,7 +154,7 @@ public class StatusBarNotificationPresenter implements NotificationPresenter,
mStatusBar = statusBar;
mShadeController = shadeController;
mCommandQueue = commandQueue;
mAboveShelfObserver = new AboveShelfObserver(stackScroller);
mAboveShelfObserver = new AboveShelfObserver(stackScrollerController.getView());
mActivityLaunchAnimator = activityLaunchAnimator;
mAboveShelfObserver.setListener(statusBarWindow.findViewById(
R.id.notification_container_parent));
@@ -190,7 +189,6 @@ public class StatusBarNotificationPresenter implements NotificationPresenter,
remoteInputManager.getController().addCallback(
Dependency.get(NotificationShadeWindowController.class));
NotificationListContainer notifListContainer = (NotificationListContainer) stackScroller;
initController.addPostInitTask(() -> {
NotificationEntryListener notificationEntryListener = new NotificationEntryListener() {
@Override
@@ -207,7 +205,8 @@ public class StatusBarNotificationPresenter implements NotificationPresenter,
}
};
mViewHierarchyManager.setUpWithPresenter(this, notifListContainer);
mViewHierarchyManager.setUpWithPresenter(this,
stackScrollerController.getNotificationListContainer());
mEntryManager.setUpWithPresenter(this);
mEntryManager.addNotificationEntryListener(notificationEntryListener);
mEntryManager.addNotificationLifetimeExtender(mHeadsUpManager);
@@ -219,7 +218,8 @@ public class StatusBarNotificationPresenter implements NotificationPresenter,
mMediaManager.setUpWithPresenter(this);
mVisualStabilityManager.setUpWithPresenter(this);
mGutsManager.setUpWithPresenter(this,
notifListContainer, mCheckSaveListener, mOnSettingsClickListener);
stackScrollerController.getNotificationListContainer(), mCheckSaveListener,
mOnSettingsClickListener);
// ForegroundServiceNotificationListener adds its listener in its constructor
// but we need to request it here in order for it to be instantiated.
// TODO: figure out how to do this correctly once Dependency.get() is gone.

View File

@@ -79,7 +79,7 @@ import com.android.systemui.statusbar.notification.collection.NotificationEntry;
import com.android.systemui.statusbar.notification.collection.provider.HighPriorityProvider;
import com.android.systemui.statusbar.notification.people.PeopleNotificationIdentifier;
import com.android.systemui.statusbar.notification.row.NotificationGutsManager.OnSettingsClickListener;
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout;
import com.android.systemui.statusbar.notification.stack.NotificationListContainer;
import com.android.systemui.statusbar.phone.StatusBar;
import com.android.systemui.statusbar.policy.DeviceProvisionedController;
@@ -117,7 +117,7 @@ public class NotificationGutsManagerTest extends SysuiTestCase {
@Mock private VisualStabilityManager mVisualStabilityManager;
@Mock private NotificationPresenter mPresenter;
@Mock private NotificationActivityStarter mNotificationActivityStarter;
@Mock private NotificationStackScrollLayout mStackScroller;
@Mock private NotificationListContainer mNotificationListContainer;
@Mock private NotificationInfo.CheckSaveListener mCheckSaveListener;
@Mock private OnSettingsClickListener mOnSettingsClickListener;
@Mock private DeviceProvisionedController mDeviceProvisionedController;
@@ -156,7 +156,7 @@ public class NotificationGutsManagerTest extends SysuiTestCase {
mChannelEditorDialogController, mContextTracker, mProvider,
mAssistantFeedbackController, mBubbleController,
new UiEventLoggerFake());
mGutsManager.setUpWithPresenter(mPresenter, mStackScroller,
mGutsManager.setUpWithPresenter(mPresenter, mNotificationListContainer,
mCheckSaveListener, mOnSettingsClickListener);
mGutsManager.setNotificationActivityStarter(mNotificationActivityStarter);
}

View File

@@ -72,7 +72,6 @@ import com.android.systemui.statusbar.notification.ConversationNotificationManag
import com.android.systemui.statusbar.notification.DynamicPrivacyController;
import com.android.systemui.statusbar.notification.NotificationEntryManager;
import com.android.systemui.statusbar.notification.NotificationWakeUpCoordinator;
import com.android.systemui.statusbar.notification.row.NotificationGutsManager;
import com.android.systemui.statusbar.notification.stack.NotificationRoundnessManager;
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout;
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController;
@@ -188,6 +187,9 @@ public class NotificationPanelViewTest extends SysuiTestCase {
private StatusBarKeyguardViewManager mStatusBarKeyguardViewManager;
@Mock
private KeyguardClockSwitchController mKeyguardClockSwitchController;
@Mock
private NotificationStackScrollLayoutController mNotificationStackScrollLayoutController;
private NotificationPanelViewController mNotificationPanelViewController;
private View.AccessibilityDelegate mAccessibiltyDelegate;
@@ -205,8 +207,11 @@ public class NotificationPanelViewTest extends SysuiTestCase {
when(mView.findViewById(R.id.keyguard_clock_container)).thenReturn(mKeyguardClockSwitch);
when(mView.findViewById(R.id.notification_stack_scroller))
.thenReturn(mNotificationStackScrollLayout);
when(mNotificationStackScrollLayout.getHeight()).thenReturn(1000);
when(mNotificationStackScrollLayout.getHeadsUpCallback()).thenReturn(mHeadsUpCallback);
when(mNotificationStackScrollLayout.getController())
.thenReturn(mNotificationStackScrollLayoutController);
when(mNotificationStackScrollLayoutController.getHeight()).thenReturn(1000);
when(mNotificationStackScrollLayoutController.getHeadsUpCallback())
.thenReturn(mHeadsUpCallback);
when(mView.findViewById(R.id.keyguard_bottom_area)).thenReturn(mKeyguardBottomArea);
when(mKeyguardBottomArea.getLeftView()).thenReturn(mock(KeyguardAffordanceView.class));
when(mKeyguardBottomArea.getRightView()).thenReturn(mock(KeyguardAffordanceView.class));
@@ -233,11 +238,6 @@ public class NotificationPanelViewTest extends SysuiTestCase {
mock(NotificationRoundnessManager.class),
mStatusBarStateController,
new FalsingManagerFake());
NotificationStackScrollLayoutController notificationStackScrollLayoutController =
new NotificationStackScrollLayoutController(
true /* allowLongPress */,
mock(NotificationGutsManager.class)
);
mNotificationPanelViewController = new NotificationPanelViewController(mView,
mInjectionInflationController,
coordinator, expansionHandler, mDynamicPrivacyController, mKeyguardBypassController,
@@ -251,7 +251,7 @@ public class NotificationPanelViewTest extends SysuiTestCase {
mConversationNotificationManager, mMediaHiearchyManager,
mBiometricUnlockController, mStatusBarKeyguardViewManager,
() -> mKeyguardClockSwitchController,
notificationStackScrollLayoutController);
mNotificationStackScrollLayoutController);
mNotificationPanelViewController.initDependencies(mStatusBar, mGroupManager,
mNotificationShelfController, mNotificationAreaController, mScrimController);
mNotificationPanelViewController.setHeadsUpManager(mHeadsUpManager);
@@ -267,8 +267,10 @@ public class NotificationPanelViewTest extends SysuiTestCase {
public void testSetDozing_notifiesNsslAndStateController() {
mNotificationPanelViewController.setDozing(true /* dozing */, true /* animate */,
null /* touch */);
InOrder inOrder = inOrder(mNotificationStackScrollLayout, mStatusBarStateController);
inOrder.verify(mNotificationStackScrollLayout).setDozing(eq(true), eq(true), eq(null));
InOrder inOrder = inOrder(
mNotificationStackScrollLayoutController, mStatusBarStateController);
inOrder.verify(mNotificationStackScrollLayoutController)
.setDozing(eq(true), eq(true), eq(null));
inOrder.verify(mStatusBarStateController).setDozeAmount(eq(1f), eq(true));
}

View File

@@ -23,13 +23,11 @@ import static org.mockito.Mockito.when;
import android.app.Notification;
import android.app.StatusBarManager;
import android.content.Context;
import android.metrics.LogMaker;
import android.support.test.metricshelper.MetricsAsserts;
import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
import android.testing.TestableLooper.RunWithLooper;
import android.view.ViewGroup;
import androidx.test.filters.SmallTest;
@@ -59,6 +57,8 @@ import com.android.systemui.statusbar.notification.interruption.NotificationInte
import com.android.systemui.statusbar.notification.row.ActivatableNotificationView;
import com.android.systemui.statusbar.notification.row.NotificationGutsManager;
import com.android.systemui.statusbar.notification.stack.NotificationListContainer;
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout;
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController;
import com.android.systemui.statusbar.policy.KeyguardStateController;
import org.junit.Before;
@@ -112,11 +112,17 @@ public class StatusBarNotificationPresenterTest extends SysuiTestCase {
NotificationShadeWindowView notificationShadeWindowView =
mock(NotificationShadeWindowView.class);
NotificationStackScrollLayoutController stackScrollLayoutController =
mock(NotificationStackScrollLayoutController.class);
when(stackScrollLayoutController.getView()).thenReturn(
mock(NotificationStackScrollLayout.class));
when(stackScrollLayoutController.getNotificationListContainer()).thenReturn(
mock(NotificationListContainer.class));
when(notificationShadeWindowView.getResources()).thenReturn(mContext.getResources());
mStatusBarNotificationPresenter = new StatusBarNotificationPresenter(mContext,
mock(NotificationPanelViewController.class), mock(HeadsUpManagerPhone.class),
notificationShadeWindowView, mock(NotificationListContainerViewGroup.class),
notificationShadeWindowView, stackScrollLayoutController,
mock(DozeScrimController.class), mock(ScrimController.class),
mock(ActivityLaunchAnimator.class), mock(DynamicPrivacyController.class),
mock(KeyguardStateController.class),
@@ -205,14 +211,4 @@ public class StatusBarNotificationPresenterTest extends SysuiTestCase {
new LogMaker(MetricsEvent.ACTION_LS_NOTE)
.setType(MetricsEvent.TYPE_ACTION));
}
// We need this because mockito doesn't know how to construct a mock that extends ViewGroup
// and implements NotificationListContainer without it because of classloader issues.
private abstract static class NotificationListContainerViewGroup extends ViewGroup
implements NotificationListContainer {
public NotificationListContainerViewGroup(Context context) {
super(context);
}
}
}

View File

@@ -124,7 +124,9 @@ import com.android.systemui.statusbar.notification.interruption.NotificationInte
import com.android.systemui.statusbar.notification.logging.NotificationLogger;
import com.android.systemui.statusbar.notification.logging.NotificationPanelLoggerFake;
import com.android.systemui.statusbar.notification.row.NotificationGutsManager;
import com.android.systemui.statusbar.notification.stack.NotificationListContainer;
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout;
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController;
import com.android.systemui.statusbar.phone.dagger.StatusBarComponent;
import com.android.systemui.statusbar.policy.BatteryController;
import com.android.systemui.statusbar.policy.ConfigurationController;
@@ -171,6 +173,8 @@ public class StatusBarTest extends SysuiTestCase {
@Mock private KeyguardStateController mKeyguardStateController;
@Mock private KeyguardIndicationController mKeyguardIndicationController;
@Mock private NotificationStackScrollLayout mStackScroller;
@Mock private NotificationStackScrollLayoutController mStackScrollerController;
@Mock private NotificationListContainer mNotificationListContainer;
@Mock private HeadsUpManagerPhone mHeadsUpManager;
@Mock private NotificationPanelViewController mNotificationPanelViewController;
@Mock private NotificationPanelView mNotificationPanelView;
@@ -283,6 +287,10 @@ public class StatusBarTest extends SysuiTestCase {
mContext.setTheme(R.style.Theme_SystemUI_Light);
when(mStackScroller.getController()).thenReturn(mStackScrollerController);
when(mStackScrollerController.getView()).thenReturn(mStackScroller);
when(mStackScrollerController.getNotificationListContainer()).thenReturn(
mNotificationListContainer);
when(mStackScroller.generateLayoutParams(any())).thenReturn(new LayoutParams(0, 0));
when(mNotificationPanelViewController.getView()).thenReturn(mNotificationPanelView);
when(mNotificationPanelView.getLayoutParams()).thenReturn(new LayoutParams(0, 0));
@@ -429,7 +437,7 @@ public class StatusBarTest extends SysuiTestCase {
mStatusBar.mStackScroller = mStackScroller;
mStatusBar.startKeyguard();
mInitController.executePostInitTasks();
notificationLogger.setUpWithContainer(mStackScroller);
notificationLogger.setUpWithContainer(mNotificationListContainer);
}
@Test