mirror of
https://github.com/M66B/FairEmail.git
synced 2026-01-14 16:49:49 +01:00
Added insert blockquote
This commit is contained in:
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user