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

Commit 4ab6968b authored by Fabrice Di Meglio's avatar Fabrice Di Meglio
Browse files

Fix dividers position for LinearLayout

- see bug #5429822 UI should be mirrored for RTL locales (Arabic, Hebrew, farsi)

Change-Id: I81a294966ec3989785c0b55d2e4d418ddc89fadd
parent 3a4832aa
Loading
Loading
Loading
Loading
+20 −6
Original line number Original line Diff line number Diff line
@@ -345,28 +345,42 @@ public class LinearLayout extends ViewGroup {


    void drawDividersHorizontal(Canvas canvas) {
    void drawDividersHorizontal(Canvas canvas) {
        final int count = getVirtualChildCount();
        final int count = getVirtualChildCount();
        final boolean isLayoutRtl = isLayoutRtl();
        for (int i = 0; i < count; i++) {
        for (int i = 0; i < count; i++) {
            final View child = getVirtualChildAt(i);
            final View child = getVirtualChildAt(i);


            if (child != null && child.getVisibility() != GONE) {
            if (child != null && child.getVisibility() != GONE) {
                if (hasDividerBeforeChildAt(i)) {
                if (hasDividerBeforeChildAt(i)) {
                    final LayoutParams lp = (LayoutParams) child.getLayoutParams();
                    final LayoutParams lp = (LayoutParams) child.getLayoutParams();
                    final int left = child.getLeft() - lp.leftMargin - mDividerWidth;
                    final int position;
                    drawVerticalDivider(canvas, left);
                    if (isLayoutRtl) {
                        position = child.getRight() + lp.rightMargin;
                    } else {
                        position = child.getLeft() - lp.leftMargin - mDividerWidth;
                    }
                    drawVerticalDivider(canvas, position);
                }
                }
            }
            }
        }
        }


        if (hasDividerBeforeChildAt(count)) {
        if (hasDividerBeforeChildAt(count)) {
            final View child = getVirtualChildAt(count - 1);
            final View child = getVirtualChildAt(count - 1);
            int right = 0;
            int position;
            if (child == null) {
            if (child == null) {
                right = getWidth() - getPaddingRight() - mDividerWidth;
                if (isLayoutRtl) {
                    position = getPaddingLeft();
                } else {
                    position = getWidth() - getPaddingRight() - mDividerWidth;
                }
            } else {
            } else {
                final LayoutParams lp = (LayoutParams) child.getLayoutParams();
                final LayoutParams lp = (LayoutParams) child.getLayoutParams();
                right = child.getRight() + lp.rightMargin;
                if (isLayoutRtl) {
                    position = child.getLeft() - lp.leftMargin - mDividerWidth;
                } else {
                    position = child.getRight() + lp.rightMargin;
                }
            }
            }
            drawVerticalDivider(canvas, right);
            drawVerticalDivider(canvas, position);
        }
        }
    }
    }