Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit af0c4233 authored by Evan Rosky's avatar Evan Rosky Committed by Android (Google) Code Review
Browse files

Merge "Revert "Fixed poor behavior of position-based focus order""

parents d0af843c e4667526
Loading
Loading
Loading
Loading
+20 −10
Original line number Diff line number Diff line
@@ -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;
            }
        }