Skip to content

Commit e7beae3

Browse files
author
Fabrice Di Meglio
committed
Make textDirection API public
Change-Id: I2d5a0e3a990b9a5b78a3bbc8df7f655702743e4b
1 parent 95d4c99 commit e7beae3

File tree

4 files changed

+33
-29
lines changed

4 files changed

+33
-29
lines changed

api/current.txt

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -992,6 +992,7 @@ package android {
992992
field public static final int textColorTertiary = 16843282; // 0x1010212
993993
field public static final int textColorTertiaryInverse = 16843283; // 0x1010213
994994
field public static final int textCursorDrawable = 16843618; // 0x1010362
995+
field public static final int textDirection = 16843688; // 0x10103a8
995996
field public static final int textEditNoPasteWindowLayout = 16843541; // 0x1010315
996997
field public static final int textEditPasteWindowLayout = 16843540; // 0x1010314
997998
field public static final int textEditSideNoPasteWindowLayout = 16843615; // 0x101035f
@@ -20478,6 +20479,19 @@ package android.text {
2047820479
method public int getTopPadding();
2047920480
}
2048020481

20482+
public abstract interface TextDirectionHeuristic {
20483+
}
20484+
20485+
public class TextDirectionHeuristics {
20486+
ctor public TextDirectionHeuristics();
20487+
field public static final android.text.TextDirectionHeuristic ANYRTL_LTR;
20488+
field public static final android.text.TextDirectionHeuristic FIRSTSTRONG_LTR;
20489+
field public static final android.text.TextDirectionHeuristic FIRSTSTRONG_RTL;
20490+
field public static final android.text.TextDirectionHeuristic LOCALE;
20491+
field public static final android.text.TextDirectionHeuristic LTR;
20492+
field public static final android.text.TextDirectionHeuristic RTL;
20493+
}
20494+
2048120495
public class TextPaint extends android.graphics.Paint {
2048220496
ctor public TextPaint();
2048320497
ctor public TextPaint(int);
@@ -23171,6 +23185,7 @@ package android.view {
2317123185
method public final android.view.ViewParent getParent();
2317223186
method public float getPivotX();
2317323187
method public float getPivotY();
23188+
method public int getResolvedTextDirection();
2317423189
method public android.content.res.Resources getResources();
2317523190
method public final int getRight();
2317623191
method protected float getRightFadingEdgeStrength();
@@ -23190,6 +23205,7 @@ package android.view {
2319023205
method public int getSystemUiVisibility();
2319123206
method public java.lang.Object getTag();
2319223207
method public java.lang.Object getTag(int);
23208+
method public int getTextDirection();
2319323209
method public final int getTop();
2319423210
method protected float getTopFadingEdgeStrength();
2319523211
method protected int getTopPaddingOffset();
@@ -23321,8 +23337,10 @@ package android.view {
2332123337
method public void requestLayout();
2332223338
method public boolean requestRectangleOnScreen(android.graphics.Rect);
2332323339
method public boolean requestRectangleOnScreen(android.graphics.Rect, boolean);
23340+
method protected void resetResolvedTextDirection();
2332423341
method public static int resolveSize(int, int);
2332523342
method public static int resolveSizeAndState(int, int, int);
23343+
method protected void resolveTextDirection();
2332623344
method public void restoreHierarchyState(android.util.SparseArray<android.os.Parcelable>);
2332723345
method public void saveHierarchyState(android.util.SparseArray<android.os.Parcelable>);
2332823346
method public void scheduleDrawable(android.graphics.drawable.Drawable, java.lang.Runnable, long);
@@ -23402,6 +23420,7 @@ package android.view {
2340223420
method public void setSystemUiVisibility(int);
2340323421
method public void setTag(java.lang.Object);
2340423422
method public void setTag(int, java.lang.Object);
23423+
method public void setTextDirection(int);
2340523424
method public final void setTop(int);
2340623425
method public void setTouchDelegate(android.view.TouchDelegate);
2340723426
method public void setTranslationX(float);
@@ -23424,6 +23443,7 @@ package android.view {
2342423443
method public boolean willNotCacheDrawing();
2342523444
method public boolean willNotDraw();
2342623445
field public static final android.util.Property ALPHA;
23446+
field protected static int DEFAULT_TEXT_DIRECTION;
2342723447
field public static final int DRAWING_CACHE_QUALITY_AUTO = 0; // 0x0
2342823448
field public static final int DRAWING_CACHE_QUALITY_HIGH = 1048576; // 0x100000
2342923449
field public static final int DRAWING_CACHE_QUALITY_LOW = 524288; // 0x80000
@@ -23500,6 +23520,12 @@ package android.view {
2350023520
field public static final int SYSTEM_UI_FLAG_HIDE_NAVIGATION = 2; // 0x2
2350123521
field public static final int SYSTEM_UI_FLAG_LOW_PROFILE = 1; // 0x1
2350223522
field public static final int SYSTEM_UI_FLAG_VISIBLE = 0; // 0x0
23523+
field public static final int TEXT_DIRECTION_ANY_RTL = 2; // 0x2
23524+
field public static final int TEXT_DIRECTION_FIRST_STRONG = 1; // 0x1
23525+
field public static final int TEXT_DIRECTION_INHERIT = 0; // 0x0
23526+
field public static final int TEXT_DIRECTION_LOCALE = 5; // 0x5
23527+
field public static final int TEXT_DIRECTION_LTR = 3; // 0x3
23528+
field public static final int TEXT_DIRECTION_RTL = 4; // 0x4
2350323529
field public static final android.util.Property TRANSLATION_X;
2350423530
field public static final android.util.Property TRANSLATION_Y;
2350523531
field protected static final java.lang.String VIEW_LOG_TAG = "View";
@@ -23766,7 +23792,6 @@ package android.view {
2376623792
method public boolean requestSendAccessibilityEvent(android.view.View, android.view.accessibility.AccessibilityEvent);
2376723793
method public void requestTransparentRegion(android.view.View);
2376823794
method protected void resetResolvedLayoutDirection();
23769-
method protected void resetResolvedTextDirection();
2377023795
method public void scheduleLayoutAnimation();
2377123796
method public void setAddStatesFromChildren(boolean);
2377223797
method public void setAlwaysDrawnWithCacheEnabled(boolean);
@@ -27595,7 +27620,6 @@ package android.widget {
2759527620
method protected void resetResolvedDrawables();
2759627621
method protected void resetResolvedLayoutDirection();
2759727622
method protected void resolveDrawables();
27598-
method protected void resolveTextDirection();
2759927623
method public void setAllCaps(boolean);
2760027624
method public final void setAutoLinkMask(int);
2760127625
method public void setCompoundDrawablePadding(int);

core/java/android/text/TextDirectionHeuristics.java

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,10 @@
1717
package android.text;
1818

1919

20-
import java.util.Locale;
21-
2220
import android.util.LocaleUtil;
2321

2422
/**
2523
* Some objects that implement TextDirectionHeuristic.
26-
* @hide
2724
*/
2825
public class TextDirectionHeuristics {
2926

@@ -74,9 +71,8 @@ private static enum TriState {
7471
* Computes the text direction based on an algorithm. Subclasses implement
7572
* {@link #defaultIsRtl} to handle cases where the algorithm cannot determine the
7673
* direction from the text alone.
77-
* @hide
7874
*/
79-
public static abstract class TextDirectionHeuristicImpl implements TextDirectionHeuristic {
75+
private static abstract class TextDirectionHeuristicImpl implements TextDirectionHeuristic {
8076
private final TextDirectionAlgorithm mAlgorithm;
8177

8278
public TextDirectionHeuristicImpl(TextDirectionAlgorithm algorithm) {
@@ -157,13 +153,11 @@ private static TriState isRtlTextOrFormat(int directionality) {
157153
/**
158154
* Interface for an algorithm to guess the direction of a paragraph of text.
159155
*
160-
* @hide
161156
*/
162-
public static interface TextDirectionAlgorithm {
157+
private static interface TextDirectionAlgorithm {
163158
/**
164159
* Returns whether the range of text is RTL according to the algorithm.
165160
*
166-
* @hide
167161
*/
168162
TriState checkRtl(char[] text, int start, int count);
169163
}
@@ -173,9 +167,8 @@ public static interface TextDirectionAlgorithm {
173167
* the paragraph direction. This is the standard Unicode Bidirectional
174168
* algorithm.
175169
*
176-
* @hide
177170
*/
178-
public static class FirstStrong implements TextDirectionAlgorithm {
171+
private static class FirstStrong implements TextDirectionAlgorithm {
179172
@Override
180173
public TriState checkRtl(char[] text, int start, int count) {
181174
TriState result = TriState.UNKNOWN;
@@ -196,9 +189,8 @@ private FirstStrong() {
196189
* character (e.g. excludes LRE, LRO, RLE, RLO) to determine the
197190
* direction of text.
198191
*
199-
* @hide
200192
*/
201-
public static class AnyStrong implements TextDirectionAlgorithm {
193+
private static class AnyStrong implements TextDirectionAlgorithm {
202194
private final boolean mLookForRtl;
203195

204196
@Override
@@ -239,7 +231,7 @@ private AnyStrong(boolean lookForRtl) {
239231
/**
240232
* Algorithm that uses the Locale direction to force the direction of a paragraph.
241233
*/
242-
public static class TextDirectionHeuristicLocale extends TextDirectionHeuristicImpl {
234+
private static class TextDirectionHeuristicLocale extends TextDirectionHeuristicImpl {
243235

244236
public TextDirectionHeuristicLocale() {
245237
super(null);

core/java/android/view/View.java

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2617,7 +2617,6 @@ static class ListenerInfo {
26172617

26182618
/**
26192619
* Text direction is inherited thru {@link ViewGroup}
2620-
* @hide
26212620
*/
26222621
public static final int TEXT_DIRECTION_INHERIT = 0;
26232622

@@ -2626,7 +2625,6 @@ static class ListenerInfo {
26262625
* determines the paragraph direction. If there is no strong directional character, the
26272626
* paragraph direction is the view's resolved layout direction.
26282627
*
2629-
* @hide
26302628
*/
26312629
public static final int TEXT_DIRECTION_FIRST_STRONG = 1;
26322630

@@ -2635,42 +2633,36 @@ static class ListenerInfo {
26352633
* any strong RTL character, otherwise it is LTR if it contains any strong LTR characters.
26362634
* If there are neither, the paragraph direction is the view's resolved layout direction.
26372635
*
2638-
* @hide
26392636
*/
26402637
public static final int TEXT_DIRECTION_ANY_RTL = 2;
26412638

26422639
/**
26432640
* Text direction is forced to LTR.
26442641
*
2645-
* @hide
26462642
*/
26472643
public static final int TEXT_DIRECTION_LTR = 3;
26482644

26492645
/**
26502646
* Text direction is forced to RTL.
26512647
*
2652-
* @hide
26532648
*/
26542649
public static final int TEXT_DIRECTION_RTL = 4;
26552650

26562651
/**
26572652
* Text direction is coming from the system Locale.
26582653
*
2659-
* @hide
26602654
*/
26612655
public static final int TEXT_DIRECTION_LOCALE = 5;
26622656

26632657
/**
26642658
* Default text direction is inherited
26652659
*
2666-
* @hide
26672660
*/
26682661
protected static int DEFAULT_TEXT_DIRECTION = TEXT_DIRECTION_INHERIT;
26692662

26702663
/**
26712664
* The text direction that has been defined by {@link #setTextDirection(int)}.
26722665
*
2673-
* {@hide}
26742666
*/
26752667
@ViewDebug.ExportedProperty(category = "text", mapping = {
26762668
@ViewDebug.IntToString(from = TEXT_DIRECTION_INHERIT, to = "INHERIT"),
@@ -2688,7 +2680,6 @@ static class ListenerInfo {
26882680
* not TEXT_DIRECTION_INHERIT, otherwise resolution proceeds up the parent
26892681
* chain of the view.
26902682
*
2691-
* {@hide}
26922683
*/
26932684
@ViewDebug.ExportedProperty(category = "text", mapping = {
26942685
@ViewDebug.IntToString(from = TEXT_DIRECTION_INHERIT, to = "INHERIT"),
@@ -13762,7 +13753,6 @@ protected float getHorizontalScrollFactor() {
1376213753
* {@link #TEXT_DIRECTION_RTL},
1376313754
* {@link #TEXT_DIRECTION_LOCALE},
1376413755
*
13765-
* @hide
1376613756
*/
1376713757
public int getTextDirection() {
1376813758
return mTextDirection;
@@ -13780,7 +13770,6 @@ public int getTextDirection() {
1378013770
* {@link #TEXT_DIRECTION_RTL},
1378113771
* {@link #TEXT_DIRECTION_LOCALE},
1378213772
*
13783-
* @hide
1378413773
*/
1378513774
public void setTextDirection(int textDirection) {
1378613775
if (textDirection != mTextDirection) {
@@ -13801,7 +13790,6 @@ public void setTextDirection(int textDirection) {
1380113790
* {@link #TEXT_DIRECTION_RTL},
1380213791
* {@link #TEXT_DIRECTION_LOCALE},
1380313792
*
13804-
* @hide
1380513793
*/
1380613794
public int getResolvedTextDirection() {
1380713795
if (mResolvedTextDirection == TEXT_DIRECTION_INHERIT) {
@@ -13813,7 +13801,6 @@ public int getResolvedTextDirection() {
1381313801
/**
1381413802
* Resolve the text direction.
1381513803
*
13816-
* @hide
1381713804
*/
1381813805
protected void resolveTextDirection() {
1381913806
if (mTextDirection != TEXT_DIRECTION_INHERIT) {
@@ -13830,7 +13817,6 @@ protected void resolveTextDirection() {
1383013817
/**
1383113818
* Reset resolved text direction. Will be resolved during a call to getResolvedTextDirection().
1383213819
*
13833-
* @hide
1383413820
*/
1383513821
protected void resetResolvedTextDirection() {
1383613822
mResolvedTextDirection = TEXT_DIRECTION_INHERIT;

core/res/res/values/public.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3494,4 +3494,6 @@
34943494
=============================================================== -->
34953495
<public type="attr" name="isolatedProcess" id="0x010103a7" />
34963496

3497+
<public type="attr" name="textDirection"/>
3498+
34973499
</resources>

0 commit comments

Comments
 (0)