Added debug option for viewport height

This commit is contained in:
M66B
2023-06-26 20:54:01 +02:00
parent a70f8bb4b7
commit 96148076f3
4 changed files with 57 additions and 4 deletions

View File

@@ -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));

View File

@@ -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<Integer, Integer> 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();