diff --git a/app/src/main/java/org/linphone/utils/DataBindingUtils.kt b/app/src/main/java/org/linphone/utils/DataBindingUtils.kt
index 3be9be1be..62e2cfaf4 100644
--- a/app/src/main/java/org/linphone/utils/DataBindingUtils.kt
+++ b/app/src/main/java/org/linphone/utils/DataBindingUtils.kt
@@ -19,6 +19,7 @@
*/
package org.linphone.utils
+import android.app.Activity
import android.content.Context
import android.graphics.Bitmap
import android.graphics.drawable.Drawable
@@ -29,6 +30,8 @@ import android.util.Patterns
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
+import android.view.inputmethod.EditorInfo
+import android.view.inputmethod.InputMethodManager
import android.widget.*
import android.widget.SeekBar.OnSeekBarChangeListener
import androidx.constraintlayout.widget.ConstraintLayout
@@ -186,6 +189,23 @@ fun editTextSetting(view: EditText, lambda: () -> Unit) {
})
}
+@BindingAdapter("onSettingImeDone")
+fun editTextImeDone(view: EditText, lambda: () -> Unit) {
+ view.setOnEditorActionListener { _, actionId, _ ->
+ if (actionId == EditorInfo.IME_ACTION_DONE) {
+ lambda()
+
+ view.clearFocus()
+
+ val imm = view.context.getSystemService(Activity.INPUT_METHOD_SERVICE) as InputMethodManager
+ imm.hideSoftInputFromWindow(view.windowToken, 0)
+
+ return@setOnEditorActionListener true
+ }
+ false
+ }
+}
+
@BindingAdapter("onFocusChangeVisibilityOf")
fun setEditTextOnFocusChangeVisibilityOf(editText: EditText, view: View) {
editText.setOnFocusChangeListener { _, hasFocus ->
diff --git a/app/src/main/java/org/linphone/views/SettingTextInputEditText.kt b/app/src/main/java/org/linphone/views/SettingTextInputEditText.kt
new file mode 100644
index 000000000..6340f2896
--- /dev/null
+++ b/app/src/main/java/org/linphone/views/SettingTextInputEditText.kt
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2010-2021 Belledonne Communications SARL.
+ *
+ * This file is part of linphone-android
+ * (see https://www.linphone.org).
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+package org.linphone.views
+
+import android.app.Activity
+import android.content.Context
+import android.util.AttributeSet
+import android.view.inputmethod.InputMethodManager
+import com.google.android.material.textfield.TextInputEditText
+import org.linphone.activities.main.settings.SettingListener
+
+class SettingTextInputEditText : TextInputEditText {
+ constructor(context: Context) : super(context)
+
+ constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
+
+ constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(
+ context,
+ attrs,
+ defStyleAttr
+ )
+
+ fun fakeImeDone(listener: SettingListener) {
+ listener.onTextValueChanged(text.toString())
+
+ // Send IME action DONE to trigger onSettingImeDone binding adapter, but that doesn't work...
+ // val inputConnection = BaseInputConnection(this, true)
+ // inputConnection.performEditorAction(EditorInfo.IME_ACTION_DONE)
+
+ // Will make check icon to disappear thanks to onFocusChangeVisibilityOf binding adapter
+ clearFocus()
+
+ // Hide keyboard
+ val imm = context.getSystemService(Activity.INPUT_METHOD_SERVICE) as InputMethodManager
+ imm.hideSoftInputFromWindow(windowToken, 0)
+ }
+}
diff --git a/app/src/main/res/layout/settings_widget_text.xml b/app/src/main/res/layout/settings_widget_text.xml
index ab33322a4..6a483763a 100644
--- a/app/src/main/res/layout/settings_widget_text.xml
+++ b/app/src/main/res/layout/settings_widget_text.xml
@@ -31,7 +31,7 @@
-