Long press to select email addresses

This commit is contained in:
M66B 2019-10-20 13:33:21 +02:00
parent 3f8118a707
commit dd287cce20
1 changed files with 25 additions and 0 deletions

View File

@ -285,14 +285,39 @@ public class FragmentCompose extends FragmentBase {
// Wire controls
spIdentity.setOnItemSelectedListener(identitySelected);
View.OnLongClickListener longClickListener = new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
EditText et = (EditText) v;
int sstart = et.getSelectionStart();
int send = et.getSelectionEnd();
String text = et.getText().toString();
if (send < 0 || send > sstart)
return false;
int ecomma = text.indexOf(',', sstart);
if (ecomma < 0)
return false;
int scomma = text.substring(0, ecomma).lastIndexOf(',');
scomma = (scomma < 0 ? 0 : scomma + 1);
et.setSelection(scomma, ecomma + 1);
return false;
}
};
etTo.setMaxLines(Integer.MAX_VALUE);
etTo.setHorizontallyScrolling(false);
etTo.setOnLongClickListener(longClickListener);
etCc.setMaxLines(Integer.MAX_VALUE);
etCc.setHorizontallyScrolling(false);
etCc.setOnLongClickListener(longClickListener);
etBcc.setMaxLines(Integer.MAX_VALUE);
etBcc.setHorizontallyScrolling(false);
etBcc.setOnLongClickListener(longClickListener);
etSubject.setMaxLines(Integer.MAX_VALUE);
etSubject.setHorizontallyScrolling(false);