Hack to make the Conversation View footer reload when a POP message finishes loading

Get rid of this later when we stop using dummy attachments for "Load More"

b/11439833

Change-Id: Ia0ea9408fb74b6c305de43eada306c5df4c5fd59
diff --git a/src/com/android/email/provider/EmailProvider.java b/src/com/android/email/provider/EmailProvider.java
index 033e368..1496295 100644
--- a/src/com/android/email/provider/EmailProvider.java
+++ b/src/com/android/email/provider/EmailProvider.java
@@ -2694,6 +2694,16 @@
                 values.put(UIProvider.MessageColumns.EVENT_INTENT_URI,
                         "content://ui.email2.android.com/event/" + msg.mId);
             }
+            /**
+             * HACK: override the attachment uri to contain a query parameter
+             * This forces the message footer to reload the attachment display when the message is
+             * fully loaded.
+             */
+            final Uri attachmentListUri = uiUri("uiattachments", messageId).buildUpon()
+                    .appendQueryParameter("MessageLoaded",
+                            msg.mFlagLoaded == Message.FLAG_LOADED_COMPLETE ? "true" : "false")
+                    .build();
+            values.put(UIProvider.MessageColumns.ATTACHMENT_LIST_URI, attachmentListUri.toString());
         }
         StringBuilder sb = genSelect(getMessageViewMap(), uiProjection, values);
         sb.append(" FROM " + Message.TABLE_NAME + " LEFT JOIN " + Body.TABLE_NAME + " ON " +
@@ -4955,6 +4965,7 @@
         if (!uri.getBooleanQueryParameter(IS_UIPROVIDER, false)) {
             notifyUIConversation(uri);
         }
+        notifyUIMessage(messageId);
         // TODO: Ideally, also test that the values actually changed.
         if (values.containsKey(MessageColumns.FLAG_READ) ||
                 values.containsKey(MessageColumns.MAILBOX_KEY)) {
@@ -5106,6 +5117,14 @@
     }
 
     /**
+     * Notify about the message id passed in
+     * @param id the message id to be notified
+     */
+    private void notifyUIMessage(String id) {
+        notifyUI(UIPROVIDER_MESSAGE_NOTIFIER, id);
+    }
+
+    /**
      * Notify about the Account id passed in
      * @param id the Account id to be notified
      */