From 1a2d581cf04376ad3256facb37f0b59c139f2e88 Mon Sep 17 00:00:00 2001 From: Tony Wickham Date: Thu, 9 Dec 2021 17:26:38 +0000 Subject: [PATCH] Only inset IME by 48dp instead of 60dp when taskbar is present - Update providedInternalImeInsets whenever taskbar height changes, since the insets are subtracted from the taskbar window height. This ensures the IME always has the same bottom inset (48dp) regardless of taskbar's window size - Also translate nav buttons down to center in the new size when IME is showing Test: Open IME from home and in apps, both in gesture nav and 3 button mode. Ensure IME bottom inset is always 48dp and nav buttons center within that space Fixes: 201115344 Change-Id: I5ed25b0ffc08145b2221cc5c960e669cc21b2aa7 --- quickstep/res/values/dimens.xml | 1 + .../taskbar/NavbarButtonsViewController.java | 33 ++++++++++++++----- .../taskbar/TaskbarActivityContext.java | 26 ++++++++++++--- 3 files changed, 47 insertions(+), 13 deletions(-) diff --git a/quickstep/res/values/dimens.xml b/quickstep/res/values/dimens.xml index 3b2d44b391..5ea94e906e 100644 --- a/quickstep/res/values/dimens.xml +++ b/quickstep/res/values/dimens.xml @@ -216,6 +216,7 @@ @*android:dimen/taskbar_frame_height + 48dp 48dp 54dp 16dp diff --git a/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java b/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java index ce1e8b6b6e..48b0f6d8bf 100644 --- a/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java +++ b/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java @@ -106,6 +106,9 @@ public class NavbarButtonsViewController { private final AnimatedFloat mTaskbarNavButtonTranslationY = new AnimatedFloat( this::updateNavButtonTranslationY); + private final AnimatedFloat mTaskbarNavButtonTranslationYForIme = new AnimatedFloat( + this::updateNavButtonTranslationY); + // Only applies to mTaskbarNavButtonTranslationY private final AnimatedFloat mNavButtonTranslationYMultiplier = new AnimatedFloat( this::updateNavButtonTranslationY); private final AnimatedFloat mTaskbarNavButtonDarkIntensity = new AnimatedFloat( @@ -162,14 +165,26 @@ public class NavbarButtonsViewController { .getKeyguardBgTaskbar(), flags -> (flags & FLAG_KEYGUARD_VISIBLE) == 0, AnimatedFloat.VALUE, 1, 0)); - // Make sure to remove nav bar buttons translation when notification shade is expanded. - mPropertyHolders.add(new StatePropertyHolder(mNavButtonTranslationYMultiplier, - flags -> (flags & FLAG_NOTIFICATION_SHADE_EXPANDED) != 0, AnimatedFloat.VALUE, - 0, 1)); - // Force nav buttons (specifically back button) to be visible during setup wizard. boolean isInSetup = !mContext.isUserSetupComplete(); - if (isThreeButtonNav || isInSetup) { + boolean alwaysShowButtons = isThreeButtonNav || isInSetup; + + // Make sure to remove nav bar buttons translation when notification shade is expanded or + // IME is showing (add separate translation for IME). + int flagsToRemoveTranslation = FLAG_NOTIFICATION_SHADE_EXPANDED | FLAG_IME_VISIBLE; + mPropertyHolders.add(new StatePropertyHolder(mNavButtonTranslationYMultiplier, + flags -> (flags & flagsToRemoveTranslation) != 0, AnimatedFloat.VALUE, + 0, 1)); + // Center nav buttons in new height for IME. + float transForIme = (mContext.getDeviceProfile().taskbarSize + - mContext.getTaskbarHeightForIme()) / 2f; + // For gesture nav, nav buttons only show for IME anyway so keep them translated down. + float defaultButtonTransY = alwaysShowButtons ? 0 : transForIme; + mPropertyHolders.add(new StatePropertyHolder(mTaskbarNavButtonTranslationYForIme, + flags -> (flags & FLAG_IME_VISIBLE) != 0, AnimatedFloat.VALUE, transForIme, + defaultButtonTransY)); + + if (alwaysShowButtons) { initButtons(mNavButtonContainer, mEndContextualContainer, mControllers.navButtonController); @@ -408,8 +423,10 @@ public class NavbarButtonsViewController { } private void updateNavButtonTranslationY() { - mNavButtonsView.setTranslationY(mTaskbarNavButtonTranslationY.value - * mNavButtonTranslationYMultiplier.value); + float normalTranslationY = mTaskbarNavButtonTranslationY.value + * mNavButtonTranslationYMultiplier.value; + float otherTranslationY = mTaskbarNavButtonTranslationYForIme.value; + mNavButtonsView.setTranslationY(normalTranslationY + otherTranslationY); } private void updateNavButtonDarkIntensity() { diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java index 692352b3fd..73c6579927 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java @@ -32,6 +32,7 @@ import android.content.Context; import android.content.Intent; import android.content.pm.ActivityInfo.Config; import android.content.pm.LauncherApps; +import android.content.res.Resources; import android.graphics.Insets; import android.graphics.PixelFormat; import android.graphics.Rect; @@ -96,6 +97,7 @@ public class TaskbarActivityContext extends ContextThemeWrapper implements Activ private final WindowManager mWindowManager; private final @Nullable RoundedCorner mLeftCorner, mRightCorner; + private final int mTaskbarHeightForIme; private WindowManager.LayoutParams mWindowLayoutParams; private boolean mIsFullscreen; // The size we should return to when we call setTaskbarWindowFullscreen(false) @@ -122,10 +124,13 @@ public class TaskbarActivityContext extends ContextThemeWrapper implements Activ mIsUserSetupComplete = SettingsCache.INSTANCE.get(this).getValue( Settings.Secure.getUriFor(Settings.Secure.USER_SETUP_COMPLETE), 0); - float taskbarIconSize = getResources().getDimension(R.dimen.taskbar_icon_size); - mDeviceProfile.updateIconSize(1, getResources()); + final Resources resources = getResources(); + float taskbarIconSize = resources.getDimension(R.dimen.taskbar_icon_size); + mDeviceProfile.updateIconSize(1, resources); float iconScale = taskbarIconSize / mDeviceProfile.iconSizePx; - mDeviceProfile.updateIconSize(iconScale, getResources()); + mDeviceProfile.updateIconSize(iconScale, resources); + + mTaskbarHeightForIme = resources.getDimensionPixelSize(R.dimen.taskbar_ime_size); mLayoutInflater = LayoutInflater.from(this).cloneInContext(this); @@ -197,7 +202,7 @@ public class TaskbarActivityContext extends ContextThemeWrapper implements Activ // Adjust the frame by the rounded corners (ie. leaving just the bar as the inset) when // the IME is showing mWindowLayoutParams.providedInternalImeInsets = Insets.of(0, - getDefaultTaskbarWindowHeight() - mDeviceProfile.taskbarSize, 0, 0); + getDefaultTaskbarWindowHeight() - mTaskbarHeightForIme, 0, 0); // Initialize controllers after all are constructed. mControllers.init(sharedState); @@ -423,7 +428,9 @@ public class TaskbarActivityContext extends ContextThemeWrapper implements Activ if (mWindowLayoutParams.height == height || mIsDestroyed) { return; } - if (height != MATCH_PARENT) { + if (height == MATCH_PARENT) { + height = mDeviceProfile.heightPx; + } else { mLastRequestedNonFullscreenHeight = height; if (mIsFullscreen) { // We still need to be fullscreen, so defer any change to our height until we call @@ -434,6 +441,8 @@ public class TaskbarActivityContext extends ContextThemeWrapper implements Activ } } mWindowLayoutParams.height = height; + mWindowLayoutParams.providedInternalImeInsets = + Insets.of(0, height - mTaskbarHeightForIme, 0, 0); mWindowManager.updateViewLayout(mDragLayer, mWindowLayoutParams); } @@ -444,6 +453,13 @@ public class TaskbarActivityContext extends ContextThemeWrapper implements Activ return mDeviceProfile.taskbarSize + Math.max(getLeftCornerRadius(), getRightCornerRadius()); } + /** + * Returns the bottom insets taskbar provides to the IME when IME is visible. + */ + public int getTaskbarHeightForIme() { + return mTaskbarHeightForIme; + } + protected void onTaskbarIconClicked(View view) { Object tag = view.getTag(); if (tag instanceof Task) {