Merge "Eliminate custom alpha handling in CellLayout"

This commit is contained in:
Michael Jurka
2012-03-21 05:14:55 -07:00
committed by Android (Google) Code Review
7 changed files with 108 additions and 118 deletions
@@ -247,8 +247,8 @@ public class BubbleTextView extends TextView {
}
void setCellLayoutPressedOrFocusedIcon() {
if (getParent() instanceof CellLayoutChildren) {
CellLayoutChildren parent = (CellLayoutChildren) getParent();
if (getParent() instanceof ShortcutAndWidgetContainer) {
ShortcutAndWidgetContainer parent = (ShortcutAndWidgetContainer) getParent();
if (parent != null) {
CellLayout layout = (CellLayout) parent.getParent();
layout.setPressedOrFocusedIcon((mPressedOrFocusedBackground != null) ? this : null);
+53 -75
View File
@@ -137,7 +137,7 @@ public class CellLayout extends ViewGroup {
private boolean mItemLocationsDirty = false;
private TimeInterpolator mEaseOutInterpolator;
private CellLayoutChildren mChildren;
private ShortcutAndWidgetContainer mShortcutsAndWidgets;
private boolean mIsHotseat = false;
private float mChildScale = 1f;
@@ -281,9 +281,9 @@ public class CellLayout extends ViewGroup {
mBackgroundRect = new Rect();
mForegroundRect = new Rect();
mChildren = new CellLayoutChildren(context);
mChildren.setCellDimensions(mCellWidth, mCellHeight, mWidthGap, mHeightGap);
addView(mChildren);
mShortcutsAndWidgets = new ShortcutAndWidgetContainer(context);
mShortcutsAndWidgets.setCellDimensions(mCellWidth, mCellHeight, mWidthGap, mHeightGap);
addView(mShortcutsAndWidgets);
}
static int widthInPortrait(Resources r, int numCells) {
@@ -309,7 +309,7 @@ public class CellLayout extends ViewGroup {
}
public void enableHardwareLayers() {
mChildren.enableHardwareLayers();
mShortcutsAndWidgets.enableHardwareLayers();
}
public void setGridSize(int x, int y) {
@@ -353,13 +353,6 @@ public class CellLayout extends ViewGroup {
}
}
public CellLayoutChildren getChildrenLayout() {
if (getChildCount() > 0) {
return (CellLayoutChildren) getChildAt(0);
}
return null;
}
void setIsDragOverlapping(boolean isDragOverlapping) {
if (mIsDragOverlapping != isDragOverlapping) {
mIsDragOverlapping = isDragOverlapping;
@@ -616,7 +609,7 @@ public class CellLayout extends ViewGroup {
// (this happens if we're being dropped from all-apps
if (bubbleChild.getLayoutParams() instanceof LayoutParams &&
(bubbleChild.getMeasuredWidth() | bubbleChild.getMeasuredHeight()) == 0) {
getChildrenLayout().measureChild(bubbleChild);
getShortcutsAndWidgets().measureChild(bubbleChild);
}
int measuredWidth = bubbleChild.getMeasuredWidth();
int measuredHeight = bubbleChild.getMeasuredHeight();
@@ -667,7 +660,7 @@ public class CellLayout extends ViewGroup {
child.setId(childId);
mChildren.addView(child, index, lp);
mShortcutsAndWidgets.addView(child, index, lp);
if (markCells) markCellsAsOccupiedForView(child);
@@ -679,61 +672,53 @@ public class CellLayout extends ViewGroup {
@Override
public void removeAllViews() {
clearOccupiedCells();
mChildren.removeAllViews();
mShortcutsAndWidgets.removeAllViews();
}
@Override
public void removeAllViewsInLayout() {
if (mChildren.getChildCount() > 0) {
if (mShortcutsAndWidgets.getChildCount() > 0) {
clearOccupiedCells();
mChildren.removeAllViewsInLayout();
mShortcutsAndWidgets.removeAllViewsInLayout();
}
}
public void removeViewWithoutMarkingCells(View view) {
mChildren.removeView(view);
mShortcutsAndWidgets.removeView(view);
}
@Override
public void removeView(View view) {
markCellsAsUnoccupiedForView(view);
mChildren.removeView(view);
mShortcutsAndWidgets.removeView(view);
}
@Override
public void removeViewAt(int index) {
markCellsAsUnoccupiedForView(mChildren.getChildAt(index));
mChildren.removeViewAt(index);
markCellsAsUnoccupiedForView(mShortcutsAndWidgets.getChildAt(index));
mShortcutsAndWidgets.removeViewAt(index);
}
@Override
public void removeViewInLayout(View view) {
markCellsAsUnoccupiedForView(view);
mChildren.removeViewInLayout(view);
mShortcutsAndWidgets.removeViewInLayout(view);
}
@Override
public void removeViews(int start, int count) {
for (int i = start; i < start + count; i++) {
markCellsAsUnoccupiedForView(mChildren.getChildAt(i));
markCellsAsUnoccupiedForView(mShortcutsAndWidgets.getChildAt(i));
}
mChildren.removeViews(start, count);
mShortcutsAndWidgets.removeViews(start, count);
}
@Override
public void removeViewsInLayout(int start, int count) {
for (int i = start; i < start + count; i++) {
markCellsAsUnoccupiedForView(mChildren.getChildAt(i));
markCellsAsUnoccupiedForView(mShortcutsAndWidgets.getChildAt(i));
}
mChildren.removeViewsInLayout(start, count);
}
public void drawChildren(Canvas canvas) {
mChildren.draw(canvas);
}
void buildChildrenLayer() {
mChildren.buildLayer();
mShortcutsAndWidgets.removeViewsInLayout(start, count);
}
@Override
@@ -747,11 +732,11 @@ public class CellLayout extends ViewGroup {
Rect frame = mRect;
final int x = touchX + mScrollX;
final int y = touchY + mScrollY;
final int count = mChildren.getChildCount();
final int count = mShortcutsAndWidgets.getChildCount();
boolean found = false;
for (int i = count - 1; i >= 0; i--) {
final View child = mChildren.getChildAt(i);
final View child = mShortcutsAndWidgets.getChildAt(i);
final LayoutParams lp = (LayoutParams) child.getLayoutParams();
if ((child.getVisibility() == VISIBLE || child.getAnimation() != null) &&
@@ -968,7 +953,7 @@ public class CellLayout extends ViewGroup {
int vFreeSpace = vSpace - (mCountY * mOriginalCellHeight);
mWidthGap = Math.min(mMaxGap, numWidthGaps > 0 ? (hFreeSpace / numWidthGaps) : 0);
mHeightGap = Math.min(mMaxGap,numHeightGaps > 0 ? (vFreeSpace / numHeightGaps) : 0);
mChildren.setCellDimensions(mCellWidth, mCellHeight, mWidthGap, mHeightGap);
mShortcutsAndWidgets.setCellDimensions(mCellWidth, mCellHeight, mWidthGap, mHeightGap);
} else {
mWidthGap = mOriginalWidthGap;
mHeightGap = mOriginalHeightGap;
@@ -1017,12 +1002,12 @@ public class CellLayout extends ViewGroup {
@Override
protected void setChildrenDrawingCacheEnabled(boolean enabled) {
mChildren.setChildrenDrawingCacheEnabled(enabled);
mShortcutsAndWidgets.setChildrenDrawingCacheEnabled(enabled);
}
@Override
protected void setChildrenDrawnWithCacheEnabled(boolean enabled) {
mChildren.setChildrenDrawnWithCacheEnabled(enabled);
mShortcutsAndWidgets.setChildrenDrawnWithCacheEnabled(enabled);
}
public float getBackgroundAlpha() {
@@ -1044,34 +1029,27 @@ public class CellLayout extends ViewGroup {
}
}
// Need to return true to let the view system know we know how to handle alpha-- this is
// because when our children have an alpha of 0.0f, they are still rendering their "dimmed"
// versions
@Override
protected boolean onSetAlpha(int alpha) {
return true;
}
@Override
public void setAlpha(float alpha) {
setChildrenAlpha(alpha);
super.setAlpha(alpha);
}
private void setChildrenAlpha(float alpha) {
public void setShortcutAndWidgetAlpha(float alpha) {
final int childCount = getChildCount();
for (int i = 0; i < childCount; i++) {
getChildAt(i).setAlpha(alpha);
}
}
public ShortcutAndWidgetContainer getShortcutsAndWidgets() {
if (getChildCount() > 0) {
return (ShortcutAndWidgetContainer) getChildAt(0);
}
return null;
}
public View getChildAt(int x, int y) {
return mChildren.getChildAt(x, y);
return mShortcutsAndWidgets.getChildAt(x, y);
}
public boolean animateChildToPosition(final View child, int cellX, int cellY, int duration,
int delay, boolean permanent, boolean adjustOccupied) {
CellLayoutChildren clc = getChildrenLayout();
ShortcutAndWidgetContainer clc = getShortcutsAndWidgets();
boolean[][] occupied = mOccupied;
if (!permanent) {
occupied = mTmpOccupied;
@@ -1623,7 +1601,7 @@ public class CellLayout extends ViewGroup {
boolean[][] occupied) {
boolean found = false;
int childCount = mChildren.getChildCount();
int childCount = mShortcutsAndWidgets.getChildCount();
Rect r0 = new Rect(boundingRect);
Rect r1 = new Rect();
@@ -1644,7 +1622,7 @@ public class CellLayout extends ViewGroup {
}
for (int i = 0; i < childCount; i++) {
View child = mChildren.getChildAt(i);
View child = mShortcutsAndWidgets.getChildAt(i);
if (views.contains(child)) continue;
LayoutParams lp = (LayoutParams) child.getLayoutParams();
@@ -1804,11 +1782,11 @@ public class CellLayout extends ViewGroup {
lp.tmpCellY = cellY;
}
int childCount = mChildren.getChildCount();
int childCount = mShortcutsAndWidgets.getChildCount();
Rect r0 = new Rect(cellX, cellY, cellX + spanX, cellY + spanY);
Rect r1 = new Rect();
for (int i = 0; i < childCount; i++) {
View child = mChildren.getChildAt(i);
View child = mShortcutsAndWidgets.getChildAt(i);
if (child == ignoreView) continue;
LayoutParams lp = (LayoutParams) child.getLayoutParams();
r1.set(lp.cellX, lp.cellY, lp.cellX + lp.cellHSpan, lp.cellY + lp.cellVSpan);
@@ -1903,9 +1881,9 @@ public class CellLayout extends ViewGroup {
}
private void copyCurrentStateToSolution(ItemConfiguration solution, boolean temp) {
int childCount = mChildren.getChildCount();
int childCount = mShortcutsAndWidgets.getChildCount();
for (int i = 0; i < childCount; i++) {
View child = mChildren.getChildAt(i);
View child = mShortcutsAndWidgets.getChildAt(i);
LayoutParams lp = (LayoutParams) child.getLayoutParams();
Point p;
if (temp) {
@@ -1924,9 +1902,9 @@ public class CellLayout extends ViewGroup {
}
}
int childCount = mChildren.getChildCount();
int childCount = mShortcutsAndWidgets.getChildCount();
for (int i = 0; i < childCount; i++) {
View child = mChildren.getChildAt(i);
View child = mShortcutsAndWidgets.getChildAt(i);
if (child == dragView) continue;
LayoutParams lp = (LayoutParams) child.getLayoutParams();
Point p = solution.map.get(child);
@@ -1951,9 +1929,9 @@ public class CellLayout extends ViewGroup {
}
}
int childCount = mChildren.getChildCount();
int childCount = mShortcutsAndWidgets.getChildCount();
for (int i = 0; i < childCount; i++) {
View child = mChildren.getChildAt(i);
View child = mShortcutsAndWidgets.getChildAt(i);
if (child == dragView) continue;
LayoutParams lp = (LayoutParams) child.getLayoutParams();
Point p = solution.map.get(child);
@@ -1976,18 +1954,18 @@ public class CellLayout extends ViewGroup {
mOccupied[i][j] = mTmpOccupied[i][j];
}
}
int childCount = mChildren.getChildCount();
int childCount = mShortcutsAndWidgets.getChildCount();
for (int i = 0; i < childCount; i++) {
LayoutParams lp = (LayoutParams) mChildren.getChildAt(i).getLayoutParams();
LayoutParams lp = (LayoutParams) mShortcutsAndWidgets.getChildAt(i).getLayoutParams();
lp.cellX = lp.tmpCellX;
lp.cellY = lp.tmpCellY;
}
}
public void setUseTempCoords(boolean useTempCoords) {
int childCount = mChildren.getChildCount();
int childCount = mShortcutsAndWidgets.getChildCount();
for (int i = 0; i < childCount; i++) {
LayoutParams lp = (LayoutParams) mChildren.getChildAt(i).getLayoutParams();
LayoutParams lp = (LayoutParams) mShortcutsAndWidgets.getChildAt(i).getLayoutParams();
lp.useTmpCoords = useTempCoords;
}
}
@@ -1998,9 +1976,9 @@ public class CellLayout extends ViewGroup {
mTmpOccupied[i][j] = mOccupied[i][j];
}
}
int childCount = mChildren.getChildCount();
int childCount = mShortcutsAndWidgets.getChildCount();
for (int i = 0; i < childCount; i++) {
View child = mChildren.getChildAt(i);
View child = mShortcutsAndWidgets.getChildAt(i);
if (child == ignoreView) continue;
LayoutParams lp = (LayoutParams) child.getLayoutParams();
lp.tmpCellX = lp.cellX;
@@ -2094,7 +2072,7 @@ public class CellLayout extends ViewGroup {
}
boolean[][] occupied = mOccupied;
mChildren.requestLayout();
mShortcutsAndWidgets.requestLayout();
return result;
}
@@ -2542,7 +2520,7 @@ out: for (int i = x; i < x + spanX - 1 && x < xCount; i++) {
markCellsAsOccupiedForView(view, mOccupied);
}
public void markCellsAsOccupiedForView(View view, boolean[][] occupied) {
if (view == null || view.getParent() != mChildren) return;
if (view == null || view.getParent() != mShortcutsAndWidgets) return;
LayoutParams lp = (LayoutParams) view.getLayoutParams();
markCellsForView(lp.cellX, lp.cellY, lp.cellHSpan, lp.cellVSpan, occupied, true);
}
@@ -2551,7 +2529,7 @@ out: for (int i = x; i < x + spanX - 1 && x < xCount; i++) {
markCellsAsUnoccupiedForView(view, mOccupied);
}
public void markCellsAsUnoccupiedForView(View view, boolean occupied[][]) {
if (view == null || view.getParent() != mChildren) return;
if (view == null || view.getParent() != mShortcutsAndWidgets) return;
LayoutParams lp = (LayoutParams) view.getLayoutParams();
markCellsForView(lp.cellX, lp.cellY, lp.cellHSpan, lp.cellVSpan, occupied, false);
}
+1 -1
View File
@@ -434,7 +434,7 @@ public class DragLayer extends FrameLayout {
public void animateViewIntoPosition(DragView dragView, final View child, int duration,
final Runnable onFinishAnimationRunnable, View anchorView) {
CellLayoutChildren parentChildren = (CellLayoutChildren) child.getParent();
ShortcutAndWidgetContainer parentChildren = (ShortcutAndWidgetContainer) child.getParent();
CellLayout parent = (CellLayout) (CellLayout) parentChildren.getParent();
CellLayout.LayoutParams lp = (CellLayout.LayoutParams) child.getLayoutParams();
parentChildren.measureChild(child);
+6 -5
View File
@@ -534,7 +534,7 @@ public class FocusHelper {
if (handleKeyEvent) {
// Select the first bubble text view in the current page of the workspace
final CellLayout layout = (CellLayout) workspace.getChildAt(pageIndex);
final CellLayoutChildren children = layout.getChildrenLayout();
final ShortcutAndWidgetContainer children = layout.getShortcutsAndWidgets();
final View newIcon = getIconInDirection(layout, children, -1, 1);
if (newIcon != null) {
newIcon.requestFocus();
@@ -556,9 +556,10 @@ public class FocusHelper {
/**
* Private helper method to get the CellLayoutChildren given a CellLayout index.
*/
private static CellLayoutChildren getCellLayoutChildrenForIndex(ViewGroup container, int i) {
private static ShortcutAndWidgetContainer getCellLayoutChildrenForIndex(
ViewGroup container, int i) {
ViewGroup parent = (ViewGroup) container.getChildAt(i);
return (CellLayoutChildren) parent.getChildAt(0);
return (ShortcutAndWidgetContainer) parent.getChildAt(0);
}
/**
@@ -664,7 +665,7 @@ public class FocusHelper {
* Handles key events in a Workspace containing.
*/
static boolean handleIconKeyEvent(View v, int keyCode, KeyEvent e) {
CellLayoutChildren parent = (CellLayoutChildren) v.getParent();
ShortcutAndWidgetContainer parent = (ShortcutAndWidgetContainer) v.getParent();
final CellLayout layout = (CellLayout) parent.getParent();
final Workspace workspace = (Workspace) layout.getParent();
final ViewGroup launcher = (ViewGroup) workspace.getParent();
@@ -819,7 +820,7 @@ public class FocusHelper {
* Handles key events for items in a Folder.
*/
static boolean handleFolderKeyEvent(View v, int keyCode, KeyEvent e) {
CellLayoutChildren parent = (CellLayoutChildren) v.getParent();
ShortcutAndWidgetContainer parent = (ShortcutAndWidgetContainer) v.getParent();
final CellLayout layout = (CellLayout) parent.getParent();
final Folder folder = (Folder) layout.getParent();
View title = folder.mFolderName;
+4 -4
View File
@@ -148,7 +148,7 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
super.onFinishInflate();
mContent = (CellLayout) findViewById(R.id.folder_content);
mContent.setGridSize(0, 0);
mContent.getChildrenLayout().setMotionEventSplittingEnabled(false);
mContent.getShortcutsAndWidgets().setMotionEventSplittingEnabled(false);
mFolderName = (FolderEditText) findViewById(R.id.folder_name);
mFolderName.setFolder(this);
mFolderName.setOnFocusChangeListener(this);
@@ -735,7 +735,7 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
mLauncher.getWorkspace().setFinalScrollForPageChange(currentPage);
// We first fetch the currently visible CellLayoutChildren
CellLayout currentLayout = (CellLayout) mLauncher.getWorkspace().getChildAt(currentPage);
CellLayoutChildren boundingLayout = currentLayout.getChildrenLayout();
ShortcutAndWidgetContainer boundingLayout = currentLayout.getShortcutsAndWidgets();
Rect bounds = new Rect();
parent.getDescendantRectRelativeToSelf(boundingLayout, bounds);
// We reset the workspaces scroll
@@ -826,11 +826,11 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
}
public int getItemCount() {
return mContent.getChildrenLayout().getChildCount();
return mContent.getShortcutsAndWidgets().getChildCount();
}
public View getItemAt(int index) {
return mContent.getChildrenLayout().getChildAt(index);
return mContent.getShortcutsAndWidgets().getChildAt(index);
}
private void onCloseComplete() {
@@ -26,7 +26,7 @@ import android.view.ViewGroup;
import com.android.launcher2.CellLayout.LayoutParams;
public class CellLayoutChildren extends ViewGroup {
public class ShortcutAndWidgetContainer extends ViewGroup {
static final String TAG = "CellLayoutChildren";
// These are temporary variables to prevent having to allocate a new object just to
@@ -41,7 +41,7 @@ public class CellLayoutChildren extends ViewGroup {
private int mWidthGap;
private int mHeightGap;
public CellLayoutChildren(Context context) {
public ShortcutAndWidgetContainer(Context context) {
super(context);
mWallpaperManager = WallpaperManager.getInstance(context);
}
+40 -29
View File
@@ -364,7 +364,7 @@ public class Workspace extends SmoothPagedView
final int childCount = getChildCount();
for (int i = 0; i < childCount; i++) {
CellLayout cl = (CellLayout) getChildAt(i);
cl.buildChildrenLayer();
cl.getShortcutsAndWidgets().buildLayer();
}
}
}
@@ -378,7 +378,7 @@ public class Workspace extends SmoothPagedView
int count = getChildCount();
for (int i = 0; i < count; i++) {
CellLayout cl = (CellLayout) getPageAt(i);
cl.getChildrenLayout().animate().alpha(mDragFadeOutAlpha)
cl.getShortcutsAndWidgets().animate().alpha(mDragFadeOutAlpha)
.setInterpolator(new AccelerateInterpolator(1.5f))
.setDuration(mDragFadeOutDuration)
.start();
@@ -394,7 +394,7 @@ public class Workspace extends SmoothPagedView
int count = getChildCount();
for (int i = 0; i < count; i++) {
CellLayout cl = (CellLayout) getPageAt(i);
cl.getChildrenLayout().animate().alpha(1f)
cl.getShortcutsAndWidgets().animate().alpha(1f)
.setInterpolator(new DecelerateInterpolator(1.5f))
.setDuration(mDragFadeOutDuration)
.start();
@@ -723,7 +723,7 @@ public class Workspace extends SmoothPagedView
// user scrolls while we are transitioning (should not affect dispatchDraw optimizations)
if (!mFadeInAdjacentScreens) {
for (int i = 0; i < getChildCount(); ++i) {
getPageAt(i).setAlpha(1f);
((CellLayout) getPageAt(i)).setShortcutAndWidgetAlpha(1f);
}
}
@@ -1206,7 +1206,7 @@ public class Workspace extends SmoothPagedView
cl.setRotationY(rotation);
if (mFadeInAdjacentScreens && !isSmall()) {
float alpha = 1 - Math.abs(scrollProgress);
cl.setAlpha(alpha);
cl.setShortcutAndWidgetAlpha(alpha);
}
}
}
@@ -1658,7 +1658,7 @@ public class Workspace extends SmoothPagedView
cl.setScaleY(finalScaleFactor);
cl.setBackgroundAlpha(finalBackgroundAlpha);
cl.setBackgroundAlphaMultiplier(finalAlphaMultiplierValue);
cl.setAlpha(finalAlpha);
cl.setShortcutAndWidgetAlpha(finalAlpha);
cl.setRotationY(rotation);
}
}
@@ -1674,7 +1674,7 @@ public class Workspace extends SmoothPagedView
cl.setScaleY(mNewScaleYs[i]);
cl.setBackgroundAlpha(mNewBackgroundAlphas[i]);
cl.setBackgroundAlphaMultiplier(mNewBackgroundAlphaMultipliers[i]);
cl.setAlpha(mNewAlphas[i]);
cl.setShortcutAndWidgetAlpha(mNewAlphas[i]);
cl.setRotationY(mNewRotationYs[i]);
} else {
LauncherViewPropertyAnimator a = new LauncherViewPropertyAnimator(cl);
@@ -1684,10 +1684,16 @@ public class Workspace extends SmoothPagedView
.scaleY(mNewScaleYs[i])
.setDuration(duration)
.setInterpolator(mZoomInInterpolator);
if (mOldAlphas[i] != mNewAlphas[i]) {
a.alpha(mNewAlphas[i]);
}
anim.play(a);
LauncherViewPropertyAnimator alphaAnim =
new LauncherViewPropertyAnimator(cl.getShortcutsAndWidgets());
if (mOldAlphas[i] != mNewAlphas[i]) {
alphaAnim.alpha(mNewAlphas[i])
.setDuration(duration)
.setInterpolator(mZoomInInterpolator);
anim.play(alphaAnim);
}
if (mOldRotationYs[i] != 0 || mNewRotationYs[i] != 0) {
ValueAnimator rotate = ValueAnimator.ofFloat(0f, 1f).setDuration(duration);
rotate.setInterpolator(new DecelerateInterpolator(2.0f));
@@ -1756,7 +1762,7 @@ public class Workspace extends SmoothPagedView
if (!mFadeInAdjacentScreens) {
for (int i = 0; i < getChildCount(); i++) {
final CellLayout cl = (CellLayout) getChildAt(i);
cl.setAlpha(1f);
cl.setShortcutAndWidgetAlpha(1f);
}
}
}
@@ -3080,7 +3086,7 @@ public class Workspace extends SmoothPagedView
info.spanY, insertAtFirst);
cellLayout.onDropChild(view);
CellLayout.LayoutParams lp = (CellLayout.LayoutParams) view.getLayoutParams();
cellLayout.getChildrenLayout().measureChild(view);
cellLayout.getShortcutsAndWidgets().measureChild(view);
LauncherModel.addOrMoveItemInDatabase(mLauncher, info, container, screen,
@@ -3319,10 +3325,10 @@ public class Workspace extends SmoothPagedView
}
private void updateItemLocationsInDatabase(CellLayout cl) {
int count = cl.getChildrenLayout().getChildCount();
int count = cl.getShortcutsAndWidgets().getChildCount();
int screen = indexOfChild(cl);
for (int i = 0; i < count; i++) {
View v = cl.getChildrenLayout().getChildAt(i);
View v = cl.getShortcutsAndWidgets().getChildAt(i);
ItemInfo info = (ItemInfo) v.getTag();
LauncherModel.moveItemInDatabase(mLauncher, info, Favorites.CONTAINER_DESKTOP, screen,
@@ -3443,7 +3449,7 @@ public class Workspace extends SmoothPagedView
CellLayout getParentCellLayoutForView(View v) {
ArrayList<CellLayout> layouts = getWorkspaceAndHotseatCellLayouts();
for (CellLayout layout : layouts) {
if (layout.getChildrenLayout().indexOfChild(v) > -1) {
if (layout.getShortcutsAndWidgets().indexOfChild(v) > -1) {
return layout;
}
}
@@ -3467,23 +3473,26 @@ public class Workspace extends SmoothPagedView
/**
* We should only use this to search for specific children. Do not use this method to modify
* CellLayoutChildren directly.
* ShortcutsAndWidgetsContainer directly. Includes ShortcutAndWidgetContainers from
* the hotseat and workspace pages
*/
ArrayList<CellLayoutChildren> getWorkspaceAndHotseatCellLayoutChildren() {
ArrayList<CellLayoutChildren> childrenLayouts = new ArrayList<CellLayoutChildren>();
ArrayList<ShortcutAndWidgetContainer> getAllShortcutAndWidgetContainers() {
ArrayList<ShortcutAndWidgetContainer> childrenLayouts =
new ArrayList<ShortcutAndWidgetContainer>();
int screenCount = getChildCount();
for (int screen = 0; screen < screenCount; screen++) {
childrenLayouts.add(((CellLayout) getChildAt(screen)).getChildrenLayout());
childrenLayouts.add(((CellLayout) getChildAt(screen)).getShortcutsAndWidgets());
}
if (mLauncher.getHotseat() != null) {
childrenLayouts.add(mLauncher.getHotseat().getLayout().getChildrenLayout());
childrenLayouts.add(mLauncher.getHotseat().getLayout().getShortcutsAndWidgets());
}
return childrenLayouts;
}
public Folder getFolderForTag(Object tag) {
ArrayList<CellLayoutChildren> childrenLayouts = getWorkspaceAndHotseatCellLayoutChildren();
for (CellLayoutChildren layout: childrenLayouts) {
ArrayList<ShortcutAndWidgetContainer> childrenLayouts =
getAllShortcutAndWidgetContainers();
for (ShortcutAndWidgetContainer layout: childrenLayouts) {
int count = layout.getChildCount();
for (int i = 0; i < count; i++) {
View child = layout.getChildAt(i);
@@ -3499,8 +3508,9 @@ public class Workspace extends SmoothPagedView
}
public View getViewForTag(Object tag) {
ArrayList<CellLayoutChildren> childrenLayouts = getWorkspaceAndHotseatCellLayoutChildren();
for (CellLayoutChildren layout: childrenLayouts) {
ArrayList<ShortcutAndWidgetContainer> childrenLayouts =
getAllShortcutAndWidgetContainers();
for (ShortcutAndWidgetContainer layout: childrenLayouts) {
int count = layout.getChildCount();
for (int i = 0; i < count; i++) {
View child = layout.getChildAt(i);
@@ -3513,8 +3523,9 @@ public class Workspace extends SmoothPagedView
}
void clearDropTargets() {
ArrayList<CellLayoutChildren> childrenLayouts = getWorkspaceAndHotseatCellLayoutChildren();
for (CellLayoutChildren layout: childrenLayouts) {
ArrayList<ShortcutAndWidgetContainer> childrenLayouts =
getAllShortcutAndWidgetContainers();
for (ShortcutAndWidgetContainer layout: childrenLayouts) {
int childCount = layout.getChildCount();
for (int j = 0; j < childCount; j++) {
View v = layout.getChildAt(j);
@@ -3536,7 +3547,7 @@ public class Workspace extends SmoothPagedView
ArrayList<CellLayout> cellLayouts = getWorkspaceAndHotseatCellLayouts();
for (final CellLayout layoutParent: cellLayouts) {
final ViewGroup layout = layoutParent.getChildrenLayout();
final ViewGroup layout = layoutParent.getShortcutsAndWidgets();
// Avoid ANRs by treating each screen separately
post(new Runnable() {
@@ -3622,8 +3633,8 @@ public class Workspace extends SmoothPagedView
}
void updateShortcuts(ArrayList<ApplicationInfo> apps) {
ArrayList<CellLayoutChildren> childrenLayouts = getWorkspaceAndHotseatCellLayoutChildren();
for (CellLayoutChildren layout: childrenLayouts) {
ArrayList<ShortcutAndWidgetContainer> childrenLayouts = getAllShortcutAndWidgetContainers();
for (ShortcutAndWidgetContainer layout: childrenLayouts) {
int childCount = layout.getChildCount();
for (int j = 0; j < childCount; j++) {
final View view = layout.getChildAt(j);