Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java +13 −32 Original line number Diff line number Diff line Loading @@ -178,8 +178,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, ConfigurationListener, Dumpable { public class NotificationStackScrollLayout extends ViewGroup implements ScrollAdapter, Dumpable { public static final float BACKGROUND_ALPHA_DIMMED = 0.7f; private static final String TAG = "StackScroller"; Loading Loading @@ -729,36 +728,13 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd return 0f; } @Override @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) public void onDensityOrFontScaleChanged() { reinflateViews(); } private void reinflateViews() { void reinflateViews() { inflateFooterView(); inflateEmptyShadeView(); updateFooter(); mSectionsManager.reinflateViews(LayoutInflater.from(mContext)); } @Override @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) public void onThemeChanged() { updateFooter(); } @Override public void onOverlayChanged() { int newRadius = mContext.getResources().getDimensionPixelSize( Utils.getThemeAttr(mContext, android.R.attr.dialogCornerRadius)); if (mCornerRadius != newRadius) { mCornerRadius = newRadius; invalidate(); } reinflateViews(); } @VisibleForTesting @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) public void updateFooter() { Loading Loading @@ -824,7 +800,6 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd super.onAttachedToWindow(); ((SysuiStatusBarStateController) Dependency.get(StatusBarStateController.class)) .addCallback(mStateListener, SysuiStatusBarStateController.RANK_STACK_SCROLLER); Dependency.get(ConfigurationController.class).addCallback(this); } @Override Loading @@ -832,7 +807,6 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd protected void onDetachedFromWindow() { super.onDetachedFromWindow(); Dependency.get(StatusBarStateController.class).removeCallback(mStateListener); Dependency.get(ConfigurationController.class).removeCallback(this); } @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) Loading @@ -840,9 +814,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd return mSwipeHelper; } @Override @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) public void onUiModeChanged() { void updateBgColor() { mBgColor = mContext.getColor(R.color.notification_shade_background_color); updateBackgroundDimming(); mShelf.onUiModeChanged(); Loading Loading @@ -1075,6 +1047,15 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd R.dimen.heads_up_status_bar_padding); } void updateCornerRadius() { int newRadius = getResources().getDimensionPixelSize( Utils.getThemeAttr(getContext(), android.R.attr.dialogCornerRadius)); if (mCornerRadius != newRadius) { mCornerRadius = newRadius; invalidate(); } } @ShadeViewRefactor(RefactorComponent.COORDINATOR) private void notifyHeightChangeListener(ExpandableView view) { notifyHeightChangeListener(view, false /* needsAnimation */); Loading Loading @@ -4851,7 +4832,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd * @param lightTheme True if light theme should be used. */ @ShadeViewRefactor(RefactorComponent.DECORATOR) private void updateDecorViews(boolean lightTheme) { void updateDecorViews(boolean lightTheme) { if (lightTheme == mUsingLightTheme) { return; } Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutController.java +50 −2 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import android.view.ViewGroup; import android.view.WindowInsets; import android.widget.FrameLayout; import com.android.internal.annotations.VisibleForTesting; import com.android.systemui.plugins.statusbar.NotificationSwipeActionHelper; import com.android.systemui.statusbar.NotificationShelfController; import com.android.systemui.statusbar.RemoteInputController; Loading @@ -46,6 +47,8 @@ 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.statusbar.policy.ConfigurationController; import com.android.systemui.statusbar.policy.ConfigurationController.ConfigurationListener; import com.android.systemui.tuner.TunerService; import java.util.function.BiConsumer; Loading @@ -64,10 +67,25 @@ public class NotificationStackScrollLayoutController { private final NotificationRoundnessManager mNotificationRoundnessManager; private final TunerService mTunerService; private final DynamicPrivacyController mDynamicPrivacyController; private final ConfigurationController mConfigurationController; private final NotificationListContainerImpl mNotificationListContainer = new NotificationListContainerImpl(); private NotificationStackScrollLayout mView; @VisibleForTesting final View.OnAttachStateChangeListener mOnAttachStateChangeListener = new View.OnAttachStateChangeListener() { @Override public void onViewAttachedToWindow(View v) { mConfigurationController.addCallback(mConfigurationListener); } @Override public void onViewDetachedFromWindow(View v) { mConfigurationController.removeCallback(mConfigurationListener); } }; private final DynamicPrivacyController.Listener mDynamicPrivacyControllerListener = () -> { if (mView.isExpanded()) { // The bottom might change because we're using the final actual height of the view Loading @@ -80,6 +98,30 @@ public class NotificationStackScrollLayoutController { }); }; @VisibleForTesting final ConfigurationListener mConfigurationListener = new ConfigurationListener() { @Override public void onDensityOrFontScaleChanged() { mView.reinflateViews(); } @Override public void onOverlayChanged() { mView.updateCornerRadius(); mView.reinflateViews(); } @Override public void onUiModeChanged() { mView.updateBgColor(); } @Override public void onThemeChanged() { updateFooter(); } }; @Inject public NotificationStackScrollLayoutController( @Named(ALLOW_NOTIFICATION_LONG_PRESS_NAME) boolean allowLongPress, Loading @@ -87,13 +129,15 @@ public class NotificationStackScrollLayoutController { HeadsUpManagerPhone headsUpManager, NotificationRoundnessManager notificationRoundnessManager, TunerService tunerService, DynamicPrivacyController dynamicPrivacyController) { DynamicPrivacyController dynamicPrivacyController, ConfigurationController configurationController) { mAllowLongPress = allowLongPress; mNotificationGutsManager = notificationGutsManager; mHeadsUpManager = headsUpManager; mNotificationRoundnessManager = notificationRoundnessManager; mTunerService = tunerService; mDynamicPrivacyController = dynamicPrivacyController; mConfigurationController = configurationController; } public void attach(NotificationStackScrollLayout view) { Loading @@ -105,7 +149,6 @@ public class NotificationStackScrollLayoutController { } mHeadsUpManager.addListener(mNotificationRoundnessManager); // TODO: why is this here? mDynamicPrivacyController.addListener(mDynamicPrivacyControllerListener); mNotificationRoundnessManager.setOnRoundingChangedCallback(mView::invalidate); Loading @@ -121,6 +164,11 @@ public class NotificationStackScrollLayoutController { }, Settings.Secure.NOTIFICATION_DISMISS_RTL, Settings.Secure.NOTIFICATION_HISTORY_ENABLED); if (mView.isAttachedToWindow()) { mOnAttachStateChangeListener.onViewAttachedToWindow(mView); } mView.addOnAttachStateChangeListener(mOnAttachStateChangeListener); } public void addOnExpandedHeightChangedListener(BiConsumer<Float, Float> listener) { Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java +2 −2 Original line number Diff line number Diff line Loading @@ -436,9 +436,9 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase { } @Test public void testOnDensityOrFontScaleChanged_reInflatesFooterViews() { public void testReInflatesFooterViews() { clearInvocations(mStackScroller); mStackScroller.onDensityOrFontScaleChanged(); mStackScroller.reinflateViews(); verify(mStackScroller).setFooterView(any()); verify(mStackScroller).setEmptyShadeView(any()); } Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollerControllerTest.java 0 → 100644 +115 −0 Original line number Diff line number Diff line /* * Copyright (C) 2020 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.systemui.statusbar.notification.stack; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import android.testing.AndroidTestingRunner; import androidx.test.filters.SmallTest; import com.android.systemui.SysuiTestCase; import com.android.systemui.colorextraction.SysuiColorExtractor; import com.android.systemui.statusbar.notification.DynamicPrivacyController; import com.android.systemui.statusbar.notification.row.NotificationGutsManager; import com.android.systemui.statusbar.phone.HeadsUpManagerPhone; import com.android.systemui.statusbar.policy.ConfigurationController; import com.android.systemui.tuner.TunerService; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.MockitoAnnotations; /** * Tests for {@link NotificationStackScrollLayoutController}. */ @SmallTest @RunWith(AndroidTestingRunner.class) public class NotificationStackScrollerControllerTest extends SysuiTestCase { @Mock private NotificationGutsManager mNotificationGutsManager; @Mock private HeadsUpManagerPhone mHeadsUpManager; @Mock private NotificationRoundnessManager mNotificationRoundnessManager; @Mock private TunerService mTunerService; @Mock private AmbientState mAmbientState; @Mock private DynamicPrivacyController mDynamicPrivacyController; @Mock private ConfigurationController mConfigurationController; @Mock private NotificationStackScrollLayout mNotificationStackScrollLayout; NotificationStackScrollLayoutController mController; @Before public void setUp() { MockitoAnnotations.initMocks(this); mController = new NotificationStackScrollLayoutController( true, mNotificationGutsManager, mHeadsUpManager, mNotificationRoundnessManager, mTunerService, mDynamicPrivacyController, mConfigurationController ); when(mNotificationStackScrollLayout.isAttachedToWindow()).thenReturn(true); } @Test public void testAttach_viewAlreadyAttached() { mController.attach(mNotificationStackScrollLayout); verify(mConfigurationController).addCallback( any(ConfigurationController.ConfigurationListener.class)); } @Test public void testAttach_viewAttachedAfterInit() { when(mNotificationStackScrollLayout.isAttachedToWindow()).thenReturn(false); mController.attach(mNotificationStackScrollLayout); verify(mConfigurationController, never()).addCallback( any(ConfigurationController.ConfigurationListener.class)); mController.mOnAttachStateChangeListener.onViewAttachedToWindow( mNotificationStackScrollLayout); verify(mConfigurationController).addCallback( any(ConfigurationController.ConfigurationListener.class)); } @Test public void testOnDensityOrFontScaleChanged_reInflatesFooterViews() { mController.attach(mNotificationStackScrollLayout); mController.mConfigurationListener.onDensityOrFontScaleChanged(); verify(mNotificationStackScrollLayout).reinflateViews(); } } Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java +13 −32 Original line number Diff line number Diff line Loading @@ -178,8 +178,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, ConfigurationListener, Dumpable { public class NotificationStackScrollLayout extends ViewGroup implements ScrollAdapter, Dumpable { public static final float BACKGROUND_ALPHA_DIMMED = 0.7f; private static final String TAG = "StackScroller"; Loading Loading @@ -729,36 +728,13 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd return 0f; } @Override @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) public void onDensityOrFontScaleChanged() { reinflateViews(); } private void reinflateViews() { void reinflateViews() { inflateFooterView(); inflateEmptyShadeView(); updateFooter(); mSectionsManager.reinflateViews(LayoutInflater.from(mContext)); } @Override @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) public void onThemeChanged() { updateFooter(); } @Override public void onOverlayChanged() { int newRadius = mContext.getResources().getDimensionPixelSize( Utils.getThemeAttr(mContext, android.R.attr.dialogCornerRadius)); if (mCornerRadius != newRadius) { mCornerRadius = newRadius; invalidate(); } reinflateViews(); } @VisibleForTesting @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) public void updateFooter() { Loading Loading @@ -824,7 +800,6 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd super.onAttachedToWindow(); ((SysuiStatusBarStateController) Dependency.get(StatusBarStateController.class)) .addCallback(mStateListener, SysuiStatusBarStateController.RANK_STACK_SCROLLER); Dependency.get(ConfigurationController.class).addCallback(this); } @Override Loading @@ -832,7 +807,6 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd protected void onDetachedFromWindow() { super.onDetachedFromWindow(); Dependency.get(StatusBarStateController.class).removeCallback(mStateListener); Dependency.get(ConfigurationController.class).removeCallback(this); } @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) Loading @@ -840,9 +814,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd return mSwipeHelper; } @Override @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) public void onUiModeChanged() { void updateBgColor() { mBgColor = mContext.getColor(R.color.notification_shade_background_color); updateBackgroundDimming(); mShelf.onUiModeChanged(); Loading Loading @@ -1075,6 +1047,15 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd R.dimen.heads_up_status_bar_padding); } void updateCornerRadius() { int newRadius = getResources().getDimensionPixelSize( Utils.getThemeAttr(getContext(), android.R.attr.dialogCornerRadius)); if (mCornerRadius != newRadius) { mCornerRadius = newRadius; invalidate(); } } @ShadeViewRefactor(RefactorComponent.COORDINATOR) private void notifyHeightChangeListener(ExpandableView view) { notifyHeightChangeListener(view, false /* needsAnimation */); Loading Loading @@ -4851,7 +4832,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd * @param lightTheme True if light theme should be used. */ @ShadeViewRefactor(RefactorComponent.DECORATOR) private void updateDecorViews(boolean lightTheme) { void updateDecorViews(boolean lightTheme) { if (lightTheme == mUsingLightTheme) { return; } Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutController.java +50 −2 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import android.view.ViewGroup; import android.view.WindowInsets; import android.widget.FrameLayout; import com.android.internal.annotations.VisibleForTesting; import com.android.systemui.plugins.statusbar.NotificationSwipeActionHelper; import com.android.systemui.statusbar.NotificationShelfController; import com.android.systemui.statusbar.RemoteInputController; Loading @@ -46,6 +47,8 @@ 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.statusbar.policy.ConfigurationController; import com.android.systemui.statusbar.policy.ConfigurationController.ConfigurationListener; import com.android.systemui.tuner.TunerService; import java.util.function.BiConsumer; Loading @@ -64,10 +67,25 @@ public class NotificationStackScrollLayoutController { private final NotificationRoundnessManager mNotificationRoundnessManager; private final TunerService mTunerService; private final DynamicPrivacyController mDynamicPrivacyController; private final ConfigurationController mConfigurationController; private final NotificationListContainerImpl mNotificationListContainer = new NotificationListContainerImpl(); private NotificationStackScrollLayout mView; @VisibleForTesting final View.OnAttachStateChangeListener mOnAttachStateChangeListener = new View.OnAttachStateChangeListener() { @Override public void onViewAttachedToWindow(View v) { mConfigurationController.addCallback(mConfigurationListener); } @Override public void onViewDetachedFromWindow(View v) { mConfigurationController.removeCallback(mConfigurationListener); } }; private final DynamicPrivacyController.Listener mDynamicPrivacyControllerListener = () -> { if (mView.isExpanded()) { // The bottom might change because we're using the final actual height of the view Loading @@ -80,6 +98,30 @@ public class NotificationStackScrollLayoutController { }); }; @VisibleForTesting final ConfigurationListener mConfigurationListener = new ConfigurationListener() { @Override public void onDensityOrFontScaleChanged() { mView.reinflateViews(); } @Override public void onOverlayChanged() { mView.updateCornerRadius(); mView.reinflateViews(); } @Override public void onUiModeChanged() { mView.updateBgColor(); } @Override public void onThemeChanged() { updateFooter(); } }; @Inject public NotificationStackScrollLayoutController( @Named(ALLOW_NOTIFICATION_LONG_PRESS_NAME) boolean allowLongPress, Loading @@ -87,13 +129,15 @@ public class NotificationStackScrollLayoutController { HeadsUpManagerPhone headsUpManager, NotificationRoundnessManager notificationRoundnessManager, TunerService tunerService, DynamicPrivacyController dynamicPrivacyController) { DynamicPrivacyController dynamicPrivacyController, ConfigurationController configurationController) { mAllowLongPress = allowLongPress; mNotificationGutsManager = notificationGutsManager; mHeadsUpManager = headsUpManager; mNotificationRoundnessManager = notificationRoundnessManager; mTunerService = tunerService; mDynamicPrivacyController = dynamicPrivacyController; mConfigurationController = configurationController; } public void attach(NotificationStackScrollLayout view) { Loading @@ -105,7 +149,6 @@ public class NotificationStackScrollLayoutController { } mHeadsUpManager.addListener(mNotificationRoundnessManager); // TODO: why is this here? mDynamicPrivacyController.addListener(mDynamicPrivacyControllerListener); mNotificationRoundnessManager.setOnRoundingChangedCallback(mView::invalidate); Loading @@ -121,6 +164,11 @@ public class NotificationStackScrollLayoutController { }, Settings.Secure.NOTIFICATION_DISMISS_RTL, Settings.Secure.NOTIFICATION_HISTORY_ENABLED); if (mView.isAttachedToWindow()) { mOnAttachStateChangeListener.onViewAttachedToWindow(mView); } mView.addOnAttachStateChangeListener(mOnAttachStateChangeListener); } public void addOnExpandedHeightChangedListener(BiConsumer<Float, Float> listener) { Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java +2 −2 Original line number Diff line number Diff line Loading @@ -436,9 +436,9 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase { } @Test public void testOnDensityOrFontScaleChanged_reInflatesFooterViews() { public void testReInflatesFooterViews() { clearInvocations(mStackScroller); mStackScroller.onDensityOrFontScaleChanged(); mStackScroller.reinflateViews(); verify(mStackScroller).setFooterView(any()); verify(mStackScroller).setEmptyShadeView(any()); } Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollerControllerTest.java 0 → 100644 +115 −0 Original line number Diff line number Diff line /* * Copyright (C) 2020 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.systemui.statusbar.notification.stack; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import android.testing.AndroidTestingRunner; import androidx.test.filters.SmallTest; import com.android.systemui.SysuiTestCase; import com.android.systemui.colorextraction.SysuiColorExtractor; import com.android.systemui.statusbar.notification.DynamicPrivacyController; import com.android.systemui.statusbar.notification.row.NotificationGutsManager; import com.android.systemui.statusbar.phone.HeadsUpManagerPhone; import com.android.systemui.statusbar.policy.ConfigurationController; import com.android.systemui.tuner.TunerService; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.MockitoAnnotations; /** * Tests for {@link NotificationStackScrollLayoutController}. */ @SmallTest @RunWith(AndroidTestingRunner.class) public class NotificationStackScrollerControllerTest extends SysuiTestCase { @Mock private NotificationGutsManager mNotificationGutsManager; @Mock private HeadsUpManagerPhone mHeadsUpManager; @Mock private NotificationRoundnessManager mNotificationRoundnessManager; @Mock private TunerService mTunerService; @Mock private AmbientState mAmbientState; @Mock private DynamicPrivacyController mDynamicPrivacyController; @Mock private ConfigurationController mConfigurationController; @Mock private NotificationStackScrollLayout mNotificationStackScrollLayout; NotificationStackScrollLayoutController mController; @Before public void setUp() { MockitoAnnotations.initMocks(this); mController = new NotificationStackScrollLayoutController( true, mNotificationGutsManager, mHeadsUpManager, mNotificationRoundnessManager, mTunerService, mDynamicPrivacyController, mConfigurationController ); when(mNotificationStackScrollLayout.isAttachedToWindow()).thenReturn(true); } @Test public void testAttach_viewAlreadyAttached() { mController.attach(mNotificationStackScrollLayout); verify(mConfigurationController).addCallback( any(ConfigurationController.ConfigurationListener.class)); } @Test public void testAttach_viewAttachedAfterInit() { when(mNotificationStackScrollLayout.isAttachedToWindow()).thenReturn(false); mController.attach(mNotificationStackScrollLayout); verify(mConfigurationController, never()).addCallback( any(ConfigurationController.ConfigurationListener.class)); mController.mOnAttachStateChangeListener.onViewAttachedToWindow( mNotificationStackScrollLayout); verify(mConfigurationController).addCallback( any(ConfigurationController.ConfigurationListener.class)); } @Test public void testOnDensityOrFontScaleChanged_reInflatesFooterViews() { mController.attach(mNotificationStackScrollLayout); mController.mConfigurationListener.onDensityOrFontScaleChanged(); verify(mNotificationStackScrollLayout).reinflateViews(); } }