astyle
This commit is contained in:
parent
8bb7613471
commit
aacb414004
6 changed files with 65 additions and 51 deletions
|
@ -285,12 +285,12 @@ public class Account implements BaseAccount
|
|||
|
||||
mMaxPushFolders = prefs.getInt(mUuid + ".maxPushFolders", 10);
|
||||
goToUnreadMessageSearch = prefs.getBoolean(mUuid + ".goToUnreadMessageSearch",
|
||||
false);
|
||||
false);
|
||||
mNotificationShowsUnreadCount = prefs.getBoolean(mUuid + ".notificationUnreadCount", true);
|
||||
subscribedFoldersOnly = prefs.getBoolean(mUuid + ".subscribedFoldersOnly",
|
||||
false);
|
||||
maximumPolledMessageAge = prefs.getInt(mUuid
|
||||
+ ".maximumPolledMessageAge", -1);
|
||||
+ ".maximumPolledMessageAge", -1);
|
||||
maximumAutoDownloadMessageSize = prefs.getInt(mUuid
|
||||
+ ".maximumAutoDownloadMessageSize", 32768);
|
||||
mMessageFormat = MessageFormat.valueOf(prefs.getString(mUuid + ".messageFormat", DEFAULT_MESSAGE_FORMAT.name()));
|
||||
|
|
|
@ -78,7 +78,8 @@ class InsertableHtmlContent implements Serializable
|
|||
/**
|
||||
* Remove all quoted content.
|
||||
*/
|
||||
public void clearQuotedContent() {
|
||||
public void clearQuotedContent()
|
||||
{
|
||||
quotedContent.setLength(0);
|
||||
footerInsertionPoint = 0;
|
||||
headerInsertionPoint = 0;
|
||||
|
@ -89,7 +90,8 @@ class InsertableHtmlContent implements Serializable
|
|||
* inserted content buffer.
|
||||
* @param content
|
||||
*/
|
||||
public void setUserContent(final String content) {
|
||||
public void setUserContent(final String content)
|
||||
{
|
||||
userContent = new StringBuilder(content);
|
||||
}
|
||||
|
||||
|
@ -114,11 +116,11 @@ class InsertableHtmlContent implements Serializable
|
|||
public String toDebugString()
|
||||
{
|
||||
return "InsertableHtmlContent{" +
|
||||
"headerInsertionPoint=" + headerInsertionPoint +
|
||||
", footerInsertionPoint=" + footerInsertionPoint +
|
||||
", quotedContent=" + quotedContent +
|
||||
", userContent=" + userContent +
|
||||
", compiledResult=" + toString() +
|
||||
'}';
|
||||
"headerInsertionPoint=" + headerInsertionPoint +
|
||||
", footerInsertionPoint=" + footerInsertionPoint +
|
||||
", quotedContent=" + quotedContent +
|
||||
", userContent=" + userContent +
|
||||
", compiledResult=" + toString() +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1193,7 +1193,8 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
|
|||
|
||||
// FYI, there's nothing in the code that requires these variables to one letter. They're one
|
||||
// letter simply to save space. This name sucks. It's too similar to Account.Identity.
|
||||
private enum IdentityField {
|
||||
private enum IdentityField
|
||||
{
|
||||
LENGTH("l"),
|
||||
OFFSET("o"),
|
||||
MESSAGE_FORMAT("f"),
|
||||
|
@ -1205,11 +1206,13 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
|
|||
|
||||
private final String value;
|
||||
|
||||
IdentityField(String value) {
|
||||
IdentityField(String value)
|
||||
{
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String value() {
|
||||
public String value()
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
|
@ -1218,7 +1221,8 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
|
|||
* checked for integer-ness during decoding.
|
||||
* @return
|
||||
*/
|
||||
public static IdentityField[] getIntegerFields() {
|
||||
public static IdentityField[] getIntegerFields()
|
||||
{
|
||||
return new IdentityField[] { LENGTH, OFFSET };
|
||||
}
|
||||
}
|
||||
|
@ -1232,13 +1236,17 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
|
|||
* @param body {@link TextBody} to analyze for body length and offset.
|
||||
* @return Identity string.
|
||||
*/
|
||||
private String buildIdentityHeader(final TextBody body) {
|
||||
private String buildIdentityHeader(final TextBody body)
|
||||
{
|
||||
Uri.Builder uri = new Uri.Builder();
|
||||
if(body.getComposedMessageLength() != null && body.getComposedMessageOffset() != null) {
|
||||
if(body.getComposedMessageLength() != null && body.getComposedMessageOffset() != null)
|
||||
{
|
||||
// See if the message body length is already in the TextBody.
|
||||
uri.appendQueryParameter(IdentityField.LENGTH.value(), body.getComposedMessageLength().toString());
|
||||
uri.appendQueryParameter(IdentityField.OFFSET.value(), body.getComposedMessageOffset().toString());
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
// If not, calculate it now.
|
||||
uri.appendQueryParameter(IdentityField.LENGTH.value(), Integer.toString(body.getText().length()));
|
||||
uri.appendQueryParameter(IdentityField.OFFSET.value(), Integer.toString(0));
|
||||
|
@ -1312,7 +1320,8 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
|
|||
try
|
||||
{
|
||||
Integer.parseInt(identity.get(key));
|
||||
} catch (NumberFormatException e)
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
Log.e(K9.LOG_TAG, "Invalid " + key.name() + " field in identity: " + identity.get(key));
|
||||
}
|
||||
|
@ -1334,7 +1343,8 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
|
|||
try
|
||||
{
|
||||
identity.put(IdentityField.LENGTH, Integer.valueOf(bodyLengthS).toString());
|
||||
} catch (Exception e)
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.e(K9.LOG_TAG, "Unable to parse bodyLength '" + bodyLengthS + "'");
|
||||
}
|
||||
|
@ -2235,11 +2245,11 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
|
|||
updateFrom();
|
||||
|
||||
Integer bodyLength = k9identity.get(IdentityField.LENGTH) != null
|
||||
? Integer.parseInt(k9identity.get(IdentityField.LENGTH))
|
||||
: 0;
|
||||
? Integer.parseInt(k9identity.get(IdentityField.LENGTH))
|
||||
: 0;
|
||||
Integer bodyOffset = k9identity.get(IdentityField.OFFSET) != null
|
||||
? Integer.parseInt(k9identity.get(IdentityField.OFFSET))
|
||||
: 0;
|
||||
? Integer.parseInt(k9identity.get(IdentityField.OFFSET))
|
||||
: 0;
|
||||
// Always respect the user's current composition format preference, even if the
|
||||
// draft was saved in a different format.
|
||||
// TODO - The current implementation doesn't allow a user in HTML mode to edit a draft that wasn't saved with K9mail.
|
||||
|
@ -2253,7 +2263,9 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
|
|||
// composition window. If that's the case, try and convert it to text to
|
||||
// match the behavior in text mode.
|
||||
mMessageContentView.setText(getBodyTextFromMessage(message, MessageFormat.TEXT));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
Part part = MimeUtility.findFirstPartByMimeType(message, "text/html");
|
||||
if (part != null) // Shouldn't happen if we were the one who saved it.
|
||||
{
|
||||
|
@ -2286,8 +2298,8 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
|
|||
else if (mAccount.getMessageFormat() == MessageFormat.TEXT)
|
||||
{
|
||||
MessageFormat format = k9identity.get(IdentityField.MESSAGE_FORMAT) != null
|
||||
? MessageFormat.valueOf(k9identity.get(IdentityField.MESSAGE_FORMAT))
|
||||
: null;
|
||||
? MessageFormat.valueOf(k9identity.get(IdentityField.MESSAGE_FORMAT))
|
||||
: null;
|
||||
if (format == null)
|
||||
{
|
||||
mMessageContentView.setText(getBodyTextFromMessage(message, MessageFormat.TEXT));
|
||||
|
@ -2379,8 +2391,8 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
|
|||
// Handle the original message in the reply
|
||||
// If we already have mSourceMessageBody, use that. It's pre-populated if we've got crypto going on.
|
||||
String content = mSourceMessageBody != null
|
||||
? mSourceMessageBody
|
||||
: getBodyTextFromMessage(mSourceMessage, mAccount.getMessageFormat());
|
||||
? mSourceMessageBody
|
||||
: getBodyTextFromMessage(mSourceMessage, mAccount.getMessageFormat());
|
||||
if (mAccount.getMessageFormat() == MessageFormat.HTML)
|
||||
{
|
||||
// Add the HTML reply header to the top of the content.
|
||||
|
@ -2860,9 +2872,9 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
|
|||
{
|
||||
StringBuilder quotedText = new StringBuilder(body.length() + QUOTE_BUFFER_LENGTH);
|
||||
quotedText.append(String.format(
|
||||
getString(R.string.message_compose_reply_header_fmt),
|
||||
Address.toString(originalMessage.getFrom()))
|
||||
);
|
||||
getString(R.string.message_compose_reply_header_fmt),
|
||||
Address.toString(originalMessage.getFrom()))
|
||||
);
|
||||
|
||||
final String prefix = mAccount.getQuotePrefix();
|
||||
final String wrappedText = Utility.wrap(body, REPLY_WRAP_LINE_WIDTH - prefix.length());
|
||||
|
@ -2932,11 +2944,11 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
|
|||
header.append("<br><div class=\"gmail_quote\">");
|
||||
// Remove all trailing newlines so that the quote starts immediately after the header. "Be like Gmail!"
|
||||
header.append(HtmlConverter.textToHtmlFragment(String.format(
|
||||
getString(R.string.message_compose_reply_header_fmt).replaceAll("\n$", ""),
|
||||
Address.toString(originalMessage.getFrom()))
|
||||
));
|
||||
getString(R.string.message_compose_reply_header_fmt).replaceAll("\n$", ""),
|
||||
Address.toString(originalMessage.getFrom()))
|
||||
));
|
||||
header.append("<blockquote class=\"gmail_quote\" " +
|
||||
"style=\"margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;\">\n");
|
||||
"style=\"margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;\">\n");
|
||||
|
||||
String footer = "</blockquote></div>";
|
||||
|
||||
|
|
|
@ -41,8 +41,8 @@ public class HtmlConverter
|
|||
public static String htmlToText(final String html)
|
||||
{
|
||||
return Html.fromHtml(html, null, new HtmlToTextTagHandler()).toString()
|
||||
.replace(PREVIEW_OBJECT_CHARACTER, PREVIEW_OBJECT_REPLACEMENT)
|
||||
.replace(NBSP_CHARACTER, NBSP_REPLACEMENT);
|
||||
.replace(PREVIEW_OBJECT_CHARACTER, PREVIEW_OBJECT_REPLACEMENT)
|
||||
.replace(NBSP_CHARACTER, NBSP_REPLACEMENT);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -53,15 +53,15 @@ public class HtmlConverter
|
|||
private static class HtmlToTextTagHandler implements Html.TagHandler
|
||||
{
|
||||
// List of tags whose content should be ignored.
|
||||
private static final Set<String> TAGS_WITH_IGNORED_CONTENT = Collections.unmodifiableSet(new HashSet<String>()
|
||||
{
|
||||
{
|
||||
add("style");
|
||||
add("script");
|
||||
add("title");
|
||||
add("!"); // comments
|
||||
}
|
||||
});
|
||||
private static final Set<String> TAGS_WITH_IGNORED_CONTENT = Collections.unmodifiableSet(new HashSet<String>()
|
||||
{
|
||||
{
|
||||
add("style");
|
||||
add("script");
|
||||
add("title");
|
||||
add("!"); // comments
|
||||
}
|
||||
});
|
||||
|
||||
@Override
|
||||
public void handleTag(boolean opening, String tag, Editable output, XMLReader xmlReader)
|
||||
|
@ -96,7 +96,7 @@ public class HtmlConverter
|
|||
if (opening)
|
||||
{
|
||||
output.setSpan(new Annotation(IGNORED_ANNOTATION_KEY, IGNORED_ANNOTATION_VALUE), len,
|
||||
len, Spannable.SPAN_MARK_MARK);
|
||||
len, Spannable.SPAN_MARK_MARK);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -1398,7 +1398,7 @@ public class MimeUtility
|
|||
|
||||
// iso-2022-jp variants are supported by no versions as of Dec 2010.
|
||||
if (charset.length() > 19 && charset.startsWith("x-") &&
|
||||
charset.endsWith("-iso-2022-jp-2007") && !Charset.isSupported(charset))
|
||||
charset.endsWith("-iso-2022-jp-2007") && !Charset.isSupported(charset))
|
||||
{
|
||||
in = new Iso2022JpToShiftJisInputStream(in);
|
||||
charset = "x-" + charset.substring(2, charset.length() - 17) + "-shift_jis-2007";
|
||||
|
@ -1406,7 +1406,7 @@ public class MimeUtility
|
|||
|
||||
// shift_jis variants are supported by Eclair and later.
|
||||
if (charset.length() > 17 && charset.startsWith("x-") &&
|
||||
charset.endsWith("-shift_jis-2007") && !Charset.isSupported(charset))
|
||||
charset.endsWith("-shift_jis-2007") && !Charset.isSupported(charset))
|
||||
{
|
||||
// If the JIS variant is iPhone, map the Unicode private use area in iPhone to the one in Android after
|
||||
// converting the character set from the standard Shift JIS to Unicode.
|
||||
|
@ -1422,7 +1422,7 @@ public class MimeUtility
|
|||
if (!Charset.isSupported(charset))
|
||||
{
|
||||
Log.e(K9.LOG_TAG, "I don't know how to deal with the charset " + charset +
|
||||
". Falling back to US-ASCII");
|
||||
". Falling back to US-ASCII");
|
||||
charset = "US-ASCII";
|
||||
}
|
||||
|
||||
|
|
|
@ -90,7 +90,7 @@ public class TextBody implements Body
|
|||
{
|
||||
mCharset = charset;
|
||||
}
|
||||
|
||||
|
||||
public Integer getComposedMessageLength()
|
||||
{
|
||||
return mComposedMessageLength;
|
||||
|
|
Loading…
Reference in a new issue