Skip to content

Commit

Permalink
Fixed some a11y issues in MainActivity.
Browse files Browse the repository at this point in the history
 - main fragments are no longer detected by talkback while search is open.
 - FAB now has a content description

Bug: 73587831,73891132
Test: tap
PiperOrigin-RevId: 187248081
Change-Id: I5a8fe2df23542d19c935cba77d1337ec753064af
  • Loading branch information
calderwoodra authored and Copybara-Service committed Feb 28, 2018
1 parent 0b0c209 commit 27b963f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
23 changes: 18 additions & 5 deletions java/com/android/dialer/main/impl/MainSearchController.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,9 @@ private void showDialpad(boolean animate, boolean fromNewIntent) {
// TODO(a bug): zero suggest results aren't actually shown but this enabled the nearby
// places promo to be shown.
searchFragment = NewSearchFragment.newInstance(/* showZeroSuggest=*/ true);
transaction.add(R.id.fragment_container, searchFragment, SEARCH_FRAGMENT_TAG);
transaction.replace(R.id.fragment_container, searchFragment, SEARCH_FRAGMENT_TAG);
transaction.addToBackStack(null);
transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
} else if (!isSearchVisible()) {
transaction.show(searchFragment);
}
Expand Down Expand Up @@ -287,11 +289,20 @@ private void closeSearch(boolean animate) {
showBottomNav();
toolbar.collapse(animate);
toolbarShadow.setVisibility(View.GONE);
mainActivity.getFragmentManager().beginTransaction().remove(getSearchFragment()).commit();
mainActivity.getFragmentManager().popBackStack();

// Clear the dialpad so the phone number isn't persisted between search sessions.
if (getDialpadFragment() != null) {
getDialpadFragment().clearDialpad();
DialpadFragment dialpadFragment = getDialpadFragment();
if (dialpadFragment != null) {
// Temporarily disable accessibility when we clear the dialpad, since it should be
// invisible and should not announce anything.
dialpadFragment
.getDigitsWidget()
.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO);
dialpadFragment.clearDialpad();
dialpadFragment
.getDigitsWidget()
.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_AUTO);
}

notifyListenersOnSearchClose();
Expand Down Expand Up @@ -355,7 +366,9 @@ private void openSearch(Optional<String> query) {
// TODO(a bug): zero suggest results aren't actually shown but this enabled the nearby
// places promo to be shown.
searchFragment = NewSearchFragment.newInstance(true);
transaction.add(R.id.fragment_container, searchFragment, SEARCH_FRAGMENT_TAG);
transaction.replace(R.id.fragment_container, searchFragment, SEARCH_FRAGMENT_TAG);
transaction.addToBackStack(null);
transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
} else if (!isSearchVisible()) {
transaction.show(getSearchFragment());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
android:layout_margin="16dp"
android:layout_gravity="end|bottom"
android:src="@drawable/quantum_ic_dialpad_white_24"
android:contentDescription="@string/dialpad_button_content_description"
app:backgroundTint="?android:attr/colorAccent"/>
</android.support.design.widget.CoordinatorLayout>

Expand Down
4 changes: 4 additions & 0 deletions java/com/android/dialer/main/impl/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,8 @@

<!-- Message displayed when there is no application available to handle voice search. [CHAR LIMIT=NONE] -->
<string name="voice_search_not_available">Voice search not available</string>

<!-- Content description for the button that displays the dialpad
[CHAR LIMIT=NONE] -->
<string name="dialpad_button_content_description">key pad</string>
</resources>

0 comments on commit 27b963f

Please sign in to comment.