Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 28c4dd6c authored by Fabián Kozynski's avatar Fabián Kozynski
Browse files

Add virtual flag that indicates QS UI in compose

This should be used outside of (NPVC) and scene container classes to
determine if the new QS UI should be used. This is true if either
com.android.systemui.qs_ui_refactor_compose_fragment OR
com.android.systemui.dual_shade are enabled.

Flag: com.android.systemui.qs_ui_refactor_compose_fragment
Flag: com.android.systemui.dual_shade
Bug: 329270606
Test: manual, check brightness slider
Change-Id: I0197e1a13f200fab6f516149eeb65a3ad9005eb2
parent feb3f74a
Loading
Loading
Loading
Loading
+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)
}
+5 −5
Original line number Diff line number Diff line
@@ -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();
        }
    }
+3 −2
Original line number Diff line number Diff line
@@ -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