mirror of https://github.com/M66B/FairEmail.git
Added default display font setting
This commit is contained in:
parent
7acf8d3282
commit
e73057c52b
|
@ -4,6 +4,11 @@
|
|||
|
||||
### [Fulgurotherium](https://en.wikipedia.org/wiki/Fulgurotherium)
|
||||
|
||||
### Next version
|
||||
|
||||
* Added default display font setting
|
||||
* Small improvements and minor bug fixes
|
||||
|
||||
### 1.1834 - 2022-02-10
|
||||
|
||||
* Added Croscore and Crosextra fonts
|
||||
|
|
|
@ -4,6 +4,11 @@
|
|||
|
||||
### [Fulgurotherium](https://en.wikipedia.org/wiki/Fulgurotherium)
|
||||
|
||||
### Next version
|
||||
|
||||
* Added default display font setting
|
||||
* Small improvements and minor bug fixes
|
||||
|
||||
### 1.1834 - 2022-02-10
|
||||
|
||||
* Added Croscore and Crosextra fonts
|
||||
|
|
|
@ -284,7 +284,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
private boolean attachments_alt;
|
||||
private boolean thumbnails;
|
||||
private boolean contrast;
|
||||
private boolean monospaced;
|
||||
private String display_font;
|
||||
private boolean inline;
|
||||
private boolean collapse_quotes;
|
||||
private boolean authentication;
|
||||
|
@ -1403,7 +1403,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
tvPreview.setMaxLines(preview_lines);
|
||||
}
|
||||
tvPreview.setTypeface(
|
||||
monospaced ? Typeface.MONOSPACE : Typeface.DEFAULT,
|
||||
StyleHelper.getTypeface(display_font, context),
|
||||
preview_italic ? Typeface.ITALIC : Typeface.NORMAL);
|
||||
tvPreview.setText(message.preview);
|
||||
tvPreview.setVisibility(preview && !TextUtils.isEmpty(message.preview) ? View.VISIBLE : View.GONE);
|
||||
|
@ -2528,7 +2528,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
tvBody.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
|
||||
|
||||
tvBody.setTextColor(contrast ? textColorPrimary : colorRead);
|
||||
tvBody.setTypeface(monospaced ? Typeface.MONOSPACE : Typeface.DEFAULT);
|
||||
tvBody.setTypeface(StyleHelper.getTypeface(display_font, context));
|
||||
|
||||
tvBody.setVisibility(View.VISIBLE);
|
||||
wvBody.setVisibility(View.GONE);
|
||||
|
@ -6433,7 +6433,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
this.attachments_alt = prefs.getBoolean("attachments_alt", false);
|
||||
this.thumbnails = prefs.getBoolean("thumbnails", true);
|
||||
this.contrast = prefs.getBoolean("contrast", false);
|
||||
this.monospaced = prefs.getBoolean("monospaced", false);
|
||||
this.display_font = prefs.getString("display_font", "");
|
||||
this.inline = prefs.getBoolean("inline_images", false);
|
||||
this.collapse_quotes = prefs.getBoolean("collapse_quotes", false);
|
||||
this.authentication = prefs.getBoolean("authentication", true);
|
||||
|
|
|
@ -34,6 +34,7 @@ import android.os.Looper;
|
|||
import android.os.StrictMode;
|
||||
import android.os.SystemClock;
|
||||
import android.os.strictmode.Violation;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Printer;
|
||||
import android.webkit.CookieManager;
|
||||
|
||||
|
@ -559,6 +560,20 @@ public class ApplicationEx extends Application
|
|||
boolean ascending = prefs.getBoolean("ascending_list", false);
|
||||
editor.putBoolean("ascending_unified", ascending);
|
||||
}
|
||||
} else if (version < 1835) {
|
||||
boolean monospaced = prefs.getBoolean("monospaced", false);
|
||||
|
||||
String compose_font = prefs.getString("compose_font", "");
|
||||
if (TextUtils.isEmpty(compose_font))
|
||||
editor.putString("compose_font", monospaced ? "monospace" : "sans-serif");
|
||||
|
||||
if (monospaced) {
|
||||
String display_font = prefs.getString("display_font", "");
|
||||
if (TextUtils.isEmpty(display_font))
|
||||
editor.putString("display_font", "monospace");
|
||||
}
|
||||
|
||||
editor.remove("monospaced");
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && !BuildConfig.DEBUG)
|
||||
|
|
|
@ -98,8 +98,7 @@ public class FragmentAnswer extends FragmentBase {
|
|||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
final Context context = getContext();
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
boolean monospaced = prefs.getBoolean("monospaced", false);
|
||||
String compose_font = prefs.getString("compose_font", monospaced ? "monospace" : "sans-serif");
|
||||
String compose_font = prefs.getString("compose_font", "");
|
||||
boolean compact = prefs.getBoolean("compose_compact", false);
|
||||
int zoom = prefs.getInt("compose_zoom", compact ? 0 : 1);
|
||||
int message_zoom = prefs.getInt("message_zoom", 100);
|
||||
|
|
|
@ -48,7 +48,6 @@ import android.graphics.Color;
|
|||
import android.graphics.ImageDecoder;
|
||||
import android.graphics.Matrix;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Typeface;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.GradientDrawable;
|
||||
import android.net.ConnectivityManager;
|
||||
|
@ -272,8 +271,8 @@ public class FragmentCompose extends FragmentBase {
|
|||
private ContentResolver resolver;
|
||||
private AdapterAttachment adapter;
|
||||
|
||||
private boolean monospaced = false;
|
||||
private String compose_font;
|
||||
private String display_font;
|
||||
private boolean dsn = true;
|
||||
private Integer encrypt = null;
|
||||
private boolean media = true;
|
||||
|
@ -331,8 +330,8 @@ public class FragmentCompose extends FragmentBase {
|
|||
super.onCreate(savedInstanceState);
|
||||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
monospaced = prefs.getBoolean("monospaced", false);
|
||||
compose_font = prefs.getString("compose_font", monospaced ? "monospace" : "sans-serif");
|
||||
compose_font = prefs.getString("compose_font", "");
|
||||
display_font = prefs.getString("display_font", "");
|
||||
media = prefs.getBoolean("compose_media", true);
|
||||
compact = prefs.getBoolean("compose_compact", false);
|
||||
zoom = prefs.getInt("compose_zoom", compact ? 0 : 1);
|
||||
|
@ -751,7 +750,7 @@ public class FragmentCompose extends FragmentBase {
|
|||
}
|
||||
});
|
||||
|
||||
tvSignature.setTypeface(monospaced ? Typeface.MONOSPACE : Typeface.DEFAULT);
|
||||
tvSignature.setTypeface(StyleHelper.getTypeface(compose_font, getContext()));
|
||||
|
||||
cbSignature.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
|
@ -828,7 +827,7 @@ public class FragmentCompose extends FragmentBase {
|
|||
});
|
||||
|
||||
etBody.setTypeface(StyleHelper.getTypeface(compose_font, getContext()));
|
||||
tvReference.setTypeface(monospaced ? Typeface.MONOSPACE : Typeface.DEFAULT);
|
||||
tvReference.setTypeface(StyleHelper.getTypeface(display_font, getContext()));
|
||||
|
||||
tvReference.setMovementMethod(new ArrowKeyMovementMethod() {
|
||||
@Override
|
||||
|
|
|
@ -145,7 +145,7 @@ public class FragmentOptions extends FragmentBase {
|
|||
"subject_top", "subject_italic", "highlight_subject", "font_size_subject", "subject_ellipsize",
|
||||
"keywords_header", "labels_header", "flags", "flags_background", "preview", "preview_italic", "preview_lines",
|
||||
"message_zoom", "overview_mode", "override_width", "addresses", "button_extra", "attachments_alt", "thumbnails",
|
||||
"contrast", "monospaced", "monospaced_pre",
|
||||
"contrast", "display_font", "monospaced_pre",
|
||||
"background_color", "text_color", "text_size", "text_font", "text_align", "text_separators",
|
||||
"collapse_quotes", "image_placeholders", "inline_images",
|
||||
"seekbar", "actionbar", "actionbar_color",
|
||||
|
|
|
@ -26,6 +26,9 @@ import android.graphics.Bitmap;
|
|||
import android.graphics.Color;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.Spanned;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
|
@ -34,6 +37,7 @@ import android.view.View;
|
|||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.ImageButton;
|
||||
|
@ -55,6 +59,8 @@ import com.flask.colorpicker.builder.ColorPickerClickListener;
|
|||
import com.flask.colorpicker.builder.ColorPickerDialogBuilder;
|
||||
|
||||
import java.text.NumberFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class FragmentOptionsDisplay extends FragmentBase implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
private Button btnTheme;
|
||||
|
@ -145,7 +151,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
|
|||
private SwitchCompat swOverrideWidth;
|
||||
|
||||
private SwitchCompat swContrast;
|
||||
private SwitchCompat swMonospaced;
|
||||
private Spinner spDisplayFont;
|
||||
private SwitchCompat swMonospacedPre;
|
||||
private SwitchCompat swBackgroundColor;
|
||||
private SwitchCompat swTextColor;
|
||||
|
@ -183,7 +189,8 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
|
|||
"keywords_header", "labels_header", "flags", "flags_background",
|
||||
"preview", "preview_italic", "preview_lines",
|
||||
"addresses",
|
||||
"message_zoom", "overview_mode", "override_width", "contrast", "monospaced", "monospaced_pre",
|
||||
"message_zoom", "overview_mode", "override_width",
|
||||
"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",
|
||||
|
@ -286,7 +293,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
|
|||
swOverviewMode = view.findViewById(R.id.swOverviewMode);
|
||||
swOverrideWidth = view.findViewById(R.id.swOverrideWidth);
|
||||
swContrast = view.findViewById(R.id.swContrast);
|
||||
swMonospaced = view.findViewById(R.id.swMonospaced);
|
||||
spDisplayFont = view.findViewById(R.id.spDisplayFont);
|
||||
swMonospacedPre = view.findViewById(R.id.swMonospacedPre);
|
||||
swBackgroundColor = view.findViewById(R.id.swBackgroundColor);
|
||||
swTextColor = view.findViewById(R.id.swTextColor);
|
||||
|
@ -306,6 +313,22 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
|
|||
|
||||
grpGravatars = view.findViewById(R.id.grpGravatars);
|
||||
|
||||
List<StyleHelper.FontDescriptor> fonts = StyleHelper.getFonts(getContext());
|
||||
|
||||
List<CharSequence> fn = new ArrayList<>();
|
||||
fn.add("-");
|
||||
for (int i = 0; i < fonts.size(); i++) {
|
||||
StyleHelper.FontDescriptor font = fonts.get(i);
|
||||
SpannableStringBuilder ssb = new SpannableStringBuilderEx(font.toString());
|
||||
ssb.setSpan(StyleHelper.getTypefaceSpan(font.type, getContext()),
|
||||
0, ssb.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
fn.add(ssb);
|
||||
}
|
||||
|
||||
ArrayAdapter<CharSequence> adapter = new ArrayAdapter<>(getContext(), android.R.layout.simple_spinner_item, fn);
|
||||
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||
spDisplayFont.setAdapter(adapter);
|
||||
|
||||
setOptions();
|
||||
|
||||
// Wire controls
|
||||
|
@ -1004,10 +1027,18 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
|
|||
}
|
||||
});
|
||||
|
||||
swMonospaced.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
spDisplayFont.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
prefs.edit().putBoolean("monospaced", checked).apply();
|
||||
public void onItemSelected(AdapterView<?> adapterView, View view, int position, long id) {
|
||||
if (position == 0)
|
||||
prefs.edit().remove("display_font").apply();
|
||||
else
|
||||
prefs.edit().putString("display_font", fonts.get(position - 1).type).apply();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected(AdapterView<?> parent) {
|
||||
prefs.edit().remove("display_font").apply();
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -1323,7 +1354,17 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
|
|||
swOverrideWidth.setChecked(prefs.getBoolean("override_width", false));
|
||||
|
||||
swContrast.setChecked(prefs.getBoolean("contrast", false));
|
||||
swMonospaced.setChecked(prefs.getBoolean("monospaced", false));
|
||||
|
||||
String display_font = prefs.getString("display_font", "");
|
||||
List<StyleHelper.FontDescriptor> fonts = StyleHelper.getFonts(getContext());
|
||||
for (int pos = 0; pos < fonts.size(); pos++) {
|
||||
StyleHelper.FontDescriptor font = fonts.get(pos);
|
||||
if (font.type.equals(display_font)) {
|
||||
spDisplayFont.setSelection(pos + 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
swMonospacedPre.setChecked(prefs.getBoolean("monospaced_pre", false));
|
||||
swBackgroundColor.setChecked(prefs.getBoolean("background_color", false));
|
||||
swTextColor.setChecked(prefs.getBoolean("text_color", true));
|
||||
|
|
|
@ -24,8 +24,6 @@ import android.content.SharedPreferences;
|
|||
import android.os.Bundle;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.Spanned;
|
||||
import android.text.style.TypefaceSpan;
|
||||
import android.util.Pair;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
|
@ -306,12 +304,10 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
|
|||
spComposeFont.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> adapterView, View view, int position, long id) {
|
||||
String value = (position == 0 ? "" : fonts.get(position - 1).type);
|
||||
boolean monospaced = prefs.getBoolean("monospaced", false);
|
||||
if (value.equals(monospaced ? "monospace" : "sans-serif"))
|
||||
if (position == 0)
|
||||
prefs.edit().remove("compose_font").apply();
|
||||
else
|
||||
prefs.edit().putString("compose_font", value).apply();
|
||||
prefs.edit().putString("compose_font", fonts.get(position - 1).type).apply();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -574,8 +570,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
|
|||
swReplyAll.setChecked(prefs.getBoolean("reply_all", false));
|
||||
swSendPending.setChecked(prefs.getBoolean("send_pending", true));
|
||||
|
||||
boolean monospaced = prefs.getBoolean("monospaced", false);
|
||||
String compose_font = prefs.getString("compose_font", monospaced ? "monospace" : "sans-serif");
|
||||
String compose_font = prefs.getString("compose_font", "");
|
||||
List<StyleHelper.FontDescriptor> fonts = StyleHelper.getFonts(getContext());
|
||||
for (int pos = 0; pos < fonts.size(); pos++) {
|
||||
StyleHelper.FontDescriptor font = fonts.get(pos);
|
||||
|
|
|
@ -888,8 +888,7 @@ public class MessageHelper {
|
|||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
boolean format_flowed = prefs.getBoolean("format_flowed", false);
|
||||
boolean monospaced = prefs.getBoolean("monospaced", false);
|
||||
String compose_font = prefs.getString("compose_font", monospaced ? "monospace" : "sans-serif");
|
||||
String compose_font = prefs.getString("compose_font", "");
|
||||
boolean auto_link = prefs.getBoolean("auto_link", false);
|
||||
|
||||
// Build html body
|
||||
|
@ -919,7 +918,7 @@ public class MessageHelper {
|
|||
TextUtils.isEmpty(child.attr("fairemail"))) {
|
||||
String old = child.attr("style");
|
||||
String style = HtmlHelper.mergeStyles(
|
||||
"font-family:" + compose_font, old);
|
||||
"font-family:" + StyleHelper.getFamily(compose_font), old);
|
||||
if (!old.equals(style))
|
||||
child.attr("style", style);
|
||||
}
|
||||
|
|
|
@ -928,25 +928,32 @@ public class StyleHelper {
|
|||
}
|
||||
}
|
||||
|
||||
static TypefaceSpan getTypefaceSpan(String family, Context context) {
|
||||
static String getFamily(String family) {
|
||||
String faces = family.toLowerCase(Locale.ROOT);
|
||||
if (faces.contains("arimo"))
|
||||
family = "Arimo, Arial, Verdana, sans-serif";
|
||||
return "Arimo, Arial, Verdana, sans-serif";
|
||||
if (faces.contains("tinos"))
|
||||
family = "Tinos, Times New Roman, serif";
|
||||
return "Tinos, Times New Roman, serif";
|
||||
if (faces.contains("cousine"))
|
||||
family = "Cousine, Courier New, monospace";
|
||||
return "Cousine, Courier New, monospace";
|
||||
if (faces.contains("lato"))
|
||||
family = "Lato, Calibri, sans-serif";
|
||||
return "Lato, Calibri, sans-serif";
|
||||
if (faces.contains("cambo"))
|
||||
family = "Cambo, Cambria, serif";
|
||||
return "Cambo, Cambria, serif";
|
||||
if (faces.contains("comic sans"))
|
||||
family = "Comic Sans, Comic Sans MS, sans-serif";
|
||||
return "Comic Sans, Comic Sans MS, sans-serif";
|
||||
return family;
|
||||
}
|
||||
|
||||
static TypefaceSpan getTypefaceSpan(String family, Context context) {
|
||||
family = getFamily(family);
|
||||
return new CustomTypefaceSpan(family, getTypeface(family, context));
|
||||
}
|
||||
|
||||
static Typeface getTypeface(String family, Context context) {
|
||||
if (TextUtils.isEmpty(family))
|
||||
return Typeface.DEFAULT;
|
||||
|
||||
List<String> faces = new ArrayList<>();
|
||||
for (String face : family.split(","))
|
||||
faces.add(face
|
||||
|
|
|
@ -1518,16 +1518,27 @@
|
|||
app:layout_constraintTop_toBottomOf="@id/tvOverrideWidthHint"
|
||||
app:switchPadding="12dp" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/swMonospaced"
|
||||
<eu.faircode.email.FixedTextView
|
||||
android:id="@+id/tvDisplayFont"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:text="@string/title_advanced_monospaced"
|
||||
android:layout_marginEnd="48dp"
|
||||
android:text="@string/title_advanced_compose_font"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/swContrast"
|
||||
app:switchPadding="12dp" />
|
||||
app:layout_constraintTop_toBottomOf="@id/swContrast" />
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/spDisplayFont"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:entries="@array/fontNameNames"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvDisplayFont" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/swMonospacedPre"
|
||||
|
@ -1537,7 +1548,7 @@
|
|||
android:text="@string/title_advanced_monospaced_pre"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/swMonospaced"
|
||||
app:layout_constraintTop_toBottomOf="@id/spDisplayFont"
|
||||
app:switchPadding="12dp" />
|
||||
|
||||
<eu.faircode.email.FixedTextView
|
||||
|
|
|
@ -4,6 +4,11 @@
|
|||
|
||||
### [Fulgurotherium](https://en.wikipedia.org/wiki/Fulgurotherium)
|
||||
|
||||
### Next version
|
||||
|
||||
* Added default display font setting
|
||||
* Small improvements and minor bug fixes
|
||||
|
||||
### 1.1834 - 2022-02-10
|
||||
|
||||
* Added Croscore and Crosextra fonts
|
||||
|
|
Loading…
Reference in New Issue