From 96148076f3b7c7793f0d7a006fb8f604252f0cce Mon Sep 17 00:00:00 2001 From: M66B Date: Mon, 26 Jun 2023 20:54:01 +0200 Subject: [PATCH] Added debug option for viewport height --- .../faircode/email/FragmentOptionsMisc.java | 27 ++++++++++++++++++- .../java/eu/faircode/email/WebViewEx.java | 8 ++++-- .../main/res/layout/fragment_options_misc.xml | 25 ++++++++++++++++- app/src/main/res/values/strings.xml | 1 + 4 files changed, 57 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java b/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java index 09edb3ea7d..0a41a0b591 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java @@ -211,6 +211,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc private SwitchCompat swUndoManager; private SwitchCompat swBrowserZoom; private SwitchCompat swFakeDark; + private EditText etViewportHeight; private SwitchCompat swShowRecent; private SwitchCompat swModSeq; private SwitchCompat swPreamble; @@ -458,6 +459,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc swUndoManager = view.findViewById(R.id.swUndoManager); swBrowserZoom = view.findViewById(R.id.swBrowserZoom); swFakeDark = view.findViewById(R.id.swFakeDark); + etViewportHeight = view.findViewById(R.id.etViewportHeight); swShowRecent = view.findViewById(R.id.swShowRecent); swModSeq = view.findViewById(R.id.swModSeq); swPreamble = view.findViewById(R.id.swPreamble); @@ -1611,6 +1613,27 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc } }); + etViewportHeight.addTextChangedListener(new TextWatcher() { + @Override + public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { + + } + + @Override + public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { + + } + + @Override + public void afterTextChanged(Editable edit) { + try { + prefs.edit().putInt("viewport_height", Integer.parseInt(edit.toString())).apply(); + } catch (Throwable ex) { + Log.e(ex); + } + } + }); + swShowRecent.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { @@ -2273,7 +2296,8 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc "send_host".equals(key) || "openai_uri".equals(key) || "openai_apikey".equals(key) || - "openai_model".equals(key)) + "openai_model".equals(key) || + "viewport_height".equals(key)) return; if ("global_keywords".equals(key)) @@ -2524,6 +2548,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc swUndoManager.setChecked(prefs.getBoolean("undo_manager", false)); swBrowserZoom.setChecked(prefs.getBoolean("browser_zoom", false)); swFakeDark.setChecked(prefs.getBoolean("fake_dark", false)); + etViewportHeight.setText(Integer.toString(prefs.getInt("viewport_height", 16000))); swShowRecent.setChecked(prefs.getBoolean("show_recent", false)); swModSeq.setChecked(prefs.getBoolean("use_modseq", true)); swPreamble.setChecked(prefs.getBoolean("preamble", false)); diff --git a/app/src/main/java/eu/faircode/email/WebViewEx.java b/app/src/main/java/eu/faircode/email/WebViewEx.java index 8e1ef2bb71..8497876100 100644 --- a/app/src/main/java/eu/faircode/email/WebViewEx.java +++ b/app/src/main/java/eu/faircode/email/WebViewEx.java @@ -48,6 +48,7 @@ import java.util.Objects; public class WebViewEx extends WebView implements DownloadListener, View.OnLongClickListener { private int height; private int maxHeight; + private int viewportHeight; private IWebView intf; private Runnable onPageLoaded; private String hash; @@ -61,6 +62,7 @@ public class WebViewEx extends WebView implements DownloadListener, View.OnLongC super(context); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); + this.viewportHeight = prefs.getInt("viewport_height", 16000); boolean overview_mode = prefs.getBoolean("overview_mode", false); boolean safe_browsing = prefs.getBoolean("safe_browsing", false); @@ -91,7 +93,9 @@ public class WebViewEx extends WebView implements DownloadListener, View.OnLongC } void init(int height, int maxHeight, float size, Pair position, boolean force_light, IWebView intf) { - Log.i("Init height=" + height + "/" + maxHeight + " size=" + size + " accelerated=" + isHardwareAccelerated()); + Log.i("Init height=" + height + "/" + maxHeight + " size=" + size + + " viewport=" + viewportHeight + + " accelerated=" + isHardwareAccelerated()); if (maxHeight == 0) { Log.e("WebView max height zero"); @@ -249,7 +253,7 @@ public class WebViewEx extends WebView implements DownloadListener, View.OnLongC @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { // Unable to create layer for WebViewEx, size 1088x16384 max size 16383 color type 4 has context 1) - int limitHeight = MeasureSpec.makeMeasureSpec(16000, MeasureSpec.AT_MOST); + int limitHeight = MeasureSpec.makeMeasureSpec(viewportHeight, MeasureSpec.AT_MOST); super.onMeasure(widthMeasureSpec, limitHeight); int mh = getMeasuredHeight(); diff --git a/app/src/main/res/layout/fragment_options_misc.xml b/app/src/main/res/layout/fragment_options_misc.xml index 63fd64fb1b..878ca28a65 100644 --- a/app/src/main/res/layout/fragment_options_misc.xml +++ b/app/src/main/res/layout/fragment_options_misc.xml @@ -1687,6 +1687,29 @@ app:layout_constraintTop_toBottomOf="@id/swBrowserZoom" app:switchPadding="12dp" /> + + + + Use Android\'s undo manager Use browser zoom Fake dark + Viewport height Show recent flag MODSEQ Preamble