Put AllApps in bottom sheet for tablets
http://screen/7steQ7W8U2ga3Hs
Bug: 208599118
Test: manual
Change-Id: I36cbac3cb7cb214081e5a33a6e042ae83e745f23
diff --git a/quickstep/src/com/android/launcher3/uioverrides/states/AllAppsState.java b/quickstep/src/com/android/launcher3/uioverrides/states/AllAppsState.java
index 8f89d30..330e496 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/states/AllAppsState.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/states/AllAppsState.java
@@ -33,13 +33,6 @@
private static final int STATE_FLAGS = FLAG_WORKSPACE_INACCESSIBLE | FLAG_CLOSE_POPUPS;
- private static final PageAlphaProvider PAGE_ALPHA_PROVIDER = new PageAlphaProvider(DEACCEL_2) {
- @Override
- public float getPageAlpha(int pageIndex) {
- return 0;
- }
- };
-
public AllAppsState(int id) {
super(id, LAUNCHER_STATE_ALLAPPS, STATE_FLAGS);
}
@@ -82,7 +75,15 @@
@Override
public PageAlphaProvider getWorkspacePageAlphaProvider(Launcher launcher) {
- return PAGE_ALPHA_PROVIDER;
+ PageAlphaProvider superPageAlphaProvider = super.getWorkspacePageAlphaProvider(launcher);
+ return new PageAlphaProvider(DEACCEL_2) {
+ @Override
+ public float getPageAlpha(int pageIndex) {
+ return launcher.getDeviceProfile().isTablet
+ ? superPageAlphaProvider.getPageAlpha(pageIndex)
+ : 0;
+ }
+ };
}
@Override
@@ -97,6 +98,8 @@
@Override
public int getWorkspaceScrimColor(Launcher launcher) {
- return Themes.getAttrColor(launcher, R.attr.allAppsScrimColor);
+ return launcher.getDeviceProfile().isTablet
+ ? launcher.getResources().getColor(R.color.widgets_picker_scrim)
+ : Themes.getAttrColor(launcher, R.attr.allAppsScrimColor);
}
}
diff --git a/res/drawable/bg_all_apps_bottom_sheet.xml b/res/drawable/bg_all_apps_bottom_sheet.xml
new file mode 100644
index 0000000..dba2fee
--- /dev/null
+++ b/res/drawable/bg_all_apps_bottom_sheet.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2022 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<ripple android:color="?android:attr/colorControlHighlight"
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:androidprv="http://schemas.android.com/apk/prv/res/android">
+ <item>
+ <shape android:shape="rectangle"
+ android:tint="?colorButtonNormal">
+ <corners
+ android:topLeftRadius="@dimen/dialogCornerRadius"
+ android:topRightRadius="@dimen/dialogCornerRadius"/>
+ <solid android:color="?attr/allAppsScrimColor" />
+ </shape>
+ </item>
+</ripple>
\ No newline at end of file
diff --git a/res/values-sw600dp/dimens.xml b/res/values-sw600dp/dimens.xml
index 3727932..157cefa 100644
--- a/res/values-sw600dp/dimens.xml
+++ b/res/values-sw600dp/dimens.xml
@@ -20,4 +20,7 @@
<!-- Widgets pickers -->
<dimen name="widget_list_horizontal_margin">32dp</dimen>
+
+<!-- AllApps -->
+ <dimen name="all_apps_bottom_sheet_horizontal_padding">32dp</dimen>
</resources>
diff --git a/res/values-sw720dp/dimens.xml b/res/values-sw720dp/dimens.xml
new file mode 100644
index 0000000..9d7941f
--- /dev/null
+++ b/res/values-sw720dp/dimens.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2022 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at`
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<resources>
+<!-- AllApps -->
+ <dimen name="all_apps_bottom_sheet_horizontal_padding">41dp</dimen>
+</resources>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 086a254..167c6b2 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -114,6 +114,7 @@
<dimen name="all_apps_content_fade_in_offset">150dp</dimen>
<dimen name="all_apps_tip_bottom_margin">8dp</dimen>
<dimen name="all_apps_height_extra">6dp</dimen>
+ <dimen name="all_apps_bottom_sheet_horizontal_padding">0dp</dimen>
<!-- The size of corner radius of the arrow in the arrow toast. -->
<dimen name="arrow_toast_corner_radius">2dp</dimen>
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);
}
diff --git a/src_ui_overrides/com/android/launcher3/uioverrides/states/AllAppsState.java b/src_ui_overrides/com/android/launcher3/uioverrides/states/AllAppsState.java
index 978c321..5543cc2 100644
--- a/src_ui_overrides/com/android/launcher3/uioverrides/states/AllAppsState.java
+++ b/src_ui_overrides/com/android/launcher3/uioverrides/states/AllAppsState.java
@@ -34,13 +34,6 @@
private static final int STATE_FLAGS = FLAG_WORKSPACE_INACCESSIBLE;
- private static final PageAlphaProvider PAGE_ALPHA_PROVIDER = new PageAlphaProvider(DEACCEL_2) {
- @Override
- public float getPageAlpha(int pageIndex) {
- return 0;
- }
- };
-
public AllAppsState(int id) {
super(id, LAUNCHER_STATE_ALLAPPS, STATE_FLAGS);
}
@@ -68,7 +61,15 @@
@Override
public PageAlphaProvider getWorkspacePageAlphaProvider(Launcher launcher) {
- return PAGE_ALPHA_PROVIDER;
+ PageAlphaProvider superPageAlphaProvider = super.getWorkspacePageAlphaProvider(launcher);
+ return new PageAlphaProvider(DEACCEL_2) {
+ @Override
+ public float getPageAlpha(int pageIndex) {
+ return launcher.getDeviceProfile().isTablet
+ ? superPageAlphaProvider.getPageAlpha(pageIndex)
+ : 0;
+ }
+ };
}
@Override
@@ -78,6 +79,8 @@
@Override
public int getWorkspaceScrimColor(Launcher launcher) {
- return Themes.getAttrColor(launcher, R.attr.allAppsScrimColor);
+ return launcher.getDeviceProfile().isTablet
+ ? launcher.getResources().getColor(R.color.widgets_picker_scrim)
+ : Themes.getAttrColor(launcher, R.attr.allAppsScrimColor);
}
}