Skip to content

Commit f7a3e97

Browse files
Fabrice Di MeglioAndroid (Google) Code Review
authored andcommitted
Merge "Fix bug #6427629 Clean up layout direction APIs" into jb-mr1-dev
2 parents ac4bd00 + 1a7d487 commit f7a3e97

File tree

4 files changed

+17
-9
lines changed

4 files changed

+17
-9
lines changed

api/current.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24953,7 +24953,6 @@ package android.view {
2495324953
method public android.view.ViewParent getParentForAccessibility();
2495424954
method public float getPivotX();
2495524955
method public float getPivotY();
24956-
method public int getResolvedTextAlignment();
2495724956
method public android.content.res.Resources getResources();
2495824957
method public final int getRight();
2495924958
method protected float getRightFadingEdgeStrength();

core/java/android/view/View.java

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16668,6 +16668,8 @@ public boolean isTextDirectionInherited() {
1666816668
* {@link #TEXT_ALIGNMENT_TEXT_END},
1666916669
* {@link #TEXT_ALIGNMENT_VIEW_START},
1667016670
* {@link #TEXT_ALIGNMENT_VIEW_END}
16671+
*
16672+
* @hide
1667116673
*/
1667216674
@ViewDebug.ExportedProperty(category = "text", mapping = {
1667316675
@ViewDebug.IntToString(from = TEXT_ALIGNMENT_INHERIT, to = "INHERIT"),
@@ -16678,7 +16680,7 @@ public boolean isTextDirectionInherited() {
1667816680
@ViewDebug.IntToString(from = TEXT_ALIGNMENT_VIEW_START, to = "VIEW_START"),
1667916681
@ViewDebug.IntToString(from = TEXT_ALIGNMENT_VIEW_END, to = "VIEW_END")
1668016682
})
16681-
public int getTextAlignment() {
16683+
public int getRawTextAlignment() {
1668216684
return (mPrivateFlags2 & PFLAG2_TEXT_ALIGNMENT_MASK) >> PFLAG2_TEXT_ALIGNMENT_MASK_SHIFT;
1668316685
}
1668416686

@@ -16698,7 +16700,7 @@ public int getTextAlignment() {
1669816700
* @attr ref android.R.styleable#View_textAlignment
1669916701
*/
1670016702
public void setTextAlignment(int textAlignment) {
16701-
if (textAlignment != getTextAlignment()) {
16703+
if (textAlignment != getRawTextAlignment()) {
1670216704
// Reset the current and resolved text alignment
1670316705
mPrivateFlags2 &= ~PFLAG2_TEXT_ALIGNMENT_MASK;
1670416706
resetResolvedTextAlignment();
@@ -16737,7 +16739,7 @@ public void setTextAlignment(int textAlignment) {
1673716739
@ViewDebug.IntToString(from = TEXT_ALIGNMENT_VIEW_START, to = "VIEW_START"),
1673816740
@ViewDebug.IntToString(from = TEXT_ALIGNMENT_VIEW_END, to = "VIEW_END")
1673916741
})
16740-
public int getResolvedTextAlignment() {
16742+
public int getTextAlignment() {
1674116743
// If text alignment is not resolved, then resolve it
1674216744
if ((mPrivateFlags2 & PFLAG2_TEXT_ALIGNMENT_RESOLVED) != PFLAG2_TEXT_ALIGNMENT_RESOLVED) {
1674316745
resolveTextAlignment();
@@ -16756,14 +16758,14 @@ public void resolveTextAlignment() {
1675616758

1675716759
if (hasRtlSupport()) {
1675816760
// Set resolved text alignment flag depending on text alignment flag
16759-
final int textAlignment = getTextAlignment();
16761+
final int textAlignment = getRawTextAlignment();
1676016762
switch (textAlignment) {
1676116763
case TEXT_ALIGNMENT_INHERIT:
1676216764
// Check if we can resolve the text alignment
1676316765
if (canResolveTextAlignment() && mParent instanceof View) {
1676416766
View view = (View) mParent;
1676516767

16766-
final int parentResolvedTextAlignment = view.getResolvedTextAlignment();
16768+
final int parentResolvedTextAlignment = view.getTextAlignment();
1676716769
switch (parentResolvedTextAlignment) {
1676816770
case TEXT_ALIGNMENT_GRAVITY:
1676916771
case TEXT_ALIGNMENT_TEXT_START:
@@ -16814,7 +16816,7 @@ public void resolveTextAlignment() {
1681416816
* @return true if text alignment resolution can be done otherwise return false.
1681516817
*/
1681616818
private boolean canResolveTextAlignment() {
16817-
switch (getTextAlignment()) {
16819+
switch (getRawTextAlignment()) {
1681816820
case TEXT_DIRECTION_INHERIT:
1681916821
return (mParent != null);
1682016822
default:
@@ -16832,6 +16834,13 @@ public void resetResolvedTextAlignment() {
1683216834
mPrivateFlags2 &= ~(PFLAG2_TEXT_ALIGNMENT_RESOLVED | PFLAG2_TEXT_ALIGNMENT_RESOLVED_MASK);
1683316835
}
1683416836

16837+
/**
16838+
* @hide
16839+
*/
16840+
public boolean isTextAlignmentInherited() {
16841+
return (getRawTextAlignment() == TEXT_ALIGNMENT_INHERIT);
16842+
}
16843+
1683516844
/**
1683616845
* Generate a value suitable for use in {@link #setId(int)}.
1683716846
* This value will not collide with ID values generated at build time by aapt for R.id.

core/java/android/view/ViewGroup.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5274,7 +5274,7 @@ public void resetResolvedLayoutDirection() {
52745274
if (child.isTextDirectionInherited()) {
52755275
child.resetResolvedTextDirection();
52765276
}
5277-
if (child.getTextAlignment() == TEXT_ALIGNMENT_INHERIT) {
5277+
if (child.isTextAlignmentInherited()) {
52785278
child.resetResolvedTextAlignment();
52795279
}
52805280
}

core/java/android/widget/TextView.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5646,7 +5646,7 @@ public void onRtlPropertiesChanged() {
56465646

56475647
private Layout.Alignment getLayoutAlignment() {
56485648
if (mLayoutAlignment == null) {
5649-
mResolvedTextAlignment = getResolvedTextAlignment();
5649+
mResolvedTextAlignment = getTextAlignment();
56505650
switch (mResolvedTextAlignment) {
56515651
case TEXT_ALIGNMENT_GRAVITY:
56525652
switch (mGravity & Gravity.RELATIVE_HORIZONTAL_GRAVITY_MASK) {

0 commit comments

Comments
 (0)