Allow selecting no send font

pull/206/head
M66B 4 years ago
parent 5364c539eb
commit 02d0e1b28c

@ -158,6 +158,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
String[] fontNameValues = getResources().getStringArray(R.array.fontNameValues); String[] fontNameValues = getResources().getStringArray(R.array.fontNameValues);
List<CharSequence> fn = new ArrayList<>(); List<CharSequence> fn = new ArrayList<>();
fn.add("-");
for (int i = 0; i < fontNameNames.length; i++) { for (int i = 0; i < fontNameNames.length; i++) {
SpannableStringBuilder ssb = new SpannableStringBuilderEx(fontNameNames[i]); SpannableStringBuilder ssb = new SpannableStringBuilderEx(fontNameNames[i]);
ssb.setSpan(new TypefaceSpan(fontNameValues[i]), 0, ssb.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); ssb.setSpan(new TypefaceSpan(fontNameValues[i]), 0, ssb.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
@ -291,7 +292,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
spComposeFont.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { spComposeFont.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override @Override
public void onItemSelected(AdapterView<?> adapterView, View view, int position, long id) { public void onItemSelected(AdapterView<?> adapterView, View view, int position, long id) {
String value = fontNameValues[position]; String value = (position == 0 ? "" : fontNameValues[position - 1]);
boolean monospaced = prefs.getBoolean("monospaced", false); boolean monospaced = prefs.getBoolean("monospaced", false);
if (value.equals(monospaced ? "monospace" : "sans-serif")) if (value.equals(monospaced ? "monospace" : "sans-serif"))
prefs.edit().remove("compose_font").apply(); prefs.edit().remove("compose_font").apply();
@ -555,7 +556,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
String[] fontNameValues = getResources().getStringArray(R.array.fontNameValues); String[] fontNameValues = getResources().getStringArray(R.array.fontNameValues);
for (int pos = 0; pos < fontNameValues.length; pos++) for (int pos = 0; pos < fontNameValues.length; pos++)
if (fontNameValues[pos].equals(compose_font)) { if (fontNameValues[pos].equals(compose_font)) {
spComposeFont.setSelection(pos); spComposeFont.setSelection(pos + 1);
break; break;
} }

@ -704,15 +704,16 @@ public class MessageHelper {
if (auto_link) if (auto_link)
HtmlHelper.autoLink(document); HtmlHelper.autoLink(document);
for (Element child : document.body().children()) if (!TextUtils.isEmpty(compose_font))
if (!TextUtils.isEmpty(child.text()) && for (Element child : document.body().children())
TextUtils.isEmpty(child.attr("fairemail"))) { if (!TextUtils.isEmpty(child.text()) &&
String old = child.attr("style"); TextUtils.isEmpty(child.attr("fairemail"))) {
String style = HtmlHelper.mergeStyles( String old = child.attr("style");
"font-family:" + compose_font, old); String style = HtmlHelper.mergeStyles(
if (!old.equals(style)) "font-family:" + compose_font, old);
child.attr("style", style); if (!old.equals(style))
} child.attr("style", style);
}
document.select("div[fairemail=signature]").removeAttr("fairemail"); document.select("div[fairemail=signature]").removeAttr("fairemail");
document.select("div[fairemail=reference]").removeAttr("fairemail"); document.select("div[fairemail=reference]").removeAttr("fairemail");

Loading…
Cancel
Save