Avoid AllApps bottom sheet from being and add collapse handle
- Instead of using top margin, use top padding instead
- Add a separate LinearView for the bottom sheet background
- Added a handle to bottom sheet background that handle touches
Bug: 208599118
Test: phone, tablet and taskbar
Change-Id: Id8d3cb5ee6c58193926e2cf5ea7b0cb2280098be
diff --git a/quickstep/res/layout/taskbar_all_apps.xml b/quickstep/res/layout/taskbar_all_apps.xml
index 2848b0f..1ad20cc 100644
--- a/quickstep/res/layout/taskbar_all_apps.xml
+++ b/quickstep/res/layout/taskbar_all_apps.xml
@@ -30,6 +30,10 @@
android:theme="?attr/allAppsTheme">
<include
+ layout="@layout/all_apps_bottom_sheet_background"
+ android:visibility="gone" />
+
+ <include
layout="@layout/all_apps_rv_layout"
android:visibility="gone" />
diff --git a/res/layout/all_apps.xml b/res/layout/all_apps.xml
index 6df6212..2ac7e63 100644
--- a/res/layout/all_apps.xml
+++ b/res/layout/all_apps.xml
@@ -26,6 +26,10 @@
android:saveEnabled="false">
<include
+ layout="@layout/all_apps_bottom_sheet_background"
+ android:visibility="gone" />
+
+ <include
layout="@layout/all_apps_rv_layout"
android:visibility="gone" />
diff --git a/res/layout/all_apps_bottom_sheet_background.xml b/res/layout/all_apps_bottom_sheet_background.xml
new file mode 100644
index 0000000..ad10d68
--- /dev/null
+++ b/res/layout/all_apps_bottom_sheet_background.xml
@@ -0,0 +1,35 @@
+<?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.
+-->
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/bottom_sheet_background"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="@drawable/bg_all_apps_bottom_sheet">
+
+ <View
+ android:id="@+id/bottom_sheet_handle_area"
+ android:layout_width="match_parent"
+ android:layout_height="34dp" />
+
+ <View
+ android:id="@+id/bottom_sheet_handle"
+ android:layout_width="48dp"
+ android:layout_height="2dp"
+ android:layout_gravity="center_horizontal"
+ android:layout_marginTop="16dp"
+ android:layout_marginBottom="16dp"
+ android:background="?android:attr/textColorSecondary" />
+</FrameLayout>
diff --git a/res/layout/secondary_launcher.xml b/res/layout/secondary_launcher.xml
index 3ccd4f2..0fe05ee 100644
--- a/res/layout/secondary_launcher.xml
+++ b/res/layout/secondary_launcher.xml
@@ -42,7 +42,7 @@
android:onClick="onAppsButtonClicked" />
<view
- class="com.android.launcher3.allapps.ActivityAllAppsContainerView"
+ class="com.android.launcher3.allapps.SecondaryLauncherAllAppsContainerView"
android:id="@+id/apps_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
@@ -56,6 +56,10 @@
android:visibility="invisible" >
<include
+ layout="@layout/all_apps_bottom_sheet_background"
+ android:visibility="gone" />
+
+ <include
layout="@layout/all_apps_rv_layout"
android:visibility="gone" />
diff --git a/src/com/android/launcher3/allapps/BaseAllAppsContainerView.java b/src/com/android/launcher3/allapps/BaseAllAppsContainerView.java
index 2b2c7c5..a66ae78 100644
--- a/src/com/android/launcher3/allapps/BaseAllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/BaseAllAppsContainerView.java
@@ -110,6 +110,8 @@
private AllAppsPagedView mViewPager;
protected FloatingHeaderView mHeader;
+ private View mBottomSheetBackground;
+ private View mBottomSheetHandleArea;
protected boolean mUsingTabs;
private boolean mHasWorkApps;
@@ -146,8 +148,6 @@
mNavBarScrimPaint.setColor(Themes.getAttrColor(context, R.attr.allAppsNavBarScrimColor));
mAllAppsStore.addUpdateListener(this::onAppsUpdated);
-
- updateBackground(mActivityContext.getDeviceProfile());
}
/** Creates the adapter provider for the main section. */
@@ -222,10 +222,8 @@
updateBackground(dp);
}
- private void updateBackground(DeviceProfile deviceProfile) {
- setBackground(deviceProfile.isTablet
- ? getContext().getDrawable(R.drawable.bg_all_apps_bottom_sheet)
- : null);
+ protected void updateBackground(DeviceProfile deviceProfile) {
+ mBottomSheetBackground.setVisibility(deviceProfile.isTablet ? View.VISIBLE : View.GONE);
}
private void onAppsUpdated() {
@@ -253,7 +251,9 @@
if (!mActivityContext.getDragLayer().isEventOverView(this, ev)) {
return true;
}
- // TODO(b/216203409) Support dragging down from bottom sheet divider, if present.
+ if (mActivityContext.getDragLayer().isEventOverView(mBottomSheetHandleArea, ev)) {
+ return true;
+ }
AllAppsRecyclerView rv = getActiveRecyclerView();
if (rv == null) {
return true;
@@ -375,6 +375,11 @@
mHeader = findViewById(R.id.all_apps_header);
rebindAdapters(true /* force */);
+
+ mBottomSheetBackground = findViewById(R.id.bottom_sheet_background);
+ updateBackground(mActivityContext.getDeviceProfile());
+
+ mBottomSheetHandleArea = findViewById(R.id.bottom_sheet_handle_area);
}
@Override
@@ -392,7 +397,6 @@
}
MarginLayoutParams mlp = (MarginLayoutParams) getLayoutParams();
- mlp.topMargin = grid.isTablet ? insets.top : 0;
int leftRightMargin = grid.allAppsLeftRightMargin;
mlp.leftMargin = insets.left + leftRightMargin;
mlp.rightMargin = insets.right + leftRightMargin;
@@ -401,7 +405,7 @@
if (grid.isVerticalBarLayout()) {
setPadding(grid.workspacePadding.left, 0, grid.workspacePadding.right, 0);
} else {
- setPadding(0, 0, 0, 0);
+ setPadding(0, grid.isTablet ? insets.top : 0, 0, 0);
}
InsettableFrameLayout.dispatchInsets(this, insets);
diff --git a/src/com/android/launcher3/allapps/SecondaryLauncherAllAppsContainerView.java b/src/com/android/launcher3/allapps/SecondaryLauncherAllAppsContainerView.java
new file mode 100644
index 0000000..0719c43
--- /dev/null
+++ b/src/com/android/launcher3/allapps/SecondaryLauncherAllAppsContainerView.java
@@ -0,0 +1,45 @@
+/*
+ * 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.
+ */
+package com.android.launcher3.allapps;
+
+import android.content.Context;
+import android.util.AttributeSet;
+
+import com.android.launcher3.DeviceProfile;
+import com.android.launcher3.secondarydisplay.SecondaryDisplayLauncher;
+
+/**
+ * AllAppsContainerView for secondary launcher
+ */
+public class SecondaryLauncherAllAppsContainerView extends
+ ActivityAllAppsContainerView<SecondaryDisplayLauncher> {
+
+ public SecondaryLauncherAllAppsContainerView(Context context) {
+ this(context, null);
+ }
+
+ public SecondaryLauncherAllAppsContainerView(Context context, AttributeSet attrs) {
+ this(context, attrs, 0);
+ }
+
+ public SecondaryLauncherAllAppsContainerView(Context context, AttributeSet attrs,
+ int defStyleAttr) {
+ super(context, attrs, defStyleAttr);
+ }
+
+ @Override
+ protected void updateBackground(DeviceProfile deviceProfile) {}
+}