Skip to content
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.

Fix keyboard issue when editing contact journal entries (EXPOSUREAPP-5869) #2674

Merged
merged 9 commits into from
Mar 25, 2021
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ class ContactDiaryEditPersonsFragment : Fragment(R.layout.contact_diary_edit_per
}

viewModel.navigationEvent.observe2(this) {

when (it) {
ShowDeletionConfirmationDialog -> DialogHelper.showDialog(deleteAllPersonsConfirmationDialog)
is ShowPersonDetailFragment -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.content.Context
import android.os.Build
import android.view.View
import android.view.inputmethod.InputMethodManager
import android.widget.EditText
import androidx.core.view.AccessibilityDelegateCompat
import androidx.core.view.ViewCompat
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat
Expand Down Expand Up @@ -43,11 +44,11 @@ fun LocalDate.toFormattedDayForAccessibility(locale: Locale): String {
DateTimeFormat.longDate().withLocale(locale).print(this)
}

fun View.focusAndShowKeyboard() {
fun EditText.focusAndShowKeyboard() {
/**
* This is to be called when the window already has focus.
*/
fun View.showTheKeyboardNow() {
fun EditText.showTheKeyboardNow() {
if (isFocused) {
post {
val imm = context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
Expand All @@ -57,6 +58,7 @@ fun View.focusAndShowKeyboard() {
}

requestFocus()
this.setSelection(this.text.length)
if (hasWindowFocus()) {
showTheKeyboardNow()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
android:layout_height="match_parent"
android:background="@color/colorBackground"
android:fillViewport="true"
android:fitsSystemWindows="true"
android:transitionName="contact_diary_shared_content">

<androidx.constraintlayout.widget.ConstraintLayout
Expand Down Expand Up @@ -67,8 +68,11 @@
android:layout_height="wrap_content"
android:imeOptions="actionNext"
android:inputType="textCapWords"
android:focusable="true"
android:maxLength="250" />

<requestFocus/>

</com.google.android.material.textfield.TextInputLayout>

<com.google.android.material.textfield.TextInputLayout
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
android:layout_height="match_parent"
android:fillViewport="true"
android:background="@color/colorBackground"
android:fitsSystemWindows="true"
android:transitionName="contact_diary_shared_content">

<androidx.constraintlayout.widget.ConstraintLayout
Expand Down Expand Up @@ -66,8 +67,11 @@
android:layout_height="wrap_content"
android:imeOptions="actionNext"
android:inputType="textCapWords"
android:focusable="true"
android:maxLength="250" />

<requestFocus/>

</com.google.android.material.textfield.TextInputLayout>

<com.google.android.material.textfield.TextInputLayout
Expand Down