Loading src/com/android/launcher3/DeviceProfile.java +12 −8 Original line number Diff line number Diff line Loading @@ -176,6 +176,8 @@ public class DeviceProfile { public int cellYPaddingPx = -1; // Folder public final int numFolderRows; public final int numFolderColumns; public float folderLabelTextScale; public int folderLabelTextSizePx; public int folderFooterHeightPx; Loading Loading @@ -431,6 +433,8 @@ public class DeviceProfile { } folderLabelTextScale = res.getFloat(R.dimen.folder_label_text_scale); numFolderRows = inv.numFolderRows; numFolderColumns = inv.numFolderColumns; if (mIsScalableGrid && inv.folderStyle != INVALID_RESOURCE_HANDLE) { TypedArray folderStyle = context.obtainStyledAttributes(inv.folderStyle, Loading Loading @@ -622,11 +626,11 @@ public class DeviceProfile { isTwoPanels ? inv.folderSpecsTwoPanelId : inv.folderSpecsId), ResponsiveSpecType.Folder); mResponsiveFolderWidthSpec = folderSpecs.getCalculatedSpec(responsiveAspectRatio, DimensionType.WIDTH, inv.numFolderColumns, DimensionType.WIDTH, numFolderColumns, mResponsiveWorkspaceWidthSpec.getAvailableSpace(), mResponsiveWorkspaceWidthSpec); mResponsiveFolderHeightSpec = folderSpecs.getCalculatedSpec(responsiveAspectRatio, DimensionType.HEIGHT, inv.numFolderRows, DimensionType.HEIGHT, numFolderRows, mResponsiveWorkspaceHeightSpec.getAvailableSpace(), mResponsiveWorkspaceHeightSpec); } Loading Loading @@ -1365,16 +1369,16 @@ public class DeviceProfile { Point totalWorkspacePadding = getTotalWorkspacePadding(); // Check if the folder fit within the available height. float contentUsedHeight = folderCellHeightPx * inv.numFolderRows + ((inv.numFolderRows - 1) * folderCellLayoutBorderSpacePx.y) float contentUsedHeight = folderCellHeightPx * numFolderRows + ((numFolderRows - 1) * folderCellLayoutBorderSpacePx.y) + folderFooterHeightPx + folderContentPaddingTop; int contentMaxHeight = availableHeightPx - totalWorkspacePadding.y; float scaleY = contentMaxHeight / contentUsedHeight; // Check if the folder fit within the available width. float contentUsedWidth = folderCellWidthPx * inv.numFolderColumns + ((inv.numFolderColumns - 1) * folderCellLayoutBorderSpacePx.x) float contentUsedWidth = folderCellWidthPx * numFolderColumns + ((numFolderColumns - 1) * folderCellLayoutBorderSpacePx.x) + folderContentPaddingLeftRight * 2; int contentMaxWidth = availableWidthPx - totalWorkspacePadding.x; float scaleX = contentMaxWidth / contentUsedWidth; Loading Loading @@ -1993,8 +1997,8 @@ public class DeviceProfile { writer.println(prefix + pxToDpStr("iconTextSizePx", iconTextSizePx)); writer.println(prefix + pxToDpStr("iconDrawablePaddingPx", iconDrawablePaddingPx)); writer.println(prefix + "\tinv.numFolderRows: " + inv.numFolderRows); writer.println(prefix + "\tinv.numFolderColumns: " + inv.numFolderColumns); writer.println(prefix + "\tnumFolderRows: " + numFolderRows); writer.println(prefix + "\tnumFolderColumns: " + numFolderColumns); writer.println(prefix + pxToDpStr("folderCellWidthPx", folderCellWidthPx)); writer.println(prefix + pxToDpStr("folderCellHeightPx", folderCellHeightPx)); writer.println(prefix + pxToDpStr("folderChildIconSizePx", folderChildIconSizePx)); Loading src/com/android/launcher3/Launcher.java +2 −2 Original line number Diff line number Diff line Loading @@ -802,7 +802,7 @@ public class Launcher extends StatefulActivity<LauncherState> if (info.container >= 0) { View folderIcon = getWorkspace().getHomescreenIconByItemId(info.container); if (folderIcon instanceof FolderIcon && folderIcon.getTag() instanceof FolderInfo) { if (new FolderGridOrganizer(getDeviceProfile().inv) if (new FolderGridOrganizer(getDeviceProfile()) .setFolderInfo((FolderInfo) folderIcon.getTag()) .isItemInPreview(info.rank)) { folderIcon.invalidate(); Loading Loading @@ -2657,7 +2657,7 @@ public class Launcher extends StatefulActivity<LauncherState> // Cache one page worth of icons getViewCache().setCacheSize(R.layout.folder_application, mDeviceProfile.inv.numFolderColumns * mDeviceProfile.inv.numFolderRows); mDeviceProfile.numFolderColumns * mDeviceProfile.numFolderRows); getViewCache().setCacheSize(R.layout.folder_page, 2); TraceHelper.INSTANCE.endSection(); Loading src/com/android/launcher3/folder/Folder.java +2 −2 Original line number Diff line number Diff line Loading @@ -1082,7 +1082,7 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo private void updateItemLocationsInDatabaseBatch(boolean isBind) { FolderGridOrganizer verifier = new FolderGridOrganizer( mActivityContext.getDeviceProfile().inv).setFolderInfo(mInfo); mActivityContext.getDeviceProfile()).setFolderInfo(mInfo); ArrayList<ItemInfo> items = new ArrayList<>(); int total = mInfo.contents.size(); Loading Loading @@ -1381,7 +1381,7 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo @Override public void onAdd(WorkspaceItemInfo item, int rank) { FolderGridOrganizer verifier = new FolderGridOrganizer( mActivityContext.getDeviceProfile().inv).setFolderInfo(mInfo); mActivityContext.getDeviceProfile()).setFolderInfo(mInfo); verifier.updateRankAndPos(item, rank); mLauncherDelegate.getModelWriter().addOrMoveItemInDatabase(item, mInfo.id, 0, item.cellX, item.cellY); Loading src/com/android/launcher3/folder/FolderAnimationManager.java +1 −1 Original line number Diff line number Diff line Loading @@ -96,7 +96,7 @@ public class FolderAnimationManager { mContext = folder.getContext(); mDeviceProfile = folder.mActivityContext.getDeviceProfile(); mPreviewVerifier = new FolderGridOrganizer(mDeviceProfile.inv); mPreviewVerifier = new FolderGridOrganizer(mDeviceProfile); mIsOpening = isOpening; Loading src/com/android/launcher3/folder/FolderGridOrganizer.java +21 −3 Original line number Diff line number Diff line Loading @@ -20,7 +20,7 @@ import static com.android.launcher3.folder.ClippedFolderIconLayoutRule.MAX_NUM_I import android.graphics.Point; import com.android.launcher3.InvariantDeviceProfile; import com.android.launcher3.DeviceProfile; import com.android.launcher3.model.data.FolderInfo; import com.android.launcher3.model.data.ItemInfo; Loading @@ -41,16 +41,33 @@ public class FolderGridOrganizer { private int mCountX; private int mCountY; private boolean mDisplayingUpperLeftQuadrant = false; private static final int PREVIEW_MAX_ROWS = 2; private static final int PREVIEW_MAX_COLUMNS = 2; /** * Note: must call {@link #setFolderInfo(FolderInfo)} manually for verifier to work. */ public FolderGridOrganizer(InvariantDeviceProfile profile) { public FolderGridOrganizer(DeviceProfile profile) { mMaxCountX = profile.numFolderColumns; mMaxCountY = profile.numFolderRows; mMaxItemsPerPage = mMaxCountX * mMaxCountY; } private FolderGridOrganizer(int maxCountX, int maxCountY) { mMaxCountX = maxCountX; mMaxCountY = maxCountY; mMaxItemsPerPage = mMaxCountX * mMaxCountY; } /** * Returns a FolderGridOrganizer that should only be used to verify if the folder icon is * showing in the preview. Max number of rows is {@link #PREVIEW_MAX_ROWS} and columns is * {@link #PREVIEW_MAX_COLUMNS}. */ public static FolderGridOrganizer getPreviewIconVerifier() { return new FolderGridOrganizer(PREVIEW_MAX_ROWS, PREVIEW_MAX_COLUMNS); } /** * Updates the organizer with the provided folder info */ Loading Loading @@ -127,6 +144,7 @@ public class FolderGridOrganizer { /** * Updates the item's cellX, cellY and rank corresponding to the provided rank. * * @return true if there was any change */ public boolean updateRankAndPos(ItemInfo item, int rank) { Loading Loading @@ -189,7 +207,7 @@ public class FolderGridOrganizer { if (page > 0 || mDisplayingUpperLeftQuadrant) { int col = rank % mCountX; int row = rank / mCountX; return col < 2 && row < 2; return col < PREVIEW_MAX_COLUMNS && row < PREVIEW_MAX_ROWS; } return rank < MAX_NUM_ITEMS_IN_PREVIEW; } Loading Loading
src/com/android/launcher3/DeviceProfile.java +12 −8 Original line number Diff line number Diff line Loading @@ -176,6 +176,8 @@ public class DeviceProfile { public int cellYPaddingPx = -1; // Folder public final int numFolderRows; public final int numFolderColumns; public float folderLabelTextScale; public int folderLabelTextSizePx; public int folderFooterHeightPx; Loading Loading @@ -431,6 +433,8 @@ public class DeviceProfile { } folderLabelTextScale = res.getFloat(R.dimen.folder_label_text_scale); numFolderRows = inv.numFolderRows; numFolderColumns = inv.numFolderColumns; if (mIsScalableGrid && inv.folderStyle != INVALID_RESOURCE_HANDLE) { TypedArray folderStyle = context.obtainStyledAttributes(inv.folderStyle, Loading Loading @@ -622,11 +626,11 @@ public class DeviceProfile { isTwoPanels ? inv.folderSpecsTwoPanelId : inv.folderSpecsId), ResponsiveSpecType.Folder); mResponsiveFolderWidthSpec = folderSpecs.getCalculatedSpec(responsiveAspectRatio, DimensionType.WIDTH, inv.numFolderColumns, DimensionType.WIDTH, numFolderColumns, mResponsiveWorkspaceWidthSpec.getAvailableSpace(), mResponsiveWorkspaceWidthSpec); mResponsiveFolderHeightSpec = folderSpecs.getCalculatedSpec(responsiveAspectRatio, DimensionType.HEIGHT, inv.numFolderRows, DimensionType.HEIGHT, numFolderRows, mResponsiveWorkspaceHeightSpec.getAvailableSpace(), mResponsiveWorkspaceHeightSpec); } Loading Loading @@ -1365,16 +1369,16 @@ public class DeviceProfile { Point totalWorkspacePadding = getTotalWorkspacePadding(); // Check if the folder fit within the available height. float contentUsedHeight = folderCellHeightPx * inv.numFolderRows + ((inv.numFolderRows - 1) * folderCellLayoutBorderSpacePx.y) float contentUsedHeight = folderCellHeightPx * numFolderRows + ((numFolderRows - 1) * folderCellLayoutBorderSpacePx.y) + folderFooterHeightPx + folderContentPaddingTop; int contentMaxHeight = availableHeightPx - totalWorkspacePadding.y; float scaleY = contentMaxHeight / contentUsedHeight; // Check if the folder fit within the available width. float contentUsedWidth = folderCellWidthPx * inv.numFolderColumns + ((inv.numFolderColumns - 1) * folderCellLayoutBorderSpacePx.x) float contentUsedWidth = folderCellWidthPx * numFolderColumns + ((numFolderColumns - 1) * folderCellLayoutBorderSpacePx.x) + folderContentPaddingLeftRight * 2; int contentMaxWidth = availableWidthPx - totalWorkspacePadding.x; float scaleX = contentMaxWidth / contentUsedWidth; Loading Loading @@ -1993,8 +1997,8 @@ public class DeviceProfile { writer.println(prefix + pxToDpStr("iconTextSizePx", iconTextSizePx)); writer.println(prefix + pxToDpStr("iconDrawablePaddingPx", iconDrawablePaddingPx)); writer.println(prefix + "\tinv.numFolderRows: " + inv.numFolderRows); writer.println(prefix + "\tinv.numFolderColumns: " + inv.numFolderColumns); writer.println(prefix + "\tnumFolderRows: " + numFolderRows); writer.println(prefix + "\tnumFolderColumns: " + numFolderColumns); writer.println(prefix + pxToDpStr("folderCellWidthPx", folderCellWidthPx)); writer.println(prefix + pxToDpStr("folderCellHeightPx", folderCellHeightPx)); writer.println(prefix + pxToDpStr("folderChildIconSizePx", folderChildIconSizePx)); Loading
src/com/android/launcher3/Launcher.java +2 −2 Original line number Diff line number Diff line Loading @@ -802,7 +802,7 @@ public class Launcher extends StatefulActivity<LauncherState> if (info.container >= 0) { View folderIcon = getWorkspace().getHomescreenIconByItemId(info.container); if (folderIcon instanceof FolderIcon && folderIcon.getTag() instanceof FolderInfo) { if (new FolderGridOrganizer(getDeviceProfile().inv) if (new FolderGridOrganizer(getDeviceProfile()) .setFolderInfo((FolderInfo) folderIcon.getTag()) .isItemInPreview(info.rank)) { folderIcon.invalidate(); Loading Loading @@ -2657,7 +2657,7 @@ public class Launcher extends StatefulActivity<LauncherState> // Cache one page worth of icons getViewCache().setCacheSize(R.layout.folder_application, mDeviceProfile.inv.numFolderColumns * mDeviceProfile.inv.numFolderRows); mDeviceProfile.numFolderColumns * mDeviceProfile.numFolderRows); getViewCache().setCacheSize(R.layout.folder_page, 2); TraceHelper.INSTANCE.endSection(); Loading
src/com/android/launcher3/folder/Folder.java +2 −2 Original line number Diff line number Diff line Loading @@ -1082,7 +1082,7 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo private void updateItemLocationsInDatabaseBatch(boolean isBind) { FolderGridOrganizer verifier = new FolderGridOrganizer( mActivityContext.getDeviceProfile().inv).setFolderInfo(mInfo); mActivityContext.getDeviceProfile()).setFolderInfo(mInfo); ArrayList<ItemInfo> items = new ArrayList<>(); int total = mInfo.contents.size(); Loading Loading @@ -1381,7 +1381,7 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo @Override public void onAdd(WorkspaceItemInfo item, int rank) { FolderGridOrganizer verifier = new FolderGridOrganizer( mActivityContext.getDeviceProfile().inv).setFolderInfo(mInfo); mActivityContext.getDeviceProfile()).setFolderInfo(mInfo); verifier.updateRankAndPos(item, rank); mLauncherDelegate.getModelWriter().addOrMoveItemInDatabase(item, mInfo.id, 0, item.cellX, item.cellY); Loading
src/com/android/launcher3/folder/FolderAnimationManager.java +1 −1 Original line number Diff line number Diff line Loading @@ -96,7 +96,7 @@ public class FolderAnimationManager { mContext = folder.getContext(); mDeviceProfile = folder.mActivityContext.getDeviceProfile(); mPreviewVerifier = new FolderGridOrganizer(mDeviceProfile.inv); mPreviewVerifier = new FolderGridOrganizer(mDeviceProfile); mIsOpening = isOpening; Loading
src/com/android/launcher3/folder/FolderGridOrganizer.java +21 −3 Original line number Diff line number Diff line Loading @@ -20,7 +20,7 @@ import static com.android.launcher3.folder.ClippedFolderIconLayoutRule.MAX_NUM_I import android.graphics.Point; import com.android.launcher3.InvariantDeviceProfile; import com.android.launcher3.DeviceProfile; import com.android.launcher3.model.data.FolderInfo; import com.android.launcher3.model.data.ItemInfo; Loading @@ -41,16 +41,33 @@ public class FolderGridOrganizer { private int mCountX; private int mCountY; private boolean mDisplayingUpperLeftQuadrant = false; private static final int PREVIEW_MAX_ROWS = 2; private static final int PREVIEW_MAX_COLUMNS = 2; /** * Note: must call {@link #setFolderInfo(FolderInfo)} manually for verifier to work. */ public FolderGridOrganizer(InvariantDeviceProfile profile) { public FolderGridOrganizer(DeviceProfile profile) { mMaxCountX = profile.numFolderColumns; mMaxCountY = profile.numFolderRows; mMaxItemsPerPage = mMaxCountX * mMaxCountY; } private FolderGridOrganizer(int maxCountX, int maxCountY) { mMaxCountX = maxCountX; mMaxCountY = maxCountY; mMaxItemsPerPage = mMaxCountX * mMaxCountY; } /** * Returns a FolderGridOrganizer that should only be used to verify if the folder icon is * showing in the preview. Max number of rows is {@link #PREVIEW_MAX_ROWS} and columns is * {@link #PREVIEW_MAX_COLUMNS}. */ public static FolderGridOrganizer getPreviewIconVerifier() { return new FolderGridOrganizer(PREVIEW_MAX_ROWS, PREVIEW_MAX_COLUMNS); } /** * Updates the organizer with the provided folder info */ Loading Loading @@ -127,6 +144,7 @@ public class FolderGridOrganizer { /** * Updates the item's cellX, cellY and rank corresponding to the provided rank. * * @return true if there was any change */ public boolean updateRankAndPos(ItemInfo item, int rank) { Loading Loading @@ -189,7 +207,7 @@ public class FolderGridOrganizer { if (page > 0 || mDisplayingUpperLeftQuadrant) { int col = rank % mCountX; int row = rank / mCountX; return col < 2 && row < 2; return col < PREVIEW_MAX_COLUMNS && row < PREVIEW_MAX_ROWS; } return rank < MAX_NUM_ITEMS_IN_PREVIEW; } Loading