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

Commit 3bef5e9f authored by Fabrice Di Meglio's avatar Fabrice Di Meglio Committed by Android (Google) Code Review
Browse files

Merge "Fix View padding resolution"

parents 0c245fb2 509708de
Loading
Loading
Loading
Loading
+23 −9
Original line number Diff line number Diff line
@@ -3093,13 +3093,13 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
            setBackgroundDrawable(background);
        }
        mUserPaddingRelative = (startPadding >= 0 || endPadding >= 0);
        // Cache user padding as we cannot fully resolve padding here (we dont have yet the resolved
        // layout direction). Those cached values will be used later during padding resolution.
        mUserPaddingStart = startPadding;
        mUserPaddingEnd = endPadding;
        updateUserPaddingRelative();
        if (padding >= 0) {
            leftPadding = padding;
            topPadding = padding;
@@ -3146,6 +3146,10 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
        computeOpaqueFlags();
    }
    private void updateUserPaddingRelative() {
        mUserPaddingRelative = (mUserPaddingStart >= 0 || mUserPaddingEnd >= 0);
    }
    /**
     * Non-public constructor for use in testing
     */
@@ -9644,6 +9648,8 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
        // Set to resolved
        mPrivateFlags2 |= LAYOUT_DIRECTION_RESOLVED;
        onResolvedLayoutDirectionChanged();
        // Resolve padding
        resolvePadding();
    }
    /**
@@ -9698,7 +9704,11 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
        mUserPaddingBottom = (mUserPaddingBottom >= 0) ? mUserPaddingBottom : mPaddingBottom;
        if(isPaddingRelative()) {
            setPaddingRelative(mUserPaddingStart, mPaddingTop, mUserPaddingEnd, mUserPaddingBottom);
        } else {
            recomputePadding();
        }
        onPaddingChanged(resolvedLayoutDirection);
    }
@@ -12233,15 +12243,20 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
     * @param bottom the bottom padding in pixels
     */
    public void setPadding(int left, int top, int right, int bottom) {
        boolean changed = false;
        mUserPaddingStart = -1;
        mUserPaddingEnd = -1;
        mUserPaddingRelative = false;
        internalSetPadding(left, top, right, bottom);
    }
    private void internalSetPadding(int left, int top, int right, int bottom) {
        mUserPaddingLeft = left;
        mUserPaddingRight = right;
        mUserPaddingBottom = bottom;
        final int viewFlags = mViewFlags;
        boolean changed = false;
        // Common case is there are no scroll bars.
        if ((viewFlags & (SCROLLBARS_VERTICAL|SCROLLBARS_HORIZONTAL)) != 0) {
@@ -12310,18 +12325,17 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
     * @param bottom the bottom padding in pixels
     */
    public void setPaddingRelative(int start, int top, int end, int bottom) {
        mUserPaddingRelative = true;
        mUserPaddingStart = start;
        mUserPaddingEnd = end;
        mUserPaddingRelative = true;
        switch(getResolvedLayoutDirection()) {
            case LAYOUT_DIRECTION_RTL:
                setPadding(end, top, start, bottom);
                internalSetPadding(end, top, start, bottom);
                break;
            case LAYOUT_DIRECTION_LTR:
            default:
                setPadding(start, top, end, bottom);
                internalSetPadding(start, top, end, bottom);
        }
    }