summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher2
diff options
context:
space:
mode:
authorWinson Chung <winsonc@google.com>2010-12-20 11:36:33 -0800
committerWinson Chung <winsonc@google.com>2010-12-20 14:44:38 -0800
commitbe5212be73fd00423e5b5487ad2911edb8c38c49 (patch)
tree7ea1ff39349e261902cec415506c44f7f9b4145a /src/com/android/launcher2
parent047379aa61b4719ab38ce595f23732e8f3b1b8e1 (diff)
downloadandroid_packages_apps_Trebuchet-be5212be73fd00423e5b5487ad2911edb8c38c49.tar.gz
android_packages_apps_Trebuchet-be5212be73fd00423e5b5487ad2911edb8c38c49.tar.bz2
android_packages_apps_Trebuchet-be5212be73fd00423e5b5487ad2911edb8c38c49.zip
Fixing drop target padding for the trash bin and all apps.
Change-Id: I65e0af4b52ce26037c77b8120d51226be27efb90
Diffstat (limited to 'src/com/android/launcher2')
-rw-r--r--src/com/android/launcher2/ApplicationInfoDropTarget.java7
-rw-r--r--src/com/android/launcher2/DeleteZone.java7
-rw-r--r--src/com/android/launcher2/IconDropTarget.java29
3 files changed, 28 insertions, 15 deletions
diff --git a/src/com/android/launcher2/ApplicationInfoDropTarget.java b/src/com/android/launcher2/ApplicationInfoDropTarget.java
index 2ee350195..7c81c1a25 100644
--- a/src/com/android/launcher2/ApplicationInfoDropTarget.java
+++ b/src/com/android/launcher2/ApplicationInfoDropTarget.java
@@ -26,6 +26,7 @@ import android.content.ComponentName;
import android.content.Context;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
+import android.graphics.Rect;
import android.util.AttributeSet;
import android.view.View;
@@ -51,6 +52,12 @@ public class ApplicationInfoDropTarget extends IconDropTarget {
// Set the hover paint colour
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);
}
public boolean acceptDrop(DragSource source, int x, int y, int xOffset, int yOffset,
diff --git a/src/com/android/launcher2/DeleteZone.java b/src/com/android/launcher2/DeleteZone.java
index b044ea807..773bc6b7d 100644
--- a/src/com/android/launcher2/DeleteZone.java
+++ b/src/com/android/launcher2/DeleteZone.java
@@ -59,15 +59,16 @@ public class DeleteZone extends IconDropTarget {
public DeleteZone(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
- mOuterDragPadding = getResources().getDimensionPixelSize(R.dimen.delete_zone_size);
- mInnerDragPadding = getResources().getDimensionPixelSize(R.dimen.delete_zone_padding);
-
final int srcColor = context.getResources().getColor(R.color.delete_color_filter);
mHoverPaint.setColorFilter(new PorterDuffColorFilter(srcColor, PorterDuff.Mode.SRC_ATOP));
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.DeleteZone, defStyle, 0);
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);
}
@Override
diff --git a/src/com/android/launcher2/IconDropTarget.java b/src/com/android/launcher2/IconDropTarget.java
index 5b375c3ff..ec08c1e81 100644
--- a/src/com/android/launcher2/IconDropTarget.java
+++ b/src/com/android/launcher2/IconDropTarget.java
@@ -16,18 +16,17 @@
package com.android.launcher2;
-import android.content.ComponentName;
+import com.android.launcher.R;
+
import android.content.Context;
+import android.graphics.Canvas;
+import android.graphics.Color;
import android.graphics.Paint;
-import android.graphics.PorterDuff;
-import android.graphics.PorterDuffColorFilter;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
-import com.android.launcher.R;
-
/**
* Implements a DropTarget which allows applications to be dropped on it,
* in order to launch the application info for that app.
@@ -51,9 +50,8 @@ public class IconDropTarget extends ImageView implements DropTarget, DragControl
/** The paint applied to the drag view on hover */
protected final Paint mHoverPaint = new Paint();
- /** Drag zone padding */
- protected int mInnerDragPadding;
- protected int mOuterDragPadding;
+ /** Drag zone padding [T, R, B, L] */
+ protected final int mDragPadding[] = new int[4];
public IconDropTarget(Context context, AttributeSet attrs) {
this(context, attrs, 0);
@@ -64,6 +62,13 @@ public class IconDropTarget extends ImageView implements DropTarget, DragControl
mDragAndDropEnabled = true;
}
+ protected void setDragPadding(int t, int r, int b, int l) {
+ mDragPadding[0] = t;
+ mDragPadding[1] = r;
+ mDragPadding[2] = b;
+ mDragPadding[3] = l;
+ }
+
void setLauncher(Launcher launcher) {
mLauncher = launcher;
}
@@ -121,10 +126,10 @@ public class IconDropTarget extends ImageView implements DropTarget, DragControl
public void getHitRect(Rect outRect) {
super.getHitRect(outRect);
if (LauncherApplication.isScreenXLarge()) {
- outRect.top -= mOuterDragPadding;
- outRect.left -= mInnerDragPadding;
- outRect.bottom += mOuterDragPadding;
- outRect.right += mOuterDragPadding;
+ outRect.top -= mDragPadding[0];
+ outRect.right += mDragPadding[1];
+ outRect.bottom += mDragPadding[2];
+ outRect.left -= mDragPadding[3];
}
}