Disable setOutline() functionality, pending full removal
bug:15283203
Change-Id: Ibf127fecfcda835117c6087180c64f622b3041e4
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 933f7f8..a09a061 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -2374,30 +2374,27 @@
static final int PFLAG3_MEASURE_NEEDED_BEFORE_LAYOUT = 0x8;
/**
- * Flag indicating that an overridden method correctly called down to
+ * Flag indicating that an overridden method correctly called down to
* the superclass implementation as required by the API spec.
*/
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 @@
private int[] mDrawableState = null;
- @Deprecated
- private Outline mOutline;
ViewOutlineProvider mOutlineProvider = ViewOutlineProvider.BACKGROUND;
/**
@@ -10751,23 +10746,9 @@
}
}
+ /** 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 @@
* @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;
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java
index 125b018..5524e15 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java
@@ -27,6 +27,7 @@
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 @@
boolean mClipViewInStack;
Rect mTmpRect = new Rect();
Paint mLayerPaint = new Paint();
- Outline mOutline = new Outline();
TaskThumbnailView mThumbnailView;
TaskBarView mBarView;
@@ -115,6 +115,15 @@
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 @@
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 @@
/** Sets the footer height. */
public void setFooterHeight(int height) {
mFooterHeight = height;
- updateOutline();
+ invalidateOutline();
invalidate(0, getMeasuredHeight() - mMaxFooterHeight, getMeasuredWidth(),
getMeasuredHeight());
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableOutlineView.java b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableOutlineView.java
index 843db04..d9719ea 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableOutlineView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableOutlineView.java
@@ -18,39 +18,50 @@
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 @@
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);
+
+ invalidateOutline();
}
- private void updateOutline() {
- if (!mCustomOutline) {
- mOutline.setRect(0,
- mClipTopAmount,
- getWidth(),
- Math.max(mActualHeight, mClipTopAmount));
- setOutline(mOutline);
- }
- }
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/SpeedBumpView.java b/packages/SystemUI/src/com/android/systemui/statusbar/SpeedBumpView.java
index 650abaa..dfeadc5 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/SpeedBumpView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/SpeedBumpView.java
@@ -61,7 +61,7 @@
super.onLayout(changed, left, top, right, bottom);
mLine.setPivotX(mLine.getWidth() / 2);
mLine.setPivotY(mLine.getHeight() / 2);
- setOutline(null);
+ setOutlineProvider(null);
}
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarHeaderView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarHeaderView.java
index 8008af9..52d3cd3 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarHeaderView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarHeaderView.java
@@ -24,6 +24,7 @@
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 @@
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 @@
updateAmPmTranslation();
}
});
+ setOutlineProvider(new ViewOutlineProvider() {
+ @Override
+ public boolean getOutline(View view, Outline outline) {
+ outline.setRect(mClipBounds);
+ return true;
+ }
+ });
}
private void loadDimens() {
@@ -423,8 +430,7 @@
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) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpNotificationView.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpNotificationView.java
index 0a48e34..d232bc4 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpNotificationView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpNotificationView.java
@@ -26,6 +26,7 @@
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
+import android.view.ViewOutlineProvider;
import android.view.ViewTreeObserver;
import android.widget.FrameLayout;
@@ -159,6 +160,21 @@
// ViewGroup methods
+ private static final ViewOutlineProvider CONTENT_HOLDER_OUTLINE_PROVIDER =
+ new ViewOutlineProvider() {
+ @Override
+ public boolean getOutline(View view, Outline outline) {
+ int outlineLeft = view.getPaddingLeft();
+ int outlineTop = view.getPaddingTop();
+
+ // Apply padding to shadow.
+ outline.setRect(outlineLeft, outlineTop,
+ view.getWidth() - outlineLeft - view.getPaddingRight(),
+ view.getHeight() - outlineTop - view.getPaddingBottom());
+ return true;
+ }
+ };
+
@Override
public void onAttachedToWindow() {
float densityScale = getResources().getDisplayMetrics().density;
@@ -174,6 +190,7 @@
mExpandHelper = new ExpandHelper(getContext(), this, minHeight, maxHeight);
mContentHolder = (ViewGroup) findViewById(R.id.content_holder);
+ mContentHolder.setOutlineProvider(CONTENT_HOLDER_OUTLINE_PROVIDER);
if (mHeadsUp != null) {
// whoops, we're on already!
@@ -232,20 +249,6 @@
mSwipeHelper.setPagingTouchSlop(pagingTouchSlop);
}
- @Override
- protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
- super.onLayout(changed, left, top, right, bottom);
- Outline o = new Outline();
-
- // Apply padding to shadow.
- int outlineLeft = mContentHolder.getPaddingLeft();
- int outlineTop = mContentHolder.getPaddingTop();
- o.setRect(outlineLeft, outlineTop,
- mContentHolder.getWidth() - outlineLeft - mContentHolder.getPaddingRight(),
- mContentHolder.getHeight() - outlineTop - mContentHolder.getPaddingBottom());
- mContentHolder.setOutline(o);
- }
-
// ExpandHelper.Callback methods
@Override