[Predictive Back] Widget to home polish: show extra rows at bottom during animation

1. setClipChildren(false) for WidgetFullSheet and content view during animation
2. setClipToOutline(true) for WidgetsRecyclerView and provide ViewOutlineProvider to expand bottom by 5% of height
3. Override calculateExtraLayoutSpace() for ScrollableLayoutManager
4. Manually modify AbstractSlideInView#mContent's background drawable during scale animation

bug: b/260956481
Test: manual

Change-Id: Ic391639de887cf4a70bc4965dc0b1fd9bc12dd2c
This commit is contained in:
Fengjiang Li
2023-02-11 11:01:58 -08:00
parent 740541e0a0
commit cb640da2bb
14 changed files with 134 additions and 33 deletions

View File

@@ -20,6 +20,7 @@ import android.util.SparseIntArray;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.annotation.Px;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.RecyclerView.Adapter;
@@ -31,6 +32,10 @@ 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 =
(1 - PREDICTIVE_BACK_MIN_SCALE) / 2;
// keyed on item type
protected final SparseIntArray mCachedSizes = new SparseIntArray();
@@ -111,6 +116,13 @@ public class ScrollableLayoutManager extends GridLayoutManager {
return adapter == null ? 0 : getItemsHeight(adapter, adapter.getItemCount());
}
@Override
protected void calculateExtraLayoutSpace(RecyclerView.State state, int[] extraLayoutSpace) {
super.calculateExtraLayoutSpace(state, extraLayoutSpace);
@Px int extraSpacePx = (int) (getHeight() * EXTRA_BOTTOM_SPACE_BY_HEIGHT_PERCENT);
extraLayoutSpace[1] = Math.max(extraLayoutSpace[1], extraSpacePx);
}
/**
* Returns the sum of the height, in pixels, of this list adapter's items from index
* 0 (inclusive) until {@code untilIndex} (exclusive). If untilIndex is same as the itemCount,