From 15475702edd8f7f5643fa701e9e55d02e7fb7d97 Mon Sep 17 00:00:00 2001 From: Lucas Dupin Date: Wed, 4 Apr 2018 14:32:53 -0700 Subject: [PATCH] Shelf horizontal alignment was a few dps off Also interpolating anti burn in offset instead of setting it. Test: visual Change-Id: Ib9248a89eaf8a8905f8d462cb8ded574975372a7 Fixes: 77541088 --- .../phone/NotificationIconContainer.java | 22 ++++++++++++++++--- .../stack/NotificationStackScrollLayout.java | 4 ++-- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconContainer.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconContainer.java index 55174349cc537..9adf923fa5060 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconContainer.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconContainer.java @@ -151,6 +151,7 @@ public class NotificationIconContainer extends AlphaOptimizedFrameLayout { private ArrayMap> mReplacingIcons; // Keep track of the last visible icon so collapsed container can report on its location private IconState mLastVisibleIconState; + private IconState mFirstVisibleIconState; private float mVisualOverflowStart; // Keep track of overflow in range [0, 3] private int mNumDots; @@ -159,7 +160,6 @@ public class NotificationIconContainer extends AlphaOptimizedFrameLayout { private int[] mAbsolutePosition = new int[2]; private View mIsolatedIconForAnimation; - public NotificationIconContainer(Context context, AttributeSet attrs) { super(context, attrs); initDimens(); @@ -192,10 +192,15 @@ public class NotificationIconContainer extends AlphaOptimizedFrameLayout { paint.setColor(Color.BLUE); canvas.drawLine(end, 0, end, height, paint); - paint.setColor(Color.BLACK); + paint.setColor(Color.GREEN); int lastIcon = (int) mLastVisibleIconState.xTranslation; canvas.drawLine(lastIcon, 0, lastIcon, height, paint); + if (mFirstVisibleIconState != null) { + int firstIcon = (int) mFirstVisibleIconState.xTranslation; + canvas.drawLine(firstIcon, 0, firstIcon, height, paint); + } + paint.setColor(Color.RED); canvas.drawLine(mVisualOverflowStart, 0, mVisualOverflowStart, height, paint); @@ -210,6 +215,7 @@ public class NotificationIconContainer extends AlphaOptimizedFrameLayout { super.onConfigurationChanged(newConfig); initDimens(); } + @Override protected void onLayout(boolean changed, int l, int t, int r, int b) { float centerY = getHeight() / 2.0f; @@ -395,6 +401,7 @@ public class NotificationIconContainer extends AlphaOptimizedFrameLayout { mNumDots = 0; if (firstOverflowIndex != -1) { translationX = mVisualOverflowStart; + mFirstVisibleIconState = null; for (int i = firstOverflowIndex; i < childCount; i++) { View view = getChildAt(i); IconState iconState = mIconStates.get(view); @@ -409,6 +416,9 @@ public class NotificationIconContainer extends AlphaOptimizedFrameLayout { } translationX += (mNumDots == MAX_DOTS ? MAX_DOTS * dotWidth : dotWidth) * iconState.iconAppearAmount; + if (mFirstVisibleIconState == null) { + mFirstVisibleIconState = iconState; + } mLastVisibleIconState = iconState; } else { iconState.visibleState = StatusBarIconView.STATE_HIDDEN; @@ -417,10 +427,16 @@ public class NotificationIconContainer extends AlphaOptimizedFrameLayout { } else if (childCount > 0) { View lastChild = getChildAt(childCount - 1); mLastVisibleIconState = mIconStates.get(lastChild); + mFirstVisibleIconState = mIconStates.get(getChildAt(0)); } boolean center = mDark; if (center && translationX < getLayoutEnd()) { - float delta = (getLayoutEnd() - translationX) / 2; + float initialTranslation = + mFirstVisibleIconState == null ? 0 : mFirstVisibleIconState.xTranslation; + float contentWidth = getFinalTranslationX() - initialTranslation; + float availableSpace = getLayoutEnd() - getActualPaddingStart(); + float delta = (availableSpace - contentWidth) / 2; + if (firstOverflowIndex != -1) { // If we have an overflow, only count those half for centering because the dots // don't have a lot of visual weight. diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java index 375e8606258f9..da7dc07b2bfb3 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java @@ -3922,12 +3922,11 @@ public class NotificationStackScrollLayout extends ViewGroup requestChildrenUpdate(); applyCurrentBackgroundBounds(); updateWillNotDraw(); - updateAntiBurnInTranslation(); notifyHeightChangeListener(mShelf); } private void updateAntiBurnInTranslation() { - setTranslationX(mAmbientState.isDark() ? mAntiBurnInOffsetX : 0); + setTranslationX(mAntiBurnInOffsetX * mDarkAmount); } /** @@ -3948,6 +3947,7 @@ public class NotificationStackScrollLayout extends ViewGroup updateContentHeight(); } updateBackgroundDimming(); + updateAntiBurnInTranslation(); } public float getDarkAmount() {