summaryrefslogtreecommitdiff
path: root/core/java/android/view/DragEvent.java
diff options
context:
space:
mode:
authorVladislav Kaznacheev <kaznacheev@google.com>2015-07-15 18:04:04 -0700
committerVladislav Kaznacheev <kaznacheev@google.com>2015-09-16 17:35:10 -0700
commitede5f5480e58dac9f6ddbd36a3085592d79c98ef (patch)
treefa0012988e2144b04742c90706cca39546b679ff /core/java/android/view/DragEvent.java
parent4dc0c15a6ac0564b2e7d9d8b957795a373d05907 (diff)
Handle content URI permissions on drop
Change-Id: I846071f01ecd1eff8e3a54a1806e68e1a4b335d2
Diffstat (limited to 'core/java/android/view/DragEvent.java')
-rw-r--r--core/java/android/view/DragEvent.java37
1 files changed, 31 insertions, 6 deletions
diff --git a/core/java/android/view/DragEvent.java b/core/java/android/view/DragEvent.java
index f559e21f661e..34835f4a8070 100644
--- a/core/java/android/view/DragEvent.java
+++ b/core/java/android/view/DragEvent.java
@@ -128,6 +128,8 @@ public class DragEvent implements Parcelable {
float mX, mY;
ClipDescription mClipDescription;
ClipData mClipData;
+ DropPermissionHolder mDropPermissionHolder;
+
Object mLocalState;
boolean mDragResult;
@@ -253,28 +255,30 @@ public class DragEvent implements Parcelable {
}
private void init(int action, float x, float y, ClipDescription description, ClipData data,
- Object localState, boolean result) {
+ DropPermissionHolder dropPermissionHolder, Object localState, boolean result) {
mAction = action;
mX = x;
mY = y;
mClipDescription = description;
mClipData = data;
+ mDropPermissionHolder = dropPermissionHolder;
mLocalState = localState;
mDragResult = result;
}
static DragEvent obtain() {
- return DragEvent.obtain(0, 0f, 0f, null, null, null, false);
+ return DragEvent.obtain(0, 0f, 0f, null, null, null, null, false);
}
/** @hide */
public static DragEvent obtain(int action, float x, float y, Object localState,
- ClipDescription description, ClipData data, boolean result) {
+ ClipDescription description, ClipData data, DropPermissionHolder dropPermissionHolder,
+ boolean result) {
final DragEvent ev;
synchronized (gRecyclerLock) {
if (gRecyclerTop == null) {
ev = new DragEvent();
- ev.init(action, x, y, description, data, localState, result);
+ ev.init(action, x, y, description, data, dropPermissionHolder, localState, result);
return ev;
}
ev = gRecyclerTop;
@@ -285,7 +289,7 @@ public class DragEvent implements Parcelable {
ev.mRecycled = false;
ev.mNext = null;
- ev.init(action, x, y, description, data, localState, result);
+ ev.init(action, x, y, description, data, dropPermissionHolder, localState, result);
return ev;
}
@@ -293,7 +297,8 @@ public class DragEvent implements Parcelable {
/** @hide */
public static DragEvent obtain(DragEvent source) {
return obtain(source.mAction, source.mX, source.mY, source.mLocalState,
- source.mClipDescription, source.mClipData, source.mDragResult);
+ source.mClipDescription, source.mClipData, source.mDropPermissionHolder,
+ source.mDragResult);
}
/**
@@ -358,6 +363,17 @@ public class DragEvent implements Parcelable {
}
/**
+ * Returns the {@link android.view.DropPermissionHolder} object that can be used by the drag
+ * listener to request and release the permissions for the content URIs contained in the
+ * {@link android.content.ClipData} object associated with this event.
+ * This method only returns valid data if the event action is {@link #ACTION_DROP}.
+ * @return The DropPermissionHolder object used to handle content URI permissions.
+ */
+ public DropPermissionHolder getDropPermissionHolder() {
+ return mDropPermissionHolder;
+ }
+
+ /**
* Returns the local state object sent to the system as part of the call to
* {@link android.view.View#startDrag(ClipData,View.DragShadowBuilder,Object,int) startDrag()}.
* The object is intended to provide local information about the drag and drop operation. For
@@ -477,6 +493,12 @@ public class DragEvent implements Parcelable {
dest.writeInt(1);
mClipDescription.writeToParcel(dest, flags);
}
+ if (mDropPermissionHolder == null) {
+ dest.writeInt(0);
+ } else {
+ dest.writeInt(1);
+ mDropPermissionHolder.writeToParcel(dest, flags);
+ }
}
/**
@@ -496,6 +518,9 @@ public class DragEvent implements Parcelable {
if (in.readInt() != 0) {
event.mClipDescription = ClipDescription.CREATOR.createFromParcel(in);
}
+ if (in.readInt() != 0) {
+ event.mDropPermissionHolder = DropPermissionHolder.CREATOR.createFromParcel(in);
+ }
return event;
}