Workaround word iterator bug Android <= M

This commit is contained in:
M66B 2020-09-13 08:59:11 +02:00
parent 30013fb22e
commit 637c97e2da
1 changed files with 15 additions and 0 deletions

View File

@ -24,6 +24,7 @@ import android.content.ClipboardManager;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.os.Build;
import android.text.Selection;
import android.text.Spannable;
import android.text.Spanned;
@ -107,6 +108,20 @@ public class FixedTextView extends AppCompatTextView {
}
}
@Override
public boolean dispatchTouchEvent(MotionEvent event) {
// https://issuetracker.google.com/issues/37068143
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.M &&
hasSelection() &&
event.getActionMasked() == MotionEvent.ACTION_DOWN) {
CharSequence text = getText();
setText(null);
setText(text);
}
return super.dispatchTouchEvent(event);
}
@Override
public boolean onTouchEvent(MotionEvent event) {
try {