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

Commit 8acdfe7c authored by Andre Le's avatar Andre Le
Browse files

QSDetailedView: Show a toast when screen recording is disabled

We will show a toast to indicate that screen recording is disabled by
policy, instead of going into the details view.

Bug: b/388345506
Flag: com.android.systemui.qs_tile_detailed_view
Test: ScreenRecordTileTest
Test: Click on screen record tile in the QS -> a toast will be shown if
screen recording is disabled.

Change-Id: Ic23906b74c8b96f77a8768f4d8d3d40775a8c922
parent 9f48f16d
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -345,9 +345,19 @@ public class ScreenRecordTileTest extends SysuiTestCase {
    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() {
+20 −2
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import android.text.TextUtils;
import android.util.Log;
import android.widget.Button;
import android.widget.Switch;
import android.widget.Toast;

import androidx.annotation.Nullable;

@@ -192,8 +193,19 @@ public class ScreenRecordTile extends QSTileImpl<QSTile.BooleanState>
    @Override
    public boolean getDetailsViewModel(Consumer<TileDetailsViewModel> callback) {
        handleClick(() -> executeWhenUnlockedKeyguard(
                () -> callback.accept(new ScreenRecordDetailsViewModel(mController,
                                        this::onStartRecordingClicked)))
                () -> {
                    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;
    }
@@ -244,6 +256,12 @@ public class ScreenRecordTile extends QSTileImpl<QSTile.BooleanState>
        return mContext.getString(R.string.quick_settings_screen_record_label);
    }

    void showDisabledByPolicyToast() {
        Toast.makeText(mContext,
                R.string.screen_capturing_disabled_by_policy_dialog_description, Toast.LENGTH_SHORT)
                .show();
    }

    private void cancelCountdown() {
        Log.d(TAG, "Cancelling countdown");
        mController.cancelCountdown();
+0 −7
Original line number Diff line number Diff line
@@ -28,13 +28,6 @@ import com.android.systemui.screenrecord.ScreenRecordPermissionViewBinder

@Composable
fun ScreenRecordDetailsContent(viewModel: ScreenRecordDetailsViewModel) {
    // TODO(b/378514312): Finish implementing this function.

    if (viewModel.recordingController.isScreenCaptureDisabled) {
        // TODO(b/388345506): Show disabled page here.
        return
    }

    val viewBinder: ScreenRecordPermissionViewBinder = remember {
        viewModel.recordingController.createScreenRecordPermissionViewBinder(
            viewModel.onStartRecordingClicked