From 0b8a6fe53240f8c8271efed0fc470a65553707de Mon Sep 17 00:00:00 2001 From: Tony Date: Tue, 9 May 2017 19:23:47 -0500 Subject: [PATCH] Visual updates for popup - Update some dimens - Increase left padding for shortcuts - Adjust arrow and notification ellipsis offset accordingly - Align shortcut dividers to be same width as text - Notification text 14sp instead of 15sp - Increase width of popup by 12dp - Shortcuts text 87% black instead of 54% - Arrow has same color as attached side, so takes on header gray instead of white when appropriate Bug: 37753827 Change-Id: I0844b85995f22218a3b7e605e1653cceaed6cda1 --- res/layout/deep_shortcut.xml | 3 +- res/layout/notification.xml | 4 +-- res/layout/notification_footer.xml | 2 +- res/layout/notification_main.xml | 2 +- res/layout/system_shortcut.xml | 3 +- res/layout/system_shortcut_icons.xml | 2 +- res/values/colors.xml | 7 ++-- res/values/dimens.xml | 32 +++++++++++-------- .../notification/NotificationItemView.java | 10 +++++- .../popup/PopupContainerWithArrow.java | 12 ++++--- .../launcher3/popup/PopupItemView.java | 14 ++++++-- .../shortcuts/ShortcutsItemView.java | 9 ++++++ 12 files changed, 67 insertions(+), 33 deletions(-) diff --git a/res/layout/deep_shortcut.xml b/res/layout/deep_shortcut.xml index 7744906bcb..85caba4a0b 100644 --- a/res/layout/deep_shortcut.xml +++ b/res/layout/deep_shortcut.xml @@ -26,11 +26,12 @@ android:background="?android:attr/selectableItemBackground" android:gravity="start|center_vertical" android:textAlignment="viewStart" - android:paddingStart="@dimen/bg_popup_item_height" + android:paddingStart="@dimen/deep_shortcuts_text_padding_start" android:paddingEnd="@dimen/popup_padding_end" android:drawableEnd="@drawable/deep_shortcuts_drag_handle" android:drawablePadding="@dimen/deep_shortcut_drawable_padding" android:textSize="14sp" + android:textColor="?android:attr/textColorPrimary" android:fontFamily="sans-serif" launcher:layoutHorizontal="true" launcher:iconDisplay="shortcut_popup" diff --git a/res/layout/notification.xml b/res/layout/notification.xml index 4250e1e545..f955c6b803 100644 --- a/res/layout/notification.xml +++ b/res/layout/notification.xml @@ -35,7 +35,7 @@ android:layout_height="@dimen/notification_header_height" android:paddingStart="@dimen/notification_padding_start" android:paddingEnd="@dimen/notification_padding_end" - android:background="@color/notification_header_background_color" + android:background="@color/popup_header_background_color" android:elevation="@dimen/notification_elevation"> + android:background="@color/popup_background_color"> diff --git a/res/layout/system_shortcut_icons.xml b/res/layout/system_shortcut_icons.xml index 9dc56e41da..676be8e694 100644 --- a/res/layout/system_shortcut_icons.xml +++ b/res/layout/system_shortcut_icons.xml @@ -21,4 +21,4 @@ android:layout_height="@dimen/system_shortcut_header_height" android:orientation="horizontal" android:gravity="end|center_vertical" - android:background="@color/notification_header_background_color" /> + android:background="@color/popup_header_background_color" /> diff --git a/res/values/colors.xml b/res/values/colors.xml index f148cf2a57..58717c273e 100644 --- a/res/values/colors.xml +++ b/res/values/colors.xml @@ -35,12 +35,11 @@ #40FFFFFF #FFF - + + #EEEEEE + #FFF #757575 - #EEEEEE - #FFF #E0E0E0 - @color/notification_color_beneath @android:color/tertiary_text_light diff --git a/res/values/dimens.xml b/res/values/dimens.xml index ca74f15afa..bd6466b462 100644 --- a/res/values/dimens.xml +++ b/res/values/dimens.xml @@ -150,7 +150,7 @@ 9dp - 208dp + 220dp 56dp 4dp 6dp @@ -159,23 +159,27 @@ 36dp 8dp 16dp - 6dp + 10dp 16dp 10dp 8dp -2dp - - 24dp - - 19dp + 28dp + + 24dp + + 23dp + + 19dp 2dp - - 158dp + + 56dp + + 164dp 24dp - - 12dp + + 16dp 40dp 48dp @@ -196,15 +200,15 @@ 32dp 13sp 12sp - 15sp + 14sp 24dp 18dp 52dp 2dp 18dp - - 15dp + + 19dp 0.5dp 70dp diff --git a/src/com/android/launcher3/notification/NotificationItemView.java b/src/com/android/launcher3/notification/NotificationItemView.java index e5bf35a1e3..dd272b3bc2 100644 --- a/src/com/android/launcher3/notification/NotificationItemView.java +++ b/src/com/android/launcher3/notification/NotificationItemView.java @@ -21,6 +21,7 @@ import android.app.Notification; import android.content.Context; import android.graphics.Rect; import android.support.annotation.Nullable; +import android.support.v4.content.ContextCompat; import android.util.AttributeSet; import android.view.MotionEvent; import android.view.View; @@ -93,7 +94,7 @@ public class NotificationItemView extends PopupItemView implements LogContainerP if (mNotificationHeaderTextColor == Notification.COLOR_DEFAULT) { mNotificationHeaderTextColor = IconPalette.resolveContrastColor(getContext(), palette.dominantColor, - getResources().getColor(R.color.notification_header_background_color)); + getResources().getColor(R.color.popup_header_background_color)); } mHeaderCount.setTextColor(mNotificationHeaderTextColor); } @@ -157,6 +158,13 @@ public class NotificationItemView extends PopupItemView implements LogContainerP } } + @Override + public int getArrowColor(boolean isArrowAttachedToBottom) { + return ContextCompat.getColor(getContext(), isArrowAttachedToBottom + ? R.color.popup_background_color + : R.color.popup_header_background_color); + } + @Override public void fillInLogContainerData(View v, ItemInfo info, LauncherLogProto.Target target, LauncherLogProto.Target targetParent) { diff --git a/src/com/android/launcher3/popup/PopupContainerWithArrow.java b/src/com/android/launcher3/popup/PopupContainerWithArrow.java index fb7f80cebb..d4ee3b8cba 100644 --- a/src/com/android/launcher3/popup/PopupContainerWithArrow.java +++ b/src/com/android/launcher3/popup/PopupContainerWithArrow.java @@ -25,7 +25,6 @@ import android.animation.ValueAnimator; import android.annotation.TargetApi; import android.content.Context; import android.content.res.Resources; -import android.graphics.Color; import android.graphics.CornerPathEffect; import android.graphics.Paint; import android.graphics.PointF; @@ -169,8 +168,6 @@ public class PopupContainerWithArrow extends AbstractFloatingView implements Dra final Resources resources = getResources(); 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.popup_arrow_horizontal_offset); final int arrowVerticalOffset = resources.getDimensionPixelSize( R.dimen.popup_arrow_vertical_offset); @@ -208,6 +205,9 @@ public class PopupContainerWithArrow extends AbstractFloatingView implements Dra } // Add the arrow. + final int arrowHorizontalOffset = resources.getDimensionPixelSize(isAlignedWithStart() ? + R.dimen.popup_arrow_horizontal_offset_start : + R.dimen.popup_arrow_horizontal_offset_end); mArrow = addArrowView(arrowHorizontalOffset, arrowVerticalOffset, arrowWidth, arrowHeight); mArrow.setPivotX(arrowWidth / 2); mArrow.setPivotY(mIsAboveIcon ? 0 : arrowHeight); @@ -493,7 +493,11 @@ public class PopupContainerWithArrow extends AbstractFloatingView implements Dra ShapeDrawable arrowDrawable = new ShapeDrawable(TriangleShape.create( width, height, !mIsAboveIcon)); Paint arrowPaint = arrowDrawable.getPaint(); - arrowPaint.setColor(Color.WHITE); + // Note that we have to use getChildAt() instead of getItemViewAt(), + // since the latter expects the arrow which hasn't been added yet. + PopupItemView itemAttachedToArrow = (PopupItemView) + (getChildAt(mIsAboveIcon ? getChildCount() - 1 : 0)); + arrowPaint.setColor(itemAttachedToArrow.getArrowColor(mIsAboveIcon)); // The corner path effect won't be reflected in the shadow, but shouldn't be noticeable. int radius = getResources().getDimensionPixelSize(R.dimen.popup_arrow_corner_radius); arrowPaint.setPathEffect(new CornerPathEffect(radius)); diff --git a/src/com/android/launcher3/popup/PopupItemView.java b/src/com/android/launcher3/popup/PopupItemView.java index a18f650c16..384f554e15 100644 --- a/src/com/android/launcher3/popup/PopupItemView.java +++ b/src/com/android/launcher3/popup/PopupItemView.java @@ -48,7 +48,7 @@ public abstract class PopupItemView extends FrameLayout protected final Rect mPillRect; private float mOpenAnimationProgress; - + protected final boolean mIsRtl; protected View mIconView; private final Paint mBackgroundClipPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG); @@ -75,6 +75,8 @@ public abstract class PopupItemView extends FrameLayout canvas.setBitmap(mRoundedCornerBitmap); canvas.drawArc(0, 0, radius*2, radius*2, 180, 90, true, mBackgroundClipPaint); mBackgroundClipPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_IN)); + + mIsRtl = Utilities.isRtl(getResources()); } @Override @@ -120,7 +122,9 @@ public abstract class PopupItemView extends FrameLayout */ public Animator createOpenAnimation(boolean isContainerAboveIcon, boolean pivotLeft) { Point center = getIconCenter(); - int arrowCenter = getResources().getDimensionPixelSize(R.dimen.popup_arrow_horizontal_center); + int arrowCenter = getResources().getDimensionPixelSize(pivotLeft ^ mIsRtl ? + R.dimen.popup_arrow_horizontal_center_start: + R.dimen.popup_arrow_horizontal_center_end); ValueAnimator openAnimator = new ZoomRevealOutlineProvider(center.x, center.y, mPillRect, this, mIconView, isContainerAboveIcon, pivotLeft, arrowCenter) .createRevealAnimator(this, false); @@ -144,7 +148,9 @@ public abstract class PopupItemView extends FrameLayout public Animator createCloseAnimation(boolean isContainerAboveIcon, boolean pivotLeft, long duration) { Point center = getIconCenter(); - int arrowCenter = getResources().getDimensionPixelSize(R.dimen.popup_arrow_horizontal_center); + int arrowCenter = getResources().getDimensionPixelSize(pivotLeft ^ mIsRtl ? + R.dimen.popup_arrow_horizontal_center_start : + R.dimen.popup_arrow_horizontal_center_end); ValueAnimator closeAnimator = new ZoomRevealOutlineProvider(center.x, center.y, mPillRect, this, mIconView, isContainerAboveIcon, pivotLeft, arrowCenter) .createRevealAnimator(this, true); @@ -177,6 +183,8 @@ public abstract class PopupItemView extends FrameLayout return getResources().getDimensionPixelSize(R.dimen.bg_round_rect_radius); } + public abstract int getArrowColor(boolean isArrowAttachedToBottom); + /** * Extension of {@link PillRevealOutlineProvider} which scales the icon based on the height. */ diff --git a/src/com/android/launcher3/shortcuts/ShortcutsItemView.java b/src/com/android/launcher3/shortcuts/ShortcutsItemView.java index ee64b984a7..28f3963c2c 100644 --- a/src/com/android/launcher3/shortcuts/ShortcutsItemView.java +++ b/src/com/android/launcher3/shortcuts/ShortcutsItemView.java @@ -20,6 +20,7 @@ import android.animation.Animator; import android.animation.AnimatorSet; import android.content.Context; import android.graphics.Point; +import android.support.v4.content.ContextCompat; import android.util.AttributeSet; import android.view.MotionEvent; import android.view.View; @@ -245,6 +246,14 @@ public class ShortcutsItemView extends PopupItemView implements View.OnLongClick return closeAnimation; } + @Override + public int getArrowColor(boolean isArrowAttachedToBottom) { + return ContextCompat.getColor(getContext(), + isArrowAttachedToBottom || mSystemShortcutIcons == null + ? R.color.popup_background_color + : R.color.popup_header_background_color); + } + @Override public void fillInLogContainerData(View v, ItemInfo info, LauncherLogProto.Target target, LauncherLogProto.Target targetParent) {