Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 798d1f83 authored by Evan Laird's avatar Evan Laird
Browse files

Don't animate status icons when the container changes size

If an icon doesn't change position relative to the view end, don't
bother animating the X translation. Otherwise we get wonky in-between
states

Test: Visual
Fixes: 132288484
Change-Id: I131bf38627a941efb1af84f2aec7c3e0391947e8
parent a7423ca9
Loading
Loading
Loading
Loading
+13 −1
Original line number Original line Diff line number Diff line
@@ -369,8 +369,18 @@ public class StatusIconContainer extends AlphaOptimizedLinearLayout {
        public int visibleState = STATE_ICON;
        public int visibleState = STATE_ICON;
        public boolean justAdded = true;
        public boolean justAdded = true;


        // How far we are from the end of the view actually is the most relevant for animation
        float distanceToViewEnd = -1;

        @Override
        @Override
        public void applyToView(View view) {
        public void applyToView(View view) {
            float parentWidth = 0;
            if (view.getParent() instanceof View) {
                parentWidth = ((View) view.getParent()).getWidth();
            }

            float currentDistanceToEnd = parentWidth - xTranslation;

            if (!(view instanceof StatusIconDisplayable)) {
            if (!(view instanceof StatusIconDisplayable)) {
                return;
                return;
            }
            }
@@ -394,7 +404,7 @@ public class StatusIconContainer extends AlphaOptimizedLinearLayout {
                    // all other transitions (to/from dot, etc)
                    // all other transitions (to/from dot, etc)
                    animationProperties = ANIMATE_ALL_PROPERTIES;
                    animationProperties = ANIMATE_ALL_PROPERTIES;
                }
                }
            } else if (visibleState != STATE_HIDDEN && xTranslation != view.getTranslationX()) {
            } else if (visibleState != STATE_HIDDEN && distanceToViewEnd != currentDistanceToEnd) {
                // Visibility isn't changing, just animate position
                // Visibility isn't changing, just animate position
                animationProperties = X_ANIMATION_PROPERTIES;
                animationProperties = X_ANIMATION_PROPERTIES;
            }
            }
@@ -407,6 +417,8 @@ public class StatusIconContainer extends AlphaOptimizedLinearLayout {
            }
            }


            justAdded = false;
            justAdded = false;
            distanceToViewEnd = currentDistanceToEnd;

        }
        }
    }
    }