[Predictive Back] Add extra bottom space in taskbar all apps to home

Bug: 272797556
Test: manual
Change-Id: Ie84117d4211c382544c9ed8e1226bf70b2bd382d
This commit is contained in:
Fengjiang Li
2023-03-13 15:33:00 -07:00
parent 7f4d53b074
commit 11f873da0b
7 changed files with 58 additions and 38 deletions

View File

@@ -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<T extends Context & ActivityContext>
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<T extends Context & ActivityContext>
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<T extends Context & ActivityContext>
+ (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<T extends Context & ActivityContext>
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);
}