Automatically show keyboard after learn more bottom sheet is dismissed.

This commit is contained in:
Onuray Sahin 2022-12-15 15:50:02 +03:00
parent 8c49609aa6
commit cc33c008ba
2 changed files with 26 additions and 3 deletions

View file

@ -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<BottomSh
override val showExpanded = true
var onDismiss: (() -> Unit)? = null
override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): BottomSheetSessionLearnMoreBinding {
return BottomSheetSessionLearnMoreBinding.inflate(inflater, container, false)
}
@ -57,6 +60,11 @@ class SessionLearnMoreBottomSheet : VectorBaseBottomSheetDialogFragment<BottomSh
}
}
override fun onDismiss(dialog: DialogInterface) {
super.onDismiss(dialog)
onDismiss?.invoke()
}
override fun invalidate() = withState(viewModel) { viewState ->
super.invalidate()
views.bottomSheetSessionLearnMoreTitle.text = viewState.title
@ -65,11 +73,12 @@ class SessionLearnMoreBottomSheet : VectorBaseBottomSheetDialogFragment<BottomSh
companion object {
fun show(fragmentManager: FragmentManager, args: Args) {
fun show(fragmentManager: FragmentManager, args: Args): SessionLearnMoreBottomSheet {
val bottomSheet = SessionLearnMoreBottomSheet()
bottomSheet.isCancelable = true
bottomSheet.setArguments(args)
bottomSheet.show(fragmentManager, "SessionLearnMoreBottomSheet")
return bottomSheet
}
}
}

View file

@ -62,12 +62,20 @@ class RenameSessionFragment :
}
private fun initEditText() {
views.renameSessionEditText.showKeyboard(andRequestFocus = true)
showKeyboard()
views.renameSessionEditText.doOnTextChanged { text, _, _, _ ->
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() {