Fixing minor bugs (5085316, 5082963, 5042828)

- Adding separator between qsb and workspace content
- Adding a bit of spacing between drawables and text in all apps
- Making the drop target area smaller...

Change-Id: I1bebe7dff20fc30e4896de1dcf23d23b62a31a07
diff --git a/src/com/android/launcher2/ButtonDropTarget.java b/src/com/android/launcher2/ButtonDropTarget.java
index 138770a..868ede8 100644
--- a/src/com/android/launcher2/ButtonDropTarget.java
+++ b/src/com/android/launcher2/ButtonDropTarget.java
@@ -29,7 +29,7 @@
 /**
  * Implements a DropTarget.
  */
-public class ButtonDropTarget extends FrameLayout implements DropTarget, DragController.DragListener {
+public class ButtonDropTarget extends TextView implements DropTarget, DragController.DragListener {
 
     protected final int mTransitionDuration;
 
diff --git a/src/com/android/launcher2/DeleteDropTarget.java b/src/com/android/launcher2/DeleteDropTarget.java
index e76ab31..1553d3c 100644
--- a/src/com/android/launcher2/DeleteDropTarget.java
+++ b/src/com/android/launcher2/DeleteDropTarget.java
@@ -26,9 +26,8 @@
 import android.graphics.drawable.TransitionDrawable;
 import android.util.AttributeSet;
 import android.view.View;
-import android.view.animation.AccelerateInterpolator;
+import android.view.ViewGroup;
 import android.view.animation.DecelerateInterpolator;
-import android.widget.TextView;
 
 import com.android.launcher.R;
 
@@ -52,22 +51,21 @@
         super.onFinishInflate();
 
         // Get the drawable
-        mText = (TextView) findViewById(R.id.delete_target_text);
-        mOriginalTextColor = mText.getTextColors();
+        mOriginalTextColor = getTextColors();
 
         // Get the hover color
         Resources r = getResources();
         mHoverColor = r.getColor(R.color.delete_target_hover_tint);
         mHoverPaint.setColorFilter(new PorterDuffColorFilter(
                 mHoverColor, PorterDuff.Mode.SRC_ATOP));
-        mDrawable = (TransitionDrawable) mText.getCompoundDrawables()[0];
+        mDrawable = (TransitionDrawable) getCompoundDrawables()[0];
         mDrawable.setCrossFadeEnabled(true);
 
         // Remove the text in the Phone UI in landscape
         int orientation = getResources().getConfiguration().orientation;
         if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
             if (!LauncherApplication.isScreenLarge()) {
-                mText.setText("");
+                setText("");
             }
         }
     }
@@ -120,10 +118,10 @@
 
         mActive = isVisible;
         mDrawable.resetTransition();
-        mText.setTextColor(mOriginalTextColor);
-        setVisibility(isVisible ? View.VISIBLE : View.GONE);
-        if (mText.getText().length() > 0) {
-            mText.setText(isUninstall ? R.string.delete_target_uninstall_label
+        setTextColor(mOriginalTextColor);
+        ((ViewGroup) getParent()).setVisibility(isVisible ? View.VISIBLE : View.GONE);
+        if (getText().length() > 0) {
+            setText(isUninstall ? R.string.delete_target_uninstall_label
                 : R.string.delete_target_label);
         }
     }
@@ -138,7 +136,7 @@
         super.onDragEnter(d);
 
         mDrawable.startTransition(mTransitionDuration);
-        mText.setTextColor(mHoverColor);
+        setTextColor(mHoverColor);
     }
 
     public void onDragExit(DragObject d) {
@@ -146,7 +144,7 @@
 
         if (!d.dragComplete) {
             mDrawable.resetTransition();
-            mText.setTextColor(mOriginalTextColor);
+            setTextColor(mOriginalTextColor);
         }
     }
 
@@ -155,11 +153,12 @@
         Rect from = new Rect();
         Rect to = new Rect();
         dragLayer.getViewRectRelativeToSelf(d.dragView, from);
-        dragLayer.getViewRectRelativeToSelf(mText, to);
+        dragLayer.getViewRectRelativeToSelf(this, to);
 
         int width = mDrawable.getIntrinsicWidth();
         int height = mDrawable.getIntrinsicHeight();
-        to.set(to.left, to.top, to.left + width, to.bottom);
+        to.set(to.left + getPaddingLeft(), to.top + getPaddingTop(),
+                to.left + getPaddingLeft() + width, to.bottom);
 
         // Center the destination rect about the trash icon
         int xOffset = (int) -(d.dragView.getMeasuredWidth() - width) / 2;
diff --git a/src/com/android/launcher2/InfoDropTarget.java b/src/com/android/launcher2/InfoDropTarget.java
index 3507181..dba845b 100644
--- a/src/com/android/launcher2/InfoDropTarget.java
+++ b/src/com/android/launcher2/InfoDropTarget.java
@@ -26,7 +26,7 @@
 import android.graphics.drawable.TransitionDrawable;
 import android.util.AttributeSet;
 import android.view.View;
-import android.widget.TextView;
+import android.view.ViewGroup;
 
 import com.android.launcher.R;
 
@@ -48,22 +48,21 @@
     protected void onFinishInflate() {
         super.onFinishInflate();
 
-        mText = (TextView) findViewById(R.id.info_target_text);
-        mOriginalTextColor = mText.getTextColors();
+        mOriginalTextColor = getTextColors();
 
         // Get the hover color
         Resources r = getResources();
         mHoverColor = r.getColor(R.color.info_target_hover_tint);
         mHoverPaint.setColorFilter(new PorterDuffColorFilter(
                 mHoverColor, PorterDuff.Mode.SRC_ATOP));
-        mDrawable = (TransitionDrawable) mText.getCompoundDrawables()[0];
+        mDrawable = (TransitionDrawable) getCompoundDrawables()[0];
         mDrawable.setCrossFadeEnabled(true);
 
         // Remove the text in the Phone UI in landscape
         int orientation = getResources().getConfiguration().orientation;
         if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
             if (!LauncherApplication.isScreenLarge()) {
-                mText.setText("");
+                setText("");
             }
         }
     }
@@ -100,8 +99,8 @@
 
         mActive = isVisible;
         mDrawable.resetTransition();
-        mText.setTextColor(mOriginalTextColor);
-        setVisibility(isVisible ? View.VISIBLE : View.GONE);
+        setTextColor(mOriginalTextColor);
+        ((ViewGroup) getParent()).setVisibility(isVisible ? View.VISIBLE : View.GONE);
     }
 
     @Override
@@ -114,7 +113,7 @@
         super.onDragEnter(d);
 
         mDrawable.startTransition(mTransitionDuration);
-        mText.setTextColor(mHoverColor);
+        setTextColor(mHoverColor);
     }
 
     public void onDragExit(DragObject d) {
@@ -122,7 +121,7 @@
 
         if (!d.dragComplete) {
             mDrawable.resetTransition();
-            mText.setTextColor(mOriginalTextColor);
+            setTextColor(mOriginalTextColor);
         }
     }
 }
diff --git a/src/com/android/launcher2/PagedView.java b/src/com/android/launcher2/PagedView.java
index 596ef50..292ccd7 100644
--- a/src/com/android/launcher2/PagedView.java
+++ b/src/com/android/launcher2/PagedView.java
@@ -163,14 +163,13 @@
 
     // Scrolling indicator
     private ValueAnimator mScrollIndicatorAnimator;
-    private android.animation.ValueAnimator mDockDividerAnimator;
     private ImageView mScrollIndicator;
     private int mScrollIndicatorPaddingLeft;
     private int mScrollIndicatorPaddingRight;
     private boolean mHasScrollIndicator = true;
-    private static final int sScrollIndicatorFadeInDuration = 150;
-    private static final int sScrollIndicatorFadeOutDuration = 650;
-    private static final int sScrollIndicatorFlashDuration = 650;
+    protected static final int sScrollIndicatorFadeInDuration = 150;
+    protected static final int sScrollIndicatorFadeOutDuration = 650;
+    protected static final int sScrollIndicatorFlashDuration = 650;
 
     // If set, will defer loading associated pages until the scrolling settles
     private boolean mDeferLoadAssociatedPagesUntilScrollCompletes;
@@ -1740,55 +1739,6 @@
         }
     }
 
-    void showDockDivider(boolean immediately) {
-        final ViewGroup parent = (ViewGroup) getParent();
-        final View divider = (ImageView) (parent.findViewById(R.id.dock_divider));
-        if (divider != null) {
-            divider.setVisibility(View.VISIBLE);
-            if (mDockDividerAnimator != null) {
-                mDockDividerAnimator.cancel();
-            }
-            if (immediately) {
-                divider.setAlpha(1f);
-            } else {
-                mDockDividerAnimator = ObjectAnimator.ofFloat(divider, "alpha", 1f);
-                mDockDividerAnimator.setDuration(sScrollIndicatorFadeInDuration);
-                mDockDividerAnimator.start();
-            }
-        }
-    }
-
-    void hideDockDivider(boolean immediately) {
-        final ViewGroup parent = (ViewGroup) getParent();
-        final View divider = (ImageView) (parent.findViewById(R.id.dock_divider));
-        if (divider != null) {
-            if (mDockDividerAnimator != null) {
-                mDockDividerAnimator.cancel();
-            }
-            if (immediately) {
-                divider.setVisibility(View.GONE);
-                divider.setAlpha(0f);
-            } else {
-                mDockDividerAnimator = ObjectAnimator.ofFloat(divider, "alpha", 0f);
-                mDockDividerAnimator.setDuration(sScrollIndicatorFadeOutDuration);
-                mDockDividerAnimator.addListener(new AnimatorListenerAdapter() {
-                    private boolean cancelled = false;
-                    @Override
-                    public void onAnimationCancel(android.animation.Animator animation) {
-                        cancelled = true;
-                    }
-                    @Override
-                    public void onAnimationEnd(android.animation.Animator animation) {
-                        if (!cancelled) {
-                            divider.setVisibility(View.GONE);
-                        }
-                    }
-                });
-                mDockDividerAnimator.start();
-            }
-        }
-    }
-
     /**
      * To be overridden by subclasses to determine whether the scroll indicator should stretch to
      * fill its space on the track or not.
diff --git a/src/com/android/launcher2/SearchDropTargetBar.java b/src/com/android/launcher2/SearchDropTargetBar.java
index ee3ab18..69a1213 100644
--- a/src/com/android/launcher2/SearchDropTargetBar.java
+++ b/src/com/android/launcher2/SearchDropTargetBar.java
@@ -77,8 +77,8 @@
         // Get the individual components
         mQSBSearchBar = findViewById(R.id.qsb_search_bar);
         mDropTargetBar = findViewById(R.id.drag_target_bar);
-        mInfoDropTarget = (ButtonDropTarget) mDropTargetBar.findViewById(R.id.info_target);
-        mDeleteDropTarget = (ButtonDropTarget) mDropTargetBar.findViewById(R.id.delete_target);
+        mInfoDropTarget = (ButtonDropTarget) mDropTargetBar.findViewById(R.id.info_target_text);
+        mDeleteDropTarget = (ButtonDropTarget) mDropTargetBar.findViewById(R.id.delete_target_text);
         mBarHeight = getResources().getDimensionPixelSize(R.dimen.qsb_bar_height);
 
         mInfoDropTarget.setSearchDropTargetBar(this);
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index 23b8c2d..e4865c2 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -58,6 +58,7 @@
 import android.view.View;
 import android.view.ViewGroup;
 import android.view.animation.DecelerateInterpolator;
+import android.widget.ImageView;
 import android.widget.TextView;
 import android.widget.Toast;
 
@@ -109,6 +110,7 @@
     private float mBackgroundAlpha = 0;
     private float mOverScrollMaxBackgroundAlpha = 0.0f;
     private int mOverScrollPageIndex = -1;
+    private AnimatorSet mDividerAnimator;
 
     private final WallpaperManager mWallpaperManager;
     private IBinder mWindowToken;
@@ -3542,4 +3544,66 @@
     protected boolean hasElasticScrollIndicator() {
         return true;
     }
+
+    void showDockDivider(boolean immediately) {
+        final ViewGroup parent = (ViewGroup) getParent();
+        final View qsbDivider = (ImageView) (parent.findViewById(R.id.qsb_divider));
+        final View dockDivider = (ImageView) (parent.findViewById(R.id.dock_divider));
+        if (qsbDivider != null && dockDivider != null) {
+            qsbDivider.setVisibility(View.VISIBLE);
+            dockDivider.setVisibility(View.VISIBLE);
+            if (mDividerAnimator != null) {
+                mDividerAnimator.cancel();
+                mDividerAnimator = null;
+            }
+            if (immediately) {
+                qsbDivider.setAlpha(1f);
+                dockDivider.setAlpha(1f);
+            } else {
+                mDividerAnimator = new AnimatorSet();
+                mDividerAnimator.playTogether(ObjectAnimator.ofFloat(qsbDivider, "alpha", 1f),
+                        ObjectAnimator.ofFloat(dockDivider, "alpha", 1f));
+                mDividerAnimator.setDuration(sScrollIndicatorFadeInDuration);
+                mDividerAnimator.start();
+            }
+        }
+    }
+
+    void hideDockDivider(boolean immediately) {
+        final ViewGroup parent = (ViewGroup) getParent();
+        final View qsbDivider = (ImageView) (parent.findViewById(R.id.qsb_divider));
+        final View dockDivider = (ImageView) (parent.findViewById(R.id.dock_divider));
+        if (qsbDivider != null && dockDivider != null) {
+            if (mDividerAnimator != null) {
+                mDividerAnimator.cancel();
+                mDividerAnimator = null;
+            }
+            if (immediately) {
+                qsbDivider.setVisibility(View.GONE);
+                dockDivider.setVisibility(View.GONE);
+                qsbDivider.setAlpha(0f);
+                dockDivider.setAlpha(0f);
+            } else {
+                mDividerAnimator = new AnimatorSet();
+                mDividerAnimator.playTogether(ObjectAnimator.ofFloat(qsbDivider, "alpha", 0f),
+                        ObjectAnimator.ofFloat(dockDivider, "alpha", 0f));
+                mDividerAnimator.addListener(new AnimatorListenerAdapter() {
+                    private boolean cancelled = false;
+                    @Override
+                    public void onAnimationCancel(android.animation.Animator animation) {
+                        cancelled = true;
+                    }
+                    @Override
+                    public void onAnimationEnd(android.animation.Animator animation) {
+                        if (!cancelled) {
+                            qsbDivider.setVisibility(View.GONE);
+                            dockDivider.setVisibility(View.GONE);
+                        }
+                    }
+                });
+                mDividerAnimator.setDuration(sScrollIndicatorFadeOutDuration);
+                mDividerAnimator.start();
+            }
+        }
+    }
 }