Change AllApps padding to use a Rect

AllApps uses different values for left and right padding in some places (e.g. ActivityAllAppsContainerView uses workspacePadding.left/right), and this change is the first step into moving those values into DeviceProfile.

Bug: 269632571
Test: NexusLauncherTest
Flag: NONE
Change-Id: I14c4edf55ca74f256b1aaa336fff246a0c78e25d
This commit is contained in:
Thales Lima
2023-10-30 12:24:05 +00:00
parent 866e77101c
commit b433c9c312
17 changed files with 70 additions and 53 deletions

View File

@@ -117,12 +117,13 @@ public class WorkModeSwitch extends LinearLayout implements Insettable,
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
View parent = (View) getParent();
int allAppsLeftRightPadding = mActivityContext.getDeviceProfile().allAppsLeftRightPadding;
boolean isRtl = Utilities.isRtl(getResources());
Rect allAppsPadding = mActivityContext.getDeviceProfile().allAppsPadding;
int size = parent.getWidth() - parent.getPaddingLeft() - parent.getPaddingRight()
- 2 * allAppsLeftRightPadding;
- (allAppsPadding.left + allAppsPadding.right);
int tabWidth = getTabWidth(getContext(), size);
int shift = (size - tabWidth) / 2 + allAppsLeftRightPadding;
setTranslationX(Utilities.isRtl(getResources()) ? shift : -shift);
int shift = (size - tabWidth) / 2 + (isRtl ? allAppsPadding.left : allAppsPadding.right);
setTranslationX(isRtl ? shift : -shift);
}
@Override