diff options
| author | 2024-11-26 14:33:17 +0000 | |
|---|---|---|
| committer | 2024-11-26 14:33:17 +0000 | |
| commit | 0fd15aa6cf8255685fa9906c3c844e54616f815d (patch) | |
| tree | d91527c39f57b22303683898801003b8ae9c71ed | |
| parent | 1f1625b56f93730ffdb71023b9736c0d1f12e97a (diff) | |
| parent | 28c4dd6ca5476cacb9c2fe3fe43ffdee9308874c (diff) | |
Merge "Add virtual flag that indicates QS UI in compose" into main
3 files changed, 51 insertions, 7 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/qs/flags/QsInCompose.kt b/packages/SystemUI/src/com/android/systemui/qs/flags/QsInCompose.kt new file mode 100644 index 000000000000..3067ccbb7cea --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/qs/flags/QsInCompose.kt @@ -0,0 +1,43 @@ +/* + * 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) +} diff --git a/packages/SystemUI/src/com/android/systemui/settings/brightness/BrightnessDialog.java b/packages/SystemUI/src/com/android/systemui/settings/brightness/BrightnessDialog.java index 8c004c4d3adf..6844f053cd21 100644 --- a/packages/SystemUI/src/com/android/systemui/settings/brightness/BrightnessDialog.java +++ b/packages/SystemUI/src/com/android/systemui/settings/brightness/BrightnessDialog.java @@ -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; @@ -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); @@ -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 @@ -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); @@ -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(); } } diff --git a/packages/SystemUI/tests/src/com/android/systemui/settings/brightness/BrightnessDialogTest.kt b/packages/SystemUI/tests/src/com/android/systemui/settings/brightness/BrightnessDialogTest.kt index f7059e244084..a64ff321cd4d 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/settings/brightness/BrightnessDialogTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/settings/brightness/BrightnessDialogTest.kt @@ -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 @@ -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 |