Loading packages/SystemUI/src/com/android/systemui/qs/FooterActionsController.kt +8 −0 Original line number Diff line number Diff line Loading @@ -213,5 +213,13 @@ class FooterActionsController @Inject constructor( mView.setKeyguardShowing() } fun refreshVisibility(shouldBeVisible: Boolean) { if (shouldBeVisible) { showFooter() } else { hideFooter() } } private fun isTunerEnabled() = tunerService.isTunerEnabled } No newline at end of file packages/SystemUI/src/com/android/systemui/qs/QSPanelControllerBase.java +2 −2 Original line number Diff line number Diff line Loading @@ -84,15 +84,15 @@ public abstract class QSPanelControllerBase<T extends QSPanel> extends ViewContr public void onConfigurationChange(Configuration newConfig) { mShouldUseSplitNotificationShade = Utils.shouldUseSplitNotificationShade(getResources()); onConfigurationChanged(); if (newConfig.orientation != mLastOrientation) { mLastOrientation = newConfig.orientation; onScreenRotated(); switchTileLayout(false); } } }; protected void onScreenRotated() { } protected void onConfigurationChanged() { } private final Function1<Boolean, Unit> mMediaHostVisibilityListener = (visible) -> { if (mMediaVisibilityChangedListener != null) { Loading packages/SystemUI/src/com/android/systemui/qs/QuickQSPanelController.java +3 −11 Original line number Diff line number Diff line Loading @@ -81,7 +81,7 @@ public class QuickQSPanelController extends QSPanelControllerBase<QuickQSPanel> mMediaHost.init(MediaHierarchyManager.LOCATION_QQS); mBrightnessController.init(mShouldUseSplitNotificationShade); mFooterActionsController.init(); refreshFooterVisibility(); mFooterActionsController.refreshVisibility(mShouldUseSplitNotificationShade); } @Override Loading Loading @@ -109,14 +109,6 @@ public class QuickQSPanelController extends QSPanelControllerBase<QuickQSPanel> return mView.isListening(); } private void refreshFooterVisibility() { if (mShouldUseSplitNotificationShade) { mFooterActionsController.showFooter(); } else { mFooterActionsController.hideFooter(); } } private void setMaxTiles(int parseNumTiles) { mView.setMaxTiles(parseNumTiles); setTiles(); Loading @@ -129,9 +121,9 @@ public class QuickQSPanelController extends QSPanelControllerBase<QuickQSPanel> } @Override protected void onScreenRotated() { protected void onConfigurationChanged() { mBrightnessController.refreshVisibility(mShouldUseSplitNotificationShade); refreshFooterVisibility(); mFooterActionsController.refreshVisibility(mShouldUseSplitNotificationShade); } @Override Loading packages/SystemUI/tests/src/com/android/systemui/qs/QuickQSPanelControllerTest.kt +18 −3 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.systemui.qs import android.content.res.Configuration import android.test.suitebuilder.annotation.SmallTest import android.testing.AndroidTestingRunner import com.android.internal.logging.MetricsLogger Loading @@ -27,12 +28,13 @@ import com.android.systemui.plugins.qs.QSTile import com.android.systemui.plugins.qs.QSTileView import com.android.systemui.qs.customize.QSCustomizerController import com.android.systemui.qs.logging.QSLogger import com.android.systemui.flags.FeatureFlags import org.junit.After import org.junit.Before import org.junit.Test import org.junit.runner.RunWith import org.mockito.ArgumentCaptor import org.mockito.ArgumentMatchers.anyBoolean import org.mockito.Captor import org.mockito.Mock import org.mockito.Mockito.`when` import org.mockito.Mockito.any Loading Loading @@ -65,11 +67,11 @@ class QuickQSPanelControllerTest : SysuiTestCase() { @Mock private lateinit var tileView: QSTileView @Mock private lateinit var featureFlags: FeatureFlags @Mock private lateinit var quickQsBrightnessController: QuickQSBrightnessController @Mock private lateinit var footerActionsController: FooterActionsController @Captor private lateinit var captor: ArgumentCaptor<QSPanel.OnConfigurationChangedListener> private lateinit var controller: QuickQSPanelController Loading @@ -78,6 +80,7 @@ class QuickQSPanelControllerTest : SysuiTestCase() { MockitoAnnotations.initMocks(this) `when`(quickQSPanel.tileLayout).thenReturn(tileLayout) `when`(quickQSPanel.isAttachedToWindow).thenReturn(true) `when`(quickQSPanel.dumpableTag).thenReturn("") `when`(quickQSPanel.resources).thenReturn(mContext.resources) `when`(qsTileHost.createTileView(any(), any(), anyBoolean())).thenReturn(tileView) Loading Loading @@ -123,4 +126,16 @@ class QuickQSPanelControllerTest : SysuiTestCase() { verify(quickQSPanel, times(limit)).addTile(any()) } @Test fun testBrightnessAndFooterVisibilityRefreshedWhenConfigurationChanged() { // times(2) because both controller and base controller are registering their listeners verify(quickQSPanel, times(2)).addOnConfigurationChangedListener(captor.capture()) captor.allValues.forEach { it.onConfigurationChange(Configuration.EMPTY) } verify(quickQsBrightnessController).refreshVisibility(anyBoolean()) // times(2) because footer visibility is also refreshed on controller init verify(footerActionsController, times(2)).refreshVisibility(anyBoolean()) } } Loading
packages/SystemUI/src/com/android/systemui/qs/FooterActionsController.kt +8 −0 Original line number Diff line number Diff line Loading @@ -213,5 +213,13 @@ class FooterActionsController @Inject constructor( mView.setKeyguardShowing() } fun refreshVisibility(shouldBeVisible: Boolean) { if (shouldBeVisible) { showFooter() } else { hideFooter() } } private fun isTunerEnabled() = tunerService.isTunerEnabled } No newline at end of file
packages/SystemUI/src/com/android/systemui/qs/QSPanelControllerBase.java +2 −2 Original line number Diff line number Diff line Loading @@ -84,15 +84,15 @@ public abstract class QSPanelControllerBase<T extends QSPanel> extends ViewContr public void onConfigurationChange(Configuration newConfig) { mShouldUseSplitNotificationShade = Utils.shouldUseSplitNotificationShade(getResources()); onConfigurationChanged(); if (newConfig.orientation != mLastOrientation) { mLastOrientation = newConfig.orientation; onScreenRotated(); switchTileLayout(false); } } }; protected void onScreenRotated() { } protected void onConfigurationChanged() { } private final Function1<Boolean, Unit> mMediaHostVisibilityListener = (visible) -> { if (mMediaVisibilityChangedListener != null) { Loading
packages/SystemUI/src/com/android/systemui/qs/QuickQSPanelController.java +3 −11 Original line number Diff line number Diff line Loading @@ -81,7 +81,7 @@ public class QuickQSPanelController extends QSPanelControllerBase<QuickQSPanel> mMediaHost.init(MediaHierarchyManager.LOCATION_QQS); mBrightnessController.init(mShouldUseSplitNotificationShade); mFooterActionsController.init(); refreshFooterVisibility(); mFooterActionsController.refreshVisibility(mShouldUseSplitNotificationShade); } @Override Loading Loading @@ -109,14 +109,6 @@ public class QuickQSPanelController extends QSPanelControllerBase<QuickQSPanel> return mView.isListening(); } private void refreshFooterVisibility() { if (mShouldUseSplitNotificationShade) { mFooterActionsController.showFooter(); } else { mFooterActionsController.hideFooter(); } } private void setMaxTiles(int parseNumTiles) { mView.setMaxTiles(parseNumTiles); setTiles(); Loading @@ -129,9 +121,9 @@ public class QuickQSPanelController extends QSPanelControllerBase<QuickQSPanel> } @Override protected void onScreenRotated() { protected void onConfigurationChanged() { mBrightnessController.refreshVisibility(mShouldUseSplitNotificationShade); refreshFooterVisibility(); mFooterActionsController.refreshVisibility(mShouldUseSplitNotificationShade); } @Override Loading
packages/SystemUI/tests/src/com/android/systemui/qs/QuickQSPanelControllerTest.kt +18 −3 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.systemui.qs import android.content.res.Configuration import android.test.suitebuilder.annotation.SmallTest import android.testing.AndroidTestingRunner import com.android.internal.logging.MetricsLogger Loading @@ -27,12 +28,13 @@ import com.android.systemui.plugins.qs.QSTile import com.android.systemui.plugins.qs.QSTileView import com.android.systemui.qs.customize.QSCustomizerController import com.android.systemui.qs.logging.QSLogger import com.android.systemui.flags.FeatureFlags import org.junit.After import org.junit.Before import org.junit.Test import org.junit.runner.RunWith import org.mockito.ArgumentCaptor import org.mockito.ArgumentMatchers.anyBoolean import org.mockito.Captor import org.mockito.Mock import org.mockito.Mockito.`when` import org.mockito.Mockito.any Loading Loading @@ -65,11 +67,11 @@ class QuickQSPanelControllerTest : SysuiTestCase() { @Mock private lateinit var tileView: QSTileView @Mock private lateinit var featureFlags: FeatureFlags @Mock private lateinit var quickQsBrightnessController: QuickQSBrightnessController @Mock private lateinit var footerActionsController: FooterActionsController @Captor private lateinit var captor: ArgumentCaptor<QSPanel.OnConfigurationChangedListener> private lateinit var controller: QuickQSPanelController Loading @@ -78,6 +80,7 @@ class QuickQSPanelControllerTest : SysuiTestCase() { MockitoAnnotations.initMocks(this) `when`(quickQSPanel.tileLayout).thenReturn(tileLayout) `when`(quickQSPanel.isAttachedToWindow).thenReturn(true) `when`(quickQSPanel.dumpableTag).thenReturn("") `when`(quickQSPanel.resources).thenReturn(mContext.resources) `when`(qsTileHost.createTileView(any(), any(), anyBoolean())).thenReturn(tileView) Loading Loading @@ -123,4 +126,16 @@ class QuickQSPanelControllerTest : SysuiTestCase() { verify(quickQSPanel, times(limit)).addTile(any()) } @Test fun testBrightnessAndFooterVisibilityRefreshedWhenConfigurationChanged() { // times(2) because both controller and base controller are registering their listeners verify(quickQSPanel, times(2)).addOnConfigurationChangedListener(captor.capture()) captor.allValues.forEach { it.onConfigurationChange(Configuration.EMPTY) } verify(quickQsBrightnessController).refreshVisibility(anyBoolean()) // times(2) because footer visibility is also refreshed on controller init verify(footerActionsController, times(2)).refreshVisibility(anyBoolean()) } }