diff options
| author | 2015-08-17 14:22:22 -0400 | |
|---|---|---|
| committer | 2015-08-17 14:23:10 -0400 | |
| commit | 1352a36beee96b8710f8d9f28c58117ced62eeca (patch) | |
| tree | 21c773ec58367560f2035a0031fae12484c9b15c | |
| parent | cbb6c16fe66b9cfffe74eb2a805064e46f885662 (diff) | |
Separate TabWidget selection from keyboard focus
Also removes a bunch of weird accessibility hacks that shouldn't have
been there in the first place.
Bug: 19382871
Change-Id: I8cbdfb6e2dab98cc88028dff5bc23376c98a077a
| -rw-r--r-- | core/java/android/widget/TabWidget.java | 59 |
1 files changed, 2 insertions, 57 deletions
diff --git a/core/java/android/widget/TabWidget.java b/core/java/android/widget/TabWidget.java index 0cc630aae526..20b771b81fd7 100644 --- a/core/java/android/widget/TabWidget.java +++ b/core/java/android/widget/TabWidget.java @@ -117,11 +117,6 @@ public class TabWidget extends LinearLayout implements OnFocusChangeListener { a.recycle(); setChildrenDrawingOrderEnabled(true); - - // Deal with focus, as we don't want the focus to go by default - // to a tab other than the current tab - setFocusable(true); - setOnFocusChangeListener(this); } @Override @@ -434,24 +429,6 @@ public class TabWidget extends LinearLayout implements OnFocusChangeListener { mSelectedTab = index; getChildTabViewAt(mSelectedTab).setSelected(true); mStripMoved = true; - - if (isShown()) { - sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SELECTED); - } - } - - /** @hide */ - @Override - public boolean dispatchPopulateAccessibilityEventInternal(AccessibilityEvent event) { - onPopulateAccessibilityEvent(event); - // Dispatch only to the selected tab. - if (mSelectedTab != -1) { - View tabView = getChildTabViewAt(mSelectedTab); - if (tabView != null && tabView.getVisibility() == VISIBLE) { - return tabView.dispatchPopulateAccessibilityEvent(event); - } - } - return false; } @Override @@ -467,18 +444,6 @@ public class TabWidget extends LinearLayout implements OnFocusChangeListener { event.setCurrentItemIndex(mSelectedTab); } - - /** @hide */ - @Override - public void sendAccessibilityEventUncheckedInternal(AccessibilityEvent event) { - // this class fires events only when tabs are focused or selected - if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_FOCUSED && isFocused()) { - event.recycle(); - return; - } - super.sendAccessibilityEventUncheckedInternal(event); - } - /** * Sets the current tab and focuses the UI on it. * This method makes sure that the focused tab matches the selected @@ -534,7 +499,6 @@ public class TabWidget extends LinearLayout implements OnFocusChangeListener { // TODO: detect this via geometry with a tabwidget listener rather // than potentially interfere with the view's listener child.setOnClickListener(new TabClickListener(getTabCount() - 1)); - child.setOnFocusChangeListener(this); } @Override @@ -551,28 +515,9 @@ public class TabWidget extends LinearLayout implements OnFocusChangeListener { mSelectionChangedListener = listener; } + @Override public void onFocusChange(View v, boolean hasFocus) { - if (v == this && hasFocus && getTabCount() > 0) { - getChildTabViewAt(mSelectedTab).requestFocus(); - return; - } - - if (hasFocus) { - int i = 0; - int numTabs = getTabCount(); - while (i < numTabs) { - 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++; - } - } + // No-op. Tab selection is separate from keyboard focus. } // registered with each tab indicator so we can notify tab host |