Email: BUG 1964940 Support multiple share from Gallery in Email

This commit is contained in:
Mihai Preda 2009-09-01 16:25:30 +02:00
parent 1b59056661
commit fa2238ca40
2 changed files with 31 additions and 3 deletions

View File

@ -158,6 +158,11 @@
<data android:mimeType="video/*" /> <data android:mimeType="video/*" />
<category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.DEFAULT" />
</intent-filter> </intent-filter>
<intent-filter android:label="@string/app_name">
<action android:name="android.intent.action.SEND_MULTIPLE" />
<data android:mimeType="*/*" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity> </activity>
<receiver android:name="com.android.exchange.EmailSyncAlarmReceiver"/> <receiver android:name="com.android.exchange.EmailSyncAlarmReceiver"/>
<receiver android:name="com.android.exchange.MailboxAlarmReceiver"/> <receiver android:name="com.android.exchange.MailboxAlarmReceiver"/>

View File

@ -72,6 +72,7 @@ import android.widget.Toast;
import java.io.Serializable; import java.io.Serializable;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.net.URLDecoder; import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -105,6 +106,11 @@ public class MessageCompose extends Activity implements OnClickListener, OnFocus
private static final Pattern PATTERN_START_OF_LINE = Pattern.compile("(?m)^"); private static final Pattern PATTERN_START_OF_LINE = Pattern.compile("(?m)^");
private static final Pattern PATTERN_ENDLINE_CRLF = Pattern.compile("\r\n"); private static final Pattern PATTERN_ENDLINE_CRLF = Pattern.compile("\r\n");
private static final String[] ATTACHMENT_META_COLUMNS = {
OpenableColumns.DISPLAY_NAME,
OpenableColumns.SIZE
};
private Account mAccount; private Account mAccount;
// mDraft is null until the first save, afterwards it contains the last saved version. // mDraft is null until the first save, afterwards it contains the last saved version.
@ -258,7 +264,8 @@ public class MessageCompose extends Activity implements OnClickListener, OnFocus
// Handle the various intents that launch the message composer // Handle the various intents that launch the message composer
if (Intent.ACTION_VIEW.equals(action) if (Intent.ACTION_VIEW.equals(action)
|| Intent.ACTION_SENDTO.equals(action) || Intent.ACTION_SENDTO.equals(action)
|| Intent.ACTION_SEND.equals(action)) { || Intent.ACTION_SEND.equals(action)
|| Intent.ACTION_SEND_MULTIPLE.equals(action)) {
setAccount(intent); setAccount(intent);
// Use the fields found in the Intent to prefill as much of the message as possible // Use the fields found in the Intent to prefill as much of the message as possible
initFromIntent(intent); initFromIntent(intent);
@ -800,8 +807,7 @@ public class MessageCompose extends Activity implements OnClickListener, OnFocus
String name = null; String name = null;
ContentResolver contentResolver = getContentResolver(); ContentResolver contentResolver = getContentResolver();
Cursor metadataCursor = contentResolver.query(uri, Cursor metadataCursor = contentResolver.query(uri,
new String[]{ OpenableColumns.DISPLAY_NAME, OpenableColumns.SIZE }, ATTACHMENT_META_COLUMNS, null, null, null);
null, null, null);
if (metadataCursor != null) { if (metadataCursor != null) {
try { try {
if (metadataCursor.moveToFirst()) { if (metadataCursor.moveToFirst()) {
@ -1021,6 +1027,23 @@ public class MessageCompose extends Activity implements OnClickListener, OnFocus
} }
} }
} }
if (Intent.ACTION_SEND_MULTIPLE.equals(intent.getAction())
&& intent.hasExtra(Intent.EXTRA_STREAM)) {
ArrayList<Parcelable> list = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM);
if (list != null) {
for (Parcelable parcelable : list) {
Uri uri = (Uri) parcelable;
if (uri != null) {
Attachment attachment = loadAttachmentInfo(uri);
if (MimeUtility.mimeTypeMatches(attachment.mMimeType,
Email.ACCEPTABLE_ATTACHMENT_SEND_TYPES)) {
addAttachment(attachment);
}
}
}
}
}
// Finally - expose fields that were filled in but are normally hidden, and set focus // Finally - expose fields that were filled in but are normally hidden, and set focus