-
-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1689 from nextcloud/fix/1660/squished-dialogs
fix: Squished dialogs when opening keyboard programmatically
- Loading branch information
Showing
3 changed files
with
27 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
app/src/main/java/it/niedermann/owncloud/notes/shared/util/KeyboardUtils.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package it.niedermann.owncloud.notes.shared.util | ||
|
||
import android.content.Context | ||
import android.view.inputmethod.InputMethodManager | ||
import android.widget.EditText | ||
|
||
object KeyboardUtils { | ||
private const val SHOW_INPUT_DELAY_MILLIS = 100L | ||
|
||
@JvmStatic | ||
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) | ||
} | ||
} |