mirror of
https://github.com/M66B/FairEmail.git
synced 2025-01-31 19:41:19 +00:00
Left and right
This commit is contained in:
parent
1d337c151a
commit
2a7a4f659a
1 changed files with 14 additions and 5 deletions
|
@ -111,7 +111,8 @@ public class EditTextCompose extends FixedEditText {
|
|||
boolean undo_manager = prefs.getBoolean("undo_manager", false);
|
||||
|
||||
addTextChangedListener(new TextWatcher() {
|
||||
private Integer arrow;
|
||||
private Integer left;
|
||||
private Integer right;
|
||||
private boolean replacing = false;
|
||||
|
||||
@Override
|
||||
|
@ -127,21 +128,29 @@ public class EditTextCompose extends FixedEditText {
|
|||
if (c == '>' &&
|
||||
text.charAt(index - 1) == '-' &&
|
||||
text.charAt(index - 2) == '-') {
|
||||
arrow = index - 2;
|
||||
left = index - 2;
|
||||
} else if (c == '-' &&
|
||||
text.charAt(index - 1) == '-' &&
|
||||
text.charAt(index - 2) == '<') {
|
||||
right = index - 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable text) {
|
||||
if (arrow != null && !replacing)
|
||||
if (!replacing && (left != null || right != null))
|
||||
try {
|
||||
replacing = true;
|
||||
text.replace(arrow, arrow + 3, "→");
|
||||
if (left != null)
|
||||
text.replace(left, left + 3, "\u2192"); // ←
|
||||
else if (right != null)
|
||||
text.replace(right, right + 3, "\u2190"); // →
|
||||
} catch (Throwable ex) {
|
||||
Log.e(ex);
|
||||
} finally {
|
||||
arrow = null;
|
||||
left = null;
|
||||
right = null;
|
||||
replacing = false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue