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

Commit 83999850 authored by Amith Yamasani's avatar Amith Yamasani Committed by Android (Google) Code Review
Browse files

Merge "2853037 AccessibilityEvent should describe Tab controls"

parents 3608d33b 5ac413a1
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -144,6 +144,11 @@ mTabHost.addTab(TAB_TAG_1, "Hello, world!", "Tab 1");
        }
    }

    @Override
    public void sendAccessibilityEvent(int eventType) {
        /* avoid super class behavior - TabWidget sends the right events */
    }

    /**
     * If you are using {@link TabSpec#setContent(android.content.Intent)}, this
     * must be called since the activityGroup is needed to launch the local activity.
+27 −1
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnFocusChangeListener;
import android.view.accessibility.AccessibilityEvent;

/**
 *
@@ -335,7 +336,7 @@ public class TabWidget extends LinearLayout implements OnFocusChangeListener {
     *  @see #focusCurrentTab
     */
    public void setCurrentTab(int index) {
        if (index < 0 || index >= getTabCount()) {
        if (index < 0 || index >= getTabCount() || index == mSelectedTab) {
            return;
        }

@@ -343,6 +344,18 @@ public class TabWidget extends LinearLayout implements OnFocusChangeListener {
        mSelectedTab = index;
        getChildTabViewAt(mSelectedTab).setSelected(true);
        mStripMoved = true;

        if (isShown()) {
            sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SELECTED);
        }
    }

    @Override
    public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
        event.setItemCount(getTabCount());
        event.setCurrentItemIndex(mSelectedTab);
        getChildTabViewAt(mSelectedTab).dispatchPopulateAccessibilityEvent(event);
        return true;
    }

    /**
@@ -416,6 +429,15 @@ public class TabWidget extends LinearLayout implements OnFocusChangeListener {
        child.setOnFocusChangeListener(this);
    }

    @Override
    public void sendAccessibilityEventUnchecked(AccessibilityEvent event) {
        // this class fires events only when tabs are focused or selected
        if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_FOCUSED && isFocused()) {
            return;
        }
        super.sendAccessibilityEventUnchecked(event);
    }

    /**
     * Provides a way for {@link TabHost} to be notified that the user clicked on a tab indicator.
     */
@@ -436,6 +458,10 @@ public class TabWidget extends LinearLayout implements OnFocusChangeListener {
                if (getChildTabViewAt(i) == v) {
                    setCurrentTab(i);
                    mSelectionChangedListener.onTabSelectionChanged(i, false);
                    if (isShown()) {
                        // a tab is focused so send an event to announce the tab widget state
                        sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED);
                    }
                    break;
                }
                i++;