Improved override widths

This commit is contained in:
M66B 2021-12-03 16:04:14 +01:00
parent ec4b142f3e
commit cf6f42fe7d
3 changed files with 33 additions and 6 deletions

View File

@ -2065,10 +2065,23 @@ public class HtmlHelper {
}
static void overrideWidth(Document document) {
document.select("head")
.prepend("<style type=\"text/css\">" +
"* {width: auto !important; max-width: none !important;}" +
"</style>");
List<String> tags = new ArrayList<>();
for (Element e : document.select("*")) {
String tag = e.tagName();
if ("img".equals(tag))
continue;
if (tags.contains(tag))
continue;
tags.add(tag);
}
StringBuilder sb = new StringBuilder();
sb.append("<style type=\"text/css\">");
for (String tag : tags)
sb.append(tag).append("{max-width: 100% !important;}");
sb.append("</style>");
document.select("head").append(sb.toString());
}
static String getLanguage(Context context, String subject, String text) {

View File

@ -1360,6 +1360,19 @@
app:layout_constraintTop_toBottomOf="@id/tvOverViewModeHint"
app:switchPadding="12dp" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvOverrideWidthHint"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginEnd="48dp"
android:text="@string/title_advanced_override_width_hint"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textStyle="italic"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swOverrideWidth" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swContrast"
android:layout_width="0dp"
@ -1368,7 +1381,7 @@
android:text="@string/title_advanced_contrast"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swOverrideWidth"
app:layout_constraintTop_toBottomOf="@id/tvOverrideWidthHint"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat

View File

@ -490,7 +490,7 @@
<string name="title_advanced_thumbnails">Show image thumbnails after the message text</string>
<string name="title_advanced_message_text_zoom2">Default message text zoom: %1$s %%</string>
<string name="title_advanced_overview_mode">Zoom original messages to fit the screen</string>
<string name="title_advanced_override_width">Override widths in original messages</string>
<string name="title_advanced_override_width">Disable fixed widths in original messages</string>
<string name="title_advanced_contrast">Use high contrast for message text</string>
<string name="title_advanced_monospaced">Use monospaced font for message text by default</string>
<string name="title_advanced_monospaced_pre">Use monospaced font for preformatted text</string>
@ -751,6 +751,7 @@
<string name="title_advanced_preview_lines_hint">Maximum %s characters in total</string>
<string name="title_advanced_preview_issue">Scrolling can be slow due to a bug in some Android versions when the number of lines is more than one</string>
<string name="title_advanced_overview_mode_hint">This can result in very small fonts</string>
<string name="title_advanced_override_width_hint">This can make messages smaller, but also look strange</string>
<string name="title_advanced_placeholders_hint">This applies to reformatted messages only</string>
<string name="title_advanced_inline_hint">Inline images are images included in the message</string>
<string name="title_advanced_parse_classes_hint">This will more accurately display messages, but possibly with a delay</string>