Fixed some a11y issues in MainActivity.

 - 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
diff --git a/java/com/android/dialer/main/impl/MainSearchController.java b/java/com/android/dialer/main/impl/MainSearchController.java
index 4f3ee60..7d380d7 100644
--- a/java/com/android/dialer/main/impl/MainSearchController.java
+++ b/java/com/android/dialer/main/impl/MainSearchController.java
@@ -128,7 +128,9 @@
       // 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);
     }
@@ -287,11 +289,20 @@
     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();
@@ -355,7 +366,9 @@
       // 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());
     }
diff --git a/java/com/android/dialer/main/impl/res/layout/main_activity.xml b/java/com/android/dialer/main/impl/res/layout/main_activity.xml
index 4f02841..b69625e 100644
--- a/java/com/android/dialer/main/impl/res/layout/main_activity.xml
+++ b/java/com/android/dialer/main/impl/res/layout/main_activity.xml
@@ -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>
 
diff --git a/java/com/android/dialer/main/impl/res/values/strings.xml b/java/com/android/dialer/main/impl/res/values/strings.xml
index c842bee..4e65432 100644
--- a/java/com/android/dialer/main/impl/res/values/strings.xml
+++ b/java/com/android/dialer/main/impl/res/values/strings.xml
@@ -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>