Long press to select email addresses

pull/164/head
M66B 5 years ago
parent 3f8118a707
commit dd287cce20

@ -285,14 +285,39 @@ public class FragmentCompose extends FragmentBase {
// Wire controls // Wire controls
spIdentity.setOnItemSelectedListener(identitySelected); 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.setMaxLines(Integer.MAX_VALUE);
etTo.setHorizontallyScrolling(false); etTo.setHorizontallyScrolling(false);
etTo.setOnLongClickListener(longClickListener);
etCc.setMaxLines(Integer.MAX_VALUE); etCc.setMaxLines(Integer.MAX_VALUE);
etCc.setHorizontallyScrolling(false); etCc.setHorizontallyScrolling(false);
etCc.setOnLongClickListener(longClickListener);
etBcc.setMaxLines(Integer.MAX_VALUE); etBcc.setMaxLines(Integer.MAX_VALUE);
etBcc.setHorizontallyScrolling(false); etBcc.setHorizontallyScrolling(false);
etBcc.setOnLongClickListener(longClickListener);
etSubject.setMaxLines(Integer.MAX_VALUE); etSubject.setMaxLines(Integer.MAX_VALUE);
etSubject.setHorizontallyScrolling(false); etSubject.setHorizontallyScrolling(false);

Loading…
Cancel
Save