Fix focus and announcements for Magnification Settings

1. When opening the settings panel in Talkback, the focus will be on the
   panel.
2. Add content description for the magnification settings panel.
3. Fix the click action announced for the magnification window to be
   opening the settings panel.

Bug: 241996711
Test: manually - attach videos to the bug
Test: atest WindowMagnificationSettingsTest
Change-Id: If787cf8b8ce270a5048c650d26905a6123f838ca
This commit is contained in:
Candice Lo
2023-03-02 16:36:03 +00:00
parent 95268ff676
commit 77cd76695a
5 changed files with 21 additions and 4 deletions

View File

@@ -21,7 +21,9 @@
android:layout_height="wrap_content"
android:background="@drawable/accessibility_magnification_setting_view_bg"
android:orientation="vertical"
android:padding="@dimen/magnification_setting_background_padding">
android:padding="@dimen/magnification_setting_background_padding"
android:focusable="true"
android:contentDescription="@string/accessibility_magnification_settings_panel_description">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"

View File

@@ -2339,6 +2339,8 @@
<string name="magnification_mode_switch_state_window">Magnify part of screen</string>
<!-- Click action label for magnification switch. [CHAR LIMIT=NONE] -->
<string name="magnification_mode_switch_click_label">Switch</string>
<!-- Click action label for magnification settings panel. [CHAR LIMIT=NONE] -->
<string name="magnification_open_settings_click_label">Open magnification settings</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>
@@ -2360,6 +2362,8 @@
<!-- Description of the window magnification Bottom handle [CHAR LIMIT=NONE]-->
<string name="accessibility_magnification_bottom_handle">Bottom handle</string>
<!-- Description of the window magnification panel [CHAR LIMIT=NONE]-->
<string name="accessibility_magnification_settings_panel_description">Magnification settings</string>
<!-- Title of the window magnification panel option Magnifier size [CHAR LIMIT=NONE]-->
<string name="accessibility_magnifier_size">Magnifier size</string>
<!-- Title of the window magnification panel option Zoom [CHAR LIMIT=NONE]-->

View File

@@ -1468,7 +1468,7 @@ class WindowMagnificationController implements View.OnTouchListener, SurfaceHold
super.onInitializeAccessibilityNodeInfo(host, info);
final AccessibilityAction clickAction = new AccessibilityAction(
AccessibilityAction.ACTION_CLICK.getId(), mContext.getResources().getString(
R.string.magnification_mode_switch_click_label));
R.string.magnification_open_settings_click_label));
info.addAction(clickAction);
info.setClickable(true);
info.addAction(

View File

@@ -353,6 +353,10 @@ class WindowMagnificationSettings implements MagnificationGestureDetector.OnGest
}
mWindowManager.addView(mSettingView, mParams);
if (resetPosition) {
// Request focus on the settings panel when position of the panel is reset.
mSettingView.requestFocus();
}
// Exclude magnification switch button from system gesture area.
setSystemGestureExclusion();
@@ -380,8 +384,8 @@ class WindowMagnificationSettings implements MagnificationGestureDetector.OnGest
mSettingView = (LinearLayout) View.inflate(mContext,
R.layout.window_magnification_settings_view, null);
mSettingView.setClickable(true);
mSettingView.setFocusable(true);
mSettingView.setFocusableInTouchMode(true);
mSettingView.setOnTouchListener(this::onTouch);
mPanelView = mSettingView.findViewById(R.id.magnifier_panel_view);
@@ -530,7 +534,7 @@ class WindowMagnificationSettings implements MagnificationGestureDetector.OnGest
LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT,
LayoutParams.TYPE_ACCESSIBILITY_MAGNIFICATION_OVERLAY,
LayoutParams.FLAG_NOT_FOCUSABLE,
/* _flags= */ 0,
PixelFormat.TRANSPARENT);
params.gravity = Gravity.TOP | Gravity.START;
params.accessibilityTitle = getAccessibilityWindowTitle(context);

View File

@@ -201,6 +201,13 @@ public class WindowMagnificationSettingsTest extends SysuiTestCase {
assertThat(magnifierMediumButton.isSelected()).isTrue();
}
@Test
public void showSettingPanel_focusOnThePanel() {
mWindowMagnificationSettings.showSettingPanel();
assertThat(mSettingView.isFocused()).isTrue();
}
private <T extends View> T getInternalView(@IdRes int idRes) {
T view = mSettingView.findViewById(idRes);
assertNotNull(view);