Skip to content
Merged
4 changes: 4 additions & 0 deletions THIRD_PARTY_NOTICES.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ Silo uses [`ass-media` 0.5.1](https://github.com/peerless2012/libass-android) un

The Dolby Vision bridge AAR is built from the `dolby_vision` crate in [`quietvoid/dovi_tool` 2.3.1](https://github.com/quietvoid/dovi_tool/tree/b25558062e4a56973482ec70133bd7b891320e48/dolby_vision), distributed under the MIT license. The upstream source commit, archive and lockfiles, the OSV-clean build lock, toolchains, native outputs, and packaged AAR are pinned in `android-shared/src/native/dovi/provenance.json`. The build lock records remediations for RUSTSEC-2026-0190, RUSTSEC-2026-0105, and RUSTSEC-2026-0204.

## TMDB Logo

`android-shared/src/androidMain/res/drawable/tmdb_logo.xml` is TMDB's approved "alt short" logo from <https://www.themoviedb.org/about/logos-attribution>, converted to a VectorDrawable without changing its shape or colours. It is a trademark of TMDB and is not covered by this repository's license. Silo shows it next to TMDB scores; keep it unmodified and less prominent than Silo's own branding.

## Gradle Wrapper

The Gradle wrapper scripts retain their upstream Apache-2.0 license.
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
package org.siloserver.silo.common.ui

import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.text.BasicText
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.semantics.clearAndSetSemantics
import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.TextUnit
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.isSpecified
import androidx.compose.ui.unit.sp
import org.siloserver.silo.common.R
import org.siloserver.silo.model.catalog.DisplayRating
import org.siloserver.silo.model.catalog.ExternalRatings

/**
* One external rating as its source's mark and its score: `IMDb 8.5`,
* `RT 93%`. The mark is the source's name as plain text, never a star or the
* source's artwork, except TMDB, whose approved logo its terms allow. The
* score is [DisplayRating.display] as the server formatted it. Screen readers
* hear "IMDb 8.5".
*
* [style] is the score's text style and should carry a color and font size;
* the mark is drawn from it semibold and dimmed, at [markFontSize] or a
* little smaller than the score, and the TMDB logo is sized to about the
* score's cap height.
*
* Callers lay entries out themselves; [WholeTokenRow] keeps them on one line.
* Do not add a FlowRow-based row here: FlowRow is experimental, and this
* module compiles against an older Compose foundation than the apps ship, so
* the call fails at runtime with NoSuchMethodError.
*/
@Composable
fun RatingEntry(
rating: DisplayRating,
style: TextStyle,
modifier: Modifier = Modifier,
markFontSize: TextUnit = TextUnit.Unspecified,
) {
val fontSize = style.fontSize.takeIf { it.isSpecified } ?: DefaultScoreSize
val scoreStyle = style.merge(
TextStyle(
fontSize = fontSize,
fontWeight = FontWeight.Bold,
fontFeatureSettings = "tnum",
),
)
Row(
modifier = modifier.clearAndSetSemantics {
contentDescription = "${rating.name} ${rating.display}"
},
horizontalArrangement = Arrangement.spacedBy(6.dp),
verticalAlignment = Alignment.CenterVertically,
) {
if (rating.source == ExternalRatings.SOURCE_TMDB) {
val logoHeight = with(LocalDensity.current) { (fontSize * TmdbLogoCapHeight).toDp() }
Image(
painter = painterResource(R.drawable.tmdb_logo),
contentDescription = rating.name,
contentScale = ContentScale.Fit,
modifier = Modifier.size(width = logoHeight * TmdbLogoAspectRatio, height = logoHeight),
)
} else {
BasicText(
text = rating.name,
style = style.merge(
TextStyle(
fontSize = markFontSize.takeIf { it.isSpecified } ?: (fontSize * MarkScale),
fontWeight = FontWeight.SemiBold,
),
),
maxLines = 1,
softWrap = false,
modifier = Modifier.alpha(MarkAlpha),
)
}
BasicText(
text = rating.display,
style = scoreStyle,
maxLines = 1,
softWrap = false,
)
}
}

private val DefaultScoreSize = 14.sp
private const val MarkScale = 0.87f
private const val MarkAlpha = 0.75f

/** About a cap height of the score text, like the web client's logo. */
private const val TmdbLogoCapHeight = 0.66f

/** The logo's own proportions (its viewBox), kept unmodified. */
private const val TmdbLogoAspectRatio = 273.42f / 35.52f
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
package org.siloserver.silo.common.ui

import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.Layout
import androidx.compose.ui.layout.ParentDataModifier
import androidx.compose.ui.unit.Constraints
import androidx.compose.ui.unit.Density
import androidx.compose.ui.unit.Dp

/**
* A single-line row that shows as many whole children as fit, in order, and
* drops the rest. A child is never moved to a second line, and is never cut
* partway unless it opts in with [WholeTokenRowScope.shrinkable]. The row is
* as wide as the children it shows, so a centering parent centers them.
* Children are vertically centered.
*
* Children marked [WholeTokenRowScope.separator] (a "·") are not tokens: the
* row shows one only between two shown tokens, so dropping a token never
* leaves a separator at either end or two in a row.
*/
@Composable
fun WholeTokenRow(
spacing: Dp,
modifier: Modifier = Modifier,
content: @Composable WholeTokenRowScope.() -> Unit,
) {
Layout(content = { WholeTokenRowScope.content() }, modifier = modifier) { measurables, constraints ->
val gap = spacing.roundToPx()
val flags = measurables.map { it.parentData as? TokenFlags ?: TokenFlags() }
val widths = measurables.map { it.maxIntrinsicWidth(Constraints.Infinity) }

// The separator written right after token [index], if any. A shown
// token keeps it only when another token is shown after it.
fun separatorAfter(index: Int): Int? = (index + 1).takeIf { it < measurables.size && flags[it].separator }

// Width a token adds after [previous]: the gap, plus previous's separator and its gap.
fun joinWidth(previous: Int?): Int = if (previous == null) {
0
} else {
gap + (separatorAfter(previous)?.let { widths[it] + gap } ?: 0)
}

fun widthOf(tokens: List<Int>): Int =
tokens.withIndex().sumOf { (k, index) -> joinWidth(tokens.getOrNull(k - 1)) + widths[index] }

// Too wide: drop the tokens marked dropFirst before any other, the
// highest rank first and, within a rank, the last first.
val kept = measurables.indices.filterNot { flags[it].separator }.toMutableList()
while (widthOf(kept) > constraints.maxWidth) {
val rank = kept.maxOfOrNull { flags[it].dropRank }?.takeIf { it > 0 } ?: break
kept.remove(kept.last { flags[it].dropRank == rank })
}

// Then keep the leading tokens that fit. A shrinkable token takes the
// width left and handles its own overflow; any other stops the row.
val shown = mutableListOf<Pair<Int, Int>>()
var width = 0
var previous: Int? = null
for (index in kept) {
val start = width + joinWidth(previous)
val left = constraints.maxWidth - start
val fits = widths[index] <= left
if (!fits && !(flags[index].shrinkable && left > 0)) break
previous?.let(::separatorAfter)?.let { shown += it to widths[it] }
shown += index to if (fits) widths[index] else left
if (!fits) break
width = start + widths[index]
previous = index
}

val placeables = shown.map { (index, maxWidth) ->
measurables[index].measure(Constraints(maxWidth = maxWidth, maxHeight = constraints.maxHeight))
}
val rowWidth = placeables.sumOf { it.width } + gap * (placeables.size - 1).coerceAtLeast(0)
val height = (placeables.maxOfOrNull { it.height } ?: 0)
.coerceIn(constraints.minHeight, constraints.maxHeight)
layout(rowWidth.coerceIn(constraints.minWidth, constraints.maxWidth), height) {
var x = 0
placeables.forEach { placeable ->
placeable.placeRelative(x, (height - placeable.height) / 2)
x += placeable.width + gap
}
}
}
}

object WholeTokenRowScope {
/**
* When the row is too wide, drop this token before any unmarked one,
* starting from the end. Tokens with a higher [rank] drop before those
* with a lower one.
*/
fun Modifier.dropFirst(rank: Int = 1): Modifier = then(TokenFlags(dropRank = rank.coerceAtLeast(1)))

/**
* When this token does not fit whole, give it the width left instead of
* dropping it. The token must end its own overflow, usually with an
* ellipsis.
*/
fun Modifier.shrinkable(): Modifier = then(TokenFlags(shrinkable = true))

/**
* This child separates the tokens either side of it, and shows only when
* both of them do.
*/
fun Modifier.separator(): Modifier = then(TokenFlags(separator = true))
}

private data class TokenFlags(
val dropRank: Int = 0,
val shrinkable: Boolean = false,
val separator: Boolean = false,
) : ParentDataModifier {
override fun Density.modifyParentData(parentData: Any?): Any {
val current = parentData as? TokenFlags ?: TokenFlags()
return TokenFlags(
dropRank = maxOf(current.dropRank, dropRank),
shrinkable = current.shrinkable || shrinkable,
separator = current.separator || separator,
)
}
}
34 changes: 34 additions & 0 deletions android-shared/src/androidMain/res/drawable/tmdb_logo.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
TMDB's approved "alt short" logo, converted unmodified (same path, same
gradient) from the SVG at https://www.themoviedb.org/about/logos-attribution.
It is TMDB's trademark, not Silo's, and is not covered by this repository's
license. Silo shows it next to TMDB scores, as TMDB's API terms of use
allow. Keep it unmodified (colours, proportions) and less prominent than
Silo's own branding. Lint's VectorPath length warning is ignored because
shortening the path would modify the logo.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
xmlns:tools="http://schemas.android.com/tools"
android:width="92.37dp"
android:height="12dp"
android:viewportWidth="273.42"
android:viewportHeight="35.52">
<path
tools:ignore="VectorPath"
android:pathData="M191.85,35.37h63.9A17.67,17.67,0,0,0,273.42,17.7h0A17.67,17.67,0,0,0,255.75,0h-63.9A17.67,17.67,0,0,0,174.18,17.7h0A17.67,17.67,0,0,0,191.85,35.37ZM10.1,35.42h7.8V6.92H28V0H0v6.9H10.1Zm28.1,0H46V8.25h.1L55.05,35.4h6L70.3,8.25h.1V35.4h7.8V0H66.45l-8.2,23.1h-.1L50,0H38.2ZM89.14.12h11.7a33.56,33.56,0,0,1,8.08,1,18.52,18.52,0,0,1,6.67,3.08,15.09,15.09,0,0,1,4.53,5.52,18.5,18.5,0,0,1,1.67,8.25,16.91,16.91,0,0,1-1.62,7.58,16.3,16.3,0,0,1-4.38,5.5,19.24,19.24,0,0,1-6.35,3.37,24.53,24.53,0,0,1-7.55,1.15H89.14Zm7.8,28.2h4a21.66,21.66,0,0,0,5-.55A10.58,10.58,0,0,0,110,26a8.73,8.73,0,0,0,2.68-3.35,11.9,11.9,0,0,0,1-5.08,9.87,9.87,0,0,0-1-4.52,9.17,9.17,0,0,0-2.63-3.18A11.61,11.61,0,0,0,106.22,8a17.06,17.06,0,0,0-4.68-.63h-4.6ZM133.09.12h13.2a32.87,32.87,0,0,1,4.63.33,12.66,12.66,0,0,1,4.17,1.3,7.94,7.94,0,0,1,3,2.72,8.34,8.34,0,0,1,1.15,4.65,7.48,7.48,0,0,1-1.67,5,9.13,9.13,0,0,1-4.43,2.82V17a10.28,10.28,0,0,1,3.18,1,8.51,8.51,0,0,1,2.45,1.85,7.79,7.79,0,0,1,1.57,2.62,9.16,9.16,0,0,1,.55,3.2,8.52,8.52,0,0,1-1.2,4.68,9.32,9.32,0,0,1-3.1,3A13.38,13.38,0,0,1,152.32,35a22.5,22.5,0,0,1-4.73.5h-14.5Zm7.8,14.15h5.65a7.65,7.65,0,0,0,1.78-.2,4.78,4.78,0,0,0,1.57-.65,3.43,3.43,0,0,0,1.13-1.2,3.63,3.63,0,0,0,.42-1.8A3.3,3.3,0,0,0,151,8.6a3.42,3.42,0,0,0-1.23-1.13A6.07,6.07,0,0,0,148,6.9a9.9,9.9,0,0,0-1.85-.18h-5.3Zm0,14.65h7a8.27,8.27,0,0,0,1.83-.2,4.67,4.67,0,0,0,1.67-.7,3.93,3.93,0,0,0,1.23-1.3,3.8,3.8,0,0,0,.47-1.95,3.16,3.16,0,0,0-.62-2,4,4,0,0,0-1.58-1.18,8.23,8.23,0,0,0-2-.55,15.12,15.12,0,0,0-2.05-.15h-5.9Z">
<aapt:attr name="android:fillColor">
<gradient
android:type="linear"
android:startX="0"
android:startY="17.76"
android:endX="273.42"
android:endY="17.76">
<item android:offset="0" android:color="#FF90CEA1" />
<item android:offset="0.56" android:color="#FF3CBEC9" />
<item android:offset="1" android:color="#FF00B3E5" />
</gradient>
</aapt:attr>
</path>
</vector>
Loading
Loading