From cc33c008ba20fc93f53edfe49b0093a8332cd203 Mon Sep 17 00:00:00 2001 From: Onuray Sahin Date: Thu, 15 Dec 2022 15:50:02 +0300 Subject: [PATCH] Automatically show keyboard after learn more bottom sheet is dismissed. --- .../v2/more/SessionLearnMoreBottomSheet.kt | 11 ++++++++++- .../devices/v2/rename/RenameSessionFragment.kt | 18 ++++++++++++++++-- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/more/SessionLearnMoreBottomSheet.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/more/SessionLearnMoreBottomSheet.kt index 22ca06eb1e..502d9abca3 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/v2/more/SessionLearnMoreBottomSheet.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/more/SessionLearnMoreBottomSheet.kt @@ -16,6 +16,7 @@ package im.vector.app.features.settings.devices.v2.more +import android.content.DialogInterface import android.os.Bundle import android.os.Parcelable import android.view.LayoutInflater @@ -42,6 +43,8 @@ class SessionLearnMoreBottomSheet : VectorBaseBottomSheetDialogFragment Unit)? = null + override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): BottomSheetSessionLearnMoreBinding { return BottomSheetSessionLearnMoreBinding.inflate(inflater, container, false) } @@ -57,6 +60,11 @@ class SessionLearnMoreBottomSheet : VectorBaseBottomSheetDialogFragment super.invalidate() views.bottomSheetSessionLearnMoreTitle.text = viewState.title @@ -65,11 +73,12 @@ class SessionLearnMoreBottomSheet : VectorBaseBottomSheetDialogFragment viewModel.handle(RenameSessionAction.EditLocally(text.toString())) } } + private fun showKeyboard() { + views.renameSessionEditText.viewTreeObserver.addOnWindowFocusChangeListener { hasFocus -> + if (hasFocus) { + views.renameSessionEditText.showKeyboard(andRequestFocus = true) + } + } + } + private fun initSaveButton() { views.renameSessionSave.debouncedClicks { viewModel.handle(RenameSessionAction.SaveModifications) @@ -89,7 +97,13 @@ class RenameSessionFragment : title = getString(R.string.device_manager_learn_more_session_rename_title), description = getString(R.string.device_manager_learn_more_session_rename), ) - SessionLearnMoreBottomSheet.show(childFragmentManager, args) + SessionLearnMoreBottomSheet + .show(childFragmentManager, args) + .apply { + onDismiss = { + showKeyboard() + } + } } private fun observeViewEvents() {