Show font size appearance

pull/198/head
M66B 4 years ago
parent 6a24566ddc
commit 7f3e274504

@ -114,10 +114,10 @@ import static org.w3c.css.sac.Condition.SAC_CLASS_CONDITION;
public class HtmlHelper {
static final int PREVIEW_SIZE = 500; // characters
static final float FONT_SMALL = 0.8f;
static final float FONT_LARGE = 1.25f;
private static final int DEFAULT_FONT_SIZE = 16; // pixels
private static final int DEFAULT_FONT_SIZE_PT = 12; // points
private static final float FONT_SMALL = 0.8f;
private static final float FONT_LARGE = 1.25f;
private static final int GRAY_THRESHOLD = Math.round(255 * 0.2f);
private static final float MIN_LUMINANCE = 0.7f;
private static final int TAB_SIZE = 2;

@ -114,9 +114,22 @@ public class StyleHelper {
return true;
} else if (action == R.id.menu_style) {
PopupMenuLifecycle popupMenu = new PopupMenuLifecycle(anchor.getContext(), owner, anchor);
final Context context = anchor.getContext();
PopupMenuLifecycle popupMenu = new PopupMenuLifecycle(context, owner, anchor);
popupMenu.inflate(R.menu.popup_style);
popupMenu.insertIcons(anchor.getContext());
{
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};
for (int i = 0; i < ids.length; i++) {
SpannableStringBuilder ssb = new SpannableStringBuilder(context.getString(titles[i]));
ssb.setSpan(new RelativeSizeSpan(sizes[i]), 0, ssb.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
smenu.add(R.id.group_style_size, ids[i], i, ssb);
}
}
String[] fontNameNames = anchor.getResources().getStringArray(R.array.fontNameNames);
String[] fontNameValues = anchor.getResources().getStringArray(R.array.fontNameValues);
@ -138,6 +151,8 @@ public class StyleHelper {
popupMenu.getMenu().findItem(R.id.menu_style_list_increase).setVisible(level >= 0);
popupMenu.getMenu().findItem(R.id.menu_style_list_decrease).setVisible(level > 0);
popupMenu.insertIcons(context);
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {

Loading…
Cancel
Save