Adjust height of tablet AllApps base on row height
- Also used hotseatQsbHeight for AllApps QSB height as they have to match to transform between each other
Fix: 232907846
Test: manual on different tablets
Test: atest DeviceProfileTest
Change-Id: I001d0e129db2a5de6c8ace4c3302381110da03f1
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index 366d372..f38cdc8 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -38,7 +38,6 @@
import com.android.launcher3.CellLayout.ContainerType;
import com.android.launcher3.DevicePaddings.DevicePadding;
-import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.icons.DotRenderer;
import com.android.launcher3.icons.GraphicsUtils;
import com.android.launcher3.icons.IconNormalizer;
@@ -54,6 +53,8 @@
public class DeviceProfile {
private static final int DEFAULT_DOT_SIZE = 100;
+ private static final float ALL_APPS_TABLET_MAX_ROWS = 5.5f;
+
// Ratio of empty space, qsb should take up to appear visually centered.
private final float mQsbCenterFactor;
@@ -167,13 +168,12 @@
// Start is the side next to the nav bar, end is the side next to the workspace
public final int hotseatBarSidePaddingStartPx;
public final int hotseatBarSidePaddingEndPx;
+ public int hotseatQsbWidth; // only used when isQsbInline
public final int hotseatQsbHeight;
public final int hotseatQsbVisualHeight;
private final int hotseatQsbShadowHeight;
public int hotseatBorderSpace;
- public int qsbWidth; // only used when isQsbInline
-
// All apps
public Point allAppsBorderSpacePx;
public int allAppsShiftRange;
@@ -309,10 +309,6 @@
+ res.getDimensionPixelSize(R.dimen.bottom_sheet_extra_top_padding)
+ (isTablet ? 0 : edgeMarginPx); // phones need edgeMarginPx additional padding
- allAppsTopPadding = isTablet ? bottomSheetTopPadding : 0;
- allAppsShiftRange = isTablet
- ? heightPx - allAppsTopPadding
- : res.getDimensionPixelSize(R.dimen.all_apps_starting_vertical_translate);
folderLabelTextScale = res.getFloat(R.dimen.folder_label_text_scale);
folderContentPaddingLeftRight =
res.getDimensionPixelSize(R.dimen.folder_content_padding_left_right);
@@ -463,7 +459,21 @@
// Hotseat and QSB width depends on updated cellSize and workspace padding
hotseatBorderSpace = calculateHotseatBorderSpace();
- qsbWidth = calculateQsbWidth();
+ hotseatQsbWidth = calculateQsbWidth();
+
+ // AllApps height calculation depends on updated cellSize
+ if (isTablet) {
+ int collapseHandleHeight =
+ res.getDimensionPixelOffset(R.dimen.bottom_sheet_handle_area_height);
+ int contentHeight = heightPx - collapseHandleHeight - hotseatQsbHeight;
+ int targetContentHeight = (int) (allAppsCellHeightPx * ALL_APPS_TABLET_MAX_ROWS);
+ allAppsTopPadding = Math.max(mInsets.top, contentHeight - targetContentHeight);
+ allAppsShiftRange = heightPx - allAppsTopPadding;
+ } else {
+ allAppsTopPadding = 0;
+ allAppsShiftRange =
+ res.getDimensionPixelSize(R.dimen.all_apps_starting_vertical_translate);
+ }
flingToDeleteThresholdVelocity = res.getDimensionPixelSize(
R.dimen.drag_flingToDeleteMinVelocity);
@@ -1052,7 +1062,7 @@
hotseatBarSizePx - hotseatBarBottomPadding - hotseatCellHeightPx;
// Push icons to the side
- int additionalQsbSpace = isQsbInline ? qsbWidth + hotseatBorderSpace : 0;
+ int additionalQsbSpace = isQsbInline ? hotseatQsbWidth + hotseatBorderSpace : 0;
int requiredWidth = iconSizePx * numShownHotseatIcons
+ hotseatBorderSpace * (numShownHotseatIcons - 1)
+ additionalQsbSpace;
@@ -1077,7 +1087,7 @@
hotseatBarPadding.right += diff;
}
} else if (isScalableGrid) {
- int sideSpacing = (availableWidthPx - qsbWidth) / 2;
+ int sideSpacing = (availableWidthPx - hotseatQsbWidth) / 2;
hotseatBarPadding.set(sideSpacing,
0,
sideSpacing,
@@ -1350,7 +1360,7 @@
writer.println(prefix + "\tnumShownHotseatIcons: " + numShownHotseatIcons);
writer.println(prefix + pxToDpStr("hotseatBorderSpace", hotseatBorderSpace));
writer.println(prefix + "\tisQsbInline: " + isQsbInline);
- writer.println(prefix + pxToDpStr("qsbWidth", qsbWidth));
+ writer.println(prefix + pxToDpStr("hotseatQsbWidth", hotseatQsbWidth));
writer.println(prefix + "\tisTaskbarPresent:" + isTaskbarPresent);
writer.println(prefix + "\tisTaskbarPresentInApps:" + isTaskbarPresentInApps);
diff --git a/src/com/android/launcher3/Hotseat.java b/src/com/android/launcher3/Hotseat.java
index 05ed319..bf492a9 100644
--- a/src/com/android/launcher3/Hotseat.java
+++ b/src/com/android/launcher3/Hotseat.java
@@ -47,7 +47,6 @@
private Consumer<Boolean> mOnVisibilityAggregatedCallback;
private final View mQsb;
- private final int mQsbHeight;
public Hotseat(Context context) {
this(context, null);
@@ -62,8 +61,6 @@
mQsb = LayoutInflater.from(context).inflate(R.layout.search_container_hotseat, this, false);
addView(mQsb);
-
- mQsbHeight = getResources().getDimensionPixelSize(R.dimen.qsb_widget_height);
}
/**
@@ -171,29 +168,29 @@
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
- int qsbWidth = mActivity.getDeviceProfile().qsbWidth;
-
- mQsb.measure(MeasureSpec.makeMeasureSpec(qsbWidth, MeasureSpec.EXACTLY),
- MeasureSpec.makeMeasureSpec(mQsbHeight, MeasureSpec.EXACTLY));
+ DeviceProfile dp = mActivity.getDeviceProfile();
+ mQsb.measure(MeasureSpec.makeMeasureSpec(dp.hotseatQsbWidth, MeasureSpec.EXACTLY),
+ MeasureSpec.makeMeasureSpec(dp.hotseatQsbHeight, MeasureSpec.EXACTLY));
}
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
super.onLayout(changed, l, t, r, b);
- int qsbWidth = mQsb.getMeasuredWidth();
+ int qsbMeasuredWidth = mQsb.getMeasuredWidth();
int left;
- if (mActivity.getDeviceProfile().isQsbInline) {
- int qsbSpace = mActivity.getDeviceProfile().hotseatBorderSpace;
+ DeviceProfile dp = mActivity.getDeviceProfile();
+ if (dp.isQsbInline) {
+ int qsbSpace = dp.hotseatBorderSpace;
left = Utilities.isRtl(getResources()) ? r - getPaddingRight() + qsbSpace
- : l + getPaddingLeft() - qsbWidth - qsbSpace;
+ : l + getPaddingLeft() - qsbMeasuredWidth - qsbSpace;
} else {
- left = (r - l - qsbWidth) / 2;
+ left = (r - l - qsbMeasuredWidth) / 2;
}
- int right = left + qsbWidth;
+ int right = left + qsbMeasuredWidth;
- int bottom = b - t - mActivity.getDeviceProfile().getQsbOffsetY();
- int top = bottom - mQsbHeight;
+ int bottom = b - t - dp.getQsbOffsetY();
+ int top = bottom - dp.hotseatQsbHeight;
mQsb.layout(left, top, right, bottom);
}
diff --git a/src/com/android/launcher3/allapps/WorkModeSwitch.java b/src/com/android/launcher3/allapps/WorkModeSwitch.java
index aee7c4c..fedc91f 100644
--- a/src/com/android/launcher3/allapps/WorkModeSwitch.java
+++ b/src/com/android/launcher3/allapps/WorkModeSwitch.java
@@ -91,12 +91,12 @@
MarginLayoutParams lp = (MarginLayoutParams) getLayoutParams();
if (lp != null) {
int bottomMargin = getResources().getDimensionPixelSize(R.dimen.work_fab_margin_bottom);
+ DeviceProfile dp = ActivityContext.lookupContext(getContext()).getDeviceProfile();
if (FeatureFlags.ENABLE_FLOATING_SEARCH_BAR.get()) {
bottomMargin <<= 1; // Double margin to add space above search bar.
- bottomMargin += getResources().getDimensionPixelSize(R.dimen.qsb_widget_height);
+ bottomMargin += dp.hotseatQsbHeight;
}
- DeviceProfile dp = ActivityContext.lookupContext(getContext()).getDeviceProfile();
if (!dp.isGestureMode) {
if (dp.isTaskbarPresent) {
bottomMargin += dp.taskbarSize;