From 2ee7ccecc8705f48d05104e0dcba9f118195af56 Mon Sep 17 00:00:00 2001 From: Hayden Schoen Date: Thu, 9 Jul 2015 19:58:56 -0700 Subject: Folder Layout Revision Updated the folder layout to reflect design revisions based on community feedback Change-Id: Ica1bb796dfccf779a954cf0903a1ae94a010ea1a --- res/drawable-hdpi/folder_bg.9.png | Bin 197 -> 823 bytes res/drawable-hdpi/folder_fill_highlight.9.png | Bin 429 -> 14914 bytes res/drawable-mdpi/folder_bg.9.png | Bin 149 -> 510 bytes res/drawable-mdpi/folder_fill_highlight.9.png | Bin 324 -> 14764 bytes res/drawable-xhdpi/folder_bg.9.png | Bin 246 -> 1023 bytes res/drawable-xhdpi/folder_fill_highlight.9.png | Bin 594 -> 15075 bytes res/drawable-xxhdpi/folder_bg.9.png | Bin 320 -> 1678 bytes res/drawable-xxhdpi/folder_fill_highlight.9.png | Bin 811 -> 15836 bytes res/layout-land/launcher.xml | 13 +- res/layout-port/launcher.xml | 13 +- res/layout-sw720dp/launcher.xml | 13 +- res/layout/user_folder.xml | 76 ++++--- res/values/dimens.xml | 6 +- src/com/android/launcher3/Folder.java | 263 ++++-------------------- src/com/android/launcher3/FolderIcon.java | 47 ++--- src/com/android/launcher3/Launcher.java | 13 +- 16 files changed, 119 insertions(+), 325 deletions(-) mode change 100755 => 100644 res/drawable-hdpi/folder_bg.9.png mode change 100755 => 100644 res/drawable-hdpi/folder_fill_highlight.9.png mode change 100755 => 100644 res/drawable-mdpi/folder_bg.9.png mode change 100755 => 100644 res/drawable-mdpi/folder_fill_highlight.9.png mode change 100755 => 100644 res/drawable-xhdpi/folder_bg.9.png mode change 100755 => 100644 res/drawable-xhdpi/folder_fill_highlight.9.png mode change 100755 => 100644 res/drawable-xxhdpi/folder_bg.9.png mode change 100755 => 100644 res/drawable-xxhdpi/folder_fill_highlight.9.png diff --git a/res/drawable-hdpi/folder_bg.9.png b/res/drawable-hdpi/folder_bg.9.png old mode 100755 new mode 100644 index 4b2108053..ee0090c09 Binary files a/res/drawable-hdpi/folder_bg.9.png and b/res/drawable-hdpi/folder_bg.9.png differ diff --git a/res/drawable-hdpi/folder_fill_highlight.9.png b/res/drawable-hdpi/folder_fill_highlight.9.png old mode 100755 new mode 100644 index c7dde8930..b82302ba6 Binary files a/res/drawable-hdpi/folder_fill_highlight.9.png and b/res/drawable-hdpi/folder_fill_highlight.9.png differ diff --git a/res/drawable-mdpi/folder_bg.9.png b/res/drawable-mdpi/folder_bg.9.png old mode 100755 new mode 100644 index 36154e2fb..4039da560 Binary files a/res/drawable-mdpi/folder_bg.9.png and b/res/drawable-mdpi/folder_bg.9.png differ diff --git a/res/drawable-mdpi/folder_fill_highlight.9.png b/res/drawable-mdpi/folder_fill_highlight.9.png old mode 100755 new mode 100644 index 418048471..7c6a0d456 Binary files a/res/drawable-mdpi/folder_fill_highlight.9.png and b/res/drawable-mdpi/folder_fill_highlight.9.png differ diff --git a/res/drawable-xhdpi/folder_bg.9.png b/res/drawable-xhdpi/folder_bg.9.png old mode 100755 new mode 100644 index c3a30837a..1fbe1d80f Binary files a/res/drawable-xhdpi/folder_bg.9.png and b/res/drawable-xhdpi/folder_bg.9.png differ diff --git a/res/drawable-xhdpi/folder_fill_highlight.9.png b/res/drawable-xhdpi/folder_fill_highlight.9.png old mode 100755 new mode 100644 index c1a4f702f..f5f0bd08d Binary files a/res/drawable-xhdpi/folder_fill_highlight.9.png and b/res/drawable-xhdpi/folder_fill_highlight.9.png differ diff --git a/res/drawable-xxhdpi/folder_bg.9.png b/res/drawable-xxhdpi/folder_bg.9.png old mode 100755 new mode 100644 index d698a0750..3b2bc4253 Binary files a/res/drawable-xxhdpi/folder_bg.9.png and b/res/drawable-xxhdpi/folder_bg.9.png differ diff --git a/res/drawable-xxhdpi/folder_fill_highlight.9.png b/res/drawable-xxhdpi/folder_fill_highlight.9.png old mode 100755 new mode 100644 index c80ead243..4dc29f46c Binary files a/res/drawable-xxhdpi/folder_fill_highlight.9.png and b/res/drawable-xxhdpi/folder_fill_highlight.9.png differ diff --git a/res/layout-land/launcher.xml b/res/layout-land/launcher.xml index 4242b065d..a865bc6ca 100644 --- a/res/layout-land/launcher.xml +++ b/res/layout-land/launcher.xml @@ -29,19 +29,8 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:visibility="invisible" - android:alpha=".5" + android:alpha="1.0" android:clipToPadding="false"> - - - - - - - - - - - + android:paddingBottom="@dimen/folder_preview_padding" + android:layout_gravity="center" + android:background="@drawable/folder_bg"> - + + + + + + diff --git a/res/values/dimens.xml b/res/values/dimens.xml index b915a2876..97a12abdc 100644 --- a/res/values/dimens.xml +++ b/res/values/dimens.xml @@ -103,14 +103,14 @@ - 4dp + 10dp 6dp 10dp - 50dp + 48dp 64dp - 26dp + 22dp 24dp diff --git a/src/com/android/launcher3/Folder.java b/src/com/android/launcher3/Folder.java index 614e1cd20..d10be4efc 100644 --- a/src/com/android/launcher3/Folder.java +++ b/src/com/android/launcher3/Folder.java @@ -39,6 +39,7 @@ import android.text.Selection; import android.text.Spannable; import android.text.TextUtils; import android.util.AttributeSet; +import android.util.DisplayMetrics; import android.util.Log; import android.util.Pair; import android.view.ActionMode; @@ -48,7 +49,6 @@ import android.view.Menu; import android.view.MenuItem; import android.view.MotionEvent; import android.view.View; -import android.view.ViewAnimationUtils; import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityManager; import android.view.animation.AccelerateInterpolator; @@ -94,6 +94,8 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList private static final int CLOSE_FOLDER_DELAY_MS = 150; + private static final int ALPHA_DELAY_MULT = 15; + private final PowerManager mPowerManager; private int mExpandDuration; @@ -130,8 +132,10 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList private boolean mDeleteFolderOnDropCompleted = false; private boolean mSuppressFolderDeletion = false; private boolean mItemAddedBackToSelfViaIcon = false; + View mFolderNameLockContainer; FolderEditText mFolderName; ImageView mFolderLock; + private int mScreenWidth; private float mFolderIconPivotX; private float mFolderIconPivotY; private boolean mHideLabels; @@ -228,6 +232,7 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList mContent.setGridSize(0, 0); mContent.getShortcutsAndWidgets().setMotionEventSplittingEnabled(false); mContent.setInvertIfRtl(true); + mFolderNameLockContainer = findViewById(R.id.folder_name_lock_container); mFolderName = (FolderEditText) findViewById(R.id.folder_name); mFolderName.setFolder(this); mFolderName.setOnFocusChangeListener(this); @@ -256,6 +261,9 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList mFolderLock.measure(measureSpec, measureSpec); mFolderLock.setOnClickListener(this); mFolderLockHeight = mFolderLock.getMeasuredHeight(); + + DisplayMetrics displayMetrics = this.getResources().getDisplayMetrics(); + mScreenWidth = displayMetrics.widthPixels; } private ActionMode.Callback mActionModeCallback = new ActionMode.Callback() { @@ -552,29 +560,10 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList View reveal = mLauncher.findViewById(R.id.reveal_fake_page_container); reveal.setVisibility(View.VISIBLE); - View revealPage = mLauncher.findViewById(R.id.reveal_fake_page); - revealPage.setVisibility(View.VISIBLE); - View revealOutline = mLauncher.findViewById(R.id.reveal_fake_folder_outline); - revealOutline.setVisibility(View.INVISIBLE); View revealFolderIcon = mLauncher.findViewById(R.id.reveal_fake_folder_icon); revealFolderIcon.setVisibility(View.INVISIBLE); } - private void prepareOutline() { - View outline = mLauncher.findViewById(R.id.reveal_fake_folder_outline); - FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) outline.getLayoutParams(); - int width = getPaddingLeft() + getPaddingRight() + mContent.getDesiredWidth(); - int height = getFolderHeight(); - - lp.width = width; - lp.height = height; - outline.setLayoutParams(lp); - - outline.setX(mLeft); - outline.setY(mTop); - outline.setVisibility(View.INVISIBLE); - } - private void prepareFakeFolderIcon() { mFolderIcon.buildDrawingCache(true); @@ -620,7 +609,7 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList return animator; } - public void animateOpen(Workspace workspace) { + public void animateOpen(Workspace workspace, int[] folderTouch) { if (!(getParent() instanceof DragLayer)) return; Animator openFolderAnim = null; @@ -660,14 +649,41 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList AnimatorSet anim = LauncherAnimUtils.createAnimatorSet(); - View[] alphaViewSet = new View[] { mFolderLock, mContent, mFolderName }; - for (View view : alphaViewSet) { - Animator alphaAnimator = setupAlphaAnimator(view, 0f, 1f, - mMaterialExpandDuration, mMaterialExpandStagger); + int[] folderLocation = new int[2]; + getLocationOnScreen(folderLocation); + + int circX = folderTouch[0] - folderLocation[0]; + int circY = folderTouch[1] - folderLocation[1]; + + Animator circReveal = LauncherAnimUtils.createCircularReveal(this, + circX, circY, 0, mScreenWidth); - anim.play(alphaAnimator); + final View[] alphaViewSet = new View[] { mFolderNameLockContainer, + mContent, mFolderName, mFolderLock }; + for (View view : alphaViewSet) { + view.setAlpha(0f); } + circReveal.setDuration(150); + circReveal.addListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationEnd(Animator animation) { + super.onAnimationEnd(animation); + + int i = 0; + for (View view : alphaViewSet) { + view.setVisibility(VISIBLE); + Animator alphaAnimator = setupAlphaAnimator(view, 0f, 1f, + mMaterialExpandDuration, mMaterialExpandStagger); + alphaAnimator.setStartDelay(ALPHA_DELAY_MULT * i); + alphaAnimator.start(); + i++; + } + } + }); + + circReveal.start(); + Animator drift = LauncherAnimUtils.ofPropertyValuesHolder(this, tx, ty); drift.setDuration(mMaterialExpandDuration); drift.setStartDelay(mMaterialExpandStagger); @@ -705,7 +721,6 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList fakeFolderIcon.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { - mFolderIcon.setPreviewBackground(-1); mFolderIcon.setAlpha(0); fakeFolderIconView.setVisibility(View.VISIBLE); } @@ -718,27 +733,6 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList Animator revealAnim = null; prepareReveal(); - if (!mIsExternalDrag) { - revealAnim = getFolderIconRevealAnimator(false); - } else { - prepareOutline(); - View revealFakeView = mLauncher.findViewById(R.id.reveal_fake_page); - revealFakeView.setVisibility(View.INVISIBLE); - View outlineView = mLauncher.findViewById(R.id.reveal_fake_folder_outline); - outlineView.setAlpha(0f); - outlineView.setVisibility(View.VISIBLE); - - float baseOutlineTranslationY = outlineView.getTranslationY(); - PropertyValuesHolder outlineTransY = PropertyValuesHolder.ofFloat("translationY", - baseOutlineTranslationY + transY, baseOutlineTranslationY); - - PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("alpha", 0f, 1f); - revealAnim = LauncherAnimUtils.ofPropertyValuesHolder(outlineView, alpha, - outlineTransY); - revealAnim.setDuration(mMaterialExpandDuration); - revealAnim.setStartDelay(mMaterialExpandStagger); - revealAnim.setInterpolator(new LogDecelerateInterpolator(60, 0)); - } if (revealAnim != null) { anim.play(revealAnim); @@ -786,44 +780,6 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList } } - private Animator getFolderIconRevealAnimator(boolean reverse) { - DragLayer parent = (DragLayer) mLauncher.findViewById(R.id.drag_layer); - float scale = parent.getDescendantRectRelativeToSelf(mFolderIcon, mTempRect); - - int centerX = (int) (mTempRect.left + mTempRect.width() * scale / 2); - int centerY = (int) (mTempRect.top + mTempRect.height() * scale / 2); - - float targetRadius = 0; - return getRevealAnimator(reverse, centerX, centerY, targetRadius); - } - - private Animator getFolderRevealAnimator(boolean reverse) { - DragLayer parent = (DragLayer) mLauncher.findViewById(R.id.drag_layer); - float scale = parent.getDescendantRectRelativeToSelf(this, mTempRect); - - int centerX = (int) (mTempRect.left + mTempRect.width() * scale / 2); - int centerY = (int) (mTempRect.top + mTempRect.height() * scale / 2); - - float targetRadius = 0; - return getRevealAnimator(reverse, centerX, centerY, targetRadius); - } - - private Animator getRevealAnimator(boolean reverse, int centerX, int centerY, - float targetRadius) { - View reveal = mLauncher.findViewById(R.id.reveal_fake_page); - int height = reveal.getMeasuredHeight(); - - float startRadius = targetRadius; - float endRadius = height; - - if (reverse) { - endRadius = startRadius; - startRadius = height; - } - return ViewAnimationUtils.createCircularReveal(reveal, centerX, - centerY, startRadius, endRadius); - } - public void beginExternalDrag(ShortcutInfo item) { setupContentForNumItems(getItemCount() + 1); findAndSetEmptyCells(item); @@ -881,14 +837,6 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList oa = LauncherAnimUtils.ofPropertyValuesHolder(this, alpha, translationY); } - oa.addListener(new AnimatorListenerAdapter() { - @Override - public void onAnimationStart(Animator animation) { - if (animate && !mDragController.isDragging()) { - hideFolderOutline(false); - } - } - }); oa.setDuration(mMaterialExpandDuration); oa.setInterpolator(new LogDecelerateInterpolator(60, 0)); anim.play(oa); @@ -899,42 +847,6 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList Animator fakeFolderIconAnim = null; if (animate) { - if (!mDragInProgress) { - reverseRevealAnim = getFolderIconRevealAnimator(true); - reverseRevealAnim.setInterpolator(new DecelerateInterpolator(2f)); - reverseRevealAnim.addListener(new AnimatorListenerAdapter() { - @Override - public void onAnimationEnd(Animator animation) { - View revealView = mLauncher.findViewById(R.id.reveal_fake_page_container); - revealView.setVisibility(View.INVISIBLE); - } - - @Override - public void onAnimationStart(Animator animation) { - View outline = mLauncher.findViewById(R.id.reveal_fake_folder_outline); - outline.setVisibility(View.INVISIBLE); - } - }); - } else { - prepareOutline(); - View revealFakeView = mLauncher.findViewById(R.id.reveal_fake_page); - revealFakeView.setVisibility(View.INVISIBLE); - View outlineView = mLauncher.findViewById(R.id.reveal_fake_folder_outline); - outlineView.setAlpha(1f); - outlineView.setVisibility(View.VISIBLE); - - float baseOutlineTranslationY = outlineView.getTranslationY(); - PropertyValuesHolder outlineTransY = PropertyValuesHolder.ofFloat("translationY", - baseOutlineTranslationY, baseOutlineTranslationY + transY); - - PropertyValuesHolder outlineAlpha = PropertyValuesHolder.ofFloat("alpha", 1f, 0f); - reverseRevealAnim = LauncherAnimUtils.ofPropertyValuesHolder(outlineView, - outlineAlpha, outlineTransY); - - reverseRevealAnim.setDuration(mMaterialExpandDuration); - reverseRevealAnim.setStartDelay(mMaterialExpandStagger); - reverseRevealAnim.setInterpolator(new DecelerateInterpolator(2f)); - } prepareFakeFolderIcon(); float iconTransY = getResources().getInteger(R.integer.folder_icon_translate_y_dist); @@ -952,7 +864,6 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList fakeFolderIconAnim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { - mFolderIcon.setPreviewBackground(-1); mFolderIcon.setAlpha(0); fakeFolderIconView.setVisibility(View.VISIBLE); } @@ -961,7 +872,6 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList public void onAnimationEnd(Animator animation) { fakeFolderIconView.setVisibility(View.INVISIBLE); mFolderIcon.setAlpha(1); - mFolderIcon.setPreviewBackground(R.drawable.folder_bg); View revealView = mLauncher.findViewById(R.id.reveal_fake_page_container); revealView.setVisibility(View.INVISIBLE); @@ -971,7 +881,6 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList View revealView = mLauncher.findViewById(R.id.reveal_fake_page_container); revealView.setVisibility(View.INVISIBLE); mFolderIcon.setAlpha(1); - mFolderIcon.setPreviewBackground(R.drawable.folder_bg); } if (workspaceAnim != null) { @@ -1058,10 +967,6 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList mPreviousTargetCell[0] = -1; mPreviousTargetCell[1] = -1; mOnExitAlarm.cancelAlarm(); - - if (mState != STATE_ANIMATING && !mIsExternalDrag) { - showFolderOutline(true); - } } OnAlarmListener mReorderAlarmListener = new OnAlarmListener() { @@ -1215,10 +1120,6 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList mOnExitAlarm.setAlarm(ON_EXIT_CLOSE_DELAY); } mReorderAlarm.cancelAlarm(); - - if (!mDragController.isDragging()) { - hideFolderOutline(true); - } } public void onDropCompleted(final View target, final DragObject d, @@ -1266,7 +1167,6 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList mSuppressOnAdd = false; if (mState == STATE_OPEN) { - hideFolderOutline(true); mLauncher.hideSearch(); } else if (mState == STATE_SMALL) { mLauncher.showSearch(); @@ -1480,7 +1380,7 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList } private int getFolderHeight() { - int height = getPaddingTop() + getPaddingBottom() + mFolderNameHeight + mFolderLockHeight + int height = getPaddingTop() + getPaddingBottom() + mFolderNameHeight + getContentAreaHeight(); return height; } @@ -1505,6 +1405,8 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList mFolderName.measure(contentAreaWidthSpec, MeasureSpec.makeMeasureSpec( mFolderNameHeight, MeasureSpec.EXACTLY)); } + mFolderNameLockContainer.measure(contentAreaWidthSpec, + MeasureSpec.makeMeasureSpec(mFolderNameHeight,MeasureSpec.EXACTLY)); setMeasuredDimension(width, height); } @@ -1821,81 +1723,6 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList // handle the special cancel cases (when the user quickly picks up and drops an in the folder) private boolean mCancelAnim = false; - private void showFolderOutline(boolean animate) { - final View revealView = mLauncher.findViewById(R.id.reveal_fake_page); - final View outline = mLauncher.findViewById(R.id.reveal_fake_folder_outline); - - if (mHideOutlinesAnimator != null && mHideOutlinesAnimator.isRunning()) { - mHideOutlinesAnimator.cancel(); - } - prepareOutline(); - - if (!animate) { - revealView.setVisibility(View.INVISIBLE); - outline.setVisibility(View.VISIBLE); - return; - } - - mRevealOutlinesAnimator = getFolderRevealAnimator(true); - mRevealOutlinesAnimator.addListener(new AnimatorListenerAdapter() { - @Override - public void onAnimationEnd(Animator animation) { - if (mCancelAnim) { - mCancelAnim = false; - } else { - revealView.setVisibility(View.INVISIBLE); - } - } - - @Override - public void onAnimationStart(Animator animation) { - outline.setAlpha(1f); - outline.setVisibility(View.VISIBLE); - } - }); - - mRevealOutlinesAnimator.start(); - } - - private void hideFolderOutline(boolean animate) { - final View revealView = mLauncher.findViewById(R.id.reveal_fake_page); - final View outline = mLauncher.findViewById(R.id.reveal_fake_folder_outline); - - if (revealView.getVisibility() == View.VISIBLE) { - // Nothing to do here - return; - } - - if (mRevealOutlinesAnimator != null && mRevealOutlinesAnimator.isRunning()) { - mCancelAnim = true; - mRevealOutlinesAnimator.cancel(); - } - - if (!animate) { - revealView.setVisibility(View.VISIBLE); - outline.setVisibility(View.INVISIBLE); - return; - } - - mHideOutlinesAnimator = getFolderRevealAnimator(false); - mHideOutlinesAnimator.addListener(new AnimatorListenerAdapter() { - @Override - public void onAnimationStart(Animator animation) { - revealView.setVisibility(View.VISIBLE); - } - - @Override - public void onAnimationEnd(Animator animation) { - if (mCancelAnim) { - mCancelAnim = false; - } else { - outline.setVisibility(View.INVISIBLE); - } - } - }); - - mHideOutlinesAnimator.start(); - } @Override public void getHitRectRelativeToDragLayer(Rect outRect) { diff --git a/src/com/android/launcher3/FolderIcon.java b/src/com/android/launcher3/FolderIcon.java index 03bb1e34a..214ec3241 100644 --- a/src/com/android/launcher3/FolderIcon.java +++ b/src/com/android/launcher3/FolderIcon.java @@ -69,7 +69,7 @@ public class FolderIcon extends FrameLayout implements FolderListener { private static final float INNER_RING_GROWTH_FACTOR = 0.0f; // The degree to which the outer ring is scaled in its natural state - private static final float OUTER_RING_GROWTH_FACTOR = 0.15f; + private static final float OUTER_RING_GROWTH_FACTOR = 0.1f; // The amount of vertical spread between items in the stack [0...1] private static final float PERSPECTIVE_SHIFT_FACTOR = 0.18f; @@ -183,11 +183,13 @@ public class FolderIcon extends FrameLayout implements FolderListener { icon.setDrawingCacheEnabled(true); // get dimen for the icon size - // ratio: iconsize = 3*padding + 2*small_icon_size - // padding*6.5 = small_icon_size - // so padding = folderIconSize / 16 - int padding = grid.iconSizePx / 16; - int smallIconSize = (int) (padding * 6.5); + // padding is equal to 1/8 of icon size + // padding gets used at start and end accounting for 2/8 + // small icons are separated by 1/2 padding + // Total padding equals 2.5/8 leaving 5.5/8 for icons + // 5.5/8 remaining, divided by 2 equals 2.75 for each small icon + int padding = grid.iconSizePx / 8; + int smallIconSize = (int) (padding * 2.75); for (int i = NUM_ITEMS_IN_PREVIEW; i >= 0; i--) { ImageView appIcon = null; @@ -288,9 +290,6 @@ public class FolderIcon extends FrameLayout implements FolderListener { mAcceptAnimator.addUpdateListener(new AnimatorUpdateListener() { public void onAnimationUpdate(ValueAnimator animation) { float percent = (Float) animation.getAnimatedValue(); - if (mFolderIcon != null) { - percent = 1f; - } mOuterRingSize = (1 + percent * OUTER_RING_GROWTH_FACTOR) * previewSize; mInnerRingSize = (1 + percent * INNER_RING_GROWTH_FACTOR) * previewSize; if (mCellLayout != null) { @@ -298,14 +297,6 @@ public class FolderIcon extends FrameLayout implements FolderListener { } } }); - mAcceptAnimator.addListener(new AnimatorListenerAdapter() { - @Override - public void onAnimationStart(Animator animation) { - if (mFolderIcon != null) { - mFolderIcon.mPreviewBackground.setBackground(null); - } - } - }); mAcceptAnimator.start(); } @@ -320,9 +311,6 @@ public class FolderIcon extends FrameLayout implements FolderListener { mNeutralAnimator.addUpdateListener(new AnimatorUpdateListener() { public void onAnimationUpdate(ValueAnimator animation) { float percent = (Float) animation.getAnimatedValue(); - if (mFolderIcon != null) { - percent = 0f; - } mOuterRingSize = (1 + (1 - percent) * OUTER_RING_GROWTH_FACTOR) * previewSize; mInnerRingSize = (1 + (1 - percent) * INNER_RING_GROWTH_FACTOR) * previewSize; if (mCellLayout != null) { @@ -337,7 +325,7 @@ public class FolderIcon extends FrameLayout implements FolderListener { mCellLayout.hideFolderAccept(FolderRingAnimator.this); } if (mFolderIcon != null) { - mFolderIcon.mPreviewBackground.setBackgroundResource(R.drawable.folder_bg); + mFolderIcon.mPreviewBackground.setVisibility(View.VISIBLE); } } }); @@ -410,14 +398,6 @@ public class FolderIcon extends FrameLayout implements FolderListener { mInfo.add(item); } - public void setPreviewBackground(int res) { - if (res < 0) { - mPreviewBackground.setBackground(null); - } else { - mPreviewBackground.setBackgroundResource(res); - } - } - public void onDragEnter(Object dragInfo) { if (mFolder.isDestroyed() || !willAcceptItem((ItemInfo) dragInfo)) return; CellLayout.LayoutParams lp = (CellLayout.LayoutParams) getLayoutParams(); @@ -456,7 +436,14 @@ public class FolderIcon extends FrameLayout implements FolderListener { item = (ShortcutInfo) mDragInfo; } mFolder.beginExternalDrag(item); - mLauncher.openFolder(FolderIcon.this); + mFolderRingAnimator.mCellLayout.hideFolderAccept(mFolderRingAnimator); + + int[] folderTouchXY = new int[2]; + mFolder.getLocationOnScreen(folderTouchXY); + int[] folderTouchXYOffset = {folderTouchXY[0] + mFolder.getWidth() / 2, + folderTouchXY[1] + mFolder.getHeight() / 2}; + + mLauncher.openFolder(FolderIcon.this, folderTouchXYOffset); } }; diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index a9ea9c75f..c2debec43 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -3134,6 +3134,11 @@ public class Launcher extends Activity final FolderInfo info = folderIcon.getFolderInfo(); Folder openFolder = mWorkspace.getFolderForTag(info); + int[] folderTouchXY = new int[2]; + v.getLocationOnScreen(folderTouchXY); + int[] folderTouchXYOffset = {folderTouchXY[0] + v.getWidth() / 2, + folderTouchXY[1] + v.getHeight() / 2}; + // If the folder info reports that the associated folder is open, then verify that // it is actually opened. There have been a few instances where this gets out of sync. if (info.opened && openFolder == null) { @@ -3146,7 +3151,7 @@ public class Launcher extends Activity // Close any open folder closeFolder(); // Open the requested folder - openFolder(folderIcon); + openFolder(folderIcon, folderTouchXYOffset); } else { // Find the open folder... int folderScreen; @@ -3158,7 +3163,7 @@ public class Launcher extends Activity // Close any folder open on the current screen closeFolder(); // Pull the folder onto this screen - openFolder(folderIcon); + openFolder(folderIcon, folderTouchXYOffset); } } } @@ -3447,7 +3452,7 @@ public class Launcher extends Activity * * @param folderInfo The FolderInfo describing the folder to open. */ - public void openFolder(FolderIcon folderIcon) { + public void openFolder(FolderIcon folderIcon, int[] folderTouch) { Folder folder = folderIcon.getFolder(); FolderInfo info = folder.mInfo; @@ -3471,7 +3476,7 @@ public class Launcher extends Activity Log.w(TAG, "Opening folder (" + folder + ") which already has a parent (" + folder.getParent() + ")."); } - folder.animateOpen(getWorkspace()); + folder.animateOpen(getWorkspace(), folderTouch); // Notify the accessibility manager that this folder "window" has appeared and occluded // the workspace items -- cgit v1.2.3