From d9fbc4a0112a84923e6187ac1ba80935de9169cc Mon Sep 17 00:00:00 2001 From: Claire G Date: Thu, 11 Aug 2022 15:59:26 +0200 Subject: [PATCH] add autoCapitalize in FormEditTextItem --- .../im/vector/app/features/form/FormEditTextItem.kt | 13 +++++++++++-- .../createroom/CreateRoomController.kt | 2 +- .../roomprofile/settings/RoomSettingsController.kt | 2 +- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/form/FormEditTextItem.kt b/vector/src/main/java/im/vector/app/features/form/FormEditTextItem.kt index 9f32980874..fd7c4424ad 100644 --- a/vector/src/main/java/im/vector/app/features/form/FormEditTextItem.kt +++ b/vector/src/main/java/im/vector/app/features/form/FormEditTextItem.kt @@ -58,6 +58,9 @@ abstract class FormEditTextItem : VectorEpoxyModel(R.la @EpoxyAttribute var singleLine: Boolean = true + @EpoxyAttribute + var autoCapitalize: Boolean = false + @EpoxyAttribute var imeOptions: Int? = null @@ -133,8 +136,14 @@ abstract class FormEditTextItem : VectorEpoxyModel(R.la private fun configureInputType(holder: Holder) { val newInputType = inputType ?: when (singleLine) { - true -> InputType.TYPE_CLASS_TEXT - false -> InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_FLAG_MULTI_LINE + true -> { + if (autoCapitalize) InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_FLAG_CAP_SENTENCES + else InputType.TYPE_CLASS_TEXT + } + false -> { + if (autoCapitalize) InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_FLAG_MULTI_LINE or InputType.TYPE_TEXT_FLAG_CAP_SENTENCES + else InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_FLAG_MULTI_LINE + } } // This is a must in order to avoid extreme lag in some devices, on fast typing diff --git a/vector/src/main/java/im/vector/app/features/roomdirectory/createroom/CreateRoomController.kt b/vector/src/main/java/im/vector/app/features/roomdirectory/createroom/CreateRoomController.kt index a5c3106f26..4d2b0c5e47 100644 --- a/vector/src/main/java/im/vector/app/features/roomdirectory/createroom/CreateRoomController.kt +++ b/vector/src/main/java/im/vector/app/features/roomdirectory/createroom/CreateRoomController.kt @@ -68,7 +68,7 @@ class CreateRoomController @Inject constructor( enabled(enableFormElement) value(viewState.roomName) hint(host.stringProvider.getString(R.string.create_room_name_hint)) - inputType(InputType.TYPE_TEXT_FLAG_CAP_SENTENCES) + autoCapitalize(true) onTextChange { text -> host.listener?.onNameChange(text) diff --git a/vector/src/main/java/im/vector/app/features/roomprofile/settings/RoomSettingsController.kt b/vector/src/main/java/im/vector/app/features/roomprofile/settings/RoomSettingsController.kt index 100670b3b0..7e07bd8ad5 100644 --- a/vector/src/main/java/im/vector/app/features/roomprofile/settings/RoomSettingsController.kt +++ b/vector/src/main/java/im/vector/app/features/roomprofile/settings/RoomSettingsController.kt @@ -92,7 +92,7 @@ class RoomSettingsController @Inject constructor( enabled(data.actionPermissions.canChangeName) value(data.newName ?: roomSummary.displayName) hint(host.stringProvider.getString(R.string.room_settings_name_hint)) - inputType(InputType.TYPE_TEXT_FLAG_CAP_SENTENCES) + autoCapitalize(true) onTextChange { text -> host.callback?.onNameChanged(text)