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

Commit 7632cb9b authored by Cibu Johny's avatar Cibu Johny Committed by Fabrice Di Meglio
Browse files

Adding horizontalDirection public attribute for View.

Change-Id: Ic8a03447252e4e155c3ee874b1d8c8ac0bc9f7f5
parent f470ced7
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -475,6 +475,7 @@ package android {
    field public static final int hint = 16843088; // 0x1010150
    field public static final int homeAsUpIndicator = 16843531; // 0x101030b
    field public static final int homeLayout = 16843549; // 0x101031d
    field public static final int horizontalDirection = 16843628; // 0x101036c
    field public static final int horizontalDivider = 16843053; // 0x101012d
    field public static final int horizontalGap = 16843327; // 0x101023f
    field public static final int horizontalScrollViewStyle = 16843603; // 0x1010353
+83 −0
Original line number Diff line number Diff line
@@ -950,6 +950,43 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
     */
    static final int PARENT_SAVE_DISABLED_MASK = 0x20000000;

    /**
     * Horizontal direction of this view is from Left to Right.
     * Use with {@link #setHorizontalDirection}.
     * {@hide}
     */
    public static final int HORIZONTAL_DIRECTION_LTR = 0x00000000;

    /**
     * Horizontal direction of this view is from Right to Left.
     * Use with {@link #setHorizontalDirection}.
     * {@hide}
     */
    public static final int HORIZONTAL_DIRECTION_RTL = 0x40000000;

    /**
     * Horizontal direction of this view is inherited from its parent.
     * Use with {@link #setHorizontalDirection}.
     * {@hide}
     */
    public static final int HORIZONTAL_DIRECTION_INHERIT = 0x80000000;

    /**
     * Horizontal direction of this view is from deduced from the default language
     * script for the locale. Use with {@link #setHorizontalDirection}.
     * {@hide}
     */
    public static final int HORIZONTAL_DIRECTION_LOCALE = 0xC0000000;

    /**
     * Mask for use with setFlags indicating bits used for horizontalDirection.
     * {@hide}
     */
    static final int HORIZONTAL_DIRECTION_MASK = 0xC0000000;

    private static final int[] HORIZONTAL_DIRECTION_FLAGS = { HORIZONTAL_DIRECTION_LTR,
            HORIZONTAL_DIRECTION_RTL, HORIZONTAL_DIRECTION_INHERIT, HORIZONTAL_DIRECTION_LOCALE};

    /**
     * View flag indicating whether {@link #addFocusables(ArrayList, int, int)}
     * should add all focusable Views regardless if they are focusable in touch mode.
@@ -2598,6 +2635,13 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
                        viewFlagMasks |= VISIBILITY_MASK;
                    }
                    break;
                case com.android.internal.R.styleable.View_horizontalDirection:
                  final int layoutDirection = a.getInt(attr, 0);
                  if (layoutDirection != 0) {
                      viewFlagValues |= HORIZONTAL_DIRECTION_FLAGS[layoutDirection];
                      viewFlagMasks |= HORIZONTAL_DIRECTION_MASK;
                  }
                  break;
                case com.android.internal.R.styleable.View_drawingCacheQuality:
                    final int cacheQuality = a.getInt(attr, 0);
                    if (cacheQuality != 0) {
@@ -3979,6 +4023,41 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
        return HAPTIC_FEEDBACK_ENABLED == (mViewFlags & HAPTIC_FEEDBACK_ENABLED);
    }

    /**
     * Returns the horizontal direction for this view.
     *
     * @return One of {@link #HORIZONTAL_DIRECTION_LTR},
     *   {@link #HORIZONTAL_DIRECTION_RTL},
     *   {@link #HORIZONTAL_DIRECTION_INHERIT} or
     *   {@link #HORIZONTAL_DIRECTION_LOCALE}.
     * @attr ref android.R.styleable#View_horizontalDirection
     * @hide
     */
    @ViewDebug.ExportedProperty(mapping = {
        @ViewDebug.IntToString(from = HORIZONTAL_DIRECTION_LTR,     to = "LTR"),
        @ViewDebug.IntToString(from = HORIZONTAL_DIRECTION_RTL,     to = "RTL"),
        @ViewDebug.IntToString(from = HORIZONTAL_DIRECTION_INHERIT, to = "INHERIT"),
        @ViewDebug.IntToString(from = HORIZONTAL_DIRECTION_LOCALE,  to = "LOCALE")
    })
    public int getHorizontalDirection() {
        return mViewFlags & HORIZONTAL_DIRECTION_MASK;
    }

    /**
     * Set the horizontal direction for this view.
     *
     * @param horizontalDirection One of {@link #HORIZONTAL_DIRECTION_LTR},
     *   {@link #HORIZONTAL_DIRECTION_RTL},
     *   {@link #HORIZONTAL_DIRECTION_INHERIT} or
     *   {@link #HORIZONTAL_DIRECTION_LOCALE}.
     * @attr ref android.R.styleable#View_horizontalDirection
     * @hide
     */
    @RemotableViewMethod
    public void setHorizontalDirection(int horizontalDirection) {
        setFlags(horizontalDirection, HORIZONTAL_DIRECTION_MASK);
    }

    /**
     * If this view doesn't do any drawing on its own, set this flag to
     * allow further optimizations. By default, this flag is not set on
@@ -5789,6 +5868,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
                mParent.recomputeViewAttributes(this);
            }
        }

        if ((changed & HORIZONTAL_DIRECTION_MASK) != 0) {
            requestLayout();
        }
    }

    /**
+16 −0
Original line number Diff line number Diff line
@@ -1913,6 +1913,22 @@
                 more information. -->
            <enum name="hardware" value="2" />
        </attr>

        <!-- Defines the direction of layout drawing. This typically is associated with writing
             direction of the language script used. The possible values are Left-to-Right,
             Right-to-Left, Locale and Inherit from parent view. If there is nothing to inherit,
             Locale is used. Locale fallsback to 'en-US'. Left-to-Right is the direction used in
             'en-US'. The default for this attribute is 'inherit'. -->
        <attr name="horizontalDirection">
            <!-- Left-to-Right -->
            <enum name="ltr" value="0" />
            <!-- Right-to-Left -->
            <enum name="rtl" value="1" />
            <!-- Inherit from parent -->
            <enum name="inherit" value="2" />
            <!-- Locale -->
            <enum name="locale" value="3" />
        </attr>
    </declare-styleable>

    <!-- Attributes that can be used with a {@link android.view.ViewGroup} or any
+1 −0
Original line number Diff line number Diff line
@@ -1667,5 +1667,6 @@
  <public type="attr" name="textEditSuggestionsBottomWindowLayout" />
  <public type="attr" name="textEditSuggestionsTopWindowLayout" />
  <public type="attr" name="textEditSuggestionItemLayout" />
  <public type="attr" name="horizontalDirection" />

</resources>