Indent improvements

pull/199/head
M66B 4 years ago
parent 8a6b0914be
commit 3a70fc1b2a

@ -648,6 +648,18 @@ public class FragmentCompose extends FragmentBase {
etBody.setSelection(added);
}
// Escape indent at end
IndentSpan[] indents = text.getSpans(added + 1, added + 1, IndentSpan.class);
for (IndentSpan indent : indents) {
int s = text.getSpanStart(indent);
int e = text.getSpanEnd(indent);
int f = text.getSpanFlags(indent);
if (e - 1 > s && added + 2 == e) {
text.removeSpan(indent);
text.setSpan(new IndentSpan(indent.getLeadingMargin(true)), s, e - 1, f);
}
}
boolean renum = false;
BulletSpan[] bullets = text.getSpans(added + 1, added + 1, BulletSpan.class);
for (BulletSpan span : bullets) {

@ -169,11 +169,22 @@ public class StyleHelper {
level = ((NumberSpan) span).getLevel();
else if (span instanceof BulletSpanEx)
level = ((BulletSpanEx) span).getLevel();
popupMenu.getMenu().findItem(R.id.menu_style_list_increase).setVisible(level >= 0);
popupMenu.getMenu().findItem(R.id.menu_style_list_decrease).setVisible(level > 0);
boolean decrease = false;
IndentSpan[] indents = edit.getSpans(start, end, IndentSpan.class);
popupMenu.getMenu().findItem(R.id.menu_style_indentation_decrease).setEnabled(indents.length > 0);
for (IndentSpan indent : indents) {
int s = edit.getSpanStart(indent);
int e = edit.getSpanEnd(indent);
if (s >= start && e <= end) {
decrease = true;
break;
}
}
popupMenu.getMenu().findItem(R.id.menu_style_indentation_decrease).setEnabled(decrease);
popupMenu.insertIcons(context);
@ -541,8 +552,12 @@ public class StyleHelper {
if (item.getItemId() == R.id.menu_style_indentation_decrease) {
IndentSpan[] indents = edit.getSpans(paragraph.first, paragraph.second, IndentSpan.class);
if (indents.length > 0)
edit.removeSpan(indents[0]);
for (IndentSpan indent : indents) {
int s = edit.getSpanStart(indent);
int e = edit.getSpanEnd(indent);
if (s >= start && e <= end)
edit.removeSpan(indent);
}
} else {
Context context = etBody.getContext();
int intentSize = context.getResources().getDimensionPixelSize(R.dimen.indent_size);

Loading…
Cancel
Save