diff options
| author | 2021-02-10 17:57:54 +0000 | |
|---|---|---|
| committer | 2021-02-10 17:57:54 +0000 | |
| commit | 0177fad8455366e9e43f64e12c924b8901899e56 (patch) | |
| tree | a2b05d267cd1754332fef30351a293fb9c59da85 | |
| parent | 61d138aca2079574a0c9aa7af7dba3ec1b7d3d07 (diff) | |
| parent | ba1c4c4e303af50175372b80778003fb2e945da2 (diff) | |
Merge "Add edgeEffectType attribute and type property" into sc-dev
| -rw-r--r-- | core/api/current.txt | 5 | ||||
| -rw-r--r-- | core/java/android/widget/EdgeEffect.java | 45 | ||||
| -rw-r--r-- | core/res/res/values/attrs.xml | 10 | ||||
| -rw-r--r-- | core/res/res/values/public.xml | 1 |
4 files changed, 61 insertions, 0 deletions
diff --git a/core/api/current.txt b/core/api/current.txt index f82e00035e65..53be53c62786 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -573,6 +573,7 @@ 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 = 16844329; // 0x1010629 field public static final int editTextBackground = 16843602; // 0x1010352 field public static final int editTextColor = 16843601; // 0x1010351 field public static final int editTextPreferenceStyle = 16842898; // 0x1010092 @@ -53586,6 +53587,7 @@ package android.widget { method @Nullable public android.graphics.BlendMode getBlendMode(); method @ColorInt public int getColor(); method public int getMaxHeight(); + method public int getType(); method public boolean isFinished(); method public void onAbsorb(int); method public void onPull(float); @@ -53594,7 +53596,10 @@ 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 { diff --git a/core/java/android/widget/EdgeEffect.java b/core/java/android/widget/EdgeEffect.java index c10ffbee686a..61ff36c09cb9 100644 --- a/core/java/android/widget/EdgeEffect.java +++ b/core/java/android/widget/EdgeEffect.java @@ -17,6 +17,7 @@ package android.widget; import android.annotation.ColorInt; +import android.annotation.IntDef; import android.annotation.Nullable; import android.compat.annotation.UnsupportedAppUsage; import android.content.Context; @@ -30,6 +31,9 @@ import android.view.animation.AnimationUtils; import android.view.animation.DecelerateInterpolator; import android.view.animation.Interpolator; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + /** * This class performs the graphical effect used at the edges of scrollable widgets * when the user scrolls beyond the content bounds in 2D space. @@ -55,6 +59,24 @@ public class EdgeEffect { */ public static final BlendMode DEFAULT_BLEND_MODE = BlendMode.SRC_ATOP; + /** + * Use a color edge glow for the edge effect. From XML, use + * <code>android:edgeEffectType="glow"</code>. + */ + public static final int TYPE_GLOW = 0; + + /** + * Use a stretch for the edge effect. From XML, use + * <code>android:edgeEffectType="stretch"</code>. + */ + public static final int TYPE_STRETCH = 1; + + /** @hide */ + @IntDef({TYPE_GLOW, TYPE_STRETCH}) + @Retention(RetentionPolicy.SOURCE) + public @interface EdgeEffectType { + } + @SuppressWarnings("UnusedDeclaration") private static final String TAG = "EdgeEffect"; @@ -121,6 +143,7 @@ public class EdgeEffect { private float mBaseGlowScale; private float mDisplacement = 0.5f; private float mTargetDisplacement = 0.5f; + private @EdgeEffectType int mEdgeEffectType = TYPE_GLOW; /** * Construct a new EdgeEffect with a theme appropriate for the provided context. @@ -132,6 +155,8 @@ public class EdgeEffect { 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, TYPE_GLOW); a.recycle(); mPaint.setColor((themeColor & 0xffffff) | 0x33000000); mPaint.setStyle(Paint.Style.FILL); @@ -309,6 +334,17 @@ public class EdgeEffect { } /** + * 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 * (content of the render target). @@ -333,6 +369,15 @@ 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 diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml index 586c99d76335..aeb4fc468fe4 100644 --- a/core/res/res/values/attrs.xml +++ b/core/res/res/values/attrs.xml @@ -1140,6 +1140,15 @@ <!-- The color applied to the edge effect on scrolling containers. --> <attr name="colorEdgeEffect" format="color" /> + <!-- The type of the edge effect. The default is glow. --> + <attr name="edgeEffectType"> + <!-- Use a colored glow at the edge. --> + <enum name="glow" value="0" /> + + <!-- Stretch the content. --> + <enum name="stretch" value="1" /> + </attr> + <!-- =================== --> <!-- Lighting properties --> <!-- =================== --> @@ -9050,6 +9059,7 @@ <!-- Used as a filter array on the theme to pull out only the EdgeEffect-relevant bits. --> <declare-styleable name="EdgeEffect"> <attr name="colorEdgeEffect" /> + <attr name="edgeEffectType" /> </declare-styleable> <!-- Use <code>tv-input</code> as the root tag of the XML resource that describes a diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml index d3f3ebd7c3d9..40c5206b86d8 100644 --- a/core/res/res/values/public.xml +++ b/core/res/res/values/public.xml @@ -3063,6 +3063,7 @@ <public name="hotwordDetectionService" /> <public name="previewLayout" /> <public name="clipToOutline" /> + <public name="edgeEffectType" /> </public-group> <public-group type="drawable" first-id="0x010800b5"> |