summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/folder/FolderPagedView.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/launcher3/folder/FolderPagedView.java')
-rw-r--r--src/com/android/launcher3/folder/FolderPagedView.java72
1 files changed, 44 insertions, 28 deletions
diff --git a/src/com/android/launcher3/folder/FolderPagedView.java b/src/com/android/launcher3/folder/FolderPagedView.java
index eecce183a..2a6007a4e 100644
--- a/src/com/android/launcher3/folder/FolderPagedView.java
+++ b/src/com/android/launcher3/folder/FolderPagedView.java
@@ -35,17 +35,14 @@ import com.android.launcher3.InvariantDeviceProfile;
import com.android.launcher3.ItemInfo;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherAppState;
-import com.android.launcher3.LauncherModel;
import com.android.launcher3.PagedView;
import com.android.launcher3.R;
import com.android.launcher3.ShortcutAndWidgetContainer;
import com.android.launcher3.ShortcutInfo;
import com.android.launcher3.Utilities;
import com.android.launcher3.Workspace.ItemOperator;
-import com.android.launcher3.dragndrop.DragController;
import com.android.launcher3.keyboard.ViewGroupFocusHelper;
import com.android.launcher3.pageindicators.PageIndicator;
-import com.android.launcher3.util.Themes;
import com.android.launcher3.util.Thunk;
import java.util.ArrayList;
@@ -68,7 +65,7 @@ public class FolderPagedView extends PagedView {
*/
private static final float SCROLL_HINT_FRACTION = 0.07f;
- private static final int[] sTempPosArray = new int[2];
+ private static final int[] sTmpArray = new int[2];
public final boolean mIsRtl;
@@ -108,7 +105,6 @@ public class FolderPagedView extends PagedView {
mIsRtl = Utilities.isRtl(getResources());
setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_YES);
- setEdgeGlowColor(Themes.getAttrColor(context, android.R.attr.colorEdgeEffect));
mFocusIndicatorHelper = new ViewGroupFocusHelper(this);
}
@@ -120,40 +116,58 @@ public class FolderPagedView extends PagedView {
}
/**
- * Sets up the grid size such that {@param count} items can fit in the grid.
+ * Calculates the grid size such that {@param count} items can fit in the grid.
* The grid size is calculated such that countY <= countX and countX = ceil(sqrt(count)) while
* maintaining the restrictions of {@link #mMaxCountX} &amp; {@link #mMaxCountY}.
*/
- private void setupContentDimensions(int count) {
- mAllocatedContentSize = count;
+ public static void calculateGridSize(int count, int countX, int countY, int maxCountX,
+ int maxCountY, int maxItemsPerPage, int[] out) {
boolean done;
- if (count >= mMaxItemsPerPage) {
- mGridCountX = mMaxCountX;
- mGridCountY = mMaxCountY;
+ int gridCountX = countX;
+ int gridCountY = countY;
+
+ if (count >= maxItemsPerPage) {
+ gridCountX = maxCountX;
+ gridCountY = maxCountY;
done = true;
} else {
done = false;
}
while (!done) {
- int oldCountX = mGridCountX;
- int oldCountY = mGridCountY;
- if (mGridCountX * mGridCountY < count) {
+ int oldCountX = gridCountX;
+ int oldCountY = gridCountY;
+ if (gridCountX * gridCountY < count) {
// Current grid is too small, expand it
- if ((mGridCountX <= mGridCountY || mGridCountY == mMaxCountY) && mGridCountX < mMaxCountX) {
- mGridCountX++;
- } else if (mGridCountY < mMaxCountY) {
- mGridCountY++;
+ if ((gridCountX <= gridCountY || gridCountY == maxCountY)
+ && gridCountX < maxCountX) {
+ gridCountX++;
+ } else if (gridCountY < maxCountY) {
+ gridCountY++;
}
- if (mGridCountY == 0) mGridCountY++;
- } else if ((mGridCountY - 1) * mGridCountX >= count && mGridCountY >= mGridCountX) {
- mGridCountY = Math.max(0, mGridCountY - 1);
- } else if ((mGridCountX - 1) * mGridCountY >= count) {
- mGridCountX = Math.max(0, mGridCountX - 1);
+ if (gridCountY == 0) gridCountY++;
+ } else if ((gridCountY - 1) * gridCountX >= count && gridCountY >= gridCountX) {
+ gridCountY = Math.max(0, gridCountY - 1);
+ } else if ((gridCountX - 1) * gridCountY >= count) {
+ gridCountX = Math.max(0, gridCountX - 1);
}
- done = mGridCountX == oldCountX && mGridCountY == oldCountY;
+ done = gridCountX == oldCountX && gridCountY == oldCountY;
}
+ out[0] = gridCountX;
+ out[1] = gridCountY;
+ }
+
+ /**
+ * Sets up the grid size such that {@param count} items can fit in the grid.
+ */
+ public void setupContentDimensions(int count) {
+ mAllocatedContentSize = count;
+ calculateGridSize(count, mGridCountX, mGridCountY, mMaxCountX, mMaxCountY, mMaxItemsPerPage,
+ sTmpArray);
+ mGridCountX = sTmpArray[0];
+ mGridCountY = sTmpArray[1];
+
// Update grid size
for (int i = getPageCount() - 1; i >= 0; i--) {
getPageAt(i).setGridSize(mGridCountX, mGridCountY);
@@ -314,6 +328,8 @@ public class FolderPagedView extends PagedView {
int position = 0;
int newX, newY, rank;
+ FolderIconPreviewVerifier verifier = new FolderIconPreviewVerifier(
+ Launcher.getLauncher(getContext()).getDeviceProfile().inv);
rank = 0;
for (int i = 0; i < itemCount; i++) {
View v = list.size() > i ? list.get(i) : null;
@@ -346,7 +362,7 @@ public class FolderPagedView extends PagedView {
currentPage.addViewToCellLayout(
v, -1, mFolder.mLauncher.getViewIdForItem(info), lp, true);
- if (rank < FolderIcon.NUM_ITEMS_IN_PREVIEW && v instanceof BubbleTextView) {
+ if (verifier.isItemInPreview(rank) && v instanceof BubbleTextView) {
((BubbleTextView) v).verifyHighRes();
}
}
@@ -400,12 +416,12 @@ public class FolderPagedView extends PagedView {
public int findNearestArea(int pixelX, int pixelY) {
int pageIndex = getNextPage();
CellLayout page = getPageAt(pageIndex);
- page.findNearestArea(pixelX, pixelY, 1, 1, sTempPosArray);
+ page.findNearestArea(pixelX, pixelY, 1, 1, sTmpArray);
if (mFolder.isLayoutRtl()) {
- sTempPosArray[0] = page.getCountX() - sTempPosArray[0] - 1;
+ sTmpArray[0] = page.getCountX() - sTmpArray[0] - 1;
}
return Math.min(mAllocatedContentSize - 1,
- pageIndex * mMaxItemsPerPage + sTempPosArray[1] * mGridCountX + sTempPosArray[0]);
+ pageIndex * mMaxItemsPerPage + sTmpArray[1] * mGridCountX + sTmpArray[0]);
}
public boolean isFull() {