diff options
author | Tony Wickham <twickham@google.com> | 2017-04-10 14:05:34 -0700 |
---|---|---|
committer | Tony Wickham <twickham@google.com> | 2017-04-11 16:44:38 -0700 |
commit | ce44516dd869dff1d6a744e26625a662d9567a10 (patch) | |
tree | 9bdca8838804fefb913d73fcf92d62883a3699cc /src/com/android/launcher3 | |
parent | cd4cc97f6f761b8cc377821a2214432a376dd4f8 (diff) | |
download | android_packages_apps_Trebuchet-ce44516dd869dff1d6a744e26625a662d9567a10.tar.gz android_packages_apps_Trebuchet-ce44516dd869dff1d6a744e26625a662d9567a10.tar.bz2 android_packages_apps_Trebuchet-ce44516dd869dff1d6a744e26625a662d9567a10.zip |
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
Diffstat (limited to 'src/com/android/launcher3')
7 files changed, 44 insertions, 85 deletions
diff --git a/src/com/android/launcher3/FastBitmapDrawable.java b/src/com/android/launcher3/FastBitmapDrawable.java index 5a44f7504..be3ba9014 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 e70b48949..000000000 --- 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 37b8325ea..5e8e2c768 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 b92814fab..99c7e754c 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<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 @@ public class PopupContainerWithArrow extends AbstractFloatingView implements Dra : 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 @@ 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 d26d3062b..6349819a5 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<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 42086fcb5..1a5297dc7 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 2255007d3..ef6365b63 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 { |