Hide inline attachments in compose. b/12553195.

Just hides the attachments visually. They still
exist and are counted against the max attachments
size.

Change-Id: Ia8c026fa083c3a95b7bc22b1564349d455f0030a
diff --git a/src/com/android/mail/browse/MessageFooterView.java b/src/com/android/mail/browse/MessageFooterView.java
index 59bf7ec..cfae87d 100644
--- a/src/com/android/mail/browse/MessageFooterView.java
+++ b/src/com/android/mail/browse/MessageFooterView.java
@@ -37,12 +37,10 @@
 import com.android.mail.browse.ConversationViewAdapter.MessageHeaderItem;
 import com.android.mail.providers.Attachment;
 import com.android.mail.providers.Message;
-import com.android.mail.providers.UIProvider;
 import com.android.mail.ui.AttachmentTile;
 import com.android.mail.ui.AttachmentTileGrid;
 import com.android.mail.utils.LogTag;
 import com.android.mail.utils.LogUtils;
-
 import com.google.common.base.Objects;
 import com.google.common.collect.Lists;
 
@@ -167,7 +165,7 @@
         final List<Attachment> barAttachments = new ArrayList<Attachment>(maxSize);
 
         for (Attachment attachment : attachments) {
-            if (attachment.type != UIProvider.AttachmentType.STANDARD) {
+            if (attachment.isInlineAttachment()) {
                 // skip non-standard (aka inline) attachments
                 continue;
             } else if (AttachmentTile.isTiledAttachment(attachment)) {
diff --git a/src/com/android/mail/compose/AttachmentsView.java b/src/com/android/mail/compose/AttachmentsView.java
index 650622e..a14eede 100644
--- a/src/com/android/mail/compose/AttachmentsView.java
+++ b/src/com/android/mail/compose/AttachmentsView.java
@@ -33,11 +33,10 @@
 import com.android.mail.providers.Account;
 import com.android.mail.providers.Attachment;
 import com.android.mail.ui.AttachmentTile;
-import com.android.mail.ui.AttachmentTileGrid;
 import com.android.mail.ui.AttachmentTile.AttachmentPreview;
+import com.android.mail.ui.AttachmentTileGrid;
 import com.android.mail.utils.LogTag;
 import com.android.mail.utils.LogUtils;
-
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.collect.Lists;
 
@@ -86,22 +85,26 @@
 
     /**
      * Set a listener for changes to the attachments.
-     * @param listener
      */
     public void setAttachmentChangesListener(AttachmentAddedOrDeletedListener listener) {
         mChangeListener = listener;
     }
 
     /**
-     * Add an attachment and update the ui accordingly.
-     * @param attachment
+     * Adds an attachment and updates the ui accordingly.
      */
-    public void addAttachment(final Attachment attachment) {
+    private void addAttachment(final Attachment attachment) {
+        mAttachments.add(attachment);
+
+        // If the attachment is inline do not display this attachment.
+        if (attachment.isInlineAttachment()) {
+            return;
+        }
+
         if (!isShown()) {
             setVisibility(View.VISIBLE);
         }
 
-        mAttachments.add(attachment);
         expandView();
 
         // If we have an attachment that should be shown in a tiled look,
@@ -184,7 +187,7 @@
     /**
      * Get the total size of all attachments currently in this view.
      */
-    public long getTotalAttachmentsSize() {
+    private long getTotalAttachmentsSize() {
         long totalSize = 0;
         for (Attachment attachment : mAttachments) {
             totalSize += attachment.size;
@@ -291,19 +294,6 @@
     }
 
     /**
-     * Adds a local attachment by file path.
-     * @param account
-     * @param contentUri the uri of the local file path
-     *
-     * @return size of the attachment added.
-     * @throws AttachmentFailureException if an error occurs adding the attachment.
-     */
-    public long addAttachment(Account account, Uri contentUri)
-            throws AttachmentFailureException {
-        return addAttachment(account, generateLocalAttachment(contentUri));
-    }
-
-    /**
      * Adds an attachment of either local or remote origin, checking to see if the attachment
      * exceeds file size limits.
      * @param account
diff --git a/src/com/android/mail/compose/ComposeActivity.java b/src/com/android/mail/compose/ComposeActivity.java
index b2bd5c1..9bca474 100644
--- a/src/com/android/mail/compose/ComposeActivity.java
+++ b/src/com/android/mail/compose/ComposeActivity.java
@@ -1688,7 +1688,7 @@
      * Add attachment and update the compose area appropriately.
      * @param data
      */
-    public void addAttachmentAndUpdateView(Intent data) {
+    private void addAttachmentAndUpdateView(Intent data) {
         if (data == null) {
             return;
         }
@@ -1706,7 +1706,7 @@
         addAttachmentAndUpdateView(data.getData());
     }
 
-    public void addAttachmentAndUpdateView(Uri contentUri) {
+    private void addAttachmentAndUpdateView(Uri contentUri) {
         if (contentUri == null) {
             return;
         }
@@ -1721,7 +1721,7 @@
         }
     }
 
-    public void addAttachmentAndUpdateView(Attachment attachment) {
+    private void addAttachmentAndUpdateView(Attachment attachment) {
         try {
             long size = mAttachmentsView.addAttachment(mAccount, attachment);
             if (size > 0) {
diff --git a/src/com/android/mail/providers/Attachment.java b/src/com/android/mail/providers/Attachment.java
index 6da871d..569d1ed 100644
--- a/src/com/android/mail/providers/Attachment.java
+++ b/src/com/android/mail/providers/Attachment.java
@@ -38,7 +38,6 @@
 import com.android.mail.utils.LogUtils;
 import com.android.mail.utils.MimeType;
 import com.android.mail.utils.Utils;
-import com.google.common.base.Objects;
 import com.google.common.collect.Lists;
 
 import org.apache.commons.io.IOUtils;
@@ -517,6 +516,15 @@
         }
     }
 
+    /**
+     * @return {@code true} if the attachment is an inline attachment
+     * that appears in the body of the message content (including possibly
+     * quoted text).
+     */
+    public boolean isInlineAttachment() {
+        return type != UIProvider.AttachmentType.STANDARD;
+    }
+
     @Override
     public boolean equals(final Object o) {
         if (this == o) {