Merge branch 'develop' of ssh://github.com/vector-im/element-x-android-poc into develop

This commit is contained in:
ganfra 2022-12-02 16:09:59 +01:00
commit 3d25464bdc
3 changed files with 23 additions and 9 deletions

View file

@ -240,9 +240,9 @@ fun MessagesContent(
.fillMaxWidth() .fillMaxWidth()
.let { .let {
if (composerFullScreen) { if (composerFullScreen) {
it.weight(1f) it.weight(1f, fill = false)
} else { } else {
it.height(COMPOSER_HEIGHT) it.wrapContentHeight(Alignment.Bottom)
} }
}, },
) )

View file

@ -66,6 +66,7 @@ class RichTextComposerLayout @JvmOverloads constructor(
// There is no need to persist these values since they're always updated by the parent fragment // There is no need to persist these values since they're always updated by the parent fragment
private var isFullScreen = false private var isFullScreen = false
private var hasRelatedMessage = false private var hasRelatedMessage = false
private var composerMode: MessageComposerMode? = null
var isTextFormattingEnabled = true var isTextFormattingEnabled = true
set(value) { set(value) {
@ -118,9 +119,15 @@ class RichTextComposerLayout @JvmOverloads constructor(
private val dimensionConverter = DimensionConverter(resources) private val dimensionConverter = DimensionConverter(resources)
fun setFullScreen(isFullScreen: Boolean, manageKeyboard: Boolean) { fun setFullScreen(isFullScreen: Boolean, animated: Boolean, manageKeyboard: Boolean) {
if (!animated && views.composerLayout.layoutParams != null) {
views.composerLayout.updateLayoutParams<ViewGroup.LayoutParams> {
height =
if (isFullScreen) ViewGroup.LayoutParams.MATCH_PARENT else ViewGroup.LayoutParams.WRAP_CONTENT
}
}
editText.updateLayoutParams<ViewGroup.LayoutParams> { editText.updateLayoutParams<ViewGroup.LayoutParams> {
height = if (isFullScreen) 0 else ViewGroup.LayoutParams.WRAP_CONTENT height = if (isFullScreen) ViewGroup.LayoutParams.MATCH_PARENT else ViewGroup.LayoutParams.WRAP_CONTENT
} }
updateTextFieldBorder(isFullScreen) updateTextFieldBorder(isFullScreen)
@ -141,6 +148,7 @@ class RichTextComposerLayout @JvmOverloads constructor(
editText.hideKeyboard() editText.hideKeyboard()
} }
} }
this.isFullScreen = isFullScreen this.isFullScreen = isFullScreen
} }
@ -466,6 +474,9 @@ class RichTextComposerLayout @JvmOverloads constructor(
} }
override fun renderComposerMode(mode: MessageComposerMode) { override fun renderComposerMode(mode: MessageComposerMode) {
if (this.composerMode == mode) return
this.composerMode = mode
if (mode is MessageComposerMode.Special) { if (mode is MessageComposerMode.Special) {
views.composerModeGroup.isVisible = true views.composerModeGroup.isVisible = true
replaceFormattedContent(mode.defaultContent) replaceFormattedContent(mode.defaultContent)

View file

@ -71,7 +71,7 @@ fun TextComposer(
} }
} }
setFullScreen(fullscreen, true) setFullScreen(fullscreen, animated = false, manageKeyboard = true)
(this as MessageComposerView).apply { (this as MessageComposerView).apply {
setup(isInDarkMode, composerMode) setup(isInDarkMode, composerMode)
} }
@ -85,8 +85,9 @@ fun TextComposer(
// whenever the state changes // whenever the state changes
// Example of Compose -> View communication // Example of Compose -> View communication
val messageComposerView = (view as MessageComposerView) val messageComposerView = (view as MessageComposerView)
view.setFullScreen(fullscreen, false) view.setFullScreen(fullscreen, animated = false, manageKeyboard = false)
// TODO messageComposerView.renderComposerMode(composerMode) // TODO: un-comment once we update to a version of the lib > 0.8.0
// messageComposerView.renderComposerMode(composerMode)
messageComposerView.sendButton.isInvisible = !composerCanSendMessage messageComposerView.sendButton.isInvisible = !composerCanSendMessage
messageComposerView.setTextIfDifferent(composerText ?: "") messageComposerView.setTextIfDifferent(composerText ?: "")
} }
@ -122,7 +123,9 @@ private fun MessageComposerView.setup(isDarkMode: Boolean, composerMode: Message
editText.setHint(ElementR.string.room_message_placeholder) editText.setHint(ElementR.string.room_message_placeholder)
emojiButton?.isVisible = true emojiButton?.isVisible = true
sendButton.isVisible = true sendButton.isVisible = true
// TODO renderComposerMode(composerMode) editText.maxLines = MessageComposerView.MAX_LINES_WHEN_COLLAPSED
// TODO: un-comment once we update to a version of the lib > 0.8.0
// renderComposerMode(composerMode)
} }
@Preview @Preview