mirror of
https://github.com/moparisthebest/k-9
synced 2025-01-31 15:20:09 -05:00
lift the "get display text" code out of the messageview and into
localmessage
This commit is contained in:
parent
84f6e546d2
commit
7623a02852
@ -15,6 +15,7 @@ import java.util.Set;
|
|||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import com.fsck.k9.mail.store.LocalStore;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
@ -2012,34 +2013,7 @@ public class MessageView extends K9Activity implements OnClickListener
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// First try and fetch an HTML part.
|
text = ((LocalMessage)mMessage).getTextForDisplay();
|
||||||
Part part = MimeUtility.findFirstPartByMimeType(mMessage, "text/html");
|
|
||||||
if (part == null)
|
|
||||||
{
|
|
||||||
// If that fails, try and get a text part.
|
|
||||||
part = MimeUtility.findFirstPartByMimeType(mMessage, "text/plain");
|
|
||||||
if (part == null)
|
|
||||||
{
|
|
||||||
text = null;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
LocalTextBody body = (LocalTextBody) part.getBody();
|
|
||||||
if (body == null)
|
|
||||||
{
|
|
||||||
text = null;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
text = body.getBodyForDisplay();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// We successfully found an HTML part; do the necessary character set decoding.
|
|
||||||
text = MimeUtility.getTextFromPart(part);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (text != null)
|
if (text != null)
|
||||||
{
|
{
|
||||||
|
@ -5403,6 +5403,41 @@ public class LocalStore extends Store implements Serializable
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public String getTextForDisplay() throws MessagingException
|
||||||
|
{
|
||||||
|
String text;// First try and fetch an HTML part.
|
||||||
|
Part part = MimeUtility.findFirstPartByMimeType(this, "text/html");
|
||||||
|
if (part == null)
|
||||||
|
{
|
||||||
|
// If that fails, try and get a text part.
|
||||||
|
part = MimeUtility.findFirstPartByMimeType(this, "text/plain");
|
||||||
|
if (part == null)
|
||||||
|
{
|
||||||
|
text = null;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LocalStore.LocalTextBody body = (LocalStore.LocalTextBody) part.getBody();
|
||||||
|
if (body == null)
|
||||||
|
{
|
||||||
|
text = null;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
text = body.getBodyForDisplay();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// We successfully found an HTML part; do the necessary character set decoding.
|
||||||
|
text = MimeUtility.getTextFromPart(part);
|
||||||
|
}
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Custom version of writeTo that updates the MIME message based on localMessage
|
/* Custom version of writeTo that updates the MIME message based on localMessage
|
||||||
* changes.
|
* changes.
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user