summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/java/android/widget/Editor.java9
-rw-r--r--core/tests/coretests/res/layout/activity_text_view.xml4
-rw-r--r--core/tests/coretests/src/android/widget/TextViewActivityTest.java34
3 files changed, 43 insertions, 4 deletions
diff --git a/core/java/android/widget/Editor.java b/core/java/android/widget/Editor.java
index 81ffff9afd4b..2d1f85508968 100644
--- a/core/java/android/widget/Editor.java
+++ b/core/java/android/widget/Editor.java
@@ -4299,10 +4299,15 @@ public class Editor {
boolean isExpanding;
final float xDiff = x - mPrevX;
+ if (isStartHandle()) {
+ isExpanding = currLine < mPreviousLineTouched;
+ } else {
+ isExpanding = currLine > mPreviousLineTouched;
+ }
if (atRtl == isStartHandle()) {
- isExpanding = xDiff > 0 || currLine > mPreviousLineTouched;
+ isExpanding |= xDiff > 0;
} else {
- isExpanding = xDiff < 0 || currLine < mPreviousLineTouched;
+ isExpanding |= xDiff < 0;
}
if (mTextView.getHorizontallyScrolling()) {
diff --git a/core/tests/coretests/res/layout/activity_text_view.xml b/core/tests/coretests/res/layout/activity_text_view.xml
index 7ab0b130c293..e795c10003ee 100644
--- a/core/tests/coretests/res/layout/activity_text_view.xml
+++ b/core/tests/coretests/res/layout/activity_text_view.xml
@@ -23,6 +23,6 @@
<EditText
android:id="@+id/textview"
android:layout_width="match_parent"
- android:layout_height="match_parent" />
+ android:layout_height="wrap_content" />
-</LinearLayout> \ No newline at end of file
+</LinearLayout>
diff --git a/core/tests/coretests/src/android/widget/TextViewActivityTest.java b/core/tests/coretests/src/android/widget/TextViewActivityTest.java
index 2c677438ca35..aa576417e992 100644
--- a/core/tests/coretests/src/android/widget/TextViewActivityTest.java
+++ b/core/tests/coretests/src/android/widget/TextViewActivityTest.java
@@ -31,6 +31,7 @@ import static android.widget.espresso.FloatingToolbarEspressoUtils.assertFloatin
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.click;
import static android.support.test.espresso.action.ViewActions.pressKey;
+import static android.support.test.espresso.action.ViewActions.replaceText;
import static android.support.test.espresso.action.ViewActions.typeTextIntoFocusedView;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
@@ -214,6 +215,39 @@ public class TextViewActivityTest extends ActivityInstrumentationTestCase2<TextV
}
@SmallTest
+ public void testSelectionHandles_multiLine_rtl() throws Exception {
+ // Arabic text.
+ final String text = "\u062A\u062B\u062C\n" + "\u062D\u062E\u062F\n"
+ + "\u0630\u0631\u0632\n" + "\u0633\u0634\u0635\n" + "\u0636\u0637\u0638\n"
+ + "\u0639\u063A\u063B";
+ onView(withId(R.id.textview)).perform(click());
+ onView(withId(R.id.textview)).perform(replaceText(text));
+ onView(withId(R.id.textview)).perform(clickOnTextAtIndex(text.length()));
+ onView(withId(R.id.textview)).perform(doubleClickOnTextAtIndex(text.indexOf('\u0634')));
+
+ final TextView textView = (TextView)getActivity().findViewById(R.id.textview);
+ onHandleView(com.android.internal.R.id.selection_start_handle)
+ .perform(dragHandle(textView, Handle.SELECTION_START, text.indexOf('\u062E')));
+ onView(withId(R.id.textview)).check(hasSelection(
+ text.substring(text.indexOf('\u062D'), text.indexOf('\u0635') + 1)));
+
+ onHandleView(com.android.internal.R.id.selection_start_handle)
+ .perform(dragHandle(textView, Handle.SELECTION_START, text.indexOf('\u062A')));
+ onView(withId(R.id.textview)).check(hasSelection(
+ text.substring(text.indexOf('\u062A'), text.indexOf('\u0635') + 1)));
+
+ onHandleView(com.android.internal.R.id.selection_end_handle)
+ .perform(dragHandle(textView, Handle.SELECTION_END, text.indexOf('\u0638')));
+ onView(withId(R.id.textview)).check(hasSelection(
+ text.substring(text.indexOf('\u062A'), text.indexOf('\u0638') + 1)));
+
+ onHandleView(com.android.internal.R.id.selection_end_handle)
+ .perform(dragHandle(textView, Handle.SELECTION_END, text.indexOf('\u063B')));
+ onView(withId(R.id.textview)).check(hasSelection(text));
+ }
+
+
+ @SmallTest
public void testSelectionHandles_doesNotPassAnotherHandle() throws Exception {
final String text = "abcd efg hijk lmn";
onView(withId(R.id.textview)).perform(click());