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

Commit e02ed610 authored by Selim Cinek's avatar Selim Cinek Committed by android-build-merger
Browse files

Merge "Fix that the empty shade view would be visible sometimes" into pi-dev

am: 866b4de2

Change-Id: Id9dcf659dce0f7bb9385cde17f9c929beb89d96d
parents 30e1f4c9 866b4de2
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@
        android:paddingStart="4dp"
        android:paddingEnd="4dp"
        android:visibility="gone">
    <FrameLayout
    <com.android.systemui.statusbar.AlphaOptimizedFrameLayout
        android:id="@+id/content"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >
@@ -46,5 +46,5 @@
            android:contentDescription="@string/accessibility_clear_all"
            android:text="@string/clear_all_notifications_text"
            android:textColor="?attr/wallpaperTextColor"/>
    </FrameLayout>
    </com.android.systemui.statusbar.AlphaOptimizedFrameLayout>
</com.android.systemui.statusbar.FooterView>
+1 −2
Original line number Diff line number Diff line
@@ -84,8 +84,7 @@ public class EmptyShadeView extends StackScrollerDecorView {
            if (view instanceof EmptyShadeView) {
                EmptyShadeView emptyShadeView = (EmptyShadeView) view;
                boolean visible = this.clipTopAmount <= mEmptyText.getPaddingTop() * 0.6f;
                emptyShadeView.performVisibilityAnimation(
                        visible && !emptyShadeView.willBeGone());
                emptyShadeView.setContentVisible(visible && emptyShadeView.isVisible());
            }
        }
    }
+1 −1
Original line number Diff line number Diff line
@@ -98,7 +98,7 @@ public class FooterView extends StackScrollerDecorView {
            if (view instanceof FooterView) {
                FooterView footerView = (FooterView) view;
                boolean visible = this.clipTopAmount < mClearAllTopPadding;
                footerView.performVisibilityAnimation(visible && !footerView.willBeGone());
                footerView.setContentVisible(visible && footerView.isVisible());
            }
        }
    }
+101 −97
Original line number Diff line number Diff line
@@ -16,13 +16,13 @@

package com.android.systemui.statusbar;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.view.animation.Interpolator;

import com.android.internal.annotations.VisibleForTesting;
import com.android.systemui.Interpolators;

/**
@@ -33,11 +33,19 @@ public abstract class StackScrollerDecorView extends ExpandableView {

    protected View mContent;
    protected View mSecondaryView;
    private boolean mIsVisible;
    private boolean mIsSecondaryVisible;
    private boolean mAnimating;
    private boolean mSecondaryAnimating;
    private boolean mIsVisible = true;
    private boolean mContentVisible = true;
    private boolean mIsSecondaryVisible = true;
    private int mDuration = 260;
    private boolean mContentAnimating;
    private final Runnable mContentVisibilityEndRunnable = () -> {
        mContentAnimating = false;
        if (getVisibility() != View.GONE && !mIsVisible) {
            setVisibility(GONE);
            setWillBeGone(false);
            notifyHeightChanged(false /* needsAnimation */);
        }
    };

    public StackScrollerDecorView(Context context, AttributeSet attrs) {
        super(context, attrs);
@@ -48,7 +56,8 @@ public abstract class StackScrollerDecorView extends ExpandableView {
        super.onFinishInflate();
        mContent = findContentView();
        mSecondaryView = findSecondaryView();
        setInvisible();
        setVisible(false /* nowVisible */, false /* animate */);
        setSecondaryVisible(false /* nowVisible */, false /* animate */);
    }

    @Override
@@ -62,72 +71,82 @@ public abstract class StackScrollerDecorView extends ExpandableView {
        return true;
    }

    public void performVisibilityAnimation(boolean nowVisible) {
        performVisibilityAnimation(nowVisible, null /* onFinishedRunnable */);
    /**
     * Set the content of this view to be visible in an animated way.
     *
     * @param contentVisible True if the content should be visible or false if it should be hidden.
     */
    public void setContentVisible(boolean contentVisible) {
        setContentVisible(contentVisible, true /* animate */);
    }
    /**
     * Set the content of this view to be visible.
     * @param contentVisible True if the content should be visible or false if it should be hidden.
     * @param animate Should an animation be performed.
     */
    private void setContentVisible(boolean contentVisible, boolean animate) {
        if (mContentVisible != contentVisible) {
            mContentAnimating = animate;
            setViewVisible(mContent, contentVisible, animate, mContentVisibilityEndRunnable);
            mContentVisible = contentVisible;
        } if (!mContentAnimating) {
            mContentVisibilityEndRunnable.run();
        }

    public void performVisibilityAnimation(boolean nowVisible, Runnable onFinishedRunnable) {
        boolean oldVisible = isVisible();
        animateText(mContent, nowVisible, oldVisible, new AnimatorListenerAdapter() {
                @Override
                public void onAnimationStart(Animator animation) {
                    mAnimating = true;
    }

                @Override
                public void onAnimationEnd(Animator animation) {
                    mAnimating = false;
    /**
     * Make this view visible. If {@code false} is passed, the view will fade out it's content
     * and set the view Visibility to GONE. If only the content should be changed
     * {@link #setContentVisible(boolean)} can be used.
     *
     * @param nowVisible should the view be visible
     * @param animate should the change be animated.
     */
    public void setVisible(boolean nowVisible, boolean animate) {
        if (mIsVisible != nowVisible) {
            mIsVisible = nowVisible;
                    if (onFinishedRunnable != null) {
                        onFinishedRunnable.run();
                    }
            if (animate) {
                if (nowVisible) {
                    setVisibility(VISIBLE);
                    setWillBeGone(false);
                    notifyHeightChanged(false /* needsAnimation */);
                } else {
                    setWillBeGone(true);
                }
            });
                setContentVisible(nowVisible, true /* animate */);
            } else {
                setVisibility(nowVisible ? VISIBLE : GONE);
                setContentVisible(nowVisible, false /* animate */);
                setWillBeGone(false);
                notifyHeightChanged(false /* needsAnimation */);
            }

    public void performSecondaryVisibilityAnimation(boolean nowVisible) {
        performSecondaryVisibilityAnimation(nowVisible, null /* onFinishedRunnable */);
        }

    public void performSecondaryVisibilityAnimation(boolean nowVisible,
            Runnable onFinishedRunnable) {
        boolean oldVisible = isSecondaryVisible();
        animateText(mSecondaryView, nowVisible, oldVisible, new AnimatorListenerAdapter() {
                @Override
                public void onAnimationStart(Animator animation) {
                    mSecondaryAnimating = true;
    }

                @Override
                public void onAnimationEnd(Animator animation) {
                    mSecondaryAnimating = false;
    /**
     * Set the secondary view of this layout to visible.
     *
     * @param nowVisible should the secondary view be visible
     * @param animate should the change be animated
     */
    public void setSecondaryVisible(boolean nowVisible, boolean animate) {
        if (mIsSecondaryVisible != nowVisible) {
            setViewVisible(mSecondaryView, nowVisible, animate, null /* endRunnable */);
            mIsSecondaryVisible = nowVisible;
                    if (onFinishedRunnable != null) {
                        onFinishedRunnable.run();
        }
    }
            });
    }

    /**
     * Check whether the secondary view is visible or not.<p/>
     *
     * @see #isVisible()
     */
    public boolean isSecondaryVisible() {
        return mSecondaryView != null && (mIsSecondaryVisible ^ mSecondaryAnimating);
    @VisibleForTesting
    boolean isSecondaryVisible() {
        return mIsSecondaryVisible;
    }

    /**
     * Check whether the whole view is visible or not.<p/>
     * The view is considered visible if it matches one of following:
     * <ul>
     *   <li> It's visible and there is no ongoing animation. </li>
     *   <li> It's not visible but is animating, thus being eventually visible. </li>
     * </ul>
     * Is this view visible. If a view is currently animating to gone, it will
     * return {@code false}.
     */
    public boolean isVisible() {
        return mIsVisible ^ mAnimating;
        return mIsVisible;
    }

    void setDuration(int duration) {
@@ -135,43 +154,35 @@ public abstract class StackScrollerDecorView extends ExpandableView {
    }

    /**
     * Animate the text to a new visibility.
     *
     * @param view Target view, maybe content view or dissmiss view
     * @param nowVisible Should it now be visible
     * @param oldVisible Is it visible currently
     * @param listener A listener that doing flag settings or other actions
     * Animate a view to a new visibility.
     * @param view Target view, maybe content view or dismiss view.
     * @param nowVisible Should it now be visible.
     * @param animate Should this be done in an animated way.
     * @param endRunnable A runnable that is run when the animation is done.
     */
    private void animateText(View view, boolean nowVisible, boolean oldVisible,
        AnimatorListenerAdapter listener) {
    private void setViewVisible(View view, boolean nowVisible,
            boolean animate, Runnable endRunnable) {
        if (view == null) {
            return;
        }

        if (nowVisible != oldVisible) {
            // Animate text
        // cancel any previous animations
        view.animate().cancel();
        float endValue = nowVisible ? 1.0f : 0.0f;
            Interpolator interpolator;
            if (nowVisible) {
                interpolator = Interpolators.ALPHA_IN;
            } else {
                interpolator = Interpolators.ALPHA_OUT;
        if (!animate) {
            view.setAlpha(endValue);
            if (endRunnable != null) {
                endRunnable.run();
            }
            return;
        }

        // Animate the view alpha
        Interpolator interpolator = nowVisible ? Interpolators.ALPHA_IN : Interpolators.ALPHA_OUT;
        view.animate()
                .alpha(endValue)
                .setInterpolator(interpolator)
                .setDuration(mDuration)
                    .setListener(listener);
        }
    }

    public void setInvisible() {
        mContent.setAlpha(0.0f);
        if (mSecondaryView != null) {
            mSecondaryView.setAlpha(0.0f);
        }
        mIsVisible = false;
        mIsSecondaryVisible = false;
                .withEndAction(endRunnable);
    }

    @Override
@@ -180,13 +191,13 @@ public abstract class StackScrollerDecorView extends ExpandableView {
            Runnable onFinishedRunnable,
            AnimatorListenerAdapter animationListener) {
        // TODO: Use duration
        performVisibilityAnimation(false);
        setContentVisible(false);
    }

    @Override
    public void performAddAnimation(long delay, long duration, boolean isHeadsUpAppear) {
        // TODO: use delay and duration
        performVisibilityAnimation(true);
        setContentVisible(true);
    }

    @Override
@@ -194,13 +205,6 @@ public abstract class StackScrollerDecorView extends ExpandableView {
        return false;
    }

    public void cancelAnimation() {
        mContent.animate().cancel();
        if (mSecondaryView != null) {
            mSecondaryView.animate().cancel();
        }
    }

    protected abstract View findContentView();

    /**
+4 −4
Original line number Diff line number Diff line
@@ -1453,11 +1453,11 @@ public class StatusBar extends SystemUI implements DemoMode,

    @VisibleForTesting
    protected void updateFooter() {
        boolean showFooterView = mState != StatusBarState.KEYGUARD
                && mEntryManager.getNotificationData().getActiveNotifications().size() != 0
        boolean showDismissView = mClearAllEnabled && hasActiveClearableNotifications();
        boolean showFooterView = (showDismissView ||
                        mEntryManager.getNotificationData().getActiveNotifications().size() != 0)
                && mState != StatusBarState.KEYGUARD
                && !mRemoteInputManager.getController().isRemoteInputActive();
        boolean showDismissView = mClearAllEnabled && mState != StatusBarState.KEYGUARD
                && hasActiveClearableNotifications();

        mStackScroller.updateFooterView(showFooterView, showDismissView);
    }
Loading