Update PreviewLayoutRule API to prepare for new folder animation.
Also created a new FeatureFlag to start building behind. Bug: 35064148 Change-Id: I4a7d30bf1e1f49f1012eb963695d44d67096a5bc
This commit is contained in:
@@ -16,10 +16,12 @@
|
||||
|
||||
package com.android.launcher3.folder;
|
||||
|
||||
import android.graphics.Path;
|
||||
import android.view.View;
|
||||
|
||||
import com.android.launcher3.folder.FolderIcon.PreviewItemDrawingParams;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class StackFolderIconLayoutRule implements FolderIcon.PreviewLayoutRule {
|
||||
|
||||
static final int MAX_NUM_ITEMS_IN_PREVIEW = 3;
|
||||
@@ -54,10 +56,10 @@ public class StackFolderIconLayoutRule implements FolderIcon.PreviewLayoutRule {
|
||||
@Override
|
||||
public PreviewItemDrawingParams computePreviewItemDrawingParams(int index, int curNumItems,
|
||||
PreviewItemDrawingParams params) {
|
||||
float scale = scaleForItem(index, curNumItems);
|
||||
|
||||
index = MAX_NUM_ITEMS_IN_PREVIEW - index - 1;
|
||||
float r = (index * 1.0f) / (MAX_NUM_ITEMS_IN_PREVIEW - 1);
|
||||
float scale = (1 - PERSPECTIVE_SCALE_FACTOR * (1 - r));
|
||||
|
||||
float offset = (1 - r) * mMaxPerspectiveShift;
|
||||
float scaledSize = scale * mBaselineIconSize;
|
||||
@@ -80,12 +82,26 @@ public class StackFolderIconLayoutRule implements FolderIcon.PreviewLayoutRule {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int numItems() {
|
||||
public int maxNumItems() {
|
||||
return MAX_NUM_ITEMS_IN_PREVIEW;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float scaleForItem(int index, int numItems) {
|
||||
// Scale is determined by the position of the icon in the preview.
|
||||
index = MAX_NUM_ITEMS_IN_PREVIEW - index - 1;
|
||||
float r = (index * 1.0f) / (MAX_NUM_ITEMS_IN_PREVIEW - 1);
|
||||
return (1 - PERSPECTIVE_SCALE_FACTOR * (1 - r));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean clipToBackground() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<View> getItemsToDisplay(Folder folder) {
|
||||
List<View> items = folder.getItemsInReadingOrder();
|
||||
return items.subList(0, Math.min(items.size(), MAX_NUM_ITEMS_IN_PREVIEW));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user