[Predictive Back] Add extra bottom space in taskbar all apps to home
Bug: 272797556
Test: manual
Change-Id: Ie84117d4211c382544c9ed8e1226bf70b2bd382d
diff --git a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsContainerView.java b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsContainerView.java
index eeca329..7f6d78a 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.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;
@@ -62,13 +61,6 @@
}
@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
return true;
diff --git a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsSlideInView.java b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsSlideInView.java
index fbc7be0..c6f7561 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 @@
}
if (FeatureFlags.ENABLE_BACK_SWIPE_LAUNCHER_ANIMATION.get()) {
+ mAppsView.getAppsRecyclerViewContainer().setOutlineProvider(mViewOutlineProvider);
+ mAppsView.getAppsRecyclerViewContainer().setClipToOutline(true);
findOnBackInvokedDispatcher().registerOnBackInvokedCallback(
OnBackInvokedDispatcher.PRIORITY_DEFAULT, mOnBackAnimationCallback);
}
@@ -135,6 +137,16 @@
setShiftRange(dp.allAppsShiftRange);
mActivityContext.addOnDeviceProfileChangeListener(this);
+ setContentBackgroundWithParent(
+ getContext().getDrawable(R.drawable.bg_rounded_corner_bottom_sheet),
+ mAppsView.getBottomSheetBackground());
+ }
+
+ @Override
+ protected void onScaleProgressChanged() {
+ super.onScaleProgressChanged();
+ mAppsView.setClipChildren(!mIsBackProgressing);
+ mAppsView.getAppsRecyclerViewContainer().setClipChildren(!mIsBackProgressing);
}
@Override
diff --git a/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java b/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java
index 8fbe997..a2e2b26 100644
--- a/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java
@@ -46,6 +46,7 @@
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.widget.Button;
@@ -259,6 +260,10 @@
return mSearchUiManager;
}
+ public View getBottomSheetBackground() {
+ return mBottomSheetBackground;
+ }
+
public View getSearchView() {
return mSearchContainer;
}
@@ -894,7 +899,7 @@
* 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 cb6ecaa..29c277c 100644
--- a/src/com/android/launcher3/util/ScrollableLayoutManager.java
+++ b/src/com/android/launcher3/util/ScrollableLayoutManager.java
@@ -33,7 +33,7 @@
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 cb6a46c..8a9b179 100644
--- a/src/com/android/launcher3/views/AbstractSlideInView.java
+++ b/src/com/android/launcher3/views/AbstractSlideInView.java
@@ -30,15 +30,18 @@
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 @@
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 @@
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 @@
+ (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 @@
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 06c622d..23cdae9 100644
--- a/src/com/android/launcher3/widget/WidgetsBottomSheet.java
+++ b/src/com/android/launcher3/widget/WidgetsBottomSheet.java
@@ -112,13 +112,14 @@
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 d5c4315..0403249 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.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.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 @@
}
};
- 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 @@
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 @@
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);