mirror of https://github.com/M66B/FairEmail.git
Added insert blockquote
This commit is contained in:
parent
493fef13e0
commit
da76047439
|
@ -13,6 +13,7 @@ import android.text.Spanned;
|
|||
import android.text.style.BulletSpan;
|
||||
import android.text.style.ForegroundColorSpan;
|
||||
import android.text.style.ImageSpan;
|
||||
import android.text.style.QuoteSpan;
|
||||
import android.text.style.RelativeSizeSpan;
|
||||
import android.text.style.StyleSpan;
|
||||
import android.text.style.TypefaceSpan;
|
||||
|
@ -119,6 +120,8 @@ public class StyleHelper {
|
|||
return setList(item);
|
||||
case R.id.group_style_font:
|
||||
return setFont(item);
|
||||
case R.id.group_style_blockquote:
|
||||
return setBlockquote(item);
|
||||
case R.id.group_style_clear:
|
||||
return clear(item);
|
||||
default:
|
||||
|
@ -294,6 +297,30 @@ public class StyleHelper {
|
|||
return true;
|
||||
}
|
||||
|
||||
private boolean setBlockquote(MenuItem item) {
|
||||
Context context = etBody.getContext();
|
||||
|
||||
int colorPrimary = Helper.resolveColor(context, R.attr.colorPrimary);
|
||||
int dp3 = Helper.dp2pixels(context, 3);
|
||||
int dp6 = Helper.dp2pixels(context, 6);
|
||||
|
||||
QuoteSpan[] spans = t.getSpans(s, e, QuoteSpan.class);
|
||||
for (QuoteSpan span : spans)
|
||||
t.removeSpan(span);
|
||||
|
||||
QuoteSpan q;
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P)
|
||||
q = new QuoteSpan(colorPrimary);
|
||||
else
|
||||
q = new QuoteSpan(colorPrimary, dp3, dp6);
|
||||
t.setSpan(q, s, e, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
|
||||
etBody.setText(t);
|
||||
etBody.setSelection(s, e);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean clear(MenuItem item) {
|
||||
for (Object span : t.getSpans(s, e, Object.class))
|
||||
if (!(span instanceof ImageSpan))
|
||||
|
|
|
@ -56,8 +56,16 @@
|
|||
</item>
|
||||
|
||||
<group
|
||||
android:id="@+id/group_style_clear"
|
||||
android:id="@+id/group_style_blockquote"
|
||||
android:orderInCategory="5">
|
||||
<item
|
||||
android:id="@+id/menu_style_blockquote"
|
||||
android:title="@string/title_style_blockquote" />
|
||||
</group>
|
||||
|
||||
<group
|
||||
android:id="@+id/group_style_clear"
|
||||
android:orderInCategory="6">
|
||||
<item
|
||||
android:id="@+id/menu_style_clear"
|
||||
android:title="@string/title_style_clear" />
|
||||
|
|
|
@ -938,6 +938,7 @@
|
|||
<string name="title_style_list_numbered">Numbered</string>
|
||||
<string name="title_style_font">Font</string>
|
||||
<string name="title_style_font_default">Default</string>
|
||||
<string name="title_style_blockquote">Block quote</string>
|
||||
<string name="title_style_clear">Clear formatting</string>
|
||||
<string name="title_style_link">Insert link</string>
|
||||
|
||||
|
|
Loading…
Reference in New Issue