Put AllApps in bottom sheet for tablets
http://screen/7steQ7W8U2ga3Hs
Bug: 208599118
Test: manual
Change-Id: I36cbac3cb7cb214081e5a33a6e042ae83e745f23
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index 8a5b888..a2324ac 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -174,6 +174,7 @@
public int allAppsIconSizePx;
public int allAppsIconDrawablePaddingPx;
public int allAppsLeftRightPadding;
+ public int allAppsLeftRightMargin;
public final int numShownAllAppsColumns;
public float allAppsIconTextSizePx;
@@ -595,11 +596,16 @@
+ textHeight + (topBottomPadding * 2);
}
- private void updateAllAppsWidth() {
- if (isTwoPanels) {
+ private void updateAllAppsWidth(Resources res) {
+
+ if (isTablet) {
+ allAppsLeftRightPadding =
+ res.getDimensionPixelSize(R.dimen.all_apps_bottom_sheet_horizontal_padding)
+ + cellLayoutPaddingLeftRightPx;
int usedWidth = (allAppsCellWidthPx * numShownAllAppsColumns)
- + (allAppsBorderSpacePx.x * (numShownAllAppsColumns + 1));
- allAppsLeftRightPadding = Math.max(1, (availableWidthPx - usedWidth) / 2);
+ + (allAppsBorderSpacePx.x * (numShownAllAppsColumns + 1))
+ + allAppsLeftRightPadding * 2;
+ allAppsLeftRightMargin = Math.max(1, (availableWidthPx - usedWidth) / 2);
} else {
allAppsLeftRightPadding =
desiredWorkspaceHorizontalMarginPx + cellLayoutPaddingLeftRightPx;
@@ -709,7 +715,7 @@
allAppsCellHeightPx = getCellSize().y;
}
allAppsCellWidthPx = allAppsIconSizePx + (2 * allAppsIconDrawablePaddingPx);
- updateAllAppsWidth();
+ updateAllAppsWidth(res);
if (isVerticalLayout) {
hideWorkspaceLabelsIfNotEnoughSpace();
@@ -1102,7 +1108,10 @@
writer.println(prefix + pxToDpStr("allAppsIconDrawablePaddingPx",
allAppsIconDrawablePaddingPx));
writer.println(prefix + pxToDpStr("allAppsCellHeightPx", allAppsCellHeightPx));
+ writer.println(prefix + pxToDpStr("allAppsCellWidthPx", allAppsCellWidthPx));
writer.println(prefix + "\tnumShownAllAppsColumns: " + numShownAllAppsColumns);
+ writer.println(prefix + pxToDpStr("allAppsLeftRightPadding", allAppsLeftRightPadding));
+ writer.println(prefix + pxToDpStr("allAppsLeftRightMargin", allAppsLeftRightMargin));
writer.println(prefix + pxToDpStr("hotseatBarSizePx", hotseatBarSizePx));
writer.println(prefix + pxToDpStr("hotseatCellHeightPx", hotseatCellHeightPx));
diff --git a/src/com/android/launcher3/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java
index 3ba6ea4..f06ec4f 100644
--- a/src/com/android/launcher3/allapps/AllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java
@@ -161,6 +161,8 @@
mNavBarScrimPaint.setColor(Themes.getAttrColor(context, R.attr.allAppsNavBarScrimColor));
mAllAppsStore.addUpdateListener(this::onAppsUpdated);
+
+ updateBackground(mLauncher.getDeviceProfile());
}
@Override
@@ -224,6 +226,13 @@
holder.recyclerView.getRecycledViewPool().clear();
}
}
+ updateBackground(dp);
+ }
+
+ private void updateBackground(DeviceProfile deviceProfile) {
+ setBackground(deviceProfile.isTablet
+ ? getContext().getDrawable(R.drawable.bg_all_apps_bottom_sheet)
+ : null);
}
private void onAppsUpdated() {
@@ -389,8 +398,10 @@
}
ViewGroup.MarginLayoutParams mlp = (MarginLayoutParams) getLayoutParams();
- mlp.leftMargin = insets.left;
- mlp.rightMargin = insets.right;
+ mlp.topMargin = grid.isTablet ? insets.top : 0;
+ int leftRightMargin = grid.allAppsLeftRightMargin;
+ mlp.leftMargin = insets.left + leftRightMargin;
+ mlp.rightMargin = insets.right + leftRightMargin;
setLayoutParams(mlp);
if (grid.isVerticalBarLayout()) {
diff --git a/src/com/android/launcher3/allapps/FloatingHeaderView.java b/src/com/android/launcher3/allapps/FloatingHeaderView.java
index 85ee636..1f7822d 100644
--- a/src/com/android/launcher3/allapps/FloatingHeaderView.java
+++ b/src/com/android/launcher3/allapps/FloatingHeaderView.java
@@ -30,12 +30,12 @@
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;
-import com.android.launcher3.BaseDraggingActivity;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Insettable;
import com.android.launcher3.R;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.uioverrides.plugins.PluginManagerWrapper;
+import com.android.launcher3.views.ActivityContext;
import com.android.systemui.plugins.AllAppsRow;
import com.android.systemui.plugins.AllAppsRow.OnHeightUpdatedListener;
import com.android.systemui.plugins.PluginListener;
@@ -118,7 +118,9 @@
mHeaderTopPadding = context.getResources()
.getDimensionPixelSize(R.dimen.all_apps_header_top_padding);
mHeaderProtectionSupported = context.getResources().getBoolean(
- R.bool.config_header_protection_supported);
+ R.bool.config_header_protection_supported)
+ // TODO(b/208599118) Support header protection for bottom sheet.
+ && !ActivityContext.lookupContext(context).getDeviceProfile().isTablet;
}
@Override
@@ -413,7 +415,7 @@
@Override
public void setInsets(Rect insets) {
- DeviceProfile grid = BaseDraggingActivity.fromContext(getContext()).getDeviceProfile();
+ DeviceProfile grid = ActivityContext.lookupContext(getContext()).getDeviceProfile();
for (FloatingHeaderRow row : mAllRows) {
row.setInsets(insets, grid);
}