-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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 #5843 from grzesiek2010/COLLECT-5828
Fixed showing keyboard
- Loading branch information
Showing
6 changed files
with
26 additions
and
56 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
40 changes: 0 additions & 40 deletions
40
collect_app/src/main/java/org/odk/collect/android/utilities/SoftKeyboardController.java
This file was deleted.
Oops, something went wrong.
25 changes: 25 additions & 0 deletions
25
collect_app/src/main/java/org/odk/collect/android/utilities/SoftKeyboardController.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,25 @@ | ||
package org.odk.collect.android.utilities | ||
|
||
import android.content.Context | ||
import android.os.Handler | ||
import android.os.Looper | ||
import android.view.View | ||
import android.view.inputmethod.InputMethodManager | ||
|
||
object SoftKeyboardController { | ||
fun showSoftKeyboard(view: View) { | ||
// Subtle delay in displaying the keyboard is necessary for the keyboard to be displayed at all, | ||
// for example, when returning from the hierarchy view. | ||
Handler(Looper.getMainLooper()).postDelayed({ | ||
if (view.requestFocus()) { | ||
val inputMethodManager = view.context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager | ||
inputMethodManager.showSoftInput(view, 0) | ||
} | ||
}, 100) | ||
} | ||
|
||
fun hideSoftKeyboard(view: View) { | ||
val inputMethodManager = view.context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager | ||
inputMethodManager.hideSoftInputFromWindow(view.windowToken, 0) | ||
} | ||
} |
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