diff options
author | Svetoslav <svetoslavganov@google.com> | 2013-05-14 17:39:35 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2013-05-14 17:39:36 +0000 |
commit | c0a979ce30cf9b96c0a84d0679aeeef7153a22fa (patch) | |
tree | 0ec66c226d9b52dd14de55ffa2599505e7cb8a9f /core/java/android/view/View.java | |
parent | 4f88ff48ee99b5e7078f7a6b774d21a3f3434bb9 (diff) | |
parent | abad55d860be793b8b9b3e288a74214da89fb368 (diff) | |
download | frameworks_base-c0a979ce30cf9b96c0a84d0679aeeef7153a22fa.zip frameworks_base-c0a979ce30cf9b96c0a84d0679aeeef7153a22fa.tar.gz frameworks_base-c0a979ce30cf9b96c0a84d0679aeeef7153a22fa.tar.bz2 |
Merge "Fixing the accessibility text traversal in extend mode." into jb-mr2-dev
Diffstat (limited to 'core/java/android/view/View.java')
-rw-r--r-- | core/java/android/view/View.java | 66 |
1 files changed, 18 insertions, 48 deletions
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index 9a94af9..7f09a6a 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -7069,7 +7069,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, AccessibilityNodeInfo.ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT); final boolean extendSelection = arguments.getBoolean( AccessibilityNodeInfo.ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN); - return nextAtGranularity(granularity, extendSelection); + return traverseAtGranularity(granularity, true, extendSelection); } } break; case AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY: { @@ -7078,7 +7078,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, AccessibilityNodeInfo.ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT); final boolean extendSelection = arguments.getBoolean( AccessibilityNodeInfo.ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN); - return previousAtGranularity(granularity, extendSelection); + return traverseAtGranularity(granularity, false, extendSelection); } } break; case AccessibilityNodeInfo.ACTION_SET_SELECTION: { @@ -7103,7 +7103,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback, return false; } - private boolean nextAtGranularity(int granularity, boolean extendSelection) { + private boolean traverseAtGranularity(int granularity, boolean forward, + boolean extendSelection) { CharSequence text = getIterableTextForAccessibility(); if (text == null || text.length() == 0) { return false; @@ -7114,60 +7115,29 @@ public class View implements Drawable.Callback, KeyEvent.Callback, } int current = getAccessibilitySelectionEnd(); if (current == ACCESSIBILITY_CURSOR_POSITION_UNDEFINED) { - current = 0; + current = forward ? 0 : text.length(); } - final int[] range = iterator.following(current); + final int[] range = forward ? iterator.following(current) : iterator.preceding(current); if (range == null) { return false; } - final int start = range[0]; - final int end = range[1]; + final int segmentStart = range[0]; + final int segmentEnd = range[1]; + int selectionStart; + int selectionEnd; if (extendSelection && isAccessibilitySelectionExtendable()) { - int selectionStart = getAccessibilitySelectionStart(); + selectionStart = getAccessibilitySelectionStart(); if (selectionStart == ACCESSIBILITY_CURSOR_POSITION_UNDEFINED) { - selectionStart = start; + selectionStart = forward ? segmentStart : segmentEnd; } - setAccessibilitySelection(selectionStart, end); + selectionEnd = forward ? segmentEnd : segmentStart; } else { - setAccessibilitySelection(end, end); + selectionStart = selectionEnd= forward ? segmentEnd : segmentStart; } - sendViewTextTraversedAtGranularityEvent( - AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY, - granularity, start, end); - return true; - } - - private boolean previousAtGranularity(int granularity, boolean extendSelection) { - CharSequence text = getIterableTextForAccessibility(); - if (text == null || text.length() == 0) { - return false; - } - TextSegmentIterator iterator = getIteratorForGranularity(granularity); - if (iterator == null) { - return false; - } - int current = getAccessibilitySelectionStart(); - if (current == ACCESSIBILITY_CURSOR_POSITION_UNDEFINED) { - current = text.length(); - } - final int[] range = iterator.preceding(current); - if (range == null) { - return false; - } - final int start = range[0]; - final int end = range[1]; - if (extendSelection && isAccessibilitySelectionExtendable()) { - int selectionEnd = getAccessibilitySelectionEnd(); - if (selectionEnd == ACCESSIBILITY_CURSOR_POSITION_UNDEFINED) { - selectionEnd = end; - } - setAccessibilitySelection(start, selectionEnd); - } else { - setAccessibilitySelection(start, start); - } - sendViewTextTraversedAtGranularityEvent( - AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY, - granularity, start, end); + setAccessibilitySelection(selectionStart, selectionEnd); + final int action = forward ? AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY + : AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY; + sendViewTextTraversedAtGranularityEvent(action, granularity, segmentStart, segmentEnd); return true; } |