Loading packages/SystemUI/src/com/android/systemui/qs/flags/QsInCompose.kt 0 → 100644 +43 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 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.flags import com.android.systemui.flags.RefactorFlagUtils import com.android.systemui.shade.shared.flag.DualShade /** * Object to help check if the new QS ui should be used. This is true if either [QSComposeFragment] * or [DualShade] are enabled. */ object QsInCompose { /** * This is not a real flag name, but a representation of the allowed flag names. Should not be * used with test annotations. */ private val flagName = "${QSComposeFragment.FLAG_NAME}|${DualShade.FLAG_NAME}" @JvmStatic inline val isEnabled: Boolean get() = QSComposeFragment.isEnabled || DualShade.isEnabled @JvmStatic fun isUnexpectedlyInLegacyMode() = RefactorFlagUtils.isUnexpectedlyInLegacyMode(isEnabled, flagName) @JvmStatic fun assertInLegacyMode() = RefactorFlagUtils.assertInLegacyMode(isEnabled, flagName) } packages/SystemUI/src/com/android/systemui/settings/brightness/BrightnessDialog.java +5 −5 Original line number Diff line number Diff line Loading @@ -48,7 +48,7 @@ import com.android.internal.logging.nano.MetricsProto.MetricsEvent; import com.android.systemui.brightness.ui.viewmodel.BrightnessSliderViewModel; import com.android.systemui.compose.ComposeInitializer; import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.qs.flags.QSComposeFragment; import com.android.systemui.qs.flags.QsInCompose; import com.android.systemui.res.R; import com.android.systemui.shade.domain.interactor.ShadeInteractor; import com.android.systemui.statusbar.policy.AccessibilityManagerWrapper; Loading Loading @@ -96,7 +96,7 @@ public class BrightnessDialog extends Activity { super.onCreate(savedInstanceState); setWindowAttributes(); View view; if (!QSComposeFragment.isEnabled()) { if (!QsInCompose.isEnabled()) { setContentView(R.layout.brightness_mirror_container); view = findViewById(R.id.brightness_mirror_container); setDialogContent((FrameLayout) view); Loading Loading @@ -140,7 +140,7 @@ public class BrightnessDialog extends Activity { window.getDecorView(); window.setLayout(WRAP_CONTENT, WRAP_CONTENT); getTheme().applyStyle(R.style.Theme_SystemUI_QuickSettings, false); if (QSComposeFragment.isEnabled()) { if (QsInCompose.isEnabled()) { window.getDecorView().addOnAttachStateChangeListener( new View.OnAttachStateChangeListener() { @Override Loading Loading @@ -217,7 +217,7 @@ public class BrightnessDialog extends Activity { @Override protected void onStart() { super.onStart(); if (!QSComposeFragment.isEnabled()) { if (!QsInCompose.isEnabled()) { mBrightnessController.registerCallbacks(); } MetricsLogger.visible(this, MetricsEvent.BRIGHTNESS_DIALOG); Loading @@ -241,7 +241,7 @@ public class BrightnessDialog extends Activity { protected void onStop() { super.onStop(); MetricsLogger.hidden(this, MetricsEvent.BRIGHTNESS_DIALOG); if (!QSComposeFragment.isEnabled()) { if (!QsInCompose.isEnabled()) { mBrightnessController.unregisterCallbacks(); } } Loading packages/SystemUI/tests/src/com/android/systemui/settings/brightness/BrightnessDialogTest.kt +3 −2 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ import com.android.systemui.activity.SingleActivityFactory import com.android.systemui.brightness.ui.viewmodel.BrightnessSliderViewModel import com.android.systemui.brightness.ui.viewmodel.brightnessSliderViewModelFactory import com.android.systemui.qs.flags.QSComposeFragment import com.android.systemui.qs.flags.QsInCompose import com.android.systemui.res.R import com.android.systemui.shade.domain.interactor.ShadeInteractor import com.android.systemui.statusbar.policy.AccessibilityManagerWrapper Loading Loading @@ -70,8 +71,8 @@ class BrightnessDialogTest(val flags: FlagsParameterization) : SysuiTestCase() { mSetFlagsRule.setFlagsParameterization(flags) } val viewId by lazy { if (QSComposeFragment.isEnabled) { private val viewId by lazy { if (QsInCompose.isEnabled) { R.id.brightness_dialog_slider } else { R.id.brightness_mirror_container Loading Loading
packages/SystemUI/src/com/android/systemui/qs/flags/QsInCompose.kt 0 → 100644 +43 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 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.flags import com.android.systemui.flags.RefactorFlagUtils import com.android.systemui.shade.shared.flag.DualShade /** * Object to help check if the new QS ui should be used. This is true if either [QSComposeFragment] * or [DualShade] are enabled. */ object QsInCompose { /** * This is not a real flag name, but a representation of the allowed flag names. Should not be * used with test annotations. */ private val flagName = "${QSComposeFragment.FLAG_NAME}|${DualShade.FLAG_NAME}" @JvmStatic inline val isEnabled: Boolean get() = QSComposeFragment.isEnabled || DualShade.isEnabled @JvmStatic fun isUnexpectedlyInLegacyMode() = RefactorFlagUtils.isUnexpectedlyInLegacyMode(isEnabled, flagName) @JvmStatic fun assertInLegacyMode() = RefactorFlagUtils.assertInLegacyMode(isEnabled, flagName) }
packages/SystemUI/src/com/android/systemui/settings/brightness/BrightnessDialog.java +5 −5 Original line number Diff line number Diff line Loading @@ -48,7 +48,7 @@ import com.android.internal.logging.nano.MetricsProto.MetricsEvent; import com.android.systemui.brightness.ui.viewmodel.BrightnessSliderViewModel; import com.android.systemui.compose.ComposeInitializer; import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.qs.flags.QSComposeFragment; import com.android.systemui.qs.flags.QsInCompose; import com.android.systemui.res.R; import com.android.systemui.shade.domain.interactor.ShadeInteractor; import com.android.systemui.statusbar.policy.AccessibilityManagerWrapper; Loading Loading @@ -96,7 +96,7 @@ public class BrightnessDialog extends Activity { super.onCreate(savedInstanceState); setWindowAttributes(); View view; if (!QSComposeFragment.isEnabled()) { if (!QsInCompose.isEnabled()) { setContentView(R.layout.brightness_mirror_container); view = findViewById(R.id.brightness_mirror_container); setDialogContent((FrameLayout) view); Loading Loading @@ -140,7 +140,7 @@ public class BrightnessDialog extends Activity { window.getDecorView(); window.setLayout(WRAP_CONTENT, WRAP_CONTENT); getTheme().applyStyle(R.style.Theme_SystemUI_QuickSettings, false); if (QSComposeFragment.isEnabled()) { if (QsInCompose.isEnabled()) { window.getDecorView().addOnAttachStateChangeListener( new View.OnAttachStateChangeListener() { @Override Loading Loading @@ -217,7 +217,7 @@ public class BrightnessDialog extends Activity { @Override protected void onStart() { super.onStart(); if (!QSComposeFragment.isEnabled()) { if (!QsInCompose.isEnabled()) { mBrightnessController.registerCallbacks(); } MetricsLogger.visible(this, MetricsEvent.BRIGHTNESS_DIALOG); Loading @@ -241,7 +241,7 @@ public class BrightnessDialog extends Activity { protected void onStop() { super.onStop(); MetricsLogger.hidden(this, MetricsEvent.BRIGHTNESS_DIALOG); if (!QSComposeFragment.isEnabled()) { if (!QsInCompose.isEnabled()) { mBrightnessController.unregisterCallbacks(); } } Loading
packages/SystemUI/tests/src/com/android/systemui/settings/brightness/BrightnessDialogTest.kt +3 −2 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ import com.android.systemui.activity.SingleActivityFactory import com.android.systemui.brightness.ui.viewmodel.BrightnessSliderViewModel import com.android.systemui.brightness.ui.viewmodel.brightnessSliderViewModelFactory import com.android.systemui.qs.flags.QSComposeFragment import com.android.systemui.qs.flags.QsInCompose import com.android.systemui.res.R import com.android.systemui.shade.domain.interactor.ShadeInteractor import com.android.systemui.statusbar.policy.AccessibilityManagerWrapper Loading Loading @@ -70,8 +71,8 @@ class BrightnessDialogTest(val flags: FlagsParameterization) : SysuiTestCase() { mSetFlagsRule.setFlagsParameterization(flags) } val viewId by lazy { if (QSComposeFragment.isEnabled) { private val viewId by lazy { if (QsInCompose.isEnabled) { R.id.brightness_dialog_slider } else { R.id.brightness_mirror_container Loading