mirror of https://github.com/M66B/FairEmail.git
Added debug option for viewport height
This commit is contained in:
parent
a70f8bb4b7
commit
96148076f3
|
@ -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));
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -1687,6 +1687,29 @@
|
|||
app:layout_constraintTop_toBottomOf="@id/swBrowserZoom"
|
||||
app:switchPadding="12dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvViewportHeight"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:layout_marginEnd="48dp"
|
||||
android:text="@string/title_advanced_viewport_height"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/swFakeDark" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/etViewportHeight"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="number"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvViewportHeight" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/swShowRecent"
|
||||
android:layout_width="0dp"
|
||||
|
@ -1696,7 +1719,7 @@
|
|||
android:text="@string/title_advanced_show_recent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/swFakeDark"
|
||||
app:layout_constraintTop_toBottomOf="@id/etViewportHeight"
|
||||
app:switchPadding="12dp" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
|
|
|
@ -862,6 +862,7 @@
|
|||
<string name="title_advanced_undo_manager" translatable="false">Use Android\'s undo manager</string>
|
||||
<string name="title_advanced_browser_zoom" translatable="false">Use browser zoom</string>
|
||||
<string name="title_advanced_fake_dark" translatable="false">Fake dark</string>
|
||||
<string name="title_advanced_viewport_height" translatable="false">Viewport height</string>
|
||||
<string name="title_advanced_show_recent" translatable="false">Show recent flag</string>
|
||||
<string name="title_advanced_modseq" translatable="false">MODSEQ</string>
|
||||
<string name="title_advanced_preamble" translatable="false">Preamble</string>
|
||||
|
|
Loading…
Reference in New Issue