Merge "Accessibility fixes for action bars"
This commit is contained in:
@@ -23,7 +23,9 @@ import android.graphics.drawable.Drawable;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.Gravity;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.accessibility.AccessibilityEvent;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.LinearLayout;
|
||||
@@ -157,14 +159,33 @@ public class ActionMenuItemView extends LinearLayout
|
||||
public void setTitle(CharSequence title) {
|
||||
mTitle = title;
|
||||
|
||||
// populate accessibility description with title
|
||||
setContentDescription(title);
|
||||
|
||||
mTextButton.setText(mTitle);
|
||||
|
||||
setContentDescription(mTitle);
|
||||
updateTextButtonVisibility();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
|
||||
onPopulateAccessibilityEvent(event);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPopulateAccessibilityEvent(AccessibilityEvent event) {
|
||||
super.onPopulateAccessibilityEvent(event);
|
||||
final CharSequence cdesc = getContentDescription();
|
||||
if (!TextUtils.isEmpty(cdesc)) {
|
||||
event.getText().add(cdesc);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean dispatchHoverEvent(MotionEvent event) {
|
||||
// Don't allow children to hover; we want this to be treated as a single component.
|
||||
return onHoverEvent(event);
|
||||
}
|
||||
|
||||
public boolean showsIcon() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -30,6 +30,9 @@ import android.view.View;
|
||||
import android.view.View.MeasureSpec;
|
||||
import android.view.ViewConfiguration;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewParent;
|
||||
import android.view.accessibility.AccessibilityEvent;
|
||||
import android.view.accessibility.AccessibilityNodeInfo;
|
||||
import android.widget.ImageButton;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@@ -22,6 +22,7 @@ import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.ViewDebug;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.accessibility.AccessibilityEvent;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
/**
|
||||
@@ -511,6 +512,10 @@ public class ActionMenuView extends LinearLayout implements MenuBuilder.ItemInvo
|
||||
return result;
|
||||
}
|
||||
|
||||
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public interface ActionMenuChildView {
|
||||
public boolean needsDividerBefore();
|
||||
public boolean needsDividerAfter();
|
||||
|
||||
@@ -46,10 +46,12 @@ import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewParent;
|
||||
import android.view.Window;
|
||||
import android.view.accessibility.AccessibilityEvent;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
@@ -220,6 +222,8 @@ public class ActionBarView extends AbsActionBarView {
|
||||
mExpandedHomeLayout = (HomeView) inflater.inflate(homeResId, this, false);
|
||||
mExpandedHomeLayout.setUp(true);
|
||||
mExpandedHomeLayout.setOnClickListener(mExpandedActionViewUpListener);
|
||||
mExpandedHomeLayout.setContentDescription(getResources().getText(
|
||||
R.string.action_bar_up_description));
|
||||
|
||||
mTitleStyleRes = a.getResourceId(R.styleable.ActionBar_titleTextStyle, 0);
|
||||
mSubtitleStyleRes = a.getResourceId(R.styleable.ActionBar_subtitleTextStyle, 0);
|
||||
@@ -1190,6 +1194,27 @@ public class ActionBarView extends AbsActionBarView {
|
||||
mIconView.setImageDrawable(icon);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
|
||||
onPopulateAccessibilityEvent(event);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPopulateAccessibilityEvent(AccessibilityEvent event) {
|
||||
super.onPopulateAccessibilityEvent(event);
|
||||
final CharSequence cdesc = getContentDescription();
|
||||
if (!TextUtils.isEmpty(cdesc)) {
|
||||
event.getText().add(cdesc);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean dispatchHoverEvent(MotionEvent event) {
|
||||
// Don't allow children to hover; we want this to be treated as a single component.
|
||||
return onHoverEvent(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFinishInflate() {
|
||||
mUpView = findViewById(com.android.internal.R.id.up);
|
||||
|
||||
Reference in New Issue
Block a user