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
This commit is contained in:
Tracy Zhou
2023-11-22 22:43:52 -08:00
parent f2643521ec
commit 95c4c8d268
20 changed files with 77 additions and 93 deletions
@@ -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;
}
@@ -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;
}
@@ -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);
@@ -387,6 +387,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
*/
@@ -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;
}
@@ -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
)
}
@@ -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();
}
@@ -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;
@@ -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
@@ -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);
/*
@@ -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;
}
@@ -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);
}
@@ -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);
@@ -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;
}
@@ -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 =
@@ -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)
}
}
@@ -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()
}
@@ -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
@@ -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
@@ -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
@@ -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)
@@ -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)