summaryrefslogtreecommitdiff
path: root/core/java/android/widget/Toolbar.java
diff options
context:
space:
mode:
authorVadim Tryshev <vadimt@google.com>2017-01-06 19:30:00 -0800
committerVadim Tryshev <vadimt@google.com>2017-01-11 17:19:39 -0800
commit1abe85c867f552a5cdf50fba3f60d796284c2102 (patch)
tree5d89807e94b5f485567da990184d9f9a68432ee5 /core/java/android/widget/Toolbar.java
parent4a07b95746fe794ec5411aad9f5334178fb641b4 (diff)
Converting action bars to clusters.
ActionBar keyboard navigation logic is now implemented via clusters. Old implementation using setTouchscreenBlocksFocus and Ctrl+Shift+< shortcut is removed. Looking at the code, I can’t rule out existence of all 3 categories (1) action bars with a nested toolbar, (2) action bars without a nested toolbar and (3) Toolbars outside of action bars. Because of this, I set “cluster” attribute both on action bar and toolbar, and have code to avoid nested clusters in case (1). Support lib’s action/tool bars aren’t converted, however, they didn’t regress since Ctrl+Shift+< never worked for them. Will be done after feature freeze. Bug: 32151632 Test: Manual checks. Change-Id: Ieb93980088c0fb385a9bc8a5d218ffc269b94dc5
Diffstat (limited to 'core/java/android/widget/Toolbar.java')
-rw-r--r--core/java/android/widget/Toolbar.java18
1 files changed, 18 insertions, 0 deletions
diff --git a/core/java/android/widget/Toolbar.java b/core/java/android/widget/Toolbar.java
index 44b2b59a9dd3..2eb50e082041 100644
--- a/core/java/android/widget/Toolbar.java
+++ b/core/java/android/widget/Toolbar.java
@@ -42,6 +42,7 @@ import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
+import android.view.ViewParent;
import com.android.internal.R;
import com.android.internal.view.menu.MenuBuilder;
@@ -331,6 +332,23 @@ public class Toolbar extends ViewGroup {
a.recycle();
}
+ @Override
+ protected void onAttachedToWindow() {
+ super.onAttachedToWindow();
+
+ // If the container is a cluster, unmark itself as a cluster to avoid having nested
+ // clusters.
+ ViewParent parent = getParent();
+ while (parent != null && parent instanceof ViewGroup) {
+ final ViewGroup vgParent = (ViewGroup) parent;
+ if (vgParent.isKeyboardNavigationCluster()) {
+ setKeyboardNavigationCluster(false);
+ break;
+ }
+ parent = vgParent.getParent();
+ }
+ }
+
/**
* Specifies the theme to use when inflating popup menus. By default, uses
* the same theme as the toolbar itself.