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

Commit 7b7ca3cd authored by Chris Craik's avatar Chris Craik
Browse files

Disable setOutline() functionality, pending full removal

bug:15283203
Change-Id: Ibf127fecfcda835117c6087180c64f622b3041e4
parent 325503ca
Loading
Loading
Loading
Loading
+6 −31
Original line number Diff line number Diff line
@@ -2379,25 +2379,22 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     */
    static final int PFLAG3_CALLED_SUPER = 0x10;
    @Deprecated
    static final int PFLAG3_OUTLINE_DEFINED = 0x20;
    /**
     * Flag indicating that we're in the process of applying window insets.
     */
    static final int PFLAG3_APPLYING_INSETS = 0x40;
    static final int PFLAG3_APPLYING_INSETS = 0x20;
    /**
     * Flag indicating that we're in the process of fitting system windows using the old method.
     */
    static final int PFLAG3_FITTING_SYSTEM_WINDOWS = 0x80;
    static final int PFLAG3_FITTING_SYSTEM_WINDOWS = 0x40;
    /**
     * Flag indicating that nested scrolling is enabled for this view.
     * The view will optionally cooperate with views up its parent chain to allow for
     * integrated nested scrolling along the same axis.
     */
    static final int PFLAG3_NESTED_SCROLLING_ENABLED = 0x200;
    static final int PFLAG3_NESTED_SCROLLING_ENABLED = 0x80;
    /* End of masks for mPrivateFlags3 */
@@ -3273,8 +3270,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
    private int[] mDrawableState = null;
    @Deprecated
    private Outline mOutline;
    ViewOutlineProvider mOutlineProvider = ViewOutlineProvider.BACKGROUND;
    /**
@@ -10751,23 +10746,9 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
        }
    }
    /** Deprecated, pending removal */
    @Deprecated
    public void setOutline(@Nullable Outline outline) {
        mPrivateFlags3 |= PFLAG3_OUTLINE_DEFINED;
        if (outline == null || outline.isEmpty()) {
            if (mOutline != null) {
                mOutline.setEmpty();
            }
        } else {
            // always copy the path since caller may reuse
            if (mOutline == null) {
                mOutline = new Outline();
            }
            mOutline.set(outline);
        }
        mRenderNode.setOutline(mOutline);
    }
    public void setOutline(@Nullable Outline outline) {}
    /**
     * Returns whether the Outline should be used to clip the contents of the View.
@@ -10836,12 +10817,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     * @see #setOutlineProvider(ViewOutlineProvider)
     */
    public void invalidateOutline() {
        if ((mPrivateFlags3 & PFLAG3_OUTLINE_DEFINED) != 0) {
            // TODO: remove this when removing old outline code
            // setOutline() was called to manually set outline, ignore provider
            return;
        }
        // Unattached views ignore this signal, and outline is recomputed in onAttachedToWindow()
        if (mAttachInfo == null) return;
+11 −16
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import android.graphics.Paint;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewOutlineProvider;
import android.view.ViewPropertyAnimator;
import android.view.animation.AccelerateInterpolator;
import android.widget.FrameLayout;
@@ -66,7 +67,6 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks, View.On
    boolean mClipViewInStack;
    Rect mTmpRect = new Rect();
    Paint mLayerPaint = new Paint();
    Outline mOutline = new Outline();

    TaskThumbnailView mThumbnailView;
    TaskBarView mBarView;
@@ -115,6 +115,15 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks, View.On
        setClipToOutline(true);
        setDim(getDim());
        setFooterHeight(getFooterHeight());
        setOutlineProvider(new ViewOutlineProvider() {
            @Override
            public boolean getOutline(View view, Outline outline) {
                int height = getHeight() - mMaxFooterHeight + mFooterHeight;
                outline.setRoundRect(0, 0, getWidth(), height,
                        mConfig.taskViewRoundedCornerRadiusPx);
                return true;
            }
        });
    }

    @Override
@@ -149,20 +158,6 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks, View.On
        mThumbnailView.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY),
                MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY));
        setMeasuredDimension(width, height);
        updateOutline();
    }

    /** Updates the outline to match whether the lock-to-app button is visible or not. */
    void updateOutline() {
        int height = getMeasuredHeight();
        if (height == 0) return;

        // Account for the current footer height
        height = height - mMaxFooterHeight + mFooterHeight;

        mOutline.setRoundRect(0, 0, getMeasuredWidth(), height,
                mConfig.taskViewRoundedCornerRadiusPx);
        setOutline(mOutline);
    }

    /** Set callback */
@@ -548,7 +543,7 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks, View.On
    /** Sets the footer height. */
    public void setFooterHeight(int height) {
        mFooterHeight = height;
        updateOutline();
        invalidateOutline();
        invalidate(0, getMeasuredHeight() - mMaxFooterHeight, getMeasuredWidth(),
                getMeasuredHeight());
    }
+26 −27
Original line number Diff line number Diff line
@@ -18,39 +18,50 @@ package com.android.systemui.statusbar;

import android.content.Context;
import android.graphics.Outline;
import android.graphics.Rect;
import android.graphics.RectF;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewOutlineProvider;

/**
 * Like {@link ExpandableView}, but setting an outline for the height and clipping.
 */
public abstract class ExpandableOutlineView extends ExpandableView {

    private final Outline mOutline = new Outline();
    private final Rect mOutlineRect = new Rect();
    private boolean mCustomOutline;
    private float mDensity;

    public ExpandableOutlineView(Context context, AttributeSet attrs) {
        super(context, attrs);
        mDensity = getResources().getDisplayMetrics().density;
        setOutlineProvider(new ViewOutlineProvider() {
            @Override
            public boolean getOutline(View view, Outline outline) {
                if (!mCustomOutline) {
                    outline.setRect(0,
                            mClipTopAmount,
                            getWidth(),
                            Math.max(mActualHeight, mClipTopAmount));
                } else {
                    outline.setRect(mOutlineRect);
                }
                return true;
            }
        });
    }

    @Override
    public void setActualHeight(int actualHeight, boolean notifyListeners) {
        super.setActualHeight(actualHeight, notifyListeners);
        updateOutline();
        invalidateOutline();
    }

    @Override
    public void setClipTopAmount(int clipTopAmount) {
        super.setClipTopAmount(clipTopAmount);
        updateOutline();
    }

    @Override
    protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
        super.onLayout(changed, left, top, right, bottom);
        updateOutline();
        invalidateOutline();
    }

    protected void setOutlineRect(RectF rect) {
@@ -58,32 +69,20 @@ public abstract class ExpandableOutlineView extends ExpandableView {
            setOutlineRect(rect.left, rect.top, rect.right, rect.bottom);
        } else {
            mCustomOutline = false;
            updateOutline();
            invalidateOutline();
        }
    }

    protected void setOutlineRect(float left, float top, float right, float bottom) {
        mCustomOutline = true;

        int rectLeft = (int) left;
        int rectTop = (int) top;
        int rectRight = (int) right;
        int rectBottom = (int) bottom;
        mOutlineRect.set((int) left, (int) top, (int) right, (int) bottom);

        // Outlines need to be at least 1 dp
        rectBottom = (int) Math.max(top + mDensity, rectBottom);
        rectRight = (int) Math.max(left + mDensity, rectRight);
        mOutline.setRect(rectLeft, rectTop, rectRight, rectBottom);
        setOutline(mOutline);
    }
        mOutlineRect.bottom = (int) Math.max(top + mDensity, mOutlineRect.bottom);
        mOutlineRect.right = (int) Math.max(left + mDensity, mOutlineRect.right);

    private void updateOutline() {
        if (!mCustomOutline) {
            mOutline.setRect(0,
                    mClipTopAmount,
                    getWidth(),
                    Math.max(mActualHeight, mClipTopAmount));
            setOutline(mOutline);
        }
        invalidateOutline();
    }

}
+1 −1
Original line number Diff line number Diff line
@@ -61,7 +61,7 @@ public class SpeedBumpView extends ExpandableView {
        super.onLayout(changed, left, top, right, bottom);
        mLine.setPivotX(mLine.getWidth() / 2);
        mLine.setPivotY(mLine.getHeight() / 2);
        setOutline(null);
        setOutlineProvider(null);
    }

    @Override
+9 −3
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewOutlineProvider;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
@@ -96,7 +97,6 @@ public class StatusBarHeaderView extends RelativeLayout implements View.OnClickL
    private QSPanel mQSPanel;

    private final Rect mClipBounds = new Rect();
    private final Outline mOutline = new Outline();

    public StatusBarHeaderView(Context context, AttributeSet attrs) {
        super(context, attrs);
@@ -142,6 +142,13 @@ public class StatusBarHeaderView extends RelativeLayout implements View.OnClickL
                updateAmPmTranslation();
            }
        });
        setOutlineProvider(new ViewOutlineProvider() {
            @Override
            public boolean getOutline(View view, Outline outline) {
                outline.setRect(mClipBounds);
                return true;
            }
        });
    }

    private void loadDimens() {
@@ -423,8 +430,7 @@ public class StatusBarHeaderView extends RelativeLayout implements View.OnClickL
    private void setClipping(float height) {
        mClipBounds.set(getPaddingLeft(), 0, getWidth() - getPaddingRight(), (int) height);
        setClipBounds(mClipBounds);
        mOutline.setRect(mClipBounds);
        setOutline(mOutline);
        invalidateOutline();
    }

    public void attachSystemIcons(LinearLayout systemIcons) {
Loading