From 7f4f499515c3e36991ce981689721705122e9a60 Mon Sep 17 00:00:00 2001 From: Vinit Nayak Date: Tue, 7 Sep 2021 14:39:45 -0700 Subject: [PATCH] Show all nav buttons when IME showing * Keep home and recents button, and rotate back button to be down when IME shows in 3 button task bar. * Move IME switcher to left side of taskbar for 3 button, keep on right side for gesture nav. Bug: 191399224 Test: Tested RTL and LTR, gesture + button nav with and w/o IME. Change-Id: I7959d26986e546596e2436b8b5eb7668f44b55cf --- quickstep/res/layout/taskbar.xml | 1 + .../res/layout/taskbar_contextual_button.xml | 23 ++++++++ quickstep/res/layout/taskbar_nav_button.xml | 14 +++++ quickstep/res/values/dimens.xml | 2 + .../taskbar/NavbarButtonsViewController.java | 52 ++++++++++++------- .../launcher3/uioverrides/ApiWrapper.java | 8 ++- 6 files changed, 79 insertions(+), 21 deletions(-) create mode 100644 quickstep/res/layout/taskbar_contextual_button.xml diff --git a/quickstep/res/layout/taskbar.xml b/quickstep/res/layout/taskbar.xml index b4c168c8a0..83ad9f33e5 100644 --- a/quickstep/res/layout/taskbar.xml +++ b/quickstep/res/layout/taskbar.xml @@ -52,6 +52,7 @@ android:orientation="horizontal" android:paddingLeft="@dimen/taskbar_nav_buttons_spacing" android:paddingRight="@dimen/taskbar_nav_buttons_spacing" + android:layout_marginEnd="@dimen/taskbar_contextual_button_margin" android:gravity="center_vertical" android:layout_gravity="end"/> diff --git a/quickstep/res/layout/taskbar_contextual_button.xml b/quickstep/res/layout/taskbar_contextual_button.xml new file mode 100644 index 0000000000..cbbbfabc45 --- /dev/null +++ b/quickstep/res/layout/taskbar_contextual_button.xml @@ -0,0 +1,23 @@ + + + \ No newline at end of file diff --git a/quickstep/res/layout/taskbar_nav_button.xml b/quickstep/res/layout/taskbar_nav_button.xml index 985f928ca7..4ffb8d81dc 100644 --- a/quickstep/res/layout/taskbar_nav_button.xml +++ b/quickstep/res/layout/taskbar_nav_button.xml @@ -1,4 +1,18 @@ + 16dp 16dp 48dp + 16dp + 35dp 24dp 220dp 6dp diff --git a/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java b/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java index 046ee6f8be..79bea036a0 100644 --- a/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java +++ b/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java @@ -34,6 +34,7 @@ import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_O import android.animation.ObjectAnimator; import android.annotation.DrawableRes; import android.annotation.IdRes; +import android.annotation.LayoutRes; import android.graphics.Rect; import android.graphics.Region; import android.graphics.Region.Op; @@ -123,21 +124,16 @@ public class NavbarButtonsViewController { .getProperty(ALPHA_INDEX_IME), flags -> (flags & FLAG_IME_VISIBLE) == 0, MultiValueAlpha.VALUE, 1, 0)); + boolean isThreeButtonNav = mContext.isThreeButtonNav(); // IME switcher View imeSwitcherButton = addButton(R.drawable.ic_ime_switcher, BUTTON_IME_SWITCH, - mEndContextualContainer, mControllers.navButtonController, R.id.ime_switcher); + isThreeButtonNav ? mStartContextualContainer : mEndContextualContainer, + mControllers.navButtonController, R.id.ime_switcher); mPropertyHolders.add(new StatePropertyHolder(imeSwitcherButton, flags -> ((flags & MASK_IME_SWITCHER_VISIBLE) == MASK_IME_SWITCHER_VISIBLE) && ((flags & FLAG_ROTATION_BUTTON_VISIBLE) == 0) && ((flags & FLAG_A11Y_VISIBLE) == 0))); - View imeDownButton = addButton(R.drawable.ic_sysbar_back, BUTTON_BACK, - mStartContextualContainer, mControllers.navButtonController, R.id.back); - imeDownButton.setRotation(Utilities.isRtl(mContext.getResources()) ? 90 : -90); - // Rotate when Ime visible - mPropertyHolders.add(new StatePropertyHolder(imeDownButton, - flags -> (flags & FLAG_IME_VISIBLE) != 0)); - mPropertyHolders.add(new StatePropertyHolder( mControllers.taskbarViewController.getTaskbarIconAlpha() .getProperty(ALPHA_INDEX_KEYGUARD), @@ -150,7 +146,7 @@ public class NavbarButtonsViewController { // Force nav buttons (specifically back button) to be visible during setup wizard. boolean areButtonsForcedVisible = !SettingsCache.INSTANCE.get(mContext).getValue( Settings.Secure.getUriFor(Settings.Secure.USER_SETUP_COMPLETE), 0); - if (mContext.isThreeButtonNav() || areButtonsForcedVisible) { + if (isThreeButtonNav || areButtonsForcedVisible) { initButtons(mNavButtonContainer, mEndContextualContainer, mControllers.navButtonController); @@ -163,11 +159,18 @@ public class NavbarButtonsViewController { // Rotation button RotationButton rotationButton = new RotationButtonImpl( - addButton(mEndContextualContainer, R.id.rotate_suggestion)); + addButton(mEndContextualContainer, R.id.rotate_suggestion, + R.layout.taskbar_contextual_button)); rotationButton.hide(); mControllers.rotationButtonController.setRotationButton(rotationButton); } else { mControllers.rotationButtonController.setRotationButton(new RotationButton() {}); + View imeDownButton = addButton(R.drawable.ic_sysbar_back, BUTTON_BACK, + mStartContextualContainer, mControllers.navButtonController, R.id.back); + imeDownButton.setRotation(Utilities.isRtl(mContext.getResources()) ? 90 : -90); + // Rotate when Ime visible + mPropertyHolders.add(new StatePropertyHolder(imeDownButton, + flags -> (flags & FLAG_IME_VISIBLE) != 0)); } applyState(); @@ -180,8 +183,11 @@ public class NavbarButtonsViewController { mBackButton = addButton(R.drawable.ic_sysbar_back, BUTTON_BACK, mNavButtonContainer, mControllers.navButtonController, R.id.back); mPropertyHolders.add(new StatePropertyHolder(mBackButton, - flags -> (flags & FLAG_IME_VISIBLE) == 0 && - (flags & FLAG_DISABLE_BACK) == 0)); + flags -> (flags & FLAG_DISABLE_BACK) == 0)); + boolean isRtl = Utilities.isRtl(mContext.getResources()); + mPropertyHolders.add(new StatePropertyHolder( + mBackButton, flags -> (flags & FLAG_IME_VISIBLE) != 0, View.ROTATION, + isRtl ? 90 : -90, 0)); // Hide when keyguard is showing, show when bouncer is showing mPropertyHolders.add(new StatePropertyHolder(mBackButton, flags -> (flags & FLAG_KEYGUARD_VISIBLE) == 0 || @@ -191,19 +197,18 @@ public class NavbarButtonsViewController { View homeButton = addButton(R.drawable.ic_sysbar_home, BUTTON_HOME, navContainer, navButtonController, R.id.home); mPropertyHolders.add(new StatePropertyHolder(homeButton, - flags -> (flags & FLAG_IME_VISIBLE) == 0 && - (flags & FLAG_KEYGUARD_VISIBLE) == 0 && + flags -> (flags & FLAG_KEYGUARD_VISIBLE) == 0 && (flags & FLAG_DISABLE_HOME) == 0)); View recentsButton = addButton(R.drawable.ic_sysbar_recent, BUTTON_RECENTS, navContainer, navButtonController, R.id.recent_apps); mPropertyHolders.add(new StatePropertyHolder(recentsButton, - flags -> (flags & FLAG_IME_VISIBLE) == 0 && - (flags & FLAG_KEYGUARD_VISIBLE) == 0 && + flags -> (flags & FLAG_KEYGUARD_VISIBLE) == 0 && (flags & FLAG_DISABLE_RECENTS) == 0)); // A11y button mA11yButton = addButton(R.drawable.ic_sysbar_accessibility_button, BUTTON_A11Y, - endContainer, navButtonController, R.id.accessibility_button); + endContainer, navButtonController, R.id.accessibility_button, + R.layout.taskbar_contextual_button); mPropertyHolders.add(new StatePropertyHolder(mA11yButton, flags -> (flags & FLAG_A11Y_VISIBLE) != 0 && (flags & FLAG_ROTATION_BUTTON_VISIBLE) == 0)); @@ -306,15 +311,22 @@ public class NavbarButtonsViewController { private ImageView addButton(@DrawableRes int drawableId, @TaskbarButton int buttonType, ViewGroup parent, TaskbarNavButtonController navButtonController, @IdRes int id) { - ImageView buttonView = addButton(parent, id); + return addButton(drawableId, buttonType, parent, navButtonController, id, + R.layout.taskbar_nav_button); + } + + private ImageView addButton(@DrawableRes int drawableId, @TaskbarButton int buttonType, + ViewGroup parent, TaskbarNavButtonController navButtonController, @IdRes int id, + @LayoutRes int layoutId) { + ImageView buttonView = addButton(parent, id, layoutId); buttonView.setImageResource(drawableId); buttonView.setOnClickListener(view -> navButtonController.onButtonClick(buttonType)); return buttonView; } - private ImageView addButton(ViewGroup parent, int id) { + private ImageView addButton(ViewGroup parent, @IdRes int id, @LayoutRes int layoutId) { ImageView buttonView = (ImageView) mContext.getLayoutInflater() - .inflate(R.layout.taskbar_nav_button, parent, false); + .inflate(layoutId, parent, false); buttonView.setId(id); parent.addView(buttonView); mAllButtons.add(buttonView); diff --git a/quickstep/src/com/android/launcher3/uioverrides/ApiWrapper.java b/quickstep/src/com/android/launcher3/uioverrides/ApiWrapper.java index 8181a846e4..c9909cc2a1 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/ApiWrapper.java +++ b/quickstep/src/com/android/launcher3/uioverrides/ApiWrapper.java @@ -56,8 +56,14 @@ public class ApiWrapper { public static int getHotseatEndOffset(Context context) { if (SysUINavigationMode.INSTANCE.get(context).getMode() == Mode.THREE_BUTTONS) { Resources res = context.getResources(); + /* + * 2 (left + right) x Padding + + * 3 nav buttons + + * Little space at the end for contextual buttons + */ return 2 * res.getDimensionPixelSize(R.dimen.taskbar_nav_buttons_spacing) - + 3 * res.getDimensionPixelSize(R.dimen.taskbar_nav_buttons_size); + + 3 * res.getDimensionPixelSize(R.dimen.taskbar_nav_buttons_size) + + res.getDimensionPixelSize(R.dimen.taskbar_contextual_button_margin); } else { return 0; }