mirror of
https://github.com/element-hq/element-android
synced 2024-11-27 03:48:12 +03:00
Automatically show keyboard after learn more bottom sheet is dismissed.
This commit is contained in:
parent
8c49609aa6
commit
cc33c008ba
2 changed files with 26 additions and 3 deletions
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
package im.vector.app.features.settings.devices.v2.more
|
package im.vector.app.features.settings.devices.v2.more
|
||||||
|
|
||||||
|
import android.content.DialogInterface
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.os.Parcelable
|
import android.os.Parcelable
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
|
@ -42,6 +43,8 @@ class SessionLearnMoreBottomSheet : VectorBaseBottomSheetDialogFragment<BottomSh
|
||||||
|
|
||||||
override val showExpanded = true
|
override val showExpanded = true
|
||||||
|
|
||||||
|
var onDismiss: (() -> Unit)? = null
|
||||||
|
|
||||||
override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): BottomSheetSessionLearnMoreBinding {
|
override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): BottomSheetSessionLearnMoreBinding {
|
||||||
return BottomSheetSessionLearnMoreBinding.inflate(inflater, container, false)
|
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 ->
|
override fun invalidate() = withState(viewModel) { viewState ->
|
||||||
super.invalidate()
|
super.invalidate()
|
||||||
views.bottomSheetSessionLearnMoreTitle.text = viewState.title
|
views.bottomSheetSessionLearnMoreTitle.text = viewState.title
|
||||||
|
@ -65,11 +73,12 @@ class SessionLearnMoreBottomSheet : VectorBaseBottomSheetDialogFragment<BottomSh
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
fun show(fragmentManager: FragmentManager, args: Args) {
|
fun show(fragmentManager: FragmentManager, args: Args): SessionLearnMoreBottomSheet {
|
||||||
val bottomSheet = SessionLearnMoreBottomSheet()
|
val bottomSheet = SessionLearnMoreBottomSheet()
|
||||||
bottomSheet.isCancelable = true
|
bottomSheet.isCancelable = true
|
||||||
bottomSheet.setArguments(args)
|
bottomSheet.setArguments(args)
|
||||||
bottomSheet.show(fragmentManager, "SessionLearnMoreBottomSheet")
|
bottomSheet.show(fragmentManager, "SessionLearnMoreBottomSheet")
|
||||||
|
return bottomSheet
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,12 +62,20 @@ class RenameSessionFragment :
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initEditText() {
|
private fun initEditText() {
|
||||||
views.renameSessionEditText.showKeyboard(andRequestFocus = true)
|
showKeyboard()
|
||||||
views.renameSessionEditText.doOnTextChanged { text, _, _, _ ->
|
views.renameSessionEditText.doOnTextChanged { text, _, _, _ ->
|
||||||
viewModel.handle(RenameSessionAction.EditLocally(text.toString()))
|
viewModel.handle(RenameSessionAction.EditLocally(text.toString()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun showKeyboard() {
|
||||||
|
views.renameSessionEditText.viewTreeObserver.addOnWindowFocusChangeListener { hasFocus ->
|
||||||
|
if (hasFocus) {
|
||||||
|
views.renameSessionEditText.showKeyboard(andRequestFocus = true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun initSaveButton() {
|
private fun initSaveButton() {
|
||||||
views.renameSessionSave.debouncedClicks {
|
views.renameSessionSave.debouncedClicks {
|
||||||
viewModel.handle(RenameSessionAction.SaveModifications)
|
viewModel.handle(RenameSessionAction.SaveModifications)
|
||||||
|
@ -89,7 +97,13 @@ class RenameSessionFragment :
|
||||||
title = getString(R.string.device_manager_learn_more_session_rename_title),
|
title = getString(R.string.device_manager_learn_more_session_rename_title),
|
||||||
description = getString(R.string.device_manager_learn_more_session_rename),
|
description = getString(R.string.device_manager_learn_more_session_rename),
|
||||||
)
|
)
|
||||||
SessionLearnMoreBottomSheet.show(childFragmentManager, args)
|
SessionLearnMoreBottomSheet
|
||||||
|
.show(childFragmentManager, args)
|
||||||
|
.apply {
|
||||||
|
onDismiss = {
|
||||||
|
showKeyboard()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun observeViewEvents() {
|
private fun observeViewEvents() {
|
||||||
|
|
Loading…
Reference in a new issue