diff options
Diffstat (limited to 'src/com/android/launcher2/Folder.java')
-rw-r--r-- | src/com/android/launcher2/Folder.java | 112 |
1 files changed, 24 insertions, 88 deletions
diff --git a/src/com/android/launcher2/Folder.java b/src/com/android/launcher2/Folder.java index fdde4d593..08d33159f 100644 --- a/src/com/android/launcher2/Folder.java +++ b/src/com/android/launcher2/Folder.java @@ -20,8 +20,6 @@ import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.ObjectAnimator; import android.animation.PropertyValuesHolder; -import android.animation.ValueAnimator; -import android.animation.ValueAnimator.AnimatorUpdateListener; import android.content.Context; import android.content.res.Resources; import android.graphics.Rect; @@ -37,10 +35,9 @@ import android.view.Menu; import android.view.MenuItem; import android.view.MotionEvent; import android.view.View; +import android.view.View.MeasureSpec; import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityManager; -import android.view.animation.AccelerateInterpolator; -import android.view.animation.DecelerateInterpolator; import android.view.inputmethod.EditorInfo; import android.view.inputmethod.InputMethodManager; import android.widget.LinearLayout; @@ -74,18 +71,13 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList private final LayoutInflater mInflater; private final IconCache mIconCache; private int mState = STATE_NONE; - private static final int FULL_GROW = 0; - private static final int PARTIAL_GROW = 1; private static final int REORDER_ANIMATION_DURATION = 230; private static final int ON_EXIT_CLOSE_DELAY = 800; - private int mMode = PARTIAL_GROW; private boolean mRearrangeOnClose = false; private FolderIcon mFolderIcon; private int mMaxCountX; private int mMaxCountY; private int mMaxNumItems; - private Rect mNewSize = new Rect(); - private Rect mIconRect = new Rect(); private ArrayList<View> mItemsInReadingOrder = new ArrayList<View>(); private Drawable mIconDrawable; boolean mItemsInvalidated = false; @@ -365,21 +357,9 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList */ private void positionAndSizeAsIcon() { if (!(getParent() instanceof DragLayer)) return; - - DragLayer.LayoutParams lp = (DragLayer.LayoutParams) getLayoutParams(); - - if (mMode == PARTIAL_GROW) { - setScaleX(0.8f); - setScaleY(0.8f); - setAlpha(0f); - } else { - mLauncher.getDragLayer().getDescendantRectRelativeToSelf(mFolderIcon, mIconRect); - lp.width = mIconRect.width(); - lp.height = mIconRect.height(); - lp.x = mIconRect.left; - lp.y = mIconRect.top; - mContent.setAlpha(0); - } + setScaleX(0.8f); + setScaleY(0.8f); + setAlpha(0f); mState = STATE_SMALL; } @@ -387,34 +367,11 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList positionAndSizeAsIcon(); if (!(getParent() instanceof DragLayer)) return; - - ObjectAnimator oa; - DragLayer.LayoutParams lp = (DragLayer.LayoutParams) getLayoutParams(); - centerAboutIcon(); - if (mMode == PARTIAL_GROW) { - PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("alpha", 1); - PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat("scaleX", 1.0f); - PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat("scaleY", 1.0f); - oa = ObjectAnimator.ofPropertyValuesHolder(this, alpha, scaleX, scaleY); - } else { - PropertyValuesHolder width = PropertyValuesHolder.ofInt("width", mNewSize.width()); - PropertyValuesHolder height = PropertyValuesHolder.ofInt("height", mNewSize.height()); - PropertyValuesHolder x = PropertyValuesHolder.ofInt("x", mNewSize.left); - PropertyValuesHolder y = PropertyValuesHolder.ofInt("y", mNewSize.top); - oa = ObjectAnimator.ofPropertyValuesHolder(lp, width, height, x, y); - oa.addUpdateListener(new AnimatorUpdateListener() { - public void onAnimationUpdate(ValueAnimator animation) { - requestLayout(); - } - }); - - PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("alpha", 1.0f); - ObjectAnimator alphaOa = ObjectAnimator.ofPropertyValuesHolder(mContent, alpha); - alphaOa.setDuration(mExpandDuration); - alphaOa.setInterpolator(new AccelerateInterpolator(2.0f)); - alphaOa.start(); - } + PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("alpha", 1); + PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat("scaleX", 1.0f); + PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat("scaleY", 1.0f); + ObjectAnimator oa = ObjectAnimator.ofPropertyValuesHolder(this, alpha, scaleX, scaleY); oa.addListener(new AnimatorListenerAdapter() { @Override @@ -457,33 +414,10 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList public void animateClosed() { if (!(getParent() instanceof DragLayer)) return; - - ObjectAnimator oa; - if (mMode == PARTIAL_GROW) { - PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("alpha", 0); - PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat("scaleX", 0.9f); - PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat("scaleY", 0.9f); - oa = ObjectAnimator.ofPropertyValuesHolder(this, alpha, scaleX, scaleY); - } else { - DragLayer.LayoutParams lp = (DragLayer.LayoutParams) getLayoutParams(); - - PropertyValuesHolder width = PropertyValuesHolder.ofInt("width", mIconRect.width()); - PropertyValuesHolder height = PropertyValuesHolder.ofInt("height", mIconRect.height()); - PropertyValuesHolder x = PropertyValuesHolder.ofInt("x", mIconRect.left); - PropertyValuesHolder y = PropertyValuesHolder.ofInt("y", mIconRect.top); - oa = ObjectAnimator.ofPropertyValuesHolder(lp, width, height, x, y); - oa.addUpdateListener(new AnimatorUpdateListener() { - public void onAnimationUpdate(ValueAnimator animation) { - requestLayout(); - } - }); - - PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("alpha", 0f); - ObjectAnimator alphaOa = ObjectAnimator.ofPropertyValuesHolder(mContent, alpha); - alphaOa.setDuration(mExpandDuration); - alphaOa.setInterpolator(new DecelerateInterpolator(2.0f)); - alphaOa.start(); - } + PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("alpha", 0); + PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat("scaleX", 0.9f); + PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat("scaleY", 0.9f); + ObjectAnimator oa = ObjectAnimator.ofPropertyValuesHolder(this, alpha, scaleX, scaleY); oa.addListener(new AnimatorListenerAdapter() { @Override @@ -791,11 +725,17 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList int centeredLeft = centerX - width / 2; int centeredTop = centerY - height / 2; + int currentPage = mLauncher.getWorkspace().getCurrentPage(); + // In case the workspace is scrolling, we need to use the final scroll to compute + // the folders bounds. + mLauncher.getWorkspace().setFinalScrollForPageChange(currentPage); // We first fetch the currently visible CellLayoutChildren - CellLayout currentPage = mLauncher.getWorkspace().getCurrentDropLayout(); - CellLayoutChildren boundingLayout = currentPage.getChildrenLayout(); + CellLayout currentLayout = (CellLayout) mLauncher.getWorkspace().getChildAt(currentPage); + CellLayoutChildren boundingLayout = currentLayout.getChildrenLayout(); Rect bounds = new Rect(); parent.getDescendantRectRelativeToSelf(boundingLayout, bounds); + // We reset the workspaces scroll + mLauncher.getWorkspace().resetFinalScrollForPageChange(currentPage); // We need to bound the folder to the currently visible CellLayoutChildren int left = Math.min(Math.max(bounds.left, centeredLeft), @@ -821,14 +761,10 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList mFolderIcon.setPivotX(folderIconPivotX); mFolderIcon.setPivotY(folderIconPivotY); - if (mMode == PARTIAL_GROW) { - lp.width = width; - lp.height = height; - lp.x = left; - lp.y = top; - } else { - mNewSize.set(left, top, left + width, top + height); - } + lp.width = width; + lp.height = height; + lp.x = left; + lp.y = top; } private void setupContentForNumItems(int count) { |