mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-20 03:08:19 +00:00
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:
@@ -1,16 +1,17 @@
|
||||
package com.android.launcher3.folder;
|
||||
|
||||
import android.graphics.Path;
|
||||
import android.graphics.Point;
|
||||
import android.view.View;
|
||||
|
||||
import com.android.launcher3.DeviceProfile;
|
||||
import com.android.launcher3.LauncherAppState;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ClippedFolderIconLayoutRule implements FolderIcon.PreviewLayoutRule {
|
||||
|
||||
static final int MAX_NUM_ITEMS_IN_PREVIEW = 4;
|
||||
private static final int MIN_NUM_ITEMS_IN_PREVIEW = 2;
|
||||
private static final int MAX_NUM_ITEMS_PER_ROW = 2;
|
||||
|
||||
final float MIN_SCALE = 0.48f;
|
||||
final float MAX_SCALE = 0.58f;
|
||||
@@ -38,7 +39,7 @@ public class ClippedFolderIconLayoutRule implements FolderIcon.PreviewLayoutRule
|
||||
public FolderIcon.PreviewItemDrawingParams computePreviewItemDrawingParams(int index,
|
||||
int curNumItems, FolderIcon.PreviewItemDrawingParams params) {
|
||||
|
||||
float totalScale = scaleForNumItems(curNumItems);
|
||||
float totalScale = scaleForItem(index, curNumItems);
|
||||
float transX;
|
||||
float transY;
|
||||
float overlayAlpha = 0;
|
||||
@@ -94,7 +95,7 @@ public class ClippedFolderIconLayoutRule implements FolderIcon.PreviewLayoutRule
|
||||
MIN_NUM_ITEMS_IN_PREVIEW) / (MAX_NUM_ITEMS_IN_PREVIEW - MIN_NUM_ITEMS_IN_PREVIEW));
|
||||
double theta = theta0 + index * (2 * Math.PI / curNumItems) * direction;
|
||||
|
||||
float halfIconSize = (mIconSize * scaleForNumItems(curNumItems)) / 2;
|
||||
float halfIconSize = (mIconSize * scaleForItem(index, curNumItems)) / 2;
|
||||
|
||||
// Map the location along the circle, and offset the coordinates to represent the center
|
||||
// of the icon, and to be based from the top / left of the preview area. The y component
|
||||
@@ -104,7 +105,9 @@ public class ClippedFolderIconLayoutRule implements FolderIcon.PreviewLayoutRule
|
||||
|
||||
}
|
||||
|
||||
private float scaleForNumItems(int numItems) {
|
||||
@Override
|
||||
public float scaleForItem(int index, int numItems) {
|
||||
// Scale is determined by the number of items in the preview.
|
||||
float scale = 1f;
|
||||
if (numItems <= 2) {
|
||||
scale = MAX_SCALE;
|
||||
@@ -118,7 +121,7 @@ public class ClippedFolderIconLayoutRule implements FolderIcon.PreviewLayoutRule
|
||||
}
|
||||
|
||||
@Override
|
||||
public int numItems() {
|
||||
public int maxNumItems() {
|
||||
return MAX_NUM_ITEMS_IN_PREVIEW;
|
||||
}
|
||||
|
||||
@@ -127,4 +130,23 @@ public class ClippedFolderIconLayoutRule implements FolderIcon.PreviewLayoutRule
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<View> getItemsToDisplay(Folder folder) {
|
||||
List<View> items = new ArrayList<>(folder.getItemsInReadingOrder());
|
||||
int numItems = items.size();
|
||||
if (FeatureFlags.LAUNCHER3_NEW_FOLDER_ANIMATION && numItems > MAX_NUM_ITEMS_IN_PREVIEW) {
|
||||
// We match the icons in the preview with the layout of the opened folder (b/27944225),
|
||||
// but we still need to figure out how we want to handle updating the preview when the
|
||||
// upper left quadrant changes.
|
||||
int appsPerRow = folder.mContent.getPageAt(0).getCountX();
|
||||
int appsToDelete = appsPerRow - MAX_NUM_ITEMS_PER_ROW;
|
||||
|
||||
// We only display the upper left quadrant.
|
||||
while (appsToDelete > 0) {
|
||||
items.remove(MAX_NUM_ITEMS_PER_ROW);
|
||||
appsToDelete--;
|
||||
}
|
||||
}
|
||||
return items.subList(0, Math.min(numItems, MAX_NUM_ITEMS_IN_PREVIEW));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user