Replace drag & drop constants with finalize ids

Bug: 197520937
Test: builds
Change-Id: I05ec8a7e119288e13e0c670e88323743238397c4
This commit is contained in:
sallyyuen
2021-11-22 17:05:42 -08:00
parent d21bfc7b40
commit 53e449951b
2 changed files with 30 additions and 32 deletions

View File

@@ -14248,34 +14248,34 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
hideTooltip();
return true;
}
}
if (action == 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);
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);
}
} 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;
case R.id.accessibilityActionDragCancel: {
if (!startedSystemDragForAccessibility()) {
return false;
}
if (mAttachInfo != null && mAttachInfo.mDragToken != null) {
cancelDragAndDrop();
return true;
}
return false;
}
return false;
}
return false;
}

View File

@@ -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";
}
}