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

Commit d1a51dd5 authored by Wes Okuhara's avatar Wes Okuhara
Browse files

Desktop screenshots: Create features interactor for supported regions

The features interactor will control which screen capture actions are
supported.

Bug: 427497534
Test: atest ScreenCaptureViewModelTest
Flag: com.android.systemui.desktop_screen_capture
Change-Id: I438ffc791cb228b61c483ef29d584d65be839503
parent 3c3f8f6b
Loading
Loading
Loading
Loading
+26 −0
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.screencapture.record.largescreen.domain.interactor

import com.android.systemui.dagger.SysUISingleton
import javax.inject.Inject

@SysUISingleton
class ScreenCaptureRecordLargeScreenFeaturesInteractor @Inject constructor() {
    // TODO(b/427497534) Guard behind a new feature flag specific for app window region.
    val appWindowRegionSupported = true
}
+30 −18
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.lifecycle.HydratedActivatable
import com.android.systemui.res.R
import com.android.systemui.screencapture.domain.interactor.ScreenshotInteractor
import com.android.systemui.screencapture.record.largescreen.domain.interactor.ScreenCaptureRecordLargeScreenFeaturesInteractor
import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject
import kotlinx.coroutines.coroutineScope
@@ -39,13 +40,14 @@ enum class ScreenCaptureRegion {
    APP_WINDOW,
}

/** Models state for the Screen Capture UI */
/** Models UI for the Screen Capture UI for large screen devices. */
class ScreenCaptureViewModel
@AssistedInject
constructor(
    @Application private val applicationContext: Context,
    private val iconProvider: ScreenCaptureIconProvider,
    private val screenshotInteractor: ScreenshotInteractor,
    private val featuresInteractor: ScreenCaptureRecordLargeScreenFeaturesInteractor,
) : HydratedActivatable() {
    private val captureTypeSource = MutableStateFlow(ScreenCaptureType.SCREENSHOT)
    private val captureRegionSource = MutableStateFlow(ScreenCaptureRegion.FULLSCREEN)
@@ -121,23 +123,33 @@ constructor(
        selectedRegion: ScreenCaptureRegion,
        icons: ScreenCaptureIcons?,
    ): List<RadioButtonGroupItemViewModel> {
        return listOf(
        return buildList {
            if (featuresInteractor.appWindowRegionSupported) {
                add(
                    RadioButtonGroupItemViewModel(
                        icon = icons?.appWindow,
                        isSelected = (selectedRegion == ScreenCaptureRegion.APP_WINDOW),
                        onClick = { updateCaptureRegion(ScreenCaptureRegion.APP_WINDOW) },
            ),
                    )
                )
            }

            add(
                RadioButtonGroupItemViewModel(
                    icon = icons?.region,
                    isSelected = (selectedRegion == ScreenCaptureRegion.PARTIAL),
                    onClick = { updateCaptureRegion(ScreenCaptureRegion.PARTIAL) },
            ),
                )
            )

            add(
                RadioButtonGroupItemViewModel(
                    icon = icons?.fullscreen,
                    isSelected = (selectedRegion == ScreenCaptureRegion.FULLSCREEN),
                    onClick = { updateCaptureRegion(ScreenCaptureRegion.FULLSCREEN) },
            ),
                )
            )
        }
    }

    @AssistedFactory
+24 −0
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.screencapture.record.largescreen.domain.interactor

import com.android.systemui.kosmos.Kosmos
import com.android.systemui.kosmos.Kosmos.Fixture

val Kosmos.screenCaptureRecordLargeScreenFeaturesInteractor by Fixture {
    ScreenCaptureRecordLargeScreenFeaturesInteractor()
}
+2 −0
Original line number Diff line number Diff line
@@ -20,11 +20,13 @@ import android.content.applicationContext
import com.android.systemui.kosmos.Kosmos
import com.android.systemui.kosmos.Kosmos.Fixture
import com.android.systemui.screencapture.domain.interactor.screenshotInteractor
import com.android.systemui.screencapture.record.largescreen.domain.interactor.screenCaptureRecordLargeScreenFeaturesInteractor

val Kosmos.screenCaptureViewModel by Fixture {
    ScreenCaptureViewModel(
        applicationContext = applicationContext,
        iconProvider = screenCaptureIconProviderKosmos,
        screenshotInteractor = screenshotInteractor,
        featuresInteractor = screenCaptureRecordLargeScreenFeaturesInteractor,
    )
}