mirror of
https://github.com/M66B/FairEmail.git
synced 2026-04-05 08:33:37 +02:00
Added extra small/large
This commit is contained in:
@@ -446,7 +446,12 @@ public class HtmlEx {
|
||||
}
|
||||
if (style[j] instanceof RelativeSizeSpan) {
|
||||
float sizeEm = ((RelativeSizeSpan) style[j]).getSizeChange();
|
||||
out.append(String.format("<span style=\"font-size:%.2fem;\">", sizeEm));
|
||||
if (sizeEm < 1)
|
||||
out.append(String.format("<span style=\"font-size:%s;\">",
|
||||
sizeEm < HtmlHelper.FONT_SMALL ? "x-small" : "small"));
|
||||
else if (sizeEm > 1)
|
||||
out.append(String.format("<span style=\"font-size:%s;\">",
|
||||
sizeEm > HtmlHelper.FONT_LARGE ? "x-large" : "large"));
|
||||
}
|
||||
if (style[j] instanceof ForegroundColorSpan) {
|
||||
int color = ((ForegroundColorSpan) style[j]).getForegroundColor();
|
||||
|
||||
@@ -132,8 +132,12 @@ import javax.mail.internet.MimeUtility;
|
||||
public class HtmlHelper {
|
||||
static final int PREVIEW_SIZE = 500; // characters
|
||||
|
||||
static final float FONT_SMALL = 0.8f;
|
||||
static final float FONT_LARGE = 1.25f;
|
||||
// https://drafts.csswg.org/css-fonts/#absolute-size-mapping
|
||||
static final float FONT_XSMALL = 0.6f; // 10px=0.625
|
||||
static final float FONT_SMALL = 0.8f; // 13px=0.8125
|
||||
// 16 px
|
||||
static final float FONT_LARGE = 1.25f; // 20px=1.2
|
||||
static final float FONT_XLARGE = 1.50f; // 24px=1.5
|
||||
|
||||
static final int MAX_FULL_TEXT_SIZE = 1024 * 1024; // characters
|
||||
static final int MAX_SHARE_TEXT_SIZE = 50 * 1024; // characters
|
||||
@@ -848,9 +852,9 @@ public class HtmlHelper {
|
||||
} else {
|
||||
if (!view) {
|
||||
if (fsize < 1)
|
||||
fsize = FONT_SMALL;
|
||||
fsize = (fsize < FONT_SMALL ? FONT_XSMALL : FONT_SMALL);
|
||||
else if (fsize > 1)
|
||||
fsize = FONT_LARGE;
|
||||
fsize = (fsize > FONT_LARGE ? FONT_XLARGE : FONT_LARGE);
|
||||
}
|
||||
element.attr("x-font-size", Float.toString(fsize));
|
||||
element.attr("x-font-size-rel", Float.toString(fsize / current));
|
||||
@@ -1919,15 +1923,17 @@ public class HtmlHelper {
|
||||
switch (value) {
|
||||
case "xx-small":
|
||||
case "x-small":
|
||||
return FONT_XSMALL;
|
||||
case "small":
|
||||
return FONT_SMALL;
|
||||
case "medium":
|
||||
return 1.0f;
|
||||
case "large":
|
||||
return FONT_LARGE;
|
||||
case "x-large":
|
||||
case "xx-large":
|
||||
case "xxx-large":
|
||||
return FONT_LARGE;
|
||||
return FONT_XLARGE;
|
||||
}
|
||||
|
||||
// Relative
|
||||
@@ -3780,17 +3786,6 @@ public class HtmlHelper {
|
||||
String value = param.substring(semi + 1).trim();
|
||||
|
||||
switch (key) {
|
||||
case "font-size":
|
||||
// @Google: why convert size to and from in a different way?
|
||||
String v = value.replace(',', '.');
|
||||
Float size = getFontSize(v, 1.0f);
|
||||
if (size != null) {
|
||||
if (size < 1.0f)
|
||||
span.tagName("small");
|
||||
else if (size > 1.0f)
|
||||
span.tagName("big");
|
||||
}
|
||||
break;
|
||||
case "text-align":
|
||||
sb.append(" display:block;");
|
||||
// fall through
|
||||
|
||||
@@ -163,9 +163,25 @@ public class StyleHelper {
|
||||
{
|
||||
SubMenu smenu = popupMenu.getMenu().findItem(R.id.menu_style_size).getSubMenu();
|
||||
smenu.clear();
|
||||
int[] ids = new int[]{R.id.menu_style_size_small, R.id.menu_style_size_medium, R.id.menu_style_size_large};
|
||||
int[] titles = new int[]{R.string.title_style_size_small, R.string.title_style_size_medium, R.string.title_style_size_large};
|
||||
float[] sizes = new float[]{HtmlHelper.FONT_SMALL, 1.0f, HtmlHelper.FONT_LARGE};
|
||||
int[] ids = new int[]{
|
||||
R.id.menu_style_size_xsmall,
|
||||
R.id.menu_style_size_small,
|
||||
R.id.menu_style_size_medium,
|
||||
R.id.menu_style_size_large,
|
||||
R.id.menu_style_size_xlarge
|
||||
};
|
||||
int[] titles = new int[]{
|
||||
R.string.title_style_size_xsmall,
|
||||
R.string.title_style_size_small,
|
||||
R.string.title_style_size_medium,
|
||||
R.string.title_style_size_large,
|
||||
R.string.title_style_size_xlarge};
|
||||
float[] sizes = new float[]{
|
||||
HtmlHelper.FONT_XSMALL,
|
||||
HtmlHelper.FONT_SMALL,
|
||||
1.0f,
|
||||
HtmlHelper.FONT_LARGE,
|
||||
HtmlHelper.FONT_XLARGE};
|
||||
for (int i = 0; i < ids.length; i++) {
|
||||
SpannableStringBuilder ssb = new SpannableStringBuilderEx(context.getString(titles[i]));
|
||||
ssb.setSpan(new RelativeSizeSpan(sizes[i]), 0, ssb.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
@@ -252,10 +268,14 @@ public class StyleHelper {
|
||||
Log.breadcrumb("style", "action", "size");
|
||||
|
||||
Float size;
|
||||
if (item.getItemId() == R.id.menu_style_size_small)
|
||||
if (item.getItemId() == R.id.menu_style_size_xsmall)
|
||||
size = HtmlHelper.FONT_XSMALL;
|
||||
else if (item.getItemId() == R.id.menu_style_size_small)
|
||||
size = HtmlHelper.FONT_SMALL;
|
||||
else if (item.getItemId() == R.id.menu_style_size_large)
|
||||
size = HtmlHelper.FONT_LARGE;
|
||||
else if (item.getItemId() == R.id.menu_style_size_xlarge)
|
||||
size = HtmlHelper.FONT_XLARGE;
|
||||
else
|
||||
size = null;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user