Added original zoom to fit screen option

pull/184/head
M66B 4 years ago
parent b54adf9a9d
commit 501de4991a

@ -2071,7 +2071,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
.appendElement("em")
.text(context.getString(R.string.title_truncated));
HtmlHelper.setViewport(document);
boolean overview_mode = prefs.getBoolean("overview_mode", false);
HtmlHelper.setViewport(document, overview_mode);
if (inline || show_images)
HtmlHelper.embedInlineImages(context, message.id, document, true);

@ -84,7 +84,7 @@ public class FragmentOptions extends FragmentBase {
"name_email", "prefer_contact", "distinguish_contacts", "show_recipients", "authentication",
"subject_top", "font_size_sender", "font_size_subject", "subject_italic", "highlight_subject", "subject_ellipsize",
"keywords_header", "labels_header", "flags", "flags_background", "preview", "preview_italic", "preview_lines",
"message_zoom", "addresses", "attachments_alt", "thumbnails",
"message_zoom", "overview_mode", "addresses", "attachments_alt", "thumbnails",
"contrast", "monospaced", "text_color", "text_size", "text_font", "text_align",
"inline_images", "collapse_quotes", "seekbar", "actionbar", "actionbar_color", "navbar_colorize",
"autoscroll", "swipenav", "swipe_close", "swipe_move", "autoexpand", "autoclose", "onclose",

@ -109,6 +109,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
private SwitchCompat swAddresses;
private EditText etMessageZoom;
private SwitchCompat swOverviewMode;
private SwitchCompat swContrast;
private SwitchCompat swMonospaced;
@ -134,7 +135,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
"keywords_header", "labels_header", "flags", "flags_background",
"preview", "preview_italic", "preview_lines",
"addresses",
"message_zoom", "contrast", "monospaced", "text_color", "text_size", "text_font", "text_align",
"message_zoom", "overview_mode", "contrast", "monospaced", "text_color", "text_size", "text_font", "text_align",
"inline_images", "collapse_quotes", "attachments_alt", "thumbnails",
"parse_classes", "authentication"
};
@ -199,6 +200,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
spPreviewLines = view.findViewById(R.id.spPreviewLines);
swAddresses = view.findViewById(R.id.swAddresses);
etMessageZoom = view.findViewById(R.id.etMessageZoom);
swOverviewMode = view.findViewById(R.id.swOverviewMode);
swContrast = view.findViewById(R.id.swContrast);
swMonospaced = view.findViewById(R.id.swMonospaced);
swTextColor = view.findViewById(R.id.swTextColor);
@ -639,6 +641,13 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
}
});
swOverviewMode.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("overview_mode", checked).apply();
}
});
swContrast.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@ -872,6 +881,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
int message_zoom = prefs.getInt("message_zoom", 0);
etMessageZoom.setText(message_zoom == 0 ? null : Integer.toString(message_zoom));
swOverviewMode.setChecked(prefs.getBoolean("overview_mode", false));
swContrast.setChecked(prefs.getBoolean("contrast", false));
swMonospaced.setChecked(prefs.getBoolean("monospaced", false));

@ -1516,7 +1516,7 @@ public class HtmlHelper {
}
}
static void setViewport(Document document) {
static void setViewport(Document document, boolean overview) {
// https://developer.mozilla.org/en-US/docs/Mozilla/Mobile/Viewport_meta_tag
Elements meta = document.head().select("meta").select("[name=viewport]");
if (meta.size() == 1) {
@ -1527,9 +1527,10 @@ public class HtmlHelper {
meta.attr("content", content);
} else {
meta.remove();
document.head().prependElement("meta")
.attr("name", "viewport")
.attr("content", "width=device-width, initial-scale=1.0");
if (!overview)
document.head().prependElement("meta")
.attr("name", "viewport")
.attr("content", "width=device-width, initial-scale=1.0");
}
Log.d(document.head().html());

@ -41,6 +41,11 @@ public class WebViewEx extends WebView implements DownloadListener, View.OnLongC
public WebViewEx(Context context) {
super(context);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean overview_mode = prefs.getBoolean("overview_mode", false);
boolean safe_browsing = prefs.getBoolean("safe_browsing", false);
setVerticalScrollBarEnabled(false);
setHorizontalScrollBarEnabled(false);
@ -49,7 +54,7 @@ public class WebViewEx extends WebView implements DownloadListener, View.OnLongC
WebSettings settings = getSettings();
settings.setUseWideViewPort(true);
settings.setLoadWithOverviewMode(false);
settings.setLoadWithOverviewMode(overview_mode);
settings.setBuiltInZoomControls(true);
settings.setDisplayZoomControls(false);
@ -60,11 +65,8 @@ public class WebViewEx extends WebView implements DownloadListener, View.OnLongC
settings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
settings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean safe_browsing = prefs.getBoolean("safe_browsing", false);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
settings.setSafeBrowsingEnabled(safe_browsing);
}
}
void init(

@ -857,6 +857,29 @@
app:layout_constraintStart_toEndOf="@id/etMessageZoom"
app:layout_constraintTop_toTopOf="@id/etMessageZoom" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swOverviewMode"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_overview_mode"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/etMessageZoom"
app:switchPadding="12dp" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvOverViewModeHint"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="48dp"
android:text="@string/title_advanced_overview_mode_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/swOverviewMode" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swContrast"
android:layout_width="0dp"
@ -865,7 +888,7 @@
android:text="@string/title_advanced_contrast"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/etMessageZoom"
app:layout_constraintTop_toBottomOf="@id/tvOverViewModeHint"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat

@ -369,6 +369,7 @@
<string name="title_advanced_attachments_alt">Show attachments after the message text</string>
<string name="title_advanced_thumbnails">Show image thumbnails after the message text</string>
<string name="title_advanced_message_text_zoom">Default message text zoom</string>
<string name="title_advanced_overview_mode">Zoom original messages to fit the screen</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_text_color">Use text colors</string>
@ -543,6 +544,7 @@
<string name="title_advanced_name_email_hint">When disabled only names will be shown when available</string>
<string name="title_advanced_preview_hint">Only available when message text has been downloaded</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_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>

Loading…
Cancel
Save