diff options
Diffstat (limited to 'src/com/android/launcher3/folder/FolderIconPreviewVerifier.java')
-rw-r--r-- | src/com/android/launcher3/folder/FolderIconPreviewVerifier.java | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/src/com/android/launcher3/folder/FolderIconPreviewVerifier.java b/src/com/android/launcher3/folder/FolderIconPreviewVerifier.java index d0d8e79d5..d054a5d42 100644 --- a/src/com/android/launcher3/folder/FolderIconPreviewVerifier.java +++ b/src/com/android/launcher3/folder/FolderIconPreviewVerifier.java @@ -25,15 +25,51 @@ import com.android.launcher3.config.FeatureFlags; */ public class FolderIconPreviewVerifier { + private final int mMaxGridCountX; + private final int mMaxGridCountY; + private final int mMaxItemsPerPage; + private final int[] mGridSize = new int[2]; + + private int mGridCountX; + private boolean mDisplayingUpperLeftQuadrant = false; + public FolderIconPreviewVerifier(InvariantDeviceProfile profile) { - // b/37570804 + mMaxGridCountX = profile.numFolderColumns; + mMaxGridCountY = profile.numFolderRows; + mMaxItemsPerPage = mMaxGridCountX * mMaxGridCountY; } public void setFolderInfo(FolderInfo info) { - // b/37570804 + int numItemsInFolder = info.contents.size(); + FolderPagedView.calculateGridSize(numItemsInFolder, 0, 0, mMaxGridCountX, + mMaxGridCountY, mMaxItemsPerPage, mGridSize); + mGridCountX = mGridSize[0]; + + mDisplayingUpperLeftQuadrant = FeatureFlags.LAUNCHER3_NEW_FOLDER_ANIMATION + && !FeatureFlags.LAUNCHER3_LEGACY_FOLDER_ICON + && numItemsInFolder > FolderIcon.NUM_ITEMS_IN_PREVIEW; } + /** + * Returns whether the item with {@param rank} is in the default Folder icon preview. + */ public boolean isItemInPreview(int rank) { + return isItemInPreview(0, rank); + } + + /** + * @param page The page the item is on. + * @param rank The rank of the item. + * @return True iff the icon is in the 2x2 upper left quadrant of the Folder. + */ + public boolean isItemInPreview(int page, int rank) { + // First page items are laid out such that the first 4 items are always in the upper + // left quadrant. For all other pages, we need to check the row and col. + if (page > 0 || mDisplayingUpperLeftQuadrant) { + int col = rank % mGridCountX; + int row = rank / mGridCountX; + return col < 2 && row < 2; + } return rank < FolderIcon.NUM_ITEMS_IN_PREVIEW; } } |