diff options
| author | 2013-05-08 17:56:17 +0000 | |
|---|---|---|
| committer | 2013-05-08 17:56:17 +0000 | |
| commit | 366b97ba25de237c42c815c5e8ca36303ce104df (patch) | |
| tree | 1553cc2256526c3de6060ecbe8c27f162bf62947 | |
| parent | d7bf6d46bd636991885662da5e710b1cf08a44d8 (diff) | |
| parent | 3167c88c2c18eaadb046d41e2108bf45eae0d289 (diff) | |
Merge "Fix bug #8839681 Reversed Textbox focus order on RTL and android:imeOptions="flagNoExtractUi"" into jb-mr2-dev
| -rw-r--r-- | core/java/android/view/FocusFinder.java | 32 |
1 files changed, 12 insertions, 20 deletions
diff --git a/core/java/android/view/FocusFinder.java b/core/java/android/view/FocusFinder.java index b2988ed34971..c2c247ed429b 100644 --- a/core/java/android/view/FocusFinder.java +++ b/core/java/android/view/FocusFinder.java @@ -172,6 +172,7 @@ public class FocusFinder { try { // Note: This sort is stable. mSequentialFocusComparator.setRoot(root); + mSequentialFocusComparator.setIsLayoutRtl(root.isLayoutRtl()); Collections.sort(focusables, mSequentialFocusComparator); } finally { mSequentialFocusComparator.recycle(); @@ -180,9 +181,9 @@ public class FocusFinder { final int count = focusables.size(); switch (direction) { case View.FOCUS_FORWARD: - return getForwardFocusable(root, focused, focusables, count); + return getNextFocusable(focused, focusables, count); case View.FOCUS_BACKWARD: - return getBackwardFocusable(root, focused, focusables, count); + return getPreviousFocusable(focused, focusables, count); } return focusables.get(count - 1); } @@ -239,13 +240,6 @@ public class FocusFinder { return closest; } - private static View getForwardFocusable(ViewGroup root, View focused, - ArrayList<View> focusables, int count) { - return (root.isLayoutRtl()) ? - getPreviousFocusable(focused, focusables, count) : - getNextFocusable(focused, focusables, count); - } - private static View getNextFocusable(View focused, ArrayList<View> focusables, int count) { if (focused != null) { int position = focusables.lastIndexOf(focused); @@ -259,13 +253,6 @@ public class FocusFinder { return null; } - private static View getBackwardFocusable(ViewGroup root, View focused, - ArrayList<View> focusables, int count) { - return (root.isLayoutRtl()) ? - getNextFocusable(focused, focusables, count) : - getPreviousFocusable(focused, focusables, count); - } - private static View getPreviousFocusable(View focused, ArrayList<View> focusables, int count) { if (focused != null) { int position = focusables.indexOf(focused); @@ -619,6 +606,7 @@ public class FocusFinder { private final Rect mFirstRect = new Rect(); private final Rect mSecondRect = new Rect(); private ViewGroup mRoot; + private boolean mIsLayoutRtl; public void recycle() { mRoot = null; @@ -628,6 +616,10 @@ public class FocusFinder { mRoot = root; } + public void setIsLayoutRtl(boolean b) { + mIsLayoutRtl = b; + } + public int compare(View first, View second) { if (first == second) { return 0; @@ -641,17 +633,17 @@ public class FocusFinder { } else if (mFirstRect.top > mSecondRect.top) { return 1; } else if (mFirstRect.left < mSecondRect.left) { - return -1; + return mIsLayoutRtl ? 1 : -1; } else if (mFirstRect.left > mSecondRect.left) { - return 1; + return mIsLayoutRtl ? -1 : 1; } else if (mFirstRect.bottom < mSecondRect.bottom) { return -1; } else if (mFirstRect.bottom > mSecondRect.bottom) { return 1; } else if (mFirstRect.right < mSecondRect.right) { - return -1; + return mIsLayoutRtl ? 1 : -1; } else if (mFirstRect.right > mSecondRect.right) { - return 1; + return mIsLayoutRtl ? -1 : 1; } else { // The view are distinct but completely coincident so we consider // them equal for our purposes. Since the sort is stable, this |