Update plugin ktlint to v12.1.0 (#2200)

* Update plugin ktlint to v12.1.0

* Run `./gradlew ktlintFormat` and fix some issues manually.

* Fix other issues reproted by Ktlint

* Limit false positives, KtLint removes unnecessary curly brace in String templates.

* Remove useless Unit

* Minor improvements over ktlint changes

* Restore `AlertDialogContent` behaviour

* Update screenshots

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Benoit Marty <benoit@matrix.org>
Co-authored-by: Jorge Martín <jorgem@element.io>
Co-authored-by: ElementBot <benoitm+elementbot@element.io>
This commit is contained in:
renovate[bot] 2024-01-10 16:22:24 +01:00 committed by GitHub
parent 675cc525cf
commit 7e9cda3aa9
442 changed files with 1091 additions and 1081 deletions

View file

@ -31,7 +31,7 @@ object ElementRichTextEditorStyle {
@Composable
fun composerStyle(
hasFocus: Boolean,
) : RichTextEditorStyle {
): RichTextEditorStyle {
val baseStyle = common()
return baseStyle.copy(
text = baseStyle.text.copy(

View file

@ -591,47 +591,52 @@ private fun ReplyToModeView(
@PreviewsDayNight
@Composable
internal fun TextComposerSimplePreview() = ElementPreview {
PreviewColumn(items = persistentListOf(
{
ATextComposer(
RichTextEditorState("", initialFocus = true),
voiceMessageState = VoiceMessageState.Idle,
composerMode = MessageComposerMode.Normal,
enableTextFormatting = true,
enableVoiceMessages = true,
currentUserId = UserId("@alice:localhost"),
)
}, {
ATextComposer(
RichTextEditorState("A message", initialFocus = true),
voiceMessageState = VoiceMessageState.Idle,
composerMode = MessageComposerMode.Normal,
enableTextFormatting = true,
enableVoiceMessages = true,
currentUserId = UserId("@alice:localhost")
PreviewColumn(
items = persistentListOf(
{
ATextComposer(
RichTextEditorState("", initialFocus = true),
voiceMessageState = VoiceMessageState.Idle,
composerMode = MessageComposerMode.Normal,
enableTextFormatting = true,
enableVoiceMessages = true,
currentUserId = UserId("@alice:localhost"),
)
},
{
ATextComposer(
RichTextEditorState("A message", initialFocus = true),
voiceMessageState = VoiceMessageState.Idle,
composerMode = MessageComposerMode.Normal,
enableTextFormatting = true,
enableVoiceMessages = true,
currentUserId = UserId("@alice:localhost")
)
},
{
ATextComposer(
RichTextEditorState(
"A message\nWith several lines\nTo preview larger textfields and long lines with overflow",
initialFocus = true
),
voiceMessageState = VoiceMessageState.Idle,
composerMode = MessageComposerMode.Normal,
enableTextFormatting = true,
enableVoiceMessages = true,
currentUserId = UserId("@alice:localhost")
)
},
{
ATextComposer(
RichTextEditorState("A message without focus", initialFocus = false),
voiceMessageState = VoiceMessageState.Idle,
composerMode = MessageComposerMode.Normal,
enableTextFormatting = true,
enableVoiceMessages = true,
currentUserId = UserId("@alice:localhost")
)
}
)
}, {
ATextComposer(
RichTextEditorState(
"A message\nWith several lines\nTo preview larger textfields and long lines with overflow",
initialFocus = true
),
voiceMessageState = VoiceMessageState.Idle,
composerMode = MessageComposerMode.Normal,
enableTextFormatting = true,
enableVoiceMessages = true,
currentUserId = UserId("@alice:localhost")
)
}, {
ATextComposer(
RichTextEditorState("A message without focus", initialFocus = false),
voiceMessageState = VoiceMessageState.Idle,
composerMode = MessageComposerMode.Normal,
enableTextFormatting = true,
enableVoiceMessages = true,
currentUserId = UserId("@alice:localhost")
)
})
)
}
@ -689,122 +694,129 @@ internal fun TextComposerEditPreview() = ElementPreview {
@PreviewsDayNight
@Composable
internal fun TextComposerReplyPreview() = ElementPreview {
PreviewColumn(items = persistentListOf({
ATextComposer(
RichTextEditorState(""),
voiceMessageState = VoiceMessageState.Idle,
composerMode = MessageComposerMode.Reply(
isThreaded = false,
senderName = "Alice",
eventId = EventId("$1234"),
attachmentThumbnailInfo = null,
defaultContent = "A message\n" +
"With several lines\n" +
"To preview larger textfields and long lines with overflow"
),
enableTextFormatting = true,
enableVoiceMessages = true,
currentUserId = UserId("@alice:localhost")
PreviewColumn(
items = persistentListOf(
{
ATextComposer(
RichTextEditorState(""),
voiceMessageState = VoiceMessageState.Idle,
composerMode = MessageComposerMode.Reply(
isThreaded = false,
senderName = "Alice",
eventId = EventId("$1234"),
attachmentThumbnailInfo = null,
defaultContent = "A message\n" +
"With several lines\n" +
"To preview larger textfields and long lines with overflow"
),
enableTextFormatting = true,
enableVoiceMessages = true,
currentUserId = UserId("@alice:localhost")
)
},
{
ATextComposer(
RichTextEditorState(""),
voiceMessageState = VoiceMessageState.Idle,
composerMode = MessageComposerMode.Reply(
isThreaded = true,
senderName = "Alice",
eventId = EventId("$1234"),
attachmentThumbnailInfo = null,
defaultContent = "A message\n" +
"With several lines\n" +
"To preview larger textfields and long lines with overflow"
),
enableTextFormatting = true,
enableVoiceMessages = true,
currentUserId = UserId("@alice:localhost")
)
},
{
ATextComposer(
RichTextEditorState("A message"),
voiceMessageState = VoiceMessageState.Idle,
composerMode = MessageComposerMode.Reply(
isThreaded = true,
senderName = "Alice",
eventId = EventId("$1234"),
attachmentThumbnailInfo = AttachmentThumbnailInfo(
thumbnailSource = MediaSource("https://domain.com/image.jpg"),
textContent = "image.jpg",
type = AttachmentThumbnailType.Image,
blurHash = A_BLUR_HASH,
),
defaultContent = "image.jpg"
),
enableTextFormatting = true,
enableVoiceMessages = true,
currentUserId = UserId("@alice:localhost")
)
},
{
ATextComposer(
RichTextEditorState("A message"),
voiceMessageState = VoiceMessageState.Idle,
composerMode = MessageComposerMode.Reply(
isThreaded = false,
senderName = "Alice",
eventId = EventId("$1234"),
attachmentThumbnailInfo = AttachmentThumbnailInfo(
thumbnailSource = MediaSource("https://domain.com/video.mp4"),
textContent = "video.mp4",
type = AttachmentThumbnailType.Video,
blurHash = A_BLUR_HASH,
),
defaultContent = "video.mp4"
),
enableTextFormatting = true,
enableVoiceMessages = true,
currentUserId = UserId("@alice:localhost")
)
},
{
ATextComposer(
RichTextEditorState("A message"),
voiceMessageState = VoiceMessageState.Idle,
composerMode = MessageComposerMode.Reply(
isThreaded = false,
senderName = "Alice",
eventId = EventId("$1234"),
attachmentThumbnailInfo = AttachmentThumbnailInfo(
thumbnailSource = null,
textContent = "logs.txt",
type = AttachmentThumbnailType.File,
blurHash = null,
),
defaultContent = "logs.txt"
),
enableTextFormatting = true,
enableVoiceMessages = true,
currentUserId = UserId("@alice:localhost")
)
},
{
ATextComposer(
RichTextEditorState("A message", initialFocus = true),
voiceMessageState = VoiceMessageState.Idle,
composerMode = MessageComposerMode.Reply(
isThreaded = false,
senderName = "Alice",
eventId = EventId("$1234"),
attachmentThumbnailInfo = AttachmentThumbnailInfo(
thumbnailSource = null,
textContent = null,
type = AttachmentThumbnailType.Location,
blurHash = null,
),
defaultContent = "Shared location"
),
enableTextFormatting = true,
enableVoiceMessages = true,
currentUserId = UserId("@alice:localhost")
)
}
)
},
{
ATextComposer(
RichTextEditorState(""),
voiceMessageState = VoiceMessageState.Idle,
composerMode = MessageComposerMode.Reply(
isThreaded = true,
senderName = "Alice",
eventId = EventId("$1234"),
attachmentThumbnailInfo = null,
defaultContent = "A message\n" +
"With several lines\n" +
"To preview larger textfields and long lines with overflow"
),
enableTextFormatting = true,
enableVoiceMessages = true,
currentUserId = UserId("@alice:localhost")
)
}, {
ATextComposer(
RichTextEditorState("A message"),
voiceMessageState = VoiceMessageState.Idle,
composerMode = MessageComposerMode.Reply(
isThreaded = true,
senderName = "Alice",
eventId = EventId("$1234"),
attachmentThumbnailInfo = AttachmentThumbnailInfo(
thumbnailSource = MediaSource("https://domain.com/image.jpg"),
textContent = "image.jpg",
type = AttachmentThumbnailType.Image,
blurHash = A_BLUR_HASH,
),
defaultContent = "image.jpg"
),
enableTextFormatting = true,
enableVoiceMessages = true,
currentUserId = UserId("@alice:localhost")
)
}, {
ATextComposer(
RichTextEditorState("A message"),
voiceMessageState = VoiceMessageState.Idle,
composerMode = MessageComposerMode.Reply(
isThreaded = false,
senderName = "Alice",
eventId = EventId("$1234"),
attachmentThumbnailInfo = AttachmentThumbnailInfo(
thumbnailSource = MediaSource("https://domain.com/video.mp4"),
textContent = "video.mp4",
type = AttachmentThumbnailType.Video,
blurHash = A_BLUR_HASH,
),
defaultContent = "video.mp4"
),
enableTextFormatting = true,
enableVoiceMessages = true,
currentUserId = UserId("@alice:localhost")
)
}, {
ATextComposer(
RichTextEditorState("A message"),
voiceMessageState = VoiceMessageState.Idle,
composerMode = MessageComposerMode.Reply(
isThreaded = false,
senderName = "Alice",
eventId = EventId("$1234"),
attachmentThumbnailInfo = AttachmentThumbnailInfo(
thumbnailSource = null,
textContent = "logs.txt",
type = AttachmentThumbnailType.File,
blurHash = null,
),
defaultContent = "logs.txt"
),
enableTextFormatting = true,
enableVoiceMessages = true,
currentUserId = UserId("@alice:localhost")
)
}, {
ATextComposer(
RichTextEditorState("A message", initialFocus = true),
voiceMessageState = VoiceMessageState.Idle,
composerMode = MessageComposerMode.Reply(
isThreaded = false,
senderName = "Alice",
eventId = EventId("$1234"),
attachmentThumbnailInfo = AttachmentThumbnailInfo(
thumbnailSource = null,
textContent = null,
type = AttachmentThumbnailType.Location,
blurHash = null,
),
defaultContent = "Shared location"
),
enableTextFormatting = true,
enableVoiceMessages = true,
currentUserId = UserId("@alice:localhost")
)
})
)
}

View file

@ -24,13 +24,13 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import io.element.android.compound.theme.ElementTheme
import io.element.android.libraries.designsystem.components.dialogs.ListDialog
import io.element.android.libraries.designsystem.components.list.TextFieldListItem
import io.element.android.libraries.designsystem.preview.ElementPreview
import io.element.android.libraries.designsystem.preview.PreviewsDayNight
import io.element.android.libraries.designsystem.theme.components.ListItem
import io.element.android.libraries.designsystem.theme.components.Text
import io.element.android.compound.theme.ElementTheme
import io.element.android.libraries.ui.strings.CommonStrings
import io.element.android.wysiwyg.view.models.LinkAction
@ -234,4 +234,3 @@ internal fun TextComposerLinkDialogEditLinkPreview() = ElementPreview {
onRemoveLinkRequest = {},
)
}

View file

@ -21,13 +21,13 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import io.element.android.compound.theme.ElementTheme
import io.element.android.libraries.designsystem.preview.ElementPreview
import io.element.android.libraries.designsystem.preview.PreviewsDayNight
import io.element.android.libraries.designsystem.theme.components.Icon
import io.element.android.libraries.designsystem.theme.components.IconButton
import io.element.android.libraries.designsystem.utils.CommonDrawables
import io.element.android.libraries.textcomposer.R
import io.element.android.compound.theme.ElementTheme
@Composable
internal fun ComposerOptionsButton(
@ -53,4 +53,3 @@ internal fun ComposerOptionsButton(
internal fun ComposerOptionsButtonPreview() = ElementPreview {
ComposerOptionsButton(onClick = {})
}

View file

@ -21,12 +21,12 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import io.element.android.compound.theme.ElementTheme
import io.element.android.libraries.designsystem.preview.ElementPreview
import io.element.android.libraries.designsystem.preview.PreviewsDayNight
import io.element.android.libraries.designsystem.theme.components.Icon
import io.element.android.libraries.designsystem.theme.components.IconButton
import io.element.android.libraries.designsystem.utils.CommonDrawables
import io.element.android.compound.theme.ElementTheme
import io.element.android.libraries.ui.strings.CommonStrings
@Composable
@ -53,4 +53,3 @@ internal fun DismissTextFormattingButton(
internal fun DismissTextFormattingButtonPreview() = ElementPreview {
DismissTextFormattingButton(onClick = {})
}

View file

@ -32,12 +32,12 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.unit.dp
import io.element.android.compound.theme.ElementTheme
import io.element.android.libraries.designsystem.preview.ElementPreview
import io.element.android.libraries.designsystem.preview.PreviewsDayNight
import io.element.android.libraries.designsystem.theme.components.Icon
import io.element.android.libraries.designsystem.theme.iconSuccessPrimaryBackground
import io.element.android.libraries.designsystem.utils.CommonDrawables
import io.element.android.compound.theme.ElementTheme
@Composable
internal fun FormattingOption(
@ -112,4 +112,3 @@ internal fun FormattingButtonPreview() = ElementPreview {
)
}
}

View file

@ -19,4 +19,3 @@ package io.element.android.libraries.textcomposer.components
internal enum class FormattingOptionState {
Default, Selected, Disabled
}

View file

@ -39,16 +39,17 @@ import androidx.compose.ui.layout.onSizeChanged
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.DpSize
import androidx.compose.ui.unit.dp
import io.element.android.compound.theme.ElementTheme
import io.element.android.libraries.designsystem.components.media.drawWaveform
import io.element.android.libraries.designsystem.preview.ElementPreview
import io.element.android.libraries.designsystem.preview.PreviewsDayNight
import io.element.android.compound.theme.ElementTheme
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.toPersistentList
import java.lang.Float.min
private const val DEFAULT_GRAPHICS_LAYER_ALPHA: Float = 0.99F
private val waveFormHeight = 26.dp
@Composable
fun LiveWaveformView(
levels: ImmutableList<Float>,
@ -67,7 +68,8 @@ fun LiveWaveformView(
}
}
Box(contentAlignment = Alignment.CenterEnd,
Box(
contentAlignment = Alignment.CenterEnd,
modifier = modifier
.fillMaxWidth()
.height(waveFormHeight)
@ -97,7 +99,6 @@ fun LiveWaveformView(
@Composable
internal fun LiveWaveformViewPreview() = ElementPreview {
Column {
LiveWaveformView(
levels = List(100) { it.toFloat() / 100 }.toPersistentList(),
modifier = Modifier.height(34.dp),

View file

@ -48,7 +48,6 @@ internal fun TextFormatting(
state: RichTextEditorState,
modifier: Modifier = Modifier,
) {
val scrollState = rememberScrollState()
val coroutineScope = rememberCoroutineScope()

View file

@ -36,6 +36,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import io.element.android.compound.theme.ElementTheme
import io.element.android.libraries.designsystem.components.media.WaveformPlaybackView
import io.element.android.libraries.designsystem.components.media.createFakeWaveform
import io.element.android.libraries.designsystem.preview.ElementPreview
@ -44,7 +45,6 @@ import io.element.android.libraries.designsystem.theme.components.Icon
import io.element.android.libraries.designsystem.theme.components.IconButton
import io.element.android.libraries.designsystem.theme.components.Text
import io.element.android.libraries.designsystem.utils.CommonDrawables
import io.element.android.compound.theme.ElementTheme
import io.element.android.libraries.ui.strings.CommonStrings
import io.element.android.libraries.ui.utils.time.formatShort
import kotlinx.collections.immutable.ImmutableList

View file

@ -14,7 +14,6 @@
* limitations under the License.
*/
package io.element.android.libraries.textcomposer.components
import androidx.compose.foundation.background
@ -28,14 +27,14 @@ import androidx.compose.ui.hapticfeedback.HapticFeedbackType
import androidx.compose.ui.platform.LocalHapticFeedback
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import io.element.android.compound.theme.ElementTheme
import io.element.android.compound.tokens.generated.CompoundIcons
import io.element.android.libraries.designsystem.preview.ElementPreview
import io.element.android.libraries.designsystem.preview.PreviewsDayNight
import io.element.android.libraries.designsystem.theme.components.Icon
import io.element.android.libraries.designsystem.theme.components.IconButton
import io.element.android.libraries.designsystem.utils.CommonDrawables
import io.element.android.libraries.textcomposer.model.VoiceMessageRecorderEvent
import io.element.android.compound.theme.ElementTheme
import io.element.android.compound.tokens.generated.CompoundIcons
import io.element.android.libraries.ui.strings.CommonStrings
@Composable

View file

@ -38,10 +38,10 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha
import androidx.compose.ui.unit.dp
import io.element.android.compound.theme.ElementTheme
import io.element.android.libraries.designsystem.preview.ElementPreview
import io.element.android.libraries.designsystem.preview.PreviewsDayNight
import io.element.android.libraries.designsystem.theme.components.Text
import io.element.android.compound.theme.ElementTheme
import io.element.android.libraries.ui.utils.time.formatShort
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.toPersistentList

View file

@ -26,7 +26,7 @@ import kotlinx.parcelize.Parcelize
@Immutable
sealed interface MessageComposerMode : Parcelable {
@Parcelize
data object Normal: MessageComposerMode
data object Normal : MessageComposerMode
sealed class Special(open val eventId: EventId?, open val defaultContent: String) :
MessageComposerMode

View file

@ -25,7 +25,7 @@ data class Suggestion(
val type: SuggestionType,
val text: String,
) {
constructor(suggestion: SuggestionPattern): this(
constructor(suggestion: SuggestionPattern) : this(
suggestion.start.toInt(),
suggestion.end.toInt(),
SuggestionType.fromPatternKey(suggestion.key),

View file

@ -17,10 +17,10 @@
package io.element.android.libraries.textcomposer.model
sealed interface VoiceMessagePlayerEvent {
data object Play: VoiceMessagePlayerEvent
data object Pause: VoiceMessagePlayerEvent
data object Play : VoiceMessagePlayerEvent
data object Pause : VoiceMessagePlayerEvent
data class Seek(
val position: Float
): VoiceMessagePlayerEvent
) : VoiceMessagePlayerEvent
}

View file

@ -17,7 +17,7 @@
package io.element.android.libraries.textcomposer.model
sealed interface VoiceMessageRecorderEvent {
data object Start: VoiceMessageRecorderEvent
data object Stop: VoiceMessageRecorderEvent
data object Cancel: VoiceMessageRecorderEvent
data object Start : VoiceMessageRecorderEvent
data object Stop : VoiceMessageRecorderEvent
data object Cancel : VoiceMessageRecorderEvent
}

View file

@ -22,7 +22,7 @@ import kotlin.time.Duration
@Immutable
sealed interface VoiceMessageState {
data object Idle: VoiceMessageState
data object Idle : VoiceMessageState
data class Preview(
val isSending: Boolean,
@ -31,10 +31,10 @@ sealed interface VoiceMessageState {
val playbackProgress: Float,
val time: Duration,
val waveform: ImmutableList<Float>,
): VoiceMessageState
) : VoiceMessageState
data class Recording(
val duration: Duration,
val levels: ImmutableList<Float>,
): VoiceMessageState
) : VoiceMessageState
}