Fix code quality check failures after new rules from #935 has been merged on develop.

This commit is contained in:
Benoit Marty 2023-07-21 16:04:55 +02:00
parent f09996cb30
commit 45954b4723
4 changed files with 13 additions and 18 deletions

View file

@ -46,13 +46,13 @@ internal class MapTilerStaticMapUrlBuilder(
density: Float density: Float
): String { ): String {
val mapId = if (darkMode) darkMapId else lightMapId val mapId = if (darkMode) darkMapId else lightMapId
val zoom = zoom.coerceIn(zoomRange) val finalZoom = zoom.coerceIn(zoomRange)
// Request @2x density for xhdpi and above (xhdpi == 320dpi == 2x density). // Request @2x density for xhdpi and above (xhdpi == 320dpi == 2x density).
val is2x = density >= 2 val is2x = density >= 2
// Scale requested width/height according to the reported display density. // Scale requested width/height according to the reported display density.
val (width, height) = coerceWidthAndHeight( val (finalWidth, finalHeight) = coerceWidthAndHeight(
width = (width / density).roundToInt(), width = (width / density).roundToInt(),
height = (height / density).roundToInt(), height = (height / density).roundToInt(),
is2x = is2x, is2x = is2x,
@ -65,7 +65,7 @@ internal class MapTilerStaticMapUrlBuilder(
// image smaller than the available space in pixels. // image smaller than the available space in pixels.
// The resulting image will have to be scaled to fit the available space in order // The resulting image will have to be scaled to fit the available space in order
// to keep the perceived content size constant at the expense of sharpness. // to keep the perceived content size constant at the expense of sharpness.
return "$MAPTILER_BASE_URL/${mapId}/static/${lon},${lat},${zoom}/${width}x${height}${scale}.webp?key=${apiKey}&attribution=bottomleft" return "$MAPTILER_BASE_URL/${mapId}/static/${lon},${lat},${finalZoom}/${finalWidth}x${finalHeight}${scale}.webp?key=${apiKey}&attribution=bottomleft"
} }
} }
@ -78,12 +78,12 @@ private fun coerceWidthAndHeight(width: Int, height: Int, is2x: Boolean): Pair<I
val aspectRatio = width.toDouble() / height.toDouble() val aspectRatio = width.toDouble() / height.toDouble()
val range = if (is2x) widthHeightRange2x else widthHeightRange val range = if (is2x) widthHeightRange2x else widthHeightRange
return if (width >= height) { return if (width >= height) {
width.coerceIn(range).let { width -> width.coerceIn(range).let { coercedWidth ->
width to (width / aspectRatio).roundToInt() coercedWidth to (coercedWidth / aspectRatio).roundToInt()
} }
} else { } else {
height.coerceIn(range).let { height -> height.coerceIn(range).let { coercedHeight ->
(height * aspectRatio).roundToInt() to height (coercedHeight * aspectRatio).roundToInt() to coercedHeight
} }
} }
} }

View file

@ -59,7 +59,6 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.zIndex import androidx.compose.ui.zIndex
import androidx.constraintlayout.compose.ConstrainScope import androidx.constraintlayout.compose.ConstrainScope
import androidx.constraintlayout.compose.ConstraintLayout import androidx.constraintlayout.compose.ConstraintLayout
import com.google.accompanist.flowlayout.FlowMainAxisAlignment
import io.element.android.features.messages.impl.timeline.aTimelineItemEvent import io.element.android.features.messages.impl.timeline.aTimelineItemEvent
import io.element.android.features.messages.impl.timeline.aTimelineItemReactions import io.element.android.features.messages.impl.timeline.aTimelineItemReactions
import io.element.android.features.messages.impl.timeline.components.event.TimelineItemEventContentView import io.element.android.features.messages.impl.timeline.components.event.TimelineItemEventContentView

View file

@ -91,7 +91,7 @@ fun TimelineItemReactionsLayout(
lastRow.forEachIndexed { i, placeable -> lastRow.forEachIndexed { i, placeable ->
val horizontalSpacing = if (i == 0) 0 else itemSpacing.toPx().toInt() val horizontalSpacing = if (i == 0) 0 else itemSpacing.toPx().toInt()
rowX += placeable.width + horizontalSpacing rowX += placeable.width + horizontalSpacing
if (rowX > (constraints.maxWidth - (buttonsWidth + horizontalSpacing))) { if (rowX > constraints.maxWidth - (buttonsWidth + horizontalSpacing)) {
val lastRowWithButton = lastRow.take(i) + listOf(expandButton, addMoreButton) val lastRowWithButton = lastRow.take(i) + listOf(expandButton, addMoreButton)
rows[rows.size - 1] = lastRowWithButton rows[rows.size - 1] = lastRowWithButton
return rows return rows

View file

@ -52,7 +52,6 @@ class RoomMemberListPresenterTests {
Truth.assertThat(initialState.searchQuery).isEmpty() Truth.assertThat(initialState.searchQuery).isEmpty()
Truth.assertThat(initialState.searchResults).isInstanceOf(SearchBarResultState.NotSearching::class.java) Truth.assertThat(initialState.searchResults).isInstanceOf(SearchBarResultState.NotSearching::class.java)
Truth.assertThat(initialState.isSearchActive).isFalse() Truth.assertThat(initialState.isSearchActive).isFalse()
val loadedState = awaitItem() val loadedState = awaitItem()
Truth.assertThat(loadedState.roomMembers).isInstanceOf(Async.Success::class.java) Truth.assertThat(loadedState.roomMembers).isInstanceOf(Async.Success::class.java)
Truth.assertThat((loadedState.roomMembers as Async.Success).data.invited).isEqualTo(listOf(aVictor(), aWalter())) Truth.assertThat((loadedState.roomMembers as Async.Success).data.invited).isEqualTo(listOf(aVictor(), aWalter()))
@ -66,11 +65,9 @@ class RoomMemberListPresenterTests {
moleculeFlow(RecompositionMode.Immediate) { moleculeFlow(RecompositionMode.Immediate) {
presenter.present() presenter.present()
}.test { }.test {
val initialState = awaitItem() skipItems(1)
val loadedState = awaitItem() val loadedState = awaitItem()
loadedState.eventSink(RoomMemberListEvents.OnSearchActiveChanged(true)) loadedState.eventSink(RoomMemberListEvents.OnSearchActiveChanged(true))
val searchActiveState = awaitItem() val searchActiveState = awaitItem()
Truth.assertThat(searchActiveState.isSearchActive).isTrue() Truth.assertThat(searchActiveState.isSearchActive).isTrue()
} }
@ -82,11 +79,11 @@ class RoomMemberListPresenterTests {
moleculeFlow(RecompositionMode.Immediate) { moleculeFlow(RecompositionMode.Immediate) {
presenter.present() presenter.present()
}.test { }.test {
val initialState = awaitItem() skipItems(1)
val loadedState = awaitItem() val loadedState = awaitItem()
loadedState.eventSink(RoomMemberListEvents.OnSearchActiveChanged(true)) loadedState.eventSink(RoomMemberListEvents.OnSearchActiveChanged(true))
val searchActiveState = awaitItem() val searchActiveState = awaitItem()
loadedState.eventSink(RoomMemberListEvents.UpdateSearchQuery("something")) searchActiveState.eventSink(RoomMemberListEvents.UpdateSearchQuery("something"))
val searchQueryUpdatedState = awaitItem() val searchQueryUpdatedState = awaitItem()
Truth.assertThat(searchQueryUpdatedState.searchQuery).isEqualTo("something") Truth.assertThat(searchQueryUpdatedState.searchQuery).isEqualTo("something")
val searchSearchResultDelivered = awaitItem() val searchSearchResultDelivered = awaitItem()
@ -100,18 +97,17 @@ class RoomMemberListPresenterTests {
moleculeFlow(RecompositionMode.Immediate) { moleculeFlow(RecompositionMode.Immediate) {
presenter.present() presenter.present()
}.test { }.test {
val initialState = awaitItem() skipItems(1)
val loadedState = awaitItem() val loadedState = awaitItem()
loadedState.eventSink(RoomMemberListEvents.OnSearchActiveChanged(true)) loadedState.eventSink(RoomMemberListEvents.OnSearchActiveChanged(true))
val searchActiveState = awaitItem() val searchActiveState = awaitItem()
loadedState.eventSink(RoomMemberListEvents.UpdateSearchQuery("Alice")) searchActiveState.eventSink(RoomMemberListEvents.UpdateSearchQuery("Alice"))
val searchQueryUpdatedState = awaitItem() val searchQueryUpdatedState = awaitItem()
Truth.assertThat(searchQueryUpdatedState.searchQuery).isEqualTo("Alice") Truth.assertThat(searchQueryUpdatedState.searchQuery).isEqualTo("Alice")
val searchSearchResultDelivered = awaitItem() val searchSearchResultDelivered = awaitItem()
Truth.assertThat(searchSearchResultDelivered.searchResults).isInstanceOf(SearchBarResultState.Results::class.java) Truth.assertThat(searchSearchResultDelivered.searchResults).isInstanceOf(SearchBarResultState.Results::class.java)
Truth.assertThat((searchSearchResultDelivered.searchResults as SearchBarResultState.Results).results.joined.first().displayName) Truth.assertThat((searchSearchResultDelivered.searchResults as SearchBarResultState.Results).results.joined.first().displayName)
.isEqualTo("Alice") .isEqualTo("Alice")
} }
} }