Restore Onuray's code: do not allow to send blank text

This commit is contained in:
Benoit Marty 2021-06-10 14:30:53 +02:00 committed by Benoit Marty
parent 5097c45568
commit e91b09ca44
3 changed files with 8 additions and 8 deletions

View file

@ -1189,7 +1189,7 @@ class RoomDetailFragment @Inject constructor(
return sendUri(contentUri)
}
override fun onTextEmptyStateChanged(isEmpty: Boolean) {
override fun onTextBlankStateChanged(isBlank: Boolean) {
// No op
}
}

View file

@ -37,11 +37,11 @@ class ComposerEditText @JvmOverloads constructor(context: Context, attrs: Attrib
interface Callback {
fun onRichContentSelected(contentUri: Uri): Boolean
fun onTextEmptyStateChanged(isEmpty: Boolean)
fun onTextBlankStateChanged(isBlank: Boolean)
}
var callback: Callback? = null
private var isEmptyText = true
private var isBlankText = true
override fun onCreateInputConnection(editorInfo: EditorInfo): InputConnection? {
val ic = super.onCreateInputConnection(editorInfo) ?: return null
@ -96,9 +96,9 @@ class ComposerEditText @JvmOverloads constructor(context: Context, attrs: Attrib
spanToRemove = null
}
// Report blank status of EditText to be able to arrange other elements of the composer
if (s.isEmpty() != isEmptyText) {
isEmptyText = !isEmptyText
callback?.onTextEmptyStateChanged(isEmptyText)
if (s.isBlank() != isBlankText) {
isBlankText = !isBlankText
callback?.onTextBlankStateChanged(isBlankText)
}
}
}

View file

@ -70,8 +70,8 @@ class TextComposerView @JvmOverloads constructor(
return callback?.onRichContentSelected(contentUri) ?: false
}
override fun onTextEmptyStateChanged(isEmpty: Boolean) {
views.sendButton.isVisible = currentConstraintSetId == R.layout.composer_layout_constraint_set_expanded || !isEmpty
override fun onTextBlankStateChanged(isBlank: Boolean) {
views.sendButton.isVisible = currentConstraintSetId == R.layout.composer_layout_constraint_set_expanded || !isBlank
}
}
views.composerRelatedMessageCloseButton.setOnClickListener {