diff --git a/res/layout/deep_shortcut.xml b/res/layout/deep_shortcut.xml index 60131e4fbd..7744906bcb 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" /> - - - + + diff --git a/res/layout/system_shortcut.xml b/res/layout/system_shortcut.xml index 3baddc480e..113b1bed15 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" /> + 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 bf0a2512a9..9dc56e41da 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 028c982064..3ce7baae22 100644 --- a/res/values/colors.xml +++ b/res/values/colors.xml @@ -37,12 +37,13 @@ #757575 - #F5F5F5 + #EEEEEE #FFF #E0E0E0 @color/notification_color_beneath - #E0E0E0 @android:color/tertiary_text_light + + #E0E0E0 diff --git a/res/values/dimens.xml b/res/values/dimens.xml index 7b1d247205..0b6100f52f 100644 --- a/res/values/dimens.xml +++ b/res/values/dimens.xml @@ -151,51 +151,57 @@ 9dp 208dp - 48dp + 56dp 4dp 6dp 16dp 36dp - 6dp - 16dp 8dp - 5dp 16dp - 10dp - 8dp - -2dp - + 6dp + 16dp + 10dp + 8dp + -2dp + - 19dp + popup_padding_end + deep_shortcut_drag_handle_size / 2 also equals 24dp--> + 24dp + + 19dp 158dp - 28dp - 10dp + 24dp + + 12dp + 40dp + 48dp + + 12dp 24dp 12dp 0dp 3dp - 24dp - 18dp 12dp - 12dp - + 16dp + 12dp + 15dp - 8dp 32dp - 60dp - @dimen/bg_popup_item_height - 12dp - 14dp - - 40dp + 80dp + 32dp + 13sp + 12sp + 15sp + 24dp + 18dp + + 52dp 2dp 18dp diff --git a/res/values/strings.xml b/res/values/strings.xml index 0461e4a021..eddae621ec 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -67,15 +67,9 @@ Search for more apps - - - +%1$d + - - Notification - Notifications - + Notifications diff --git a/src/com/android/launcher3/FastBitmapDrawable.java b/src/com/android/launcher3/FastBitmapDrawable.java index 5a44f75041..be3ba90145 100644 --- a/src/com/android/launcher3/FastBitmapDrawable.java +++ b/src/com/android/launcher3/FastBitmapDrawable.java @@ -167,7 +167,7 @@ public class FastBitmapDrawable extends Drawable { } } - 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 e70b489490..0000000000 --- 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 37b8325ea5..5e8e2c7683 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 @@ public class NotificationItemView extends PopupItemView implements LogContainerP 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 @@ public class NotificationItemView extends PopupItemView implements LogContainerP @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 @@ public class NotificationItemView extends PopupItemView implements LogContainerP 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 b92814fab2..99c7e754c1 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.AbstractFloatingView; 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.badge.BadgeInfo; 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 class PopupContainerWithArrow extends AbstractFloatingView implements Dra public void populateAndShow(final BubbleTextView originalIcon, final List shortcutIds, final List 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 @@ public class PopupContainerWithArrow extends AbstractFloatingView implements Dra : mShortcutsItemView.getDeepShortcutViews(reverseOrder); List 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 @@ public class PopupContainerWithArrow extends AbstractFloatingView implements Dra 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 @@ public class PopupContainerWithArrow extends AbstractFloatingView implements Dra // 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 @@ public class PopupContainerWithArrow extends AbstractFloatingView implements Dra 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 d26d3062b4..6349819a5e 100644 --- a/src/com/android/launcher3/popup/PopupPopulator.java +++ b/src/com/android/launcher3/popup/PopupPopulator.java @@ -54,6 +54,7 @@ public class PopupPopulator { 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 @@ public class PopupPopulator { @NonNull List 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 42086fcb5c..1a5297dc72 100644 --- a/src/com/android/launcher3/shortcuts/DeepShortcutTextView.java +++ b/src/com/android/launcher3/shortcuts/DeepShortcutTextView.java @@ -47,7 +47,7 @@ public class DeepShortcutTextView extends BubbleTextView { 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 2255007d37..ef6365b632 100644 --- a/src/com/android/launcher3/shortcuts/ShortcutsItemView.java +++ b/src/com/android/launcher3/shortcuts/ShortcutsItemView.java @@ -118,8 +118,7 @@ public class ShortcutsItemView extends PopupItemView implements View.OnLongClick 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 @@ public class ShortcutsItemView extends PopupItemView implements View.OnLongClick 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 {