Merge "Add a flag to cancelDragAndDrop to skip animation" into qt-dev

This commit is contained in:
TreeHugger Robot
2019-04-19 05:40:41 +00:00
committed by Android (Google) Code Review
6 changed files with 13 additions and 10 deletions

View File

@@ -187,8 +187,10 @@ interface IWindowSession {
/**
* Cancel the current drag operation.
* skipAnimation is 'true' when it should skip the drag cancel animation which brings the drag
* shadow image back to the drag start position.
*/
void cancelDragAndDrop(IBinder dragToken);
void cancelDragAndDrop(IBinder dragToken, boolean skipAnimation);
/**
* Tell the OS that we've just dragged into a View that is willing to accept the drop

View File

@@ -25456,7 +25456,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
}
if (mAttachInfo.mDragToken != null) {
try {
mAttachInfo.mSession.cancelDragAndDrop(mAttachInfo.mDragToken);
mAttachInfo.mSession.cancelDragAndDrop(mAttachInfo.mDragToken, false);
} catch (Exception e) {
Log.e(VIEW_LOG_TAG, "Unable to cancel drag", e);
}

View File

@@ -236,7 +236,7 @@ class DragDropController {
}
}
void cancelDragAndDrop(IBinder dragToken) {
void cancelDragAndDrop(IBinder dragToken, boolean skipAnimation) {
if (DEBUG_DRAG) {
Slog.d(TAG_WM, "cancelDragAndDrop");
}
@@ -257,7 +257,7 @@ class DragDropController {
}
mDragState.mDragResult = false;
mDragState.cancelDragLocked();
mDragState.cancelDragLocked(skipAnimation);
}
} finally {
mCallback.get().postCancelDragAndDrop();

View File

@@ -475,15 +475,16 @@ class DragState {
closeLocked();
}
void cancelDragLocked() {
void cancelDragLocked(boolean skipAnimation) {
if (mAnimator != null) {
return;
}
if (!mDragInProgress) {
// This can happen if an app invokes Session#cancelDragAndDrop before
if (!mDragInProgress || skipAnimation) {
// mDragInProgress is false if an app invokes Session#cancelDragAndDrop before
// Session#performDrag. Reset the drag state without playing the cancel animation
// because H.DRAG_START_TIMEOUT may be sent to WindowManagerService, which will cause
// DragState#reset() while playing the cancel animation.
// skipAnimation is true when a caller requests to skip the drag cancel animation.
closeLocked();
return;
}

View File

@@ -283,10 +283,10 @@ class Session extends IWindowSession.Stub implements IBinder.DeathRecipient {
}
@Override
public void cancelDragAndDrop(IBinder dragToken) {
public void cancelDragAndDrop(IBinder dragToken, boolean skipAnimation) {
final long ident = Binder.clearCallingIdentity();
try {
mDragDropController.cancelDragAndDrop(dragToken);
mDragDropController.cancelDragAndDrop(dragToken, skipAnimation);
} finally {
Binder.restoreCallingIdentity(ident);
}

View File

@@ -137,7 +137,7 @@ public class DragDropControllerTests extends WindowTestsBase {
return;
}
if (mToken != null) {
mTarget.cancelDragAndDrop(mToken);
mTarget.cancelDragAndDrop(mToken, false);
}
latch = new CountDownLatch(1);
mTarget.setOnClosedCallbackLocked(latch::countDown);