From b1aee44bea4b50a4e9b85e85212101a5c7280fd9 Mon Sep 17 00:00:00 2001 From: George Mount Date: Thu, 29 Apr 2021 23:24:12 +0000 Subject: [PATCH] Remove edge effect type from the API. Fixes: 186758538 Relnote: "Removes edge effect type from the API -- EdgeEffect now supports only stretch edge effect for all applications." Test: existing tests, modified to work with stretch Change-Id: Iec7a9d4a0316ff3ba7297c4565bb881a1adcf949 --- core/api/current.txt | 11 ---- core/java/android/widget/AbsListView.java | 21 ------ core/java/android/widget/EdgeEffect.java | 66 +++---------------- .../android/widget/HorizontalScrollView.java | 21 ------ core/java/android/widget/ScrollView.java | 22 ------- .../android/internal/widget/RecyclerView.java | 38 ----------- .../android/internal/widget/ViewPager.java | 22 ------- core/res/res/values/attrs.xml | 10 --- core/res/res/values/public.xml | 1 - .../res/layout/stretch_layout.xml | 2 - 10 files changed, 10 insertions(+), 204 deletions(-) diff --git a/core/api/current.txt b/core/api/current.txt index 7ed8b6c17574e..b257f5eea9d7f 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -586,7 +586,6 @@ package android { field public static final int dropDownWidth = 16843362; // 0x1010262 field public static final int duplicateParentState = 16842985; // 0x10100e9 field public static final int duration = 16843160; // 0x1010198 - field public static final int edgeEffectType; field public static final int editTextBackground = 16843602; // 0x1010352 field public static final int editTextColor = 16843601; // 0x1010351 field public static final int editTextPreferenceStyle = 16842898; // 0x1010092 @@ -53791,7 +53790,6 @@ package android.widget { method public int getCheckedItemPosition(); method public android.util.SparseBooleanArray getCheckedItemPositions(); method public int getChoiceMode(); - method public int getEdgeEffectType(); method public int getListPaddingBottom(); method public int getListPaddingLeft(); method public int getListPaddingRight(); @@ -53833,7 +53831,6 @@ package android.widget { method public void setChoiceMode(int); method public void setDrawSelectorOnTop(boolean); method public void setEdgeEffectColor(@ColorInt int); - method public void setEdgeEffectType(int); method public void setFastScrollAlwaysVisible(boolean); method public void setFastScrollEnabled(boolean); method public void setFastScrollStyle(int); @@ -54524,7 +54521,6 @@ package android.widget { method @ColorInt public int getColor(); method public float getDistance(); method public int getMaxHeight(); - method public int getType(); method public boolean isFinished(); method public void onAbsorb(int); method public void onPull(float); @@ -54534,10 +54530,7 @@ package android.widget { method public void setBlendMode(@Nullable android.graphics.BlendMode); method public void setColor(@ColorInt int); method public void setSize(int, int); - method public void setType(int); field public static final android.graphics.BlendMode DEFAULT_BLEND_MODE; - field public static final int TYPE_GLOW = 0; // 0x0 - field public static final int TYPE_STRETCH = 1; // 0x1 } public class EditText extends android.widget.TextView { @@ -54842,7 +54835,6 @@ package android.widget { method public boolean executeKeyEvent(android.view.KeyEvent); method public void fling(int); method public boolean fullScroll(int); - method public int getEdgeEffectType(); method @ColorInt public int getLeftEdgeEffectColor(); method public int getMaxScrollAmount(); method @ColorInt public int getRightEdgeEffectColor(); @@ -54850,7 +54842,6 @@ package android.widget { method public boolean isSmoothScrollingEnabled(); method public boolean pageScroll(int); method public void setEdgeEffectColor(@ColorInt int); - method public void setEdgeEffectType(int); method public void setFillViewport(boolean); method public void setLeftEdgeEffectColor(@ColorInt int); method public void setRightEdgeEffectColor(@ColorInt int); @@ -55736,7 +55727,6 @@ package android.widget { method public void fling(int); method public boolean fullScroll(int); method @ColorInt public int getBottomEdgeEffectColor(); - method public int getEdgeEffectType(); method public int getMaxScrollAmount(); method @ColorInt public int getTopEdgeEffectColor(); method public boolean isFillViewport(); @@ -55745,7 +55735,6 @@ package android.widget { method public void scrollToDescendant(@NonNull android.view.View); method public void setBottomEdgeEffectColor(@ColorInt int); method public void setEdgeEffectColor(@ColorInt int); - method public void setEdgeEffectType(int); method public void setFillViewport(boolean); method public void setSmoothScrollingEnabled(boolean); method public void setTopEdgeEffectColor(@ColorInt int); diff --git a/core/java/android/widget/AbsListView.java b/core/java/android/widget/AbsListView.java index eb16cef152480..b3f848b4cf22c 100644 --- a/core/java/android/widget/AbsListView.java +++ b/core/java/android/widget/AbsListView.java @@ -6613,27 +6613,6 @@ public abstract class AbsListView extends AdapterView implements Te return mEdgeGlowBottom.getColor(); } - /** - * Returns the {@link EdgeEffect#getType()} for the edge effects. - * @return the {@link EdgeEffect#getType()} for the edge effects. - * @attr ref android.R.styleable#EdgeEffect_edgeEffectType - */ - @EdgeEffect.EdgeEffectType - public int getEdgeEffectType() { - return mEdgeGlowTop.getType(); - } - - /** - * Sets the {@link EdgeEffect#setType(int)} for the edge effects. - * @param type The edge effect type to use for the edge effects. - * @attr ref android.R.styleable#EdgeEffect_edgeEffectType - */ - public void setEdgeEffectType(@EdgeEffect.EdgeEffectType int type) { - mEdgeGlowTop.setType(type); - mEdgeGlowBottom.setType(type); - invalidate(); - } - /** * Sets the recycler listener to be notified whenever a View is set aside in * the recycler for later reuse. This listener can be used to free resources diff --git a/core/java/android/widget/EdgeEffect.java b/core/java/android/widget/EdgeEffect.java index 4d2d9e86f1a68..bf76262e2cb61 100644 --- a/core/java/android/widget/EdgeEffect.java +++ b/core/java/android/widget/EdgeEffect.java @@ -62,9 +62,7 @@ import java.lang.annotation.RetentionPolicy; */ public class EdgeEffect { /** - * This sets the default value for {@link #setType(int)} to {@link #TYPE_STRETCH} instead - * of {@link #TYPE_GLOW}. The type can still be overridden by the theme, view attribute, - * or by calling {@link #setType(int)}. + * This sets the edge effect to use stretch instead of glow. * * @hide */ @@ -72,35 +70,20 @@ public class EdgeEffect { @EnabledSince(targetSdkVersion = Build.VERSION_CODES.BASE) public static final long USE_STRETCH_EDGE_EFFECT_BY_DEFAULT = 171228096L; - /** - * This sets the default value for {@link #setType(int)} to {@link #TYPE_STRETCH} instead - * of {@link #TYPE_GLOW} for views that instantiate with - * {@link #EdgeEffect(Context, AttributeSet)}, indicating use of S+ EdgeEffect support. The - * type can still be overridden by the theme, view attribute, or by calling - * {@link #setType(int)}. - * - * @hide - */ - @ChangeId - @EnabledSince(targetSdkVersion = Build.VERSION_CODES.S) - public static final long USE_STRETCH_EDGE_EFFECT_FOR_SUPPORTED = 178807038L; - /** * The default blend mode used by {@link EdgeEffect}. */ public static final BlendMode DEFAULT_BLEND_MODE = BlendMode.SRC_ATOP; /** - * Use a color edge glow for the edge effect. From XML, use - * android:edgeEffectType="glow". + * Use a color edge glow for the edge effect. */ - public static final int TYPE_GLOW = 0; + private static final int TYPE_GLOW = 0; /** - * Use a stretch for the edge effect. From XML, use - * android:edgeEffectType="stretch". + * Use a stretch for the edge effect. */ - public static final int TYPE_STRETCH = 1; + private static final int TYPE_STRETCH = 1; /** * The velocity threshold before the spring animation is considered settled. @@ -221,7 +204,7 @@ public class EdgeEffect { * @param context Context used to provide theming and resource information for the EdgeEffect */ public EdgeEffect(Context context) { - this(context, null, Compatibility.isChangeEnabled(USE_STRETCH_EDGE_EFFECT_BY_DEFAULT)); + this(context, null); } /** @@ -230,20 +213,12 @@ public class EdgeEffect { * @param attrs The attributes of the XML tag that is inflating the view */ public EdgeEffect(@NonNull Context context, @Nullable AttributeSet attrs) { - this(context, attrs, - Compatibility.isChangeEnabled(USE_STRETCH_EDGE_EFFECT_BY_DEFAULT) - || Compatibility.isChangeEnabled(USE_STRETCH_EDGE_EFFECT_FOR_SUPPORTED)); - } - - private EdgeEffect(@NonNull Context context, @Nullable AttributeSet attrs, - boolean defaultStretch) { final TypedArray a = context.obtainStyledAttributes( attrs, com.android.internal.R.styleable.EdgeEffect); final int themeColor = a.getColor( com.android.internal.R.styleable.EdgeEffect_colorEdgeEffect, 0xff666666); - mEdgeEffectType = a.getInt( - com.android.internal.R.styleable.EdgeEffect_edgeEffectType, - defaultStretch ? TYPE_STRETCH : TYPE_GLOW); + mEdgeEffectType = Compatibility.isChangeEnabled(USE_STRETCH_EDGE_EFFECT_BY_DEFAULT) + ? TYPE_STRETCH : TYPE_GLOW; a.recycle(); mPaint.setAntiAlias(true); @@ -505,17 +480,6 @@ public class EdgeEffect { mPaint.setColor(color); } - /** - * Sets the edge effect type to use. The default without a theme attribute set is - * {@link EdgeEffect#TYPE_GLOW}. - * - * @param type The edge effect type to use. - * @attr ref android.R.styleable#EdgeEffect_edgeEffectType - */ - public void setType(@EdgeEffectType int type) { - mEdgeEffectType = type; - } - /** * Set or clear the blend mode. A blend mode defines how source pixels * (generated by a drawing command) are composited with the destination pixels @@ -541,16 +505,6 @@ public class EdgeEffect { return mPaint.getColor(); } - /** - * Return the edge effect type to use. - * - * @return The edge effect type to use. - * @attr ref android.R.styleable#EdgeEffect_edgeEffectType - */ - public @EdgeEffectType int getType() { - return mEdgeEffectType; - } - /** * Returns the blend mode. A blend mode defines how source pixels * (generated by a drawing command) are composited with the destination pixels @@ -568,7 +522,7 @@ public class EdgeEffect { * Draw into the provided canvas. Assumes that the canvas has been rotated * accordingly and the size has been set. The effect will be drawn the full * width of X=0 to X=width, beginning from Y=0 and extending to some factor < - * 1.f of height. The {@link #TYPE_STRETCH} effect will only be visible on a + * 1.f of height. The effect will only be visible on a * hardware canvas, e.g. {@link RenderNode#beginRecording()}. * * @param canvas Canvas to draw into @@ -686,7 +640,7 @@ public class EdgeEffect { * @return The maximum height of the edge effect */ public int getMaxHeight() { - return (int) (mBounds.height() * MAX_GLOW_SCALE + 0.5f); + return (int) mHeight; } private void update() { diff --git a/core/java/android/widget/HorizontalScrollView.java b/core/java/android/widget/HorizontalScrollView.java index e41893e37103e..018cba7f95e5c 100644 --- a/core/java/android/widget/HorizontalScrollView.java +++ b/core/java/android/widget/HorizontalScrollView.java @@ -307,27 +307,6 @@ public class HorizontalScrollView extends FrameLayout { return mEdgeGlowRight.getColor(); } - /** - * Returns the {@link EdgeEffect#getType()} for the edge effects. - * @return the {@link EdgeEffect#getType()} for the edge effects. - * @attr ref android.R.styleable#EdgeEffect_edgeEffectType - */ - @EdgeEffect.EdgeEffectType - public int getEdgeEffectType() { - return mEdgeGlowLeft.getType(); - } - - /** - * Sets the {@link EdgeEffect#setType(int)} for the edge effects. - * @param type The edge effect type to use for the edge effects. - * @attr ref android.R.styleable#EdgeEffect_edgeEffectType - */ - public void setEdgeEffectType(@EdgeEffect.EdgeEffectType int type) { - mEdgeGlowRight.setType(type); - mEdgeGlowLeft.setType(type); - invalidate(); - } - /** * @return The maximum amount this scroll view will scroll in response to * an arrow event. diff --git a/core/java/android/widget/ScrollView.java b/core/java/android/widget/ScrollView.java index 3610eb47edbca..693b13bbf224e 100644 --- a/core/java/android/widget/ScrollView.java +++ b/core/java/android/widget/ScrollView.java @@ -339,27 +339,6 @@ public class ScrollView extends FrameLayout { return mEdgeGlowBottom.getColor(); } - /** - * Returns the {@link EdgeEffect#getType()} for the edge effects. - * @return the {@link EdgeEffect#getType()} for the edge effects. - * @attr ref android.R.styleable#EdgeEffect_edgeEffectType - */ - @EdgeEffect.EdgeEffectType - public int getEdgeEffectType() { - return mEdgeGlowTop.getType(); - } - - /** - * Sets the {@link EdgeEffect#setType(int)} for the edge effects. - * @param type The edge effect type to use for the edge effects. - * @attr ref android.R.styleable#EdgeEffect_edgeEffectType - */ - public void setEdgeEffectType(@EdgeEffect.EdgeEffectType int type) { - mEdgeGlowTop.setType(type); - mEdgeGlowBottom.setType(type); - invalidate(); - } - /** * @return The maximum amount this scroll view will scroll in response to * an arrow event. @@ -368,7 +347,6 @@ public class ScrollView extends FrameLayout { return (int) (MAX_SCROLL_FACTOR * (mBottom - mTop)); } - private void initScrollView() { mScroller = new OverScroller(getContext()); setFocusable(true); diff --git a/core/java/com/android/internal/widget/RecyclerView.java b/core/java/com/android/internal/widget/RecyclerView.java index 9ed5eb1d144e5..be15a9bba107b 100644 --- a/core/java/com/android/internal/widget/RecyclerView.java +++ b/core/java/com/android/internal/widget/RecyclerView.java @@ -16,16 +16,10 @@ package com.android.internal.widget; -import static android.widget.EdgeEffect.TYPE_GLOW; -import static android.widget.EdgeEffect.TYPE_STRETCH; -import static android.widget.EdgeEffect.USE_STRETCH_EDGE_EFFECT_BY_DEFAULT; -import static android.widget.EdgeEffect.USE_STRETCH_EDGE_EFFECT_FOR_SUPPORTED; - import android.annotation.CallSuper; import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.Nullable; -import android.compat.Compatibility; import android.compat.annotation.UnsupportedAppUsage; import android.content.Context; import android.content.res.TypedArray; @@ -466,8 +460,6 @@ public class RecyclerView extends ViewGroup implements ScrollingView, NestedScro private final int[] mScrollConsumed = new int[2]; private final int[] mNestedOffsets = new int[2]; - private int mEdgeEffectType; - /** * These are views that had their a11y importance changed during a layout. We defer these events * until the end of the layout because a11y service may make sync calls back to the RV while @@ -595,12 +587,8 @@ public class RecyclerView extends ViewGroup implements ScrollingView, NestedScro setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS); } - boolean defaultToStretch = Compatibility.isChangeEnabled(USE_STRETCH_EDGE_EFFECT_BY_DEFAULT) - || Compatibility.isChangeEnabled(USE_STRETCH_EDGE_EFFECT_FOR_SUPPORTED); TypedArray a = context.obtainStyledAttributes(attrs, com.android.internal.R.styleable.EdgeEffect); - mEdgeEffectType = a.getInt(com.android.internal.R.styleable.EdgeEffect_edgeEffectType, - defaultToStretch ? TYPE_STRETCH : TYPE_GLOW); a.recycle(); // Re-set whether nested scrolling is enabled so that it is set on all API levels @@ -625,28 +613,6 @@ public class RecyclerView extends ViewGroup implements ScrollingView, NestedScro setAccessibilityDelegate(mAccessibilityDelegate); } - /** - * Returns the {@link EdgeEffect#getType()} used for all EdgeEffects. - * - * @return @link EdgeEffect#getType()} used for all EdgeEffects. - */ - @EdgeEffect.EdgeEffectType - public int getEdgeEffectType() { - return mEdgeEffectType; - } - - /** - * Sets the {@link EdgeEffect#getType()} used in all EdgeEffects. - * Any existing over-scroll effects are cleared and new effects are created as needed. - * - * @param type the {@link EdgeEffect#getType()} used in all EdgeEffects. - */ - public void setEdgeEffectType(@EdgeEffect.EdgeEffectType int type) { - mEdgeEffectType = type; - invalidateGlows(); - invalidate(); - } - /** * Instantiate and set a LayoutManager, if specified in the attributes. */ @@ -2223,7 +2189,6 @@ public class RecyclerView extends ViewGroup implements ScrollingView, NestedScro return; } mLeftGlow = new EdgeEffect(getContext()); - mLeftGlow.setType(mEdgeEffectType); if (mClipToPadding) { mLeftGlow.setSize(getMeasuredHeight() - getPaddingTop() - getPaddingBottom(), getMeasuredWidth() - getPaddingLeft() - getPaddingRight()); @@ -2237,7 +2202,6 @@ public class RecyclerView extends ViewGroup implements ScrollingView, NestedScro return; } mRightGlow = new EdgeEffect(getContext()); - mRightGlow.setType(mEdgeEffectType); if (mClipToPadding) { mRightGlow.setSize(getMeasuredHeight() - getPaddingTop() - getPaddingBottom(), getMeasuredWidth() - getPaddingLeft() - getPaddingRight()); @@ -2251,7 +2215,6 @@ public class RecyclerView extends ViewGroup implements ScrollingView, NestedScro return; } mTopGlow = new EdgeEffect(getContext()); - mTopGlow.setType(mEdgeEffectType); if (mClipToPadding) { mTopGlow.setSize(getMeasuredWidth() - getPaddingLeft() - getPaddingRight(), getMeasuredHeight() - getPaddingTop() - getPaddingBottom()); @@ -2266,7 +2229,6 @@ public class RecyclerView extends ViewGroup implements ScrollingView, NestedScro return; } mBottomGlow = new EdgeEffect(getContext()); - mBottomGlow.setType(mEdgeEffectType); if (mClipToPadding) { mBottomGlow.setSize(getMeasuredWidth() - getPaddingLeft() - getPaddingRight(), getMeasuredHeight() - getPaddingTop() - getPaddingBottom()); diff --git a/core/java/com/android/internal/widget/ViewPager.java b/core/java/com/android/internal/widget/ViewPager.java index 93cde3ddb72d8..1174db5b2cf76 100644 --- a/core/java/com/android/internal/widget/ViewPager.java +++ b/core/java/com/android/internal/widget/ViewPager.java @@ -386,28 +386,6 @@ public class ViewPager extends ViewGroup { } } - /** - * Returns the {@link EdgeEffect#getType()} for the edge effects. - * @return the {@link EdgeEffect#getType()} for the edge effects. - * @attr ref android.R.styleable#EdgeEffect_edgeEffectType - */ - @EdgeEffect.EdgeEffectType - public int getEdgeEffectType() { - // Both left and right edge have the same edge effect type - return mLeftEdge.getType(); - } - - /** - * Sets the {@link EdgeEffect#setType(int)} for the edge effects. - * @param type The edge effect type to use for the edge effects. - * @attr ref android.R.styleable#EdgeEffect_edgeEffectType - */ - public void setEdgeEffectType(@EdgeEffect.EdgeEffectType int type) { - mLeftEdge.setType(type); - mRightEdge.setType(type); - invalidate(); - } - /** * Set a PagerAdapter that will supply views for this pager as needed. * diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml index 480b47835100a..f0c43ff18d367 100644 --- a/core/res/res/values/attrs.xml +++ b/core/res/res/values/attrs.xml @@ -1179,15 +1179,6 @@ - - - - - - - - - @@ -9257,7 +9248,6 @@ -