diff options
| author | Evan Rosky <erosky@google.com> | 2017-03-09 21:37:31 +0000 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2017-03-09 21:37:35 +0000 |
| commit | af0c4233263b925f4929a5960334ade81d4515b5 (patch) | |
| tree | 9e8fc417366feb8e3762de531ffd441d1dd73b50 /core/java/android/view/FocusFinder.java | |
| parent | d0af843c75f08a1175b04522eaed5db8de895bbd (diff) | |
| parent | e46675263f81377d7fb521c9e947258ecada1a44 (diff) | |
Merge "Revert "Fixed poor behavior of position-based focus order""
Diffstat (limited to 'core/java/android/view/FocusFinder.java')
| -rw-r--r-- | core/java/android/view/FocusFinder.java | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/core/java/android/view/FocusFinder.java b/core/java/android/view/FocusFinder.java index ad0614151b37..61c92018a406 100644 --- a/core/java/android/view/FocusFinder.java +++ b/core/java/android/view/FocusFinder.java @@ -732,17 +732,27 @@ public class FocusFinder { getRect(first, mFirstRect); getRect(second, mSecondRect); - boolean overlapsVertically = (mFirstRect.top < mSecondRect.top - && mFirstRect.bottom > mSecondRect.top) - || (mFirstRect.top > mSecondRect.top - && mFirstRect.top < mSecondRect.bottom); - boolean alignedVertically = (mFirstRect.left > mSecondRect.left) - == (mFirstRect.right < mSecondRect.right); - if (overlapsVertically && !alignedVertically) { - int rtl = mIsLayoutRtl ? -1 : 1; - return rtl * (mFirstRect.left - mSecondRect.left); + if (mFirstRect.top < mSecondRect.top) { + return -1; + } else if (mFirstRect.top > mSecondRect.top) { + return 1; + } else if (mFirstRect.left < mSecondRect.left) { + return mIsLayoutRtl ? 1 : -1; + } else if (mFirstRect.left > mSecondRect.left) { + 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 mIsLayoutRtl ? 1 : -1; + } else if (mFirstRect.right > mSecondRect.right) { + return mIsLayoutRtl ? -1 : 1; } else { - return mFirstRect.top - mSecondRect.top; + // The view are distinct but completely coincident so we consider + // them equal for our purposes. Since the sort is stable, this + // means that the views will retain their layout order relative to one another. + return 0; } } |
