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

Commit 088311b4 authored by Josh Tsuji's avatar Josh Tsuji
Browse files

New Bubbles animations!

Turns out we can animate SurfaceView alpha if a) it's Z ordered to the top, and b) we use a ValueAnimator to call .setAlpha() specifically - using .animate().alpha() sort of works but results in weird flickering. Go figure!

This CL uses that newfound ability to add:
- Fade/scale down the expanded view when you drag out the expanded bubble
- Softer expand/collapse animations
- Softer transition between bubbles
- Fixes for flashes of old bubbles while transitioning between bubbles/overflow

Will follow up with polish to exactly match the mocks, but this gets the big underlying changes in!

Test: atest SystemUITests
Test: expand and collapse bubbles
Test: drag out bubbles/dismiss the currently expanded bubble
Test: switch between bubbles of different heights
Test: all of the above one after another
Fixes: 170268335
Fixes: 177930422
Fixes: 169595742
Change-Id: I5913c05392050a4ab736d34c5cea935bf61d3db8
parent 9330a9ac
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -385,6 +385,14 @@ public class Bubble implements BubbleViewProvider {
        }
    }

    @Override
    public void setExpandedContentAlpha(float alpha) {
        if (mExpandedView != null) {
            mExpandedView.setAlpha(alpha);
            mExpandedView.setTaskViewAlpha(alpha);
        }
    }

    /**
     * Set visibility of bubble in the expanded state.
     *
@@ -394,7 +402,7 @@ public class Bubble implements BubbleViewProvider {
     * and setting {@code false} actually means rendering the expanded view in transparent.
     */
    @Override
    public void setContentVisibility(boolean visibility) {
    public void setTaskViewVisibility(boolean visibility) {
        if (mExpandedView != null) {
            mExpandedView.setContentVisibility(visibility);
        }
+41 −2
Original line number Diff line number Diff line
@@ -85,6 +85,19 @@ public class BubbleExpandedView extends LinearLayout {
    private boolean mImeVisible;
    private boolean mNeedsNewHeight;

    /**
     * Whether we want the TaskView's content to be visible (alpha = 1f). If
     * {@link #mIsAlphaAnimating} is true, this may not reflect the TaskView's actual alpha value
     * until the animation ends.
     */
    private boolean mIsContentVisible = false;

    /**
     * Whether we're animating the TaskView's alpha value. If so, we will hold off on applying alpha
     * changes from {@link #setContentVisibility} until the animation ends.
     */
    private boolean mIsAlphaAnimating = false;

    private int mMinHeight;
    private int mOverflowHeight;
    private int mSettingsIconHeight;
@@ -464,6 +477,29 @@ public class BubbleExpandedView extends LinearLayout {
        }
    }

    /**
     * Whether we are currently animating the TaskView's alpha value. If this is set to true, calls
     * to {@link #setContentVisibility} will not be applied until this is set to false again.
     */
    void setAlphaAnimating(boolean animating) {
        mIsAlphaAnimating = animating;

        // If we're done animating, apply the correct
        if (!animating) {
            setContentVisibility(mIsContentVisible);
        }
    }

    /**
     * Sets the alpha of the underlying TaskView, since changing the expanded view's alpha does not
     * affect the TaskView since it uses a Surface.
     */
    void setTaskViewAlpha(float alpha) {
        if (mTaskView != null) {
            mTaskView.setAlpha(alpha);
        }
    }

    /**
     * Set visibility of contents in the expanded state.
     *
@@ -477,16 +513,19 @@ public class BubbleExpandedView extends LinearLayout {
            Log.d(TAG, "setContentVisibility: visibility=" + visibility
                    + " bubble=" + getBubbleKey());
        }
        mIsContentVisible = visibility;

        final float alpha = visibility ? 1f : 0f;

        mPointerView.setAlpha(alpha);
        if (mTaskView != null) {
        if (mTaskView != null && !mIsAlphaAnimating) {
            mTaskView.setAlpha(alpha);
        }
    }


    @Nullable
    View getTaskView() {
    TaskView getTaskView() {
        return mTaskView;
    }

+6 −2
Original line number Diff line number Diff line
@@ -167,8 +167,12 @@ class BubbleOverflow(
        return dotPath
    }

    override fun setContentVisibility(visible: Boolean) {
        expandedView?.setContentVisibility(visible)
    override fun setExpandedContentAlpha(alpha: Float) {
        expandedView?.alpha = alpha
    }

    override fun setTaskViewVisibility(visible: Boolean) {
        // Overflow does not have a TaskView.
    }

    override fun getIconView(): BadgedImageView? {
+176 −59

File changed.

Preview size limit exceeded, changes collapsed.

+10 −1
Original line number Diff line number Diff line
@@ -29,7 +29,16 @@ import androidx.annotation.Nullable;
public interface BubbleViewProvider {
    @Nullable BubbleExpandedView getExpandedView();

    void setContentVisibility(boolean visible);
    /**
     * Sets the alpha of the expanded view content. This will be applied to both the expanded view
     * container itself (the manage button, etc.) as well as the TaskView within it.
     */
    void setExpandedContentAlpha(float alpha);

    /**
     * Sets whether the contents of the bubble's TaskView should be visible.
     */
    void setTaskViewVisibility(boolean visible);

    @Nullable View getIconView();