Addeed option to show HTML titles

pull/209/head
M66B 2 years ago
parent cd72d860a3
commit 929984c20e

@ -146,7 +146,7 @@ public class FragmentOptions extends FragmentBase {
"message_zoom", "overview_mode", "override_width", "addresses", "button_extra", "attachments_alt", "thumbnails",
"contrast", "hyphenation", "display_font", "monospaced_pre",
"list_count", "bundled_fonts", "parse_classes",
"background_color", "text_color", "text_size", "text_font", "text_align", "text_separators",
"background_color", "text_color", "text_size", "text_font", "text_align", "text_titles", "text_separators",
"collapse_quotes", "image_placeholders", "inline_images",
"seekbar", "actionbar", "actionbar_color", "group_category",
"autoscroll", "swipenav", "reversed", "swipe_close", "swipe_move", "autoexpand", "autoclose", "onclose",

@ -179,6 +179,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
private SwitchCompat swTextSize;
private SwitchCompat swTextFont;
private SwitchCompat swTextAlign;
private SwitchCompat swTextTitles;
private SwitchCompat swAuthentication;
private SwitchCompat swAuthenticationIndicator;
@ -209,7 +210,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
"collapse_quotes", "image_placeholders", "inline_images", "button_extra",
"unzip", "attachments_alt", "thumbnails",
"list_count", "bundled_fonts", "parse_classes",
"background_color", "text_color", "text_size", "text_font", "text_align",
"background_color", "text_color", "text_size", "text_font", "text_align", "text_titles",
"authentication", "authentication_indicator"
};
@ -336,6 +337,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
swTextSize = view.findViewById(R.id.swTextSize);
swTextFont = view.findViewById(R.id.swTextFont);
swTextAlign = view.findViewById(R.id.swTextAlign);
swTextTitles = view.findViewById(R.id.swTextTitles);
swAuthentication = view.findViewById(R.id.swAuthentication);
swAuthenticationIndicator = view.findViewById(R.id.swAuthenticationIndicator);
@ -1259,6 +1261,13 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
}
});
swTextTitles.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("text_titles", checked).apply();
}
});
swAuthentication.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@ -1510,6 +1519,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
swTextSize.setChecked(prefs.getBoolean("text_size", true));
swTextFont.setChecked(prefs.getBoolean("text_font", true));
swTextAlign.setChecked(prefs.getBoolean("text_align", true));
swTextTitles.setChecked(prefs.getBoolean("text_titles", false));
swAuthentication.setChecked(prefs.getBoolean("authentication", true));
swAuthenticationIndicator.setChecked(prefs.getBoolean("authentication_indicator", false));
swAuthenticationIndicator.setEnabled(swAuthentication.isChecked());

@ -424,6 +424,7 @@ public class HtmlHelper {
boolean text_size = (!view || prefs.getBoolean("text_size", true));
boolean text_font = (!view || prefs.getBoolean("text_font", true));
boolean text_align = prefs.getBoolean("text_align", true);
boolean text_titles = prefs.getBoolean("text_titles", false);
boolean display_hidden = prefs.getBoolean("display_hidden", false);
boolean disable_tracking = prefs.getBoolean("disable_tracking", true);
boolean parse_classes = prefs.getBoolean("parse_classes", true);
@ -509,6 +510,7 @@ public class HtmlHelper {
.addAttributes("td", "height")
.addAttributes("tr", "width")
.addAttributes("tr", "height")
.addAttributes(":all", "title")
.removeAttributes("td", "colspan", "rowspan", "width")
.removeAttributes("th", "colspan", "rowspan", "width")
.addProtocols("img", "src", "cid")
@ -1031,6 +1033,14 @@ public class HtmlHelper {
element.attr("x-block", "true");
}
// Insert titles
if (text_titles)
for (Element e : document.select("[title]")) {
String title = e.attr("title");
if (!TextUtils.isEmpty(title))
e.prependChild(document.createElement("span").text("{" + title + "}"));
}
// Replace headings
Elements hs = document.select("h1,h2,h3,h4,h5,h6");
hs.attr("x-line-before", "true");

@ -1910,6 +1910,7 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:checked="true"
android:text="@string/title_advanced_parse_classes"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
@ -1933,7 +1934,6 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:enabled="true"
android:text="@string/title_advanced_background_color"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
@ -1945,7 +1945,7 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:enabled="true"
android:checked="true"
android:text="@string/title_advanced_text_color"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
@ -1957,7 +1957,7 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:enabled="true"
android:checked="true"
android:text="@string/title_advanced_text_size"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
@ -1969,7 +1969,7 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:enabled="true"
android:checked="true"
android:text="@string/title_advanced_text_font"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
@ -1981,13 +1981,24 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:enabled="true"
android:checked="true"
android:text="@string/title_advanced_text_align"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swTextFont"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swTextTitles"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_text_titles"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swTextAlign"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swAuthentication"
android:layout_width="0dp"
@ -2000,7 +2011,7 @@
android:text="@string/title_advanced_authentication"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swTextAlign"
app:layout_constraintTop_toBottomOf="@id/swTextTitles"
app:switchPadding="12dp" />
<TextView

@ -557,6 +557,7 @@
<string name="title_advanced_text_size">Use text sizes</string>
<string name="title_advanced_text_font">Use fonts</string>
<string name="title_advanced_text_align">Use text alignment</string>
<string name="title_advanced_text_titles">Show {HTML titles}</string>
<string name="title_advanced_text_separators">Use separator lines</string>
<string name="title_advanced_collapse_quotes">Collapse quoted text</string>
<string name="title_advanced_image_placeholders">Show image placeholders</string>

Loading…
Cancel
Save