mirror of
https://github.com/moparisthebest/k-9
synced 2025-02-07 02:30:10 -05:00
Allow users to choose whether they want plaintext messages to be
fixed-width when uprezzed to HTML.
This commit is contained in:
parent
d2ed40d626
commit
4bfebe42f1
@ -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_label">Touch-friendly view</string>
|
||||||
<string name="global_settings_touchable_summary">Roomier list items with message previews</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_title">Set up a new account</string>
|
||||||
<string name="account_setup_basics_instructions">Enter this account\'s email address:</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="operational_preferences">Sync</string>
|
||||||
<string name="accountlist_preferences">Account List</string>
|
<string name="accountlist_preferences">Account List</string>
|
||||||
<string name="messagelist_preferences">Message Lists</string>
|
<string name="messagelist_preferences">Message Lists</string>
|
||||||
|
<string name="messageview_preferences">Messages</string>
|
||||||
<string name="settings_theme_label">Theme</string>
|
<string name="settings_theme_label">Theme</string>
|
||||||
|
|
||||||
<string name="background_ops_label">Background sync</string>
|
<string name="background_ops_label">Background sync</string>
|
||||||
<string name="background_ops_never">Never</string>
|
<string name="background_ops_never">Never</string>
|
||||||
<string name="background_ops_always">Always</string>
|
<string name="background_ops_always">Always</string>
|
||||||
|
@ -89,6 +89,15 @@
|
|||||||
|
|
||||||
</PreferenceCategory>
|
</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">
|
<PreferenceCategory android:title="@string/operational_preferences" android:key="operational_preferences">
|
||||||
|
|
||||||
<ListPreference
|
<ListPreference
|
||||||
|
@ -78,6 +78,9 @@ public class K9 extends Application
|
|||||||
private static boolean mMessageListStars = true;
|
private static boolean mMessageListStars = true;
|
||||||
private static boolean mMessageListCheckboxes = false;
|
private static boolean mMessageListCheckboxes = false;
|
||||||
private static boolean mMessageListTouchable = false;
|
private static boolean mMessageListTouchable = false;
|
||||||
|
|
||||||
|
private static boolean mMessageViewFixedWidthFont = false;
|
||||||
|
|
||||||
private static boolean mGesturesEnabled = true;
|
private static boolean mGesturesEnabled = true;
|
||||||
private static boolean mManageBack = false;
|
private static boolean mManageBack = false;
|
||||||
private static boolean mMeasureAccounts = true;
|
private static boolean mMeasureAccounts = true;
|
||||||
@ -304,6 +307,9 @@ public class K9 extends Application
|
|||||||
editor.putBoolean("messageListStars",mMessageListStars);
|
editor.putBoolean("messageListStars",mMessageListStars);
|
||||||
editor.putBoolean("messageListCheckboxes",mMessageListCheckboxes);
|
editor.putBoolean("messageListCheckboxes",mMessageListCheckboxes);
|
||||||
editor.putBoolean("messageListTouchable",mMessageListTouchable);
|
editor.putBoolean("messageListTouchable",mMessageListTouchable);
|
||||||
|
|
||||||
|
editor.putBoolean("messageViewFixedWidthFont",mMessageViewFixedWidthFont);
|
||||||
|
|
||||||
editor.putInt("theme", theme);
|
editor.putInt("theme", theme);
|
||||||
editor.putBoolean("useGalleryBugWorkaround", useGalleryBugWorkaround);
|
editor.putBoolean("useGalleryBugWorkaround", useGalleryBugWorkaround);
|
||||||
|
|
||||||
@ -330,6 +336,9 @@ public class K9 extends Application
|
|||||||
mMessageListStars = sprefs.getBoolean("messageListStars",true);
|
mMessageListStars = sprefs.getBoolean("messageListStars",true);
|
||||||
mMessageListCheckboxes = sprefs.getBoolean("messageListCheckboxes",false);
|
mMessageListCheckboxes = sprefs.getBoolean("messageListCheckboxes",false);
|
||||||
mMessageListTouchable = sprefs.getBoolean("messageListTouchable",false);
|
mMessageListTouchable = sprefs.getBoolean("messageListTouchable",false);
|
||||||
|
|
||||||
|
mMessageViewFixedWidthFont = sprefs.getBoolean("messageViewFixedWidthFont", false);
|
||||||
|
|
||||||
useGalleryBugWorkaround = sprefs.getBoolean("useGalleryBugWorkaround", K9.isGalleryBuggy());
|
useGalleryBugWorkaround = sprefs.getBoolean("useGalleryBugWorkaround", K9.isGalleryBuggy());
|
||||||
|
|
||||||
fontSizes.load(sprefs);
|
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)
|
private static Method getMethod(Class<?> classObject, String methodName)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -33,6 +33,8 @@ public class Prefs extends K9PreferenceActivity
|
|||||||
private static final String PREFERENCE_MESSAGELIST_CHECKBOXES = "messagelist_checkboxes";
|
private static final String PREFERENCE_MESSAGELIST_CHECKBOXES = "messagelist_checkboxes";
|
||||||
private static final String PREFERENCE_MESSAGELIST_TOUCHABLE = "messagelist_touchable";
|
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_MEASURE_ACCOUNTS = "measure_accounts";
|
||||||
private static final String PREFERENCE_COUNT_SEARCH = "count_search";
|
private static final String PREFERENCE_COUNT_SEARCH = "count_search";
|
||||||
private static final String PREFERENCE_GALLERY_BUG_WORKAROUND = "use_gallery_bug_workaround";
|
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 mStars;
|
||||||
private CheckBoxPreference mCheckboxes;
|
private CheckBoxPreference mCheckboxes;
|
||||||
private CheckBoxPreference mTouchable;
|
private CheckBoxPreference mTouchable;
|
||||||
|
|
||||||
|
private CheckBoxPreference mFixedWidth;
|
||||||
|
|
||||||
private CheckBoxPreference mMeasureAccounts;
|
private CheckBoxPreference mMeasureAccounts;
|
||||||
private CheckBoxPreference mCountSearch;
|
private CheckBoxPreference mCountSearch;
|
||||||
private CheckBoxPreference mUseGalleryBugWorkaround;
|
private CheckBoxPreference mUseGalleryBugWorkaround;
|
||||||
@ -161,6 +166,10 @@ public class Prefs extends K9PreferenceActivity
|
|||||||
mTouchable = (CheckBoxPreference)findPreference(PREFERENCE_MESSAGELIST_TOUCHABLE);
|
mTouchable = (CheckBoxPreference)findPreference(PREFERENCE_MESSAGELIST_TOUCHABLE);
|
||||||
mTouchable.setChecked(K9.messageListTouchable());
|
mTouchable.setChecked(K9.messageListTouchable());
|
||||||
|
|
||||||
|
mFixedWidth = (CheckBoxPreference)findPreference(PREFERENCE_MESSAGEVIEW_FIXEDWIDTH);
|
||||||
|
mFixedWidth.setChecked(K9.messageViewFixedWidthFont());
|
||||||
|
|
||||||
|
|
||||||
mMeasureAccounts = (CheckBoxPreference)findPreference(PREFERENCE_MEASURE_ACCOUNTS);
|
mMeasureAccounts = (CheckBoxPreference)findPreference(PREFERENCE_MEASURE_ACCOUNTS);
|
||||||
mMeasureAccounts.setChecked(K9.measureAccounts());
|
mMeasureAccounts.setChecked(K9.measureAccounts());
|
||||||
|
|
||||||
@ -190,9 +199,10 @@ public class Prefs extends K9PreferenceActivity
|
|||||||
K9.setManageBack(mManageBack.isChecked());
|
K9.setManageBack(mManageBack.isChecked());
|
||||||
K9.setMessageListStars(mStars.isChecked());
|
K9.setMessageListStars(mStars.isChecked());
|
||||||
K9.setMessageListCheckboxes(mCheckboxes.isChecked());
|
K9.setMessageListCheckboxes(mCheckboxes.isChecked());
|
||||||
|
|
||||||
K9.setMessageListTouchable(mTouchable.isChecked());
|
K9.setMessageListTouchable(mTouchable.isChecked());
|
||||||
|
|
||||||
|
K9.setMessageViewFixedWidthFont(mFixedWidth.isChecked());
|
||||||
|
|
||||||
K9.setMeasureAccounts(mMeasureAccounts.isChecked());
|
K9.setMeasureAccounts(mMeasureAccounts.isChecked());
|
||||||
K9.setCountSearchMessages(mCountSearch.isChecked());
|
K9.setCountSearchMessages(mCountSearch.isChecked());
|
||||||
|
|
||||||
|
@ -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]{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");
|
text = text.replaceAll("(?m)(\r\n|\n|\r){4,}","\n\n");
|
||||||
|
|
||||||
|
|
||||||
Matcher m = Regex.WEB_URL_PATTERN.matcher(text);
|
Matcher m = Regex.WEB_URL_PATTERN.matcher(text);
|
||||||
StringBuffer sb = new StringBuffer(text.length() + 512);
|
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())
|
while (m.find())
|
||||||
{
|
{
|
||||||
int start = m.start();
|
int start = m.start();
|
||||||
@ -2353,12 +2355,38 @@ public class LocalStore extends Store implements Serializable
|
|||||||
|
|
||||||
|
|
||||||
m.appendTail(sb);
|
m.appendTail(sb);
|
||||||
sb.append("</pre></body></html>");
|
sb.append(htmlifyMessageFooter());
|
||||||
|
sb.append("</body></html>");
|
||||||
text = sb.toString();
|
text = sb.toString();
|
||||||
|
|
||||||
return text;
|
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
|
@Override
|
||||||
public boolean isInTopGroup()
|
public boolean isInTopGroup()
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user