Added option to override HTML widths

This commit is contained in:
M66B
2021-12-03 09:12:01 +01:00
parent 644d36f322
commit 190888e59b
6 changed files with 38 additions and 3 deletions

View File

@@ -2610,7 +2610,10 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
HtmlHelper.guessSchemes(document);
boolean overview_mode = prefs.getBoolean("overview_mode", false);
boolean override_width = prefs.getBoolean("override_width", false);
HtmlHelper.setViewport(document, overview_mode);
if (!overview_mode && override_width)
HtmlHelper.overrideWidth(document);
if (inline || show_images)
HtmlHelper.embedInlineImages(context, message.id, document, show_images);

View File

@@ -135,7 +135,7 @@ public class FragmentOptions extends FragmentBase {
"font_size_sender", "sender_ellipsize",
"subject_top", "subject_italic", "highlight_subject", "font_size_subject", "subject_ellipsize",
"keywords_header", "labels_header", "flags", "flags_background", "preview", "preview_italic", "preview_lines",
"message_zoom", "overview_mode", "addresses", "button_extra", "attachments_alt", "thumbnails",
"message_zoom", "overview_mode", "override_width", "addresses", "button_extra", "attachments_alt", "thumbnails",
"contrast", "monospaced", "monospaced_pre",
"background_color", "text_color", "text_size", "text_font", "text_align", "text_separators",
"collapse_quotes", "image_placeholders", "inline_images",

View File

@@ -135,6 +135,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
private TextView tvMessageZoom;
private SeekBar sbMessageZoom;
private SwitchCompat swOverviewMode;
private SwitchCompat swOverrideWidth;
private SwitchCompat swContrast;
private SwitchCompat swMonospaced;
@@ -173,7 +174,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
"keywords_header", "labels_header", "flags", "flags_background",
"preview", "preview_italic", "preview_lines",
"addresses",
"message_zoom", "overview_mode", "contrast", "monospaced", "monospaced_pre",
"message_zoom", "overview_mode", "override_width", "contrast", "monospaced", "monospaced_pre",
"background_color", "text_color", "text_size", "text_font", "text_align", "text_separators",
"collapse_quotes", "image_placeholders", "inline_images", "button_extra", "attachments_alt", "thumbnails",
"parse_classes",
@@ -267,6 +268,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
tvMessageZoom = view.findViewById(R.id.tvMessageZoom);
sbMessageZoom = view.findViewById(R.id.sbMessageZoom);
swOverviewMode = view.findViewById(R.id.swOverviewMode);
swOverrideWidth = view.findViewById(R.id.swOverrideWidth);
swContrast = view.findViewById(R.id.swContrast);
swMonospaced = view.findViewById(R.id.swMonospaced);
swMonospacedPre = view.findViewById(R.id.swMonospacedPre);
@@ -898,6 +900,14 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("overview_mode", checked).apply();
swOverrideWidth.setEnabled(!checked);
}
});
swOverrideWidth.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("override_width", checked).apply();
}
});
@@ -1213,6 +1223,8 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
sbMessageZoom.setProgress(message_zoom - 50);
swOverviewMode.setChecked(prefs.getBoolean("overview_mode", false));
swOverrideWidth.setChecked(prefs.getBoolean("override_width", false));
swOverrideWidth.setEnabled(!swOverviewMode.isChecked());
swContrast.setChecked(prefs.getBoolean("contrast", false));
swMonospaced.setChecked(prefs.getBoolean("monospaced", false));

View File

@@ -2064,6 +2064,13 @@ public class HtmlHelper {
Log.i(document.head().html());
}
static void overrideWidth(Document document) {
document.select("head")
.prepend("<style type=\"text/css\">" +
"* {width: auto !important; max-width: none !important;}" +
"</style>");
}
static String getLanguage(Context context, String subject, String text) {
try {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);