Merge "Move hasEqualAttribute from Paint with adding some accessors"
diff --git a/api/current.txt b/api/current.txt
index bb3cb0b..d897162 100755
--- a/api/current.txt
+++ b/api/current.txt
@@ -14007,6 +14007,10 @@
method public float getRunAdvance(char[], int, int, int, int, boolean, int);
method public float getRunAdvance(java.lang.CharSequence, int, int, int, int, boolean, int);
method public android.graphics.Shader getShader();
+ method public int getShadowLayerColor();
+ method public float getShadowLayerDx();
+ method public float getShadowLayerDy();
+ method public float getShadowLayerRadius();
method public float getStrikeThruPosition();
method public float getStrikeThruThickness();
method public android.graphics.Paint.Cap getStrokeCap();
@@ -44158,6 +44162,8 @@
field public float density;
field public int[] drawableState;
field public int linkColor;
+ field public int underlineColor;
+ field public float underlineThickness;
}
public class TextUtils {
diff --git a/core/java/android/text/TextLine.java b/core/java/android/text/TextLine.java
index b49a949..44dfd11 100644
--- a/core/java/android/text/TextLine.java
+++ b/core/java/android/text/TextLine.java
@@ -1230,7 +1230,7 @@
// with the next chunk. So we just save the TextPaint for future comparisons
// and use.
activePaint.set(wp);
- } else if (!wp.hasEqualAttributes(activePaint)) {
+ } else if (!equalAttributes(wp, activePaint)) {
// The style of the present chunk of text is substantially different from the
// style of the previous chunk. We need to handle the active piece of text
// and restart with the present chunk.
@@ -1335,4 +1335,42 @@
}
private static final int TAB_INCREMENT = 20;
+
+ private static boolean equalAttributes(@NonNull TextPaint lp, @NonNull TextPaint rp) {
+ return lp.getColorFilter() == rp.getColorFilter()
+ && lp.getMaskFilter() == rp.getMaskFilter()
+ && lp.getShader() == rp.getShader()
+ && lp.getTypeface() == rp.getTypeface()
+ && lp.getXfermode() == rp.getXfermode()
+ && lp.getTextLocales().equals(rp.getTextLocales())
+ && TextUtils.equals(lp.getFontFeatureSettings(), rp.getFontFeatureSettings())
+ && TextUtils.equals(lp.getFontVariationSettings(), rp.getFontVariationSettings())
+ && lp.getShadowLayerRadius() == rp.getShadowLayerRadius()
+ && lp.getShadowLayerDx() == rp.getShadowLayerDx()
+ && lp.getShadowLayerDy() == rp.getShadowLayerDy()
+ && lp.getShadowLayerColor() == rp.getShadowLayerColor()
+ && lp.getFlags() == rp.getFlags()
+ && lp.getHinting() == rp.getHinting()
+ && lp.getStyle() == rp.getStyle()
+ && lp.getColor() == rp.getColor()
+ && lp.getStrokeWidth() == rp.getStrokeWidth()
+ && lp.getStrokeMiter() == rp.getStrokeMiter()
+ && lp.getStrokeCap() == rp.getStrokeCap()
+ && lp.getStrokeJoin() == rp.getStrokeJoin()
+ && lp.getTextAlign() == rp.getTextAlign()
+ && lp.isElegantTextHeight() == rp.isElegantTextHeight()
+ && lp.getTextSize() == rp.getTextSize()
+ && lp.getTextScaleX() == rp.getTextScaleX()
+ && lp.getTextSkewX() == rp.getTextSkewX()
+ && lp.getLetterSpacing() == rp.getLetterSpacing()
+ && lp.getWordSpacing() == rp.getWordSpacing()
+ && lp.getHyphenEdit() == rp.getHyphenEdit()
+ && lp.bgColor == rp.bgColor
+ && lp.baselineShift == rp.baselineShift
+ && lp.linkColor == rp.linkColor
+ && lp.drawableState == rp.drawableState
+ && lp.density == rp.density
+ && lp.underlineColor == rp.underlineColor
+ && lp.underlineThickness == rp.underlineThickness;
+ }
}
diff --git a/core/java/android/text/TextPaint.java b/core/java/android/text/TextPaint.java
index 7bcc685..d5aad33 100644
--- a/core/java/android/text/TextPaint.java
+++ b/core/java/android/text/TextPaint.java
@@ -17,7 +17,7 @@
package android.text;
import android.annotation.ColorInt;
-import android.annotation.NonNull;
+import android.annotation.Px;
import android.annotation.UnsupportedAppUsage;
import android.graphics.Paint;
@@ -37,17 +37,14 @@
public float density = 1.0f;
/**
* Special value 0 means no custom underline
- * @hide
*/
@ColorInt
- @UnsupportedAppUsage
public int underlineColor = 0;
+
/**
* Thickness of the underline, in pixels.
- * @hide
*/
- @UnsupportedAppUsage
- public float underlineThickness;
+ public @Px float underlineThickness;
public TextPaint() {
super();
@@ -78,24 +75,6 @@
}
/**
- * Returns true if all attributes, including the attributes inherited from Paint, are equal.
- *
- * The caller is expected to have checked the trivial cases, like the pointers being equal,
- * the objects having different classes, or the parameter being null.
- * @hide
- */
- public boolean hasEqualAttributes(@NonNull TextPaint other) {
- return bgColor == other.bgColor
- && baselineShift == other.baselineShift
- && linkColor == other.linkColor
- && drawableState == other.drawableState
- && density == other.density
- && underlineColor == other.underlineColor
- && underlineThickness == other.underlineThickness
- && super.hasEqualAttributes((Paint) other);
- }
-
- /**
* Defines a custom underline for this Paint.
* @param color underline solid color
* @param thickness underline thickness
diff --git a/graphics/java/android/graphics/Paint.java b/graphics/java/android/graphics/Paint.java
index 33caa00..69ff3bc 100644
--- a/graphics/java/android/graphics/Paint.java
+++ b/graphics/java/android/graphics/Paint.java
@@ -592,49 +592,6 @@
mShadowLayerColor = paint.mShadowLayerColor;
}
- /**
- * Returns true if all attributes are equal.
- *
- * The caller is expected to have checked the trivial cases, like the pointers being equal,
- * the objects having different classes, or the parameter being null.
- * @hide
- */
- public boolean hasEqualAttributes(@NonNull Paint other) {
- return mColorFilter == other.mColorFilter
- && mMaskFilter == other.mMaskFilter
- && mPathEffect == other.mPathEffect
- && mShader == other.mShader
- && mTypeface == other.mTypeface
- && mXfermode == other.mXfermode
- && mHasCompatScaling == other.mHasCompatScaling
- && mCompatScaling == other.mCompatScaling
- && mInvCompatScaling == other.mInvCompatScaling
- && mBidiFlags == other.mBidiFlags
- && mLocales.equals(other.mLocales)
- && TextUtils.equals(mFontFeatureSettings, other.mFontFeatureSettings)
- && TextUtils.equals(mFontVariationSettings, other.mFontVariationSettings)
- && mShadowLayerRadius == other.mShadowLayerRadius
- && mShadowLayerDx == other.mShadowLayerDx
- && mShadowLayerDy == other.mShadowLayerDy
- && mShadowLayerColor == other.mShadowLayerColor
- && getFlags() == other.getFlags()
- && getHinting() == other.getHinting()
- && getStyle() == other.getStyle()
- && getColor() == other.getColor()
- && getStrokeWidth() == other.getStrokeWidth()
- && getStrokeMiter() == other.getStrokeMiter()
- && getStrokeCap() == other.getStrokeCap()
- && getStrokeJoin() == other.getStrokeJoin()
- && getTextAlign() == other.getTextAlign()
- && isElegantTextHeight() == other.isElegantTextHeight()
- && getTextSize() == other.getTextSize()
- && getTextScaleX() == other.getTextScaleX()
- && getTextSkewX() == other.getTextSkewX()
- && getLetterSpacing() == other.getLetterSpacing()
- && getWordSpacing() == other.getWordSpacing()
- && getHyphenEdit() == other.getHyphenEdit();
- }
-
/** @hide */
@UnsupportedAppUsage
public void setCompatibilityScaling(float factor) {
@@ -1395,6 +1352,38 @@
}
/**
+ * Returns the blur radius of the shadow layer.
+ * @see #setShadowLayer(float,float,float,int)
+ */
+ public float getShadowLayerRadius() {
+ return mShadowLayerRadius;
+ }
+
+ /**
+ * Returns the x offset of the shadow layer.
+ * @see #setShadowLayer(float,float,float,int)
+ */
+ public float getShadowLayerDx() {
+ return mShadowLayerDx;
+ }
+
+ /**
+ * Returns the y offset of the shadow layer.
+ * @see #setShadowLayer(float,float,float,int)
+ */
+ public float getShadowLayerDy() {
+ return mShadowLayerDy;
+ }
+
+ /**
+ * Returns the color of the shadow layer.
+ * @see #setShadowLayer(float,float,float,int)
+ */
+ public @ColorInt int getShadowLayerColor() {
+ return mShadowLayerColor;
+ }
+
+ /**
* Return the paint's Align value for drawing text. This controls how the
* text is positioned relative to its origin. LEFT align means that all of
* the text will be drawn to the right of its origin (i.e. the origin