Add edgeEffectType attribute and type property
Bug: 178807038 This adds the edgeEffectType property and type attribute. These will be used to enable stretchy edge effect for overscroll. Merged-In: I16f20b36d9a15c08e0a37f98572ef9c9f8fbc88f Test: new CTS test for setting/retrieving the effect type. Test: Ic363f71d241649d15faa86434516457e62b261f4 Change-Id: I16f20b36d9a15c08e0a37f98572ef9c9f8fbc88f
This commit is contained in:
@@ -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
|
||||
@@ -53561,6 +53562,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);
|
||||
@@ -53569,7 +53571,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 {
|
||||
|
||||
@@ -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);
|
||||
@@ -308,6 +333,17 @@ 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
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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">
|
||||
|
||||
Reference in New Issue
Block a user