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

Commit 8102d913 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Teleportation between clusters."

parents ccc90afb 01b0c9ed
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -41708,6 +41708,7 @@ package android.view {
    method public android.view.View findNearestTouchable(android.view.ViewGroup, int, int, int, int[]);
    method public final android.view.View findNextFocus(android.view.ViewGroup, android.view.View, int);
    method public android.view.View findNextFocusFromRect(android.view.ViewGroup, android.graphics.Rect, int);
    method public android.view.View findNextKeyboardNavigationCluster(android.view.ViewGroup, android.view.View, int);
    method public static android.view.FocusFinder getInstance();
  }
@@ -43000,6 +43001,7 @@ package android.view {
    method public void addChildrenForAccessibility(java.util.ArrayList<android.view.View>);
    method public void addFocusables(java.util.ArrayList<android.view.View>, int);
    method public void addFocusables(java.util.ArrayList<android.view.View>, int, int);
    method public void addKeyboardNavigationClusters(java.util.Collection<android.view.View>, int);
    method public void addOnAttachStateChangeListener(android.view.View.OnAttachStateChangeListener);
    method public void addOnLayoutChangeListener(android.view.View.OnLayoutChangeListener);
    method public void addTouchables(java.util.ArrayList<android.view.View>);
@@ -43287,6 +43289,7 @@ package android.view {
    method public boolean isVerticalFadingEdgeEnabled();
    method public boolean isVerticalScrollBarEnabled();
    method public void jumpDrawablesToCurrentState();
    method public android.view.View keyboardNavigationClusterSearch(int);
    method public void layout(int, int, int, int);
    method public final void measure(int, int);
    method protected static int[] mergeDrawableStates(int[], int[]);
@@ -43934,6 +43937,7 @@ package android.view {
    method protected deprecated boolean isChildrenDrawnWithCacheEnabled();
    method public boolean isMotionEventSplittingEnabled();
    method public boolean isTransitionGroup();
    method public android.view.View keyboardNavigationClusterSearch(android.view.View, int);
    method public final void layout(int, int, int, int);
    method protected void measureChild(android.view.View, int, int);
    method protected void measureChildWithMargins(android.view.View, int, int, int, int);
@@ -44096,6 +44100,7 @@ package android.view {
    method public abstract boolean isLayoutRequested();
    method public abstract boolean isTextAlignmentResolved();
    method public abstract boolean isTextDirectionResolved();
    method public abstract android.view.View keyboardNavigationClusterSearch(android.view.View, int);
    method public abstract void notifySubtreeAccessibilityStateChanged(android.view.View, android.view.View, int);
    method public abstract boolean onNestedFling(android.view.View, float, float, boolean);
    method public abstract boolean onNestedPreFling(android.view.View, float, float);
+5 −0
Original line number Diff line number Diff line
@@ -44850,6 +44850,7 @@ package android.view {
    method public android.view.View findNearestTouchable(android.view.ViewGroup, int, int, int, int[]);
    method public final android.view.View findNextFocus(android.view.ViewGroup, android.view.View, int);
    method public android.view.View findNextFocusFromRect(android.view.ViewGroup, android.graphics.Rect, int);
    method public android.view.View findNextKeyboardNavigationCluster(android.view.ViewGroup, android.view.View, int);
    method public static android.view.FocusFinder getInstance();
  }
@@ -46142,6 +46143,7 @@ package android.view {
    method public void addChildrenForAccessibility(java.util.ArrayList<android.view.View>);
    method public void addFocusables(java.util.ArrayList<android.view.View>, int);
    method public void addFocusables(java.util.ArrayList<android.view.View>, int, int);
    method public void addKeyboardNavigationClusters(java.util.Collection<android.view.View>, int);
    method public void addOnAttachStateChangeListener(android.view.View.OnAttachStateChangeListener);
    method public void addOnLayoutChangeListener(android.view.View.OnLayoutChangeListener);
    method public void addTouchables(java.util.ArrayList<android.view.View>);
@@ -46429,6 +46431,7 @@ package android.view {
    method public boolean isVerticalFadingEdgeEnabled();
    method public boolean isVerticalScrollBarEnabled();
    method public void jumpDrawablesToCurrentState();
    method public android.view.View keyboardNavigationClusterSearch(int);
    method public void layout(int, int, int, int);
    method public final void measure(int, int);
    method protected static int[] mergeDrawableStates(int[], int[]);
@@ -47076,6 +47079,7 @@ package android.view {
    method protected deprecated boolean isChildrenDrawnWithCacheEnabled();
    method public boolean isMotionEventSplittingEnabled();
    method public boolean isTransitionGroup();
    method public android.view.View keyboardNavigationClusterSearch(android.view.View, int);
    method public final void layout(int, int, int, int);
    method protected void measureChild(android.view.View, int, int);
    method protected void measureChildWithMargins(android.view.View, int, int, int, int);
@@ -47238,6 +47242,7 @@ package android.view {
    method public abstract boolean isLayoutRequested();
    method public abstract boolean isTextAlignmentResolved();
    method public abstract boolean isTextDirectionResolved();
    method public abstract android.view.View keyboardNavigationClusterSearch(android.view.View, int);
    method public abstract void notifySubtreeAccessibilityStateChanged(android.view.View, android.view.View, int);
    method public abstract boolean onNestedFling(android.view.View, float, float, boolean);
    method public abstract boolean onNestedPreFling(android.view.View, float, float);
+5 −0
Original line number Diff line number Diff line
@@ -41974,6 +41974,7 @@ package android.view {
    method public android.view.View findNearestTouchable(android.view.ViewGroup, int, int, int, int[]);
    method public final android.view.View findNextFocus(android.view.ViewGroup, android.view.View, int);
    method public android.view.View findNextFocusFromRect(android.view.ViewGroup, android.graphics.Rect, int);
    method public android.view.View findNextKeyboardNavigationCluster(android.view.ViewGroup, android.view.View, int);
    method public static android.view.FocusFinder getInstance();
  }
@@ -43268,6 +43269,7 @@ package android.view {
    method public void addChildrenForAccessibility(java.util.ArrayList<android.view.View>);
    method public void addFocusables(java.util.ArrayList<android.view.View>, int);
    method public void addFocusables(java.util.ArrayList<android.view.View>, int, int);
    method public void addKeyboardNavigationClusters(java.util.Collection<android.view.View>, int);
    method public void addOnAttachStateChangeListener(android.view.View.OnAttachStateChangeListener);
    method public void addOnLayoutChangeListener(android.view.View.OnLayoutChangeListener);
    method public void addTouchables(java.util.ArrayList<android.view.View>);
@@ -43556,6 +43558,7 @@ package android.view {
    method public boolean isVerticalFadingEdgeEnabled();
    method public boolean isVerticalScrollBarEnabled();
    method public void jumpDrawablesToCurrentState();
    method public android.view.View keyboardNavigationClusterSearch(int);
    method public void layout(int, int, int, int);
    method public final void measure(int, int);
    method protected static int[] mergeDrawableStates(int[], int[]);
@@ -44207,6 +44210,7 @@ package android.view {
    method protected deprecated boolean isChildrenDrawnWithCacheEnabled();
    method public boolean isMotionEventSplittingEnabled();
    method public boolean isTransitionGroup();
    method public android.view.View keyboardNavigationClusterSearch(android.view.View, int);
    method public final void layout(int, int, int, int);
    method protected void measureChild(android.view.View, int, int);
    method protected void measureChildWithMargins(android.view.View, int, int, int, int);
@@ -44369,6 +44373,7 @@ package android.view {
    method public abstract boolean isLayoutRequested();
    method public abstract boolean isTextAlignmentResolved();
    method public abstract boolean isTextDirectionResolved();
    method public abstract android.view.View keyboardNavigationClusterSearch(android.view.View, int);
    method public abstract void notifySubtreeAccessibilityStateChanged(android.view.View, android.view.View, int);
    method public abstract boolean onNestedFling(android.view.View, float, float, boolean);
    method public abstract boolean onNestedPreFling(android.view.View, float, float);
+84 −0
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package android.view;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.graphics.Rect;
import android.util.ArrayMap;
import android.util.SparseArray;
@@ -24,6 +26,7 @@ import android.util.SparseBooleanArray;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

/**
 * The algorithm used for finding the next focusable view in a given direction
@@ -102,6 +105,30 @@ public class FocusFinder {
        return next;
    }

    /**
     * Find the root of the next keyboard navigation cluster after the current one.
     * @param root Thew view tree to look inside. Cannot be null
     * @param currentCluster The starting point of the search. Null means the default cluster
     * @param direction Direction to look
     * @return The next cluster, or null if none exists
     */
    public View findNextKeyboardNavigationCluster(
            @NonNull ViewGroup root, @Nullable View currentCluster, int direction) {
        View next = null;

        final ArrayList<View> clusters = mTempList;
        try {
            clusters.clear();
            root.addKeyboardNavigationClusters(clusters, direction);
            if (!clusters.isEmpty()) {
                next = findNextKeyboardNavigationCluster(root, currentCluster, clusters, direction);
            }
        } finally {
            clusters.clear();
        }
        return next;
    }

    private View findNextUserSpecifiedFocus(ViewGroup root, View focused, int direction) {
        // check for user specified next focus
        View userSetNextFocus = focused.findUserSetNextFocus(root, direction);
@@ -170,6 +197,24 @@ public class FocusFinder {
        }
    }

    private View findNextKeyboardNavigationCluster(ViewGroup root, View currentCluster,
            List<View> clusters, int direction) {
        final int count = clusters.size();

        switch (direction) {
            case View.FOCUS_FORWARD:
            case View.FOCUS_DOWN:
            case View.FOCUS_RIGHT:
                return getNextKeyboardNavigationCluster(root, currentCluster, clusters, count);
            case View.FOCUS_BACKWARD:
            case View.FOCUS_UP:
            case View.FOCUS_LEFT:
                return getPreviousKeyboardNavigationCluster(root, currentCluster, clusters, count);
            default:
                throw new IllegalArgumentException("Unknown direction: " + direction);
        }
    }

    private View findNextFocusInRelativeDirection(ArrayList<View> focusables, ViewGroup root,
            View focused, Rect focusedRect, int direction) {
        try {
@@ -270,6 +315,45 @@ public class FocusFinder {
        return null;
    }

    private static View getNextKeyboardNavigationCluster(ViewGroup root, View currentCluster,
            List<View> clusters, int count) {
        if (currentCluster == null) {
            // The current cluster is the default one.
            // The next cluster after the default one is the first one.
            // Note that the caller guarantees that 'clusters' is not empty.
            return clusters.get(0);
        }

        final int position = clusters.lastIndexOf(currentCluster);
        if (position >= 0 && position + 1 < count) {
            // Return the next non-default cluster if we can find it.
            return clusters.get(position + 1);
        }

        // The current cluster is the last one. The next one is the default one, i.e. the root.
        return root;
    }

    private static View getPreviousKeyboardNavigationCluster(ViewGroup root, View currentCluster,
            List<View> clusters, int count) {
        if (currentCluster == null) {
            // The current cluster is the default one.
            // The previous cluster before the default one is the last one.
            // Note that the caller guarantees that 'clusters' is not empty.
            return clusters.get(count - 1);
        }

        final int position = clusters.indexOf(currentCluster);
        if (position > 0) {
            // Return the previous non-default cluster if we can find it.
            return clusters.get(position - 1);
        }

        // The current cluster is the first one. The previous one is the default one, i.e. the
        // root.
        return root;
    }

    /**
     * Is rect1 a better candidate than rect2 for a focus search in a particular
     * direction from a source rect?  This is the core routine that determines
+33 −0
Original line number Diff line number Diff line
@@ -128,6 +128,7 @@ import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
@@ -9085,6 +9086,24 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
        }
    }
    /**
     * Find the nearest keyboard navigation cluster in the specified direction.
     * This does not actually give focus to that cluster.
     *
     * @param direction Direction to look
     *
     * @return The nearest keyboard navigation cluster in the specified direction, or null if none
     *         can be found
     */
    public View keyboardNavigationClusterSearch(int direction) {
        if (mParent != null) {
            final View currentCluster = isKeyboardNavigationCluster() ? this : null;
            return mParent.keyboardNavigationClusterSearch(currentCluster, direction);
        } else {
            return null;
        }
    }
    /**
     * This method is the last chance for the focused view and its ancestors to
     * respond to an arrow key. This is called when the focused view did not
@@ -9207,6 +9226,20 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
        views.add(this);
    }
    /**
     * Adds any keyboard navigation cluster roots that are descendants of this view (possibly
     * including this view if it is a cluster root itself) to views.
     *
     * @param views Cluster roots found so far
     * @param direction Direction to look
     */
    public void addKeyboardNavigationClusters(@NonNull Collection<View> views, int direction) {
        if (!isKeyboardNavigationCluster()) {
            return;
        }
        views.add(this);
    }
    /**
     * Finds the Views that contain given text. The containment is case insensitive.
     * The search is performed by either the text that the View renders or the content
Loading