Match updated redlines for shortcuts.

- Align shortcut icons with original icon.
- Drag handle is lighter and smaller.
- Shortcut pills are slightly wider to accommodate long text.

Bug: 28980830
Change-Id: I8e9709e3cbdb9df86a805a4b63a696975c61df5a
diff --git a/res/drawable/deep_shortcuts_drag_handle.xml b/res/drawable/deep_shortcuts_drag_handle.xml
index d5fca2e..99d2b07 100644
--- a/res/drawable/deep_shortcuts_drag_handle.xml
+++ b/res/drawable/deep_shortcuts_drag_handle.xml
@@ -15,12 +15,12 @@
 -->
 
 <vector xmlns:android="http://schemas.android.com/apk/res/android"
-        android:width="24dp"
-        android:height="24dp"
+        android:width="@dimen/deep_shortcut_drag_handle_size"
+        android:height="@dimen/deep_shortcut_drag_handle_size"
         android:viewportWidth="24.0"
         android:viewportHeight="24.0">
 
     <path
         android:pathData="M20 9H4v2h16V9zM4 15h16v-2H4v2z"
-        android:fillColor="#757575"/>
+        android:fillColor="#4D000000"/>
 </vector>
\ No newline at end of file
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 6bfd069..7436478 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -155,7 +155,7 @@
 
 <!-- Deep shortcuts -->
     <dimen name="deep_shortcuts_elevation">9dp</dimen>
-    <dimen name="bg_pill_width">180dp</dimen>
+    <dimen name="bg_pill_width">208dp</dimen>
     <dimen name="bg_pill_height">48dp</dimen>
     <dimen name="bg_pill_radius">24dp</dimen>
     <dimen name="deep_shortcuts_spacing">4dp</dimen>
@@ -164,9 +164,18 @@
          of the shortcut container before the container is removed. -->
     <dimen name="deep_shortcuts_start_drag_threshold">35dp</dimen>
     <dimen name="deep_shortcut_icon_size">36dp</dimen>
+    <dimen name="deep_shortcut_padding_start">6dp</dimen>
+    <dimen name="deep_shortcut_padding_end">16dp</dimen>
+    <dimen name="deep_shortcut_drawable_padding">8dp</dimen>
     <dimen name="deep_shortcut_anim_translation_y">5dp</dimen>
+    <dimen name="deep_shortcut_drag_handle_size">16dp</dimen>
     <dimen name="deep_shortcuts_arrow_width">10dp</dimen>
     <dimen name="deep_shortcuts_arrow_height">8dp</dimen>
     <dimen name="deep_shortcuts_arrow_vertical_offset">-2dp</dimen>
+    <!-- deep_shortcut_padding_start + deep_shortcut_icon_size / 2 - deep_shortcuts_arrow_width / 2-->
+    <!-- Note that this works for right-aligned shortcuts, too, because
+         deep_shortcut_padding_end + deep_shortcut_drag_handle_size / 2 - deep_shortcuts_arrow_width / 2
+         also happens to equal 19dp-->
+    <dimen name="deep_shortcuts_arrow_horizontal_offset">19dp</dimen>
 
 </resources>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 627c433..a647cf2 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -80,9 +80,9 @@
     <style name="Icon.DeepShortcut">
         <item name="android:gravity">start|center_vertical</item>
         <item name="android:elevation">@dimen/deep_shortcuts_elevation</item>
-        <item name="android:paddingLeft">7dp</item>
-        <item name="android:paddingRight">12dp</item>
-        <item name="android:drawablePadding">9dp</item>
+        <item name="android:paddingStart">@dimen/deep_shortcut_padding_start</item>
+        <item name="android:paddingEnd">@dimen/deep_shortcut_padding_end</item>
+        <item name="android:drawablePadding">@dimen/deep_shortcut_drawable_padding</item>
         <item name="android:textColor">@color/quantum_panel_text_color</item>
         <item name="android:shadowRadius">0</item>
         <item name="customShadows">false</item>
diff --git a/src/com/android/launcher3/shortcuts/DeepShortcutsContainer.java b/src/com/android/launcher3/shortcuts/DeepShortcutsContainer.java
index c881c8c..a693f15 100644
--- a/src/com/android/launcher3/shortcuts/DeepShortcutsContainer.java
+++ b/src/com/android/launcher3/shortcuts/DeepShortcutsContainer.java
@@ -96,8 +96,10 @@
     private boolean mIsLeftAligned;
     private boolean mIsAboveIcon;
     private View mArrow;
-
     private boolean mSrcIconDragStarted;
+    private LauncherViewPropertyAnimator mArrowHoverAnimator;
+    private boolean mIsRtl;
+    private int mArrowHorizontalOffset;
 
     /**
      * Sorts shortcuts in rank order, with manifest shortcuts coming before dynamic shortcuts.
@@ -128,6 +130,7 @@
         mStartDragThreshold = getResources().getDimensionPixelSize(
                 R.dimen.deep_shortcuts_start_drag_threshold);
         mAccessibilityDelegate = new ShortcutMenuAccessibilityDelegate(mLauncher);
+        mIsRtl = Utilities.isRtl(getResources());
     }
 
     public DeepShortcutsContainer(Context context, AttributeSet attrs) {
@@ -153,7 +156,20 @@
         }
 
         measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED);
-        animateOpen(originalIcon);
+        orientAboutIcon(originalIcon);
+
+        // Add the arrow.
+        final Resources resources = getResources();
+        final int arrowWidth = resources.getDimensionPixelSize(R.dimen.deep_shortcuts_arrow_width);
+        final int arrowHeight = resources.getDimensionPixelSize(R.dimen.deep_shortcuts_arrow_height);
+        mArrowHorizontalOffset = resources.getDimensionPixelSize(
+                R.dimen.deep_shortcuts_arrow_horizontal_offset);
+        final int arrowVerticalOffset = resources.getDimensionPixelSize(
+                R.dimen.deep_shortcuts_arrow_vertical_offset);
+        mArrow = addArrowView(mArrowHorizontalOffset, arrowVerticalOffset, arrowWidth, arrowHeight);
+        mArrowHoverAnimator = new LauncherViewPropertyAnimator(mArrow);
+
+        animateOpen();
 
         deferDrag(originalIcon);
 
@@ -230,25 +246,13 @@
         return getChildCount() - 1;
     }
 
-    private void animateOpen(BubbleTextView originalIcon) {
-        orientAboutIcon(originalIcon);
-        final Resources resources = getResources();
-        final int arrowWidth = resources.getDimensionPixelSize(R.dimen.deep_shortcuts_arrow_width);
-        final int arrowHeight = resources.getDimensionPixelSize(R.dimen.deep_shortcuts_arrow_height);
-        int iconWidth = originalIcon.getWidth() - originalIcon.getTotalPaddingLeft()
-                - originalIcon.getTotalPaddingRight();
-        iconWidth *= originalIcon.getScaleX();
-        final int arrowHorizontalOffset = iconWidth / 2 - arrowWidth / 2;
-        final int arrowVerticalOffset = resources.getDimensionPixelSize(
-                R.dimen.deep_shortcuts_arrow_vertical_offset);
-        mArrow = addArrowView(arrowHorizontalOffset, arrowVerticalOffset, arrowWidth, arrowHeight);
-
+    private void animateOpen() {
         setVisibility(View.VISIBLE);
 
         final AnimatorSet shortcutAnims = LauncherAnimUtils.createAnimatorSet();
         final int shortcutCount = getShortcutCount();
-        final int pivotX = mIsLeftAligned ? arrowHorizontalOffset
-                : getMeasuredWidth() - arrowHorizontalOffset;
+        final int pivotX = mIsLeftAligned ? mArrowHorizontalOffset
+                : getMeasuredWidth() - mArrowHorizontalOffset;
         final int pivotY = getShortcutAt(0).getMeasuredHeight() / 2;
         for (int i = 0; i < shortcutCount; i++) {
             DeepShortcutView deepShortcutView = getShortcutAt(i);
@@ -292,20 +296,40 @@
         Rect insets = dragLayer.getInsets();
 
         // Align left (right in RTL) if there is room.
-        boolean isRtl = Utilities.isRtl(getResources());
         int leftAlignedX = mTempRect.left + icon.getPaddingLeft();
         int rightAlignedX = mTempRect.right - width - icon.getPaddingRight();
         int x = leftAlignedX;
         boolean canBeLeftAligned = leftAlignedX + width < dragLayer.getRight() - insets.right;
         boolean canBeRightAligned = rightAlignedX > dragLayer.getLeft() + insets.left;
-        if (!canBeLeftAligned || (isRtl && canBeRightAligned)) {
+        if (!canBeLeftAligned || (mIsRtl && canBeRightAligned)) {
             x = rightAlignedX;
         }
         mIsLeftAligned = x == leftAlignedX;
-        if (isRtl) {
+        if (mIsRtl) {
             x -= dragLayer.getWidth() - width;
         }
 
+        // Offset x so that the arrow and shortcut icons are center-aligned with the original icon.
+        int iconWidth = icon.getWidth() - icon.getTotalPaddingLeft() - icon.getTotalPaddingRight();
+        iconWidth *= icon.getScaleX();
+        Resources resources = getResources();
+        int xOffset;
+        if (isAlignedWithStart()) {
+            // Aligning with the shortcut icon.
+            int shortcutIconWidth = resources.getDimensionPixelSize(R.dimen.deep_shortcut_icon_size);
+            int shortcutPaddingStart = resources.getDimensionPixelSize(
+                    R.dimen.deep_shortcut_padding_start);
+            xOffset = iconWidth / 2 - shortcutIconWidth / 2 - shortcutPaddingStart;
+        } else {
+            // Aligning with the drag handle.
+            int shortcutDragHandleWidth = resources.getDimensionPixelSize(
+                    R.dimen.deep_shortcut_drag_handle_size);
+            int shortcutPaddingEnd = resources.getDimensionPixelSize(
+                    R.dimen.deep_shortcut_padding_end);
+            xOffset = iconWidth / 2 - shortcutDragHandleWidth / 2 - shortcutPaddingEnd;
+        }
+        x += mIsLeftAligned ? xOffset : -xOffset;
+
         // Open above icon if there is room.
         int y = mTempRect.top - height;
         mIsAboveIcon = mTempRect.top - height > dragLayer.getTop() + insets.top;
@@ -320,6 +344,10 @@
         setY(y);
     }
 
+    private boolean isAlignedWithStart() {
+        return mIsLeftAligned && !mIsRtl || !mIsLeftAligned && mIsRtl;
+    }
+
     /**
      * Adds an arrow view pointing at the original icon.
      * @param horizontalOffset the horizontal offset of the arrow, so that it