Merge "ClipDescription no longer inherits from ClipData."
diff --git a/api/current.xml b/api/current.xml
index 715b49a..bac65eb 100644
--- a/api/current.xml
+++ b/api/current.xml
@@ -40322,13 +40322,15 @@
</method>
</class>
<class name="ClipData"
- extends="android.content.ClipDescription"
+ extends="java.lang.Object"
abstract="false"
static="false"
final="false"
deprecated="not deprecated"
visibility="public"
>
+<implements name="android.os.Parcelable">
+</implements>
<constructor name="ClipData"
type="android.content.ClipData"
static="false"
@@ -40345,6 +40347,20 @@
<parameter name="item" type="android.content.ClipData.Item">
</parameter>
</constructor>
+<constructor name="ClipData"
+ type="android.content.ClipData"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="description" type="android.content.ClipDescription">
+</parameter>
+<parameter name="icon" type="android.graphics.Bitmap">
+</parameter>
+<parameter name="item" type="android.content.ClipData.Item">
+</parameter>
+</constructor>
<method name="addItem"
return="void"
abstract="false"
@@ -40358,6 +40374,28 @@
<parameter name="item" type="android.content.ClipData.Item">
</parameter>
</method>
+<method name="describeContents"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getDescription"
+ return="android.content.ClipDescription"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
<method name="getIcon"
return="android.graphics.Bitmap"
abstract="false"
@@ -40463,6 +40501,21 @@
<parameter name="uri" type="android.net.Uri">
</parameter>
</method>
+<method name="writeToParcel"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="dest" type="android.os.Parcel">
+</parameter>
+<parameter name="flags" type="int">
+</parameter>
+</method>
<field name="CREATOR"
type="android.os.Parcelable.Creator"
transient="false"
diff --git a/core/java/android/content/ClipData.java b/core/java/android/content/ClipData.java
index a19b132..6f4d098 100644
--- a/core/java/android/content/ClipData.java
+++ b/core/java/android/content/ClipData.java
@@ -37,8 +37,9 @@
* each of which can hold one or more representations of an item of data.
* For display to the user, it also has a label and iconic representation.</p>
*
- * <p>A ClipData is a sub-class of {@link ClipDescription}, which describes
- * important meta-data about the clip. In particular, its {@link #getMimeType(int)}
+ * <p>A ClipData contains a {@link ClipDescription}, which describes
+ * important meta-data about the clip. In particular, its
+ * {@link ClipDescription#getMimeType(int) getDescription().getMimeType(int)}
* must return correct MIME type(s) describing the data in the clip. For help
* in correctly constructing a clip with the correct MIME type, use
* {@link #newPlainText(CharSequence, Bitmap, CharSequence)},
@@ -62,8 +63,8 @@
* <p>If all you want is the textual representation of the clipped data, you
* can use the convenience method {@link Item#coerceToText Item.coerceToText}.
* In this case there is generally no need to worry about the MIME types
- * reported by {@link #getMimeType(int)}, since any clip item an always be
- * converted to a string.
+ * reported by {@link ClipDescription#getMimeType(int) getDescription().getMimeType(int)},
+ * since any clip item an always be converted to a string.
*
* <p>More complicated exchanges will be done through URIs, in particular
* "content:" URIs. A content URI allows the recipient of a ClippedData item
@@ -133,11 +134,16 @@
* into an editor), then {@link Item#coerceToText(Context)} will ask the content
* provider for the clip URI as text and successfully paste the entire note.
*/
-public class ClipData extends ClipDescription {
- static final String[] MIMETYPES_TEXT_PLAIN = new String[] { MIMETYPE_TEXT_PLAIN };
- static final String[] MIMETYPES_TEXT_URILIST = new String[] { MIMETYPE_TEXT_URILIST };
- static final String[] MIMETYPES_TEXT_INTENT = new String[] { MIMETYPE_TEXT_INTENT };
+public class ClipData implements Parcelable {
+ static final String[] MIMETYPES_TEXT_PLAIN = new String[] {
+ ClipDescription.MIMETYPE_TEXT_PLAIN };
+ static final String[] MIMETYPES_TEXT_URILIST = new String[] {
+ ClipDescription.MIMETYPE_TEXT_URILIST };
+ static final String[] MIMETYPES_TEXT_INTENT = new String[] {
+ ClipDescription.MIMETYPE_TEXT_INTENT };
+ final ClipDescription mClipDescription;
+
final Bitmap mIcon;
final ArrayList<Item> mItems = new ArrayList<Item>();
@@ -320,7 +326,7 @@
* @param item The contents of the first item in the clip.
*/
public ClipData(CharSequence label, String[] mimeTypes, Bitmap icon, Item item) {
- super(label, mimeTypes);
+ mClipDescription = new ClipDescription(label, mimeTypes);
if (item == null) {
throw new NullPointerException("item is null");
}
@@ -329,7 +335,25 @@
}
/**
- * Create a new ClipData holding data of the type {@link #MIMETYPE_TEXT_PLAIN}.
+ * Create a new clip.
+ *
+ * @param description The ClipDescription describing the clip contents.
+ * @param icon Bitmap providing the user with an iconing representation of
+ * the clip.
+ * @param item The contents of the first item in the clip.
+ */
+ public ClipData(ClipDescription description, Bitmap icon, Item item) {
+ mClipDescription = description;
+ if (item == null) {
+ throw new NullPointerException("item is null");
+ }
+ mIcon = icon;
+ mItems.add(item);
+ }
+
+ /**
+ * Create a new ClipData holding data of the type
+ * {@link ClipDescription#MIMETYPE_TEXT_PLAIN}.
*
* @param label User-visible label for the clip data.
* @param icon Iconic representation of the clip data.
@@ -342,7 +366,8 @@
}
/**
- * Create a new ClipData holding an Intent with MIME type {@link #MIMETYPE_TEXT_INTENT}.
+ * Create a new ClipData holding an Intent with MIME type
+ * {@link ClipDescription#MIMETYPE_TEXT_INTENT}.
*
* @param label User-visible label for the clip data.
* @param icon Iconic representation of the clip data.
@@ -358,7 +383,7 @@
* Create a new ClipData holding a URI. If the URI is a content: URI,
* this will query the content provider for the MIME type of its data and
* use that as the MIME type. Otherwise, it will use the MIME type
- * {@link #MIMETYPE_TEXT_URILIST}.
+ * {@link ClipDescription#MIMETYPE_TEXT_URILIST}.
*
* @param resolver ContentResolver used to get information about the URI.
* @param label User-visible label for the clip data.
@@ -375,7 +400,7 @@
mimeTypes = resolver.getStreamTypes(uri, "*/*");
if (mimeTypes == null) {
if (realType != null) {
- mimeTypes = new String[] { realType, MIMETYPE_TEXT_URILIST };
+ mimeTypes = new String[] { realType, ClipDescription.MIMETYPE_TEXT_URILIST };
}
} else {
String[] tmp = new String[mimeTypes.length + (realType != null ? 2 : 1)];
@@ -385,7 +410,7 @@
i++;
}
System.arraycopy(mimeTypes, 0, tmp, i, mimeTypes.length);
- tmp[i + mimeTypes.length] = MIMETYPE_TEXT_URILIST;
+ tmp[i + mimeTypes.length] = ClipDescription.MIMETYPE_TEXT_URILIST;
mimeTypes = tmp;
}
}
@@ -396,7 +421,8 @@
}
/**
- * Create a new ClipData holding an URI with MIME type {@link #MIMETYPE_TEXT_URILIST}.
+ * Create a new ClipData holding an URI with MIME type
+ * {@link ClipDescription#MIMETYPE_TEXT_URILIST}.
* Unlike {@link #newUri(ContentResolver, CharSequence, Bitmap, Uri)}, nothing
* is inferred about the URI -- if it is a content: URI holding a bitmap,
* the reported type will still be uri-list. Use this with care!
@@ -411,6 +437,14 @@
return new ClipData(label, MIMETYPES_TEXT_URILIST, icon, item);
}
+ /**
+ * Return the {@link ClipDescription} associated with this data, describing
+ * what it contains.
+ */
+ public ClipDescription getDescription() {
+ return mClipDescription;
+ }
+
public void addItem(Item item) {
if (item == null) {
throw new NullPointerException("item is null");
@@ -437,7 +471,7 @@
@Override
public void writeToParcel(Parcel dest, int flags) {
- super.writeToParcel(dest, flags);
+ mClipDescription.writeToParcel(dest, flags);
if (mIcon != null) {
dest.writeInt(1);
mIcon.writeToParcel(dest, flags);
@@ -465,7 +499,7 @@
}
ClipData(Parcel in) {
- super(in);
+ mClipDescription = new ClipDescription(in);
if (in.readInt() != 0) {
mIcon = Bitmap.CREATOR.createFromParcel(in);
} else {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/ShirtPocket.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/ShirtPocket.java
index 10b52f2..7ee3c19 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/ShirtPocket.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/ShirtPocket.java
@@ -116,7 +116,7 @@
mClipping = clipping;
if (mClipping != null) {
Bitmap icon = mClipping.getIcon();
- mDescription.setText(mClipping.getLabel());
+ mDescription.setText(mClipping.getDescription().getLabel());
if (icon != null) {
mPreviewIcon.setImageBitmap(icon);
mPreviewIcon.setVisibility(View.VISIBLE);
diff --git a/services/java/com/android/server/ClipboardService.java b/services/java/com/android/server/ClipboardService.java
index bdf313c..30ea48c 100644
--- a/services/java/com/android/server/ClipboardService.java
+++ b/services/java/com/android/server/ClipboardService.java
@@ -115,7 +115,7 @@
public ClipDescription getPrimaryClipDescription() {
synchronized (this) {
- return new ClipDescription(mPrimaryClip);
+ return mPrimaryClip.getDescription();
}
}
diff --git a/services/java/com/android/server/WindowManagerService.java b/services/java/com/android/server/WindowManagerService.java
index 9bc24d2..c29e4a9 100644
--- a/services/java/com/android/server/WindowManagerService.java
+++ b/services/java/com/android/server/WindowManagerService.java
@@ -569,7 +569,7 @@
void broadcastDragStartedLw(final float touchX, final float touchY) {
// Cache a base-class instance of the clip metadata so that parceling
// works correctly in calling out to the apps.
- mDataDescription = new ClipDescription(mData);
+ mDataDescription = mData.getDescription();
mNotifiedWindows.clear();
mDragInProgress = true;