diff --git a/src/com/android/launcher2/AppsCustomizePagedView.java b/src/com/android/launcher2/AppsCustomizePagedView.java index 691228d3a6..eac3c47b49 100644 --- a/src/com/android/launcher2/AppsCustomizePagedView.java +++ b/src/com/android/launcher2/AppsCustomizePagedView.java @@ -166,7 +166,8 @@ class AppsCustomizeAsyncTask extends AsyncTask mApps; @@ -593,6 +595,9 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen if (!super.beginDragging(v)) return false; + // Reset the alpha on the dragged icon before we drag + resetDrawableState(); + // Go into spring loaded mode (must happen before we startDrag()) mLauncher.enterSpringLoadedDragMode(); @@ -751,7 +756,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen ApplicationInfo info = mApps.get(i); PagedViewIcon icon = (PagedViewIcon) mLayoutInflater.inflate( R.layout.apps_customize_application, layout, false); - icon.applyFromApplicationInfo(info, true); + icon.applyFromApplicationInfo(info, true, this); icon.setOnClickListener(this); icon.setOnLongClickListener(this); icon.setOnTouchListener(this); @@ -1427,6 +1432,22 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen cancelAllTasks(); } + @Override + public void iconPressed(PagedViewIcon icon) { + // Reset the previously pressed icon and store a reference to the pressed icon so that + // we can reset it on return to Launcher (in Launcher.onResume()) + if (mPressedIcon != null) { + mPressedIcon.resetDrawableState(); + } + mPressedIcon = icon; + } + + public void resetDrawableState() { + if (mPressedIcon != null) { + mPressedIcon.resetDrawableState(); + mPressedIcon = null; + } + } /* * We load an extra page on each side to prevent flashes from scrolling and loading of the diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java index 2b91302629..6ac9fe213f 100644 --- a/src/com/android/launcher2/Launcher.java +++ b/src/com/android/launcher2/Launcher.java @@ -561,9 +561,17 @@ public final class Launcher extends Activity mRestoring = false; mOnResumeNeedsLoad = false; } + + // Reset the pressed state of icons that were locked in the press state while activities + // were launching if (mWaitingForResume != null) { + // Resets the previous workspace icon press state mWaitingForResume.setStayPressed(false); } + if (mAppsCustomizeContent != null) { + // Resets the previous all apps icon press state + mAppsCustomizeContent.resetDrawableState(); + } // When we resume Launcher, a different Activity might be responsible for the app // market intent, so refresh the icon updateAppMarketIcon(); diff --git a/src/com/android/launcher2/PagedViewIcon.java b/src/com/android/launcher2/PagedViewIcon.java index 548b394588..00f9321c65 100644 --- a/src/com/android/launcher2/PagedViewIcon.java +++ b/src/com/android/launcher2/PagedViewIcon.java @@ -26,7 +26,16 @@ import android.widget.TextView; * drawables on the top). */ public class PagedViewIcon extends TextView { + /** A simple callback interface to allow a PagedViewIcon to notify when it has been pressed */ + public static interface PressedCallback { + void iconPressed(PagedViewIcon icon); + } + private static final String TAG = "PagedViewIcon"; + private static final float PRESS_ALPHA = 0.4f; + + private PagedViewIcon.PressedCallback mPressedCallback; + private boolean mResetDrawableState = false; private Bitmap mIcon; @@ -42,15 +51,38 @@ public class PagedViewIcon extends TextView { super(context, attrs, defStyle); } - public void applyFromApplicationInfo(ApplicationInfo info, boolean scaleUp) { + public void applyFromApplicationInfo(ApplicationInfo info, boolean scaleUp, + PagedViewIcon.PressedCallback cb) { mIcon = info.iconBitmap; + mPressedCallback = cb; setCompoundDrawablesWithIntrinsicBounds(null, new FastBitmapDrawable(mIcon), null, null); setText(info.title); setTag(info); } + public void resetDrawableState() { + mResetDrawableState = true; + post(new Runnable() { + @Override + public void run() { + refreshDrawableState(); + } + }); + } + protected void drawableStateChanged() { - setAlpha(isPressed() ? 0.5f : 1f); super.drawableStateChanged(); + + // We keep in the pressed state until resetDrawableState() is called to reset the press + // feedback + if (isPressed()) { + setAlpha(PRESS_ALPHA); + if (mPressedCallback != null) { + mPressedCallback.iconPressed(this); + } + } else if (mResetDrawableState) { + setAlpha(1f); + mResetDrawableState = false; + } } } diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java index 4ecc1a528e..ab78a8cc5b 100644 --- a/src/com/android/launcher2/Workspace.java +++ b/src/com/android/launcher2/Workspace.java @@ -231,7 +231,7 @@ public class Workspace extends SmoothPagedView private float[] mNewBackgroundAlphaMultipliers; private float[] mNewAlphas; private float[] mNewRotationYs; - private float mTransitionProgress; + private float mTransitionProgress = 1f; /** * Used to inflate the Workspace from XML.