mirror of https://github.com/M66B/FairEmail.git
Added option to disable small/large texts
This commit is contained in:
parent
73d323e2a2
commit
282033ccbe
|
@ -49,7 +49,7 @@ public class FragmentOptions extends FragmentBase {
|
|||
"subject_top", "font_size_sender", "font_size_subject", "subject_italic", "subject_ellipsize", "keywords_header",
|
||||
"flags", "flags_background", "preview", "preview_italic", "preview_lines",
|
||||
"addresses", "attachments_alt",
|
||||
"contrast", "monospaced", "text_color",
|
||||
"contrast", "monospaced", "text_color", "text_size",
|
||||
"inline_images", "collapse_quotes", "seekbar", "actionbar",
|
||||
"autoscroll", "swipenav", "autoexpand", "autoclose", "onclose",
|
||||
"quick_filter", "quick_scroll",
|
||||
|
|
|
@ -95,6 +95,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
|
|||
private SwitchCompat swContrast;
|
||||
private SwitchCompat swMonospaced;
|
||||
private SwitchCompat swTextColor;
|
||||
private SwitchCompat swTextSize;
|
||||
private SwitchCompat swCollapseQuotes;
|
||||
private SwitchCompat swImagesInline;
|
||||
private SwitchCompat swSeekbar;
|
||||
|
@ -106,7 +107,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
|
|||
"name_email", "prefer_contact", "distinguish_contacts", "authentication",
|
||||
"subject_top", "font_size_sender", "font_size_subject", "subject_italic", "subject_ellipsize", "keywords_header",
|
||||
"flags", "flags_background", "preview", "preview_italic", "preview_lines", "addresses", "attachments_alt",
|
||||
"contrast", "monospaced", "text_color",
|
||||
"contrast", "monospaced", "text_color", "text_size",
|
||||
"inline_images", "collapse_quotes", "seekbar", "actionbar",
|
||||
};
|
||||
|
||||
|
@ -162,6 +163,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
|
|||
swContrast = view.findViewById(R.id.swContrast);
|
||||
swMonospaced = view.findViewById(R.id.swMonospaced);
|
||||
swTextColor = view.findViewById(R.id.swTextColor);
|
||||
swTextSize = view.findViewById(R.id.swTextSize);
|
||||
swCollapseQuotes = view.findViewById(R.id.swCollapseQuotes);
|
||||
swImagesInline = view.findViewById(R.id.swImagesInline);
|
||||
swSeekbar = view.findViewById(R.id.swSeekbar);
|
||||
|
@ -529,6 +531,13 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
|
|||
}
|
||||
});
|
||||
|
||||
swTextSize.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
prefs.edit().putBoolean("text_size", checked).apply();
|
||||
}
|
||||
});
|
||||
|
||||
swCollapseQuotes.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
|
@ -686,6 +695,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
|
|||
swContrast.setChecked(prefs.getBoolean("contrast", false));
|
||||
swMonospaced.setChecked(prefs.getBoolean("monospaced", false));
|
||||
swTextColor.setChecked(prefs.getBoolean("text_color", true));
|
||||
swTextSize.setChecked(prefs.getBoolean("text_size", true));
|
||||
swCollapseQuotes.setChecked(prefs.getBoolean("collapse_quotes", false));
|
||||
swImagesInline.setChecked(prefs.getBoolean("inline_images", false));
|
||||
swSeekbar.setChecked(prefs.getBoolean("seekbar", false));
|
||||
|
|
|
@ -262,6 +262,7 @@ public class HtmlHelper {
|
|||
private static Document _sanitize(Context context, Document parsed, boolean show_images, boolean autolink, boolean more) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
boolean text_color = prefs.getBoolean("text_color", true);
|
||||
boolean text_size = prefs.getBoolean("text_size", true);
|
||||
boolean display_hidden = prefs.getBoolean("display_hidden", false);
|
||||
boolean disable_tracking = prefs.getBoolean("disable_tracking", true);
|
||||
|
||||
|
@ -348,6 +349,7 @@ public class HtmlHelper {
|
|||
|
||||
Whitelist whitelist = Whitelist.relaxed()
|
||||
.addTags("hr", "abbr", "big", "font", "dfn", "del", "s", "tt")
|
||||
.addAttributes(":all", "style")
|
||||
.removeTags("col", "colgroup", "thead", "tbody")
|
||||
.removeAttributes("table", "width")
|
||||
.removeAttributes("td", "colspan", "rowspan", "width")
|
||||
|
@ -357,7 +359,6 @@ public class HtmlHelper {
|
|||
.addProtocols("a", "href", "full");
|
||||
if (text_color)
|
||||
whitelist
|
||||
.addAttributes(":all", "style")
|
||||
.addAttributes("font", "color");
|
||||
|
||||
final Document document = new Cleaner(whitelist).clean(parsed);
|
||||
|
@ -392,6 +393,9 @@ public class HtmlHelper {
|
|||
switch (key) {
|
||||
case "color":
|
||||
// https://developer.mozilla.org/en-US/docs/Web/CSS/color
|
||||
if (!text_color)
|
||||
continue;
|
||||
|
||||
Integer color = parseColor(value, dark);
|
||||
if (color != null) {
|
||||
// fromHtml does not support transparency
|
||||
|
@ -400,10 +404,14 @@ public class HtmlHelper {
|
|||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N)
|
||||
element.attr("color", c);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case "font-size":
|
||||
// https://developer.mozilla.org/en-US/docs/Web/CSS/font-size
|
||||
if (!text_size)
|
||||
continue;
|
||||
|
||||
Element parent = element.parent();
|
||||
if (parent != null) {
|
||||
boolean set = false;
|
||||
|
@ -440,6 +448,7 @@ public class HtmlHelper {
|
|||
e.appendChild(element);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case "font-weight":
|
||||
|
@ -512,6 +521,13 @@ public class HtmlHelper {
|
|||
last.remove();
|
||||
}
|
||||
|
||||
if (!text_size)
|
||||
for (Element h : document.select("h1,h2,h3,h4,h5,h6")) {
|
||||
h.appendElement("br");
|
||||
h.appendElement("br");
|
||||
h.tagName("strong");
|
||||
}
|
||||
|
||||
// Paragraphs
|
||||
for (Element p : document.select("p")) {
|
||||
p.appendElement("br");
|
||||
|
|
|
@ -666,6 +666,18 @@
|
|||
app:layout_constraintTop_toBottomOf="@id/swMonospaced"
|
||||
app:switchPadding="12dp" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/swTextSize"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:enabled="true"
|
||||
android:text="@string/title_advanced_text_size"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/swTextColor"
|
||||
app:switchPadding="12dp" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/swCollapseQuotes"
|
||||
android:layout_width="0dp"
|
||||
|
@ -674,7 +686,7 @@
|
|||
android:text="@string/title_advanced_collapse_quotes"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/swTextColor"
|
||||
app:layout_constraintTop_toBottomOf="@id/swTextSize"
|
||||
app:switchPadding="12dp" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
|
|
|
@ -327,6 +327,7 @@
|
|||
<string name="title_advanced_contrast">Use high contrast for message text</string>
|
||||
<string name="title_advanced_monospaced">Use monospaced font for message text</string>
|
||||
<string name="title_advanced_text_color">Show text colors</string>
|
||||
<string name="title_advanced_text_size">Show small and large texts</string>
|
||||
<string name="title_advanced_collapse_quotes">Collapse quoted text</string>
|
||||
<string name="title_advanced_images_inline">Automatically show inline images</string>
|
||||
<string name="title_advanced_seekbar">Show relative conversation position with a dot</string>
|
||||
|
|
Loading…
Reference in New Issue