From d6cb3b9ac4db86cc5d37174a6e6c4d69c8a8a753 Mon Sep 17 00:00:00 2001 From: wangqi Date: Fri, 9 Mar 2018 16:33:43 -0800 Subject: 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 --- .../android/incallui/rtt/impl/RttChatFragment.java | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'java') diff --git a/java/com/android/incallui/rtt/impl/RttChatFragment.java b/java/com/android/incallui/rtt/impl/RttChatFragment.java index 9e8a24a48..e35ff4d73 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.ViewGroup; 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 android.widget.TextView.OnEditorActionListener; 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 @@ public class RttChatFragment extends Fragment @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { if (dy < 0) { - hideKeyboard(); + UiUtil.hideKeyboardFrom(getContext(), editText); } } }; @@ -182,7 +182,13 @@ public class RttChatFragment extends Fragment 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 @@ public class RttChatFragment extends Fragment 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(); -- cgit v1.2.3