mirror of
https://github.com/M66B/FairEmail.git
synced 2024-12-27 02:07:12 +00:00
Unquote
This commit is contained in:
parent
1cc9797987
commit
b1c2f82239
1 changed files with 13 additions and 3 deletions
|
@ -147,12 +147,22 @@ public class EditTextCompose extends FixedEditText {
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean surround(String before, String after) {
|
private boolean surround(String before, String after) {
|
||||||
|
Editable edit = getText();
|
||||||
int start = getSelectionStart();
|
int start = getSelectionStart();
|
||||||
int end = getSelectionEnd();
|
int end = getSelectionEnd();
|
||||||
boolean selection = (start >= 0 && start < end);
|
boolean selection = (edit != null && start >= 0 && start < end);
|
||||||
if (selection) {
|
if (selection) {
|
||||||
getText().insert(end, after);
|
int s = start - before.length();
|
||||||
getText().insert(start, before);
|
int e = end + after.length();
|
||||||
|
if (s >= 0 && e < length() &&
|
||||||
|
edit.subSequence(s, start).toString().equals(before) &&
|
||||||
|
edit.subSequence(end, e).toString().equals(after)) {
|
||||||
|
edit.delete(end, e);
|
||||||
|
edit.delete(s, start);
|
||||||
|
} else {
|
||||||
|
edit.insert(end, after);
|
||||||
|
edit.insert(start, before);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return selection;
|
return selection;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue