summaryrefslogtreecommitdiff
path: root/core/java/android
diff options
context:
space:
mode:
authorSally Yuen <sallyyuen@google.com>2021-08-24 12:45:20 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2021-08-24 12:45:20 +0000
commit46f761720fb900e7d39f02230801d2d344d916d3 (patch)
tree8ea335230bc0fbf17466b1678f54d2652112fdf4 /core/java/android
parent709173fe4ddbd355d9b66c7670eb9380ace991db (diff)
parentff67d5e3e8269de11f53f58743f98c3da2b1277a (diff)
Merge "Add AccessibilityAction and AccessibilityEvent API for drag & drop" into sc-v2-dev am: 0e08f81393 am: ff67d5e3e8
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15585174 Change-Id: I2d9c7f71da5f3ce98d0795d77fed248999d3bc5b
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/view/accessibility/AccessibilityEvent.java30
-rw-r--r--core/java/android/view/accessibility/AccessibilityNodeInfo.java49
2 files changed, 79 insertions, 0 deletions
diff --git a/core/java/android/view/accessibility/AccessibilityEvent.java b/core/java/android/view/accessibility/AccessibilityEvent.java
index 40da86a2ee43..ff6f8ac389ea 100644
--- a/core/java/android/view/accessibility/AccessibilityEvent.java
+++ b/core/java/android/view/accessibility/AccessibilityEvent.java
@@ -613,6 +613,36 @@ public final class AccessibilityEvent extends AccessibilityRecord implements Par
public static final int CONTENT_CHANGE_TYPE_STATE_DESCRIPTION = 0x00000040;
/**
+ * Change type for {@link #TYPE_WINDOW_CONTENT_CHANGED} event:
+ * A drag has started while accessibility is enabled. This is either via an
+ * AccessibilityAction, or via touch events. This is sent from the source that initiated the
+ * drag.
+ *
+ * @see AccessibilityNodeInfo.AccessibilityAction#ACTION_DRAG_START
+ */
+ public static final int CONTENT_CHANGE_TYPE_DRAG_STARTED = 0x00000080;
+
+ /**
+ * Change type for {@link #TYPE_WINDOW_CONTENT_CHANGED} event:
+ * A drag in with accessibility enabled has ended. This means the content has been
+ * successfully dropped. This is sent from the target that accepted the dragged content.
+ *
+ * @see AccessibilityNodeInfo.AccessibilityAction#ACTION_DRAG_DROP
+ */
+ public static final int CONTENT_CHANGE_TYPE_DRAG_DROPPED = 0x00000100;
+
+ /**
+ * Change type for {@link #TYPE_WINDOW_CONTENT_CHANGED} event:
+ * A drag in with accessibility enabled has ended. This means the content has been
+ * unsuccessfully dropped, the user has canceled the action via an AccessibilityAction, or
+ * no drop has been detected within a timeout and the drag was automatically cancelled. This is
+ * sent from the source that initiated the drag.
+ *
+ * @see AccessibilityNodeInfo.AccessibilityAction#ACTION_DRAG_CANCEL
+ */
+ public static final int CONTENT_CHANGE_TYPE_DRAG_CANCELLED = 0x0000200;
+
+ /**
* Change type for {@link #TYPE_WINDOWS_CHANGED} event:
* The window was added.
*/
diff --git a/core/java/android/view/accessibility/AccessibilityNodeInfo.java b/core/java/android/view/accessibility/AccessibilityNodeInfo.java
index 085eb81182f1..587a27074544 100644
--- a/core/java/android/view/accessibility/AccessibilityNodeInfo.java
+++ b/core/java/android/view/accessibility/AccessibilityNodeInfo.java
@@ -27,6 +27,7 @@ import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.TestApi;
import android.compat.annotation.UnsupportedAppUsage;
+import android.content.ClipData;
import android.graphics.Rect;
import android.graphics.Region;
import android.os.Build;
@@ -4353,6 +4354,14 @@ public class AccessibilityNodeInfo implements Parcelable {
case R.id.accessibilityActionImeEnter:
return "ACTION_IME_ENTER";
default:
+ // TODO(197520937): Use finalized constants in switch
+ if (action == R.id.accessibilityActionDragStart) {
+ return "ACTION_DRAG";
+ } else if (action == R.id.accessibilityActionDragCancel) {
+ return "ACTION_CANCEL_DRAG";
+ } else if (action == R.id.accessibilityActionDragDrop) {
+ return "ACTION_DROP";
+ }
return "ACTION_UNKNOWN";
}
}
@@ -4995,6 +5004,46 @@ public class AccessibilityNodeInfo implements Parcelable {
@NonNull public static final AccessibilityAction ACTION_IME_ENTER =
new AccessibilityAction(R.id.accessibilityActionImeEnter);
+ /**
+ * Action to start a drag.
+ * <p>
+ * This action initiates a drag & drop within the system. The source's dragged content is
+ * prepared before the drag begins. In View, this action should prepare the arguments to
+ * {@link View#startDragAndDrop(ClipData, View.DragShadowBuilder, Object, int)} and then
+ * call {@link View#startDragAndDrop(ClipData, View.DragShadowBuilder, Object, int)}. The
+ * equivalent should be performed for other UI toolkits.
+ * </p>
+ *
+ * @see AccessibilityEvent#CONTENT_CHANGE_TYPE_DRAG_STARTED
+ */
+ @NonNull public static final AccessibilityAction ACTION_DRAG_START =
+ new AccessibilityAction(R.id.accessibilityActionDragStart);
+
+ /**
+ * Action to trigger a drop of the content being dragged.
+ * <p>
+ * This action is added to potential drop targets if the source started a drag with
+ * {@link #ACTION_DRAG_START}. In View, these targets are Views that accepted
+ * {@link android.view.DragEvent#ACTION_DRAG_STARTED} and have an
+ * {@link View.OnDragListener}.
+ * </p>
+ *
+ * @see AccessibilityEvent#CONTENT_CHANGE_TYPE_DRAG_DROPPED
+ */
+ @NonNull public static final AccessibilityAction ACTION_DRAG_DROP =
+ new AccessibilityAction(R.id.accessibilityActionDragDrop);
+
+ /**
+ * Action to cancel a drag.
+ * <p>
+ * This action is added to the source that started a drag with {@link #ACTION_DRAG_START}.
+ * </p>
+ *
+ * @see AccessibilityEvent#CONTENT_CHANGE_TYPE_DRAG_CANCELLED
+ */
+ @NonNull public static final AccessibilityAction ACTION_DRAG_CANCEL =
+ new AccessibilityAction(R.id.accessibilityActionDragCancel);
+
private final int mActionId;
private final CharSequence mLabel;