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

Commit 3e804a61 authored by Gilles Debunne's avatar Gilles Debunne Committed by Android (Google) Code Review
Browse files

Merge "Removed TextAlign in TextView"

parents b391f2e0 978a8ff8
Loading
Loading
Loading
Loading
+12 −60
Original line number Diff line number Diff line
@@ -243,10 +243,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
    private static final int SIGNED = 2;
    private static final int DECIMAL = 4;

    private static enum TEXT_ALIGN {
        INHERIT, GRAVITY, TEXT_START, TEXT_END, CENTER, VIEW_START, VIEW_END;
    }

    /**
     * Draw marquee text with fading edges as usual
     */
@@ -329,9 +325,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
    // The alignment to pass to Layout, or null if not resolved.
    private Layout.Alignment mLayoutAlignment;

    // The default value for mTextAlign.
    private TEXT_ALIGN mTextAlign = TEXT_ALIGN.INHERIT;

    private boolean mResolvedDrawables;

    /**
@@ -5667,69 +5660,28 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
                      physicalWidth, false);
    }

    @Override
    protected void resetResolvedLayoutDirection() {
        super.resetResolvedLayoutDirection();

        if (mLayoutAlignment != null &&
                (mTextAlign == TEXT_ALIGN.VIEW_START ||
                mTextAlign == TEXT_ALIGN.VIEW_END)) {
            mLayoutAlignment = null;
        }
    }

    private Layout.Alignment getLayoutAlignment() {
        if (mLayoutAlignment == null) {
            Layout.Alignment alignment;
            TEXT_ALIGN textAlign = mTextAlign;
            switch (textAlign) {
                case INHERIT:
                    // fall through to gravity temporarily
                    // intention is to inherit value through view hierarchy.
                case GRAVITY:
            switch (mGravity & Gravity.RELATIVE_HORIZONTAL_GRAVITY_MASK) {
                case Gravity.START:
                            alignment = Layout.Alignment.ALIGN_NORMAL;
                    mLayoutAlignment = Layout.Alignment.ALIGN_NORMAL;
                    break;
                case Gravity.END:
                            alignment = Layout.Alignment.ALIGN_OPPOSITE;
                    mLayoutAlignment = Layout.Alignment.ALIGN_OPPOSITE;
                    break;
                case Gravity.LEFT:
                            alignment = Layout.Alignment.ALIGN_LEFT;
                    mLayoutAlignment = Layout.Alignment.ALIGN_LEFT;
                    break;
                case Gravity.RIGHT:
                            alignment = Layout.Alignment.ALIGN_RIGHT;
                    mLayoutAlignment = Layout.Alignment.ALIGN_RIGHT;
                    break;
                case Gravity.CENTER_HORIZONTAL:
                            alignment = Layout.Alignment.ALIGN_CENTER;
                            break;
                        default:
                            alignment = Layout.Alignment.ALIGN_NORMAL;
                            break;
                    }
                    break;
                case TEXT_START:
                    alignment = Layout.Alignment.ALIGN_NORMAL;
                    break;
                case TEXT_END:
                    alignment = Layout.Alignment.ALIGN_OPPOSITE;
                    break;
                case CENTER:
                    alignment = Layout.Alignment.ALIGN_CENTER;
                    break;
                case VIEW_START:
                    alignment = (getResolvedLayoutDirection() == LAYOUT_DIRECTION_RTL) ?
                            Layout.Alignment.ALIGN_RIGHT : Layout.Alignment.ALIGN_LEFT;
                    break;
                case VIEW_END:
                    alignment = (getResolvedLayoutDirection() == LAYOUT_DIRECTION_RTL) ?
                            Layout.Alignment.ALIGN_LEFT : Layout.Alignment.ALIGN_RIGHT;
                    mLayoutAlignment = Layout.Alignment.ALIGN_CENTER;
                    break;
                default:
                    alignment = Layout.Alignment.ALIGN_NORMAL;
                    mLayoutAlignment = Layout.Alignment.ALIGN_NORMAL;
                    break;
            }
            mLayoutAlignment = alignment;
        }
        return mLayoutAlignment;
    }