OSDN Git Service

Fixed an issue where icons were jumping
authorSelim Cinek <cinek@google.com>
Tue, 1 Aug 2017 00:47:45 +0000 (17:47 -0700)
committerSelim Cinek <cinek@google.com>
Tue, 1 Aug 2017 22:24:48 +0000 (22:24 +0000)
Because width and height are different for icons on
some devices, the animation could jump unfortunately.
This was mainly introduced since we changed the
statusbar height.

Test: observe icon animations (Especially on last notification)
Change-Id: Iee4f63467895045146c92d68eb4f9ca8a38d943a
Fixes: 64008528

packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java

index 1889806..30cdb9d 100644 (file)
@@ -70,6 +70,7 @@ public class NotificationShelf extends ActivatableNotificationView implements
     private boolean mHasItemsInStableShelf;
     private NotificationIconContainer mCollapsedIcons;
     private int mScrollFastThreshold;
+    private int mIconSize;
     private int mStatusBarState;
     private float mMaxShelfEnd;
     private int mRelativeOffset;
@@ -120,6 +121,7 @@ public class NotificationShelf extends ActivatableNotificationView implements
         mShelfIcons.setPadding(padding, 0, padding, 0);
         mScrollFastThreshold = res.getDimensionPixelOffset(R.dimen.scroll_fast_threshold);
         mShowNotificationShelf = res.getBoolean(R.bool.config_showNotificationShelf);
+        mIconSize = res.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_icon_size);
 
         if (!mShowNotificationShelf) {
             setVisibility(GONE);
@@ -486,12 +488,12 @@ public class NotificationShelf extends ActivatableNotificationView implements
         }
         notificationIconPosition += iconTopPadding;
         float shelfIconPosition = getTranslationY() + icon.getTop();
-        shelfIconPosition += ((1.0f - icon.getIconScale()) * icon.getHeight()) / 2.0f;
+        shelfIconPosition += (icon.getHeight() - icon.getIconScale() * mIconSize) / 2.0f;
         float iconYTranslation = NotificationUtils.interpolate(
                 notificationIconPosition - shelfIconPosition,
                 0,
                 transitionAmount);
-        float shelfIconSize = icon.getHeight() * icon.getIconScale();
+        float shelfIconSize = mIconSize * icon.getIconScale();
         float alpha = 1.0f;
         boolean noIcon = !row.isShowingIcon();
         if (noIcon) {
@@ -503,7 +505,7 @@ public class NotificationShelf extends ActivatableNotificationView implements
         float newSize = NotificationUtils.interpolate(notificationIconSize, shelfIconSize,
                 transitionAmount);
         if (iconState != null) {
-            iconState.scaleX = newSize / icon.getHeight() / icon.getIconScale();
+            iconState.scaleX = newSize / shelfIconSize;
             iconState.scaleY = iconState.scaleX;
             iconState.hidden = transitionAmount == 0.0f && !iconState.isAnimating(icon);
             boolean isAppearing = row.isDrawingAppearAnimation() && !row.isInShelf();