From ce4504b78e3e0a337063ffb20381199e8ef8aaa2 Mon Sep 17 00:00:00 2001
From: Andy Stadler <>
Date: Tue, 24 Mar 2009 22:20:55 -0700
Subject: [PATCH] Automated import from //branches/master/...@142153,142153
---
res/values/strings.xml | 3 +++
src/com/android/email/Email.java | 8 ++++++++
src/com/android/email/activity/MessageCompose.java | 7 +++++++
3 files changed, 18 insertions(+)
diff --git a/res/values/strings.xml b/res/values/strings.xml
index de4f706a0..57c9fa20f 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -157,6 +157,9 @@
You must add at least one recipient.
Some attachments cannot be forwarded because they have not downloaded.
+
+ File too large to attach.
To:
diff --git a/src/com/android/email/Email.java b/src/com/android/email/Email.java
index 81aae8e2b..2e49bff76 100644
--- a/src/com/android/email/Email.java
+++ b/src/com/android/email/Email.java
@@ -116,6 +116,14 @@ public class Email extends Application {
*/
public static final int MAX_ATTACHMENT_DOWNLOAD_SIZE = (5 * 1024 * 1024);
+ /**
+ * The maximum size of an attachment we're willing to upload (measured as stored on disk).
+ * Attachments that are base64 encoded (most) will be about 1.375x their actual size
+ * so we should probably factor that in. A 5MB attachment will generally be around
+ * 6.8MB uploaded.
+ */
+ public static final int MAX_ATTACHMENT_UPLOAD_SIZE = (5 * 1024 * 1024);
+
/**
* Called throughout the application when the number of accounts has changed. This method
* enables or disables the Compose activity, the boot receiver and the service based on
diff --git a/src/com/android/email/activity/MessageCompose.java b/src/com/android/email/activity/MessageCompose.java
index 424e15eff..4fca856f9 100644
--- a/src/com/android/email/activity/MessageCompose.java
+++ b/src/com/android/email/activity/MessageCompose.java
@@ -832,6 +832,13 @@ public class MessageCompose extends Activity implements OnClickListener, OnFocus
attachment.name = uri.getLastPathSegment();
}
+ // Before attaching the attachment, make sure it meets any other pre-attach criteria
+ if (attachment.size > Email.MAX_ATTACHMENT_UPLOAD_SIZE) {
+ Toast.makeText(this, R.string.message_compose_attachment_size, Toast.LENGTH_LONG)
+ .show();
+ return;
+ }
+
View view = getLayoutInflater().inflate(
R.layout.message_compose_attachment,
mAttachments,