Added option to restore old WebView behavior

pull/194/merge
M66B 3 years ago
parent d9f76a2b79
commit d4e3d65ed6

@ -299,6 +299,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
private List<String> languages;
private static boolean debug;
private int level;
private boolean webview_legacy;
private boolean gotoTop = false;
private Integer gotoPos = null;
@ -2430,7 +2431,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
if (clampedY && ((WebViewEx) wvBody).isZoomedY()) {
boolean flinged = false;
try {
if (rv != null)
if (!webview_legacy && rv != null)
flinged = rv.fling(dx * 10, dy * 10);
} catch (Throwable ex) {
Log.e(ex);
@ -6201,6 +6202,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
debug = prefs.getBoolean("debug", false);
level = prefs.getInt("log_level", Log.getDefaultLogLevel());
webview_legacy = prefs.getBoolean("webview_legacy", false);
DiffUtil.ItemCallback<TupleMessageEx> callback = new DiffUtil.ItemCallback<TupleMessageEx>() {
@Override
public boolean areItemsTheSame(

@ -145,7 +145,7 @@ public class FragmentOptions extends FragmentBase {
"swipe_reply",
"language_detection",
"quick_filter", "quick_scroll",
"experiments", "debug", "log_level",
"experiments", "debug", "log_level", "webview_legacy",
"biometrics",
"default_light"
};

@ -140,6 +140,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
private TextView tvChunkSize;
private SeekBar sbChunkSize;
private ImageButton ibSqliteCache;
private SwitchCompat swWebViewLegacy;
private SwitchCompat swModSeq;
private SwitchCompat swExpunge;
private SwitchCompat swUidExpunge;
@ -183,7 +184,8 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
"experiments", "crash_reports", "cleanup_attachments",
"protocol", "debug", "log_level",
"query_threads", "wal", "checkpoints", "sqlite_cache",
"chunk_size", "use_modseq", "perform_expunge", "uid_expunge",
"chunk_size", "webview_legacy",
"use_modseq", "perform_expunge", "uid_expunge",
"auth_plain", "auth_login", "auth_ntlm", "auth_sasl",
"keep_alive_poll", "empty_pool", "idle_done",
"exact_alarms", "infra", "dup_msgids", "test_iab"
@ -277,6 +279,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
ibSqliteCache = view.findViewById(R.id.ibSqliteCache);
tvChunkSize = view.findViewById(R.id.tvChunkSize);
sbChunkSize = view.findViewById(R.id.sbChunkSize);
swWebViewLegacy = view.findViewById(R.id.swWebViewLegacy);
swModSeq = view.findViewById(R.id.swModSeq);
swExpunge = view.findViewById(R.id.swExpunge);
swUidExpunge = view.findViewById(R.id.swUidExpunge);
@ -834,6 +837,13 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
}
});
swWebViewLegacy.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("webview_legacy", checked).apply();
}
});
swModSeq.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@ -1381,6 +1391,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
tvChunkSize.setText(getString(R.string.title_advanced_chunk_size, chunk_size));
sbChunkSize.setProgress(chunk_size);
swWebViewLegacy.setChecked(prefs.getBoolean("webview_legacy", false));
swModSeq.setChecked(prefs.getBoolean("use_modseq", true));
swExpunge.setChecked(prefs.getBoolean("perform_expunge", true));
swUidExpunge.setChecked(prefs.getBoolean("uid_expunge", false));

@ -48,6 +48,7 @@ import static androidx.webkit.WebSettingsCompat.FORCE_DARK_ON;
public class WebViewEx extends WebView implements DownloadListener, View.OnLongClickListener {
private int height;
private int maxHeight;
private boolean legacy;
private IWebView intf;
private Runnable onPageLoaded;
@ -111,6 +112,7 @@ public class WebViewEx extends WebView implements DownloadListener, View.OnLongC
int zoom = prefs.getInt("view_zoom", compact ? 0 : 1);
int message_zoom = prefs.getInt("message_zoom", 100);
boolean monospaced = prefs.getBoolean("monospaced", false);
legacy = prefs.getBoolean("webview_legacy", false);
WebSettings settings = getSettings();
@ -215,10 +217,17 @@ public class WebViewEx extends WebView implements DownloadListener, View.OnLongC
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
if (height > getMinimumHeight())
super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(Math.min(height, maxHeight), MeasureSpec.AT_MOST));
else
super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(maxHeight, MeasureSpec.AT_MOST));
if (legacy) {
if (height > getMinimumHeight())
super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(height, MeasureSpec.AT_MOST));
else
super.onMeasure(widthMeasureSpec, heightMeasureSpec); // Unspecified
} else {
if (height > getMinimumHeight())
super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(Math.min(height, maxHeight), MeasureSpec.AT_MOST));
else
super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(maxHeight, MeasureSpec.AT_MOST));
}
int mh = getMeasuredHeight();
Log.i("Measured height=" + mh + " last=" + height + "/" + maxHeight + " ch=" + getContentHeight());

@ -781,6 +781,18 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvChunkSize" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swWebViewLegacy"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:checked="true"
android:text="@string/title_advanced_webview_legacy"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/sbChunkSize"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swModSeq"
android:layout_width="0dp"
@ -790,7 +802,7 @@
android:text="@string/title_advanced_modseq"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/sbChunkSize"
app:layout_constraintTop_toBottomOf="@id/swWebViewLegacy"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat

@ -681,6 +681,7 @@
<string name="title_advanced_checkpoints" translatable="false">Checkpoints</string>
<string name="title_advanced_sqlite_cache" translatable="false">Sqlite cache: %1$s %% - %2$s</string>
<string name="title_advanced_chunk_size" translatable="false">Chunk size: %1$d</string>
<string name="title_advanced_webview_legacy" translatable="false">Old WebView behavior</string>
<string name="title_advanced_modseq" translatable="false">MODSEQ</string>
<string name="title_advanced_expunge" translatable="false">AUTO EXPUNGE</string>
<string name="title_advanced_uid_expunge" translatable="false">UID EXPUNGE</string>

Loading…
Cancel
Save