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

Commit b878ddb5 authored by Fabrice Di Meglio's avatar Fabrice Di Meglio
Browse files

Fix bug #7621927 Radio button/TextView drawable regression in 4.2

- as we remove the 9 patch padding trick, we need also to do the correct
positioning of the radio / checkbox / star during draw

Change-Id: I02b67bef9c0f2dc1c0c65361de14ab20ce9b881d
parent 02053d1c
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -248,6 +248,15 @@ public abstract class CompoundButton extends Button implements Checkable {
        return padding;
    }

    /**
     * @hide
     */
    @Override
    public int getHorizontalOffsetForDrawables() {
        final Drawable buttonDrawable = mButtonDrawable;
        return (buttonDrawable != null) ? buttonDrawable.getIntrinsicWidth() : 0;
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
+14 −4
Original line number Diff line number Diff line
@@ -4734,6 +4734,13 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
        return highlight;
    }

    /**
     * @hide
     */
    public int getHorizontalOffsetForDrawables() {
        return 0;
    }

    @Override
    protected void onDraw(Canvas canvas) {
        restartMarqueeIfNeeded();
@@ -4751,6 +4758,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
        final int left = mLeft;
        final int bottom = mBottom;
        final int top = mTop;
        final boolean isLayoutRtl = isLayoutRtl();
        final int offset = getHorizontalOffsetForDrawables();
        final int leftOffset = isLayoutRtl ? 0 : offset;
        final int rightOffset = isLayoutRtl ? offset : 0 ;

        final Drawables dr = mDrawables;
        if (dr != null) {
@@ -4766,7 +4777,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
            // Make sure to update invalidateDrawable() when changing this code.
            if (dr.mDrawableLeft != null) {
                canvas.save();
                canvas.translate(scrollX + mPaddingLeft,
                canvas.translate(scrollX + mPaddingLeft + leftOffset,
                                 scrollY + compoundPaddingTop +
                                 (vspace - dr.mDrawableHeightLeft) / 2);
                dr.mDrawableLeft.draw(canvas);
@@ -4777,7 +4788,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
            // Make sure to update invalidateDrawable() when changing this code.
            if (dr.mDrawableRight != null) {
                canvas.save();
                canvas.translate(scrollX + right - left - mPaddingRight - dr.mDrawableSizeRight,
                canvas.translate(scrollX + right - left - mPaddingRight
                        - dr.mDrawableSizeRight - rightOffset,
                         scrollY + compoundPaddingTop + (vspace - dr.mDrawableHeightRight) / 2);
                dr.mDrawableRight.draw(canvas);
                canvas.restore();
@@ -4862,8 +4874,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
        }
        canvas.translate(compoundPaddingLeft, extendedPaddingTop + voffsetText);

        final boolean isLayoutRtl = isLayoutRtl();

        final int layoutDirection = getLayoutDirection();
        final int absoluteGravity = Gravity.getAbsoluteGravity(mGravity, layoutDirection);
        if (mEllipsize == TextUtils.TruncateAt.MARQUEE &&