diff options
author | Tracy Zhou <tracyzhou@google.com> | 2023-11-22 22:43:52 -0800 |
---|---|---|
committer | Tracy Zhou <tracyzhou@google.com> | 2023-12-14 18:39:42 -0800 |
commit | 95c4c8d2680169a57a1924a5bc2018ea39a26fe8 (patch) | |
tree | e9ea71126a8b889c03d861f37556164fc781075c | |
parent | f2643521ecb5b7839f1c6984a13b08f2968a624a (diff) | |
download | Launcher3-95c4c8d2680169a57a1924a5bc2018ea39a26fe8.tar.gz |
Fix crash from folding/unfolding
This is fundamentally caused by the phone device profile not having task bar related attributes, which crashes in icon alignment animation. We had resolved it by skipping this animation based on isPhoneMode check. However, we passed in launcherDp instead of taskbarDp (from TaskbarActivityContext) which doesn't always have the most up to date information in race conditions (e.g. repetitively fold/unfold)
Fixes: 311431054
Test: repetively fold/unfold, make sure it doesn't crash
Change-Id: I65f600112da4123d337b3f59a2fe6dd13ac7af74
20 files changed, 77 insertions, 93 deletions
diff --git a/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java b/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java index bed4c376ae..709d3bac57 100644 --- a/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java +++ b/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java @@ -25,8 +25,6 @@ import static com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_X; import static com.android.launcher3.Utilities.getDescendantCoordRelativeToAncestor; import static com.android.launcher3.config.FeatureFlags.ENABLE_TASKBAR_NAVBAR_UNIFICATION; import static com.android.launcher3.taskbar.LauncherTaskbarUIController.SYSUI_SURFACE_PROGRESS_INDEX; -import static com.android.launcher3.taskbar.TaskbarManager.isPhoneButtonNavMode; -import static com.android.launcher3.taskbar.TaskbarManager.isPhoneMode; import static com.android.launcher3.taskbar.TaskbarNavButtonController.BUTTON_A11Y; import static com.android.launcher3.taskbar.TaskbarNavButtonController.BUTTON_BACK; import static com.android.launcher3.taskbar.TaskbarNavButtonController.BUTTON_HOME; @@ -239,7 +237,7 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT Point p = !mContext.isUserSetupComplete() ? new Point(0, mControllers.taskbarActivityContext.getSetupWindowHeight()) : DimensionUtils.getTaskbarPhoneDimensions(deviceProfile, resources, - TaskbarManager.isPhoneMode(deviceProfile)); + mContext.isPhoneMode()); mNavButtonsView.getLayoutParams().height = p.y; mIsImeRenderingNavButtons = @@ -305,7 +303,7 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT initButtons(mNavButtonContainer, mEndContextualContainer, mControllers.navButtonController); updateButtonLayoutSpacing(); - updateStateForFlag(FLAG_SMALL_SCREEN, isPhoneButtonNavMode(mContext)); + updateStateForFlag(FLAG_SMALL_SCREEN, mContext.isPhoneButtonNavMode()); mPropertyHolders.add(new StatePropertyHolder( mControllers.taskbarDragLayerController.getNavbarBackgroundAlpha(), @@ -388,7 +386,7 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT int navButtonSize = mContext.getResources().getDimensionPixelSize( R.dimen.taskbar_nav_buttons_size); boolean isRtl = Utilities.isRtl(mContext.getResources()); - if (!isPhoneMode(mContext.getDeviceProfile())) { + if (!mContext.isPhoneMode()) { mPropertyHolders.add(new StatePropertyHolder( mBackButton, flags -> (flags & FLAG_ONLY_BACK_FOR_BOUNCER_VISIBLE) != 0 || (flags & FLAG_KEYGUARD_VISIBLE) != 0, @@ -632,7 +630,7 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT * Sets the translationY of the nav buttons based on the current device state. */ public void updateNavButtonTranslationY() { - if (isPhoneButtonNavMode(mContext)) { + if (mContext.isPhoneButtonNavMode()) { return; } final float normalTranslationY = mTaskbarNavButtonTranslationY.value; @@ -751,9 +749,8 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT dp, mNavButtonsView, mImeSwitcherButton, mControllers.rotationButtonController.getRotationButton(), mA11yButton, res, isInKidsMode, isInSetup, isThreeButtonNav, - TaskbarManager.isPhoneMode(dp), - mWindowManagerProxy.getRotation(mContext)); - navButtonLayoutter.layoutButtons(dp, isA11yButtonPersistent()); + mContext.isPhoneMode(), mWindowManagerProxy.getRotation(mContext)); + navButtonLayoutter.layoutButtons(mContext, isA11yButtonPersistent()); updateNavButtonColor(); return; } diff --git a/quickstep/src/com/android/launcher3/taskbar/StashedHandleViewController.java b/quickstep/src/com/android/launcher3/taskbar/StashedHandleViewController.java index da1f766420..ad2dc234a0 100644 --- a/quickstep/src/com/android/launcher3/taskbar/StashedHandleViewController.java +++ b/quickstep/src/com/android/launcher3/taskbar/StashedHandleViewController.java @@ -107,7 +107,7 @@ public class StashedHandleViewController implements TaskbarControllers.LoggableT mControllers = controllers; DeviceProfile deviceProfile = mActivity.getDeviceProfile(); Resources resources = mActivity.getResources(); - if (isPhoneGestureNavMode(mActivity.getDeviceProfile())) { + if (mActivity.isPhoneGestureNavMode()) { mTaskbarSize = resources.getDimensionPixelSize(R.dimen.taskbar_phone_size); mStashedHandleWidth = resources.getDimensionPixelSize(R.dimen.taskbar_stashed_small_screen); @@ -120,7 +120,7 @@ public class StashedHandleViewController implements TaskbarControllers.LoggableT mStashedHandleView.getLayoutParams().height = mTaskbarSize + taskbarBottomMargin; mTaskbarStashedHandleAlpha.get(ALPHA_INDEX_STASHED).setValue( - isPhoneGestureNavMode(deviceProfile) ? 1 : 0); + mActivity.isPhoneGestureNavMode() ? 1 : 0); mTaskbarStashedHandleHintScale.updateValue(1f); final int stashedTaskbarHeight = mControllers.taskbarStashController.getStashedHeight(); @@ -148,7 +148,7 @@ public class StashedHandleViewController implements TaskbarControllers.LoggableT view.setPivotY(stashedCenterY); }); initRegionSampler(); - if (isPhoneGestureNavMode(deviceProfile)) { + if (mActivity.isPhoneGestureNavMode()) { onIsStashedChanged(true); } } @@ -184,10 +184,6 @@ public class StashedHandleViewController implements TaskbarControllers.LoggableT mRegionSamplingHelper = null; } - private boolean isPhoneGestureNavMode(DeviceProfile deviceProfile) { - return TaskbarManager.isPhoneMode(deviceProfile) && !mActivity.isThreeButtonNav(); - } - public MultiPropertyFactory<View> getStashedHandleAlpha() { return mTaskbarStashedHandleAlpha; } diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java index 4290948ad2..f6703f3139 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java @@ -214,7 +214,7 @@ public class TaskbarActivityContext extends BaseTaskbarContext { Context c = getApplicationContext(); mWindowManager = c.getSystemService(WindowManager.class); - boolean phoneMode = TaskbarManager.isPhoneMode(mDeviceProfile); + boolean phoneMode = isPhoneMode(); mLeftCorner = phoneMode ? null : display.getRoundedCorner(RoundedCorner.POSITION_BOTTOM_LEFT); @@ -388,6 +388,28 @@ public class TaskbarActivityContext extends BaseTaskbarContext { } /** + * @return {@code true} if the device profile isn't a large screen profile and we are using a + * single window for taskbar and navbar. + */ + public boolean isPhoneMode() { + return ENABLE_TASKBAR_NAVBAR_UNIFICATION && mDeviceProfile.isPhone; + } + + /** + * @return {@code true} if {@link #isPhoneMode()} is true and we're using 3 button-nav + */ + public boolean isPhoneButtonNavMode() { + return isPhoneMode() && isThreeButtonNav(); + } + + /** + * @return {@code true} if {@link #isPhoneMode()} is true and we're using gesture nav + */ + public boolean isPhoneGestureNavMode() { + return isPhoneMode() && !isThreeButtonNav(); + } + + /** * Show Taskbar upon receiving broadcast */ public void showTaskbarFromBroadcast() { @@ -464,9 +486,7 @@ public class TaskbarActivityContext extends BaseTaskbarContext { windowLayoutParams.privateFlags = WindowManager.LayoutParams.PRIVATE_FLAG_NO_MOVE_ANIMATION; windowLayoutParams.accessibilityTitle = getString( - TaskbarManager.isPhoneMode(mDeviceProfile) - ? R.string.taskbar_phone_a11y_title - : R.string.taskbar_a11y_title); + isPhoneMode() ? R.string.taskbar_phone_a11y_title : R.string.taskbar_a11y_title); return windowLayoutParams; } @@ -480,8 +500,7 @@ public class TaskbarActivityContext extends BaseTaskbarContext { ENABLE_TASKBAR_NAVBAR_UNIFICATION ? TYPE_NAVIGATION_BAR : TYPE_NAVIGATION_BAR_PANEL; WindowManager.LayoutParams windowLayoutParams = createDefaultWindowLayoutParams(windowType, TaskbarActivityContext.WINDOW_TITLE); - boolean isPhoneNavMode = TaskbarManager.isPhoneButtonNavMode(this); - if (!isPhoneNavMode) { + if (!isPhoneButtonNavMode()) { return windowLayoutParams; } diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarBackgroundRenderer.kt b/quickstep/src/com/android/launcher3/taskbar/TaskbarBackgroundRenderer.kt index d6016f1304..30f8d56504 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarBackgroundRenderer.kt +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarBackgroundRenderer.kt @@ -23,7 +23,6 @@ import android.graphics.Paint import android.graphics.Path import android.graphics.RectF import com.android.app.animation.Interpolators -import com.android.launcher3.DeviceProfile import com.android.launcher3.R import com.android.launcher3.Utilities import com.android.launcher3.Utilities.mapRange @@ -95,10 +94,10 @@ class TaskbarBackgroundRenderer(private val context: TaskbarActivityContext) { setCornerRoundness(DEFAULT_ROUNDNESS) } - fun updateStashedHandleWidth(dp: DeviceProfile, res: Resources) { + fun updateStashedHandleWidth(context: TaskbarActivityContext, res: Resources) { stashedHandleWidth = res.getDimensionPixelSize( - if (TaskbarManager.isPhoneMode(dp)) R.dimen.taskbar_stashed_small_screen + if (context.isPhoneMode) R.dimen.taskbar_stashed_small_screen else R.dimen.taskbar_stashed_handle_width ) } diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarDragLayer.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarDragLayer.java index a24cf4ba58..f9fc9832c8 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarDragLayer.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarDragLayer.java @@ -106,7 +106,7 @@ public class TaskbarDragLayer extends BaseDragLayer<TaskbarActivityContext> { public void init(TaskbarDragLayerController.TaskbarDragLayerCallbacks callbacks) { mControllerCallbacks = callbacks; - mBackgroundRenderer.updateStashedHandleWidth(mActivity.getDeviceProfile(), getResources()); + mBackgroundRenderer.updateStashedHandleWidth(mActivity, getResources()); recreateControllers(); } diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarDragLayerController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarDragLayerController.java index 73e32abb2c..3823c5a098 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarDragLayerController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarDragLayerController.java @@ -276,11 +276,10 @@ public class TaskbarDragLayerController implements TaskbarControllers.LoggableTa */ public int getTaskbarBackgroundHeight() { DeviceProfile deviceProfile = mActivity.getDeviceProfile(); - if (TaskbarManager.isPhoneMode(deviceProfile)) { + if (mActivity.isPhoneMode()) { Resources resources = mActivity.getResources(); - Point taskbarDimensions = - DimensionUtils.getTaskbarPhoneDimensions(deviceProfile, resources, - TaskbarManager.isPhoneMode(deviceProfile)); + Point taskbarDimensions = DimensionUtils.getTaskbarPhoneDimensions(deviceProfile, + resources, true /* isPhoneMode */); return taskbarDimensions.y == -1 ? deviceProfile.getDisplayInfo().currentSize.y : taskbarDimensions.y; diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarEduTooltipController.kt b/quickstep/src/com/android/launcher3/taskbar/TaskbarEduTooltipController.kt index 6d1b55870f..4776f0cb30 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarEduTooltipController.kt +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarEduTooltipController.kt @@ -32,7 +32,6 @@ import com.android.launcher3.Utilities import com.android.launcher3.config.FeatureFlags.enableTaskbarPinningEdu import com.android.launcher3.taskbar.TaskbarAutohideSuspendController.FLAG_AUTOHIDE_SUSPEND_EDU_OPEN import com.android.launcher3.taskbar.TaskbarControllers.LoggableTaskbarController -import com.android.launcher3.taskbar.TaskbarManager.isPhoneMode import com.android.launcher3.util.DisplayController import com.android.launcher3.util.OnboardingPrefs.TASKBAR_EDU_TOOLTIP_STEP import com.android.quickstep.util.LottieAnimationColorUtils @@ -62,7 +61,7 @@ class TaskbarEduTooltipController(val activityContext: TaskbarActivityContext) : LoggableTaskbarController { private val isTooltipEnabled: Boolean - get() = !Utilities.isRunningInTestHarness() && !isPhoneMode(activityContext.deviceProfile) + get() = !Utilities.isRunningInTestHarness() && !activityContext.isPhoneMode private val isOpen: Boolean get() = tooltip?.isOpen ?: false val isBeforeTooltipFeaturesStep: Boolean diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java index 057b71b74f..a8506805b8 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java @@ -17,7 +17,6 @@ package com.android.launcher3.taskbar; import static com.android.app.animation.Interpolators.EMPHASIZED; import static com.android.launcher3.taskbar.TaskbarKeyguardController.MASK_ANY_SYSUI_LOCKED; -import static com.android.launcher3.taskbar.TaskbarManager.isPhoneMode; import static com.android.launcher3.taskbar.TaskbarStashController.FLAG_IN_APP; import static com.android.launcher3.taskbar.TaskbarStashController.FLAG_IN_OVERVIEW; import static com.android.launcher3.taskbar.TaskbarStashController.FLAG_IN_STASHED_LAUNCHER_STATE; @@ -734,7 +733,7 @@ public class TaskbarLauncherStateController { } mIconAlphaForHome.setValue(alpha); boolean hotseatVisible = alpha == 0 - || isPhoneMode(mLauncher.getDeviceProfile()) + || mControllers.taskbarActivityContext.isPhoneMode() || (!mControllers.uiController.isHotseatIconOnTopWhenAligned() && mIconAlignment.value > 0); /* diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java index bbac11625d..831bc1167d 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java @@ -492,23 +492,7 @@ public class TaskbarManager { } } - /** - * @return {@code true} if provided device profile isn't a large screen profile - * and we are using a single window for taskbar and navbar. - */ - public static boolean isPhoneMode(DeviceProfile deviceProfile) { - return ENABLE_TASKBAR_NAVBAR_UNIFICATION && deviceProfile.isPhone; - } - - /** - * @return {@code true} if {@link #isPhoneMode(DeviceProfile)} is true and we're using - * 3 button-nav - */ - public static boolean isPhoneButtonNavMode(TaskbarActivityContext context) { - return isPhoneMode(context.getDeviceProfile()) && context.isThreeButtonNav(); - } - - private boolean isTaskbarPresent(DeviceProfile deviceProfile) { + private static boolean isTaskbarPresent(DeviceProfile deviceProfile) { return ENABLE_TASKBAR_NAVBAR_UNIFICATION || deviceProfile.isTaskbarPresent; } diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java index 9aaa80f74c..b3a8b935f1 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java @@ -256,7 +256,7 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba mSystemUiProxy = SystemUiProxy.INSTANCE.get(activity); mAccessibilityManager = mActivity.getSystemService(AccessibilityManager.class); - if (isPhoneMode()) { + if (mActivity.isPhoneMode()) { mUnstashedHeight = mActivity.getResources().getDimensionPixelSize( R.dimen.taskbar_phone_size); mStashedHeight = mActivity.getResources().getDimensionPixelSize( @@ -316,7 +316,7 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba updateStateForFlag(FLAG_STASHED_IN_APP_AUTO, isStashedInAppAuto); updateStateForFlag(FLAG_STASHED_IN_APP_SETUP, isInSetup); updateStateForFlag(FLAG_IN_SETUP, isInSetup); - updateStateForFlag(FLAG_STASHED_SMALL_SCREEN, isPhoneMode() + updateStateForFlag(FLAG_STASHED_SMALL_SCREEN, mActivity.isPhoneMode() && !mActivity.isThreeButtonNav()); // For now, assume we're in an app, since LauncherTaskbarUIController won't be able to tell // us that we're paused until a bit later. This avoids flickering upon recreating taskbar. @@ -386,13 +386,6 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba return (hasAnyFlag(FLAG_IN_STASHED_LAUNCHER_STATE) && supportsVisualStashing()); } - /** - * @return {@code true} if we're not on a large screen AND using gesture nav - */ - private boolean isPhoneMode() { - return TaskbarManager.isPhoneMode(mActivity.getDeviceProfile()); - } - private boolean hasAnyFlag(int flagMask) { return hasAnyFlag(mState, flagMask); } @@ -428,7 +421,7 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba * @see android.view.WindowInsets.Type#systemBars() */ public int getContentHeightToReportToApps() { - if ((isPhoneMode() && !mActivity.isThreeButtonNav()) + if ((mActivity.isPhoneMode() && !mActivity.isThreeButtonNav()) || DisplayController.isTransientTaskbar(mActivity)) { return getStashedHeight(); } @@ -579,7 +572,7 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba mAnimator = new AnimatorSet(); addJankMonitorListener(mAnimator, /* appearing= */ !mIsStashed); boolean isTransientTaskbar = DisplayController.isTransientTaskbar(mActivity); - final float stashTranslation = isPhoneMode() || isTransientTaskbar + final float stashTranslation = mActivity.isPhoneMode() || isTransientTaskbar ? 0 : (mUnstashedHeight - mStashedHeight); @@ -651,7 +644,7 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba firstHalfAnimatorSet.playTogether( mIconAlphaForStash.animateToValue(0), - mIconScaleForStash.animateToValue(isPhoneMode() ? + mIconScaleForStash.animateToValue(mActivity.isPhoneMode() ? 0 : STASHED_TASKBAR_SCALE) ); secondHalfAnimatorSet.playTogether( @@ -948,7 +941,7 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba return false; } return (mIsImeShowing || mIsImeSwitcherShowing) && - !(isPhoneMode() && mActivity.isThreeButtonNav() + !(mActivity.isPhoneMode() && mActivity.isThreeButtonNav() && mActivity.getDeviceProfile().isLandscape); } diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java index 2ab00665ed..74517a8c69 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java @@ -123,7 +123,7 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar mIconLayoutBounds = mActivityContext.getTransientTaskbarBounds(); Resources resources = getResources(); boolean isTransientTaskbar = DisplayController.isTransientTaskbar(mActivityContext) - && !TaskbarManager.isPhoneMode(mActivityContext.getDeviceProfile()); + && !mActivityContext.isPhoneMode(); mIsRtl = Utilities.isRtl(resources); mTransientTaskbarMinWidth = resources.getDimension(R.dimen.transient_taskbar_min_width); diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java index c0cbd45cc1..33fb3954ea 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java @@ -29,8 +29,6 @@ import static com.android.launcher3.config.FeatureFlags.enableTaskbarPinning; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASKBAR_ALLAPPS_BUTTON_TAP; import static com.android.launcher3.taskbar.TaskbarPinningController.PINNING_PERSISTENT; import static com.android.launcher3.taskbar.TaskbarPinningController.PINNING_TRANSIENT; -import static com.android.launcher3.taskbar.TaskbarManager.isPhoneButtonNavMode; -import static com.android.launcher3.taskbar.TaskbarManager.isPhoneMode; import static com.android.launcher3.util.MultiPropertyFactory.MULTI_PROPERTY_VALUE; import static com.android.launcher3.util.MultiTranslateDelegate.INDEX_TASKBAR_ALIGNMENT_ANIM; import static com.android.launcher3.util.MultiTranslateDelegate.INDEX_TASKBAR_PINNING_ANIM; @@ -191,7 +189,7 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar public void init(TaskbarControllers controllers) { mControllers = controllers; mTaskbarView.init(new TaskbarViewCallbacks()); - mTaskbarView.getLayoutParams().height = isPhoneMode(mActivity.getDeviceProfile()) + mTaskbarView.getLayoutParams().height = mActivity.isPhoneMode() ? mActivity.getResources().getDimensionPixelSize(R.dimen.taskbar_phone_size) : mActivity.getDeviceProfile().taskbarHeight; @@ -219,7 +217,7 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar // This gets modified in NavbarButtonsViewController, but the initial value it reads // may be incorrect since it's state gets destroyed on taskbar recreate, so reset here mTaskbarIconAlpha.get(ALPHA_INDEX_SMALL_SCREEN) - .animateToValue(isPhoneButtonNavMode(mActivity) ? 0 : 1).start(); + .animateToValue(mActivity.isPhoneButtonNavMode() ? 0 : 1).start(); } if (enableTaskbarPinning()) { mTaskbarView.addOnLayoutChangeListener(mTaskbarViewLayoutChangeListener); @@ -598,7 +596,7 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar * 1 => fully aligned */ public void setLauncherIconAlignment(float alignmentRatio, DeviceProfile launcherDp) { - if (isPhoneMode(launcherDp)) { + if (mActivity.isPhoneMode()) { mIconAlignControllerLazy = null; return; } diff --git a/quickstep/src/com/android/launcher3/taskbar/navbutton/KidsNavLayoutter.kt b/quickstep/src/com/android/launcher3/taskbar/navbutton/KidsNavLayoutter.kt index 3f51958402..65b77ac31c 100644 --- a/quickstep/src/com/android/launcher3/taskbar/navbutton/KidsNavLayoutter.kt +++ b/quickstep/src/com/android/launcher3/taskbar/navbutton/KidsNavLayoutter.kt @@ -24,8 +24,8 @@ import android.view.ViewGroup import android.widget.FrameLayout import android.widget.ImageView import android.widget.LinearLayout -import com.android.launcher3.DeviceProfile import com.android.launcher3.R +import com.android.launcher3.taskbar.TaskbarActivityContext import com.android.launcher3.taskbar.navbutton.LayoutResourceHelper.* import com.android.systemui.shared.rotation.RotationButton @@ -48,7 +48,7 @@ class KidsNavLayoutter( a11yButton ) { - override fun layoutButtons(dp: DeviceProfile, isA11yButtonPersistent: Boolean) { + override fun layoutButtons(context: TaskbarActivityContext, isA11yButtonPersistent: Boolean) { val iconSize: Int = resources.getDimensionPixelSize(DIMEN_TASKBAR_ICON_SIZE_KIDS) val buttonWidth: Int = resources.getDimensionPixelSize(DIMEN_TASKBAR_NAV_BUTTONS_WIDTH_KIDS) val buttonHeight: Int = diff --git a/quickstep/src/com/android/launcher3/taskbar/navbutton/NavButtonLayoutFactory.kt b/quickstep/src/com/android/launcher3/taskbar/navbutton/NavButtonLayoutFactory.kt index 6b05e9a891..22f0131bb2 100644 --- a/quickstep/src/com/android/launcher3/taskbar/navbutton/NavButtonLayoutFactory.kt +++ b/quickstep/src/com/android/launcher3/taskbar/navbutton/NavButtonLayoutFactory.kt @@ -24,6 +24,7 @@ import android.widget.FrameLayout import android.widget.ImageView import android.widget.LinearLayout import com.android.launcher3.DeviceProfile +import com.android.launcher3.taskbar.TaskbarActivityContext import com.android.launcher3.taskbar.navbutton.LayoutResourceHelper.* import com.android.launcher3.taskbar.navbutton.NavButtonLayoutFactory.Companion import com.android.launcher3.taskbar.navbutton.NavButtonLayoutFactory.NavButtonLayoutter @@ -162,6 +163,6 @@ class NavButtonLayoutFactory { /** Lays out and provides access to the home, recents, and back buttons for various mischief */ interface NavButtonLayoutter { - fun layoutButtons(dp: DeviceProfile, isA11yButtonPersistent: Boolean) + fun layoutButtons(context: TaskbarActivityContext, isA11yButtonPersistent: Boolean) } } diff --git a/quickstep/src/com/android/launcher3/taskbar/navbutton/PhoneGestureLayoutter.kt b/quickstep/src/com/android/launcher3/taskbar/navbutton/PhoneGestureLayoutter.kt index 5a7bc4969c..3817f91ec1 100644 --- a/quickstep/src/com/android/launcher3/taskbar/navbutton/PhoneGestureLayoutter.kt +++ b/quickstep/src/com/android/launcher3/taskbar/navbutton/PhoneGestureLayoutter.kt @@ -20,7 +20,7 @@ import android.content.res.Resources import android.view.ViewGroup import android.widget.ImageView import android.widget.LinearLayout -import com.android.launcher3.DeviceProfile +import com.android.launcher3.taskbar.TaskbarActivityContext import com.android.systemui.shared.rotation.RotationButton /** Layoutter for showing gesture navigation on phone screen. No buttons here, no-op container */ @@ -43,7 +43,7 @@ class PhoneGestureLayoutter( a11yButton ) { - override fun layoutButtons(dp: DeviceProfile, isA11yButtonPersistent: Boolean) { + override fun layoutButtons(context: TaskbarActivityContext, isA11yButtonPersistent: Boolean) { endContextualContainer.removeAllViews() startContextualContainer.removeAllViews() } diff --git a/quickstep/src/com/android/launcher3/taskbar/navbutton/PhoneLandscapeNavLayoutter.kt b/quickstep/src/com/android/launcher3/taskbar/navbutton/PhoneLandscapeNavLayoutter.kt index 382e29832d..7583cc1761 100644 --- a/quickstep/src/com/android/launcher3/taskbar/navbutton/PhoneLandscapeNavLayoutter.kt +++ b/quickstep/src/com/android/launcher3/taskbar/navbutton/PhoneLandscapeNavLayoutter.kt @@ -23,9 +23,8 @@ import android.widget.FrameLayout import android.widget.ImageView import android.widget.LinearLayout import androidx.core.view.children -import com.android.launcher3.DeviceProfile import com.android.launcher3.R -import com.android.launcher3.taskbar.TaskbarManager +import com.android.launcher3.taskbar.TaskbarActivityContext import com.android.launcher3.util.DimensionUtils import com.android.systemui.shared.rotation.RotationButton @@ -48,11 +47,11 @@ open class PhoneLandscapeNavLayoutter( a11yButton ) { - override fun layoutButtons(dp: DeviceProfile, isA11yButtonPersistent: Boolean) { + override fun layoutButtons(context: TaskbarActivityContext, isA11yButtonPersistent: Boolean) { // TODO(b/230395757): Polish pending, this is just to make it usable val endStartMargins = resources.getDimensionPixelSize(R.dimen.taskbar_nav_buttons_size) - val taskbarDimensions = DimensionUtils.getTaskbarPhoneDimensions(dp, resources, - TaskbarManager.isPhoneMode(dp)) + val taskbarDimensions = DimensionUtils.getTaskbarPhoneDimensions(context.deviceProfile, + resources, context.isPhoneMode) navButtonContainer.removeAllViews() navButtonContainer.orientation = LinearLayout.VERTICAL diff --git a/quickstep/src/com/android/launcher3/taskbar/navbutton/PhonePortraitNavLayoutter.kt b/quickstep/src/com/android/launcher3/taskbar/navbutton/PhonePortraitNavLayoutter.kt index e1ffa4dabf..4388ce617f 100644 --- a/quickstep/src/com/android/launcher3/taskbar/navbutton/PhonePortraitNavLayoutter.kt +++ b/quickstep/src/com/android/launcher3/taskbar/navbutton/PhonePortraitNavLayoutter.kt @@ -22,9 +22,8 @@ import android.view.ViewGroup import android.widget.FrameLayout import android.widget.ImageView import android.widget.LinearLayout -import com.android.launcher3.DeviceProfile import com.android.launcher3.R -import com.android.launcher3.taskbar.TaskbarManager +import com.android.launcher3.taskbar.TaskbarActivityContext import com.android.launcher3.util.DimensionUtils import com.android.systemui.shared.rotation.RotationButton @@ -47,11 +46,11 @@ class PhonePortraitNavLayoutter( a11yButton ) { - override fun layoutButtons(dp: DeviceProfile, isA11yButtonPersistent: Boolean) { + override fun layoutButtons(context: TaskbarActivityContext, isA11yButtonPersistent: Boolean) { // TODO(b/230395757): Polish pending, this is just to make it usable val taskbarDimensions = - DimensionUtils.getTaskbarPhoneDimensions(dp, resources, - TaskbarManager.isPhoneMode(dp)) + DimensionUtils.getTaskbarPhoneDimensions(context.deviceProfile, resources, + context.isPhoneMode) val endStartMargins = resources.getDimensionPixelSize(R.dimen.taskbar_nav_buttons_size) // Ensure order of buttons is correct diff --git a/quickstep/src/com/android/launcher3/taskbar/navbutton/SetupNavLayoutter.kt b/quickstep/src/com/android/launcher3/taskbar/navbutton/SetupNavLayoutter.kt index abdd32c712..1ac00608d6 100644 --- a/quickstep/src/com/android/launcher3/taskbar/navbutton/SetupNavLayoutter.kt +++ b/quickstep/src/com/android/launcher3/taskbar/navbutton/SetupNavLayoutter.kt @@ -22,8 +22,8 @@ import android.view.ViewGroup import android.widget.FrameLayout import android.widget.ImageView import android.widget.LinearLayout -import com.android.launcher3.DeviceProfile import com.android.launcher3.R +import com.android.launcher3.taskbar.TaskbarActivityContext import com.android.systemui.shared.rotation.RotationButton class SetupNavLayoutter( @@ -45,7 +45,7 @@ class SetupNavLayoutter( a11yButton ) { - override fun layoutButtons(dp: DeviceProfile, isA11yButtonPersistent: Boolean) { + override fun layoutButtons(context: TaskbarActivityContext, isA11yButtonPersistent: Boolean) { // Since setup wizard only has back button enabled, it looks strange to be // end-aligned, so start-align instead. val navButtonsLayoutParams = navButtonContainer.layoutParams as FrameLayout.LayoutParams diff --git a/quickstep/src/com/android/launcher3/taskbar/navbutton/TaskbarNavLayoutter.kt b/quickstep/src/com/android/launcher3/taskbar/navbutton/TaskbarNavLayoutter.kt index f5a4c64fd5..5465b6bbc9 100644 --- a/quickstep/src/com/android/launcher3/taskbar/navbutton/TaskbarNavLayoutter.kt +++ b/quickstep/src/com/android/launcher3/taskbar/navbutton/TaskbarNavLayoutter.kt @@ -22,8 +22,8 @@ import android.view.ViewGroup import android.widget.FrameLayout import android.widget.ImageView import android.widget.LinearLayout -import com.android.launcher3.DeviceProfile import com.android.launcher3.R +import com.android.launcher3.taskbar.TaskbarActivityContext import com.android.systemui.shared.rotation.RotationButton /** @@ -48,9 +48,11 @@ class TaskbarNavLayoutter( a11yButton ) { - override fun layoutButtons(dp: DeviceProfile, isA11yButtonPersistent: Boolean) { + override fun layoutButtons(context: TaskbarActivityContext, isA11yButtonPersistent: Boolean) { // Add spacing after the end of the last nav button - var navMarginEnd = resources.getDimension(dp.inv.inlineNavButtonsEndSpacing).toInt() + var navMarginEnd = resources + .getDimension(context.deviceProfile.inv.inlineNavButtonsEndSpacing) + .toInt() val contextualWidth = endContextualContainer.width // If contextual buttons are showing, we check if the end margin is enough for the // contextual button to be showing - if not, move the nav buttons over a smidge @@ -91,7 +93,7 @@ class TaskbarNavLayoutter( endContextualContainer.removeAllViews() startContextualContainer.removeAllViews() - if (!dp.isGestureMode) { + if (!context.deviceProfile.isGestureMode) { val contextualMargin = resources.getDimensionPixelSize( R.dimen.taskbar_contextual_button_padding) repositionContextualContainer(endContextualContainer, 0, Gravity.END) diff --git a/quickstep/src/com/android/quickstep/TouchInteractionService.java b/quickstep/src/com/android/quickstep/TouchInteractionService.java index bd4625b7f7..d1d2f972ba 100644 --- a/quickstep/src/com/android/quickstep/TouchInteractionService.java +++ b/quickstep/src/com/android/quickstep/TouchInteractionService.java @@ -974,8 +974,8 @@ public class TouchInteractionService extends Service { TaskbarActivityContext tac = mTaskbarManager.getCurrentActivityContext(); if (tac != null && !(base instanceof AssistantInputConsumer)) { // Present always on large screen or on small screen w/ flag - DeviceProfile dp = tac.getDeviceProfile(); - boolean useTaskbarConsumer = dp.isTaskbarPresent && !TaskbarManager.isPhoneMode(dp) + boolean useTaskbarConsumer = tac.getDeviceProfile().isTaskbarPresent + && !tac.isPhoneMode() && !tac.isInStashedLauncherState(); if (canStartSystemGesture && useTaskbarConsumer) { reasonString.append(NEWLINE_PREFIX) |