Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ android {
applicationId = "dev.typetype.android"
minSdk = 23
targetSdk = 37
versionCode = 10807
versionName = "1.8.0-beta.7"
versionCode = 10808
versionName = "1.8.0-beta.8"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
resValue("string", "app_name", "TypeType")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class CommentBodyTest {
}

composeRule.onNodeWithText("Read more").assertExists().performClick()
composeRule.onNodeWithText("Long comment starts here$suffix").assertExists()
composeRule.onNodeWithText("Show less").assertExists().performClick()
composeRule.onNodeWithText("Read more").assertExists()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ internal class StreamRepositoryImpl @Inject constructor(
},
storyboard = previewFrames
.mapNotNull { it.toDomainStoryboard() }
.maxByOrNull { it.frameWidth },
.let(::selectStoryboard),
startPositionMillis = startPosition * 1000L,
sponsorBlockSegments = sponsorBlockSegments.mapNotNull {
it.toDomainSponsorBlockSegment(duration)
Expand All @@ -207,6 +207,11 @@ internal class StreamRepositoryImpl @Inject constructor(
.maxByOrNull { it.height }
?.url

private fun selectStoryboard(storyboards: List<StreamStoryboard>): StreamStoryboard? =
storyboards.filter { it.frameWidth >= TARGET_STORYBOARD_FRAME_WIDTH }
.minByOrNull { it.frameWidth }
?: storyboards.maxByOrNull { it.frameWidth }

private fun PreviewFrameItem.toDomainStoryboard(): StreamStoryboard? =
StreamStoryboard(
urls = urls.filter(String::isNotBlank),
Expand Down Expand Up @@ -289,6 +294,7 @@ internal suspend fun <T> cancellableStreamResult(
}

private const val SABR_DELIVERY_METHOD = "sabr"
private const val TARGET_STORYBOARD_FRAME_WIDTH = 160

private class SabrContractException :
IllegalStateException("The server returned no playable SABR contract"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,17 @@ private fun ExpandableCommentText(
maxLines = if (expanded) Int.MAX_VALUE else COMMENT_COLLAPSE_LINE_LIMIT,
overflow = if (expanded) TextOverflow.Clip else TextOverflow.Ellipsis,
)
if (needsTruncation && !expanded) {
if (needsTruncation) {
TextButton(
onClick = { expanded = true },
onClick = { expanded = !expanded },
contentPadding = PaddingValues(horizontal = 4.dp),
modifier = Modifier.padding(top = 2.dp),
) {
Text(stringResource(R.string.comments_read_more))
Text(
stringResource(
if (expanded) R.string.comments_show_less else R.string.comments_read_more,
)
)
}
}
}
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,7 @@
<string name="comments_title">Comments</string>
<string name="comments_empty">No comments</string>
<string name="comments_read_more">Read more</string>
<string name="comments_show_less">Show less</string>
<string name="comments_like_count">Likes: %1$s</string>
<string name="comments_replies_failed">Couldn\'t load replies</string>
<string name="comments_load_failed">Couldn\'t load comments</string>
Expand Down