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

Commit d861162e authored by Nikki Moteva's avatar Nikki Moteva
Browse files

System UI: add capture button to region select screen capture

Screencast: http://shortn/_FGOhGb6mNd

Bug: 417533820
Test: Manual
Flag: com.android.systemui.desktop_screen_capture
Change-Id: I1e06abf6afbd8f1341805a48e9a3cccfc0a714a2
parent 1d71862c
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -348,6 +348,8 @@
    <!-- Button to stop a screen recording [CHAR LIMIT=35] -->
    <string name="screenrecord_stop_dialog_button">Stop recording</string>

    <!-- Button text in the region select box for triggering a screenshot of the selected area. [CHAR LIMIT=35] -->
    <string name="screen_capture_region_selection_button">Capture selected area</string>
    <!-- Button text in the toolbar for choosing the screenshot type. [CHAR LIMIT=35] -->
    <string name="screen_capture_toolbar_capture_button">Capture</string>
    <!-- Button text in the toolbar for choosing the screen recording type. [CHAR LIMIT=35] -->
+19 −2
Original line number Diff line number Diff line
@@ -39,8 +39,11 @@ import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.layout.onSizeChanged
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import com.android.systemui.common.shared.model.Icon as IconModel
import com.android.systemui.res.R

/**
 * An enum to identify each of the four corners of the rectangle.
@@ -177,6 +180,11 @@ private fun ResizableRectangle(
    onDragEnd: () -> Unit,
    modifier: Modifier = Modifier,
) {
    // TODO(b/422855266): Preload icons in the view model to avoid loading icons in UI thread and
    // improve performance
    val screenshotIcon =
        IconModel.Resource(res = R.drawable.ic_screen_capture_camera, contentDescription = null)

    // The diameter of the resizable knob on each corner of the region box.
    val knobDiameter = 8.dp
    // The width of the border stroke around the region box.
@@ -222,8 +230,17 @@ private fun ResizableRectangle(
                                    onBoxDrag(dragAmount, screenWidth, screenHeight)
                                },
                            )
                        }
                        },
                contentAlignment = Alignment.Center,
            ) {
                PrimaryButton(
                    text = stringResource(id = R.string.screen_capture_region_selection_button),
                    onClick = {
                        // TODO(b/417534202): trigger a screenshot of the selected area.
                    },
                    icon = screenshotIcon,
                )
            }

            // The offset is half of the knob diameter so that it is centered.
            val knobOffset = knobDiameter / 2