Loading packages/SystemUI/res/layout/quick_status_bar_expanded_header.xml +2 −2 Original line number Diff line number Diff line Loading @@ -32,7 +32,7 @@ android:paddingStart="0dp" android:elevation="4dp" > <!-- Date and privacy. Only visible in QS --> <!-- Date and privacy. Only visible in QS when not in split shade --> <include layout="@layout/quick_status_bar_header_date_privacy"/> <RelativeLayout Loading @@ -42,7 +42,7 @@ android:layout_gravity="top" android:clipChildren="false" android:clipToPadding="false"> <!-- Time, icons and Carrier (only in QS) --> <!-- Time, icons and Carrier (only in QS when not in split shade) --> <include layout="@layout/quick_qs_status_icons"/> <com.android.systemui.qs.QuickQSPanel Loading packages/SystemUI/src/com/android/systemui/qs/QSPanelControllerBase.java +3 −0 Original line number Diff line number Diff line Loading @@ -88,11 +88,14 @@ public abstract class QSPanelControllerBase<T extends QSPanel> extends ViewContr Utils.shouldUseSplitNotificationShade(mFeatureFlags, getResources()); if (newConfig.orientation != mLastOrientation) { mLastOrientation = newConfig.orientation; onScreenRotated(); switchTileLayout(false); } } }; protected void onScreenRotated() { } private final Function1<Boolean, Unit> mMediaHostVisibilityListener = (visible) -> { if (mMediaVisibilityChangedListener != null) { mMediaVisibilityChangedListener.accept(visible); Loading packages/SystemUI/src/com/android/systemui/qs/QuickQSBrightnessController.kt 0 → 100644 +94 −0 Original line number Diff line number Diff line /* * Copyright (C) 2021 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.qs import androidx.annotation.VisibleForTesting import com.android.systemui.settings.brightness.BrightnessController import com.android.systemui.settings.brightness.BrightnessSlider import javax.inject.Inject /** * Controls brightness slider in QQS, which is visible only in split shade. It's responsible for * showing/hiding it when appropriate and (un)registering listeners */ class QuickQSBrightnessController @VisibleForTesting constructor( private val brightnessControllerFactory: () -> BrightnessController ) { @Inject constructor( brightnessControllerFactory: BrightnessController.Factory, brightnessSliderFactory: BrightnessSlider.Factory, quickQSPanel: QuickQSPanel ) : this(brightnessControllerFactory = { val slider = brightnessSliderFactory.create(quickQSPanel.context, quickQSPanel) slider.init() quickQSPanel.setBrightnessView(slider.rootView) brightnessControllerFactory.create(slider) }) private var isListening = false private var brightnessController: BrightnessController? = null fun init(shouldUseSplitNotificationShade: Boolean) { refreshVisibility(shouldUseSplitNotificationShade) } /** * Starts/Stops listening for brightness changing events. * It's fine to call this function even if slider is not visible (which would be the case for * all small screen devices), it will just do nothing in that case */ fun setListening(listening: Boolean) { if (listening) { // controller can be null when slider was never shown if (!isListening && brightnessController != null) { brightnessController?.registerCallbacks() isListening = true } } else { brightnessController?.unregisterCallbacks() isListening = false } } fun checkRestrictionAndSetEnabled() { brightnessController?.checkRestrictionAndSetEnabled() } fun refreshVisibility(shouldUseSplitNotificationShade: Boolean) { if (shouldUseSplitNotificationShade) { showBrightnessSlider() } else { hideBrightnessSlider() } } private fun hideBrightnessSlider() { brightnessController?.hideSlider() } private fun showBrightnessSlider() { if (brightnessController == null) { brightnessController = brightnessControllerFactory() } brightnessController?.showSlider() if (!isListening) { brightnessController?.registerCallbacks() isListening = true } } } No newline at end of file packages/SystemUI/src/com/android/systemui/qs/QuickQSPanel.java +0 −5 Original line number Diff line number Diff line Loading @@ -45,11 +45,6 @@ public class QuickQSPanel extends QSPanel { mMaxTiles = getResources().getInteger(R.integer.quick_qs_panel_max_tiles); } @Override public void setBrightnessView(View view) { // Don't add brightness view } @Override void initialize() { super.initialize(); Loading packages/SystemUI/src/com/android/systemui/qs/QuickQSPanelController.java +24 −1 Original line number Diff line number Diff line Loading @@ -49,16 +49,21 @@ public class QuickQSPanelController extends QSPanelControllerBase<QuickQSPanel> } }; // brightness is visible only in split shade private final QuickQSBrightnessController mBrightnessController; @Inject QuickQSPanelController(QuickQSPanel view, QSTileHost qsTileHost, QSCustomizerController qsCustomizerController, @Named(QS_USING_MEDIA_PLAYER) boolean usingMediaPlayer, @Named(QUICK_QS_PANEL) MediaHost mediaHost, MetricsLogger metricsLogger, UiEventLogger uiEventLogger, QSLogger qsLogger, DumpManager dumpManager, FeatureFlags featureFlags DumpManager dumpManager, FeatureFlags featureFlags, QuickQSBrightnessController quickQSBrightnessController ) { super(view, qsTileHost, qsCustomizerController, usingMediaPlayer, mediaHost, metricsLogger, uiEventLogger, qsLogger, dumpManager, featureFlags); mBrightnessController = quickQSBrightnessController; } @Override Loading @@ -67,6 +72,7 @@ public class QuickQSPanelController extends QSPanelControllerBase<QuickQSPanel> mMediaHost.setExpansion(0.0f); mMediaHost.setShowsOnlyActiveMedia(true); mMediaHost.init(MediaHierarchyManager.LOCATION_QQS); mBrightnessController.init(mShouldUseSplitNotificationShade); } @Override Loading @@ -81,6 +87,12 @@ public class QuickQSPanelController extends QSPanelControllerBase<QuickQSPanel> mView.removeOnConfigurationChangedListener(mOnConfigurationChangedListener); } @Override void setListening(boolean listening) { super.setListening(listening); mBrightnessController.setListening(listening); } public boolean isListening() { return mView.isListening(); } Loading @@ -90,6 +102,17 @@ public class QuickQSPanelController extends QSPanelControllerBase<QuickQSPanel> setTiles(); } @Override public void refreshAllTiles() { mBrightnessController.checkRestrictionAndSetEnabled(); super.refreshAllTiles(); } @Override protected void onScreenRotated() { mBrightnessController.refreshVisibility(mShouldUseSplitNotificationShade); } @Override public void setTiles() { List<QSTile> tiles = new ArrayList<>(); Loading Loading
packages/SystemUI/res/layout/quick_status_bar_expanded_header.xml +2 −2 Original line number Diff line number Diff line Loading @@ -32,7 +32,7 @@ android:paddingStart="0dp" android:elevation="4dp" > <!-- Date and privacy. Only visible in QS --> <!-- Date and privacy. Only visible in QS when not in split shade --> <include layout="@layout/quick_status_bar_header_date_privacy"/> <RelativeLayout Loading @@ -42,7 +42,7 @@ android:layout_gravity="top" android:clipChildren="false" android:clipToPadding="false"> <!-- Time, icons and Carrier (only in QS) --> <!-- Time, icons and Carrier (only in QS when not in split shade) --> <include layout="@layout/quick_qs_status_icons"/> <com.android.systemui.qs.QuickQSPanel Loading
packages/SystemUI/src/com/android/systemui/qs/QSPanelControllerBase.java +3 −0 Original line number Diff line number Diff line Loading @@ -88,11 +88,14 @@ public abstract class QSPanelControllerBase<T extends QSPanel> extends ViewContr Utils.shouldUseSplitNotificationShade(mFeatureFlags, getResources()); if (newConfig.orientation != mLastOrientation) { mLastOrientation = newConfig.orientation; onScreenRotated(); switchTileLayout(false); } } }; protected void onScreenRotated() { } private final Function1<Boolean, Unit> mMediaHostVisibilityListener = (visible) -> { if (mMediaVisibilityChangedListener != null) { mMediaVisibilityChangedListener.accept(visible); Loading
packages/SystemUI/src/com/android/systemui/qs/QuickQSBrightnessController.kt 0 → 100644 +94 −0 Original line number Diff line number Diff line /* * Copyright (C) 2021 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.qs import androidx.annotation.VisibleForTesting import com.android.systemui.settings.brightness.BrightnessController import com.android.systemui.settings.brightness.BrightnessSlider import javax.inject.Inject /** * Controls brightness slider in QQS, which is visible only in split shade. It's responsible for * showing/hiding it when appropriate and (un)registering listeners */ class QuickQSBrightnessController @VisibleForTesting constructor( private val brightnessControllerFactory: () -> BrightnessController ) { @Inject constructor( brightnessControllerFactory: BrightnessController.Factory, brightnessSliderFactory: BrightnessSlider.Factory, quickQSPanel: QuickQSPanel ) : this(brightnessControllerFactory = { val slider = brightnessSliderFactory.create(quickQSPanel.context, quickQSPanel) slider.init() quickQSPanel.setBrightnessView(slider.rootView) brightnessControllerFactory.create(slider) }) private var isListening = false private var brightnessController: BrightnessController? = null fun init(shouldUseSplitNotificationShade: Boolean) { refreshVisibility(shouldUseSplitNotificationShade) } /** * Starts/Stops listening for brightness changing events. * It's fine to call this function even if slider is not visible (which would be the case for * all small screen devices), it will just do nothing in that case */ fun setListening(listening: Boolean) { if (listening) { // controller can be null when slider was never shown if (!isListening && brightnessController != null) { brightnessController?.registerCallbacks() isListening = true } } else { brightnessController?.unregisterCallbacks() isListening = false } } fun checkRestrictionAndSetEnabled() { brightnessController?.checkRestrictionAndSetEnabled() } fun refreshVisibility(shouldUseSplitNotificationShade: Boolean) { if (shouldUseSplitNotificationShade) { showBrightnessSlider() } else { hideBrightnessSlider() } } private fun hideBrightnessSlider() { brightnessController?.hideSlider() } private fun showBrightnessSlider() { if (brightnessController == null) { brightnessController = brightnessControllerFactory() } brightnessController?.showSlider() if (!isListening) { brightnessController?.registerCallbacks() isListening = true } } } No newline at end of file
packages/SystemUI/src/com/android/systemui/qs/QuickQSPanel.java +0 −5 Original line number Diff line number Diff line Loading @@ -45,11 +45,6 @@ public class QuickQSPanel extends QSPanel { mMaxTiles = getResources().getInteger(R.integer.quick_qs_panel_max_tiles); } @Override public void setBrightnessView(View view) { // Don't add brightness view } @Override void initialize() { super.initialize(); Loading
packages/SystemUI/src/com/android/systemui/qs/QuickQSPanelController.java +24 −1 Original line number Diff line number Diff line Loading @@ -49,16 +49,21 @@ public class QuickQSPanelController extends QSPanelControllerBase<QuickQSPanel> } }; // brightness is visible only in split shade private final QuickQSBrightnessController mBrightnessController; @Inject QuickQSPanelController(QuickQSPanel view, QSTileHost qsTileHost, QSCustomizerController qsCustomizerController, @Named(QS_USING_MEDIA_PLAYER) boolean usingMediaPlayer, @Named(QUICK_QS_PANEL) MediaHost mediaHost, MetricsLogger metricsLogger, UiEventLogger uiEventLogger, QSLogger qsLogger, DumpManager dumpManager, FeatureFlags featureFlags DumpManager dumpManager, FeatureFlags featureFlags, QuickQSBrightnessController quickQSBrightnessController ) { super(view, qsTileHost, qsCustomizerController, usingMediaPlayer, mediaHost, metricsLogger, uiEventLogger, qsLogger, dumpManager, featureFlags); mBrightnessController = quickQSBrightnessController; } @Override Loading @@ -67,6 +72,7 @@ public class QuickQSPanelController extends QSPanelControllerBase<QuickQSPanel> mMediaHost.setExpansion(0.0f); mMediaHost.setShowsOnlyActiveMedia(true); mMediaHost.init(MediaHierarchyManager.LOCATION_QQS); mBrightnessController.init(mShouldUseSplitNotificationShade); } @Override Loading @@ -81,6 +87,12 @@ public class QuickQSPanelController extends QSPanelControllerBase<QuickQSPanel> mView.removeOnConfigurationChangedListener(mOnConfigurationChangedListener); } @Override void setListening(boolean listening) { super.setListening(listening); mBrightnessController.setListening(listening); } public boolean isListening() { return mView.isListening(); } Loading @@ -90,6 +102,17 @@ public class QuickQSPanelController extends QSPanelControllerBase<QuickQSPanel> setTiles(); } @Override public void refreshAllTiles() { mBrightnessController.checkRestrictionAndSetEnabled(); super.refreshAllTiles(); } @Override protected void onScreenRotated() { mBrightnessController.refreshVisibility(mShouldUseSplitNotificationShade); } @Override public void setTiles() { List<QSTile> tiles = new ArrayList<>(); Loading