Skip to content

Commit

Permalink
[SearchBar] Added support to set a default content description if a c…
Browse files Browse the repository at this point in the history
…ontent description is not set explicitly.

PiperOrigin-RevId: 546349642
  • Loading branch information
raajkumars authored and paulfthomas committed Jul 11, 2023
1 parent d440e3c commit c15a323
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/java/com/google/android/material/search/SearchBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,9 @@ public SearchBar(@NonNull Context context, @Nullable AttributeSet attrs, int def
accessibilityManager =
(AccessibilityManager) getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
setupTouchExplorationStateChangeListener();
if (getContentDescription() == null) {
setContentDescription(getResources().getText(R.string.searchbar_default_content_description));
}
}

private void setupTouchExplorationStateChangeListener() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
com.google.android.material.search.SearchBar$ScrollingViewBehavior
</string>

<string name="searchbar_default_content_description"
description="Content description for the search bar, which is a product component name. [CHAR_LIMIT=NONE]">Search Bar</string>
<!-- Default content description for the navigation button (i.e. the back arrow) for
SearchView. -->
<string name="searchview_navigation_content_description"
Expand Down

0 comments on commit c15a323

Please sign in to comment.