Fixing tab width and panner not aligned with the all-apps icons

Bug: 234008165
Test: Verified on device
Change-Id: Ibec3eed4aef730439d79b086d6ae23b63b66361e
This commit is contained in:
Sunny Goyal
2022-07-11 11:03:54 -07:00
parent 46f79bda0c
commit eab51677ae
3 changed files with 46 additions and 8 deletions

View File

@@ -16,6 +16,7 @@
package com.android.launcher3.allapps;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TURN_OFF_WORK_APPS_TAP;
import static com.android.launcher3.workprofile.PersonalWorkSlidingTabStrip.getTabWidth;
import android.content.Context;
import android.graphics.Insets;
@@ -96,7 +97,6 @@ public class WorkModeSwitch extends Button implements Insettable, View.OnClickLi
}
DeviceProfile dp = ActivityContext.lookupContext(getContext()).getDeviceProfile();
lp.rightMargin = lp.leftMargin = dp.allAppsLeftRightPadding;
if (!dp.isGestureMode) {
if (dp.isTaskbarPresent) {
bottomMargin += dp.taskbarSize;
@@ -109,6 +109,18 @@ public class WorkModeSwitch extends Button implements Insettable, View.OnClickLi
}
}
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
DeviceProfile dp = ActivityContext.lookupContext(getContext()).getDeviceProfile();
View parent = (View) getParent();
int size = parent.getWidth() - parent.getPaddingLeft() - parent.getPaddingRight()
- 2 * dp.allAppsLeftRightPadding;
int tabWidth = getTabWidth(getContext(), size);
int shift = (size - tabWidth) / 2 + dp.allAppsLeftRightPadding;
setTranslationX(Utilities.isRtl(getResources()) ? shift : -shift);
}
@Override
public void onActivePageChanged(int page) {
mOnWorkTab = page == ActivityAllAppsContainerView.AdapterHolder.WORK;