Fix detekt issues.
This commit is contained in:
parent
c9ac509424
commit
d8665b20c4
5 changed files with 66 additions and 65 deletions
|
|
@ -3,4 +3,4 @@ package io.element.android.x.matrix.core
|
||||||
import java.io.Serializable
|
import java.io.Serializable
|
||||||
|
|
||||||
@JvmInline
|
@JvmInline
|
||||||
value class EventId(val value: String) : Serializable
|
value class EventId(val value: String) : Serializable
|
||||||
|
|
|
||||||
|
|
@ -7,4 +7,4 @@ internal class MediaKeyer : Keyer<MediaResolver.Meta> {
|
||||||
override fun key(data: MediaResolver.Meta, options: Options): String? {
|
override fun key(data: MediaResolver.Meta, options: Options): String? {
|
||||||
return "${data.source.url()}_${data.kind}"
|
return "${data.source.url()}_${data.kind}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,4 +12,4 @@ fun logError(throwable: Throwable) {
|
||||||
Timber.e("Error", throwable)
|
Timber.e("Error", throwable)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -485,7 +485,7 @@ class RichTextComposerLayout @JvmOverloads constructor(
|
||||||
} else {
|
} else {
|
||||||
views.composerModeGroup.isGone = true
|
views.composerModeGroup.isGone = true
|
||||||
(mode as? MessageComposerMode.Normal)?.content?.let { text ->
|
(mode as? MessageComposerMode.Normal)?.content?.let { text ->
|
||||||
// TODO: un-comment once we update to a version of the lib > 0.8.0
|
// TODO un-comment once we update to a version of the lib > 0.8.0
|
||||||
/*
|
/*
|
||||||
if (isTextFormattingEnabled) {
|
if (isTextFormattingEnabled) {
|
||||||
replaceFormattedContent(text)
|
replaceFormattedContent(text)
|
||||||
|
|
|
||||||
|
|
@ -22,80 +22,81 @@ import io.element.android.x.element.resources.R as ElementR
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun TextComposer(
|
fun TextComposer(
|
||||||
onSendMessage: (String) -> Unit,
|
|
||||||
modifier: Modifier = Modifier,
|
|
||||||
fullscreen: Boolean,
|
fullscreen: Boolean,
|
||||||
onFullscreenToggle: () -> Unit,
|
|
||||||
composerMode: MessageComposerMode,
|
|
||||||
onCloseSpecialMode: () -> Unit,
|
|
||||||
onComposerTextChange: (CharSequence) -> Unit,
|
|
||||||
composerCanSendMessage: Boolean,
|
|
||||||
composerText: String?,
|
composerText: String?,
|
||||||
|
composerMode: MessageComposerMode,
|
||||||
|
composerCanSendMessage: Boolean,
|
||||||
|
modifier: Modifier = Modifier,
|
||||||
|
onSendMessage: (String) -> Unit = {},
|
||||||
|
onFullscreenToggle: () -> Unit = {},
|
||||||
|
onCloseSpecialMode: () -> Unit = {},
|
||||||
|
onComposerTextChange: (CharSequence) -> Unit = {},
|
||||||
) {
|
) {
|
||||||
if (LocalInspectionMode.current) {
|
if (LocalInspectionMode.current) {
|
||||||
FakeComposer(modifier)
|
FakeComposer(modifier)
|
||||||
return
|
} else {
|
||||||
}
|
val isInDarkMode = isSystemInDarkTheme()
|
||||||
|
AndroidView(
|
||||||
|
modifier = modifier,
|
||||||
|
factory = { context ->
|
||||||
|
RichTextComposerLayout(context).apply {
|
||||||
|
// Sets up listeners for View -> Compose communication
|
||||||
|
this.callback = object : Callback {
|
||||||
|
override fun onRichContentSelected(contentUri: Uri): Boolean {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
val isInDarkMode = isSystemInDarkTheme()
|
override fun onTextChanged(text: CharSequence) {
|
||||||
AndroidView(
|
onComposerTextChange(text)
|
||||||
modifier = modifier,
|
}
|
||||||
factory = { context ->
|
|
||||||
RichTextComposerLayout(context).apply {
|
override fun onCloseRelatedMessage() {
|
||||||
// Sets up listeners for View -> Compose communication
|
onCloseSpecialMode()
|
||||||
this.callback = object : Callback {
|
}
|
||||||
override fun onRichContentSelected(contentUri: Uri): Boolean {
|
|
||||||
return false
|
override fun onSendMessage(text: CharSequence) {
|
||||||
|
// text contains markdown.
|
||||||
|
onSendMessage(text.toString())
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onAddAttachment() {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onExpandOrCompactChange() {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onFullScreenModeChanged() {
|
||||||
|
onFullscreenToggle()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
setFullScreen(fullscreen, animated = false, manageKeyboard = true)
|
||||||
override fun onTextChanged(text: CharSequence) {
|
(this as MessageComposerView).apply {
|
||||||
onComposerTextChange(text)
|
setup(isInDarkMode, composerMode)
|
||||||
}
|
|
||||||
|
|
||||||
override fun onCloseRelatedMessage() {
|
|
||||||
onCloseSpecialMode()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onSendMessage(text: CharSequence) {
|
|
||||||
// text contains markdown.
|
|
||||||
onSendMessage(text.toString())
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onAddAttachment() {
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onExpandOrCompactChange() {
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onFullScreenModeChanged() {
|
|
||||||
onFullscreenToggle()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setFullScreen(fullscreen, animated = false, manageKeyboard = true)
|
},
|
||||||
(this as MessageComposerView).apply {
|
update = { view ->
|
||||||
setup(isInDarkMode, composerMode)
|
// View's been inflated or state read in this block has been updated
|
||||||
}
|
// Add logic here if necessary
|
||||||
|
|
||||||
|
// As selectedItem is read here, AndroidView will recompose
|
||||||
|
// whenever the state changes
|
||||||
|
// Example of Compose -> View communication
|
||||||
|
val messageComposerView = (view as MessageComposerView)
|
||||||
|
view.setFullScreen(fullscreen, animated = false, manageKeyboard = false)
|
||||||
|
messageComposerView.renderComposerMode(composerMode)
|
||||||
|
messageComposerView.sendButton.isInvisible = !composerCanSendMessage
|
||||||
|
messageComposerView.setTextIfDifferent(composerText ?: "")
|
||||||
|
messageComposerView.editText.requestFocus()
|
||||||
}
|
}
|
||||||
},
|
)
|
||||||
update = { view ->
|
}
|
||||||
// View's been inflated or state read in this block has been updated
|
|
||||||
// Add logic here if necessary
|
|
||||||
|
|
||||||
// As selectedItem is read here, AndroidView will recompose
|
|
||||||
// whenever the state changes
|
|
||||||
// Example of Compose -> View communication
|
|
||||||
val messageComposerView = (view as MessageComposerView)
|
|
||||||
view.setFullScreen(fullscreen, animated = false, manageKeyboard = false)
|
|
||||||
messageComposerView.renderComposerMode(composerMode)
|
|
||||||
messageComposerView.sendButton.isInvisible = !composerCanSendMessage
|
|
||||||
messageComposerView.setTextIfDifferent(composerText ?: "")
|
|
||||||
messageComposerView.editText.requestFocus()
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun FakeComposer(modifier: Modifier) {
|
private fun FakeComposer(
|
||||||
|
modifier: Modifier = Modifier,
|
||||||
|
) {
|
||||||
// AndroidView is not Available in this mode, just render a Text
|
// AndroidView is not Available in this mode, just render a Text
|
||||||
Box(
|
Box(
|
||||||
modifier = modifier
|
modifier = modifier
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue