Loading packages/SystemUI/src/com/android/systemui/screencapture/record/largescreen/ui/compose/LargeScreenCaptureRecordContent.kt +3 −1 Original line number Diff line number Diff line Loading @@ -33,6 +33,8 @@ constructor(private val viewModelFactory: PreCaptureViewModel.Factory) : ScreenC val viewModel: PreCaptureViewModel = rememberViewModel("PreCaptureViewModel") { viewModelFactory.create() } if (viewModel.isShowingUI) { PreCaptureUI(viewModel = viewModel) } } } packages/SystemUI/src/com/android/systemui/screencapture/record/largescreen/ui/viewmodel/PreCaptureViewModel.kt +18 −2 Original line number Diff line number Diff line Loading @@ -60,11 +60,15 @@ constructor( private val featuresInteractor: ScreenCaptureRecordLargeScreenFeaturesInteractor, private val drawableLoaderViewModelImpl: DrawableLoaderViewModelImpl, ) : HydratedActivatable(), DrawableLoaderViewModel by drawableLoaderViewModelImpl { private val isShowingUIFlow = MutableStateFlow(true) private val captureTypeSource = MutableStateFlow(ScreenCaptureType.SCREENSHOT) private val captureRegionSource = MutableStateFlow(ScreenCaptureRegion.FULLSCREEN) val icons: ScreenCaptureIcons? by iconProvider.icons.hydratedStateOf() val isShowingUI: Boolean by isShowingUIFlow.hydratedStateOf() // TODO(b/423697394) Init default value to be user's previously selected option val captureType: ScreenCaptureType by captureTypeSource.hydratedStateOf() Loading Loading @@ -102,18 +106,30 @@ constructor( require(captureTypeSource.value == ScreenCaptureType.SCREENSHOT) require(captureRegionSource.value == ScreenCaptureRegion.FULLSCREEN) // Finishing the activity is not guaranteed to complete before the screenshot is taken. // Since the pre-capture UI should not be included in the screenshot, hide the UI first. hideUI() closeUI() backgroundScope.launch { // TODO(b/430361425) Pass in current display as argument. screenshotInteractor.takeFullscreenScreenshot() } // TODO(b/427500006) Close the window after requesting a fullscreen screenshot. } fun onPartialRegionDragEnd(offset: Offset, width: Dp, height: Dp) { // TODO(b/427541309) Update region box position and size. } /** * Simply hides all Composables from being visible in the [ScreenCaptureActivity], but does NOT * close the activity. See [closeUI] for closing the activity. */ fun hideUI() { isShowingUIFlow.value = false } /** Closes the UI by finishing the parent [ScreenCaptureActivity]. */ fun closeUI() { activity.finish() } Loading packages/SystemUI/tests/src/com/android/systemui/screencapture/record/largescreen/ui/viewmodel/PreCaptureViewModelTest.kt +9 −0 Original line number Diff line number Diff line Loading @@ -63,6 +63,7 @@ class PreCaptureViewModelTest : SysuiTestCase() { fun initialState() = testScope.runTest { // Assert that the initial values are as expected upon creation and activation. assertThat(viewModel.isShowingUI).isTrue() assertThat(viewModel.captureType).isEqualTo(ScreenCaptureType.SCREENSHOT) assertThat(viewModel.captureRegion).isEqualTo(ScreenCaptureRegion.FULLSCREEN) } Loading Loading @@ -194,6 +195,14 @@ class PreCaptureViewModelTest : SysuiTestCase() { assertThat(viewModel.captureRegionButtonViewModels.count { it.isSelected }).isEqualTo(1) } @Test fun hideUI_stopsShowingUI() = testScope.runTest { viewModel.hideUI() assertThat(viewModel.isShowingUI).isFalse() } @Test fun closeUI_finishesActivity() = testScope.runTest { Loading Loading
packages/SystemUI/src/com/android/systemui/screencapture/record/largescreen/ui/compose/LargeScreenCaptureRecordContent.kt +3 −1 Original line number Diff line number Diff line Loading @@ -33,6 +33,8 @@ constructor(private val viewModelFactory: PreCaptureViewModel.Factory) : ScreenC val viewModel: PreCaptureViewModel = rememberViewModel("PreCaptureViewModel") { viewModelFactory.create() } if (viewModel.isShowingUI) { PreCaptureUI(viewModel = viewModel) } } }
packages/SystemUI/src/com/android/systemui/screencapture/record/largescreen/ui/viewmodel/PreCaptureViewModel.kt +18 −2 Original line number Diff line number Diff line Loading @@ -60,11 +60,15 @@ constructor( private val featuresInteractor: ScreenCaptureRecordLargeScreenFeaturesInteractor, private val drawableLoaderViewModelImpl: DrawableLoaderViewModelImpl, ) : HydratedActivatable(), DrawableLoaderViewModel by drawableLoaderViewModelImpl { private val isShowingUIFlow = MutableStateFlow(true) private val captureTypeSource = MutableStateFlow(ScreenCaptureType.SCREENSHOT) private val captureRegionSource = MutableStateFlow(ScreenCaptureRegion.FULLSCREEN) val icons: ScreenCaptureIcons? by iconProvider.icons.hydratedStateOf() val isShowingUI: Boolean by isShowingUIFlow.hydratedStateOf() // TODO(b/423697394) Init default value to be user's previously selected option val captureType: ScreenCaptureType by captureTypeSource.hydratedStateOf() Loading Loading @@ -102,18 +106,30 @@ constructor( require(captureTypeSource.value == ScreenCaptureType.SCREENSHOT) require(captureRegionSource.value == ScreenCaptureRegion.FULLSCREEN) // Finishing the activity is not guaranteed to complete before the screenshot is taken. // Since the pre-capture UI should not be included in the screenshot, hide the UI first. hideUI() closeUI() backgroundScope.launch { // TODO(b/430361425) Pass in current display as argument. screenshotInteractor.takeFullscreenScreenshot() } // TODO(b/427500006) Close the window after requesting a fullscreen screenshot. } fun onPartialRegionDragEnd(offset: Offset, width: Dp, height: Dp) { // TODO(b/427541309) Update region box position and size. } /** * Simply hides all Composables from being visible in the [ScreenCaptureActivity], but does NOT * close the activity. See [closeUI] for closing the activity. */ fun hideUI() { isShowingUIFlow.value = false } /** Closes the UI by finishing the parent [ScreenCaptureActivity]. */ fun closeUI() { activity.finish() } Loading
packages/SystemUI/tests/src/com/android/systemui/screencapture/record/largescreen/ui/viewmodel/PreCaptureViewModelTest.kt +9 −0 Original line number Diff line number Diff line Loading @@ -63,6 +63,7 @@ class PreCaptureViewModelTest : SysuiTestCase() { fun initialState() = testScope.runTest { // Assert that the initial values are as expected upon creation and activation. assertThat(viewModel.isShowingUI).isTrue() assertThat(viewModel.captureType).isEqualTo(ScreenCaptureType.SCREENSHOT) assertThat(viewModel.captureRegion).isEqualTo(ScreenCaptureRegion.FULLSCREEN) } Loading Loading @@ -194,6 +195,14 @@ class PreCaptureViewModelTest : SysuiTestCase() { assertThat(viewModel.captureRegionButtonViewModels.count { it.isSelected }).isEqualTo(1) } @Test fun hideUI_stopsShowingUI() = testScope.runTest { viewModel.hideUI() assertThat(viewModel.isShowingUI).isFalse() } @Test fun closeUI_finishesActivity() = testScope.runTest { Loading