From f03c3a639893b9274a87ae6706f5214d9d43cc40 Mon Sep 17 00:00:00 2001 From: Matthew Ng Date: Wed, 3 Apr 2019 13:52:57 -0700 Subject: [PATCH] Ime in gestural mode will have ime switcher and down arrow When in gestural mode, the navigation bar will inset the ime window higher to raise up revealing the original height of the navigation bar. In place will be the (alt) back button (pointing down), the handle and ime switcher (if should be shown). Fixes: 128928130 Bug: 113952590 Bug: 112934365 Test: manual Change-Id: I28cc4def846cb09eb2d7ab00d12561f0c198dbbc --- packages/SystemUI/res/layout/contextual.xml | 8 +-- packages/SystemUI/res/layout/home_handle.xml | 2 + packages/SystemUI/res/layout/ime_switcher.xml | 28 ++++++++ packages/SystemUI/res/layout/menu_ime.xml | 8 +-- packages/SystemUI/res/values/config.xml | 2 +- .../statusbar/phone/ContextualButton.java | 3 + .../phone/ContextualButtonGroup.java | 7 +- .../phone/NavigationBarFragment.java | 4 +- .../phone/NavigationBarInflaterView.java | 17 +++-- .../statusbar/phone/NavigationBarView.java | 71 +++++++++++++++++-- .../phone/NavigationBarContextTest.java | 2 + .../server/wm/NavigationBarExperiments.java | 4 +- 12 files changed, 129 insertions(+), 27 deletions(-) create mode 100644 packages/SystemUI/res/layout/ime_switcher.xml diff --git a/packages/SystemUI/res/layout/contextual.xml b/packages/SystemUI/res/layout/contextual.xml index c8f0a24aff622..9b6ccaeef1e4f 100644 --- a/packages/SystemUI/res/layout/contextual.xml +++ b/packages/SystemUI/res/layout/contextual.xml @@ -37,16 +37,10 @@ android:paddingStart="@dimen/navigation_key_padding" android:paddingEnd="@dimen/navigation_key_padding" /> - diff --git a/packages/SystemUI/res/layout/ime_switcher.xml b/packages/SystemUI/res/layout/ime_switcher.xml new file mode 100644 index 0000000000000..7710b25d6e4cb --- /dev/null +++ b/packages/SystemUI/res/layout/ime_switcher.xml @@ -0,0 +1,28 @@ + + + + diff --git a/packages/SystemUI/res/layout/menu_ime.xml b/packages/SystemUI/res/layout/menu_ime.xml index 8a3a0b19c892c..24374e80b211a 100644 --- a/packages/SystemUI/res/layout/menu_ime.xml +++ b/packages/SystemUI/res/layout/menu_ime.xml @@ -35,13 +35,13 @@ android:visibility="invisible" android:contentDescription="@string/accessibility_menu" /> - left[.5W],back[1WC];home;recent[1WC],right[.5W] back[1.7WC];home;contextual[1.7WC] - ";home_handle;" + back[1.7WC];home_handle;ime_switcher[1.7WC] false diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ContextualButton.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ContextualButton.java index 5dded527a7fb4..541c142c422a5 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ContextualButton.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ContextualButton.java @@ -51,6 +51,9 @@ public class ContextualButton extends ButtonDispatcher { * Reload the drawable from resource id, should reapply the previous dark intensity. */ public void updateIcon() { + if (getCurrentView() == null || !getCurrentView().isAttachedToWindow()) { + return; + } final KeyButtonDrawable currentDrawable = getImageDrawable(); KeyButtonDrawable drawable = getNewDrawable(); if (currentDrawable != null) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ContextualButtonGroup.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ContextualButtonGroup.java index 38df17ab52fda..02b660f4734d9 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ContextualButtonGroup.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ContextualButtonGroup.java @@ -112,23 +112,24 @@ public class ContextualButtonGroup extends ButtonDispatcher { * their icons for their buttons. */ public void updateIcons() { - if (getCurrentView() == null || !getCurrentView().isAttachedToWindow()) { - return; - } for (ButtonData data : mButtonData) { data.button.updateIcon(); } } public void dump(PrintWriter pw) { + View view = getCurrentView(); pw.println("ContextualButtonGroup {"); pw.println(" getVisibleContextButton(): " + getVisibleContextButton()); pw.println(" isVisible(): " + isVisible()); + pw.println(" attached(): " + (view != null && view.isAttachedToWindow())); pw.println(" mButtonData [ "); for (int i = mButtonData.size() - 1; i >= 0; --i) { final ButtonData data = mButtonData.get(i); + view = data.button.getCurrentView(); pw.println(" " + i + ": markedVisible=" + data.markedVisible + " visible=" + data.button.getVisibility() + + " attached=" + (view != null && view.isAttachedToWindow()) + " alpha=" + data.button.getAlpha()); } pw.println(" ]"); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java index 3dcadf1d5071c..6729f9fa5787c 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java @@ -202,7 +202,9 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback @Override public void onBackButtonAlphaChanged(float alpha, boolean animate) { final ButtonDispatcher backButton = mNavigationBarView.getBackButton(); - if (QuickStepContract.isGesturalMode(getContext())) { + final boolean useAltBack = + (mNavigationIconHints & StatusBarManager.NAVIGATION_HINT_BACK_ALT) != 0; + if (QuickStepContract.isGesturalMode(getContext()) && !useAltBack) { // If property was changed to hide/show back button, going home will trigger // launcher to to change the back button alpha to reflect property change backButton.setVisibility(View.GONE); 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 26aa617db167d..a522ed1ced74c 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarInflaterView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarInflaterView.java @@ -68,6 +68,7 @@ public class NavigationBarInflaterView extends FrameLayout public static final String LEFT = "left"; public static final String RIGHT = "right"; public static final String CONTEXTUAL = "contextual"; + public static final String IME_SWITCHER = "ime_switcher"; public static final String GRAVITY_SEPARATOR = ";"; public static final String BUTTON_SEPARATOR = ","; @@ -164,17 +165,21 @@ public class NavigationBarInflaterView extends FrameLayout @Override public void onTuningChanged(String key, String newValue) { if (NAV_BAR_VIEWS.equals(key)) { - if (!Objects.equals(mCurrentLayout, newValue)) { - mUsingCustomLayout = newValue != null; - clearViews(); - inflateLayout(newValue); - } + setNavigationBarLayout(newValue); } else if (NAV_BAR_LEFT.equals(key) || NAV_BAR_RIGHT.equals(key)) { clearViews(); inflateLayout(mCurrentLayout); } } + public void setNavigationBarLayout(String layoutValue) { + if (!Objects.equals(mCurrentLayout, layoutValue)) { + mUsingCustomLayout = layoutValue != null; + clearViews(); + inflateLayout(layoutValue); + } + } + public void onLikelyDefaultLayoutChange() { // Don't override custom layouts if (mUsingCustomLayout) return; @@ -401,6 +406,8 @@ public class NavigationBarInflaterView extends FrameLayout v = inflater.inflate(R.layout.contextual, parent, false); } else if (HOME_HANDLE.equals(button)) { v = inflater.inflate(R.layout.home_handle, parent, false); + } else if (IME_SWITCHER.equals(button)) { + v = inflater.inflate(R.layout.ime_switcher, parent, false); } else if (button.startsWith(KEY)) { String uri = extractImage(button); int code = extractKeycode(button); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java index 7abdbd03a56ba..e2a63cc00d9ef 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java @@ -21,7 +21,6 @@ import static android.view.WindowManagerPolicyConstants.NAV_BAR_INVALID; import static com.android.systemui.shared.system.NavigationBarCompat.FLAG_SHOW_OVERVIEW_BUTTON; import static com.android.systemui.statusbar.phone.BarTransitions.MODE_OPAQUE; -import static com.android.systemui.statusbar.phone.NavigationBarInflaterView.NAV_BAR_VIEWS; import android.animation.LayoutTransition; import android.animation.LayoutTransition.TransitionListener; @@ -35,6 +34,7 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; +import android.content.pm.ParceledListSlice; import android.content.res.Configuration; import android.graphics.Canvas; import android.graphics.Point; @@ -48,6 +48,8 @@ import android.util.Log; import android.util.Slog; import android.util.SparseArray; import android.view.Display; +import android.view.IPinnedStackController; +import android.view.IPinnedStackListener; import android.view.MotionEvent; import android.view.Surface; import android.view.View; @@ -133,6 +135,7 @@ public class NavigationBarView extends FrameLayout implements PluginListener