Skip to content

Commit 33c3689

Browse files
Fabrice Di MeglioAndroid (Google) Code Review
authored andcommitted
Merge "Fix bug #7282594 EditText does not allow to move the cursor when typing RTL text and if gravity is set to LEFT" into jb-mr1-dev
2 parents 55941e3 + db24f0a commit 33c3689

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

core/java/android/text/Layout.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -475,10 +475,14 @@ private int getLineStartPos(int line, int left, int right) {
475475
Alignment align = getParagraphAlignment(line);
476476
int dir = getParagraphDirection(line);
477477

478-
int x;
479478
if (align == Alignment.ALIGN_LEFT) {
480-
x = left;
481-
} else if (align == Alignment.ALIGN_NORMAL) {
479+
align = (dir == DIR_LEFT_TO_RIGHT) ? Alignment.ALIGN_NORMAL : Alignment.ALIGN_OPPOSITE;
480+
} else if (align == Alignment.ALIGN_RIGHT) {
481+
align = (dir == DIR_LEFT_TO_RIGHT) ? Alignment.ALIGN_OPPOSITE : Alignment.ALIGN_NORMAL;
482+
}
483+
484+
int x;
485+
if (align == Alignment.ALIGN_NORMAL) {
482486
if (dir == DIR_LEFT_TO_RIGHT) {
483487
x = left;
484488
} else {
@@ -498,12 +502,11 @@ private int getLineStartPos(int line, int left, int right) {
498502
}
499503
}
500504
int max = (int)getLineExtent(line, tabStops, false);
501-
if (align == Alignment.ALIGN_RIGHT) {
502-
x = right - max;
503-
} else if (align == Alignment.ALIGN_OPPOSITE) {
505+
if (align == Alignment.ALIGN_OPPOSITE) {
504506
if (dir == DIR_LEFT_TO_RIGHT) {
505507
x = right - max;
506508
} else {
509+
// max is negative here
507510
x = left - max;
508511
}
509512
} else { // Alignment.ALIGN_CENTER

0 commit comments

Comments
 (0)