Closed Gloix closed 7 years ago
Hi, I'd like to point out that accessibility is still lacking with this library. I'm interested in the topic because I'm developing an app targeted to visually impaired people so I have to hack into the view hierarchy in order to set the required content descriptions that I need.
Currently, in order to set the content description of the the back button and the clear query button I have these lines in my app code
mSearchView.findViewById(R.id.left_action).setContentDescription(getString(android.support.v7.appcompat.R.string.abc_action_bar_up_description));
mSearchView.findViewById(R.id.clear_btn).setContentDescription(getString(android.support.v7.appcompat.R.string.abc_searchview_description_clear));
Here I'm using resources from the appcompat library, which are marked private.
P.D.: #101 was merged so I won't have to keep a fork of the project anymore :)
I ran into this problem with my app Tusky. My code ended up as follows:
final View leftAction = searchView.findViewById(R.id.left_action);
leftAction.setContentDescription(getString(R.string.action_open_drawer));
searchView.setOnFocusChangeListener(new FloatingSearchView.OnFocusChangeListener() {
@Override
public void onFocus() {
leftAction.setContentDescription(getString(R.string.action_close));
}
@Override
public void onFocusCleared() {
leftAction.setContentDescription(getString(R.string.action_open_drawer));
}
});
View clearButton = searchView.findViewById(R.id.clear_btn);
clearButton.setContentDescription(getString(R.string.action_clear));
It's not too inconvenient, but having a way to specify it in the layout or with functions would've been a little cleaner.
Icons shown don't have a proper description. Currently it is easy to set menu items' contentDescription to that of the resource menu items' title using the
getTitle()
method inside the library. (Maybe I can submit a pull request for that).Regarding the up navigation string, it can be extracted from
android.support.v7.appcompat.R.string.abc_action_bar_up_description
, but I haven't found a string resource for the hamburger icon.As of now, the easy fix for a developer using the library is to set the
contentDescription
for the icon found by theleft_icon
id, though I don't think this is the proper way. Or at least should be properly documented. However, I think the proper way would be to have it translated beforehand.