From 48773c5b3fc71834c7d3bc166de143cc35d6068e Mon Sep 17 00:00:00 2001 From: M66B Date: Sat, 12 Feb 2022 10:04:05 +0100 Subject: [PATCH] Added option to disable bundle fonts --- .../email/FragmentOptionsDisplay.java | 12 +++- .../java/eu/faircode/email/StyleHelper.java | 61 ++++++++++--------- .../res/layout/fragment_options_display.xml | 14 ++++- app/src/main/res/values/strings.xml | 1 + 4 files changed, 58 insertions(+), 30 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsDisplay.java b/app/src/main/java/eu/faircode/email/FragmentOptionsDisplay.java index 44afb9ed3a..5a2a252ae0 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptionsDisplay.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptionsDisplay.java @@ -165,6 +165,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer private SwitchCompat swAttachmentsAlt; private SwitchCompat swThumbnails; + private SwitchCompat swBundledFonts; private SwitchCompat swParseClasses; private SwitchCompat swAuthentication; private SwitchCompat swAuthenticationIndicator; @@ -192,7 +193,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer "display_font", "contrast", "monospaced_pre", "background_color", "text_color", "text_size", "text_font", "text_align", "text_separators", "collapse_quotes", "image_placeholders", "inline_images", "button_extra", "attachments_alt", "thumbnails", - "parse_classes", + "bundled_fonts", "parse_classes", "authentication", "authentication_indicator" }; @@ -306,6 +307,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer swButtonExtra = view.findViewById(R.id.swButtonExtra); swAttachmentsAlt = view.findViewById(R.id.swAttachmentsAlt); swThumbnails = view.findViewById(R.id.swThumbnails); + swBundledFonts = view.findViewById(R.id.swBundledFonts); swParseClasses = view.findViewById(R.id.swParseClasses); swAuthentication = view.findViewById(R.id.swAuthentication); swAuthenticationIndicator = view.findViewById(R.id.swAuthenticationIndicator); @@ -1137,6 +1139,13 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer } }); + swBundledFonts.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { + prefs.edit().putBoolean("bundled_fonts", checked).apply(); + } + }); + swParseClasses.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { @@ -1378,6 +1387,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer swAttachmentsAlt.setChecked(prefs.getBoolean("attachments_alt", false)); swThumbnails.setChecked(prefs.getBoolean("thumbnails", true)); + swBundledFonts.setChecked(prefs.getBoolean("bundled_fonts", true)); swParseClasses.setChecked(prefs.getBoolean("parse_classes", true)); swAuthentication.setChecked(prefs.getBoolean("authentication", true)); swAuthenticationIndicator.setChecked(prefs.getBoolean("authentication_indicator", false)); diff --git a/app/src/main/java/eu/faircode/email/StyleHelper.java b/app/src/main/java/eu/faircode/email/StyleHelper.java index 8c597bf9a3..216c79ed5d 100644 --- a/app/src/main/java/eu/faircode/email/StyleHelper.java +++ b/app/src/main/java/eu/faircode/email/StyleHelper.java @@ -954,6 +954,9 @@ public class StyleHelper { if (TextUtils.isEmpty(family)) return Typeface.DEFAULT; + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); + boolean bundled_fonts = prefs.getBoolean("bundled_fonts", true); + List faces = new ArrayList<>(); for (String face : family.split(",")) faces.add(face @@ -965,34 +968,36 @@ public class StyleHelper { if (faces.contains("fairemail")) return ResourcesCompat.getFont(context, R.font.fantasy); - if (faces.contains("arimo") || - faces.contains("arial") || - faces.contains("verdana") || - faces.contains("helvetica")) - return ResourcesCompat.getFont(context, R.font.arimo); - - if (faces.contains("tinos") || - faces.contains("times new roman")) - return ResourcesCompat.getFont(context, R.font.tinos); - - if (faces.contains("cousine") || - faces.contains("courier new")) - return ResourcesCompat.getFont(context, R.font.cousine); - - if (faces.contains("lato") || - faces.contains("carlito") || - faces.contains("calibri")) - return ResourcesCompat.getFont(context, R.font.lato); - - if (faces.contains("caladea") || - faces.contains("cambo") || - faces.contains("cambria")) - return ResourcesCompat.getFont(context, R.font.caladea); - - if (faces.contains("opendyslexic") || - faces.contains("comic sans") || - faces.contains("comic sans ms")) - return ResourcesCompat.getFont(context, R.font.opendyslexic); + if (bundled_fonts) { + if (faces.contains("arimo") || + faces.contains("arial") || + faces.contains("verdana") || + faces.contains("helvetica")) + return ResourcesCompat.getFont(context, R.font.arimo); + + if (faces.contains("tinos") || + faces.contains("times new roman")) + return ResourcesCompat.getFont(context, R.font.tinos); + + if (faces.contains("cousine") || + faces.contains("courier new")) + return ResourcesCompat.getFont(context, R.font.cousine); + + if (faces.contains("lato") || + faces.contains("carlito") || + faces.contains("calibri")) + return ResourcesCompat.getFont(context, R.font.lato); + + if (faces.contains("caladea") || + faces.contains("cambo") || + faces.contains("cambria")) + return ResourcesCompat.getFont(context, R.font.caladea); + + if (faces.contains("opendyslexic") || + faces.contains("comic sans") || + faces.contains("comic sans ms")) + return ResourcesCompat.getFont(context, R.font.opendyslexic); + } for (String face : faces) { Typeface tf = Typeface.create(face, Typeface.NORMAL); diff --git a/app/src/main/res/layout/fragment_options_display.xml b/app/src/main/res/layout/fragment_options_display.xml index 36de7cdfce..f1fa19e1e9 100644 --- a/app/src/main/res/layout/fragment_options_display.xml +++ b/app/src/main/res/layout/fragment_options_display.xml @@ -1759,6 +1759,18 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> + + Show conversation action bar Use account color as background color for conversation action bar Colorize the Android navigation bar + Use bundled fonts Parse style sheets Show authentication warnings The underlying checks can be configured in the receive settings