From 9d87b0c317b7092a2b78a651deb48595216eb0d1 Mon Sep 17 00:00:00 2001 From: Brandon Dayauon Date: Fri, 10 Jun 2022 15:29:10 -0700 Subject: [PATCH] Fix work toggle button to be placed where it should be. Previously, the implementation used the entire screen width within it's calculations to determine where the button should be placed. This is wrong because allApps have it's own container which we should take the width from. The current implementation works fine because the width of the screen for phones is the same width as the allApps container BUT this implemention is WRONG for tablets. With now using the allApps width for the calculation .. it works for both tablets/phones. Bug: 235054324 Test: Photos in bug thread Change-Id: I4c771d310a5d33646ad618e9c241cb5662493747 --- src/com/android/launcher3/allapps/WorkProfileManager.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/com/android/launcher3/allapps/WorkProfileManager.java b/src/com/android/launcher3/allapps/WorkProfileManager.java index b70cb13b07..844392322b 100644 --- a/src/com/android/launcher3/allapps/WorkProfileManager.java +++ b/src/com/android/launcher3/allapps/WorkProfileManager.java @@ -158,10 +158,10 @@ public class WorkProfileManager implements PersonalWorkSlidingTabStrip.OnActiveP workFabMarginBottom += mAllApps.mActivityContext.getDeviceProfile().getInsets().bottom; } lp.bottomMargin = workFabMarginBottom; - int totalScreenWidth = mDeviceProfile.widthPx; + int allAppsContainerWidth = mAllApps.getVisibleContainerView().getWidth(); int personalWorkTabWidth = mAllApps.mActivityContext.getAppsView().getFloatingHeaderView().getTabWidth(); - lp.rightMargin = lp.leftMargin = (totalScreenWidth - personalWorkTabWidth) / 2; + lp.rightMargin = lp.leftMargin = (allAppsContainerWidth - personalWorkTabWidth) / 2; if (mWorkModeSwitch.getParent() != mAllApps) { mAllApps.addView(mWorkModeSwitch); }