1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2024-12-29 03:05:31 +00:00

Small behavior improvement

This commit is contained in:
M66B 2019-10-20 15:55:25 +02:00
parent 069cf8f10c
commit a21aa3e68f

View file

@ -66,6 +66,7 @@ import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.InputMethodManager;
@ -285,6 +286,25 @@ public class FragmentCompose extends FragmentBase {
// Wire controls
spIdentity.setOnItemSelectedListener(identitySelected);
View.OnTouchListener onTouchListener = new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
EditText et = (EditText) v;
int sstart = et.getSelectionStart();
int send = et.getSelectionEnd();
if (sstart == send && event.getAction() == MotionEvent.ACTION_DOWN) {
float x = event.getX() + et.getScrollX();
float y = event.getY() + et.getScrollY();
int pos = et.getOffsetForPosition(x, y);
if (pos >= 0)
et.setSelection(pos);
}
return false;
}
};
View.OnLongClickListener longClickListener = new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
@ -309,14 +329,17 @@ public class FragmentCompose extends FragmentBase {
etTo.setMaxLines(Integer.MAX_VALUE);
etTo.setHorizontallyScrolling(false);
etTo.setOnTouchListener(onTouchListener);
etTo.setOnLongClickListener(longClickListener);
etCc.setMaxLines(Integer.MAX_VALUE);
etCc.setHorizontallyScrolling(false);
etCc.setOnTouchListener(onTouchListener);
etCc.setOnLongClickListener(longClickListener);
etBcc.setMaxLines(Integer.MAX_VALUE);
etBcc.setHorizontallyScrolling(false);
etBcc.setOnTouchListener(onTouchListener);
etBcc.setOnLongClickListener(longClickListener);
etSubject.setMaxLines(Integer.MAX_VALUE);