summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorChris Tate <ctate@google.com>2010-10-21 14:46:18 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2010-10-21 14:46:18 -0700
commit1381cac20a9b09e7af0fa6723f1fd7ed60273062 (patch)
tree6838bc5668a641f55c3a8fbded6fc489aac98fb4 /core
parentc5152cad1dc0d37704ff7b4f7662c430aa1a765b (diff)
parentd4533f1469990582e4a2dd0898429093fe2690c0 (diff)
downloadframeworks_base-1381cac20a9b09e7af0fa6723f1fd7ed60273062.zip
frameworks_base-1381cac20a9b09e7af0fa6723f1fd7ed60273062.tar.gz
frameworks_base-1381cac20a9b09e7af0fa6723f1fd7ed60273062.tar.bz2
Merge "Report drag success/fail in the DRAG_ENDED message"
Diffstat (limited to 'core')
-rw-r--r--core/java/android/view/DragEvent.java23
-rw-r--r--core/java/android/view/IWindowSession.aidl7
-rw-r--r--core/java/android/view/ViewRoot.java12
3 files changed, 34 insertions, 8 deletions
diff --git a/core/java/android/view/DragEvent.java b/core/java/android/view/DragEvent.java
index ebf8505..bbac14c 100644
--- a/core/java/android/view/DragEvent.java
+++ b/core/java/android/view/DragEvent.java
@@ -29,6 +29,7 @@ public class DragEvent implements Parcelable {
float mX, mY;
ClipDescription mClipDescription;
ClipData mClipData;
+ boolean mDragResult;
private DragEvent mNext;
private RuntimeException mRecycledLocation;
@@ -53,25 +54,27 @@ public class DragEvent implements Parcelable {
private DragEvent() {
}
- private void init(int action, float x, float y, ClipDescription description, ClipData data) {
+ private void init(int action, float x, float y, ClipDescription description, ClipData data,
+ boolean result) {
mAction = action;
mX = x;
mY = y;
mClipDescription = description;
mClipData = data;
+ mDragResult = result;
}
static DragEvent obtain() {
- return DragEvent.obtain(0, 0f, 0f, null, null);
+ return DragEvent.obtain(0, 0f, 0f, null, null, false);
}
public static DragEvent obtain(int action, float x, float y,
- ClipDescription description, ClipData data) {
+ ClipDescription description, ClipData data, boolean result) {
final DragEvent ev;
synchronized (gRecyclerLock) {
if (gRecyclerTop == null) {
ev = new DragEvent();
- ev.init(action, x, y, description, data);
+ ev.init(action, x, y, description, data, result);
return ev;
}
ev = gRecyclerTop;
@@ -82,14 +85,14 @@ public class DragEvent implements Parcelable {
ev.mRecycled = false;
ev.mNext = null;
- ev.init(action, x, y, description, data);
+ ev.init(action, x, y, description, data, result);
return ev;
}
public static DragEvent obtain(DragEvent source) {
return obtain(source.mAction, source.mX, source.mY,
- source.mClipDescription, source.mClipData);
+ source.mClipDescription, source.mClipData, source.mDragResult);
}
public int getAction() {
@@ -112,6 +115,10 @@ public class DragEvent implements Parcelable {
return mClipDescription;
}
+ public boolean getResult() {
+ return mDragResult;
+ }
+
/**
* Recycle the DragEvent, to be re-used by a later caller. After calling
* this function you must never touch the event again.
@@ -146,7 +153,7 @@ public class DragEvent implements Parcelable {
public String toString() {
return "DragEvent{" + Integer.toHexString(System.identityHashCode(this))
+ " action=" + mAction + " @ (" + mX + ", " + mY + ") desc=" + mClipDescription
- + " data=" + mClipData
+ + " data=" + mClipData + " result=" + mDragResult
+ "}";
}
@@ -160,6 +167,7 @@ public class DragEvent implements Parcelable {
dest.writeInt(mAction);
dest.writeFloat(mX);
dest.writeFloat(mY);
+ dest.writeInt(mDragResult ? 1 : 0);
if (mClipData == null) {
dest.writeInt(0);
} else {
@@ -181,6 +189,7 @@ public class DragEvent implements Parcelable {
event.mAction = in.readInt();
event.mX = in.readFloat();
event.mY = in.readFloat();
+ event.mDragResult = (in.readInt() != 0);
if (in.readInt() != 0) {
event.mClipData = ClipData.CREATOR.createFromParcel(in);
}
diff --git a/core/java/android/view/IWindowSession.aidl b/core/java/android/view/IWindowSession.aidl
index 79ea5b6..23fae42 100644
--- a/core/java/android/view/IWindowSession.aidl
+++ b/core/java/android/view/IWindowSession.aidl
@@ -130,6 +130,13 @@ interface IWindowSession {
boolean performDrag(IWindow window, IBinder dragToken, float touchX, float touchY,
float thumbCenterX, float thumbCenterY, in ClipData data);
+ /**
+ * Report the result of a drop action targeted to the given window.
+ * consumed is 'true' when the drop was accepted by a valid recipient,
+ * 'false' otherwise.
+ */
+ void reportDropResult(IWindow window, boolean consumed);
+
/**
* Tell the OS that we've just dragged into a View that is willing to accept the drop
*/
diff --git a/core/java/android/view/ViewRoot.java b/core/java/android/view/ViewRoot.java
index ae671b8..ea688ad 100644
--- a/core/java/android/view/ViewRoot.java
+++ b/core/java/android/view/ViewRoot.java
@@ -2506,7 +2506,7 @@ public final class ViewRoot extends Handler implements ViewParent, View.AttachIn
final View prevDragView = mCurrentDragView;
// Now dispatch the drag/drop event
- mView.dispatchDragEvent(event);
+ boolean result = mView.dispatchDragEvent(event);
// If we changed apparent drag target, tell the OS about it
if (prevDragView != mCurrentDragView) {
@@ -2521,6 +2521,16 @@ public final class ViewRoot extends Handler implements ViewParent, View.AttachIn
Slog.e(TAG, "Unable to note drag target change");
}
}
+
+ // Report the drop result if necessary
+ if (what == DragEvent.ACTION_DROP) {
+ try {
+ Log.i(TAG, "Reporting drop result: " + result);
+ sWindowSession.reportDropResult(mWindow, result);
+ } catch (RemoteException e) {
+ Log.e(TAG, "Unable to report drop result");
+ }
+ }
}
}
event.recycle();