From db24f0a73f4385aea104367a4bc71b78f25dbc3f Mon Sep 17 00:00:00 2001 From: Fabrice Di Meglio Date: Wed, 3 Oct 2012 17:17:14 -0700 Subject: Fix bug #7282594 EditText does not allow to move the cursor when typing RTL text and if gravity is set to LEFT - fold LEFT/RIGHT into NORMAL/OPPOSITE cases Change-Id: Idf14342ffed4840e7b4ea53cc42f1cde8f196a4c --- core/java/android/text/Layout.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'core/java/android/text/Layout.java') diff --git a/core/java/android/text/Layout.java b/core/java/android/text/Layout.java index d2bed489e23d..123accae4f6e 100644 --- a/core/java/android/text/Layout.java +++ b/core/java/android/text/Layout.java @@ -475,10 +475,14 @@ public abstract class Layout { Alignment align = getParagraphAlignment(line); int dir = getParagraphDirection(line); - int x; if (align == Alignment.ALIGN_LEFT) { - x = left; - } else if (align == Alignment.ALIGN_NORMAL) { + align = (dir == DIR_LEFT_TO_RIGHT) ? Alignment.ALIGN_NORMAL : Alignment.ALIGN_OPPOSITE; + } else if (align == Alignment.ALIGN_RIGHT) { + align = (dir == DIR_LEFT_TO_RIGHT) ? Alignment.ALIGN_OPPOSITE : Alignment.ALIGN_NORMAL; + } + + int x; + if (align == Alignment.ALIGN_NORMAL) { if (dir == DIR_LEFT_TO_RIGHT) { x = left; } else { @@ -498,12 +502,11 @@ public abstract class Layout { } } int max = (int)getLineExtent(line, tabStops, false); - if (align == Alignment.ALIGN_RIGHT) { - x = right - max; - } else if (align == Alignment.ALIGN_OPPOSITE) { + if (align == Alignment.ALIGN_OPPOSITE) { if (dir == DIR_LEFT_TO_RIGHT) { x = right - max; } else { + // max is negative here x = left - max; } } else { // Alignment.ALIGN_CENTER -- cgit v1.2.3