summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorWinson Chung <winsonc@google.com>2010-12-21 11:31:54 -0800
committerWinson Chung <winsonc@google.com>2010-12-21 16:04:02 -0800
commit59e1f9a07eef87b1d287956d21b8d9c5b27faf9c (patch)
treed37b7b49e34a28608ecffce7b24d92ef927b8b53 /src
parent577d017732abf9969e9a5c1b6aa3ffb5b8fdae7f (diff)
downloadandroid_packages_apps_Trebuchet-59e1f9a07eef87b1d287956d21b8d9c5b27faf9c.tar.gz
android_packages_apps_Trebuchet-59e1f9a07eef87b1d287956d21b8d9c5b27faf9c.tar.bz2
android_packages_apps_Trebuchet-59e1f9a07eef87b1d287956d21b8d9c5b27faf9c.zip
Adding fade when dragging items outside of the customization tray.
Change-Id: Ie8dad00bc0278053707f81d948528929e6bb6f5c
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher2/AllAppsPagedView.java4
-rw-r--r--src/com/android/launcher2/ApplicationInfoDropTarget.java14
-rw-r--r--src/com/android/launcher2/BubbleTextView.java11
-rw-r--r--src/com/android/launcher2/CustomizePagedView.java31
-rw-r--r--src/com/android/launcher2/DeleteZone.java10
-rw-r--r--src/com/android/launcher2/PagedViewIcon.java22
-rw-r--r--src/com/android/launcher2/PagedViewWidget.java60
7 files changed, 123 insertions, 29 deletions
diff --git a/src/com/android/launcher2/AllAppsPagedView.java b/src/com/android/launcher2/AllAppsPagedView.java
index caa140605..a424bc61c 100644
--- a/src/com/android/launcher2/AllAppsPagedView.java
+++ b/src/com/android/launcher2/AllAppsPagedView.java
@@ -263,6 +263,10 @@ public class AllAppsPagedView extends PagedViewWithDraggableItems implements All
// Toggle the selection on the dragged app
Checkable checkable = (Checkable) v;
+
+ // Note: we toggle the checkable state to actually cause an alpha fade for the duration
+ // of the drag of the item. (The fade-in will occur when all checked states are
+ // disabled when dragging ends)
checkable.toggle();
}
diff --git a/src/com/android/launcher2/ApplicationInfoDropTarget.java b/src/com/android/launcher2/ApplicationInfoDropTarget.java
index 9d421c68a..f9440227a 100644
--- a/src/com/android/launcher2/ApplicationInfoDropTarget.java
+++ b/src/com/android/launcher2/ApplicationInfoDropTarget.java
@@ -51,11 +51,15 @@ public class ApplicationInfoDropTarget extends IconDropTarget {
int colour = getContext().getResources().getColor(R.color.app_info_filter);
mHoverPaint.setColorFilter(new PorterDuffColorFilter(colour, PorterDuff.Mode.SRC_ATOP));
- // For the application info drop target, we just ignore the left padding since we don't want
- // to overlap with the delete zone padding
- int tb = getResources().getDimensionPixelSize(R.dimen.delete_zone_vertical_drag_padding);
- int lr = getResources().getDimensionPixelSize(R.dimen.delete_zone_horizontal_drag_padding);
- setDragPadding(tb, lr, tb, 0);
+ if (LauncherApplication.isScreenXLarge()) {
+ // For the application info drop target, we just ignore the left padding since we don't want
+ // to overlap with the delete zone padding
+ int tb = getResources().getDimensionPixelSize(
+ R.dimen.delete_zone_vertical_drag_padding);
+ int lr = getResources().getDimensionPixelSize(
+ R.dimen.delete_zone_horizontal_drag_padding);
+ setDragPadding(tb, lr, tb, 0);
+ }
}
public boolean acceptDrop(DragSource source, int x, int y, int xOffset, int yOffset,
diff --git a/src/com/android/launcher2/BubbleTextView.java b/src/com/android/launcher2/BubbleTextView.java
index 6e2a58b9e..2d0492443 100644
--- a/src/com/android/launcher2/BubbleTextView.java
+++ b/src/com/android/launcher2/BubbleTextView.java
@@ -88,13 +88,10 @@ public class BubbleTextView extends CacheableTextView {
mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mPaint.setColor(bubbleColor);
mBubbleColorAlpha = Color.alpha(bubbleColor) / 255.0f;
- mFocusedOutlineColor =
- getResources().getColor(R.color.workspace_item_focused_outline_color);
- mFocusedGlowColor = getResources().getColor(R.color.workspace_item_focused_glow_color);
- mPressedOutlineColor =
- getResources().getColor(R.color.workspace_item_pressed_outline_color);
- mPressedGlowColor =
- getResources().getColor(R.color.workspace_item_pressed_glow_color);
+ mFocusedOutlineColor = res.getColor(R.color.workspace_item_focused_outline_color);
+ mFocusedGlowColor = res.getColor(R.color.workspace_item_focused_glow_color);
+ mPressedOutlineColor = res.getColor(R.color.workspace_item_pressed_outline_color);
+ mPressedGlowColor = res.getColor(R.color.workspace_item_pressed_glow_color);
}
protected int getCacheTopPadding() {
diff --git a/src/com/android/launcher2/CustomizePagedView.java b/src/com/android/launcher2/CustomizePagedView.java
index 60f1c90c3..ec9d52e4f 100644
--- a/src/com/android/launcher2/CustomizePagedView.java
+++ b/src/com/android/launcher2/CustomizePagedView.java
@@ -54,6 +54,7 @@ import android.view.MenuItem;
import android.view.View;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.Interpolator;
+import android.widget.Checkable;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
@@ -327,6 +328,7 @@ public class CustomizePagedView extends PagedViewWithDraggableItems
@Override
public void onDropCompleted(View target, boolean success) {
+ resetCheckedGrandchildren();
mLauncher.getWorkspace().onDragStopped();
}
@@ -498,6 +500,7 @@ public class CustomizePagedView extends PagedViewWithDraggableItems
}
super.beginDragging(v);
+ boolean result = false;
switch (mCustomizationType) {
case WidgetCustomization: {
// Get the widget preview as the drag representation
@@ -515,7 +518,8 @@ public class CustomizePagedView extends PagedViewWithDraggableItems
mDragController.startDrag(
i, b, this, createWidgetInfo, DragController.DRAG_ACTION_COPY, null);
b.recycle();
- return true;
+ result = true;
+ break;
}
case ShortcutCustomization: {
// get icon (top compound drawable, index is 1)
@@ -528,7 +532,8 @@ public class CustomizePagedView extends PagedViewWithDraggableItems
mDragController.startDrag(v, b, this, createItemInfo, DragController.DRAG_ACTION_COPY,
null);
b.recycle();
- return true;
+ result = true;
+ break;
}
case ApplicationCustomization: {
// Pick up the application for dropping
@@ -542,10 +547,28 @@ public class CustomizePagedView extends PagedViewWithDraggableItems
mLauncher.getWorkspace().onDragStartedWithItemSpans(1, 1, b);
mDragController.startDrag(v, b, this, app, DragController.DRAG_ACTION_COPY, null);
b.recycle();
- return true;
+ result = true;
+ break;
}
}
- return false;
+
+ // We toggle the checked state _after_ we create the view for the drag in case toggling the
+ // checked state changes the view's look
+ if (v instanceof Checkable) {
+ // In preparation for drag, we always reset the checked grand children regardless of
+ // what choice mode we are in
+ resetCheckedGrandchildren();
+
+ // Toggle the selection on the dragged app
+ Checkable checkable = (Checkable) v;
+
+ // Note: we toggle the checkable state to actually cause an alpha fade for the duration
+ // of the drag of the item. (The fade-in will occur when all checked states are
+ // disabled when dragging ends)
+ checkable.toggle();
+ }
+
+ return result;
}
/**
diff --git a/src/com/android/launcher2/DeleteZone.java b/src/com/android/launcher2/DeleteZone.java
index 4bed84c5c..98d2b8366 100644
--- a/src/com/android/launcher2/DeleteZone.java
+++ b/src/com/android/launcher2/DeleteZone.java
@@ -70,9 +70,13 @@ public class DeleteZone extends IconDropTarget {
mOrientation = a.getInt(R.styleable.DeleteZone_direction, ORIENTATION_HORIZONTAL);
a.recycle();
- int tb = getResources().getDimensionPixelSize(R.dimen.delete_zone_vertical_drag_padding);
- int lr = getResources().getDimensionPixelSize(R.dimen.delete_zone_horizontal_drag_padding);
- setDragPadding(tb, lr, tb, lr);
+ if (LauncherApplication.isScreenXLarge()) {
+ int tb = getResources().getDimensionPixelSize(
+ R.dimen.delete_zone_vertical_drag_padding);
+ int lr = getResources().getDimensionPixelSize(
+ R.dimen.delete_zone_horizontal_drag_padding);
+ setDragPadding(tb, lr, tb, lr);
+ }
}
@Override
diff --git a/src/com/android/launcher2/PagedViewIcon.java b/src/com/android/launcher2/PagedViewIcon.java
index d91daf918..e4049eb19 100644
--- a/src/com/android/launcher2/PagedViewIcon.java
+++ b/src/com/android/launcher2/PagedViewIcon.java
@@ -20,6 +20,7 @@ import android.animation.ObjectAnimator;
import android.content.Context;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
+import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.Canvas;
@@ -57,9 +58,9 @@ public class PagedViewIcon extends CacheableTextView implements Checkable {
private boolean mIsChecked;
private ObjectAnimator mCheckedAlphaAnimator;
- private final static float sCheckedAlpha = 0.4f;
- private final static int sCheckedFadeInDuration = 150;
- private final static int sCheckedFadeOutDuration = 200;
+ private float mCheckedAlpha = 1.0f;
+ private int mCheckedFadeInDuration;
+ private int mCheckedFadeOutDuration;
// Highlight colors
private int mHoloBlurColor;
@@ -116,6 +117,15 @@ public class PagedViewIcon extends CacheableTextView implements Checkable {
sHolographicOutlineHelper = new HolographicOutlineHelper();
}
+ // Set up fade in/out constants
+ final Resources r = context.getResources();
+ final int alpha = r.getInteger(R.integer.icon_allAppsCustomizeFadeAlpha);
+ if (alpha > 0) {
+ mCheckedAlpha = r.getInteger(R.integer.icon_allAppsCustomizeFadeAlpha) / 256.0f;
+ mCheckedFadeInDuration = r.getInteger(R.integer.icon_allAppsCustomizeFadeInTime);
+ mCheckedFadeOutDuration = r.getInteger(R.integer.icon_allAppsCustomizeFadeOutTime);
+ }
+
setFocusable(true);
setBackgroundDrawable(null);
}
@@ -230,11 +240,11 @@ public class PagedViewIcon extends CacheableTextView implements Checkable {
float alpha;
int duration;
if (mIsChecked) {
- alpha = sCheckedAlpha;
- duration = sCheckedFadeInDuration;
+ alpha = mCheckedAlpha;
+ duration = mCheckedFadeInDuration;
} else {
alpha = 1.0f;
- duration = sCheckedFadeOutDuration;
+ duration = mCheckedFadeOutDuration;
}
// Initialize the animator
diff --git a/src/com/android/launcher2/PagedViewWidget.java b/src/com/android/launcher2/PagedViewWidget.java
index 5f5844f44..8c729b1ca 100644
--- a/src/com/android/launcher2/PagedViewWidget.java
+++ b/src/com/android/launcher2/PagedViewWidget.java
@@ -16,34 +16,34 @@
package com.android.launcher2;
+import android.animation.ObjectAnimator;
import android.appwidget.AppWidgetProviderInfo;
import android.content.Context;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
+import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
-import android.graphics.PorterDuffXfermode;
import android.graphics.PorterDuff.Mode;
-import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Message;
import android.util.AttributeSet;
import android.view.MotionEvent;
+import android.widget.Checkable;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.android.launcher.R;
-import com.android.launcher2.PagedView.PagedViewIconCache;
/**
* The linear layout used strictly for the widget/wallpaper tab of the customization tray
*/
-public class PagedViewWidget extends LinearLayout {
+public class PagedViewWidget extends LinearLayout implements Checkable {
static final String TAG = "PagedViewWidgetLayout";
private final Paint mPaint = new Paint();
@@ -59,6 +59,12 @@ public class PagedViewWidget extends LinearLayout {
private int mHoloBlurColor;
private int mHoloOutlineColor;
+ private boolean mIsChecked;
+ private ObjectAnimator mCheckedAlphaAnimator;
+ private float mCheckedAlpha = 1.0f;
+ private int mCheckedFadeInDuration;
+ private int mCheckedFadeOutDuration;
+
private static final HandlerThread sWorkerThread = new HandlerThread("pagedviewwidget-helper");
static {
sWorkerThread.start();
@@ -118,6 +124,15 @@ public class PagedViewWidget extends LinearLayout {
sHolographicOutlineHelper = new HolographicOutlineHelper();
}
+ // Set up fade in/out constants
+ final Resources r = context.getResources();
+ final int alpha = r.getInteger(R.integer.icon_allAppsCustomizeFadeAlpha);
+ if (alpha > 0) {
+ mCheckedAlpha = r.getInteger(R.integer.icon_allAppsCustomizeFadeAlpha) / 256.0f;
+ mCheckedFadeInDuration = r.getInteger(R.integer.icon_allAppsCustomizeFadeInTime);
+ mCheckedFadeOutDuration = r.getInteger(R.integer.icon_allAppsCustomizeFadeOutTime);
+ }
+
setFocusable(true);
setWillNotDraw(false);
setClipToPadding(false);
@@ -219,4 +234,41 @@ public class PagedViewWidget extends LinearLayout {
super.onDetachedFromWindow();
sWorker.removeMessages(MESSAGE_CREATE_HOLOGRAPHIC_OUTLINE, this);
}
+
+ @Override
+ public void setChecked(boolean checked) {
+ if (mIsChecked != checked) {
+ mIsChecked = checked;
+
+ float alpha;
+ int duration;
+ if (mIsChecked) {
+ alpha = mCheckedAlpha;
+ duration = mCheckedFadeInDuration;
+ } else {
+ alpha = 1.0f;
+ duration = mCheckedFadeOutDuration;
+ }
+
+ // Initialize the animator
+ if (mCheckedAlphaAnimator != null) {
+ mCheckedAlphaAnimator.cancel();
+ }
+ mCheckedAlphaAnimator = ObjectAnimator.ofFloat(this, "alpha", getAlpha(), alpha);
+ mCheckedAlphaAnimator.setDuration(duration);
+ mCheckedAlphaAnimator.start();
+
+ invalidate();
+ }
+ }
+
+ @Override
+ public boolean isChecked() {
+ return mIsChecked;
+ }
+
+ @Override
+ public void toggle() {
+ setChecked(!mIsChecked);
+ }
}