I've been working on making our app more accessible for user's using it with TalkBack. One issue I've ran into is the Google SignInButton announces itself as "Button" via TalkBack (not even "unlabeled").
I've tried setting its contentDescription both in xml and code like other views in the app, but it hasn't made a difference to this behavior.
Any ideas on how to get this view to announce itself as "Google Button" for instance would be much appreciated!
If it helps, this is what the view looks like in the xml:
<com.google.android.gms.common.SignInButton
android:id="@+id/google_sign_in_button"
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_marginEnd="10dp"
android:layout_marginTop="0dp"
android:layout_weight="1" />
Thanks!
During debugging I found that SignInButton has a single child element. Setting the contentDescription on this child element got the correct behavior from TalkBack. Here is the code:
SignInButton signInButton = (SignInButton) view.findViewById(R.id.google_sign_in_button);
signInButton.setSize(SignInButton.SIZE_ICON_ONLY);
signInButton.setScopes(mGso.getScopeArray());
signInButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
googleSignIn();
}
});
if (signInButton.getChildCount() > 0) {
View signInButtonInnerContent = signInButton.getChildAt(0);
signInButtonInnerContent.setContentDescription(getString(R.string.google_button_description));
}