From 47bd7333e16f5743f06c387d12d8816fbbe33b76 Mon Sep 17 00:00:00 2001 From: Keisuke Kuroyanagi Date: Fri, 6 May 2016 10:49:54 -0700 Subject: [PATCH] Fix: Cannot control ime_switcher and menu after resetting. mButtonDispatchers contains ButtonDispatcher for ime_switcher and menu; however, in #inflateButton, we tried to find ButtonDispatcher for menu_ime, which is a FrameLayout containing ime_switcher and menu. Therefore, after #clearViews and #inflateLayout, ime_switcher and menu KeyButtonView are not in the corresponding ButtonDispatchers. It means NavigationBarView#getImeSwitchButton and NavigationBarView#getMenuButton returns empty ButtonDispatcher. As a result, we can't control ime switch button and menu button via NavigationBarView after then. e.g. We can't control ime switch button visibility. This CL fixes that issue by calling #addToDispatchers recursively for ViewGroup children if corresponding ButtonDispatcher is not found. This behavior is aligned with #addAll. Bug: 28580774 Change-Id: Ibe724753390b7bbb395a6d53d00bc6d06d00aa9a --- .../systemui/statusbar/phone/NavigationBarInflaterView.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarInflaterView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarInflaterView.java index ec45d604b8297..ee4a102937603 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarInflaterView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarInflaterView.java @@ -282,6 +282,12 @@ public class NavigationBarInflaterView extends FrameLayout implements TunerServi final int indexOfKey = mButtonDispatchers.indexOfKey(v.getId()); if (indexOfKey >= 0) { mButtonDispatchers.valueAt(indexOfKey).addView(v); + } else if (v instanceof ViewGroup) { + final ViewGroup viewGroup = (ViewGroup)v; + final int N = viewGroup.getChildCount(); + for (int i = 0; i < N; i++) { + addToDispatchers(viewGroup.getChildAt(i)); + } } } }