From efc346677b240ffbb0a6becf258d7bbeb404abac Mon Sep 17 00:00:00 2001 From: Tracy Zhou Date: Mon, 22 Apr 2019 13:37:12 -0700 Subject: [PATCH] Add rotate suggestion button to gestural nav. Fixes: 128942468 Test: 1. In fully gestural mode, rotation/back button is moved to the bottom left corner and keyboard button is moved to the bottom right. When the keyboard is up, rotation button does not show. The rotation button in this setting has an oval background that matches the home handle color. 2. In 2-button and 3-button mode, the rotation button stays the same. Screenshot: https://screenshot.googleplex.com/or2GbOzmZTX Change-Id: I32f2f11d33bf6881a67770679db2118917d2123b --- packages/SystemUI/res/layout/contextual.xml | 14 +-- .../SystemUI/res/layout/rotate_suggestion.xml | 29 +++++++ .../SystemUI/res/layout/start_contextual.xml | 36 ++++++++ packages/SystemUI/res/values/config.xml | 2 +- .../statusbar/phone/ButtonDispatcher.java | 4 +- .../statusbar/phone/ContextualButton.java | 6 +- .../phone/ContextualButtonGroup.java | 4 +- .../phone/NavigationBarInflaterView.java | 3 + .../statusbar/phone/NavigationBarView.java | 87 ++++++++++++++----- .../phone/RotationContextButton.java | 22 +++-- .../statusbar/policy/KeyButtonDrawable.java | 54 +++++++++--- .../phone/NavigationBarContextTest.java | 22 ++--- 12 files changed, 219 insertions(+), 64 deletions(-) create mode 100644 packages/SystemUI/res/layout/rotate_suggestion.xml create mode 100644 packages/SystemUI/res/layout/start_contextual.xml diff --git a/packages/SystemUI/res/layout/contextual.xml b/packages/SystemUI/res/layout/contextual.xml index 9b6ccaeef1e4f..90a7768846992 100644 --- a/packages/SystemUI/res/layout/contextual.xml +++ b/packages/SystemUI/res/layout/contextual.xml @@ -42,16 +42,10 @@ android:layout_height="match_parent" android:visibility="invisible" /> - + + + \ No newline at end of file diff --git a/packages/SystemUI/res/layout/start_contextual.xml b/packages/SystemUI/res/layout/start_contextual.xml new file mode 100644 index 0000000000000..e022c7301e3b6 --- /dev/null +++ b/packages/SystemUI/res/layout/start_contextual.xml @@ -0,0 +1,36 @@ + + + + + + \ No newline at end of file diff --git a/packages/SystemUI/res/values/config.xml b/packages/SystemUI/res/values/config.xml index 73386879a20d7..4abe9f0bfb5cd 100644 --- a/packages/SystemUI/res/values/config.xml +++ b/packages/SystemUI/res/values/config.xml @@ -331,7 +331,7 @@ left[.5W],back[1WC];home;recent[1WC],right[.5W] back[1.7WC];home;contextual[1.7WC] - back[1.7WC];home_handle;ime_switcher[1.7WC] + start_contextual[.1WC];home_handle;ime_switcher[.1WC] false diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ButtonDispatcher.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ButtonDispatcher.java index 5f5fad33fbfe1..6a93c7c9e5c42 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ButtonDispatcher.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ButtonDispatcher.java @@ -47,7 +47,7 @@ public class ButtonDispatcher { private Boolean mLongClickable; private Float mAlpha; private Float mDarkIntensity; - private Integer mVisibility = -1; + private Integer mVisibility = View.VISIBLE; private Boolean mDelayTouchFeedback; private KeyButtonDrawable mImageDrawable; private View mCurrentView; @@ -86,7 +86,7 @@ public class ButtonDispatcher { if (mAlpha != null) { view.setAlpha(mAlpha); } - if (mVisibility != null && mVisibility != -1) { + if (mVisibility != null) { view.setVisibility(mVisibility); } if (mAccessibilityDelegate != null) { 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 541c142c422a5..5bc17f5bc2c61 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ContextualButton.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ContextualButton.java @@ -51,7 +51,7 @@ 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()) { + if (getCurrentView() == null || !getCurrentView().isAttachedToWindow() || mIconResId == 0) { return; } final KeyButtonDrawable currentDrawable = getImageDrawable(); @@ -92,7 +92,7 @@ public class ContextualButton extends ButtonDispatcher { setVisibility(View.VISIBLE); return true; } - return mGroup.setButtonVisiblity(getId(), true /* visible */) == View.VISIBLE; + return mGroup.setButtonVisibility(getId(), true /* visible */) == View.VISIBLE; } /** @@ -104,7 +104,7 @@ public class ContextualButton extends ButtonDispatcher { setVisibility(View.INVISIBLE); return false; } - return mGroup.setButtonVisiblity(getId(), false /* visible */) != View.VISIBLE; + return mGroup.setButtonVisibility(getId(), false /* visible */) != View.VISIBLE; } /** 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 02b660f4734d9..9e843f93d00e0 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ContextualButtonGroup.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ContextualButtonGroup.java @@ -37,7 +37,7 @@ public class ContextualButtonGroup extends ButtonDispatcher { /** * Add a contextual button to the group. The order of adding increases in its priority. The * priority is used to determine which button should be visible when setting multiple button's - * visibility {@see setButtonVisiblity}. + * visibility {@see setButtonVisibility}. * @param button the button added to the group */ public void addButton(@NonNull ContextualButton button) { @@ -71,7 +71,7 @@ public class ContextualButtonGroup extends ButtonDispatcher { * @return if the button is visible after operation * @throws RuntimeException if the input id does not match any of the ids in the group */ - public int setButtonVisiblity(@IdRes int buttonResId, boolean visible) { + public int setButtonVisibility(@IdRes int buttonResId, boolean visible) { final int index = getContextButtonIndex(buttonResId); if (index == INVALID_INDEX) { throw new RuntimeException("Cannot find the button id of " + buttonResId 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 404c07b807e5b..963fc54ecd2d0 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarInflaterView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarInflaterView.java @@ -71,6 +71,7 @@ public class NavigationBarInflaterView extends FrameLayout public static final String RIGHT = "right"; public static final String CONTEXTUAL = "contextual"; public static final String IME_SWITCHER = "ime_switcher"; + public static final String START_CONTEXTUAL = "start_contextual"; public static final String GRAVITY_SEPARATOR = ";"; public static final String BUTTON_SEPARATOR = ","; @@ -419,6 +420,8 @@ public class NavigationBarInflaterView extends FrameLayout 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 (START_CONTEXTUAL.equals(button)) { + v = inflater.inflate(R.layout.start_contextual, 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 6f1e161cf2373..4333200e702a7 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java @@ -49,6 +49,8 @@ import android.view.MotionEvent; import android.view.Surface; import android.view.View; import android.view.ViewGroup; +import android.view.ViewTreeObserver.InternalInsetsInfo; +import android.view.ViewTreeObserver.OnComputeInternalInsetsListener; import android.view.WindowInsets; import android.view.WindowManager; import android.view.WindowManagerGlobal; @@ -135,6 +137,7 @@ public class NavigationBarView extends FrameLayout implements PluginListener