diff options
| author | 2023-07-25 03:08:51 +0000 | |
|---|---|---|
| committer | 2023-07-27 03:33:58 +0000 | |
| commit | 03eb23eecae948cc1f90df8e693c178aa40bae5a (patch) | |
| tree | dcd0e3aecb99b31c2db025cbfdf8a492ea1786a0 | |
| parent | dd47c1acd0bfc10ab7939b0549510cf475b2125d (diff) | |
Support exiting edit mode when performing click action on the magnifier
When the window magnifier is in Edit mode, performing click action on
magnifier window could allow users to exit edit mode in Accessibility
Service.
Bug: 274735471
Test: manually - attach video to the bug
Test: atest WindowMagnificationControllerTest
Change-Id: Ie8fce6e03fcde5c8551b2a0c448f25e8c4b6ebd6
3 files changed, 46 insertions, 2 deletions
diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml index 983b09f957ae..5f14733ec135 100644 --- a/packages/SystemUI/res/values/strings.xml +++ b/packages/SystemUI/res/values/strings.xml @@ -2401,6 +2401,8 @@ <string name="magnification_open_settings_click_label">Open magnification settings</string> <!-- Click action label for magnification settings panel. [CHAR LIMIT=NONE] --> <string name="magnification_close_settings_click_label">Close magnification settings</string> + <!-- Click action label for exiting magnifier edit mode. [CHAR LIMIT=NONE] --> + <string name="magnification_exit_edit_mode_click_label">Exit edit mode</string> <!-- Label of the corner of a rectangle that you can tap and drag to resize the magnification area. [CHAR LIMIT=NONE] --> <string name="magnification_drag_corner_to_resize">Drag corner to resize</string> diff --git a/packages/SystemUI/src/com/android/systemui/accessibility/WindowMagnificationController.java b/packages/SystemUI/src/com/android/systemui/accessibility/WindowMagnificationController.java index 602f817f826b..28d59c21086b 100644 --- a/packages/SystemUI/src/com/android/systemui/accessibility/WindowMagnificationController.java +++ b/packages/SystemUI/src/com/android/systemui/accessibility/WindowMagnificationController.java @@ -1446,6 +1446,12 @@ class WindowMagnificationController implements View.OnTouchListener, SurfaceHold private class MirrorWindowA11yDelegate extends View.AccessibilityDelegate { private CharSequence getClickAccessibilityActionLabel() { + if (mEditSizeEnable) { + // Perform click action to exit edit mode + return mContext.getResources().getString( + R.string.magnification_exit_edit_mode_click_label); + } + return mSettingsPanelVisibility ? mContext.getResources().getString( R.string.magnification_close_settings_click_label) @@ -1488,8 +1494,14 @@ class WindowMagnificationController implements View.OnTouchListener, SurfaceHold private boolean performA11yAction(int action) { if (action == AccessibilityAction.ACTION_CLICK.getId()) { - // Simulate tapping the drag view so it opens the Settings. - handleSingleTap(mDragView); + if (mEditSizeEnable) { + // When edit mode is enabled, click the magnifier to exit edit mode. + setEditMagnifierSizeMode(false); + } else { + // Simulate tapping the drag view so it opens the Settings. + handleSingleTap(mDragView); + } + } else if (action == R.id.accessibility_action_zoom_in) { performScale(mScale + A11Y_CHANGE_SCALE_DIFFERENCE); } else if (action == R.id.accessibility_action_zoom_out) { diff --git a/packages/SystemUI/tests/src/com/android/systemui/accessibility/WindowMagnificationControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/accessibility/WindowMagnificationControllerTest.java index 56f81606a282..e96ad876db3a 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/accessibility/WindowMagnificationControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/accessibility/WindowMagnificationControllerTest.java @@ -682,6 +682,36 @@ public class WindowMagnificationControllerTest extends SysuiTestCase { } @Test + public void windowMagnifierEditMode_performA11yClickAction_exitEditMode() { + mInstrumentation.runOnMainSync(() -> { + mWindowMagnificationController.enableWindowMagnificationInternal(Float.NaN, Float.NaN, + Float.NaN); + mWindowMagnificationController.setEditMagnifierSizeMode(true); + }); + + View closeButton = getInternalView(R.id.close_button); + View bottomRightCorner = getInternalView(R.id.bottom_right_corner); + View bottomLeftCorner = getInternalView(R.id.bottom_left_corner); + View topRightCorner = getInternalView(R.id.top_right_corner); + View topLeftCorner = getInternalView(R.id.top_left_corner); + + assertEquals(View.VISIBLE, closeButton.getVisibility()); + assertEquals(View.VISIBLE, bottomRightCorner.getVisibility()); + assertEquals(View.VISIBLE, bottomLeftCorner.getVisibility()); + assertEquals(View.VISIBLE, topRightCorner.getVisibility()); + assertEquals(View.VISIBLE, topLeftCorner.getVisibility()); + + final View mirrorView = mWindowManager.getAttachedView(); + mirrorView.performAccessibilityAction(AccessibilityAction.ACTION_CLICK.getId(), null); + + assertEquals(View.GONE, closeButton.getVisibility()); + assertEquals(View.GONE, bottomRightCorner.getVisibility()); + assertEquals(View.GONE, bottomLeftCorner.getVisibility()); + assertEquals(View.GONE, topRightCorner.getVisibility()); + assertEquals(View.GONE, topLeftCorner.getVisibility()); + } + + @Test public void enableWindowMagnification_hasA11yWindowTitle() { mInstrumentation.runOnMainSync(() -> { mWindowMagnificationController.enableWindowMagnificationInternal(Float.NaN, Float.NaN, |