mirror of https://github.com/M66B/FairEmail.git
Auto original dark
This commit is contained in:
parent
522cd30e7c
commit
a67e679e17
|
@ -4178,20 +4178,11 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||||
|
|
||||||
if (full) {
|
if (full) {
|
||||||
TextView tvDark = dview.findViewById(R.id.tvDark);
|
TextView tvDark = dview.findViewById(R.id.tvDark);
|
||||||
CheckBox cbDark = dview.findViewById(R.id.cbDark);
|
|
||||||
CheckBox cbAlwaysImages = dview.findViewById(R.id.cbAlwaysImages);
|
CheckBox cbAlwaysImages = dview.findViewById(R.id.cbAlwaysImages);
|
||||||
|
|
||||||
boolean confirm_html = prefs.getBoolean("confirm_html", true);
|
boolean confirm_html = prefs.getBoolean("confirm_html", true);
|
||||||
cbDark.setChecked(prefs.getBoolean("html_dark", confirm_html));
|
|
||||||
cbAlwaysImages.setChecked(prefs.getBoolean("html_always_images", false));
|
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() {
|
cbAlwaysImages.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
|
@ -4201,10 +4192,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||||
|
|
||||||
boolean isDark = Helper.isDarkTheme(context);
|
boolean isDark = Helper.isDarkTheme(context);
|
||||||
boolean canDark = WebViewEx.isFeatureSupported(WebViewFeature.FORCE_DARK);
|
boolean canDark = WebViewEx.isFeatureSupported(WebViewFeature.FORCE_DARK);
|
||||||
|
|
||||||
tvDark.setVisibility(isDark && !canDark ? View.VISIBLE : View.GONE);
|
tvDark.setVisibility(isDark && !canDark ? View.VISIBLE : View.GONE);
|
||||||
cbDark.setVisibility(isDark && canDark ? View.VISIBLE : View.GONE);
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
boolean disable_tracking = prefs.getBoolean("disable_tracking", true);
|
boolean disable_tracking = prefs.getBoolean("disable_tracking", true);
|
||||||
|
|
||||||
|
@ -7266,8 +7254,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||||
boolean overview_mode = prefs.getBoolean("overview_mode", false);
|
boolean overview_mode = prefs.getBoolean("overview_mode", false);
|
||||||
boolean safe_browsing = prefs.getBoolean("safe_browsing", 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);
|
View view = inflater.inflate(R.layout.fragment_open_full, container, false);
|
||||||
WebView wv = view.findViewById(R.id.wv);
|
WebView wv = view.findViewById(R.id.wv);
|
||||||
|
@ -7289,8 +7275,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
|
||||||
settings.setSafeBrowsingEnabled(safe_browsing);
|
settings.setSafeBrowsingEnabled(safe_browsing);
|
||||||
|
|
||||||
if (html_dark &&
|
if (WebViewEx.isFeatureSupported(WebViewFeature.FORCE_DARK))
|
||||||
WebViewEx.isFeatureSupported(WebViewFeature.FORCE_DARK))
|
|
||||||
WebSettingsCompat.setForceDark(settings,
|
WebSettingsCompat.setForceDark(settings,
|
||||||
Helper.isDarkTheme(getContext()) ? FORCE_DARK_ON : FORCE_DARK_OFF);
|
Helper.isDarkTheme(getContext()) ? FORCE_DARK_ON : FORCE_DARK_OFF);
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,10 @@ import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.BlendMode;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
|
import android.graphics.PorterDuff;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.util.Pair;
|
import android.util.Pair;
|
||||||
|
@ -104,23 +107,18 @@ public class WebViewEx extends WebView implements DownloadListener, View.OnLongC
|
||||||
int zoom = prefs.getInt("view_zoom", compact ? 0 : 1);
|
int zoom = prefs.getInt("view_zoom", compact ? 0 : 1);
|
||||||
int message_zoom = prefs.getInt("message_zoom", 100);
|
int message_zoom = prefs.getInt("message_zoom", 100);
|
||||||
boolean monospaced = prefs.getBoolean("monospaced", false);
|
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();
|
WebSettings settings = getSettings();
|
||||||
|
|
||||||
boolean forced = false;
|
|
||||||
boolean dark = Helper.isDarkTheme(context);
|
boolean dark = Helper.isDarkTheme(context);
|
||||||
if (html_dark &&
|
if (WebViewEx.isFeatureSupported(WebViewFeature.FORCE_DARK)) {
|
||||||
WebViewEx.isFeatureSupported(WebViewFeature.FORCE_DARK)) {
|
|
||||||
WebSettingsCompat.setForceDark(settings, dark ? FORCE_DARK_ON : FORCE_DARK_OFF);
|
WebSettingsCompat.setForceDark(settings, dark ? FORCE_DARK_ON : FORCE_DARK_OFF);
|
||||||
forced = true;
|
setBackgroundColor(Color.TRANSPARENT);
|
||||||
|
} else {
|
||||||
|
if (!dark)
|
||||||
|
setBackgroundColor(Color.TRANSPARENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
setBackgroundColor(dark && !forced
|
|
||||||
? Color.WHITE
|
|
||||||
: ColorUtils.setAlphaComponent(Color.WHITE, 127));
|
|
||||||
|
|
||||||
float fontSize = 16f /* Default */ * message_zoom / 100f;
|
float fontSize = 16f /* Default */ * message_zoom / 100f;
|
||||||
if (zoom == 0 /* small */)
|
if (zoom == 0 /* small */)
|
||||||
fontSize *= HtmlHelper.FONT_SMALL;
|
fontSize *= HtmlHelper.FONT_SMALL;
|
||||||
|
@ -178,7 +176,7 @@ public class WebViewEx extends WebView implements DownloadListener, View.OnLongC
|
||||||
});
|
});
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
|
||||||
setOnScrollChangeListener(new View.OnScrollChangeListener() {
|
setOnScrollChangeListener(new OnScrollChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onScrollChange(View v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
|
public void onScrollChange(View v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
|
||||||
Log.i("Scroll (x,y)=" + scrollX + "," + scrollY);
|
Log.i("Scroll (x,y)=" + scrollX + "," + scrollY);
|
||||||
|
|
|
@ -32,16 +32,6 @@
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/tvMessage" />
|
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
|
<CheckBox
|
||||||
android:id="@+id/cbAlwaysImages"
|
android:id="@+id/cbAlwaysImages"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
@ -50,7 +40,7 @@
|
||||||
android:text="@string/title_ask_show_html_images"
|
android:text="@string/title_ask_show_html_images"
|
||||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/cbDark" />
|
app:layout_constraintTop_toBottomOf="@id/tvDark" />
|
||||||
|
|
||||||
<CheckBox
|
<CheckBox
|
||||||
android:id="@+id/cbNotAgain"
|
android:id="@+id/cbNotAgain"
|
||||||
|
|
|
@ -1101,7 +1101,6 @@
|
||||||
<string name="title_ask_delete_rule">Delete rule permanently?</string>
|
<string name="title_ask_delete_rule">Delete rule permanently?</string>
|
||||||
<string name="title_ask_discard">Discard draft?</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">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_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_html_images">Always show images on showing original messages</string>
|
||||||
<string name="title_ask_show_image">Showing images can leak privacy sensitive information</string>
|
<string name="title_ask_show_image">Showing images can leak privacy sensitive information</string>
|
||||||
|
|
Loading…
Reference in New Issue