From 16bb2c75d0c3b2d9b5121de045cd100483102da9 Mon Sep 17 00:00:00 2001 From: Vadim Tryshev Date: Tue, 25 Oct 2016 13:10:35 -0700 Subject: [PATCH] Not blocking focus on action bar on tab MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When the focus jumps from action bar to outside of it, action bar disables focusing on it so that tabbing couldn’t get back to it. Currently, it does the check that the focus has left the bar from onFocusChange(), when the internal data structures are in process of updating the current focus; as a result, the check may report a wrong result, and the focus will be blocked while it’s actually is still in the action bar. This caused the action bar to lose focus. The fix makes the check in a posted action, fixing the issue. Bug: 32087180 Test: Manual test that the issue doesn’t repro. Change-Id: I67069d2ae58f2843e6fcc8c705943324cc1533f4 --- core/java/android/app/ActionBar.java | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/core/java/android/app/ActionBar.java b/core/java/android/app/ActionBar.java index 0552d34d52157..58f5a787a355f 100644 --- a/core/java/android/app/ActionBar.java +++ b/core/java/android/app/ActionBar.java @@ -1494,22 +1494,22 @@ public abstract class ActionBar { public void onFocusChange(View v, boolean hasFocus) { if (!hasFocus) { v.setOnFocusChangeListener(null); - final View focused = mFocusRoot.findFocus(); - if (focused != null) { - focused.setOnFocusChangeListener(this); - } else { - mFocusRoot.post(this); - } + mFocusRoot.post(this); } } @Override public void run() { - if (mContainer != null) { - mContainer.setTouchscreenBlocksFocus(true); - } - if (mToolbar != null) { - mToolbar.setTouchscreenBlocksFocus(true); + final View focused = mFocusRoot.findFocus(); + if (focused != null) { + focused.setOnFocusChangeListener(this); + } else { + if (mContainer != null) { + mContainer.setTouchscreenBlocksFocus(true); + } + if (mToolbar != null) { + mToolbar.setTouchscreenBlocksFocus(true); + } } } }