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

Commit acec8ad6 authored by Selim Cinek's avatar Selim Cinek Committed by Android (Google) Code Review
Browse files

Merge "Animating the work profile button location now"

parents d0803bb4 0d07c7ec
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -237,6 +237,10 @@ public class NotificationHeaderView extends LinearLayout {
        }
    }

    public View getWorkProfileIcon() {
        return mProfileBadge;
    }

    public class HeaderTouchListener implements View.OnTouchListener {

        private final ArrayList<Rect> mTouchRects = new ArrayList<>();
+26 −5
Original line number Diff line number Diff line
@@ -30,6 +30,8 @@ public class HeaderTransformState extends TransformState {
    private static Pools.SimplePool<HeaderTransformState> sInstancePool
            = new Pools.SimplePool<>(40);
    private View mExpandButton;
    private View mWorkProfileIcon;
    private TransformState mWorkProfileState;

    @Override
    public void initFrom(View view) {
@@ -37,13 +39,16 @@ public class HeaderTransformState extends TransformState {
        if (view instanceof NotificationHeaderView) {
            NotificationHeaderView header = (NotificationHeaderView) view;
            mExpandButton = header.getExpandButton();
            mWorkProfileState = TransformState.obtain();
            mWorkProfileIcon = header.getWorkProfileIcon();
            mWorkProfileState.initFrom(mWorkProfileIcon);
        }
    }

    @Override
    public boolean transformViewTo(TransformState otherState, Runnable endRunnable) {
        // if the transforming notification has a header, we have ensured that it looks the same
        // but the expand button, so lets fade just that one.
        // but the expand button, so lets fade just that one and transform the work profile icon.
        if (!(mTransformedView instanceof NotificationHeaderView)) {
            return false;
        }
@@ -66,7 +71,7 @@ public class HeaderTransformState extends TransformState {
    @Override
    public void transformViewFrom(TransformState otherState) {
        // if the transforming notification has a header, we have ensured that it looks the same
        // but the expand button, so lets fade just that one.
        // but the expand button, so lets fade just that one and transform the work profile icon.
        if (!(mTransformedView instanceof NotificationHeaderView)) {
            return;
        }
@@ -79,10 +84,14 @@ public class HeaderTransformState extends TransformState {
            if (headerChild.getVisibility() == View.GONE) {
                continue;
            }
            if (headerChild != mExpandButton) {
                headerChild.setVisibility(View.VISIBLE);
            } else {
            if (headerChild == mExpandButton) {
                CrossFadeHelper.fadeIn(mExpandButton);
            } else {
                headerChild.setVisibility(View.VISIBLE);
                if (headerChild == mWorkProfileIcon) {
                    mWorkProfileState.animateViewFrom(
                            ((HeaderTransformState) otherState).mWorkProfileState);
                }
            }
        }
        return;
@@ -99,6 +108,9 @@ public class HeaderTransformState extends TransformState {
    @Override
    public void recycle() {
        super.recycle();
        if (mWorkProfileState != null) {
            mWorkProfileState.recycle();
        }
        sInstancePool.release(this);
    }

@@ -106,6 +118,7 @@ public class HeaderTransformState extends TransformState {
    protected void reset() {
        super.reset();
        mExpandButton = null;
        mWorkProfileState = null;
    }

    public void setVisible(boolean visible) {
@@ -125,6 +138,10 @@ public class HeaderTransformState extends TransformState {
            if (headerChild == mExpandButton) {
                headerChild.setAlpha(visible ? 1.0f : 0.0f);
            }
            if (headerChild == mWorkProfileIcon) {
                headerChild.setTranslationX(0);
                headerChild.setTranslationY(0);
            }
        }
    }

@@ -144,6 +161,10 @@ public class HeaderTransformState extends TransformState {
            headerChild.animate().cancel();
            headerChild.setVisibility(View.VISIBLE);
            headerChild.setAlpha(1.0f);
            if (headerChild == mWorkProfileIcon) {
                headerChild.setTranslationX(0);
                headerChild.setTranslationY(0);
            }
        }
    }
}
+3 −0
Original line number Diff line number Diff line
@@ -286,6 +286,9 @@ public class TransformState {
    }

    public void setVisible(boolean visible) {
        if (mTransformedView.getVisibility() == View.GONE) {
            return;
        }
        mTransformedView.animate().cancel();
        mTransformedView.setVisibility(visible ? View.VISIBLE : View.INVISIBLE);
        mTransformedView.setAlpha(visible ? 1.0f : 0.0f);