Fix workFAB alignment.

The calculation to find how much the FAB should shift is outdated as using the
method from deviceProfile#getAllAppsIconStartMargin() gives a better value.

bug:332761814
Test manually:
after LTR expanded:https://drive.google.com/file/d/1NZQW0CF9VFZBoM3673LFiUknqW2nf4r8/view?usp=sharing
after LTR collapsed: https://drive.google.com/file/d/1NRpdTuYQntSs5-yeRL1fJIJy2ETDOYLM/view?usp=sharing
after RTL collapsed: https://drive.google.com/file/d/1NE51MIsS5Fk0DwAuzCehEQzTa42OGj_o/view?usp=sharing
after RTL expanded: https://drive.google.com/file/d/1NPgiPfzw3DOa_xbB_TtlwK-G1Y5WCi53/view?usp=sharing
Flag:None

Change-Id: I07579635d6176553d27497cb73b81799648fb014
diff --git a/src/com/android/launcher3/allapps/WorkModeSwitch.java b/src/com/android/launcher3/allapps/WorkModeSwitch.java
index eb7d429..72b34c3 100644
--- a/src/com/android/launcher3/allapps/WorkModeSwitch.java
+++ b/src/com/android/launcher3/allapps/WorkModeSwitch.java
@@ -15,12 +15,9 @@
  */
 package com.android.launcher3.allapps;
 
-import static com.android.launcher3.workprofile.PersonalWorkSlidingTabStrip.getTabWidth;
-
 import android.content.Context;
 import android.graphics.Rect;
 import android.util.AttributeSet;
-import android.view.View;
 import android.view.WindowInsets;
 import android.widget.ImageView;
 import android.widget.LinearLayout;
@@ -53,6 +50,7 @@
     private final Rect mImeInsets = new Rect();
     private int mFlags;
     private final ActivityContext mActivityContext;
+    private final Context mContext;
 
     // Threshold when user scrolls up/down to determine when should button extend/collapse
     private final int mScrollThreshold;
@@ -71,6 +69,7 @@
 
     public WorkModeSwitch(@NonNull Context context, @NonNull AttributeSet attrs, int defStyleAttr) {
         super(context, attrs, defStyleAttr);
+        mContext = context;
         mScrollThreshold = Utilities.dpToPx(SCROLL_THRESHOLD_DP);
         mActivityContext = ActivityContext.lookupContext(getContext());
         mStatsLogManager = mActivityContext.getStatsLogManager();
@@ -114,13 +113,8 @@
     @Override
     protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
         super.onLayout(changed, left, top, right, bottom);
-        View parent = (View) getParent();
         boolean isRtl = Utilities.isRtl(getResources());
-        Rect allAppsPadding = mActivityContext.getDeviceProfile().allAppsPadding;
-        int size = parent.getWidth() - parent.getPaddingLeft() - parent.getPaddingRight()
-                - (allAppsPadding.left + allAppsPadding.right);
-        int tabWidth = getTabWidth(getContext(), size);
-        int shift = (size - tabWidth) / 2 + (isRtl ? allAppsPadding.left : allAppsPadding.right);
+        int shift = mActivityContext.getDeviceProfile().getAllAppsIconStartMargin(mContext);
         setTranslationX(isRtl ? shift : -shift);
     }