From 705857c942fcce5eee7bf7bfd89a2efdf9f32ca9 Mon Sep 17 00:00:00 2001 From: M66B Date: Fri, 12 Jun 2020 13:10:02 +0200 Subject: [PATCH] Prevent crash --- .../java/eu/faircode/email/FixedTextView.java | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/app/src/main/java/eu/faircode/email/FixedTextView.java b/app/src/main/java/eu/faircode/email/FixedTextView.java index db3ee39598..3b567da516 100644 --- a/app/src/main/java/eu/faircode/email/FixedTextView.java +++ b/app/src/main/java/eu/faircode/email/FixedTextView.java @@ -23,6 +23,7 @@ import android.content.Context; import android.graphics.Canvas; import android.graphics.Rect; import android.util.AttributeSet; +import android.view.KeyEvent; import android.view.MotionEvent; import androidx.annotation.NonNull; @@ -169,4 +170,37 @@ public class FixedTextView extends AppCompatTextView { return false; } } + + @Override + public boolean onKeyDown(int keyCode, KeyEvent event) { + try { + return super.onKeyDown(keyCode, event); + } catch (Throwable ex) { + /* + java.lang.IllegalArgumentException + at com.android.internal.util.Preconditions.checkArgument(Preconditions.java:33) + at android.widget.SelectionActionModeHelper$TextClassificationHelper.init(SelectionActionModeHelper.java:641) + at android.widget.SelectionActionModeHelper.resetTextClassificationHelper(SelectionActionModeHelper.java:204) + at android.widget.SelectionActionModeHelper.startActionModeAsync(SelectionActionModeHelper.java:88) + at android.widget.Editor.startSelectionActionModeAsync(Editor.java:2021) + at android.widget.Editor.refreshTextActionMode(Editor.java:1966) + at android.widget.TextView.spanChange(TextView.java:9525) + at android.widget.TextView$ChangeWatcher.onSpanChanged(TextView.java:11973) + at android.text.SpannableStringBuilder.sendSpanChanged(SpannableStringBuilder.java:1292) + at android.text.SpannableStringBuilder.setSpan(SpannableStringBuilder.java:748) + at android.text.SpannableStringBuilder.setSpan(SpannableStringBuilder.java:672) + at android.text.Selection.extendSelection(Selection.java:102) + at android.text.Selection.extendLeft(Selection.java:324) + at android.text.method.ArrowKeyMovementMethod.left(ArrowKeyMovementMethod.java:72) + at android.text.method.BaseMovementMethod.handleMovementKey(BaseMovementMethod.java:165) + at android.text.method.ArrowKeyMovementMethod.handleMovementKey(ArrowKeyMovementMethod.java:65) + at android.text.method.BaseMovementMethod.onKeyDown(BaseMovementMethod.java:42) + at android.widget.TextView.doKeyDown(TextView.java:7367) + at android.widget.TextView.onKeyDown(TextView.java:7117) + at android.view.KeyEvent.dispatch(KeyEvent.java:2707) + */ + Log.w(ex); + return false; + } + } }