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

Commit 418b1fc5 authored by Vadim Tryshev's avatar Vadim Tryshev
Browse files

Restricting navigation into and from clusters.

Tabbing loops inside cluster. Tabbing outside of clusters (i.e. in
the default cluster) won’t enter clusters. Initial focus won’t go
into a cluster.

Arrows work like before.

Bug: 32151632
Test: Manual checks. CTS test will be added after feature freeze.
Change-Id: Icecbd75394e2dd4afe2e1c4e6bc9ac64f6785699
parent e298756b
Loading
Loading
Loading
Loading
+13 −3
Original line number Diff line number Diff line
@@ -869,10 +869,13 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
     */
    @Override
    public View focusSearch(View focused, int direction) {
        if (isRootNamespace()) {
        if (isRootNamespace()
                || isKeyboardNavigationCluster()
                && (direction == FOCUS_FORWARD || direction == FOCUS_BACKWARD)) {
            // root namespace means we should consider ourselves the top of the
            // tree for focus searching; otherwise we could be focus searching
            // into other tabs.  see LocalActivityManager and TabHost for more info
            // into other tabs.  see LocalActivityManager and TabHost for more info.
            // Cluster's root works same way for the forward and backward navigation.
            return FocusFinder.getInstance().findNextFocus(this, focused, direction);
        } else if (mParent != null) {
            return mParent.focusSearch(focused, direction);
@@ -1104,6 +1107,12 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager

    @Override
    public void addFocusables(ArrayList<View> views, int direction, int focusableMode) {
        if (isKeyboardNavigationCluster()
                && (direction == FOCUS_FORWARD || direction == FOCUS_BACKWARD) && !hasFocus()) {
            // A cluster cannot be focus-entered from outside using forward/backward navigation.
            return;
        }

        final int focusableCount = views.size();

        final int descendantFocusability = getDescendantFocusability();
@@ -3026,7 +3035,8 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
        final View[] children = mChildren;
        for (int i = index; i != end; i += increment) {
            View child = children[i];
            if ((child.mViewFlags & VISIBILITY_MASK) == VISIBLE) {
            if ((child.mViewFlags & VISIBILITY_MASK) == VISIBLE
                    && !child.isKeyboardNavigationCluster()) {
                if (child.requestFocus(direction, previouslyFocusedRect)) {
                    return true;
                }