Merge "Adds header protection on tablet all apps panel." into tm-qpr-dev
diff --git a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsContainerView.java b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsContainerView.java
index f8d9d11..70405d9 100644
--- a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsContainerView.java
+++ b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsContainerView.java
@@ -19,6 +19,8 @@
import android.util.AttributeSet;
import android.view.WindowInsets;
+import com.android.launcher3.DeviceProfile;
+import com.android.launcher3.R;
import com.android.launcher3.allapps.ActivityAllAppsContainerView;
import com.android.launcher3.taskbar.overlay.TaskbarOverlayContext;
@@ -44,4 +46,11 @@
protected boolean isSearchSupported() {
return false;
}
+
+ @Override
+ protected void updateBackground(DeviceProfile deviceProfile) {
+ super.updateBackground(deviceProfile);
+ // TODO(b/240670050): Remove this and add header protection for the taskbar entrypoint.
+ mBottomSheetBackground.setBackgroundResource(R.drawable.bg_rounded_corner_bottom_sheet);
+ }
}
diff --git a/res/layout/all_apps_bottom_sheet_background.xml b/res/layout/all_apps_bottom_sheet_background.xml
index 3e47690..b0157c9 100644
--- a/res/layout/all_apps_bottom_sheet_background.xml
+++ b/res/layout/all_apps_bottom_sheet_background.xml
@@ -16,8 +16,7 @@
<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_rounded_corner_bottom_sheet">
+ android:layout_height="match_parent">
<View
android:id="@+id/bottom_sheet_handle_area"
diff --git a/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java b/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java
index 5296df1..e21b4db 100644
--- a/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java
@@ -281,6 +281,10 @@
@Override
public int getHeaderBottom() {
if (FeatureFlags.ENABLE_FLOATING_SEARCH_BAR.get()) {
+ if (mActivityContext.getDeviceProfile().isTablet) {
+ return super.getHeaderBottom() + mHeader.getClipTop()
+ + mBottomSheetBackground.getTop();
+ }
return super.getHeaderBottom() + mHeader.getClipTop();
}
return super.getHeaderBottom() + mSearchContainer.getBottom();
diff --git a/src/com/android/launcher3/allapps/BaseAllAppsContainerView.java b/src/com/android/launcher3/allapps/BaseAllAppsContainerView.java
index 65b4661..aea98ae 100644
--- a/src/com/android/launcher3/allapps/BaseAllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/BaseAllAppsContainerView.java
@@ -26,8 +26,11 @@
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
+import android.graphics.Path;
+import android.graphics.Path.Direction;
import android.graphics.Point;
import android.graphics.Rect;
+import android.graphics.RectF;
import android.os.Bundle;
import android.os.Parcelable;
import android.os.Process;
@@ -35,6 +38,7 @@
import android.util.AttributeSet;
import android.util.Log;
import android.util.SparseArray;
+import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
@@ -121,7 +125,7 @@
private SearchRecyclerView mSearchRecyclerView;
protected FloatingHeaderView mHeader;
- private View mBottomSheetBackground;
+ protected View mBottomSheetBackground;
private View mBottomSheetHandleArea;
@Nullable private View mSearchBarProtection;
@@ -134,8 +138,12 @@
private final int mScrimColor;
private final int mHeaderProtectionColor;
protected final float mHeaderThreshold;
+ private final Path mTmpPath = new Path();
+ private final RectF mTmpRectF = new RectF();
+ private float[] mBottomSheetCornerRadii;
private ScrimView mScrimView;
private int mHeaderColor;
+ private int mBottomSheetBackgroundColor;
private int mTabsProtectionAlpha;
protected BaseAllAppsContainerView(Context context, AttributeSet attrs, int defStyleAttr) {
@@ -236,6 +244,9 @@
protected void updateBackground(DeviceProfile deviceProfile) {
mBottomSheetBackground.setVisibility(deviceProfile.isTablet ? View.VISIBLE : View.GONE);
+ // Note: For tablets, the opaque background and header protection are added in drawOnScrim.
+ // For the taskbar entrypoint, the scrim is drawn differently, so a static background is
+ // added in TaskbarAllAppsContainerView and header protection is not yet supported.
}
private void onAppsUpdated() {
@@ -428,9 +439,22 @@
rebindAdapters(true /* force */);
mBottomSheetBackground = findViewById(R.id.bottom_sheet_background);
- updateBackground(mActivityContext.getDeviceProfile());
-
mBottomSheetHandleArea = findViewById(R.id.bottom_sheet_handle_area);
+ float cornerRadius = Themes.getDialogCornerRadius(getContext());
+ mBottomSheetCornerRadii = new float[]{
+ cornerRadius,
+ cornerRadius, // Top left radius in px
+ cornerRadius,
+ cornerRadius, // Top right radius in px
+ 0,
+ 0, // Bottom right
+ 0,
+ 0 // Bottom left
+ };
+ final TypedValue value = new TypedValue();
+ getContext().getTheme().resolveAttribute(android.R.attr.colorBackground, value, true);
+ mBottomSheetBackgroundColor = value.data;
+ updateBackground(mActivityContext.getDeviceProfile());
}
@Override
@@ -743,6 +767,20 @@
@Override
public void drawOnScrim(Canvas canvas) {
+ boolean isTablet = mActivityContext.getDeviceProfile().isTablet;
+
+ // Draw full background panel for tablets.
+ if (isTablet) {
+ mHeaderPaint.setColor(mBottomSheetBackgroundColor);
+ View panel = (View) mBottomSheetBackground;
+ float translationY = ((View) panel.getParent()).getTranslationY();
+ mTmpRectF.set(panel.getLeft(), panel.getTop() + translationY,
+ panel.getRight(), panel.getBottom());
+ mTmpPath.reset();
+ mTmpPath.addRoundRect(mTmpRectF, mBottomSheetCornerRadii, Direction.CW);
+ canvas.drawPath(mTmpPath, mHeaderPaint);
+ }
+
if (!mHeader.isHeaderProtectionSupported()) {
return;
}
@@ -753,24 +791,44 @@
mHeaderPaint.setColor(mHeaderColor);
mHeaderPaint.setAlpha((int) (getAlpha() * Color.alpha(mHeaderColor)));
}
- if (mHeaderPaint.getColor() != mScrimColor && mHeaderPaint.getColor() != 0) {
- int bottom = getHeaderBottom();
- FloatingHeaderView headerView = getFloatingHeaderView();
- if (!mUsingTabs && !FeatureFlags.ENABLE_FLOATING_SEARCH_BAR.get()) {
- // Add protection which is otherwise added when tabs scroll up.
- bottom += headerView.getTabsAdditionalPaddingTop();
+ if (mHeaderPaint.getColor() == mScrimColor || mHeaderPaint.getColor() == 0) {
+ return;
+ }
+ int bottom = getHeaderBottom();
+ FloatingHeaderView headerView = getFloatingHeaderView();
+ if (!mUsingTabs && !FeatureFlags.ENABLE_FLOATING_SEARCH_BAR.get()) {
+ // Add protection which is otherwise added when tabs scroll up.
+ bottom += headerView.getTabsAdditionalPaddingTop();
+ }
+ if (isTablet) {
+ // Start adding header protection if search bar or tabs will attach to the top.
+ if (!FeatureFlags.ENABLE_FLOATING_SEARCH_BAR.get() || mUsingTabs) {
+ View panel = (View) mBottomSheetBackground;
+ float translationY = ((View) panel.getParent()).getTranslationY();
+ mTmpRectF.set(panel.getLeft(), panel.getTop() + translationY, panel.getRight(),
+ bottom);
+ mTmpPath.reset();
+ mTmpPath.addRoundRect(mTmpRectF, mBottomSheetCornerRadii, Direction.CW);
+ canvas.drawPath(mTmpPath, mHeaderPaint);
}
+ } else {
canvas.drawRect(0, 0, canvas.getWidth(), bottom, mHeaderPaint);
- int tabsHeight = headerView.getPeripheralProtectionHeight();
- if (mTabsProtectionAlpha > 0 && tabsHeight != 0) {
- if (DEBUG_HEADER_PROTECTION) {
- mHeaderPaint.setColor(Color.BLUE);
- mHeaderPaint.setAlpha(255);
- } else {
- mHeaderPaint.setAlpha((int) (getAlpha() * mTabsProtectionAlpha));
- }
- canvas.drawRect(0, bottom, canvas.getWidth(), bottom + tabsHeight, mHeaderPaint);
+ }
+ int tabsHeight = headerView.getPeripheralProtectionHeight();
+ if (mTabsProtectionAlpha > 0 && tabsHeight != 0) {
+ if (DEBUG_HEADER_PROTECTION) {
+ mHeaderPaint.setColor(Color.BLUE);
+ mHeaderPaint.setAlpha(255);
+ } else {
+ mHeaderPaint.setAlpha((int) (getAlpha() * mTabsProtectionAlpha));
}
+ int left = 0;
+ int right = canvas.getWidth();
+ if (isTablet) {
+ left = mBottomSheetBackground.getLeft();
+ right = mBottomSheetBackground.getRight();
+ }
+ canvas.drawRect(left, bottom, right, bottom + tabsHeight, mHeaderPaint);
}
}