Fix formatting

This commit is contained in:
ganfra 2026-04-16 16:18:53 +02:00
parent 6b933b6506
commit fbfeeae084
14 changed files with 31 additions and 52 deletions

View file

@ -28,7 +28,6 @@ import io.element.android.compound.tokens.generated.CompoundIcons
import io.element.android.features.location.api.R
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
import io.element.android.libraries.designsystem.theme.components.Icon
import io.element.android.libraries.designsystem.theme.components.Text
import io.element.android.libraries.ui.strings.CommonStrings

View file

@ -93,7 +93,7 @@ fun LocationShareRow(
Text(
text = if (item.isLive) stringResource(CommonStrings.screen_room_live_location_banner) else item.formattedTimestamp,
style = ElementTheme.typography.fontBodySmRegular,
color = if(item.isLive) ElementTheme.colors.textPrimary else ElementTheme.colors.textSecondary,
color = if (item.isLive) ElementTheme.colors.textPrimary else ElementTheme.colors.textSecondary,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
)

View file

@ -43,7 +43,7 @@ import io.element.android.libraries.matrix.api.room.joinedRoomMembers
import io.element.android.libraries.ui.strings.CommonStrings
import io.element.android.services.toolbox.api.strings.StringProvider
import kotlinx.collections.immutable.persistentListOf
import kotlinx.collections.immutable.toPersistentList
import kotlinx.collections.immutable.toImmutableList
import kotlinx.coroutines.flow.combine
@AssistedInject
@ -161,7 +161,7 @@ class ShowLocationPresenter(
isLive = true,
assetType = lastLocation.assetType,
)
}.toPersistentList()
}.toImmutableList()
}.collect { value = it }
}.value
}

View file

@ -434,7 +434,7 @@ class ShowLocationPresenterTest {
senderName = senderName,
senderId = senderId,
senderAvatarUrl = avatarUrl,
timestamp = 1234567890L,
timestamp = 0L,
assetType = AssetType.SENDER,
)
@ -468,7 +468,7 @@ class ShowLocationPresenterTest {
private fun aLiveLocationShare(
userId: UserId,
geoUri: String = "geo:48.8584,2.2945",
timestamp: Long = 1234567890L,
timestamp: Long = 0L,
endTimestamp: Long = Long.MAX_VALUE,
assetType: AssetType = AssetType.SENDER,
): LiveLocationShare {

View file

@ -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,

View file

@ -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)
}

View file

@ -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,
)

View file

@ -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()
}

View file

@ -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)
}

View file

@ -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,
),

View file

@ -71,4 +71,3 @@ private fun RustLiveLocationShare.into(): LiveLocationShare {
endTimestamp = (startTs + timeout).toLong()
)
}

View file

@ -52,5 +52,4 @@ internal fun Flow<List<LiveLocationShare>>.timedByExpiry(
send(liveShares)
reschedule(liveShares)
}
}

View file

@ -12,9 +12,8 @@ import com.google.common.truth.Truth.assertThat
import io.element.android.libraries.matrix.api.core.UserId
import io.element.android.libraries.matrix.api.room.location.LiveLocationShare
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.emptyFlow
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.emptyFlow
import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.test.advanceTimeBy
import kotlinx.coroutines.test.runTest
@ -22,7 +21,6 @@ import org.junit.Test
@OptIn(ExperimentalCoroutinesApi::class)
class TimedLiveLocationSharesFlowTest {
@Test
fun `it keeps emitting shares for subsequent expiries without upstream changes`() = runTest {
val shares = listOf(

View file

@ -66,5 +66,3 @@ fun <R : TestRule> AndroidComposeTestRule<R, ComponentActivity>.assertNodeWithTe
val text = activity.getString(res)
onNodeWithText(text).assertIsDisplayed()
}