MCPcopy Create free account
hub / github.com/M66B/FairEmail / selectFont

Method selectFont

app/src/main/java/eu/faircode/email/StyleHelper.java:785–812  ·  view source on GitHub ↗
(LifecycleOwner owner, View anchor, EditText etBody, int start, int end, boolean select)

Source from the content-addressed store, hash-verified

783 }
784
785 static boolean selectFont(LifecycleOwner owner, View anchor, EditText etBody, int start, int end, boolean select) {
786 Log.breadcrumb("style", "action", "selectFont");
787
788 Context context = anchor.getContext();
789 PopupMenuLifecycle popupMenu = new PopupMenuLifecycle(context, owner, anchor);
790
791 List<FontDescriptor> fonts = getFonts(context, false);
792 for (int i = 0; i < fonts.size(); i++) {
793 FontDescriptor font = fonts.get(i);
794 SpannableStringBuilder ssb = new SpannableStringBuilderEx(font.toString());
795 ssb.setSpan(getTypefaceSpan(font.type, context), 0, ssb.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
796 popupMenu.getMenu().add(font.custom ? group_style_font_custom : group_style_font_standard, i, 0, ssb)
797 .setIntent(new Intent().putExtra("face", font.type));
798 }
799 popupMenu.getMenu().add(group_style_font_standard, fonts.size(), 0, R.string.title_style_font_default)
800 .setIntent(new Intent());
801
802 popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
803 @Override
804 public boolean onMenuItemClick(MenuItem item) {
805 return setFont(etBody, start, end, item.getIntent().getStringExtra("face"), select);
806 }
807 });
808
809 popupMenu.show();
810
811 return true;
812 }
813
814 static boolean setFont(EditText etBody, int start, int end, String face, boolean select) {
815 Log.breadcrumb("style", "action", "font");

Callers 1

applyMethod · 0.95

Calls 11

breadcrumbMethod · 0.95
getFontsMethod · 0.95
toStringMethod · 0.95
setSpanMethod · 0.95
getTypefaceSpanMethod · 0.95
showMethod · 0.95
sizeMethod · 0.65
getMethod · 0.45
lengthMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected