Loading src/com/android/launcher3/Launcher.java +8 −4 Original line number Diff line number Diff line Loading @@ -488,14 +488,18 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns, @Override public void invalidateParent(ItemInfo info) { FolderIconPreviewVerifier verifier = new FolderIconPreviewVerifier(getDeviceProfile().inv); if (verifier.isItemInPreview(info.rank) && (info.container >= 0)) { if (info.container >= 0) { View folderIcon = getWorkspace().getHomescreenIconByItemId(info.container); if (folderIcon != null) { if (folderIcon instanceof FolderIcon && folderIcon.getTag() instanceof FolderInfo) { FolderIconPreviewVerifier verifier = new FolderIconPreviewVerifier(getDeviceProfile().inv); verifier.setFolderInfo((FolderInfo) folderIcon.getTag()); if (verifier.isItemInPreview(info.rank)) { folderIcon.invalidate(); } } } } /** * Returns whether we should delay spring loaded mode -- for shortcuts and widgets that have Loading src/com/android/launcher3/folder/FolderIcon.java +1 −0 Original line number Diff line number Diff line Loading @@ -200,6 +200,7 @@ public class FolderIcon extends FrameLayout implements FolderListener { private void setFolder(Folder folder) { mFolder = folder; mPreviewVerifier = new FolderIconPreviewVerifier(mLauncher.getDeviceProfile().inv); mPreviewVerifier.setFolderInfo(mFolder.getInfo()); updatePreviewItems(false); } Loading src/com/android/launcher3/folder/FolderIconPreviewVerifier.java +20 −5 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.launcher3.folder; import android.util.Log; import com.android.launcher3.FolderInfo; import com.android.launcher3.InvariantDeviceProfile; Loading @@ -26,14 +28,20 @@ import static com.android.launcher3.folder.ClippedFolderIconLayoutRule.MAX_NUM_I */ public class FolderIconPreviewVerifier { private static final String TAG = "FolderPreviewVerifier"; private final int mMaxGridCountX; private final int mMaxGridCountY; private final int mMaxItemsPerPage; private final int[] mGridSize = new int[2]; private final int[] mGridSize = new int[] { 1, 1 }; private int mNumItemsInFolder; private int mGridCountX; private boolean mDisplayingUpperLeftQuadrant = false; /** * Note: must call {@link #setFolderInfo(FolderInfo)} manually for verifier to work. */ public FolderIconPreviewVerifier(InvariantDeviceProfile profile) { mMaxGridCountX = profile.numFolderColumns; mMaxGridCountY = profile.numFolderRows; Loading @@ -42,11 +50,14 @@ public class FolderIconPreviewVerifier { public void setFolderInfo(FolderInfo info) { int numItemsInFolder = info.contents.size(); if (numItemsInFolder != mNumItemsInFolder) { FolderPagedView.calculateGridSize(numItemsInFolder, 0, 0, mMaxGridCountX, mMaxGridCountY, mMaxItemsPerPage, mGridSize); mGridCountX = mGridSize[0]; mDisplayingUpperLeftQuadrant = numItemsInFolder > MAX_NUM_ITEMS_IN_PREVIEW; mNumItemsInFolder = numItemsInFolder; } } /** Loading @@ -62,6 +73,10 @@ public class FolderIconPreviewVerifier { * @return True iff the icon is in the 2x2 upper left quadrant of the Folder. */ public boolean isItemInPreview(int page, int rank) { if (mGridSize[0] == 1) { Log.w(TAG, "setFolderInfo not called before checking if item is in preview."); } // 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) { Loading src/com/android/launcher3/folder/FolderPagedView.java +1 −0 Original line number Diff line number Diff line Loading @@ -321,6 +321,7 @@ public class FolderPagedView extends PagedView<PageIndicatorDots> { FolderIconPreviewVerifier verifier = new FolderIconPreviewVerifier( Launcher.getLauncher(getContext()).getDeviceProfile().inv); verifier.setFolderInfo(mFolder.getInfo()); rank = 0; for (int i = 0; i < itemCount; i++) { View v = list.size() > i ? list.get(i) : null; Loading src/com/android/launcher3/model/LoaderTask.java +10 −12 Original line number Diff line number Diff line Loading @@ -340,8 +340,6 @@ public class LoaderTask implements Runnable { Intent intent; String targetPkg; FolderIconPreviewVerifier verifier = new FolderIconPreviewVerifier(mApp.getInvariantDeviceProfile()); while (!mStopped && c.moveToNext()) { try { if (c.user == null) { Loading Loading @@ -461,8 +459,7 @@ public class LoaderTask implements Runnable { c.markRestored(); } boolean useLowResIcon = !c.isOnWorkspaceOrHotseat() && !verifier.isItemInPreview(c.getInt(rankIndex)); boolean useLowResIcon = !c.isOnWorkspaceOrHotseat(); if (c.restoreFlag != 0) { // Already verified above that user is same as default user Loading Loading @@ -745,24 +742,25 @@ public class LoaderTask implements Runnable { } } // Sort the folder items, update ranks, and make sure all preview items are high res. FolderIconPreviewVerifier verifier = new FolderIconPreviewVerifier(mApp.getInvariantDeviceProfile()); // Sort the folder items and make sure all items in the preview are high resolution. for (FolderInfo folder : mBgDataModel.folders) { Collections.sort(folder.contents, Folder.ITEM_POS_COMPARATOR); verifier.setFolderInfo(folder); int size = folder.contents.size(); // Update ranks here to ensure there are no gaps caused by removed folder items. // Ranks are the source of truth for folder items, so cellX and cellY can be ignored // for now. Database will be updated once user manually modifies folder. for (int rank = 0; rank < size; ++rank) { ShortcutInfo info = folder.contents.get(rank); info.rank = rank; int numItemsInPreview = 0; for (ShortcutInfo info : folder.contents) { if (info.usingLowResIcon() && info.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION && verifier.isItemInPreview(info.rank)) { mIconCache.getTitleAndIcon(info, false); numItemsInPreview++; } if (numItemsInPreview >= MAX_NUM_ITEMS_IN_PREVIEW) { break; } } } Loading Loading
src/com/android/launcher3/Launcher.java +8 −4 Original line number Diff line number Diff line Loading @@ -488,14 +488,18 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns, @Override public void invalidateParent(ItemInfo info) { FolderIconPreviewVerifier verifier = new FolderIconPreviewVerifier(getDeviceProfile().inv); if (verifier.isItemInPreview(info.rank) && (info.container >= 0)) { if (info.container >= 0) { View folderIcon = getWorkspace().getHomescreenIconByItemId(info.container); if (folderIcon != null) { if (folderIcon instanceof FolderIcon && folderIcon.getTag() instanceof FolderInfo) { FolderIconPreviewVerifier verifier = new FolderIconPreviewVerifier(getDeviceProfile().inv); verifier.setFolderInfo((FolderInfo) folderIcon.getTag()); if (verifier.isItemInPreview(info.rank)) { folderIcon.invalidate(); } } } } /** * Returns whether we should delay spring loaded mode -- for shortcuts and widgets that have Loading
src/com/android/launcher3/folder/FolderIcon.java +1 −0 Original line number Diff line number Diff line Loading @@ -200,6 +200,7 @@ public class FolderIcon extends FrameLayout implements FolderListener { private void setFolder(Folder folder) { mFolder = folder; mPreviewVerifier = new FolderIconPreviewVerifier(mLauncher.getDeviceProfile().inv); mPreviewVerifier.setFolderInfo(mFolder.getInfo()); updatePreviewItems(false); } Loading
src/com/android/launcher3/folder/FolderIconPreviewVerifier.java +20 −5 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.launcher3.folder; import android.util.Log; import com.android.launcher3.FolderInfo; import com.android.launcher3.InvariantDeviceProfile; Loading @@ -26,14 +28,20 @@ import static com.android.launcher3.folder.ClippedFolderIconLayoutRule.MAX_NUM_I */ public class FolderIconPreviewVerifier { private static final String TAG = "FolderPreviewVerifier"; private final int mMaxGridCountX; private final int mMaxGridCountY; private final int mMaxItemsPerPage; private final int[] mGridSize = new int[2]; private final int[] mGridSize = new int[] { 1, 1 }; private int mNumItemsInFolder; private int mGridCountX; private boolean mDisplayingUpperLeftQuadrant = false; /** * Note: must call {@link #setFolderInfo(FolderInfo)} manually for verifier to work. */ public FolderIconPreviewVerifier(InvariantDeviceProfile profile) { mMaxGridCountX = profile.numFolderColumns; mMaxGridCountY = profile.numFolderRows; Loading @@ -42,11 +50,14 @@ public class FolderIconPreviewVerifier { public void setFolderInfo(FolderInfo info) { int numItemsInFolder = info.contents.size(); if (numItemsInFolder != mNumItemsInFolder) { FolderPagedView.calculateGridSize(numItemsInFolder, 0, 0, mMaxGridCountX, mMaxGridCountY, mMaxItemsPerPage, mGridSize); mGridCountX = mGridSize[0]; mDisplayingUpperLeftQuadrant = numItemsInFolder > MAX_NUM_ITEMS_IN_PREVIEW; mNumItemsInFolder = numItemsInFolder; } } /** Loading @@ -62,6 +73,10 @@ public class FolderIconPreviewVerifier { * @return True iff the icon is in the 2x2 upper left quadrant of the Folder. */ public boolean isItemInPreview(int page, int rank) { if (mGridSize[0] == 1) { Log.w(TAG, "setFolderInfo not called before checking if item is in preview."); } // 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) { Loading
src/com/android/launcher3/folder/FolderPagedView.java +1 −0 Original line number Diff line number Diff line Loading @@ -321,6 +321,7 @@ public class FolderPagedView extends PagedView<PageIndicatorDots> { FolderIconPreviewVerifier verifier = new FolderIconPreviewVerifier( Launcher.getLauncher(getContext()).getDeviceProfile().inv); verifier.setFolderInfo(mFolder.getInfo()); rank = 0; for (int i = 0; i < itemCount; i++) { View v = list.size() > i ? list.get(i) : null; Loading
src/com/android/launcher3/model/LoaderTask.java +10 −12 Original line number Diff line number Diff line Loading @@ -340,8 +340,6 @@ public class LoaderTask implements Runnable { Intent intent; String targetPkg; FolderIconPreviewVerifier verifier = new FolderIconPreviewVerifier(mApp.getInvariantDeviceProfile()); while (!mStopped && c.moveToNext()) { try { if (c.user == null) { Loading Loading @@ -461,8 +459,7 @@ public class LoaderTask implements Runnable { c.markRestored(); } boolean useLowResIcon = !c.isOnWorkspaceOrHotseat() && !verifier.isItemInPreview(c.getInt(rankIndex)); boolean useLowResIcon = !c.isOnWorkspaceOrHotseat(); if (c.restoreFlag != 0) { // Already verified above that user is same as default user Loading Loading @@ -745,24 +742,25 @@ public class LoaderTask implements Runnable { } } // Sort the folder items, update ranks, and make sure all preview items are high res. FolderIconPreviewVerifier verifier = new FolderIconPreviewVerifier(mApp.getInvariantDeviceProfile()); // Sort the folder items and make sure all items in the preview are high resolution. for (FolderInfo folder : mBgDataModel.folders) { Collections.sort(folder.contents, Folder.ITEM_POS_COMPARATOR); verifier.setFolderInfo(folder); int size = folder.contents.size(); // Update ranks here to ensure there are no gaps caused by removed folder items. // Ranks are the source of truth for folder items, so cellX and cellY can be ignored // for now. Database will be updated once user manually modifies folder. for (int rank = 0; rank < size; ++rank) { ShortcutInfo info = folder.contents.get(rank); info.rank = rank; int numItemsInPreview = 0; for (ShortcutInfo info : folder.contents) { if (info.usingLowResIcon() && info.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION && verifier.isItemInPreview(info.rank)) { mIconCache.getTitleAndIcon(info, false); numItemsInPreview++; } if (numItemsInPreview >= MAX_NUM_ITEMS_IN_PREVIEW) { break; } } } Loading