Skip to content

Commit 1a7d487

Browse files
author
Fabrice Di Meglio
committed
Fix bug #6427629 Clean up layout direction APIs
- rename getResolvedTextAlignment() to getTextAlignment() Change-Id: I6a2b6c9ec4f5cea1adde46e35d5f3c49880791ee
1 parent 97e146c commit 1a7d487

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
@@ -24898,7 +24898,6 @@ package android.view {
2489824898
method public android.view.ViewParent getParentForAccessibility();
2489924899
method public float getPivotX();
2490024900
method public float getPivotY();
24901-
method public int getResolvedTextAlignment();
2490224901
method public android.content.res.Resources getResources();
2490324902
method public final int getRight();
2490424903
method protected float getRightFadingEdgeStrength();

core/java/android/view/View.java

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16664,6 +16664,8 @@ public boolean isTextDirectionInherited() {
1666416664
* {@link #TEXT_ALIGNMENT_TEXT_END},
1666516665
* {@link #TEXT_ALIGNMENT_VIEW_START},
1666616666
* {@link #TEXT_ALIGNMENT_VIEW_END}
16667+
*
16668+
* @hide
1666716669
*/
1666816670
@ViewDebug.ExportedProperty(category = "text", mapping = {
1666916671
@ViewDebug.IntToString(from = TEXT_ALIGNMENT_INHERIT, to = "INHERIT"),
@@ -16674,7 +16676,7 @@ public boolean isTextDirectionInherited() {
1667416676
@ViewDebug.IntToString(from = TEXT_ALIGNMENT_VIEW_START, to = "VIEW_START"),
1667516677
@ViewDebug.IntToString(from = TEXT_ALIGNMENT_VIEW_END, to = "VIEW_END")
1667616678
})
16677-
public int getTextAlignment() {
16679+
public int getRawTextAlignment() {
1667816680
return (mPrivateFlags2 & PFLAG2_TEXT_ALIGNMENT_MASK) >> PFLAG2_TEXT_ALIGNMENT_MASK_SHIFT;
1667916681
}
1668016682

@@ -16694,7 +16696,7 @@ public int getTextAlignment() {
1669416696
* @attr ref android.R.styleable#View_textAlignment
1669516697
*/
1669616698
public void setTextAlignment(int textAlignment) {
16697-
if (textAlignment != getTextAlignment()) {
16699+
if (textAlignment != getRawTextAlignment()) {
1669816700
// Reset the current and resolved text alignment
1669916701
mPrivateFlags2 &= ~PFLAG2_TEXT_ALIGNMENT_MASK;
1670016702
resetResolvedTextAlignment();
@@ -16733,7 +16735,7 @@ public void setTextAlignment(int textAlignment) {
1673316735
@ViewDebug.IntToString(from = TEXT_ALIGNMENT_VIEW_START, to = "VIEW_START"),
1673416736
@ViewDebug.IntToString(from = TEXT_ALIGNMENT_VIEW_END, to = "VIEW_END")
1673516737
})
16736-
public int getResolvedTextAlignment() {
16738+
public int getTextAlignment() {
1673716739
// If text alignment is not resolved, then resolve it
1673816740
if ((mPrivateFlags2 & PFLAG2_TEXT_ALIGNMENT_RESOLVED) != PFLAG2_TEXT_ALIGNMENT_RESOLVED) {
1673916741
resolveTextAlignment();
@@ -16752,14 +16754,14 @@ public void resolveTextAlignment() {
1675216754

1675316755
if (hasRtlSupport()) {
1675416756
// Set resolved text alignment flag depending on text alignment flag
16755-
final int textAlignment = getTextAlignment();
16757+
final int textAlignment = getRawTextAlignment();
1675616758
switch (textAlignment) {
1675716759
case TEXT_ALIGNMENT_INHERIT:
1675816760
// Check if we can resolve the text alignment
1675916761
if (canResolveTextAlignment() && mParent instanceof View) {
1676016762
View view = (View) mParent;
1676116763

16762-
final int parentResolvedTextAlignment = view.getResolvedTextAlignment();
16764+
final int parentResolvedTextAlignment = view.getTextAlignment();
1676316765
switch (parentResolvedTextAlignment) {
1676416766
case TEXT_ALIGNMENT_GRAVITY:
1676516767
case TEXT_ALIGNMENT_TEXT_START:
@@ -16810,7 +16812,7 @@ public void resolveTextAlignment() {
1681016812
* @return true if text alignment resolution can be done otherwise return false.
1681116813
*/
1681216814
private boolean canResolveTextAlignment() {
16813-
switch (getTextAlignment()) {
16815+
switch (getRawTextAlignment()) {
1681416816
case TEXT_DIRECTION_INHERIT:
1681516817
return (mParent != null);
1681616818
default:
@@ -16828,6 +16830,13 @@ public void resetResolvedTextAlignment() {
1682816830
mPrivateFlags2 &= ~(PFLAG2_TEXT_ALIGNMENT_RESOLVED | PFLAG2_TEXT_ALIGNMENT_RESOLVED_MASK);
1682916831
}
1683016832

16833+
/**
16834+
* @hide
16835+
*/
16836+
public boolean isTextAlignmentInherited() {
16837+
return (getRawTextAlignment() == TEXT_ALIGNMENT_INHERIT);
16838+
}
16839+
1683116840
/**
1683216841
* Generate a value suitable for use in {@link #setId(int)}.
1683316842
* 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)