From 9b81e4ea0a157a2e1995a2a01b71b63475c12318 Mon Sep 17 00:00:00 2001 From: Arthur Hung Date: Mon, 19 Sep 2022 11:33:54 +0000 Subject: [PATCH] Revert "Clear default focus highlight when lost window focus or re-enter touch mode" This reverts commit 5fc73f8f2fc508f56813a4eb8d8d33e40b8f6346. Reason for revert: b/246952306 Change-Id: I134a59a9cd576e6cf6a9bf8b5bcf2ae96e3fdb93 --- core/java/android/view/View.java | 3 +-- core/java/android/view/ViewRootImpl.java | 15 +-------------- 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index cf087bcf7cfc8..8fee4db458b34 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -24490,9 +24490,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback, /** * Set the current default focus highlight. * @param highlight the highlight drawable, or {@code null} if it's no longer needed. - * @hide */ - void setDefaultFocusHighlight(Drawable highlight) { + private void setDefaultFocusHighlight(Drawable highlight) { mDefaultFocusHighlight = highlight; mDefaultFocusHighlightSizeChanged = true; if (highlight != null) { diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index 89a1557db4823..074cbe5a69475 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -3815,13 +3815,6 @@ public final class ViewRootImpl implements ViewParent, if (mAttachInfo.mTooltipHost != null) { mAttachInfo.mTooltipHost.hideTooltip(); } - if (!hasWindowFocus) { - // Clear focus highlight if its window lost focus. - final View focused = mView.findFocus(); - if (focused != null) { - focused.setDefaultFocusHighlight(null); - } - } } // Note: must be done after the focus change callbacks, @@ -5853,13 +5846,7 @@ public final class ViewRootImpl implements ViewParent, // be when the window is first being added, and mFocused isn't // set yet. final View focused = mView.findFocus(); - if (focused == null) { - return false; - } - - // Clear default focus highlight if it entered touch mode. - focused.setDefaultFocusHighlight(null); - if (!focused.isFocusableInTouchMode()) { + if (focused != null && !focused.isFocusableInTouchMode()) { final ViewGroup ancestorToTakeFocus = findAncestorToTakeFocusInTouchMode(focused); if (ancestorToTakeFocus != null) { // there is an ancestor that wants focus after its