Merge "Bug 5249855 - Add support for content descriptions on action bar tabs"
This commit is contained in:
@@ -2487,12 +2487,15 @@ package android.app {
|
|||||||
|
|
||||||
public static abstract class ActionBar.Tab {
|
public static abstract class ActionBar.Tab {
|
||||||
ctor public ActionBar.Tab();
|
ctor public ActionBar.Tab();
|
||||||
|
method public abstract java.lang.CharSequence getContentDescription();
|
||||||
method public abstract android.view.View getCustomView();
|
method public abstract android.view.View getCustomView();
|
||||||
method public abstract android.graphics.drawable.Drawable getIcon();
|
method public abstract android.graphics.drawable.Drawable getIcon();
|
||||||
method public abstract int getPosition();
|
method public abstract int getPosition();
|
||||||
method public abstract java.lang.Object getTag();
|
method public abstract java.lang.Object getTag();
|
||||||
method public abstract java.lang.CharSequence getText();
|
method public abstract java.lang.CharSequence getText();
|
||||||
method public abstract void select();
|
method public abstract void select();
|
||||||
|
method public abstract android.app.ActionBar.Tab setContentDescription(int);
|
||||||
|
method public abstract android.app.ActionBar.Tab setContentDescription(java.lang.CharSequence);
|
||||||
method public abstract android.app.ActionBar.Tab setCustomView(android.view.View);
|
method public abstract android.app.ActionBar.Tab setCustomView(android.view.View);
|
||||||
method public abstract android.app.ActionBar.Tab setCustomView(int);
|
method public abstract android.app.ActionBar.Tab setCustomView(int);
|
||||||
method public abstract android.app.ActionBar.Tab setIcon(android.graphics.drawable.Drawable);
|
method public abstract android.app.ActionBar.Tab setIcon(android.graphics.drawable.Drawable);
|
||||||
|
|||||||
@@ -790,6 +790,37 @@ public abstract class ActionBar {
|
|||||||
* Select this tab. Only valid if the tab has been added to the action bar.
|
* Select this tab. Only valid if the tab has been added to the action bar.
|
||||||
*/
|
*/
|
||||||
public abstract void select();
|
public abstract void select();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a description of this tab's content for use in accessibility support.
|
||||||
|
* If no content description is provided the title will be used.
|
||||||
|
*
|
||||||
|
* @param resId A resource ID referring to the description text
|
||||||
|
* @return The current instance for call chaining
|
||||||
|
* @see #setContentDescription(CharSequence)
|
||||||
|
* @see #getContentDescription()
|
||||||
|
*/
|
||||||
|
public abstract Tab setContentDescription(int resId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a description of this tab's content for use in accessibility support.
|
||||||
|
* If no content description is provided the title will be used.
|
||||||
|
*
|
||||||
|
* @param contentDesc Description of this tab's content
|
||||||
|
* @return The current instance for call chaining
|
||||||
|
* @see #setContentDescription(int)
|
||||||
|
* @see #getContentDescription()
|
||||||
|
*/
|
||||||
|
public abstract Tab setContentDescription(CharSequence contentDesc);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a brief description of this tab's content for use in accessibility support.
|
||||||
|
*
|
||||||
|
* @return Description of this tab's content
|
||||||
|
* @see #setContentDescription(CharSequence)
|
||||||
|
* @see #setContentDescription(int)
|
||||||
|
*/
|
||||||
|
public abstract CharSequence getContentDescription();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -783,6 +783,7 @@ public class ActionBarImpl extends ActionBar {
|
|||||||
private Object mTag;
|
private Object mTag;
|
||||||
private Drawable mIcon;
|
private Drawable mIcon;
|
||||||
private CharSequence mText;
|
private CharSequence mText;
|
||||||
|
private CharSequence mContentDesc;
|
||||||
private int mPosition = -1;
|
private int mPosition = -1;
|
||||||
private View mCustomView;
|
private View mCustomView;
|
||||||
|
|
||||||
@@ -878,6 +879,25 @@ public class ActionBarImpl extends ActionBar {
|
|||||||
public void select() {
|
public void select() {
|
||||||
selectTab(this);
|
selectTab(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Tab setContentDescription(int resId) {
|
||||||
|
return setContentDescription(mContext.getResources().getText(resId));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Tab setContentDescription(CharSequence contentDesc) {
|
||||||
|
mContentDesc = contentDesc;
|
||||||
|
if (mPosition >= 0) {
|
||||||
|
mTabScrollView.updateTab(mPosition);
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CharSequence getContentDescription() {
|
||||||
|
return mContentDesc;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -443,6 +443,8 @@ public class ScrollingTabContainerView extends HorizontalScrollView
|
|||||||
mTextView.setVisibility(GONE);
|
mTextView.setVisibility(GONE);
|
||||||
mTextView.setText(null);
|
mTextView.setText(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setContentDescription(tab.getContentDescription());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user