0

capture_selfie_cam: Add a11y alert for preview collision avoidance

Bug: 1302690
Change-Id: I8371137fbb3e480b58086318a26faa279c021cad
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3585086
Reviewed-by: Ahmed Fakhry <afakhry@chromium.org>
Commit-Queue: Min Chen <minch@chromium.org>
Cr-Commit-Position: refs/heads/main@{#994476}
This commit is contained in:
minch
2022-04-21 01:59:52 +00:00
committed by Chromium LUCI CQ
parent 52813cd2b4
commit a18e57f944
6 changed files with 40 additions and 8 deletions

@ -4040,6 +4040,18 @@ Here are some things you can try to get started.
<message name="IDS_ASH_SCREEN_CAPTURE_CAMERA_PREVIEW_SNAPPED_TO_LOWER_LEFT" desc="Alert spoken by screen readers when camera preview being snapped to lower left corner">
Camera snapped to lower left corner
</message>
<message name="IDS_ASH_SCREEN_CAPTURE_CAMERA_PREVIEW_SNAPPED_TO_UPPER_RIGHT_ON_CONFLICT" desc="Alert spoken by screen readers when camera preview being snapped to upper right corner because its bounds overlap with other system surface.">
Camera snapped to upper right corner. Conflict with system surface.
</message>
<message name="IDS_ASH_SCREEN_CAPTURE_CAMERA_PREVIEW_SNAPPED_TO_UPPER_LEFT_ON_CONFLICT" desc="Alert spoken by screen readers when camera preview being snapped to upper left corner because its bounds overlap with other system surface.">
Camera snapped to upper left corner. Conflict with system surface.
</message>
<message name="IDS_ASH_SCREEN_CAPTURE_CAMERA_PREVIEW_SNAPPED_TO_LOWER_RIGHT_ON_CONFLICT" desc="Alert spoken by screen readers when camera preview being snapped to lower right corner because its bounds overlap with other system surface.">
Camera snapped to lower right corner. Conflict with system surface.
</message>
<message name="IDS_ASH_SCREEN_CAPTURE_CAMERA_PREVIEW_SNAPPED_TO_LOWER_LEFT_ON_CONFLICT" desc="Alert spoken by screen readers when camera preview being snapped to lower left corner because its bounds overlap with other system surface.">
Camera snapped to lower left corner. Conflict with system surface.
</message>
<message name="IDS_ASH_SCREEN_CAPTURE_NAVIGATION_ALERT_RECORD_MICROPHONE" desc="Alert spoken by screen readers when user tabs to record microphone setting.">
Record microphone <ph name="CURRENT_STATE">$1<ex>off</ex></ph>, Press enter to turn microphone recording <ph name="NEW_STATE">$2<ex>on</ex></ph>
</message>

@ -0,0 +1 @@
64b3b723e311bbeb6522504a5c0a8d94a36ae39f

@ -0,0 +1 @@
6dee1cc4d6a8cd23a4e8dac71fc1d4ea381d4756

@ -0,0 +1 @@
9e7124e72407d7144c4bef0001457325d1db5fd0

@ -0,0 +1 @@
ce7f68cabc5d2ddad3acb11a701dad367ed501b2

@ -276,17 +276,28 @@ gfx::Size CalculatePreviewInitialSize() {
}
// Returns the appropriate `message_id` for ChromeVox alert on setting camera
// preview snap position.
int GetMessageIdForSnapPosition(CameraPreviewSnapPosition snap_position) {
// preview snap position. `for_collision_avoidance` indicates whether the
// preview snap position updating happens because of its bounds overlap with
// other system surfaces.
int GetMessageIdForSnapPosition(CameraPreviewSnapPosition snap_position,
bool for_collision_avoidance) {
switch (snap_position) {
case CameraPreviewSnapPosition::kTopRight:
return IDS_ASH_SCREEN_CAPTURE_CAMERA_PREVIEW_SNAPPED_TO_UPPER_RIGHT;
return for_collision_avoidance
? IDS_ASH_SCREEN_CAPTURE_CAMERA_PREVIEW_SNAPPED_TO_UPPER_RIGHT_ON_CONFLICT
: IDS_ASH_SCREEN_CAPTURE_CAMERA_PREVIEW_SNAPPED_TO_UPPER_RIGHT;
case CameraPreviewSnapPosition::kTopLeft:
return IDS_ASH_SCREEN_CAPTURE_CAMERA_PREVIEW_SNAPPED_TO_UPPER_LEFT;
return for_collision_avoidance
? IDS_ASH_SCREEN_CAPTURE_CAMERA_PREVIEW_SNAPPED_TO_UPPER_LEFT_ON_CONFLICT
: IDS_ASH_SCREEN_CAPTURE_CAMERA_PREVIEW_SNAPPED_TO_UPPER_LEFT;
case CameraPreviewSnapPosition::kBottomRight:
return IDS_ASH_SCREEN_CAPTURE_CAMERA_PREVIEW_SNAPPED_TO_LOWER_RIGHT;
return for_collision_avoidance
? IDS_ASH_SCREEN_CAPTURE_CAMERA_PREVIEW_SNAPPED_TO_LOWER_RIGHT_ON_CONFLICT
: IDS_ASH_SCREEN_CAPTURE_CAMERA_PREVIEW_SNAPPED_TO_LOWER_RIGHT;
case CameraPreviewSnapPosition::kBottomLeft:
return IDS_ASH_SCREEN_CAPTURE_CAMERA_PREVIEW_SNAPPED_TO_LOWER_LEFT;
return for_collision_avoidance
? IDS_ASH_SCREEN_CAPTURE_CAMERA_PREVIEW_SNAPPED_TO_LOWER_LEFT_ON_CONFLICT
: IDS_ASH_SCREEN_CAPTURE_CAMERA_PREVIEW_SNAPPED_TO_LOWER_LEFT;
}
}
@ -493,7 +504,7 @@ void CaptureModeCameraController::SetCameraPreviewSnapPosition(
// Trigger a11y alert on setting camera preview snap position even though the
// snap position may actually not change.
capture_mode_util::TriggerAccessibilityAlert(
GetMessageIdForSnapPosition(value));
GetMessageIdForSnapPosition(value, /*for_collision_avoidance=*/false));
camera_preview_snap_position_ = value;
MaybeUpdatePreviewWidget(animate);
@ -855,7 +866,12 @@ gfx::Rect CaptureModeCameraController::CalculatePreviewWidgetTargetBounds(
wm::ConvertRectToScreen(parent, &preview_bounds_in_screen);
if (!preview_bounds_in_screen.Intersects(collision_rect_screen)) {
camera_preview_snap_position_ = snap_position;
if (snap_position != camera_preview_snap_position_) {
camera_preview_snap_position_ = snap_position;
capture_mode_util::TriggerAccessibilityAlert(
GetMessageIdForSnapPosition(snap_position,
/*for_collision_avoidance=*/true));
}
// Notice return `preview_bounds` instead of `preview_bounds_in_screen`,
// since it's the target bounds for camera preview in its parent's
// coordinate system.