Update popup to match redlines

- Update specs in dimens.xml and colors.xml
- Move notification count to top right, and keep "Notifications" in left
    - Also removed NotificationHeaderView and instead use FrameLayout
- Limit to 2 shortcuts instead of 3 if there are notifications
- Use SP instead of DP for text (b/35869307)

Bug: 35766387
Change-Id: I892640933ad6351946af3df6c805b98bb4e7cb50
diff --git a/res/layout/deep_shortcut.xml b/res/layout/deep_shortcut.xml
index 60131e4..7744906 100644
--- a/res/layout/deep_shortcut.xml
+++ b/res/layout/deep_shortcut.xml
@@ -27,7 +27,7 @@
         android:gravity="start|center_vertical"
         android:textAlignment="viewStart"
         android:paddingStart="@dimen/bg_popup_item_height"
-        android:paddingEnd="@dimen/deep_shortcut_padding_end"
+        android:paddingEnd="@dimen/popup_padding_end"
         android:drawableEnd="@drawable/deep_shortcuts_drag_handle"
         android:drawablePadding="@dimen/deep_shortcut_drawable_padding"
         android:textSize="14sp"
@@ -40,8 +40,8 @@
         android:id="@+id/icon"
         android:layout_width="@dimen/deep_shortcut_icon_size"
         android:layout_height="@dimen/deep_shortcut_icon_size"
-        android:layout_margin="@dimen/deep_shortcut_padding_start"
-        android:layout_gravity="start" />
+        android:layout_marginStart="@dimen/popup_padding_start"
+        android:layout_gravity="start|center_vertical" />
 
     <View
         android:id="@+id/divider"
diff --git a/res/layout/notification.xml b/res/layout/notification.xml
index 6922ad9..4250e1e 100644
--- a/res/layout/notification.xml
+++ b/res/layout/notification.xml
@@ -29,30 +29,33 @@
         android:orientation="vertical"
         android:clipChildren="false">
 
-        <com.android.launcher3.notification.NotificationHeaderView
+        <FrameLayout
             android:id="@+id/header"
             android:layout_width="match_parent"
             android:layout_height="@dimen/notification_header_height"
-            android:orientation="horizontal"
-            android:paddingStart="@dimen/notification_padding"
+            android:paddingStart="@dimen/notification_padding_start"
+            android:paddingEnd="@dimen/notification_padding_end"
             android:background="@color/notification_header_background_color"
             android:elevation="@dimen/notification_elevation">
             <TextView
-                android:id="@+id/notification_count"
-                android:layout_width="wrap_content"
-                android:layout_height="match_parent"
-                android:gravity="start|center_vertical"
-                android:paddingEnd="@dimen/notification_header_padding_after_count"
-                android:textSize="@dimen/notification_main_text_size"
-                android:textColor="?android:attr/textColorPrimary" />
-            <TextView
                 android:id="@+id/notification_text"
                 android:layout_width="wrap_content"
                 android:layout_height="match_parent"
-                android:gravity="start|center_vertical"
-                android:textSize="@dimen/notification_main_text_size"
+                android:layout_gravity="start"
+                android:gravity="center_vertical"
+                android:text="@string/notifications_header"
+                android:textSize="@dimen/notification_header_text_size"
                 android:textColor="?android:attr/textColorSecondary" />
-        </com.android.launcher3.notification.NotificationHeaderView>
+            <TextView
+                android:id="@+id/notification_count"
+                android:layout_width="@dimen/notification_icon_size"
+                android:layout_height="match_parent"
+                android:layout_gravity="end"
+                android:gravity="center"
+                android:textSize="@dimen/notification_header_count_text_size"
+                android:fontFamily="sans-serif-medium"
+                android:textColor="?android:attr/textColorPrimary" />
+        </FrameLayout>
 
         <include layout="@layout/notification_main"
             android:id="@+id/main_view"
diff --git a/res/layout/notification_main.xml b/res/layout/notification_main.xml
index 9c5847f..8fa1b68 100644
--- a/res/layout/notification_main.xml
+++ b/res/layout/notification_main.xml
@@ -29,7 +29,7 @@
         android:orientation="vertical"
         android:gravity="center_vertical"
         android:background="@color/notification_background_color"
-        android:paddingStart="@dimen/notification_padding"
+        android:paddingStart="@dimen/notification_padding_start"
         android:paddingEnd="@dimen/notification_main_text_padding_end">
         <TextView
             android:id="@+id/title"
@@ -57,7 +57,7 @@
         android:id="@+id/popup_item_icon"
         android:layout_width="@dimen/notification_icon_size"
         android:layout_height="@dimen/notification_icon_size"
-        android:layout_marginEnd="@dimen/notification_padding"
+        android:layout_marginEnd="@dimen/notification_padding_end"
         android:layout_gravity="center_vertical|end" />
 
 </com.android.launcher3.notification.NotificationMainView>
diff --git a/res/layout/system_shortcut.xml b/res/layout/system_shortcut.xml
index 3baddc4..113b1be 100644
--- a/res/layout/system_shortcut.xml
+++ b/res/layout/system_shortcut.xml
@@ -27,7 +27,7 @@
         android:gravity="start|center_vertical"
         android:textAlignment="viewStart"
         android:paddingStart="@dimen/bg_popup_item_height"
-        android:paddingEnd="@dimen/deep_shortcut_padding_end"
+        android:paddingEnd="@dimen/popup_padding_end"
         android:textSize="14sp"
         android:fontFamily="sans-serif"
         launcher:layoutHorizontal="true" />
@@ -36,8 +36,8 @@
         android:id="@+id/icon"
         android:layout_width="@dimen/system_shortcut_icon_size"
         android:layout_height="@dimen/system_shortcut_icon_size"
-        android:layout_margin="@dimen/system_shortcut_padding_start"
-        android:layout_gravity="start" />
+        android:layout_marginStart="@dimen/system_shortcut_margin_start"
+        android:layout_gravity="start|center_vertical" />
 
     <View
         android:id="@+id/divider"
diff --git a/res/layout/system_shortcut_icon_only.xml b/res/layout/system_shortcut_icon_only.xml
index 02d4ef8..313c69c 100644
--- a/res/layout/system_shortcut_icon_only.xml
+++ b/res/layout/system_shortcut_icon_only.xml
@@ -16,8 +16,7 @@
 
 <ImageView
     xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="@dimen/deep_shortcut_icon_size"
-    android:layout_height="@dimen/deep_shortcut_icon_size"
-    android:background="?android:attr/selectableItemBackground"
-    android:layout_marginEnd="@dimen/deep_shortcut_padding_start"
-    android:padding="4dp" />
+    android:layout_width="@dimen/system_shortcut_header_icon_touch_size"
+    android:layout_height="@dimen/system_shortcut_header_icon_touch_size"
+    android:background="?android:attr/selectableItemBackgroundBorderless"
+    android:padding="@dimen/system_shortcut_header_icon_padding" />
diff --git a/res/layout/system_shortcut_icons.xml b/res/layout/system_shortcut_icons.xml
index bf0a251..9dc56e4 100644
--- a/res/layout/system_shortcut_icons.xml
+++ b/res/layout/system_shortcut_icons.xml
@@ -18,8 +18,7 @@
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:id="@+id/system_shortcut_icons"
     android:layout_width="match_parent"
-    android:layout_height="@dimen/bg_popup_item_height"
-    android:paddingEnd="@dimen/deep_shortcut_padding_start"
+    android:layout_height="@dimen/system_shortcut_header_height"
     android:orientation="horizontal"
     android:gravity="end|center_vertical"
     android:background="@color/notification_header_background_color" />
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 028c982..3ce7baa 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -37,12 +37,13 @@
 
     <!-- Notifications -->
     <color name="notification_icon_default_color">#757575</color> <!-- Gray 600 -->
-    <color name="notification_header_background_color">#F5F5F5</color> <!-- Gray 100 -->
+    <color name="notification_header_background_color">#EEEEEE</color> <!-- Gray 200 -->
     <color name="notification_background_color">#FFF</color>
     <color name="notification_color_beneath">#E0E0E0</color> <!-- Gray 300 -->
     <color name="divider_color">@color/notification_color_beneath</color>
-    <color name="icon_background">#E0E0E0</color> <!-- Gray 300 -->
 
     <!-- System shortcuts -->
     <color name="system_shortcuts_icon_color">@android:color/tertiary_text_light</color>
+
+    <color name="icon_background">#E0E0E0</color> <!-- Gray 300 -->
 </resources>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 7b1d247..0b6100f 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -151,51 +151,57 @@
 <!-- Deep shortcuts -->
     <dimen name="deep_shortcuts_elevation">9dp</dimen>
     <dimen name="bg_popup_item_width">208dp</dimen>
-    <dimen name="bg_popup_item_height">48dp</dimen>
+    <dimen name="bg_popup_item_height">56dp</dimen>
     <dimen name="popup_items_spacing">4dp</dimen>
     <dimen name="pre_drag_view_scale">6dp</dimen>
     <!-- an icon with shortcuts must be dragged this far before the container is removed. -->
     <dimen name="deep_shortcuts_start_drag_threshold">16dp</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-->
+    <dimen name="popup_padding_start">6dp</dimen>
+    <dimen name="popup_padding_end">16dp</dimen>
+    <dimen name="popup_arrow_width">10dp</dimen>
+    <dimen name="popup_arrow_height">8dp</dimen>
+    <dimen name="popup_arrow_vertical_offset">-2dp</dimen>
+    <!-- popup_padding_start + deep_shortcut_icon_size / 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>
+         popup_padding_end + deep_shortcut_drag_handle_size / 2 also equals 24dp-->
+    <dimen name="popup_arrow_horizontal_center">24dp</dimen>
+    <!-- popup_arrow_center - popup_arrow_width / 2-->
+    <dimen name="popup_arrow_horizontal_offset">19dp</dimen>
     <!-- popup_item_width - icon_size - padding_start - drawable_padding -->
     <dimen name="deep_shortcuts_divider_width">158dp</dimen>
-    <dimen name="system_shortcut_icon_size">28dp</dimen>
-    <dimen name="system_shortcut_padding_start">10dp</dimen>
+    <dimen name="system_shortcut_icon_size">24dp</dimen>
+    <!-- popup_arrow_center - system_shortcut_icon_size / 2 -->
+    <dimen name="system_shortcut_margin_start">12dp</dimen>
+    <dimen name="system_shortcut_header_height">40dp</dimen>
+    <dimen name="system_shortcut_header_icon_touch_size">48dp</dimen>
+    <!-- (touch_size - icon_size) / 2 -->
+    <dimen name="system_shortcut_header_icon_padding">12dp</dimen>
 
 <!-- Icon badges (with notification counts) -->
     <dimen name="badge_size">24dp</dimen>
     <dimen name="badge_text_size">12dp</dimen>
     <dimen name="badge_small_padding">0dp</dimen>
     <dimen name="badge_large_padding">3dp</dimen>
-    <dimen name="notification_icon_size">24dp</dimen>
-    <dimen name="notification_footer_icon_size">18dp</dimen>
 
 <!-- Notifications -->
     <dimen name="bg_round_rect_radius">12dp</dimen>
-    <dimen name="notification_padding">12dp</dimen>
-    <!-- notification_padding + (icon_size - footer_icon_size) / 2 -->
+    <dimen name="notification_padding_start">16dp</dimen>
+    <dimen name="notification_padding_end">12dp</dimen>
+    <!-- notification_padding_end + (icon_size - footer_icon_size) / 2 -->
     <dimen name="notification_footer_icon_row_padding">15dp</dimen>
-    <dimen name="notification_header_padding_after_count">8dp</dimen>
     <dimen name="notification_header_height">32dp</dimen>
-    <dimen name="notification_main_height">60dp</dimen>
-    <dimen name="notification_footer_height">@dimen/bg_popup_item_height</dimen>
-    <dimen name="notification_header_text_size">12dp</dimen>
-    <dimen name="notification_main_text_size">14dp</dimen>
-    <!-- notification_icon_size + notification+padding + padding we want between icon and text -->
-    <dimen name="notification_main_text_padding_end">40dp</dimen>
+    <dimen name="notification_main_height">80dp</dimen>
+    <dimen name="notification_footer_height">32dp</dimen>
+    <dimen name="notification_header_text_size">13sp</dimen>
+    <dimen name="notification_header_count_text_size">12sp</dimen>
+    <dimen name="notification_main_text_size">15sp</dimen>
+    <dimen name="notification_icon_size">24dp</dimen>
+    <dimen name="notification_footer_icon_size">18dp</dimen>
+    <!-- notification_icon_size + notification_padding_end + 16dp padding between icon and text -->
+    <dimen name="notification_main_text_padding_end">52dp</dimen>
     <dimen name="notification_elevation">2dp</dimen>
     <dimen name="horizontal_ellipsis_size">18dp</dimen>
     <!-- arrow_horizontal_offset - (ellipsis_size - arrow_width) / 2 -->
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 0461e4a..eddae62 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -67,15 +67,9 @@
     <!-- Label for the button which allows the user to get app search results. [CHAR_LIMIT=50] -->
     <string name="all_apps_search_market_message">Search for more apps</string>
 
-    <!-- Deep items -->
-    <!-- Text to indicate more items that couldn't be displayed due to space constraints.
-         The text must fit in the size of a small icon [CHAR_LIMIT=3] -->
-    <string name="deep_notifications_overflow" translatable="false">+%1$d</string>
+    <!-- Popup items -->
     <!-- Text to display as the header above notifications. [CHAR_LIMIT=30] -->
-    <plurals name="notifications_header" translatable="false">
-        <item quantity="one">Notification</item>
-        <item quantity="other">Notifications</item>
-    </plurals>
+    <string name="notifications_header">Notifications</string>
 
     <!-- Drag and drop -->
     <skip />
diff --git a/src/com/android/launcher3/FastBitmapDrawable.java b/src/com/android/launcher3/FastBitmapDrawable.java
index 5a44f75..be3ba90 100644
--- a/src/com/android/launcher3/FastBitmapDrawable.java
+++ b/src/com/android/launcher3/FastBitmapDrawable.java
@@ -167,7 +167,7 @@
         }
     }
 
-    protected IconPalette getIconPalette() {
+    public IconPalette getIconPalette() {
         if (mIconPalette == null) {
             mIconPalette = IconPalette.fromDominantColor(Utilities
                     .findDominantColorByHue(mBitmap, 20));
diff --git a/src/com/android/launcher3/notification/NotificationHeaderView.java b/src/com/android/launcher3/notification/NotificationHeaderView.java
deleted file mode 100644
index e70b489..0000000
--- a/src/com/android/launcher3/notification/NotificationHeaderView.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.launcher3.notification;
-
-import android.content.Context;
-import android.util.AttributeSet;
-import android.widget.LinearLayout;
-import android.widget.TextView;
-
-import com.android.launcher3.R;
-
-/**
- * A {@link LinearLayout} that contains two text views: one for the notification count
- * and one just to say "Notification" or "Notifications"
- */
-public class NotificationHeaderView extends LinearLayout {
-
-    private TextView mNotificationCount;
-    private TextView mNotificationText;
-
-    public NotificationHeaderView(Context context) {
-        this(context, null, 0);
-    }
-
-    public NotificationHeaderView(Context context, AttributeSet attrs) {
-        this(context, attrs, 0);
-    }
-
-    public NotificationHeaderView(Context context, AttributeSet attrs, int defStyle) {
-        super(context, attrs, defStyle);
-    }
-
-    @Override
-    protected void onFinishInflate() {
-        super.onFinishInflate();
-        mNotificationCount = (TextView) findViewById(R.id.notification_count);
-        mNotificationText = (TextView) findViewById(R.id.notification_text);
-    }
-
-    public void update(int notificationCount) {
-        mNotificationCount.setText(String.valueOf(notificationCount));
-        mNotificationText.setText(getResources().getQuantityString(
-                R.plurals.notifications_header, notificationCount));
-    }
-}
diff --git a/src/com/android/launcher3/notification/NotificationItemView.java b/src/com/android/launcher3/notification/NotificationItemView.java
index 37b8325..5e8e2c7 100644
--- a/src/com/android/launcher3/notification/NotificationItemView.java
+++ b/src/com/android/launcher3/notification/NotificationItemView.java
@@ -17,16 +17,20 @@
 package com.android.launcher3.notification;
 
 import android.animation.Animator;
+import android.app.Notification;
 import android.content.Context;
 import android.graphics.Rect;
+import android.support.annotation.Nullable;
 import android.util.AttributeSet;
 import android.view.MotionEvent;
 import android.view.View;
 import android.widget.FrameLayout;
+import android.widget.TextView;
 
 import com.android.launcher3.ItemInfo;
 import com.android.launcher3.R;
 import com.android.launcher3.anim.PillHeightRevealOutlineProvider;
+import com.android.launcher3.graphics.IconPalette;
 import com.android.launcher3.logging.UserEventDispatcher.LogContainerProvider;
 import com.android.launcher3.popup.PopupItemView;
 import com.android.launcher3.userevent.nano.LauncherLogProto;
@@ -43,11 +47,12 @@
 
     private static final Rect sTempRect = new Rect();
 
-    private NotificationHeaderView mHeader;
+    private TextView mHeaderCount;
     private NotificationMainView mMainView;
     private NotificationFooterLayout mFooter;
     private SwipeHelper mSwipeHelper;
     private boolean mAnimatingNextIcon;
+    private int mNotificationHeaderTextColor = Notification.COLOR_DEFAULT;
 
     public NotificationItemView(Context context) {
         this(context, null, 0);
@@ -64,7 +69,7 @@
     @Override
     protected void onFinishInflate() {
         super.onFinishInflate();
-        mHeader = (NotificationHeaderView) findViewById(R.id.header);
+        mHeaderCount = (TextView) findViewById(R.id.notification_count);
         mMainView = (NotificationMainView) findViewById(R.id.main_view);
         mFooter = (NotificationFooterLayout) findViewById(R.id.footer);
         mSwipeHelper = new SwipeHelper(SwipeHelper.X, mMainView, getContext());
@@ -77,8 +82,16 @@
                 getBackgroundRadius(), newHeight).createRevealAnimator(this, true /* isReversed */);
     }
 
-    public void updateHeader(int notificationCount) {
-        mHeader.update(notificationCount);
+    public void updateHeader(int notificationCount, @Nullable IconPalette palette) {
+        mHeaderCount.setText(notificationCount <= 1 ? "" : String.valueOf(notificationCount));
+        if (palette != null) {
+            if (mNotificationHeaderTextColor == Notification.COLOR_DEFAULT) {
+                mNotificationHeaderTextColor =
+                        IconPalette.resolveContrastColor(getContext(), palette.dominantColor,
+                            getResources().getColor(R.color.notification_header_background_color));
+            }
+            mHeaderCount.setTextColor(mNotificationHeaderTextColor);
+        }
     }
 
     @Override
diff --git a/src/com/android/launcher3/popup/PopupContainerWithArrow.java b/src/com/android/launcher3/popup/PopupContainerWithArrow.java
index b92814f..99c7e75 100644
--- a/src/com/android/launcher3/popup/PopupContainerWithArrow.java
+++ b/src/com/android/launcher3/popup/PopupContainerWithArrow.java
@@ -46,6 +46,7 @@
 import com.android.launcher3.BubbleTextView;
 import com.android.launcher3.DragSource;
 import com.android.launcher3.DropTarget;
+import com.android.launcher3.FastBitmapDrawable;
 import com.android.launcher3.ItemInfo;
 import com.android.launcher3.Launcher;
 import com.android.launcher3.LauncherAnimUtils;
@@ -62,6 +63,7 @@
 import com.android.launcher3.dragndrop.DragController;
 import com.android.launcher3.dragndrop.DragLayer;
 import com.android.launcher3.dragndrop.DragOptions;
+import com.android.launcher3.graphics.IconPalette;
 import com.android.launcher3.graphics.TriangleShape;
 import com.android.launcher3.notification.NotificationItemView;
 import com.android.launcher3.notification.NotificationKeyData;
@@ -158,12 +160,12 @@
     public void populateAndShow(final BubbleTextView originalIcon, final List<String> shortcutIds,
             final List<NotificationKeyData> notificationKeys) {
         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);
+        final int arrowWidth = resources.getDimensionPixelSize(R.dimen.popup_arrow_width);
+        final int arrowHeight = resources.getDimensionPixelSize(R.dimen.popup_arrow_height);
         final int arrowHorizontalOffset = resources.getDimensionPixelSize(
-                R.dimen.deep_shortcuts_arrow_horizontal_offset);
+                R.dimen.popup_arrow_horizontal_offset);
         final int arrowVerticalOffset = resources.getDimensionPixelSize(
-                R.dimen.deep_shortcuts_arrow_vertical_offset);
+                R.dimen.popup_arrow_vertical_offset);
 
         // Add dummy views first, and populate with real info when ready.
         PopupPopulator.Item[] itemsToPopulate = PopupPopulator
@@ -191,11 +193,11 @@
                 : mShortcutsItemView.getDeepShortcutViews(reverseOrder);
         List<View> systemShortcutViews = mShortcutsItemView == null
                 ? Collections.EMPTY_LIST
-                : mShortcutsItemView.getSystemShortcutViews(reverseOrder);
+                : mShortcutsItemView.getSystemShortcutViews(reverseOrder || true);
         if (mNotificationItemView != null) {
             BadgeInfo badgeInfo = mLauncher.getPopupDataProvider()
                     .getBadgeInfoForItem(originalItemInfo);
-            updateNotificationHeader(badgeInfo);
+            updateNotificationHeader(badgeInfo, originalIcon);
         }
 
         // Add the arrow.
@@ -247,7 +249,7 @@
                             R.layout.shortcuts_item, this, false);
                     addView(mShortcutsItemView);
                 }
-                mShortcutsItemView.addShortcutView(item, itemTypeToPopulate, mIsAboveIcon);
+                mShortcutsItemView.addShortcutView(item, itemTypeToPopulate);
                 if (shouldAddBottomMargin) {
                     ((LayoutParams) mShortcutsItemView.getLayoutParams()).bottomMargin = spacing;
                 }
@@ -384,14 +386,14 @@
             // 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);
+                    R.dimen.popup_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);
+                    R.dimen.popup_padding_end);
             xOffset = iconWidth / 2 - shortcutDragHandleWidth / 2 - shortcutPaddingEnd;
         }
         x += mIsLeftAligned ? xOffset : -xOffset;
@@ -548,12 +550,15 @@
         if (originalItemInfo != mOriginalIcon.getTag()) {
             return;
         }
-        updateNotificationHeader(badgeInfo);
+        updateNotificationHeader(badgeInfo, mOriginalIcon);
     }
 
-    private void updateNotificationHeader(BadgeInfo badgeInfo) {
+    private void updateNotificationHeader(BadgeInfo badgeInfo, BubbleTextView originalIcon) {
         if (mNotificationItemView != null && badgeInfo != null) {
-            mNotificationItemView.updateHeader(badgeInfo.getNotificationCount());
+            IconPalette palette = originalIcon.getIcon() instanceof FastBitmapDrawable
+                    ? ((FastBitmapDrawable) originalIcon.getIcon()).getIconPalette()
+                    : null;
+            mNotificationItemView.updateHeader(badgeInfo.getNotificationCount(), palette);
         }
     }
 
diff --git a/src/com/android/launcher3/popup/PopupPopulator.java b/src/com/android/launcher3/popup/PopupPopulator.java
index d26d306..6349819 100644
--- a/src/com/android/launcher3/popup/PopupPopulator.java
+++ b/src/com/android/launcher3/popup/PopupPopulator.java
@@ -54,6 +54,7 @@
 
     public static final int MAX_ITEMS = 4;
     @VisibleForTesting static final int NUM_DYNAMIC = 2;
+    private static final int MAX_SHORTCUTS_IF_NOTIFICATIONS = 2;
 
     public enum Item {
         SHORTCUT(R.layout.deep_shortcut, true),
@@ -74,7 +75,11 @@
             @NonNull List<NotificationKeyData> notificationKeys) {
         boolean hasNotifications = notificationKeys.size() > 0;
         int numNotificationItems = hasNotifications ? 1 : 0;
-        int numItems = Math.min(MAX_ITEMS, shortcutIds.size() + numNotificationItems)
+        int numShortcuts = shortcutIds.size();
+        if (hasNotifications && numShortcuts > MAX_SHORTCUTS_IF_NOTIFICATIONS) {
+            numShortcuts = MAX_SHORTCUTS_IF_NOTIFICATIONS;
+        }
+        int numItems = Math.min(MAX_ITEMS, numShortcuts + numNotificationItems)
                 + PopupDataProvider.SYSTEM_SHORTCUTS.length;
         Item[] items = new Item[numItems];
         for (int i = 0; i < numItems; i++) {
diff --git a/src/com/android/launcher3/shortcuts/DeepShortcutTextView.java b/src/com/android/launcher3/shortcuts/DeepShortcutTextView.java
index 42086fc..1a5297d 100644
--- a/src/com/android/launcher3/shortcuts/DeepShortcutTextView.java
+++ b/src/com/android/launcher3/shortcuts/DeepShortcutTextView.java
@@ -47,7 +47,7 @@
         super(context, attrs, defStyle);
 
         Resources resources = getResources();
-        mDragHandleWidth = resources.getDimensionPixelSize(R.dimen.deep_shortcut_padding_end)
+        mDragHandleWidth = resources.getDimensionPixelSize(R.dimen.popup_padding_end)
                 + resources.getDimensionPixelSize(R.dimen.deep_shortcut_drag_handle_size)
                 + resources.getDimensionPixelSize(R.dimen.deep_shortcut_drawable_padding) / 2;
     }
diff --git a/src/com/android/launcher3/shortcuts/ShortcutsItemView.java b/src/com/android/launcher3/shortcuts/ShortcutsItemView.java
index 2255007..ef6365b 100644
--- a/src/com/android/launcher3/shortcuts/ShortcutsItemView.java
+++ b/src/com/android/launcher3/shortcuts/ShortcutsItemView.java
@@ -118,8 +118,7 @@
         return false;
     }
 
-    public void addShortcutView(View shortcutView, PopupPopulator.Item shortcutType,
-            boolean isAboveIcon) {
+    public void addShortcutView(View shortcutView, PopupPopulator.Item shortcutType) {
         if (shortcutType == PopupPopulator.Item.SHORTCUT) {
             mDeepShortcutViews.add((DeepShortcutView) shortcutView);
         } else {
@@ -130,11 +129,7 @@
             if (mSystemShortcutIcons == null) {
                 mSystemShortcutIcons = (LinearLayout) mLauncher.getLayoutInflater().inflate(
                         R.layout.system_shortcut_icons, mShortcutsLayout, false);
-                if (isAboveIcon) {
-                    mShortcutsLayout.addView(mSystemShortcutIcons, 0);
-                } else {
-                    mShortcutsLayout.addView(mSystemShortcutIcons);
-                }
+                mShortcutsLayout.addView(mSystemShortcutIcons, 0);
             }
             mSystemShortcutIcons.addView(shortcutView);
         } else {