Dismiss keyboard when opening overflow menu in RTT call.

This is to prevent dialpad showing with keyboard open.
The alternative way to dismiss keyboard after dialpad shows up doesn't work.

Bug: 67596257
Test: manual
PiperOrigin-RevId: 188556453
Change-Id: I4b917d8ac83246d2002641ae7759261699149c65
diff --git a/java/com/android/incallui/rtt/impl/RttChatFragment.java b/java/com/android/incallui/rtt/impl/RttChatFragment.java
index 9e8a24a..e35ff4d 100644
--- a/java/com/android/incallui/rtt/impl/RttChatFragment.java
+++ b/java/com/android/incallui/rtt/impl/RttChatFragment.java
@@ -37,7 +37,6 @@
 import android.view.Window;
 import android.view.accessibility.AccessibilityEvent;
 import android.view.inputmethod.EditorInfo;
-import android.view.inputmethod.InputMethodManager;
 import android.widget.Chronometer;
 import android.widget.EditText;
 import android.widget.ImageButton;
@@ -46,6 +45,7 @@
 import com.android.dialer.common.Assert;
 import com.android.dialer.common.FragmentUtils;
 import com.android.dialer.common.LogUtil;
+import com.android.dialer.common.UiUtil;
 import com.android.incallui.audioroute.AudioRouteSelectorDialogFragment;
 import com.android.incallui.audioroute.AudioRouteSelectorDialogFragment.AudioRouteSelectorPresenter;
 import com.android.incallui.call.DialerCall.State;
@@ -87,7 +87,7 @@
         @Override
         public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
           if (dy < 0) {
-            hideKeyboard();
+            UiUtil.hideKeyboardFrom(getContext(), editText);
           }
         }
       };
@@ -182,7 +182,13 @@
 
     overflowMenu = new RttOverflowMenu(getContext(), inCallButtonUiDelegate);
     view.findViewById(R.id.rtt_overflow_button)
-        .setOnClickListener(v -> overflowMenu.showAtLocation(v, Gravity.TOP | Gravity.RIGHT, 0, 0));
+        .setOnClickListener(
+            v -> {
+              // Hide keyboard when opening overflow menu. This is alternative solution since hiding
+              // keyboard after the menu is open or dialpad is shown doesn't work.
+              UiUtil.hideKeyboardFrom(getContext(), editText);
+              overflowMenu.showAtLocation(v, Gravity.TOP | Gravity.RIGHT, 0, 0);
+            });
 
     nameTextView = view.findViewById(R.id.rtt_name_or_number);
     chronometer = view.findViewById(R.id.rtt_timer);
@@ -265,14 +271,6 @@
     onRttScreenStop();
   }
 
-  private void hideKeyboard() {
-    InputMethodManager inputMethodManager = getContext().getSystemService(InputMethodManager.class);
-    if (inputMethodManager.isAcceptingText()) {
-      inputMethodManager.hideSoftInputFromWindow(
-          getActivity().getCurrentFocus().getWindowToken(), 0);
-    }
-  }
-
   @Override
   public void onRttScreenStart() {
     rttCallScreenDelegate.onRttCallScreenUiReady();