mirror of
https://github.com/M66B/FairEmail.git
synced 2025-01-01 12:44:42 +00:00
Refactoring
This commit is contained in:
parent
3b7a60fdef
commit
412e726fda
3 changed files with 24 additions and 40 deletions
|
@ -13,6 +13,7 @@ import android.text.style.StyleSpan;
|
|||
import android.text.style.TypefaceSpan;
|
||||
import android.text.style.URLSpan;
|
||||
import android.text.style.UnderlineSpan;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
|
@ -93,6 +94,11 @@ public class StyleHelper {
|
|||
PopupMenu popupMenu = new PopupMenu(anchor.getContext(), anchor);
|
||||
popupMenu.inflate(R.menu.popup_style);
|
||||
|
||||
String[] fontNames = anchor.getResources().getStringArray(R.array.fontNameNames);
|
||||
for (int i = 0; i < fontNames.length; i++)
|
||||
popupMenu.getMenu().add(R.id.group_style_font, i, Menu.NONE, fontNames[i]);
|
||||
popupMenu.getMenu().add(R.id.group_style_font, fontNames.length, Menu.NONE, R.string.title_style_font_default);
|
||||
|
||||
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
|
@ -189,23 +195,9 @@ public class StyleHelper {
|
|||
for (TypefaceSpan span : spans)
|
||||
t.removeSpan(span);
|
||||
|
||||
String face;
|
||||
switch (item.getItemId()) {
|
||||
case R.id.menu_style_font_cursive:
|
||||
face = "cursive";
|
||||
break;
|
||||
case R.id.menu_style_font_serif:
|
||||
face = "serif";
|
||||
break;
|
||||
case R.id.menu_style_font_sans_serif:
|
||||
face = "sans-serif";
|
||||
break;
|
||||
case R.id.menu_style_font_monospace:
|
||||
face = "monospace";
|
||||
break;
|
||||
default:
|
||||
face = null;
|
||||
}
|
||||
int id = item.getItemId();
|
||||
String[] names = anchor.getResources().getStringArray(R.array.fontNameValues);
|
||||
String face = (id < names.length ? names[id] : null);
|
||||
|
||||
if (face != null)
|
||||
t.setSpan(new TypefaceSpan(face), s, e, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
|
|
|
@ -20,23 +20,7 @@
|
|||
android:title="@string/title_style_color" />
|
||||
</group>
|
||||
|
||||
<group android:id="@+id/group_style_font">
|
||||
<item
|
||||
android:id="@+id/menu_style_font_cursive"
|
||||
android:title="@string/title_style_font_cursive" />
|
||||
<item
|
||||
android:id="@+id/menu_style_font_serif"
|
||||
android:title="@string/title_style_font_serif" />
|
||||
<item
|
||||
android:id="@+id/menu_style_font_sans_serif"
|
||||
android:title="@string/title_style_font_sans_serif" />
|
||||
<item
|
||||
android:id="@+id/menu_style_font_monospace"
|
||||
android:title="@string/title_style_font_monospace" />
|
||||
<item
|
||||
android:id="@+id/menu_style_font_default"
|
||||
android:title="@string/title_style_font_default" />
|
||||
</group>
|
||||
<group android:id="@+id/group_style_font" />
|
||||
|
||||
<group android:id="@+id/group_style_clear">
|
||||
<item
|
||||
|
|
|
@ -874,14 +874,8 @@
|
|||
<string name="title_style_size_small">Small</string>
|
||||
<string name="title_style_size_medium">Medium</string>
|
||||
<string name="title_style_size_large">Large</string>
|
||||
|
||||
<string name="title_style_font">Font</string>
|
||||
<string name="title_style_font_cursive">Cursive</string>
|
||||
<string name="title_style_font_serif">Serif</string>
|
||||
<string name="title_style_font_sans_serif">Sans-serif</string>
|
||||
<string name="title_style_font_monospace">Monospace</string>
|
||||
<string name="title_style_font_default">Default</string>
|
||||
|
||||
<string name="title_style_color">Color …</string>
|
||||
<string name="title_style_clear">Clear formatting</string>
|
||||
<string name="title_style_link">Insert link</string>
|
||||
|
@ -1583,6 +1577,20 @@
|
|||
<item>50000000</item>
|
||||
</integer-array>
|
||||
|
||||
<string-array name="fontNameNames">
|
||||
<item>Cursive</item>
|
||||
<item>Serif</item>
|
||||
<item>Sans-serif</item>
|
||||
<item>Monospace</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="fontNameValues" translatable="false">
|
||||
<item>cursive</item>
|
||||
<item>serif</item>
|
||||
<item>sans-serif</item>
|
||||
<item>monospace</item>
|
||||
</string-array>
|
||||
|
||||
<string name="fingerprint" translatable="false">17BA15C1AF55D925F98B99CEA4375D4CDF4C174B</string>
|
||||
<string name="public_key" translatable="false">MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtFbxEbzL8u5accPGgBw/XdyiSS5BBE6ZQ9ELpKyJ/OQN+kdYniCAOw3lsQ/GuJScy4Y2HobqbBgLL8GLHG+Yu2EHC9dLjA3v2Mc25vvnfn86BsrpQvz1poN2n+roTBdq09FWbtebJ8m0hDBVmtfRi7RhTKIL4No3kodLhksdnucKjcFheubebWKgpmvbmw7NwuELhaZmyhw8WTtnQ4rZPMhjY1JJZgzwNExXgD7zzg4pJPkuQlfkuRkkvBpHpi3C7VDnYjrBlLHngI4wv3wxQBVwJqlvAT9PmX8dOVnTsWWdJdLQBZVWphuqVY54kjBIovN+o8w03WjsV9QiOQq+XwIDAQAB</string>
|
||||
</resources>
|
||||
|
|
Loading…
Reference in a new issue