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

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

Merge "Using official names for clusters and sections."

parents fabf8e81 311a5b54
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -41847,7 +41847,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(int, android.view.View, android.view.View, int);
    method public android.view.View findNextKeyboardNavigationGroup(int, android.view.View, android.view.View, int);
    method public static android.view.FocusFinder getInstance();
  }
@@ -43144,7 +43144,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(int, java.util.Collection<android.view.View>, int);
    method public void addKeyboardNavigationGroups(int, 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>);
@@ -43432,7 +43432,7 @@ package android.view {
    method public boolean isVerticalFadingEdgeEnabled();
    method public boolean isVerticalScrollBarEnabled();
    method public void jumpDrawablesToCurrentState();
    method public android.view.View keyboardNavigationClusterSearch(int, android.view.View, int);
    method public android.view.View keyboardNavigationGroupSearch(int, android.view.View, int);
    method public void layout(int, int, int, int);
    method public final void measure(int, int);
    method protected static int[] mergeDrawableStates(int[], int[]);
@@ -43714,8 +43714,6 @@ package android.view {
    field public static final int FOCUS_BACKWARD = 1; // 0x1
    field public static final int FOCUS_DOWN = 130; // 0x82
    field public static final int FOCUS_FORWARD = 2; // 0x2
    field public static final int FOCUS_GROUP_CLUSTER = 1; // 0x1
    field public static final int FOCUS_GROUP_SECTION = 2; // 0x2
    field public static final int FOCUS_LEFT = 17; // 0x11
    field public static final int FOCUS_RIGHT = 66; // 0x42
    field public static final int FOCUS_UP = 33; // 0x21
@@ -43727,6 +43725,8 @@ package android.view {
    field public static final int IMPORTANT_FOR_ACCESSIBILITY_YES = 1; // 0x1
    field public static final int INVISIBLE = 4; // 0x4
    field public static final int KEEP_SCREEN_ON = 67108864; // 0x4000000
    field public static final int KEYBOARD_NAVIGATION_GROUP_CLUSTER = 1; // 0x1
    field public static final int KEYBOARD_NAVIGATION_GROUP_SECTION = 2; // 0x2
    field public static final int LAYER_TYPE_HARDWARE = 2; // 0x2
    field public static final int LAYER_TYPE_NONE = 0; // 0x0
    field public static final int LAYER_TYPE_SOFTWARE = 1; // 0x1
@@ -44245,7 +44245,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(int, android.view.View, int);
    method public abstract android.view.View keyboardNavigationGroupSearch(int, 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);
+6 −6
Original line number Diff line number Diff line
@@ -45065,7 +45065,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(int, android.view.View, android.view.View, int);
    method public android.view.View findNextKeyboardNavigationGroup(int, android.view.View, android.view.View, int);
    method public static android.view.FocusFinder getInstance();
  }
@@ -46362,7 +46362,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(int, java.util.Collection<android.view.View>, int);
    method public void addKeyboardNavigationGroups(int, 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>);
@@ -46650,7 +46650,7 @@ package android.view {
    method public boolean isVerticalFadingEdgeEnabled();
    method public boolean isVerticalScrollBarEnabled();
    method public void jumpDrawablesToCurrentState();
    method public android.view.View keyboardNavigationClusterSearch(int, android.view.View, int);
    method public android.view.View keyboardNavigationGroupSearch(int, android.view.View, int);
    method public void layout(int, int, int, int);
    method public final void measure(int, int);
    method protected static int[] mergeDrawableStates(int[], int[]);
@@ -46932,8 +46932,6 @@ package android.view {
    field public static final int FOCUS_BACKWARD = 1; // 0x1
    field public static final int FOCUS_DOWN = 130; // 0x82
    field public static final int FOCUS_FORWARD = 2; // 0x2
    field public static final int FOCUS_GROUP_CLUSTER = 1; // 0x1
    field public static final int FOCUS_GROUP_SECTION = 2; // 0x2
    field public static final int FOCUS_LEFT = 17; // 0x11
    field public static final int FOCUS_RIGHT = 66; // 0x42
    field public static final int FOCUS_UP = 33; // 0x21
@@ -46945,6 +46943,8 @@ package android.view {
    field public static final int IMPORTANT_FOR_ACCESSIBILITY_YES = 1; // 0x1
    field public static final int INVISIBLE = 4; // 0x4
    field public static final int KEEP_SCREEN_ON = 67108864; // 0x4000000
    field public static final int KEYBOARD_NAVIGATION_GROUP_CLUSTER = 1; // 0x1
    field public static final int KEYBOARD_NAVIGATION_GROUP_SECTION = 2; // 0x2
    field public static final int LAYER_TYPE_HARDWARE = 2; // 0x2
    field public static final int LAYER_TYPE_NONE = 0; // 0x0
    field public static final int LAYER_TYPE_SOFTWARE = 1; // 0x1
@@ -47463,7 +47463,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(int, android.view.View, int);
    method public abstract android.view.View keyboardNavigationGroupSearch(int, 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);
+6 −6
Original line number Diff line number Diff line
@@ -42134,7 +42134,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(int, android.view.View, android.view.View, int);
    method public android.view.View findNextKeyboardNavigationGroup(int, android.view.View, android.view.View, int);
    method public static android.view.FocusFinder getInstance();
  }
@@ -43433,7 +43433,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(int, java.util.Collection<android.view.View>, int);
    method public void addKeyboardNavigationGroups(int, 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>);
@@ -43722,7 +43722,7 @@ package android.view {
    method public boolean isVerticalFadingEdgeEnabled();
    method public boolean isVerticalScrollBarEnabled();
    method public void jumpDrawablesToCurrentState();
    method public android.view.View keyboardNavigationClusterSearch(int, android.view.View, int);
    method public android.view.View keyboardNavigationGroupSearch(int, android.view.View, int);
    method public void layout(int, int, int, int);
    method public final void measure(int, int);
    method protected static int[] mergeDrawableStates(int[], int[]);
@@ -44004,8 +44004,6 @@ package android.view {
    field public static final int FOCUS_BACKWARD = 1; // 0x1
    field public static final int FOCUS_DOWN = 130; // 0x82
    field public static final int FOCUS_FORWARD = 2; // 0x2
    field public static final int FOCUS_GROUP_CLUSTER = 1; // 0x1
    field public static final int FOCUS_GROUP_SECTION = 2; // 0x2
    field public static final int FOCUS_LEFT = 17; // 0x11
    field public static final int FOCUS_RIGHT = 66; // 0x42
    field public static final int FOCUS_UP = 33; // 0x21
@@ -44017,6 +44015,8 @@ package android.view {
    field public static final int IMPORTANT_FOR_ACCESSIBILITY_YES = 1; // 0x1
    field public static final int INVISIBLE = 4; // 0x4
    field public static final int KEEP_SCREEN_ON = 67108864; // 0x4000000
    field public static final int KEYBOARD_NAVIGATION_GROUP_CLUSTER = 1; // 0x1
    field public static final int KEYBOARD_NAVIGATION_GROUP_SECTION = 2; // 0x2
    field public static final int LAYER_TYPE_HARDWARE = 2; // 0x2
    field public static final int LAYER_TYPE_NONE = 0; // 0x0
    field public static final int LAYER_TYPE_SOFTWARE = 1; // 0x1
@@ -44539,7 +44539,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(int, android.view.View, int);
    method public abstract android.view.View keyboardNavigationGroupSearch(int, 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);
+63 −60
Original line number Diff line number Diff line
@@ -16,8 +16,8 @@

package android.view;

import static android.view.View.FOCUS_GROUP_CLUSTER;
import static android.view.View.FOCUS_GROUP_SECTION;
import static android.view.View.KEYBOARD_NAVIGATION_GROUP_CLUSTER;
import static android.view.View.KEYBOARD_NAVIGATION_GROUP_SECTION;

import android.annotation.NonNull;
import android.annotation.Nullable;
@@ -25,7 +25,7 @@ import android.graphics.Rect;
import android.util.ArrayMap;
import android.util.SparseArray;
import android.util.SparseBooleanArray;
import android.view.View.FocusGroupType;
import android.view.View.KeyboardNavigationGroupType;

import java.util.ArrayList;
import java.util.Collections;
@@ -110,30 +110,31 @@ public class FocusFinder {
    }

    /**
     * Find the root of the next keyboard navigation cluster after the current one.
     * @param focusGroupType Type of the focus group
     * Find the root of the next keyboard navigation group after the current one. The group type can
     * be either a cluster or a section.
     * @param groupType Type of the keyboard navigation group
     * @param root The view tree to look inside. Cannot be null
     * @param currentCluster The starting point of the search. Null means the default cluster
     * @param currentGroup The starting point of the search. Null means the default group
     * @param direction Direction to look
     * @return The next cluster, or null if none exists
     * @return The next group, or null if none exists
     */
    public View findNextKeyboardNavigationCluster(
            @FocusGroupType int focusGroupType,
    public View findNextKeyboardNavigationGroup(
            @KeyboardNavigationGroupType int groupType,
            @NonNull View root,
            @Nullable View currentCluster,
            @Nullable View currentGroup,
            int direction) {
        View next = null;

        final ArrayList<View> clusters = mTempList;
        final ArrayList<View> groups = mTempList;
        try {
            clusters.clear();
            root.addKeyboardNavigationClusters(focusGroupType, clusters, direction);
            if (!clusters.isEmpty()) {
                next = findNextKeyboardNavigationCluster(
                        focusGroupType, root, currentCluster, clusters, direction);
            groups.clear();
            root.addKeyboardNavigationGroups(groupType, groups, direction);
            if (!groups.isEmpty()) {
                next = findNextKeyboardNavigationGroup(
                        groupType, root, currentGroup, groups, direction);
            }
        } finally {
            clusters.clear();
            groups.clear();
        }
        return next;
    }
@@ -206,25 +207,25 @@ public class FocusFinder {
        }
    }

    private View findNextKeyboardNavigationCluster(
            @FocusGroupType int focusGroupType,
    private View findNextKeyboardNavigationGroup(
            @KeyboardNavigationGroupType int groupType,
            View root,
            View currentCluster,
            List<View> clusters,
            View currentGroup,
            List<View> groups,
            int direction) {
        final int count = clusters.size();
        final int count = groups.size();

        switch (direction) {
            case View.FOCUS_FORWARD:
            case View.FOCUS_DOWN:
            case View.FOCUS_RIGHT:
                return getNextKeyboardNavigationCluster(
                        focusGroupType, root, currentCluster, clusters, count);
                return getNextKeyboardNavigationGroup(
                        groupType, root, currentGroup, groups, count);
            case View.FOCUS_BACKWARD:
            case View.FOCUS_UP:
            case View.FOCUS_LEFT:
                return getPreviousKeyboardNavigationCluster(
                        focusGroupType, root, currentCluster, clusters, count);
                return getPreviousKeyboardNavigationGroup(
                        groupType, root, currentGroup, groups, count);
            default:
                throw new IllegalArgumentException("Unknown direction: " + direction);
        }
@@ -330,67 +331,69 @@ public class FocusFinder {
        return null;
    }

    private static View getNextKeyboardNavigationCluster(
            @FocusGroupType int focusGroupType,
    private static View getNextKeyboardNavigationGroup(
            @KeyboardNavigationGroupType int groupType,
            View root,
            View currentCluster,
            List<View> clusters,
            View currentGroup,
            List<View> groups,
            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);
        if (currentGroup == null) {
            // The current group is the default one.
            // The next group after the default one is the first one.
            // Note that the caller guarantees that 'group' is not empty.
            return groups.get(0);
        }

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

        switch (focusGroupType) {
            case FOCUS_GROUP_CLUSTER:
        switch (groupType) {
            case KEYBOARD_NAVIGATION_GROUP_CLUSTER:
                // The current cluster is the last one. The next one is the default one, i.e. the
                // root.
                return root;
            case FOCUS_GROUP_SECTION:
            case KEYBOARD_NAVIGATION_GROUP_SECTION:
                // There is no "default section", hence returning the first one.
                return clusters.get(0);
                return groups.get(0);
            default:
                throw new IllegalArgumentException("Unknown focus group type: " + focusGroupType);
                throw new IllegalArgumentException(
                        "Unknown keyboard navigation group type: " + groupType);
        }
    }

    private static View getPreviousKeyboardNavigationCluster(
            @FocusGroupType int focusGroupType,
    private static View getPreviousKeyboardNavigationGroup(
            @KeyboardNavigationGroupType int groupType,
            View root,
            View currentCluster,
            List<View> clusters,
            View currentGroup,
            List<View> groups,
            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);
        if (currentGroup == null) {
            // The current group is the default one.
            // The previous group before the default one is the last one.
            // Note that the caller guarantees that 'groups' is not empty.
            return groups.get(count - 1);
        }

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

        switch (focusGroupType) {
            case FOCUS_GROUP_CLUSTER:
        switch (groupType) {
            case KEYBOARD_NAVIGATION_GROUP_CLUSTER:
                // The current cluster is the first one. The previous one is the default one, i.e.
                // the root.
                return root;
            case FOCUS_GROUP_SECTION:
            case KEYBOARD_NAVIGATION_GROUP_SECTION:
                // There is no "default section", hence returning the last one.
                return clusters.get(count - 1);
                return groups.get(count - 1);
            default:
                throw new IllegalArgumentException("Unknown focus group type: " + focusGroupType);
                throw new IllegalArgumentException(
                        "Unknown keyboard navigation group type: " + groupType);
        }
    }

+39 −35

File changed.

Preview size limit exceeded, changes collapsed.

Loading