Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 52ca1161 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Clear TextView focus on escape key press" into main

parents 31827e99 09c8a489
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -82,3 +82,10 @@ flag {
  description: "A feature flag that implement inter character justification."
  bug: "283193133"
}

flag {
  name: "escape_clears_focus"
  namespace: "text"
  description: "Feature flag for clearing focus when the escape key is pressed."
  bug: "312921137"
}
+17 −0
Original line number Diff line number Diff line
@@ -9589,6 +9589,23 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
                }
                break;
            case KeyEvent.KEYCODE_ESCAPE:
                if (com.android.text.flags.Flags.escapeClearsFocus() && event.hasNoModifiers()) {
                    if (mEditor != null && mEditor.getTextActionMode() != null) {
                        stopTextActionMode();
                        return KEY_EVENT_HANDLED;
                    }
                    if (hasFocus()) {
                        clearFocus();
                        InputMethodManager imm = getInputMethodManager();
                        if (imm != null) {
                            imm.hideSoftInputFromView(this, 0);
                        }
                        return KEY_EVENT_HANDLED;
                    }
                }
                break;
            case KeyEvent.KEYCODE_CUT:
                if (event.hasNoModifiers() && canCut()) {
                    if (onTextContextMenuItem(ID_CUT)) {