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

Commit 1a7d4873 authored by Fabrice Di Meglio's avatar Fabrice Di Meglio
Browse files

Fix bug #6427629 Clean up layout direction APIs

- rename getResolvedTextAlignment() to getTextAlignment()

Change-Id: I6a2b6c9ec4f5cea1adde46e35d5f3c49880791ee
parent 97e146cf
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 getResolvedTextAlignment();
    method public android.content.res.Resources getResources();
    method public final int getRight();
    method protected float getRightFadingEdgeStrength();
+15 −6
Original line number Diff line number Diff line
@@ -16664,6 +16664,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     * {@link #TEXT_ALIGNMENT_TEXT_END},
     * {@link #TEXT_ALIGNMENT_VIEW_START},
     * {@link #TEXT_ALIGNMENT_VIEW_END}
     *
     * @hide
     */
    @ViewDebug.ExportedProperty(category = "text", mapping = {
            @ViewDebug.IntToString(from = TEXT_ALIGNMENT_INHERIT, to = "INHERIT"),
@@ -16674,7 +16676,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
            @ViewDebug.IntToString(from = TEXT_ALIGNMENT_VIEW_START, to = "VIEW_START"),
            @ViewDebug.IntToString(from = TEXT_ALIGNMENT_VIEW_END, to = "VIEW_END")
    })
    public int getTextAlignment() {
    public int getRawTextAlignment() {
        return (mPrivateFlags2 & PFLAG2_TEXT_ALIGNMENT_MASK) >> PFLAG2_TEXT_ALIGNMENT_MASK_SHIFT;
    }
@@ -16694,7 +16696,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     * @attr ref android.R.styleable#View_textAlignment
     */
    public void setTextAlignment(int textAlignment) {
        if (textAlignment != getTextAlignment()) {
        if (textAlignment != getRawTextAlignment()) {
            // Reset the current and resolved text alignment
            mPrivateFlags2 &= ~PFLAG2_TEXT_ALIGNMENT_MASK;
            resetResolvedTextAlignment();
@@ -16733,7 +16735,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
            @ViewDebug.IntToString(from = TEXT_ALIGNMENT_VIEW_START, to = "VIEW_START"),
            @ViewDebug.IntToString(from = TEXT_ALIGNMENT_VIEW_END, to = "VIEW_END")
    })
    public int getResolvedTextAlignment() {
    public int getTextAlignment() {
        // If text alignment is not resolved, then resolve it
        if ((mPrivateFlags2 & PFLAG2_TEXT_ALIGNMENT_RESOLVED) != PFLAG2_TEXT_ALIGNMENT_RESOLVED) {
            resolveTextAlignment();
@@ -16752,14 +16754,14 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
        if (hasRtlSupport()) {
            // Set resolved text alignment flag depending on text alignment flag
            final int textAlignment = getTextAlignment();
            final int textAlignment = getRawTextAlignment();
            switch (textAlignment) {
                case TEXT_ALIGNMENT_INHERIT:
                    // Check if we can resolve the text alignment
                    if (canResolveTextAlignment() && mParent instanceof View) {
                        View view = (View) mParent;
                        final int parentResolvedTextAlignment = view.getResolvedTextAlignment();
                        final int parentResolvedTextAlignment = view.getTextAlignment();
                        switch (parentResolvedTextAlignment) {
                            case TEXT_ALIGNMENT_GRAVITY:
                            case TEXT_ALIGNMENT_TEXT_START:
@@ -16810,7 +16812,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     * @return true if text alignment resolution can be done otherwise return false.
     */
    private boolean canResolveTextAlignment() {
        switch (getTextAlignment()) {
        switch (getRawTextAlignment()) {
            case TEXT_DIRECTION_INHERIT:
                return (mParent != null);
            default:
@@ -16828,6 +16830,13 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
        mPrivateFlags2 &= ~(PFLAG2_TEXT_ALIGNMENT_RESOLVED | PFLAG2_TEXT_ALIGNMENT_RESOLVED_MASK);
    }
    /**
     * @hide
     */
    public boolean isTextAlignmentInherited() {
        return (getRawTextAlignment() == TEXT_ALIGNMENT_INHERIT);
    }
    /**
     * Generate a value suitable for use in {@link #setId(int)}.
     * This value will not collide with ID values generated at build time by aapt for R.id.
+1 −1
Original line number Diff line number Diff line
@@ -5274,7 +5274,7 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
            if (child.isTextDirectionInherited()) {
                child.resetResolvedTextDirection();
            }
            if (child.getTextAlignment() == TEXT_ALIGNMENT_INHERIT) {
            if (child.isTextAlignmentInherited()) {
                child.resetResolvedTextAlignment();
            }
        }
+1 −1
Original line number Diff line number Diff line
@@ -5646,7 +5646,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener

    private Layout.Alignment getLayoutAlignment() {
        if (mLayoutAlignment == null) {
            mResolvedTextAlignment = getResolvedTextAlignment();
            mResolvedTextAlignment = getTextAlignment();
            switch (mResolvedTextAlignment) {
                case TEXT_ALIGNMENT_GRAVITY:
                    switch (mGravity & Gravity.RELATIVE_HORIZONTAL_GRAVITY_MASK) {