diff options
| author | 2024-03-18 13:25:35 -0700 | |
|---|---|---|
| committer | 2024-03-18 13:25:35 -0700 | |
| commit | 47824b93f3f67b11dffceaa2d00712f2f7f25d6c (patch) | |
| tree | 3474c766ed006c5574a2b2c871d61ef7bf453c08 | |
| parent | 54552737ad328f0deb32227f9c803827d7779f3f (diff) | |
Prevent TextView refocus on escape key press
Bug: 329598550
Bug: 312921137
Test: atest android.widget.cts.TextViewTest
Change-Id: Ied159ac0b514a9815e7ac1e5d3328bbfa243e547
| -rw-r--r-- | core/java/android/view/View.java | 3 | ||||
| -rw-r--r-- | core/java/android/widget/TextView.java | 2 |
2 files changed, 3 insertions, 2 deletions
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index a5ff48fd3ca6..c946a15b304b 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -8474,8 +8474,9 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * hierarchy * @param refocus when propagate is true, specifies whether to request the * root view place new focus + * @hide */ - void clearFocusInternal(View focused, boolean propagate, boolean refocus) { + public void clearFocusInternal(View focused, boolean propagate, boolean refocus) { if ((mPrivateFlags & PFLAG_FOCUSED) != 0) { mPrivateFlags &= ~PFLAG_FOCUSED; clearParentsWantFocus(); diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java index 0373539c44ea..246ed6c94385 100644 --- a/core/java/android/widget/TextView.java +++ b/core/java/android/widget/TextView.java @@ -9733,7 +9733,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener return KEY_EVENT_HANDLED; } if (hasFocus()) { - clearFocus(); + clearFocusInternal(null, /* propagate */ true, /* refocus */ false); InputMethodManager imm = getInputMethodManager(); if (imm != null) { imm.hideSoftInputFromView(this, 0); |