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

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

Fix bug #6427629 Clean up layout direction APIs

- rename getResolvedLayoutDirection() to getLayoutDirection()

Change-Id: I3afe56c0db0751952f5056c23893cb7455531d29
parent 4457e85a
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -24898,7 +24898,6 @@ package android.view {
    method public android.view.ViewParent getParentForAccessibility();
    method public float getPivotX();
    method public float getPivotY();
    method public int getResolvedLayoutDirection();
    method public int getResolvedTextAlignment();
    method public int getResolvedTextDirection();
    method public android.content.res.Resources getResources();
+25 −16
Original line number Diff line number Diff line
@@ -3926,7 +3926,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
        }
        // Apply layout direction to the new Drawables if needed
        final int layoutDirection = getResolvedLayoutDirection();
        final int layoutDirection = getLayoutDirection();
        if (track != null) {
            track.setLayoutDirection(layoutDirection);
        }
@@ -5778,7 +5778,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
        @ViewDebug.IntToString(from = LAYOUT_DIRECTION_INHERIT, to = "INHERIT"),
        @ViewDebug.IntToString(from = LAYOUT_DIRECTION_LOCALE,  to = "LOCALE")
    })
    public int getLayoutDirection() {
    private int getRawLayoutDirection() {
        return (mPrivateFlags2 & PFLAG2_LAYOUT_DIRECTION_MASK) >> PFLAG2_LAYOUT_DIRECTION_MASK_SHIFT;
    }
@@ -5795,7 +5795,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     */
    @RemotableViewMethod
    public void setLayoutDirection(int layoutDirection) {
        if (getLayoutDirection() != layoutDirection) {
        if (getRawLayoutDirection() != layoutDirection) {
            // Reset the current layout direction and the resolved one
            mPrivateFlags2 &= ~PFLAG2_LAYOUT_DIRECTION_MASK;
            resetRtlProperties();
@@ -5820,7 +5820,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
        @ViewDebug.IntToString(from = LAYOUT_DIRECTION_LTR, to = "RESOLVED_DIRECTION_LTR"),
        @ViewDebug.IntToString(from = LAYOUT_DIRECTION_RTL, to = "RESOLVED_DIRECTION_RTL")
    })
    public int getResolvedLayoutDirection() {
    public int getLayoutDirection() {
        final int targetSdkVersion = getContext().getApplicationInfo().targetSdkVersion;
        if (targetSdkVersion < JELLY_BEAN_MR1) {
            mPrivateFlags2 |= PFLAG2_LAYOUT_DIRECTION_RESOLVED;
@@ -5842,7 +5842,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     */
    @ViewDebug.ExportedProperty(category = "layout")
    public boolean isLayoutRtl() {
        return (getResolvedLayoutDirection() == LAYOUT_DIRECTION_RTL);
        return (getLayoutDirection() == LAYOUT_DIRECTION_RTL);
    }
    /**
@@ -9935,7 +9935,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     */
    private void resolveLayoutParams() {
        if (mLayoutParams != null) {
            mLayoutParams.onResolveLayoutDirection(getResolvedLayoutDirection());
            mLayoutParams.onResolveLayoutDirection(getLayoutDirection());
        }
    }
@@ -11560,7 +11560,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
        if (hasRtlSupport()) {
            // Set resolved depending on layout direction
            switch (getLayoutDirection()) {
            switch ((mPrivateFlags2 & PFLAG2_LAYOUT_DIRECTION_MASK) >>
                    PFLAG2_LAYOUT_DIRECTION_MASK_SHIFT) {
                case LAYOUT_DIRECTION_INHERIT:
                    // We cannot resolve yet. LTR is by default and let the resolution happen again
                    // later to get the correct resolved value
@@ -11572,7 +11573,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
                    // resolution happen again later
                    if (!viewGroup.canResolveLayoutDirection()) return;
                    if (viewGroup.getResolvedLayoutDirection() == LAYOUT_DIRECTION_RTL) {
                    if (viewGroup.getLayoutDirection() == LAYOUT_DIRECTION_RTL) {
                        mPrivateFlags2 |= PFLAG2_LAYOUT_DIRECTION_RESOLVED_RTL;
                    }
                    break;
@@ -11602,7 +11603,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     * @hide
     */
    public boolean canResolveLayoutDirection() {
        switch (getLayoutDirection()) {
        switch ((mPrivateFlags2 & PFLAG2_LAYOUT_DIRECTION_MASK) >>
                PFLAG2_LAYOUT_DIRECTION_MASK_SHIFT) {
            case LAYOUT_DIRECTION_INHERIT:
                return (mParent != null) && (mParent instanceof ViewGroup);
            default:
@@ -11620,6 +11622,13 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
        mPrivateFlags2 &= ~PFLAG2_LAYOUT_DIRECTION_RESOLVED_MASK;
    }
    /**
     * @hide
     */
    public boolean isLayoutDirectionInherited() {
        return (getRawLayoutDirection() == LAYOUT_DIRECTION_INHERIT);
    }
    /**
     * Return if padding has been resolved
     *
@@ -11659,7 +11668,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
            // If start / end padding are defined, they will be resolved (hence overriding) to
            // left / right or right / left depending on the resolved layout direction.
            // If start / end padding are not defined, use the left / right ones.
            int resolvedLayoutDirection = getResolvedLayoutDirection();
            int resolvedLayoutDirection = getLayoutDirection();
            // Set user padding to initial values ...
            mUserPaddingLeft = (mUserPaddingLeftInitial == UNDEFINED_PADDING) ?
                    0 : mUserPaddingLeftInitial;
@@ -14101,9 +14110,9 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     */
    public void resolveDrawables() {
        if (mBackground != null) {
            mBackground.setLayoutDirection(getResolvedLayoutDirection());
            mBackground.setLayoutDirection(getLayoutDirection());
        }
        onResolveDrawables(getResolvedLayoutDirection());
        onResolveDrawables(getLayoutDirection());
    }
    /**
@@ -14390,7 +14399,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
                padding = new Rect();
                sThreadLocal.set(padding);
            }
            background.setLayoutDirection(getResolvedLayoutDirection());
            background.setLayoutDirection(getLayoutDirection());
            if (background.getPadding(padding)) {
                resetResolvedPadding();
                switch (background.getLayoutDirection()) {
@@ -14587,7 +14596,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
        mUserPaddingStart = start;
        mUserPaddingEnd = end;
        switch(getResolvedLayoutDirection()) {
        switch(getLayoutDirection()) {
            case LAYOUT_DIRECTION_RTL:
                mUserPaddingLeftInitial = end;
                mUserPaddingRightInitial = start;
@@ -14646,7 +14655,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
        if (!isPaddingResolved()) {
            resolvePadding();
        }
        return (getResolvedLayoutDirection() == LAYOUT_DIRECTION_RTL) ?
        return (getLayoutDirection() == LAYOUT_DIRECTION_RTL) ?
                mPaddingRight : mPaddingLeft;
    }
@@ -14675,7 +14684,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
        if (!isPaddingResolved()) {
            resolvePadding();
        }
        return (getResolvedLayoutDirection() == LAYOUT_DIRECTION_RTL) ?
        return (getLayoutDirection() == LAYOUT_DIRECTION_RTL) ?
                mPaddingLeft : mPaddingRight;
    }
+3 −3
Original line number Diff line number Diff line
@@ -3392,7 +3392,7 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
            childHasTransientStateChanged(child, true);
        }

        if (child.getLayoutDirection() == View.LAYOUT_DIRECTION_INHERIT) {
        if (child.isLayoutDirectionInherited()) {
            child.resetResolvedLayoutDirection();
            child.resolveRtlProperties();
        }
@@ -5268,7 +5268,7 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
        int count = getChildCount();
        for (int i = 0; i < count; i++) {
            final View child = getChildAt(i);
            if (child.getLayoutDirection() == LAYOUT_DIRECTION_INHERIT) {
            if (child.isLayoutDirectionInherited()) {
                child.resetResolvedLayoutDirection();
            }
            if (child.getTextDirection() == TEXT_DIRECTION_INHERIT) {
@@ -6155,7 +6155,7 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
            view.getDrawingRect(viewLocation);
            root.offsetDescendantRectToMyCoords(view, viewLocation);
            mView = view;
            mLayoutDirection = root.getResolvedLayoutDirection();
            mLayoutDirection = root.getLayoutDirection();
        }

        private void clear() {
+1 −1
Original line number Diff line number Diff line
@@ -108,7 +108,7 @@ public abstract class AbsSeekBar extends ProgressBar {
        if (thumb != null) {
            thumb.setCallback(this);
            if (canResolveLayoutDirection()) {
                thumb.setLayoutDirection(getResolvedLayoutDirection());
                thumb.setLayoutDirection(getLayoutDirection());
            }

            // Assuming the thumb drawable is symmetric, set the thumb offset
+1 −2
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@

package android.widget;

import android.app.SearchManager.OnDismissListener;
import android.content.Context;
import android.content.res.TypedArray;
import android.database.DataSetObserver;
@@ -1094,7 +1093,7 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe
            mPopup.setInputMethodMode(ListPopupWindow.INPUT_METHOD_NEEDED);
            mPopup.setListItemExpandMax(EXPAND_MAX);
        }
        mPopup.setLayoutDirection(getResolvedLayoutDirection());
        mPopup.setLayoutDirection(getLayoutDirection());
        mPopup.show();
        mPopup.getListView().setOverScrollMode(View.OVER_SCROLL_ALWAYS);
    }
Loading