Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9d40d872 authored by Adam Powell's avatar Adam Powell Committed by Android (Google) Code Review
Browse files

Merge "Add support for shadows in TextAppearance styles"

parents 07aef1c7 ac91df87
Loading
Loading
Loading
Loading
+31 −2
Original line number Diff line number Diff line
@@ -607,6 +607,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
        int typefaceIndex = -1;
        int styleIndex = -1;
        boolean allCaps = false;
        int shadowcolor = 0;
        float dx = 0, dy = 0, r = 0;

        final Resources.Theme theme = context.getTheme();

@@ -667,6 +669,22 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
                case com.android.internal.R.styleable.TextAppearance_textAllCaps:
                    allCaps = appearance.getBoolean(attr, false);
                    break;

                case com.android.internal.R.styleable.TextAppearance_shadowColor:
                    shadowcolor = a.getInt(attr, 0);
                    break;

                case com.android.internal.R.styleable.TextAppearance_shadowDx:
                    dx = a.getFloat(attr, 0);
                    break;

                case com.android.internal.R.styleable.TextAppearance_shadowDy:
                    dy = a.getFloat(attr, 0);
                    break;

                case com.android.internal.R.styleable.TextAppearance_shadowRadius:
                    r = a.getFloat(attr, 0);
                    break;
                }
            }

@@ -690,8 +708,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
        int maxlength = -1;
        CharSequence text = "";
        CharSequence hint = null;
        int shadowcolor = 0;
        float dx = 0, dy = 0, r = 0;
        boolean password = false;
        int inputType = EditorInfo.TYPE_NULL;

@@ -2331,6 +2347,19 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener

        setTypefaceFromAttrs(familyName, typefaceIndex, styleIndex);

        final int shadowcolor = appearance.getInt(
                com.android.internal.R.styleable.TextAppearance_shadowColor, 0);
        if (shadowcolor != 0) {
            final float dx = appearance.getFloat(
                    com.android.internal.R.styleable.TextAppearance_shadowDx, 0);
            final float dy = appearance.getFloat(
                    com.android.internal.R.styleable.TextAppearance_shadowDy, 0);
            final float r = appearance.getFloat(
                    com.android.internal.R.styleable.TextAppearance_shadowRadius, 0);

            setShadowLayer(r, dx, dy, shadowcolor);
        }

        if (appearance.getBoolean(com.android.internal.R.styleable.TextAppearance_textAllCaps,
                false)) {
            setTransformationMethod(new AllCapsTransformationMethod(getContext()));
+12 −4
Original line number Diff line number Diff line
@@ -3061,6 +3061,14 @@
        <attr name="textColorLink" />
        <!-- Present the text in ALL CAPS. This may use a small-caps form when available. -->
        <attr name="textAllCaps" format="boolean" />
        <!-- Place a shadow of the specified color behind the text. -->
        <attr name="shadowColor" format="color" />
        <!-- Horizontal offset of the shadow. -->
        <attr name="shadowDx" format="float" />
        <!-- Vertical offset of the shadow. -->
        <attr name="shadowDy" format="float" />
        <!-- Radius of the shadow. -->
        <attr name="shadowRadius" format="float" />
    </declare-styleable>
    <declare-styleable name="TextClock">
        <!-- Specifies the formatting pattern used to show the time and/or date
@@ -3195,13 +3203,13 @@
             specified number. -->
        <attr name="maxLength" format="integer" min="0" />
        <!-- Place a shadow of the specified color behind the text. -->
        <attr name="shadowColor" format="color" />
        <attr name="shadowColor" />
        <!-- Horizontal offset of the shadow. -->
        <attr name="shadowDx" format="float" />
        <attr name="shadowDx" />
        <!-- Vertical offset of the shadow. -->
        <attr name="shadowDy" format="float" />
        <attr name="shadowDy" />
        <!-- Radius of the shadow. -->
        <attr name="shadowRadius" format="float" />
        <attr name="shadowRadius" />
        <attr name="autoLink" />
        <!-- If set to false, keeps the movement method from being set
             to the link movement method even if autoLink causes links