diff --git a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsContainerView.java b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsContainerView.java index eeca329e80..7f6d78a420 100644 --- a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsContainerView.java +++ b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsContainerView.java @@ -20,7 +20,6 @@ import android.util.AttributeSet; import android.view.View; 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; @@ -61,13 +60,6 @@ public class TaskbarAllAppsContainerView extends 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); - } - @Override public boolean isInAllApps() { // All apps is always open diff --git a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsSlideInView.java b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsSlideInView.java index fbc7be0832..c6f7561ef9 100644 --- a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsSlideInView.java +++ b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsSlideInView.java @@ -97,6 +97,8 @@ public class TaskbarAllAppsSlideInView extends AbstractSlideInView return mSearchUiManager; } + public View getBottomSheetBackground() { + return mBottomSheetBackground; + } + public View getSearchView() { return mSearchContainer; } @@ -905,7 +910,7 @@ public class ActivityAllAppsContainerView * The container for A-Z apps (the ViewPager for main+work tabs, or main RV). This is currently * hidden while searching. **/ - protected View getAppsRecyclerViewContainer() { + public ViewGroup getAppsRecyclerViewContainer() { return mViewPager != null ? mViewPager : findViewById(R.id.apps_list_view); } diff --git a/src/com/android/launcher3/util/ScrollableLayoutManager.java b/src/com/android/launcher3/util/ScrollableLayoutManager.java index cb6ecaa664..29c277c5ff 100644 --- a/src/com/android/launcher3/util/ScrollableLayoutManager.java +++ b/src/com/android/launcher3/util/ScrollableLayoutManager.java @@ -33,7 +33,7 @@ import androidx.recyclerview.widget.RecyclerView.ViewHolder; public class ScrollableLayoutManager extends GridLayoutManager { public static final float PREDICTIVE_BACK_MIN_SCALE = 0.9f; - private static final float EXTRA_BOTTOM_SPACE_BY_HEIGHT_PERCENT = + public static final float EXTRA_BOTTOM_SPACE_BY_HEIGHT_PERCENT = (1 - PREDICTIVE_BACK_MIN_SCALE) / 2; // keyed on item type diff --git a/src/com/android/launcher3/views/AbstractSlideInView.java b/src/com/android/launcher3/views/AbstractSlideInView.java index cb6a46cb8b..8a9b179a1b 100644 --- a/src/com/android/launcher3/views/AbstractSlideInView.java +++ b/src/com/android/launcher3/views/AbstractSlideInView.java @@ -30,15 +30,18 @@ import android.animation.ObjectAnimator; import android.animation.PropertyValuesHolder; import android.content.Context; import android.graphics.Canvas; +import android.graphics.Outline; import android.graphics.drawable.Drawable; import android.util.AttributeSet; import android.util.Property; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; +import android.view.ViewOutlineProvider; import android.view.animation.Interpolator; import androidx.annotation.FloatRange; +import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.Px; @@ -96,8 +99,21 @@ public abstract class AbstractSlideInView private final AnimatedFloat mSlideInViewScale = new AnimatedFloat(this::onScaleProgressChanged, VIEW_NO_SCALE); - private boolean mIsBackProgressing; + protected boolean mIsBackProgressing; @Nullable private Drawable mContentBackground; + @Nullable private View mContentBackgroundParentView; + + protected final ViewOutlineProvider mViewOutlineProvider = new ViewOutlineProvider() { + @Override + public void getOutline(View view, Outline outline) { + outline.setRect( + 0, + 0, + view.getMeasuredWidth(), + view.getMeasuredHeight() + getBottomOffsetPx() + ); + } + }; public AbstractSlideInView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); @@ -119,10 +135,6 @@ public abstract class AbstractSlideInView mColorScrim = scrimColor != -1 ? createColorScrim(context, scrimColor) : null; } - protected void setContentBackground(Drawable drawable) { - mContentBackground = drawable; - } - protected void attachToContainer() { if (mColorScrim != null) { getPopupContainer().addView(mColorScrim); @@ -190,7 +202,7 @@ public abstract class AbstractSlideInView + (1 - PREDICTIVE_BACK_MIN_SCALE) * (1 - deceleratedProgress)); } - private void onScaleProgressChanged() { + protected void onScaleProgressChanged() { float scaleProgress = mSlideInViewScale.value; SCALE_PROPERTY.set(this, scaleProgress); setClipChildren(!mIsBackProgressing); @@ -222,16 +234,27 @@ public abstract class AbstractSlideInView super.dispatchDraw(canvas); } + /** + * Set slide in view's background {@link Drawable} which will be draw onto a parent view in + * {@link #dispatchDraw(Canvas)} + */ + protected void setContentBackgroundWithParent( + @NonNull Drawable drawable, @NonNull View parentView) { + mContentBackground = drawable; + mContentBackgroundParentView = parentView; + } + /** Draw scaled background during predictive back animation. */ - protected void drawScaledBackground(Canvas canvas) { - if (mContentBackground == null) { + private void drawScaledBackground(Canvas canvas) { + if (mContentBackground == null || mContentBackgroundParentView == null) { return; } mContentBackground.setBounds( - mContent.getLeft(), - mContent.getTop() + (int) mContent.getTranslationY(), - mContent.getRight(), - mContent.getBottom() + (mIsBackProgressing ? getBottomOffsetPx() : 0)); + mContentBackgroundParentView.getLeft(), + mContentBackgroundParentView.getTop() + (int) mContent.getTranslationY(), + mContentBackgroundParentView.getRight(), + mContentBackgroundParentView.getBottom() + + (mIsBackProgressing ? getBottomOffsetPx() : 0)); mContentBackground.draw(canvas); } diff --git a/src/com/android/launcher3/widget/WidgetsBottomSheet.java b/src/com/android/launcher3/widget/WidgetsBottomSheet.java index 06c622dd00..23cdae99d0 100644 --- a/src/com/android/launcher3/widget/WidgetsBottomSheet.java +++ b/src/com/android/launcher3/widget/WidgetsBottomSheet.java @@ -112,13 +112,14 @@ public class WidgetsBottomSheet extends BaseWidgetSheet { if (!hasSeenEducationTip()) { addOnLayoutChangeListener(mLayoutChangeListenerToShowTips); } - setContentBackground(getContext().getDrawable(R.drawable.bg_rounded_corner_bottom_sheet)); } @Override protected void onFinishInflate() { super.onFinishInflate(); mContent = findViewById(R.id.widgets_bottom_sheet); + setContentBackgroundWithParent( + getContext().getDrawable(R.drawable.bg_rounded_corner_bottom_sheet), mContent); } @Override diff --git a/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java b/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java index d5c43155af..0403249307 100644 --- a/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java +++ b/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java @@ -29,7 +29,6 @@ import android.content.Context; import android.content.pm.LauncherApps; import android.content.res.Configuration; import android.content.res.Resources; -import android.graphics.Outline; import android.graphics.Rect; import android.os.Process; import android.os.UserHandle; @@ -41,7 +40,6 @@ import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; -import android.view.ViewOutlineProvider; import android.view.WindowInsets; import android.view.animation.AnimationUtils; import android.view.animation.Interpolator; @@ -170,18 +168,6 @@ public class WidgetsFullSheet extends BaseWidgetSheet } }; - private final ViewOutlineProvider mViewOutlineProvider = new ViewOutlineProvider() { - @Override - public void getOutline(View view, Outline outline) { - outline.setRect( - 0, - 0, - view.getMeasuredWidth(), - view.getMeasuredHeight() + getBottomOffsetPx() - ); - } - }; - @Px private final int mTabsHeight; @Nullable private WidgetsRecyclerView mCurrentWidgetsRecyclerView; @@ -227,7 +213,6 @@ public class WidgetsFullSheet extends BaseWidgetSheet mUserManagerState.init(UserCache.INSTANCE.get(context), context.getSystemService(UserManager.class)); - setContentBackground(getContext().getDrawable(R.drawable.bg_widgets_full_sheet)); } public WidgetsFullSheet(Context context, AttributeSet attrs) { @@ -238,6 +223,8 @@ public class WidgetsFullSheet extends BaseWidgetSheet protected void onFinishInflate() { super.onFinishInflate(); mContent = findViewById(R.id.container); + setContentBackgroundWithParent(getContext().getDrawable(R.drawable.bg_widgets_full_sheet), + mContent); mContent.setOutlineProvider(mViewOutlineProvider); mContent.setClipToOutline(true);