summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Vinit Nayak <peanutbutter@google.com> 2025-01-29 16:26:26 -0500
committer Vinit Nayak <peanutbutter@google.com> 2025-01-30 08:00:40 -0800
commit170cb01769b6da201980b4803de665492e47252c (patch)
treebdd8d21dc36a37f765c01778f93c2d3174503892
parentabcbc53ad362c63245f3520143062e340d94633c (diff)
Add divider swap for a11y voice access
Test: Manual, atest DividerViewTest Fixes: 379640352 Flag: EXEMPT bug fix Change-Id: I12d51c22322b9de20ff1567cf11c5581f6a7e277
-rw-r--r--libs/WindowManager/Shell/res/values/ids.xml1
-rw-r--r--libs/WindowManager/Shell/res/values/strings.xml2
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/common/split/DividerView.java9
-rw-r--r--libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/common/split/DividerViewTest.java13
4 files changed, 22 insertions, 3 deletions
diff --git a/libs/WindowManager/Shell/res/values/ids.xml b/libs/WindowManager/Shell/res/values/ids.xml
index debcba071d9c..fe3679c6ae73 100644
--- a/libs/WindowManager/Shell/res/values/ids.xml
+++ b/libs/WindowManager/Shell/res/values/ids.xml
@@ -25,6 +25,7 @@
<item type="id" name="action_move_tl_50" />
<item type="id" name="action_move_tl_30" />
<item type="id" name="action_move_rb_full" />
+ <item type="id" name="action_swap_apps" />
<!-- For saving PhysicsAnimationLayout animations/animators as view tags. -->
<item type="id" name="translation_x_dynamicanimation_tag"/>
diff --git a/libs/WindowManager/Shell/res/values/strings.xml b/libs/WindowManager/Shell/res/values/strings.xml
index 468c345259d0..f9f6e8252edb 100644
--- a/libs/WindowManager/Shell/res/values/strings.xml
+++ b/libs/WindowManager/Shell/res/values/strings.xml
@@ -90,6 +90,8 @@
<string name="accessibility_action_divider_left_30">Left 30%</string>
<!-- Accessibility action for moving docked stack divider to make the right screen full screen [CHAR LIMIT=NONE] -->
<string name="accessibility_action_divider_right_full">Right full screen</string>
+ <!-- Accessibility action for swapping the apps around the divider (double tap action) [CHAR LIMIT=NONE] -->
+ <string name="accessibility_action_divider_swap">Swap Apps</string>
<!-- Accessibility action for moving docked stack divider to make the top screen full screen [CHAR LIMIT=NONE] -->
<string name="accessibility_action_divider_top_full">Top full screen</string>
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/DividerView.java b/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/DividerView.java
index 2c418d34f09a..06044ccc1c61 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/DividerView.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/DividerView.java
@@ -125,11 +125,13 @@ public class DividerView extends FrameLayout implements View.OnTouchListener {
}
};
- private final AccessibilityDelegate mHandleDelegate = new AccessibilityDelegate() {
+ final AccessibilityDelegate mHandleDelegate = new AccessibilityDelegate() {
@Override
public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfo info) {
super.onInitializeAccessibilityNodeInfo(host, info);
final DividerSnapAlgorithm snapAlgorithm = mSplitLayout.mDividerSnapAlgorithm;
+ info.addAction(new AccessibilityAction(R.id.action_swap_apps,
+ mContext.getString(R.string.accessibility_action_divider_swap)));
if (mSplitLayout.isLeftRightSplit()) {
info.addAction(new AccessibilityAction(R.id.action_move_tl_full,
mContext.getString(R.string.accessibility_action_divider_left_full)));
@@ -172,6 +174,11 @@ public class DividerView extends FrameLayout implements View.OnTouchListener {
@Override
public boolean performAccessibilityAction(@NonNull View host, int action,
@Nullable Bundle args) {
+ if (action == R.id.action_swap_apps) {
+ mSplitLayout.onDoubleTappedDivider();
+ return true;
+ }
+
DividerSnapAlgorithm.SnapTarget nextTarget = null;
DividerSnapAlgorithm snapAlgorithm = mSplitLayout.mDividerSnapAlgorithm;
if (action == R.id.action_move_tl_full) {
diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/common/split/DividerViewTest.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/common/split/DividerViewTest.java
index fd3d3b5b6e2f..8c34c1946702 100644
--- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/common/split/DividerViewTest.java
+++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/common/split/DividerViewTest.java
@@ -36,6 +36,7 @@ import androidx.test.annotation.UiThreadTest;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
+import com.android.wm.shell.R;
import com.android.wm.shell.ShellTaskOrganizer;
import com.android.wm.shell.ShellTestCase;
import com.android.wm.shell.common.DisplayController;
@@ -66,9 +67,9 @@ public class DividerViewTest extends ShellTestCase {
public void setup() {
MockitoAnnotations.initMocks(this);
Configuration configuration = getConfiguration();
- mSplitLayout = new SplitLayout("TestSplitLayout", mContext, configuration,
+ mSplitLayout = spy(new SplitLayout("TestSplitLayout", mContext, configuration,
mSplitLayoutHandler, mCallbacks, mDisplayController, mDisplayImeController,
- mTaskOrganizer, SplitLayout.PARALLAX_NONE, mSplitState, mHandler);
+ mTaskOrganizer, SplitLayout.PARALLAX_NONE, mSplitState, mHandler));
SplitWindowManager splitWindowManager = new SplitWindowManager("TestSplitWindowManager",
mContext,
configuration, mCallbacks);
@@ -98,6 +99,14 @@ public class DividerViewTest extends ShellTestCase {
"false", false);
}
+ @Test
+ public void swapDividerActionForA11y() {
+ mDividerView.setAccessibilityDelegate(mDividerView.mHandleDelegate);
+ mDividerView.getAccessibilityDelegate().performAccessibilityAction(mDividerView,
+ R.id.action_swap_apps, null);
+ verify(mSplitLayout, times(1)).onDoubleTappedDivider();
+ }
+
private static MotionEvent getMotionEvent(long eventTime, int action, float x, float y) {
MotionEvent.PointerProperties properties = new MotionEvent.PointerProperties();
properties.id = 0;