Hide keyboard when closing chat room side pane

This commit is contained in:
Sylvain Berfini 2022-01-17 10:42:31 +01:00
parent bef768f997
commit 17547753b4
2 changed files with 7 additions and 2 deletions

View file

@ -226,7 +226,7 @@ class MainActivity : GenericActivity(), SnackBarActivity, NavController.OnDestin
destination: NavDestination,
arguments: Bundle?
) {
currentFocus?.hideKeyboard()
hideKeyboard()
if (statusFragment.visibility == View.GONE) {
statusFragment.visibility = View.VISIBLE
}
@ -239,11 +239,15 @@ class MainActivity : GenericActivity(), SnackBarActivity, NavController.OnDestin
updateTabsFragmentVisibility()
}
fun hideKeyboard() {
currentFocus?.hideKeyboard()
}
private fun updateTabsFragmentVisibility() {
tabsFragment.visibility = if (tabsFragmentVisible1 && tabsFragmentVisible2) View.VISIBLE else View.GONE
}
private fun View.hideKeyboard() {
fun View.hideKeyboard() {
val imm = context.getSystemService(Activity.INPUT_METHOD_SERVICE) as InputMethodManager
imm.hideSoftInputFromWindow(windowToken, 0)
}

View file

@ -125,6 +125,7 @@ class MasterChatRoomsFragment : MasterFragment<ChatRoomMasterFragmentBinding, Ch
viewLifecycleOwner,
{
it.consume {
(requireActivity() as MainActivity).hideKeyboard()
if (!binding.slidingPane.closePane()) {
goBack()
}