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

Commit 09bd29da authored by Selim Cinek's avatar Selim Cinek
Browse files

Disabling animations now when the screen is off

Before, notifications were animating weirdly when the
Keyboard was shown, this should not happen anymore.

Test: add notifications, go to keyboard
Change-Id: If0edccf84bdd09be99eaeae2dceee8e29f30ae12
Fixes: 34471382
parent edebced7
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -68,6 +68,7 @@ public class NotificationShelf extends ActivatableNotificationView {
    private float mMaxShelfEnd;
    private int mRelativeOffset;
    private boolean mInteractive;
    private boolean mAnimationsEnabled = true;

    public NotificationShelf(Context context, AttributeSet attrs) {
        super(context, attrs);
@@ -574,6 +575,15 @@ public class NotificationShelf extends ActivatableNotificationView {
        mMaxShelfEnd = maxShelfEnd;
    }

    public void setAnimationsEnabled(boolean enabled) {
        mAnimationsEnabled = enabled;
        mCollapsedIcons.setAnimationsEnabled(enabled);
        if (!enabled) {
            // we need to wait with enabling the animations until the first frame has passed
            mShelfIcons.setAnimationsEnabled(false);
        }
    }

    private class ShelfState extends ExpandableViewState {
        private float openedAmount;
        private boolean hasItemsInStableShelf;
@@ -586,6 +596,7 @@ public class NotificationShelf extends ActivatableNotificationView {
            setOpenedAmount(openedAmount);
            updateAppearance();
            setHasItemsInStableShelf(hasItemsInStableShelf);
            mShelfIcons.setAnimationsEnabled(mAnimationsEnabled);
        }

        @Override
@@ -595,6 +606,7 @@ public class NotificationShelf extends ActivatableNotificationView {
            setOpenedAmount(openedAmount);
            updateAppearance();
            setHasItemsInStableShelf(hasItemsInStableShelf);
            mShelfIcons.setAnimationsEnabled(mAnimationsEnabled);
        }
    }
}
+63 −43
Original line number Diff line number Diff line
@@ -104,6 +104,7 @@ public class NotificationIconContainer extends AlphaOptimizedFrameLayout {
    private float mOpenedAmount = 0.0f;
    private float mVisualOverflowAdaption;
    private boolean mDisallowNextAnimation;
    private boolean mAnimationsEnabled = true;

    public NotificationIconContainer(Context context, AttributeSet attrs) {
        super(context, attrs);
@@ -422,6 +423,20 @@ public class NotificationIconContainer extends AlphaOptimizedFrameLayout {
        return mIconSize;
    }

    public void setAnimationsEnabled(boolean enabled) {
        if (!enabled && mAnimationsEnabled) {
            for (int i = 0; i < getChildCount(); i++) {
                View child = getChildAt(i);
                ViewState childState = mIconStates.get(child);
                if (childState != null) {
                    childState.cancelAnimations(child);
                    childState.applyToView(child);
                }
            }
        }
        mAnimationsEnabled = enabled;
    }

    public class IconState extends ViewState {
        public float iconAppearAmount = 1.0f;
        public float clampedAppearAmount = 1.0f;
@@ -438,11 +453,14 @@ public class NotificationIconContainer extends AlphaOptimizedFrameLayout {
                StatusBarIconView icon = (StatusBarIconView) view;
                boolean animate = false;
                AnimationProperties animationProperties = null;
                boolean animationsAllowed = mAnimationsEnabled && !mDisallowNextAnimation;
                if (animationsAllowed) {
                    if (justAdded) {
                        super.applyToView(icon);
                        if (iconAppearAmount != 0.0f) {
                            icon.setAlpha(0.0f);
                        icon.setVisibleState(StatusBarIconView.STATE_HIDDEN, false /* animate */);
                            icon.setVisibleState(StatusBarIconView.STATE_HIDDEN,
                                    false /* animate */);
                            animationProperties = ADD_ICON_PROPERTIES;
                            animate = true;
                        }
@@ -460,7 +478,8 @@ public class NotificationIconContainer extends AlphaOptimizedFrameLayout {
                    if (needsCannedAnimation) {
                        AnimationFilter animationFilter = mTempProperties.getAnimationFilter();
                        animationFilter.reset();
                    animationFilter.combineFilter(ICON_ANIMATION_PROPERTIES.getAnimationFilter());
                        animationFilter.combineFilter(
                                ICON_ANIMATION_PROPERTIES.getAnimationFilter());
                        mTempProperties.resetCustomInterpolators();
                        mTempProperties.combineCustomInterpolators(ICON_ANIMATION_PROPERTIES);
                        if (animationProperties != null) {
@@ -484,8 +503,9 @@ public class NotificationIconContainer extends AlphaOptimizedFrameLayout {
                        animationProperties.setDuration(CANNED_ANIMATION_DURATION);
                        animate = true;
                    }
                icon.setVisibleState(visibleState);
                if (animate && !mDisallowNextAnimation) {
                }
                icon.setVisibleState(visibleState, animationsAllowed);
                if (animate) {
                    animateTo(icon, animationProperties);
                } else {
                    super.applyToView(view);
+1 −0
Original line number Diff line number Diff line
@@ -2740,6 +2740,7 @@ public class NotificationStackScrollLayout extends ViewGroup

    private void updateNotificationAnimationStates() {
        boolean running = mAnimationsEnabled || mPulsing;
        mShelf.setAnimationsEnabled(running);
        int childCount = getChildCount();
        for (int i = 0; i < childCount; i++) {
            View child = getChildAt(i);