Added clear style menu

This commit is contained in:
M66B 2018-11-05 11:18:49 +00:00
parent a9eb908ca8
commit b4e6169fb1
4 changed files with 22 additions and 2 deletions

View File

@ -411,6 +411,7 @@ public class FragmentCompose extends FragmentEx {
return true;
case R.id.menu_bold:
case R.id.menu_italic:
case R.id.menu_clear:
case R.id.menu_link:
onMenuStyle(item.getItemId());
return true;
@ -448,6 +449,10 @@ public class FragmentCompose extends FragmentEx {
case R.id.menu_italic:
s.setSpan(new StyleSpan(Typeface.ITALIC), start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
break;
case R.id.menu_clear:
for (Object span : s.getSpans(start, end, Object.class))
s.removeSpan(span);
break;
case R.id.menu_link:
Uri uri = null;
ClipboardManager cbm = getContext().getSystemService(ClipboardManager.class);
@ -796,8 +801,6 @@ public class FragmentCompose extends FragmentEx {
ImageSpan is = new ImageSpan(getContext(), Uri.parse("cid:" + BuildConfig.APPLICATION_ID + "." + attachment.id), ImageSpan.ALIGN_BASELINE);
s.setSpan(is, start, start + 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
String html = Html.toHtml(s);
Log.i(Helper.TAG, "html=" + html);
etBody.setText(Html.fromHtml(html, cidGetter, null));
}
}

View File

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M3.27,5L2,6.27l6.97,6.97L6.5,19h3l1.57,-3.66L16.73,21 18,19.73 3.55,5.27 3.27,5zM6,5v0.18L8.82,8h2.4l-0.72,1.68 2.1,2.1L14.21,8H20V5H6z"/>
</vector>

View File

@ -14,6 +14,12 @@
android:title="@string/title_style_italic"
app:showAsAction="ifRoom" />
<item
android:id="@+id/menu_clear"
android:icon="@drawable/baseline_format_clear_24"
android:title="@string/title_style_clear"
app:showAsAction="ifRoom" />
<item
android:id="@+id/menu_link"
android:icon="@drawable/baseline_insert_link_24"

View File

@ -223,6 +223,7 @@
<string name="title_clipboard_empty">Clipboard empty</string>
<string name="title_style_bold">Bold</string>
<string name="title_style_italic">Italic</string>
<string name="title_style_clear">Clear formatting</string>
<string name="title_style_link">Insert link</string>
<string name="title_style_image">Insert image</string>
<string name="title_add_attachment">Add attachment</string>