mirror of
https://github.com/nextcloud/android.git
synced 2024-11-27 09:39:25 +03:00
Merge pull request #12014 from nextcloud/fix/softkeyboard
Fix softKeyboard not appearing
This commit is contained in:
commit
303950d9a4
8 changed files with 17 additions and 23 deletions
|
@ -138,7 +138,7 @@ public class ChooseRichDocumentsTemplateDialogFragment extends DialogFragment im
|
|||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
keyboardUtils.showKeyboardForEditText(binding.filename);
|
||||
keyboardUtils.showKeyboardForEditText(requireDialog().getWindow(), binding.filename);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
|
|
@ -119,7 +119,7 @@ class ChooseTemplateDialogFragment : DialogFragment(), View.OnClickListener, Tem
|
|||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
keyboardUtils.showKeyboardForEditText(binding.filename)
|
||||
keyboardUtils.showKeyboardForEditText(dialog?.window, binding.filename)
|
||||
}
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
|
|
|
@ -116,7 +116,7 @@ public class CreateFolderDialogFragment
|
|||
super.onResume();
|
||||
|
||||
bindButton();
|
||||
keyboardUtils.showKeyboardForEditText(binding.userInput);
|
||||
keyboardUtils.showKeyboardForEditText(requireDialog().getWindow(), binding.userInput);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
|
|
@ -90,7 +90,7 @@ public class NoteDialogFragment extends DialogFragment implements DialogInterfac
|
|||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
keyboardUtils.showKeyboardForEditText(binding.noteText);
|
||||
keyboardUtils.showKeyboardForEditText(requireDialog().getWindow(), binding.noteText);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
|
|
@ -103,7 +103,7 @@ public class RenameFileDialogFragment
|
|||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
keyboardUtils.showKeyboardForEditText(binding.userInput);
|
||||
keyboardUtils.showKeyboardForEditText(requireDialog().getWindow(), binding.userInput);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
|
|
@ -83,7 +83,7 @@ public class RenamePublicShareDialogFragment
|
|||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
keyboardUtils.showKeyboardForEditText(binding.userInput);
|
||||
keyboardUtils.showKeyboardForEditText(requireDialog().getWindow(), binding.userInput);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
|
|
@ -99,7 +99,7 @@ public class SharePasswordDialogFragment extends DialogFragment implements Dialo
|
|||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
keyboardUtils.showKeyboardForEditText(binding.sharePassword);
|
||||
keyboardUtils.showKeyboardForEditText(requireDialog().getWindow(), binding.sharePassword);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author ZetaTom
|
||||
* @author Álvaro Brey
|
||||
* Copyright (C) 2023 ZetaTom
|
||||
* Copyright (C) 2022 Álvaro Brey
|
||||
* Copyright (C) 2022 Nextcloud GmbH
|
||||
*
|
||||
|
@ -22,26 +24,18 @@
|
|||
|
||||
package com.owncloud.android.utils
|
||||
|
||||
import android.content.Context
|
||||
import android.view.inputmethod.InputMethodManager
|
||||
import android.view.Window
|
||||
import android.widget.EditText
|
||||
import androidx.core.view.WindowCompat
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
import javax.inject.Inject
|
||||
|
||||
class KeyboardUtils @Inject constructor() {
|
||||
|
||||
fun showKeyboardForEditText(editText: EditText) {
|
||||
editText.requestFocus()
|
||||
// needs 100ms delay to account for focus animations
|
||||
editText.postDelayed({
|
||||
val context = editText.context
|
||||
if (context != null) {
|
||||
val inputMethodManager = context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
|
||||
inputMethodManager.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT)
|
||||
}
|
||||
}, SHOW_INPUT_DELAY_MILLIS)
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val SHOW_INPUT_DELAY_MILLIS = 100L
|
||||
fun showKeyboardForEditText(window: Window?, editText: EditText) {
|
||||
if (window != null) {
|
||||
editText.requestFocus()
|
||||
WindowCompat.getInsetsController(window, editText).show(WindowInsetsCompat.Type.ime())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue