Merge "Fix the GAR issue of Switch Access user can not move the FAB to the edge to hide it in half." into sc-dev
This commit is contained in:
@@ -173,5 +173,7 @@
|
||||
<item type="id" name="action_move_top_right"/>
|
||||
<item type="id" name="action_move_bottom_left"/>
|
||||
<item type="id" name="action_move_bottom_right"/>
|
||||
<item type="id" name="action_move_to_edge_and_hide"/>
|
||||
<item type="id" name="action_move_out_edge_and_show"/>
|
||||
</resources>
|
||||
|
||||
|
||||
@@ -2705,6 +2705,10 @@
|
||||
<string name="accessibility_floating_button_action_move_bottom_left">Move bottom left</string>
|
||||
<!-- Action in accessibility menu to move the accessibility floating button to the bottom right of the screen. [CHAR LIMIT=30]-->
|
||||
<string name="accessibility_floating_button_action_move_bottom_right">Move bottom right</string>
|
||||
<!-- Action in accessibility menu to move the accessibility floating button to the edge and hide it to half. [CHAR LIMIT=30]-->
|
||||
<string name="accessibility_floating_button_action_move_to_edge_and_hide_to_half">Move to edge and hide</string>
|
||||
<!-- Action in accessibility menu to move the accessibility floating button out the edge and show. [CHAR LIMIT=30]-->
|
||||
<string name="accessibility_floating_button_action_move_out_edge_and_show">Move out edge and show</string>
|
||||
|
||||
<!-- Device Controls strings -->
|
||||
<!-- Device Controls empty state, title [CHAR LIMIT=30] -->
|
||||
|
||||
@@ -303,25 +303,39 @@ public class AccessibilityFloatingMenuView extends FrameLayout
|
||||
|
||||
final Rect bounds = getAvailableBounds();
|
||||
if (action == R.id.action_move_top_left) {
|
||||
setShapeType(ShapeType.OVAL);
|
||||
snapToLocation(bounds.left, bounds.top);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (action == R.id.action_move_top_right) {
|
||||
setShapeType(ShapeType.OVAL);
|
||||
snapToLocation(bounds.right, bounds.top);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (action == R.id.action_move_bottom_left) {
|
||||
setShapeType(ShapeType.OVAL);
|
||||
snapToLocation(bounds.left, bounds.bottom);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (action == R.id.action_move_bottom_right) {
|
||||
setShapeType(ShapeType.OVAL);
|
||||
snapToLocation(bounds.right, bounds.bottom);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (action == R.id.action_move_to_edge_and_hide) {
|
||||
setShapeType(ShapeType.HALF_OVAL);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (action == R.id.action_move_out_edge_and_show) {
|
||||
setShapeType(ShapeType.OVAL);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -446,6 +460,16 @@ public class AccessibilityFloatingMenuView extends FrameLayout
|
||||
res.getString(
|
||||
R.string.accessibility_floating_button_action_move_bottom_right));
|
||||
info.addAction(moveBottomRight);
|
||||
|
||||
final int moveEdgeId = mShapeType == ShapeType.OVAL
|
||||
? R.id.action_move_to_edge_and_hide
|
||||
: R.id.action_move_out_edge_and_show;
|
||||
final int moveEdgeTextResId = mShapeType == ShapeType.OVAL
|
||||
? R.string.accessibility_floating_button_action_move_to_edge_and_hide_to_half
|
||||
: R.string.accessibility_floating_button_action_move_out_edge_and_show;
|
||||
final AccessibilityAction moveToOrOutEdge =
|
||||
new AccessibilityAction(moveEdgeId, res.getString(moveEdgeTextResId));
|
||||
info.addAction(moveToOrOutEdge);
|
||||
}
|
||||
|
||||
private boolean onTouched(MotionEvent event) {
|
||||
|
||||
@@ -348,61 +348,95 @@ public class AccessibilityFloatingMenuViewTest extends SysuiTestCase {
|
||||
final AccessibilityNodeInfo infos = new AccessibilityNodeInfo();
|
||||
mMenuView.onInitializeAccessibilityNodeInfo(infos);
|
||||
|
||||
assertThat(infos.getActionList().size()).isEqualTo(4);
|
||||
assertThat(infos.getActionList().size()).isEqualTo(5);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void accessibilityActionMove_moveTopLeft_success() {
|
||||
public void accessibilityActionMove_halfOval_moveTopLeft_success() {
|
||||
final AccessibilityFloatingMenuView menuView =
|
||||
spy(new AccessibilityFloatingMenuView(mContext));
|
||||
doReturn(mAvailableBounds).when(menuView).getAvailableBounds();
|
||||
menuView.setShapeType(/* halfOvalShape */ 1);
|
||||
|
||||
final boolean isActionPerformed =
|
||||
menuView.performAccessibilityAction(R.id.action_move_top_left, null);
|
||||
|
||||
assertThat(isActionPerformed).isTrue();
|
||||
assertThat(menuView.mShapeType).isEqualTo(/* ovalShape */ 0);
|
||||
verify(menuView).snapToLocation(mAvailableBounds.left, mAvailableBounds.top);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void accessibilityActionMove_moveTopRight_success() {
|
||||
public void accessibilityActionMove_halfOval_moveTopRight_success() {
|
||||
final AccessibilityFloatingMenuView menuView =
|
||||
spy(new AccessibilityFloatingMenuView(mContext));
|
||||
doReturn(mAvailableBounds).when(menuView).getAvailableBounds();
|
||||
menuView.setShapeType(/* halfOvalShape */ 1);
|
||||
|
||||
final boolean isActionPerformed =
|
||||
menuView.performAccessibilityAction(R.id.action_move_top_right, null);
|
||||
|
||||
assertThat(isActionPerformed).isTrue();
|
||||
assertThat(menuView.mShapeType).isEqualTo(/* ovalShape */ 0);
|
||||
verify(menuView).snapToLocation(mAvailableBounds.right, mAvailableBounds.top);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void accessibilityActionMove_moveBottomLeft_success() {
|
||||
public void accessibilityActionMove_halfOval_moveBottomLeft_success() {
|
||||
final AccessibilityFloatingMenuView menuView =
|
||||
spy(new AccessibilityFloatingMenuView(mContext));
|
||||
doReturn(mAvailableBounds).when(menuView).getAvailableBounds();
|
||||
menuView.setShapeType(/* halfOvalShape */ 1);
|
||||
|
||||
final boolean isActionPerformed =
|
||||
menuView.performAccessibilityAction(R.id.action_move_bottom_left, null);
|
||||
|
||||
assertThat(isActionPerformed).isTrue();
|
||||
assertThat(menuView.mShapeType).isEqualTo(/* ovalShape */ 0);
|
||||
verify(menuView).snapToLocation(mAvailableBounds.left, mAvailableBounds.bottom);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void accessibilityActionMove_moveBottomRight_success() {
|
||||
public void accessibilityActionMove_halfOval_moveBottomRight_success() {
|
||||
final AccessibilityFloatingMenuView menuView =
|
||||
spy(new AccessibilityFloatingMenuView(mContext));
|
||||
doReturn(mAvailableBounds).when(menuView).getAvailableBounds();
|
||||
menuView.setShapeType(/* halfOvalShape */ 1);
|
||||
|
||||
final boolean isActionPerformed =
|
||||
menuView.performAccessibilityAction(R.id.action_move_bottom_right, null);
|
||||
|
||||
assertThat(isActionPerformed).isTrue();
|
||||
assertThat(menuView.mShapeType).isEqualTo(/* ovalShape */ 0);
|
||||
verify(menuView).snapToLocation(mAvailableBounds.right, mAvailableBounds.bottom);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void accessibilityActionMove_halfOval_moveOutEdgeAndShow_success() {
|
||||
final AccessibilityFloatingMenuView menuView =
|
||||
spy(new AccessibilityFloatingMenuView(mContext));
|
||||
doReturn(mAvailableBounds).when(menuView).getAvailableBounds();
|
||||
menuView.setShapeType(/* halfOvalShape */ 1);
|
||||
|
||||
final boolean isActionPerformed =
|
||||
menuView.performAccessibilityAction(R.id.action_move_out_edge_and_show, null);
|
||||
|
||||
assertThat(isActionPerformed).isTrue();
|
||||
assertThat(menuView.mShapeType).isEqualTo(/* ovalShape */ 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setupAccessibilityActions_oval_hasActionMoveToEdgeAndHide() {
|
||||
final AccessibilityFloatingMenuView menuView = new AccessibilityFloatingMenuView(mContext);
|
||||
menuView.setShapeType(/* ovalShape */ 0);
|
||||
|
||||
final AccessibilityNodeInfo infos = new AccessibilityNodeInfo();
|
||||
menuView.onInitializeAccessibilityNodeInfo(infos);
|
||||
|
||||
assertThat(infos.getActionList().stream().anyMatch(
|
||||
action -> action.getId() == R.id.action_move_to_edge_and_hide)).isTrue();
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
mInterceptMotionEvent = null;
|
||||
|
||||
Reference in New Issue
Block a user