Create showKeyBoard() extension
This commit is contained in:
parent
4b273e8746
commit
a3f8f138a6
|
@ -21,6 +21,14 @@ import android.view.View
|
|||
import android.view.inputmethod.InputMethodManager
|
||||
|
||||
fun View.hideKeyboard() {
|
||||
val imm = context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
|
||||
imm.hideSoftInputFromWindow(windowToken, 0)
|
||||
val imm = context?.getSystemService(Context.INPUT_METHOD_SERVICE) as? InputMethodManager
|
||||
imm?.hideSoftInputFromWindow(windowToken, 0)
|
||||
}
|
||||
|
||||
fun View.showKeyboard(andRequestFocus: Boolean = false) {
|
||||
if (andRequestFocus) {
|
||||
requestFocus()
|
||||
}
|
||||
val imm = context?.getSystemService(Context.INPUT_METHOD_SERVICE) as? InputMethodManager
|
||||
imm?.showSoftInput(this, InputMethodManager.SHOW_IMPLICIT)
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ import im.vector.matrix.android.api.session.user.model.User
|
|||
import im.vector.riotx.R
|
||||
import im.vector.riotx.core.extensions.hideKeyboard
|
||||
import im.vector.riotx.core.extensions.setupAsSearch
|
||||
import im.vector.riotx.core.extensions.showKeyboard
|
||||
import im.vector.riotx.core.platform.VectorBaseFragment
|
||||
import kotlinx.android.synthetic.main.fragment_create_direct_room_directory_users.*
|
||||
import javax.inject.Inject
|
||||
|
@ -63,9 +64,7 @@ class CreateDirectRoomDirectoryUsersFragment @Inject constructor(
|
|||
viewModel.handle(CreateDirectRoomAction.SearchDirectoryUsers(it.toString()))
|
||||
}
|
||||
.disposeOnDestroyView()
|
||||
createDirectRoomSearchById.requestFocus()
|
||||
val imm = context?.getSystemService(Context.INPUT_METHOD_SERVICE) as? InputMethodManager
|
||||
imm?.showSoftInput(createDirectRoomSearchById, InputMethodManager.SHOW_IMPLICIT)
|
||||
createDirectRoomSearchById.showKeyboard(andRequestFocus = true)
|
||||
}
|
||||
|
||||
private fun setupCloseView() {
|
||||
|
|
|
@ -74,6 +74,7 @@ import im.vector.riotx.core.error.ErrorFormatter
|
|||
import im.vector.riotx.core.extensions.hideKeyboard
|
||||
import im.vector.riotx.core.extensions.observeEvent
|
||||
import im.vector.riotx.core.extensions.setTextOrHide
|
||||
import im.vector.riotx.core.extensions.showKeyboard
|
||||
import im.vector.riotx.core.files.addEntryToDownloadManager
|
||||
import im.vector.riotx.core.glide.GlideApp
|
||||
import im.vector.riotx.core.platform.VectorBaseFragment
|
||||
|
@ -1223,9 +1224,7 @@ class RoomDetailFragment @Inject constructor(
|
|||
}
|
||||
|
||||
private fun focusComposerAndShowKeyboard() {
|
||||
composerLayout.composerEditText.requestFocus()
|
||||
val imm = context?.getSystemService(Context.INPUT_METHOD_SERVICE) as? InputMethodManager
|
||||
imm?.showSoftInput(composerLayout.composerEditText, InputMethodManager.SHOW_IMPLICIT)
|
||||
composerLayout.composerEditText.showKeyboard(andRequestFocus = true)
|
||||
}
|
||||
|
||||
private fun showSnackWithMessage(message: String, duration: Int = Snackbar.LENGTH_SHORT) {
|
||||
|
|
|
@ -38,6 +38,7 @@ import com.bumptech.glide.load.engine.cache.DiskCache
|
|||
import com.google.android.material.textfield.TextInputEditText
|
||||
import com.google.android.material.textfield.TextInputLayout
|
||||
import im.vector.riotx.R
|
||||
import im.vector.riotx.core.extensions.hideKeyboard
|
||||
import im.vector.riotx.core.extensions.showPassword
|
||||
import im.vector.riotx.core.platform.SimpleTextWatcher
|
||||
import im.vector.riotx.core.preference.UserAvatarPreference
|
||||
|
@ -696,8 +697,7 @@ class VectorSettingsGeneralFragment : VectorSettingsBaseFragment() {
|
|||
.setPositiveButton(R.string.settings_change_password_submit, null)
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.setOnDismissListener {
|
||||
val imm = activity.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
|
||||
imm.hideSoftInputFromWindow(view.applicationWindowToken, 0)
|
||||
view.hideKeyboard()
|
||||
}
|
||||
.create()
|
||||
|
||||
|
@ -762,8 +762,7 @@ class VectorSettingsGeneralFragment : VectorSettingsBaseFragment() {
|
|||
showPassword.performClick()
|
||||
}
|
||||
|
||||
val imm = activity.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
|
||||
imm.hideSoftInputFromWindow(view.applicationWindowToken, 0)
|
||||
view.hideKeyboard()
|
||||
|
||||
val oldPwd = oldPasswordText.text.toString().trim()
|
||||
val newPwd = newPasswordText.text.toString().trim()
|
||||
|
|
Loading…
Reference in New Issue