summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFabrice Di Meglio <fdimeglio@google.com>2013-02-06 15:40:46 -0800
committerFabrice Di Meglio <fdimeglio@google.com>2013-02-06 15:40:46 -0800
commitd6a33c6f348d1316e0fdc519eda43468fcdcbfe7 (patch)
tree1822780bddc418eebb482f262709f8a4c01ed151 /src
parent892d023c548a5e49b67b4c81ff1e3e9d02004e6e (diff)
downloadandroid_packages_apps_Trebuchet-d6a33c6f348d1316e0fdc519eda43468fcdcbfe7.tar.gz
android_packages_apps_Trebuchet-d6a33c6f348d1316e0fdc519eda43468fcdcbfe7.tar.bz2
android_packages_apps_Trebuchet-d6a33c6f348d1316e0fdc519eda43468fcdcbfe7.zip
Fix Launcher drop targets for App remove / uninstall / info
- make the code aware of the layout direction - use start drawables - fix animation drop rect Change-Id: I35f01b9079aef418c0a22b39e32344c7bf5a0660
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher2/ButtonDropTarget.java37
-rw-r--r--src/com/android/launcher2/DeleteDropTarget.java4
2 files changed, 30 insertions, 11 deletions
diff --git a/src/com/android/launcher2/ButtonDropTarget.java b/src/com/android/launcher2/ButtonDropTarget.java
index 1c9fa5f95..ff0813add 100644
--- a/src/com/android/launcher2/ButtonDropTarget.java
+++ b/src/com/android/launcher2/ButtonDropTarget.java
@@ -22,6 +22,7 @@ import android.graphics.PointF;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
+import android.view.View;
import android.widget.TextView;
import com.android.launcher.R;
@@ -70,7 +71,7 @@ public class ButtonDropTarget extends TextView implements DropTarget, DragContro
}
protected Drawable getCurrentDrawable() {
- Drawable[] drawables = getCompoundDrawables();
+ Drawable[] drawables = getCompoundDrawablesRelative();
for (int i = 0; i < drawables.length; ++i) {
if (drawables[i] != null) {
return drawables[i];
@@ -116,21 +117,39 @@ public class ButtonDropTarget extends TextView implements DropTarget, DragContro
outRect.bottom += mBottomDragPadding;
}
- Rect getIconRect(int itemWidth, int itemHeight, int drawableWidth, int drawableHeight) {
+ private boolean isRtl() {
+ return (getLayoutDirection() == View.LAYOUT_DIRECTION_RTL);
+ }
+
+ Rect getIconRect(int viewWidth, int viewHeight, int drawableWidth, int drawableHeight) {
DragLayer dragLayer = mLauncher.getDragLayer();
// Find the rect to animate to (the view is center aligned)
Rect to = new Rect();
dragLayer.getViewRectRelativeToSelf(this, to);
- int width = drawableWidth;
- int height = drawableHeight;
- int left = to.left + getPaddingLeft();
- int top = to.top + (getMeasuredHeight() - height) / 2;
- to.set(left, top, left + width, top + height);
+
+ final int width = drawableWidth;
+ final int height = drawableHeight;
+
+ final int left;
+ final int right;
+
+ if (isRtl()) {
+ right = to.right - getPaddingRight();
+ left = right - width;
+ } else {
+ left = to.left + getPaddingLeft();
+ right = left + width;
+ }
+
+ final int top = to.top + (getMeasuredHeight() - height) / 2;
+ final int bottom = top + height;
+
+ to.set(left, top, right, bottom);
// Center the destination rect about the trash icon
- int xOffset = (int) -(itemWidth - width) / 2;
- int yOffset = (int) -(itemHeight - height) / 2;
+ final int xOffset = (int) -(viewWidth - width) / 2;
+ final int yOffset = (int) -(viewHeight - height) / 2;
to.offset(xOffset, yOffset);
return to;
diff --git a/src/com/android/launcher2/DeleteDropTarget.java b/src/com/android/launcher2/DeleteDropTarget.java
index 39a0b09c7..d575b8f58 100644
--- a/src/com/android/launcher2/DeleteDropTarget.java
+++ b/src/com/android/launcher2/DeleteDropTarget.java
@@ -154,9 +154,9 @@ public class DeleteDropTarget extends ButtonDropTarget {
}
if (isUninstall) {
- setCompoundDrawablesWithIntrinsicBounds(mUninstallDrawable, null, null, null);
+ setCompoundDrawablesRelativeWithIntrinsicBounds(mUninstallDrawable, null, null, null);
} else {
- setCompoundDrawablesWithIntrinsicBounds(mRemoveDrawable, null, null, null);
+ setCompoundDrawablesRelativeWithIntrinsicBounds(mRemoveDrawable, null, null, null);
}
mCurrentDrawable = (TransitionDrawable) getCurrentDrawable();