From 01e981fafb8b6fb2b02bc95d368ff2b208e47c71 Mon Sep 17 00:00:00 2001 From: Chilun Huang Date: Fri, 3 Feb 2023 18:49:47 +0800 Subject: Add strings to announce where the app splits to Add strings to announce whether the app is split to left/top or right/bottom. Bug: 265752180 Test: Manual drag the app icon and check the announcement Test: atest WMShellUnitTests Change-Id: I0a72fcd6e4784b7693c3b467b68ddd6c606786cc --- libs/WindowManager/Shell/res/values/strings.xml | 9 +++++++ .../android/wm/shell/draganddrop/DragLayout.java | 29 +++++++++++++++++++--- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/libs/WindowManager/Shell/res/values/strings.xml b/libs/WindowManager/Shell/res/values/strings.xml index 250dac6cbaee..adc65dd7f699 100644 --- a/libs/WindowManager/Shell/res/values/strings.xml +++ b/libs/WindowManager/Shell/res/values/strings.xml @@ -100,6 +100,15 @@ Bottom full screen + + Split left + + Split right + + Split top + + Split bottom + Using one-handed mode diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/draganddrop/DragLayout.java b/libs/WindowManager/Shell/src/com/android/wm/shell/draganddrop/DragLayout.java index 55378a826385..3ade1ed9392f 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/draganddrop/DragLayout.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/draganddrop/DragLayout.java @@ -22,6 +22,10 @@ import static android.view.ViewGroup.LayoutParams.MATCH_PARENT; import static com.android.wm.shell.common.split.SplitScreenConstants.SPLIT_POSITION_BOTTOM_OR_RIGHT; import static com.android.wm.shell.common.split.SplitScreenConstants.SPLIT_POSITION_TOP_OR_LEFT; +import static com.android.wm.shell.draganddrop.DragAndDropPolicy.Target.TYPE_SPLIT_BOTTOM; +import static com.android.wm.shell.draganddrop.DragAndDropPolicy.Target.TYPE_SPLIT_LEFT; +import static com.android.wm.shell.draganddrop.DragAndDropPolicy.Target.TYPE_SPLIT_RIGHT; +import static com.android.wm.shell.draganddrop.DragAndDropPolicy.Target.TYPE_SPLIT_TOP; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; @@ -315,6 +319,25 @@ public class DragLayout extends LinearLayout { // Switching between targets mDropZoneView1.animateSwitch(); mDropZoneView2.animateSwitch(); + // Announce for accessibility. + switch (target.type) { + case TYPE_SPLIT_LEFT: + mDropZoneView1.announceForAccessibility( + mContext.getString(R.string.accessibility_split_left)); + break; + case TYPE_SPLIT_RIGHT: + mDropZoneView2.announceForAccessibility( + mContext.getString(R.string.accessibility_split_right)); + break; + case TYPE_SPLIT_TOP: + mDropZoneView1.announceForAccessibility( + mContext.getString(R.string.accessibility_split_top)); + break; + case TYPE_SPLIT_BOTTOM: + mDropZoneView2.announceForAccessibility( + mContext.getString(R.string.accessibility_split_bottom)); + break; + } } mCurrentTarget = target; } @@ -424,12 +447,10 @@ public class DragLayout extends LinearLayout { } private void animateHighlight(DragAndDropPolicy.Target target) { - if (target.type == DragAndDropPolicy.Target.TYPE_SPLIT_LEFT - || target.type == DragAndDropPolicy.Target.TYPE_SPLIT_TOP) { + if (target.type == TYPE_SPLIT_LEFT || target.type == TYPE_SPLIT_TOP) { mDropZoneView1.setShowingHighlight(true); mDropZoneView2.setShowingHighlight(false); - } else if (target.type == DragAndDropPolicy.Target.TYPE_SPLIT_RIGHT - || target.type == DragAndDropPolicy.Target.TYPE_SPLIT_BOTTOM) { + } else if (target.type == TYPE_SPLIT_RIGHT || target.type == TYPE_SPLIT_BOTTOM) { mDropZoneView1.setShowingHighlight(false); mDropZoneView2.setShowingHighlight(true); } -- cgit v1.2.3-59-g8ed1b