Merge "Should be getting launcher icon DPI from ActivityManager."
diff --git a/src/com/android/launcher2/AppsCustomizePagedView.java b/src/com/android/launcher2/AppsCustomizePagedView.java
index 691228d..eac3c47 100644
--- a/src/com/android/launcher2/AppsCustomizePagedView.java
+++ b/src/com/android/launcher2/AppsCustomizePagedView.java
@@ -166,7 +166,8 @@
* The Apps/Customize page that displays all the applications, widgets, and shortcuts.
*/
public class AppsCustomizePagedView extends PagedViewWithDraggableItems implements
- AllAppsView, View.OnClickListener, View.OnKeyListener, DragSource {
+ AllAppsView, View.OnClickListener, View.OnKeyListener, DragSource,
+ PagedViewIcon.PressedCallback {
static final String LOG_TAG = "AppsCustomizePagedView";
/**
@@ -185,6 +186,7 @@
// Save and Restore
private int mSaveInstanceStateItemIndex = -1;
+ private PagedViewIcon mPressedIcon;
// Content
private ArrayList<ApplicationInfo> mApps;
@@ -593,6 +595,9 @@
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 @@
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 @@
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 2b91302..6ac9fe2 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -561,9 +561,17 @@
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/PagedView.java b/src/com/android/launcher2/PagedView.java
index 903169f..afee8b0 100644
--- a/src/com/android/launcher2/PagedView.java
+++ b/src/com/android/launcher2/PagedView.java
@@ -341,12 +341,10 @@
// a method that subclasses can override to add behavior
protected void onPageBeginMoving() {
- showScrollingIndicator(false);
}
// a method that subclasses can override to add behavior
protected void onPageEndMoving() {
- hideScrollingIndicator(false);
}
/**
diff --git a/src/com/android/launcher2/PagedViewIcon.java b/src/com/android/launcher2/PagedViewIcon.java
index 548b394..00f9321 100644
--- a/src/com/android/launcher2/PagedViewIcon.java
+++ b/src/com/android/launcher2/PagedViewIcon.java
@@ -26,7 +26,16 @@
* 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 @@
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/PagedViewWithDraggableItems.java b/src/com/android/launcher2/PagedViewWithDraggableItems.java
index 287a065..a047970 100644
--- a/src/com/android/launcher2/PagedViewWithDraggableItems.java
+++ b/src/com/android/launcher2/PagedViewWithDraggableItems.java
@@ -165,4 +165,12 @@
cancelDragging();
super.onDetachedFromWindow();
}
+
+ /** Show the scrolling indicators when we move the page */
+ protected void onPageBeginMoving() {
+ showScrollingIndicator(false);
+ }
+ protected void onPageEndMoving() {
+ hideScrollingIndicator(false);
+ }
}
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index 4ecc1a5..8d11aa7 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -231,7 +231,7 @@
private float[] mNewBackgroundAlphaMultipliers;
private float[] mNewAlphas;
private float[] mNewRotationYs;
- private float mTransitionProgress;
+ private float mTransitionProgress = 1f;
/**
* Used to inflate the Workspace from XML.
@@ -678,6 +678,9 @@
if (LauncherApplication.isScreenLarge()) {
showOutlines();
}
+
+ // Show the scroll indicator as you pan the page
+ showScrollingIndicator(false);
}
protected void onPageEndMoving() {
@@ -701,6 +704,11 @@
if (LauncherApplication.isScreenLarge()) {
hideOutlines();
}
+
+ // Hide the scroll indicator as you pan the page
+ if (!mDragController.isDragging()) {
+ hideScrollingIndicator(false);
+ }
}
mOverScrollMaxBackgroundAlpha = 0.0f;
mOverScrollPageIndex = -1;
@@ -1928,6 +1936,9 @@
mDragController.startDrag(b, dragLayerX, dragLayerY, source, child.getTag(),
DragController.DRAG_ACTION_MOVE, dragVisualizeOffset, dragRect);
b.recycle();
+
+ // Show the scrolling indicator when you pick up an item
+ showScrollingIndicator(false);
}
void addApplicationShortcut(ShortcutInfo info, CellLayout target, long container, int screen,
@@ -3118,6 +3129,9 @@
}
mDragOutline = null;
mDragInfo = null;
+
+ // Hide the scrolling indicator after you pick up an item
+ hideScrollingIndicator(false);
}
public boolean isDropEnabled() {