summaryrefslogtreecommitdiff
path: root/core/java/android
diff options
context:
space:
mode:
authorsallyyuen <sallyyuen@google.com>2021-11-22 17:05:42 -0800
committersallyyuen <sallyyuen@google.com>2022-01-06 16:36:15 -0800
commit53e449951bf6e752cedff1b2d0dde59b96df1492 (patch)
tree161a61b8e4b96cdb5da2e07d45d09ea0a5c8598c /core/java/android
parentd21bfc7b4003e440bc7e1422a792913a80dbf2a1 (diff)
Replace drag & drop constants with finalize ids
Bug: 197520937 Test: builds Change-Id: I05ec8a7e119288e13e0c670e88323743238397c4
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/view/View.java46
-rw-r--r--core/java/android/view/accessibility/AccessibilityNodeInfo.java14
2 files changed, 29 insertions, 31 deletions
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 258359e98264..02f372fcb19a 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -14248,34 +14248,34 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
hideTooltip();
return true;
}
- }
-
- if (action == R.id.accessibilityActionDragDrop) {
- if (!canAcceptAccessibilityDrop()) {
+ case R.id.accessibilityActionDragDrop: {
+ if (!canAcceptAccessibilityDrop()) {
+ return false;
+ }
+ try {
+ if (mAttachInfo != null && mAttachInfo.mSession != null) {
+ final int[] location = new int[2];
+ getLocationInWindow(location);
+ final int centerX = location[0] + getWidth() / 2;
+ final int centerY = location[1] + getHeight() / 2;
+ return mAttachInfo.mSession.dropForAccessibility(mAttachInfo.mWindow,
+ centerX, centerY);
+ }
+ } catch (RemoteException e) {
+ Log.e(VIEW_LOG_TAG, "Unable to drop for accessibility", e);
+ }
return false;
}
- try {
- if (mAttachInfo != null && mAttachInfo.mSession != null) {
- final int[] location = new int[2];
- getLocationInWindow(location);
- final int centerX = location[0] + getWidth() / 2;
- final int centerY = location[1] + getHeight() / 2;
- return mAttachInfo.mSession.dropForAccessibility(mAttachInfo.mWindow,
- centerX, centerY);
+ case R.id.accessibilityActionDragCancel: {
+ if (!startedSystemDragForAccessibility()) {
+ return false;
+ }
+ if (mAttachInfo != null && mAttachInfo.mDragToken != null) {
+ cancelDragAndDrop();
+ return true;
}
- } catch (RemoteException e) {
- Log.e(VIEW_LOG_TAG, "Unable to drop for accessibility", e);
- }
- return false;
- } else if (action == R.id.accessibilityActionDragCancel) {
- if (!startedSystemDragForAccessibility()) {
return false;
}
- if (mAttachInfo != null && mAttachInfo.mDragToken != null) {
- cancelDragAndDrop();
- return true;
- }
- return false;
}
return false;
}
diff --git a/core/java/android/view/accessibility/AccessibilityNodeInfo.java b/core/java/android/view/accessibility/AccessibilityNodeInfo.java
index db7c6634c8a7..0a33d6cd82ea 100644
--- a/core/java/android/view/accessibility/AccessibilityNodeInfo.java
+++ b/core/java/android/view/accessibility/AccessibilityNodeInfo.java
@@ -4321,15 +4321,13 @@ public class AccessibilityNodeInfo implements Parcelable {
return "ACTION_PRESS_AND_HOLD";
case R.id.accessibilityActionImeEnter:
return "ACTION_IME_ENTER";
+ case R.id.accessibilityActionDragStart:
+ return "ACTION_DRAG";
+ case R.id.accessibilityActionDragCancel:
+ return "ACTION_CANCEL_DRAG";
+ case R.id.accessibilityActionDragDrop:
+ return "ACTION_DROP";
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";
}
}