1
0
mirror of https://github.com/moparisthebest/k-9 synced 2025-01-30 23:00:09 -05:00

Allow users to choose whether they want plaintext messages to be

fixed-width when uprezzed to HTML.
This commit is contained in:
Jesse Vincent 2010-06-06 21:33:33 +00:00
parent d2ed40d626
commit 4bfebe42f1
5 changed files with 73 additions and 4 deletions

View File

@ -293,6 +293,8 @@ Welcome to K-9 Mail setup. K-9 is an open source mail client for Android origin
<string name="global_settings_touchable_label">Touch-friendly view</string>
<string name="global_settings_touchable_summary">Roomier list items with message previews</string>
<string name="global_settings_messageview_fixedwidth_label">Fixed-width fonts</string>
<string name="global_settings_messageview_fixedwidth_summary">Use a fixed-width font when showing plain-text messages</string>
<string name="account_setup_basics_title">Set up a new account</string>
<string name="account_setup_basics_instructions">Enter this account\'s email address:</string>
@ -696,8 +698,9 @@ Welcome to K-9 Mail setup. K-9 is an open source mail client for Android origin
<string name="operational_preferences">Sync</string>
<string name="accountlist_preferences">Account List</string>
<string name="messagelist_preferences">Message Lists</string>
<string name="messageview_preferences">Messages</string>
<string name="settings_theme_label">Theme</string>
<string name="background_ops_label">Background sync</string>
<string name="background_ops_never">Never</string>
<string name="background_ops_always">Always</string>

View File

@ -89,6 +89,15 @@
</PreferenceCategory>
<PreferenceCategory android:title="@string/messageview_preferences" android:key="messageview_preferences">
<CheckBoxPreference
android:key="messageview_fixedwidth_font"
android:title="@string/global_settings_messageview_fixedwidth_label"
android:summary="@string/global_settings_messageview_fixedwidth_summary"
/>
</PreferenceCategory>
<PreferenceCategory android:title="@string/operational_preferences" android:key="operational_preferences">
<ListPreference

View File

@ -78,6 +78,9 @@ public class K9 extends Application
private static boolean mMessageListStars = true;
private static boolean mMessageListCheckboxes = false;
private static boolean mMessageListTouchable = false;
private static boolean mMessageViewFixedWidthFont = false;
private static boolean mGesturesEnabled = true;
private static boolean mManageBack = false;
private static boolean mMeasureAccounts = true;
@ -304,6 +307,9 @@ public class K9 extends Application
editor.putBoolean("messageListStars",mMessageListStars);
editor.putBoolean("messageListCheckboxes",mMessageListCheckboxes);
editor.putBoolean("messageListTouchable",mMessageListTouchable);
editor.putBoolean("messageViewFixedWidthFont",mMessageViewFixedWidthFont);
editor.putInt("theme", theme);
editor.putBoolean("useGalleryBugWorkaround", useGalleryBugWorkaround);
@ -330,6 +336,9 @@ public class K9 extends Application
mMessageListStars = sprefs.getBoolean("messageListStars",true);
mMessageListCheckboxes = sprefs.getBoolean("messageListCheckboxes",false);
mMessageListTouchable = sprefs.getBoolean("messageListTouchable",false);
mMessageViewFixedWidthFont = sprefs.getBoolean("messageViewFixedWidthFont", false);
useGalleryBugWorkaround = sprefs.getBoolean("useGalleryBugWorkaround", K9.isGalleryBuggy());
fontSizes.load(sprefs);
@ -505,6 +514,16 @@ public class K9 extends Application
}
public static boolean messageViewFixedWidthFont()
{
return mMessageViewFixedWidthFont;
}
public static void setMessageViewFixedWidthFont(boolean fixed)
{
mMessageViewFixedWidthFont = fixed;
}
private static Method getMethod(Class<?> classObject, String methodName)
{
try

View File

@ -33,6 +33,8 @@ public class Prefs extends K9PreferenceActivity
private static final String PREFERENCE_MESSAGELIST_CHECKBOXES = "messagelist_checkboxes";
private static final String PREFERENCE_MESSAGELIST_TOUCHABLE = "messagelist_touchable";
private static final String PREFERENCE_MESSAGEVIEW_FIXEDWIDTH = "messageview_fixedwidth_font";
private static final String PREFERENCE_MEASURE_ACCOUNTS = "measure_accounts";
private static final String PREFERENCE_COUNT_SEARCH = "count_search";
private static final String PREFERENCE_GALLERY_BUG_WORKAROUND = "use_gallery_bug_workaround";
@ -47,6 +49,9 @@ public class Prefs extends K9PreferenceActivity
private CheckBoxPreference mStars;
private CheckBoxPreference mCheckboxes;
private CheckBoxPreference mTouchable;
private CheckBoxPreference mFixedWidth;
private CheckBoxPreference mMeasureAccounts;
private CheckBoxPreference mCountSearch;
private CheckBoxPreference mUseGalleryBugWorkaround;
@ -161,6 +166,10 @@ public class Prefs extends K9PreferenceActivity
mTouchable = (CheckBoxPreference)findPreference(PREFERENCE_MESSAGELIST_TOUCHABLE);
mTouchable.setChecked(K9.messageListTouchable());
mFixedWidth = (CheckBoxPreference)findPreference(PREFERENCE_MESSAGEVIEW_FIXEDWIDTH);
mFixedWidth.setChecked(K9.messageViewFixedWidthFont());
mMeasureAccounts = (CheckBoxPreference)findPreference(PREFERENCE_MEASURE_ACCOUNTS);
mMeasureAccounts.setChecked(K9.measureAccounts());
@ -190,9 +199,10 @@ public class Prefs extends K9PreferenceActivity
K9.setManageBack(mManageBack.isChecked());
K9.setMessageListStars(mStars.isChecked());
K9.setMessageListCheckboxes(mCheckboxes.isChecked());
K9.setMessageListTouchable(mTouchable.isChecked());
K9.setMessageViewFixedWidthFont(mFixedWidth.isChecked());
K9.setMeasureAccounts(mMeasureAccounts.isChecked());
K9.setCountSearchMessages(mCountSearch.isChecked());

View File

@ -2333,9 +2333,11 @@ public class LocalStore extends Store implements Serializable
text = text.replaceAll("(?m)^([^\r\n]{4,}[\\s\\w,:;+/])(?:\r\n|\n|\r)(?=[a-z]\\S{0,10}[\\s\\n\\r])","$1 ");
text = text.replaceAll("(?m)(\r\n|\n|\r){4,}","\n\n");
Matcher m = Regex.WEB_URL_PATTERN.matcher(text);
StringBuffer sb = new StringBuffer(text.length() + 512);
sb.append("<html><body><pre style=\"white-space: pre-wrap; word-wrap:break-word; \">");
sb.append("<html><head></head><body>");
sb.append(htmlifyMessageHeader());
while (m.find())
{
int start = m.start();
@ -2353,12 +2355,38 @@ public class LocalStore extends Store implements Serializable
m.appendTail(sb);
sb.append("</pre></body></html>");
sb.append(htmlifyMessageFooter());
sb.append("</body></html>");
text = sb.toString();
return text;
}
private String htmlifyMessageHeader()
{
if (K9.messageViewFixedWidthFont())
{
return "<pre style=\"white-space: pre-wrap; word-wrap:break-word; \">";
}
else
{
return "<div style=\"white-space: pre-wrap; word-wrap:break-word; \">";
}
}
private String htmlifyMessageFooter()
{
if (K9.messageViewFixedWidthFont())
{
return "</pre>";
}
else
{
return "</div>";
}
}
@Override
public boolean isInTopGroup()
{