summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2012-04-13 17:32:18 -0700
committerDianne Hackborn <hackbod@google.com>2012-04-16 18:10:37 -0700
commitac4243f177efb66f15df2f818418eac2b7abcec7 (patch)
tree6623cd9370485b86fc8225822c45a04e800701e2
parentac76e72272c957dc7609aa68224efa2d32c23cd0 (diff)
downloadframeworks_base-ac4243f177efb66f15df2f818418eac2b7abcec7.zip
frameworks_base-ac4243f177efb66f15df2f818418eac2b7abcec7.tar.gz
frameworks_base-ac4243f177efb66f15df2f818418eac2b7abcec7.tar.bz2
Make ACTION_SEND and ACTION_SEND_MULTIPLE build full clip items.
The current code was just for transferring URI grants. This change makes it so it propagates all of the relevant extra data into the ClipData, so developers can just retrieve the ClipData for all of their data needs. Change-Id: I36a050c7beae325aceb84518337f878c337d8b86
-rw-r--r--core/java/android/content/Intent.java53
1 files changed, 40 insertions, 13 deletions
diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java
index 19e4372..6653336 100644
--- a/core/java/android/content/Intent.java
+++ b/core/java/android/content/Intent.java
@@ -6576,35 +6576,54 @@ public class Intent implements Parcelable, Cloneable {
final String action = getAction();
if (ACTION_SEND.equals(action)) {
- final Uri stream;
+ Uri stream = null;
try {
stream = getParcelableExtra(EXTRA_STREAM);
} catch (ClassCastException e) {
- return;
}
- if (stream != null) {
+ final CharSequence text = getCharSequenceExtra(EXTRA_TEXT);
+ final String htmlText = getStringExtra(EXTRA_HTML_TEXT);
+ if (stream != null || text != null || htmlText != null) {
final ClipData clipData = new ClipData(
- null, new String[] { getType() }, new ClipData.Item(stream));
-
+ null, new String[] { getType() },
+ new ClipData.Item(text, htmlText, null, stream));
setClipData(clipData);
addFlags(FLAG_GRANT_READ_URI_PERMISSION);
}
} else if (ACTION_SEND_MULTIPLE.equals(action)) {
- final ArrayList<Uri> streams;
+ ArrayList<Uri> streams = null;
try {
streams = getParcelableArrayListExtra(EXTRA_STREAM);
} catch (ClassCastException e) {
- return;
}
- if (streams != null && streams.size() > 0) {
- final Uri firstStream = streams.get(0);
+ final ArrayList<CharSequence> texts = getCharSequenceArrayListExtra(EXTRA_TEXT);
+ final ArrayList<String> htmlTexts = getStringArrayListExtra(EXTRA_HTML_TEXT);
+ int num = -1;
+ if (streams != null) {
+ num = streams.size();
+ }
+ if (texts != null) {
+ if (num >= 0 && num != texts.size()) {
+ // Wha...! F- you.
+ return;
+ }
+ num = texts.size();
+ }
+ if (htmlTexts != null) {
+ if (num >= 0 && num != htmlTexts.size()) {
+ // Wha...! F- you.
+ return;
+ }
+ num = htmlTexts.size();
+ }
+ if (num > 0) {
final ClipData clipData = new ClipData(
- null, new String[] { getType() }, new ClipData.Item(firstStream));
+ null, new String[] { getType() },
+ makeClipItem(streams, texts, htmlTexts, 0));
- final int size = streams.size();
- for (int i = 1; i < size; i++) {
- clipData.addItem(new ClipData.Item(streams.get(i)));
+ for (int i = 1; i < num; i++) {
+ clipData.addItem(makeClipItem(streams, texts, htmlTexts, i));
}
setClipData(clipData);
@@ -6612,4 +6631,12 @@ public class Intent implements Parcelable, Cloneable {
}
}
}
+
+ private static ClipData.Item makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts,
+ ArrayList<String> htmlTexts, int which) {
+ Uri uri = streams != null ? streams.get(which) : null;
+ CharSequence text = texts != null ? texts.get(which) : null;
+ String htmlText = htmlTexts != null ? htmlTexts.get(which) : null;
+ return new ClipData.Item(text, htmlText, null, uri);
+ }
}