Revert "Auto original dark"

This reverts commit a67e679e17.
This commit is contained in:
M66B 2021-09-17 23:17:35 +02:00
parent a67e679e17
commit 97d46e5c03
4 changed files with 39 additions and 11 deletions

View File

@ -4178,11 +4178,20 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
if (full) {
TextView tvDark = dview.findViewById(R.id.tvDark);
CheckBox cbDark = dview.findViewById(R.id.cbDark);
CheckBox cbAlwaysImages = dview.findViewById(R.id.cbAlwaysImages);
boolean confirm_html = prefs.getBoolean("confirm_html", true);
cbDark.setChecked(prefs.getBoolean("html_dark", confirm_html));
cbAlwaysImages.setChecked(prefs.getBoolean("html_always_images", false));
cbDark.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
prefs.edit().putBoolean("html_dark", isChecked).apply();
}
});
cbAlwaysImages.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
@ -4192,7 +4201,10 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
boolean isDark = Helper.isDarkTheme(context);
boolean canDark = WebViewEx.isFeatureSupported(WebViewFeature.FORCE_DARK);
tvDark.setVisibility(isDark && !canDark ? View.VISIBLE : View.GONE);
cbDark.setVisibility(isDark && canDark ? View.VISIBLE : View.GONE);
} else {
boolean disable_tracking = prefs.getBoolean("disable_tracking", true);
@ -7254,6 +7266,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
boolean overview_mode = prefs.getBoolean("overview_mode", false);
boolean safe_browsing = prefs.getBoolean("safe_browsing", false);
boolean confirm_html = prefs.getBoolean("confirm_html", true);
boolean html_dark = prefs.getBoolean("html_dark", confirm_html);
View view = inflater.inflate(R.layout.fragment_open_full, container, false);
WebView wv = view.findViewById(R.id.wv);
@ -7275,7 +7289,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
settings.setSafeBrowsingEnabled(safe_browsing);
if (WebViewEx.isFeatureSupported(WebViewFeature.FORCE_DARK))
if (html_dark &&
WebViewEx.isFeatureSupported(WebViewFeature.FORCE_DARK))
WebSettingsCompat.setForceDark(settings,
Helper.isDarkTheme(getContext()) ? FORCE_DARK_ON : FORCE_DARK_OFF);

View File

@ -23,10 +23,7 @@ import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.graphics.BlendMode;
import android.graphics.Color;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build;
import android.util.Pair;
@ -107,18 +104,23 @@ 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);
boolean confirm_html = prefs.getBoolean("confirm_html", true);
boolean html_dark = prefs.getBoolean("html_dark", confirm_html);
WebSettings settings = getSettings();
boolean forced = false;
boolean dark = Helper.isDarkTheme(context);
if (WebViewEx.isFeatureSupported(WebViewFeature.FORCE_DARK)) {
if (html_dark &&
WebViewEx.isFeatureSupported(WebViewFeature.FORCE_DARK)) {
WebSettingsCompat.setForceDark(settings, dark ? FORCE_DARK_ON : FORCE_DARK_OFF);
setBackgroundColor(Color.TRANSPARENT);
} else {
if (!dark)
setBackgroundColor(Color.TRANSPARENT);
forced = true;
}
setBackgroundColor(dark && !forced
? Color.WHITE
: ColorUtils.setAlphaComponent(Color.WHITE, 127));
float fontSize = 16f /* Default */ * message_zoom / 100f;
if (zoom == 0 /* small */)
fontSize *= HtmlHelper.FONT_SMALL;
@ -176,7 +178,7 @@ public class WebViewEx extends WebView implements DownloadListener, View.OnLongC
});
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
setOnScrollChangeListener(new OnScrollChangeListener() {
setOnScrollChangeListener(new View.OnScrollChangeListener() {
@Override
public void onScrollChange(View v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
Log.i("Scroll (x,y)=" + scrollX + "," + scrollY);

View File

@ -32,6 +32,16 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvMessage" />
<CheckBox
android:id="@+id/cbDark"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_ask_show_html_dark"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvDark" />
<CheckBox
android:id="@+id/cbAlwaysImages"
android:layout_width="wrap_content"
@ -40,7 +50,7 @@
android:text="@string/title_ask_show_html_images"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvDark" />
app:layout_constraintTop_toBottomOf="@id/cbDark" />
<CheckBox
android:id="@+id/cbNotAgain"

View File

@ -1101,6 +1101,7 @@
<string name="title_ask_delete_rule">Delete rule permanently?</string>
<string name="title_ask_discard">Discard draft?</string>
<string name="title_ask_show_html">Showing the original message can leak privacy sensitive information</string>
<string name="title_ask_show_html_dark">Use dark theme</string>
<string name="title_ask_show_html_remark">Displaying the original message on a dark background is not possible as it may make dark texts and images invisible</string>
<string name="title_ask_show_html_images">Always show images on showing original messages</string>
<string name="title_ask_show_image">Showing images can leak privacy sensitive information</string>