Fix formatting
This commit is contained in:
parent
6b933b6506
commit
fbfeeae084
14 changed files with 31 additions and 52 deletions
|
|
@ -570,7 +570,7 @@ class MessagesFlowNode(
|
|||
)
|
||||
}
|
||||
is TimelineItemLocationContent -> {
|
||||
val mode = when(event.content.mode){
|
||||
val mode = when (event.content.mode) {
|
||||
is TimelineItemLocationContent.Mode.Live -> ShowLocationMode.Live(event.senderId)
|
||||
is TimelineItemLocationContent.Mode.Static -> ShowLocationMode.Static(
|
||||
location = event.content.mode.location,
|
||||
|
|
|
|||
|
|
@ -289,7 +289,7 @@ private fun MessageSummary(
|
|||
is TimelineItemRedactedContent,
|
||||
is TimelineItemUnknownContent -> content = { ContentForBody(textContent) }
|
||||
is TimelineItemLocationContent -> {
|
||||
val body = when(event.content.mode) {
|
||||
val body = when (event.content.mode) {
|
||||
is TimelineItemLocationContent.Mode.Live -> stringResource(CommonStrings.common_shared_live_location)
|
||||
is TimelineItemLocationContent.Mode.Static -> stringResource(CommonStrings.common_shared_location)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@ import io.element.android.compound.tokens.generated.CompoundIcons
|
|||
import io.element.android.features.location.api.StaticMapView
|
||||
import io.element.android.features.messages.impl.timeline.model.event.TimelineItemLocationContent
|
||||
import io.element.android.features.messages.impl.timeline.model.event.TimelineItemLocationContentProvider
|
||||
import io.element.android.features.messages.impl.timeline.model.event.ensureActiveLiveLocation
|
||||
import io.element.android.libraries.designsystem.preview.ElementPreview
|
||||
import io.element.android.libraries.designsystem.preview.PreviewsDayNight
|
||||
import io.element.android.libraries.designsystem.theme.components.CircularProgressIndicator
|
||||
|
|
@ -129,7 +128,6 @@ private fun LiveLocationOverlay(
|
|||
} else {
|
||||
stringResource(CommonStrings.common_live_location_ended)
|
||||
},
|
||||
|
||||
style = ElementTheme.typography.fontBodySmMedium,
|
||||
color = ElementTheme.colors.textPrimary,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ data class TimelineItemLocationContent(
|
|||
internal fun TimelineItemLocationContent.ensureActiveLiveLocation(
|
||||
currentTimeMillis: () -> Long = System::currentTimeMillis,
|
||||
): TimelineItemLocationContent {
|
||||
return when (val mode = mode) {
|
||||
return when (mode) {
|
||||
is TimelineItemLocationContent.Mode.Live -> {
|
||||
val isActive = rememberIsLiveLocationActive(mode, currentTimeMillis)
|
||||
copy(mode = mode.copy(isActive = isActive))
|
||||
|
|
@ -102,7 +102,6 @@ private fun rememberIsLiveLocationActive(
|
|||
mode: TimelineItemLocationContent.Mode.Live,
|
||||
currentTimeMillis: () -> Long,
|
||||
): Boolean {
|
||||
|
||||
fun TimelineItemLocationContent.Mode.Live.isActive(): Boolean {
|
||||
return isActive && endTimestamp > currentTimeMillis()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ class DefaultMessageSummaryFormatter(
|
|||
is TimelineItemTextBasedContent -> content.plainText
|
||||
is TimelineItemProfileChangeContent -> content.body
|
||||
is TimelineItemStateContent -> content.body
|
||||
is TimelineItemLocationContent -> when(content.mode) {
|
||||
is TimelineItemLocationContent -> when (content.mode) {
|
||||
is TimelineItemLocationContent.Mode.Live -> context.getString(CommonStrings.common_shared_live_location)
|
||||
is TimelineItemLocationContent.Mode.Static -> context.getString(CommonStrings.common_shared_location)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,9 +78,7 @@ import org.robolectric.RobolectricTestRunner
|
|||
import kotlin.time.Duration
|
||||
import kotlin.time.Duration.Companion.minutes
|
||||
|
||||
@Suppress("LargeClass")
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
class TimelineItemContentMessageFactoryTest {
|
||||
@Suppress("LargeClass") @RunWith(RobolectricTestRunner::class) class TimelineItemContentMessageFactoryTest {
|
||||
@Test
|
||||
fun `test create OtherMessageType`() = runTest {
|
||||
val sut = createTimelineItemContentMessageFactory()
|
||||
|
|
@ -164,16 +162,11 @@ class TimelineItemContentMessageFactoryTest {
|
|||
senderProfile = aProfileDetails(),
|
||||
eventId = AN_EVENT_ID,
|
||||
) as TimelineItemTextContent
|
||||
val expected = TimelineItemTextContent(
|
||||
body = "https://www.example.org",
|
||||
htmlDocument = null,
|
||||
isEdited = false,
|
||||
formattedBody = buildSpannedString {
|
||||
inSpans(URLSpan("https://www.example.org")) {
|
||||
append("https://www.example.org")
|
||||
}
|
||||
val expected = TimelineItemTextContent(body = "https://www.example.org", htmlDocument = null, isEdited = false, formattedBody = buildSpannedString {
|
||||
inSpans(URLSpan("https://www.example.org")) {
|
||||
append("https://www.example.org")
|
||||
}
|
||||
)
|
||||
})
|
||||
assertThat(result.body).isEqualTo(expected.body)
|
||||
assertThat(result.htmlDocument).isEqualTo(expected.htmlDocument)
|
||||
assertThat(result.plainText).isEqualTo(expected.plainText)
|
||||
|
|
@ -198,9 +191,7 @@ class TimelineItemContentMessageFactoryTest {
|
|||
append("and manually added link")
|
||||
}
|
||||
}.toSpannable()
|
||||
val sut = createTimelineItemContentMessageFactory(
|
||||
domConverterTransform = { expected }
|
||||
)
|
||||
val sut = createTimelineItemContentMessageFactory(domConverterTransform = { expected })
|
||||
val result = sut.create(
|
||||
content = createMessageContent(
|
||||
type = TextMessageType(
|
||||
|
|
@ -217,9 +208,7 @@ class TimelineItemContentMessageFactoryTest {
|
|||
|
||||
@Test
|
||||
fun `test create TextMessageType with unknown formatted body does nothing`() = runTest {
|
||||
val sut = createTimelineItemContentMessageFactory(
|
||||
htmlConverterTransform = { it }
|
||||
)
|
||||
val sut = createTimelineItemContentMessageFactory(htmlConverterTransform = { it })
|
||||
val result = sut.create(
|
||||
content = createMessageContent(
|
||||
type = TextMessageType(
|
||||
|
|
@ -354,10 +343,10 @@ class TimelineItemContentMessageFactoryTest {
|
|||
formattedCaption = null,
|
||||
source = MediaSource("url"),
|
||||
info = AudioInfo(
|
||||
duration = 1.minutes,
|
||||
size = 123L,
|
||||
mimetype = MimeTypes.Mp3,
|
||||
)
|
||||
duration = 1.minutes,
|
||||
size = 123L,
|
||||
mimetype = MimeTypes.Mp3,
|
||||
)
|
||||
),
|
||||
isEdited = true,
|
||||
),
|
||||
|
|
@ -595,16 +584,16 @@ class TimelineItemContentMessageFactoryTest {
|
|||
formattedCaption = null,
|
||||
source = MediaSource("url"),
|
||||
info = FileInfo(
|
||||
mimetype = MimeTypes.Pdf,
|
||||
size = 123L,
|
||||
thumbnailInfo = ThumbnailInfo(
|
||||
height = 10L,
|
||||
width = 5L,
|
||||
mimetype = MimeTypes.Jpeg,
|
||||
size = 111L,
|
||||
),
|
||||
thumbnailSource = MediaSource("url_thumbnail"),
|
||||
)
|
||||
mimetype = MimeTypes.Pdf,
|
||||
size = 123L,
|
||||
thumbnailInfo = ThumbnailInfo(
|
||||
height = 10L,
|
||||
width = 5L,
|
||||
mimetype = MimeTypes.Jpeg,
|
||||
size = 111L,
|
||||
),
|
||||
thumbnailSource = MediaSource("url_thumbnail"),
|
||||
)
|
||||
),
|
||||
isEdited = true,
|
||||
),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue