add debugging code to dump a conversation HTML

Change-Id: If330f600d5527503eed9745281076f895a275cd0
diff --git a/res/raw/template_conversation_upper.html b/res/raw/template_conversation_upper.html
index b4abb38..1beb249 100644
--- a/res/raw/template_conversation_upper.html
+++ b/res/raw/template_conversation_upper.html
@@ -13,5 +13,4 @@
   </style>
 </head>
 <body style="margin: 0;">
-<!-- TODO: promote this to a spacer so its overlay can scroll like the other adapter views -->
 <div id="conversation-header" style="height: %spx;"></div>
diff --git a/src/com/android/mail/ui/ConversationViewFragment.java b/src/com/android/mail/ui/ConversationViewFragment.java
index 3260463..b3436f1 100644
--- a/src/com/android/mail/ui/ConversationViewFragment.java
+++ b/src/com/android/mail/ui/ConversationViewFragment.java
@@ -144,6 +144,8 @@
     public static final String ARG_CONVERSATION = "conversation";
     private static final String ARG_FOLDER = "folder";
 
+    private static final boolean DEBUG_DUMP_CONVERSATION_HTML = false;
+
     /**
      * Constructor needs to be public to handle orientation changes and activity lifecycle events.
      */
@@ -403,8 +405,28 @@
     }
 
     private void renderConversation(MessageCursor messageCursor) {
-        mWebView.loadDataWithBaseURL(mBaseUri, renderMessageBodies(messageCursor), "text/html",
-                "utf-8", null);
+        final String convHtml = renderMessageBodies(messageCursor);
+
+        if (DEBUG_DUMP_CONVERSATION_HTML) {
+            java.io.FileWriter fw = null;
+            try {
+                fw = new java.io.FileWriter("/sdcard/conv" + mConversation.id
+                        + ".html");
+                fw.write(convHtml);
+            } catch (java.io.IOException e) {
+                e.printStackTrace();
+            } finally {
+                if (fw != null) {
+                    try {
+                        fw.close();
+                    } catch (java.io.IOException e) {
+                        e.printStackTrace();
+                    }
+                }
+            }
+        }
+
+        mWebView.loadDataWithBaseURL(mBaseUri, convHtml, "text/html", "utf-8", null);
         mCursor = messageCursor;
     }