style="@style/DropTargetButton"
android:id="@+id/delete_target_text"
android:text="@string/delete_zone_label_workspace"
- android:drawableLeft="@drawable/remove_target_selector" />
+ android:drawableStart="@drawable/remove_target_selector" />
</FrameLayout>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/DropTargetButton"
android:id="@+id/info_target_text"
android:text="@string/info_target_label"
- android:drawableLeft="@drawable/info_target_selector" />
+ android:drawableStart="@drawable/info_target_selector" />
</FrameLayout>
</merge>
\ No newline at end of file
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;
}
protected Drawable getCurrentDrawable() {
- Drawable[] drawables = getCompoundDrawables();
+ Drawable[] drawables = getCompoundDrawablesRelative();
for (int i = 0; i < drawables.length; ++i) {
if (drawables[i] != null) {
return drawables[i];
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;
}
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();