From 7ec3cd72db018661f861c50255560c5f1cecc182 Mon Sep 17 00:00:00 2001 From: M66B Date: Sat, 18 Sep 2021 10:57:31 +0200 Subject: [PATCH] Replaced default dark by force light theme --- CHANGELOG.md | 5 + app/build.gradle | 2 +- app/src/main/assets/CHANGELOG.md | 5 + .../eu/faircode/email/AdapterMessage.java | 114 +++++++++++------- .../java/eu/faircode/email/WebViewEx.java | 10 +- app/src/main/res/drawable/lightdark.xml | 9 ++ .../res/drawable/twotone_dark_mode_24.xml | 15 +++ .../res/drawable/twotone_light_mode_24.xml | 15 +++ app/src/main/res/layout/dialog_buttons.xml | 15 ++- app/src/main/res/layout/dialog_show_full.xml | 12 +- .../res/layout/include_message_navigation.xml | 14 ++- app/src/main/res/menu/popup_message_more.xml | 6 + app/src/main/res/values/strings.xml | 2 +- 13 files changed, 160 insertions(+), 64 deletions(-) create mode 100644 app/src/main/res/drawable/lightdark.xml create mode 100644 app/src/main/res/drawable/twotone_dark_mode_24.xml create mode 100644 app/src/main/res/drawable/twotone_light_mode_24.xml diff --git a/CHANGELOG.md b/CHANGELOG.md index 25edb50302..5828cd3ba1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ ### [Yaverlandia](https://en.wikipedia.org/wiki/Yaverlandia) +### 1.1726-b + +* Following dark/light theme for original message view +* Added message menu item / optional button to force light theme for original message view + ### 1.1726 * Show in-app changelog after updating diff --git a/app/build.gradle b/app/build.gradle index 5b837813d5..2386c3f451 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -133,7 +133,7 @@ android { productFlavors { github { dimension "all" - buildConfigField "String", "REVISION", "\"a\"" + buildConfigField "String", "REVISION", "\"b\"" buildConfigField "boolean", "BETA_RELEASE", "true" buildConfigField "boolean", "PLAY_STORE_RELEASE", "false" buildConfigField "boolean", "AMAZON_RELEASE", "false" diff --git a/app/src/main/assets/CHANGELOG.md b/app/src/main/assets/CHANGELOG.md index 25edb50302..5828cd3ba1 100644 --- a/app/src/main/assets/CHANGELOG.md +++ b/app/src/main/assets/CHANGELOG.md @@ -2,6 +2,11 @@ ### [Yaverlandia](https://en.wikipedia.org/wiki/Yaverlandia) +### 1.1726-b + +* Following dark/light theme for original message view +* Added message menu item / optional button to force light theme for original message view + ### 1.1726 * Show in-app changelog after updating diff --git a/app/src/main/java/eu/faircode/email/AdapterMessage.java b/app/src/main/java/eu/faircode/email/AdapterMessage.java index 2a4d1c7925..e93fa35f7c 100644 --- a/app/src/main/java/eu/faircode/email/AdapterMessage.java +++ b/app/src/main/java/eu/faircode/email/AdapterMessage.java @@ -430,6 +430,7 @@ public class AdapterMessage extends RecyclerView.Adapter 0 || tos > 0) ? View.VISIBLE : View.GONE); ibTranslate.setVisibility(tools && !outbox && button_translate && DeepL.isAvailable(context) && message.content ? View.VISIBLE : View.GONE); + ibForceLight.setVisibility(tools && full && dark && button_force_light && message.content ? View.VISIBLE : View.GONE); + ibForceLight.setImageLevel(force_light ? 1 : 0); ibHide.setVisibility(tools && button_hide && !outbox ? View.VISIBLE : View.GONE); ibSeen.setVisibility(tools && button_seen && !outbox && seen ? View.VISIBLE : View.GONE); ibAnswer.setVisibility(!tools || outbox || (!expand_all && expand_one) || !threading ? View.GONE : View.VISIBLE); @@ -2218,26 +2231,7 @@ public class AdapterMessage extends RecyclerView.Adapter() { @Override @@ -4387,6 +4398,7 @@ public class AdapterMessage extends RecyclerView.Adapter= Build.VERSION_CODES.O) settings.setSafeBrowsingEnabled(safe_browsing); - if (html_dark && - WebViewEx.isFeatureSupported(WebViewFeature.FORCE_DARK)) - WebSettingsCompat.setForceDark(settings, - Helper.isDarkTheme(getContext()) ? FORCE_DARK_ON : FORCE_DARK_OFF); + boolean dark = (Helper.isDarkTheme(context) && !force_light); + if (WebViewEx.isFeatureSupported(WebViewFeature.FORCE_DARK)) + WebSettingsCompat.setForceDark(settings, dark ? FORCE_DARK_ON : FORCE_DARK_OFF); settings.setLoadsImagesAutomatically(true); settings.setBlockNetworkLoads(false); @@ -7378,6 +7405,7 @@ public class AdapterMessage extends RecyclerView.Adapter position, IWebView intf) { + void init(int height, float size, Pair position, boolean force_light, IWebView intf) { Log.i("Init height=" + height + " size=" + size); this.height = (height == 0 ? getMinimumHeight() : height); @@ -104,16 +104,12 @@ 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 dark = Helper.isDarkTheme(context); - if (html_dark && - WebViewEx.isFeatureSupported(WebViewFeature.FORCE_DARK)) + boolean dark = (Helper.isDarkTheme(context) && !force_light); + if (WebViewEx.isFeatureSupported(WebViewFeature.FORCE_DARK)) WebSettingsCompat.setForceDark(settings, dark ? FORCE_DARK_ON : FORCE_DARK_OFF); - if (!dark) setBackgroundColor(ColorUtils.setAlphaComponent(Color.WHITE, 127)); diff --git a/app/src/main/res/drawable/lightdark.xml b/app/src/main/res/drawable/lightdark.xml new file mode 100644 index 0000000000..31aed2733a --- /dev/null +++ b/app/src/main/res/drawable/lightdark.xml @@ -0,0 +1,9 @@ + + + + + diff --git a/app/src/main/res/drawable/twotone_dark_mode_24.xml b/app/src/main/res/drawable/twotone_dark_mode_24.xml new file mode 100644 index 0000000000..0bec87e5c2 --- /dev/null +++ b/app/src/main/res/drawable/twotone_dark_mode_24.xml @@ -0,0 +1,15 @@ + + + + diff --git a/app/src/main/res/drawable/twotone_light_mode_24.xml b/app/src/main/res/drawable/twotone_light_mode_24.xml new file mode 100644 index 0000000000..ae5adcf71c --- /dev/null +++ b/app/src/main/res/drawable/twotone_light_mode_24.xml @@ -0,0 +1,15 @@ + + + + diff --git a/app/src/main/res/layout/dialog_buttons.xml b/app/src/main/res/layout/dialog_buttons.xml index 995f6cb8dd..14cd4d1ebf 100644 --- a/app/src/main/res/layout/dialog_buttons.xml +++ b/app/src/main/res/layout/dialog_buttons.xml @@ -200,6 +200,19 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/cbSearchText" /> + + + app:layout_constraintTop_toBottomOf="@id/cbForceLight" /> - - + app:layout_constraintTop_toBottomOf="@id/tvDark" /> + + + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 1562e754d0..314e3e72d9 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -998,6 +998,7 @@ Edit as new Edit local notes Create rule … + Force light theme Share Add to calendar Add shortcut @@ -1101,7 +1102,6 @@ Delete rule permanently? Discard draft? Showing the original message can leak privacy sensitive information - Use dark theme Displaying the original message on a dark background is not possible as it may make dark texts and images invisible Always show images on showing original messages Showing images can leak privacy sensitive information