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

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

Merge "Fix bug #4813026 resolved direction of view doesn't change after layout direction changes"

parents d3d4b4b8 80dc53d6
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -4345,20 +4345,26 @@ public class View implements Drawable.Callback2, KeyEvent.Callback, Accessibilit
    }

    /**
     * Set the layout direction for this view.
     * Set the layout direction for this view. This will propagate a reset of layout direction
     * resolution to the view's children and resolve layout direction for this view.
     *
     * @param layoutDirection One of {@link #LAYOUT_DIRECTION_LTR},
     *   {@link #LAYOUT_DIRECTION_RTL},
     *   {@link #LAYOUT_DIRECTION_INHERIT} or
     *   {@link #LAYOUT_DIRECTION_LOCALE}.
     *
     * @attr ref android.R.styleable#View_layoutDirection
     *
     * @hide
     */
    @RemotableViewMethod
    public void setLayoutDirection(int layoutDirection) {
        if (getLayoutDirection() != layoutDirection) {
            resetLayoutDirectionResolution();
            // Setting the flag will also request a layout.
            setFlags(layoutDirection, LAYOUT_DIRECTION_MASK);
        }
    }

    /**
     * Returns the resolved layout direction for this view.
@@ -8988,7 +8994,8 @@ public class View implements Drawable.Callback2, KeyEvent.Callback, Accessibilit
    /**
     * Reset the resolved layout direction by clearing the corresponding flag
     */
    private void resetLayoutDirectionResolution() {
    void resetLayoutDirectionResolution() {
        // Reset the current View resolution
        mPrivateFlags2 &= ~LAYOUT_DIRECTION_RESOLVED;
    }

+18 −0
Original line number Diff line number Diff line
@@ -4997,6 +4997,24 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
        viewAncestor.requestTransitionStart(transition);
    }

    /**
     * This method will be called when we need to reset the layout direction resolution flag
     *
     */
    @Override
    void resetLayoutDirectionResolution() {
        super.resetLayoutDirectionResolution();

        // Take care of resetting the children resolution too
        final int count = getChildCount();
        for (int i = 0; i < count; i++) {
            final View child = getChildAt(i);
            if (child.getLayoutDirection() == LAYOUT_DIRECTION_INHERIT) {
                child.resetLayoutDirectionResolution();
            }
        }
    }

    /**
     * Return true if the pressed state should be delayed for children or descendants of this
     * ViewGroup. Generally, this should be done for containers that can scroll, such as a List.