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

Commit c50856c5 authored by Andre Le's avatar Andre Le
Browse files

QSDetailedView: Remove screen record details view

Fall back to use the dialog for screen record tile.

Bug: 416094743
Flag: com.android.systemui.qs_tile_detailed_view
Test: ScreenRecordTileTest
Change-Id: I3d6e60b561e91ef005e2b4983988ac09703979fa
parent 5210ef7e
Loading
Loading
Loading
Loading
+1 −36
Original line number Diff line number Diff line
@@ -43,10 +43,10 @@ import android.testing.TestableLooper;
import androidx.test.filters.SmallTest;

import com.android.internal.logging.MetricsLogger;
import com.android.systemui.Flags;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.animation.DialogTransitionAnimator;
import com.android.systemui.classifier.FalsingManagerFake;
import com.android.systemui.Flags;
import com.android.systemui.flags.FeatureFlags;
import com.android.systemui.mediaprojection.MediaProjectionMetricsLogger;
import com.android.systemui.plugins.ActivityStarter;
@@ -67,7 +67,6 @@ import com.android.systemui.statusbar.phone.KeyguardDismissUtil;
import com.android.systemui.statusbar.policy.KeyguardStateController;

import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -421,40 +420,6 @@ public class ScreenRecordTileTest extends SysuiTestCase {
                .notifyPermissionRequestDisplayed(mContext.getUserId());
    }

    @Test
    @EnableFlags(QsDetailedView.FLAG_NAME)
    public void testNotStartingAndRecording_returnDetailsViewModel() {
        when(mController.isStarting()).thenReturn(false);
        when(mController.isRecording()).thenReturn(false);
        when(mController.isScreenCaptureDisabled()).thenReturn(false);
        mTile.getDetailsViewModel(Assert::assertNotNull);
    }

    @Test
    @EnableFlags(QsDetailedView.FLAG_NAME)
    public void testRecordingDisabled_notReturnDetailsViewModel() {
        when(mController.isStarting()).thenReturn(false);
        when(mController.isRecording()).thenReturn(false);
        when(mController.isScreenCaptureDisabled()).thenReturn(true);
        mTile.getDetailsViewModel(Assert::assertNull);
    }

    @Test
    @EnableFlags(QsDetailedView.FLAG_NAME)
    public void testStarting_notReturnDetailsViewModel() {
        when(mController.isStarting()).thenReturn(true);
        when(mController.isRecording()).thenReturn(false);
        mTile.getDetailsViewModel(Assert::assertNull);
    }

    @Test
    @EnableFlags(QsDetailedView.FLAG_NAME)
    public void testRecording_notReturnDetailsViewModel() {
        when(mController.isStarting()).thenReturn(false);
        when(mController.isRecording()).thenReturn(true);
        mTile.getDetailsViewModel(Assert::assertNull);
    }

    private QSTile.Icon createExpectedIcon(int resId) {
        if (QsInCompose.isEnabled()) {
            return new QSTileImpl.DrawableIconWithRes(mContext.getDrawable(resId), resId);
+0 −3
Original line number Diff line number Diff line
@@ -54,8 +54,6 @@ import com.android.systemui.qs.tiles.dialog.InternetDetailsContent
import com.android.systemui.qs.tiles.dialog.InternetDetailsViewModel
import com.android.systemui.qs.tiles.dialog.ModesDetailsContent
import com.android.systemui.qs.tiles.dialog.ModesDetailsViewModel
import com.android.systemui.qs.tiles.dialog.ScreenRecordDetailsContent
import com.android.systemui.qs.tiles.dialog.ScreenRecordDetailsViewModel

@Composable
fun TileDetails(modifier: Modifier = Modifier, detailsViewModel: DetailsViewModel) {
@@ -148,7 +146,6 @@ fun TileDetails(modifier: Modifier = Modifier, detailsViewModel: DetailsViewMode
private fun MapTileDetailsContent(tileDetailsViewModel: TileDetailsViewModel) {
    when (tileDetailsViewModel) {
        is InternetDetailsViewModel -> InternetDetailsContent(tileDetailsViewModel)
        is ScreenRecordDetailsViewModel -> ScreenRecordDetailsContent(tileDetailsViewModel)
        is BluetoothDetailsViewModel ->
            BluetoothDetailsContent(tileDetailsViewModel.detailsContentViewModel)
        is ModesDetailsViewModel -> ModesDetailsContent(tileDetailsViewModel)
+0 −24
Original line number Diff line number Diff line
@@ -42,14 +42,12 @@ import com.android.systemui.mediaprojection.MediaProjectionMetricsLogger;
import com.android.systemui.plugins.ActivityStarter;
import com.android.systemui.plugins.FalsingManager;
import com.android.systemui.plugins.qs.QSTile;
import com.android.systemui.plugins.qs.TileDetailsViewModel;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.qs.QSHost;
import com.android.systemui.qs.QsEventLogger;
import com.android.systemui.qs.logging.QSLogger;
import com.android.systemui.qs.pipeline.domain.interactor.PanelInteractor;
import com.android.systemui.qs.tileimpl.QSTileImpl;
import com.android.systemui.qs.tiles.dialog.ScreenRecordDetailsViewModel;
import com.android.systemui.res.R;
import com.android.systemui.screenrecord.ScreenRecordUxController;
import com.android.systemui.screenrecord.data.model.ScreenRecordModel;
@@ -58,8 +56,6 @@ import com.android.systemui.statusbar.phone.KeyguardDismissUtil;
import com.android.systemui.statusbar.policy.KeyguardStateController;
import com.android.systemui.util.Utils;

import java.util.function.Consumer;

import javax.inject.Inject;

/**
@@ -196,26 +192,6 @@ public class ScreenRecordTile extends QSTileImpl<QSTile.BooleanState>
        refreshState();
    }

    @Override
    public boolean getDetailsViewModel(Consumer<TileDetailsViewModel> callback) {
        handleClick(() -> executeWhenUnlockedKeyguard(
                () -> {
                    if (mController.isScreenCaptureDisabled()) {
                        // Close the panel first so that the toast can show up.
                        mDialogTransitionAnimator.disableAllCurrentDialogsExitAnimations();
                        mPanelInteractor.collapsePanels();

                        showDisabledByPolicyToast();
                        return;
                    }

                    callback.accept(new ScreenRecordDetailsViewModel(mController,
                            this::onStartRecordingClicked));
                })
        );
        return true;
    }

    @Override
    protected void handleUpdateState(BooleanState state, Object arg) {
        boolean isStarting = mController.isStarting();
+0 −48
Original line number Diff line number Diff line
/*
 * Copyright (C) 2025 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.tiles.dialog

import android.view.LayoutInflater
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.viewinterop.AndroidView
import com.android.systemui.res.R
import com.android.systemui.screenrecord.ScreenRecordPermissionContentManager

@Composable
fun ScreenRecordDetailsContent(viewModel: ScreenRecordDetailsViewModel) {
    val contentManager: ScreenRecordPermissionContentManager = remember {
        viewModel.screenRecordUxController.createScreenRecordPermissionContentManager(
            viewModel.onStartRecordingClicked
        )
    }

    AndroidView(
        modifier = Modifier.fillMaxWidth(),
        factory = { context ->
            // Inflate with the existing dialog xml layout
            val view = LayoutInflater.from(context).inflate(R.layout.screen_share_dialog, null)
            contentManager.bind(view)

            view
            // TODO(b/378514473): Revamp the details view according to the spec.
        },
        onRelease = { contentManager.unbind() },
    )
}
+0 −37
Original line number Diff line number Diff line
/*
 * Copyright (C) 2025 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.tiles.dialog

import com.android.systemui.plugins.qs.TileDetailsViewModel
import com.android.systemui.screenrecord.ScreenRecordUxController

/** The view model used for the screen record details view in the Quick Settings */
class ScreenRecordDetailsViewModel(
    val screenRecordUxController: ScreenRecordUxController,
    val onStartRecordingClicked: Runnable,
) : TileDetailsViewModel {

    override fun clickOnSettingsButton() {
        // No settings button in this tile.
    }

    // TODO(b/388321032): Replace this string with a string in a translatable xml file,
    override val title = "Screen recording"

    // No sub-title in this tile.
    override val subTitle = ""
}