Various minor bug fixes (#1707)

## Description
Gathering several small bug fixes:
- Clear the backdrop when manually reloading the home page
- Convert the "# years old" string resource to plural
- Fix a spelling error in the source English strings
- Ensure #1680 is respected when searching for subtitles to download
- Slightly adjust padding for the header in collection details to match
other headers

### Related issues
Fixes string issues reported in
https://github.com/damontecres/Wholphin/issues/1705#issuecomment-4982909931

### Testing
Emulator

## Screenshots
N/A

## AI or LLM usage
None
This commit is contained in:
Damontecres 2026-07-18 17:50:35 -04:00 • committed by GitHub
parent 3cc2bf2dd1
commit 35c4d13f8f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
35 changed files with 147 additions and 67 deletions

View file

@ -138,17 +138,7 @@ class StreamChoiceService
playbackLanguageChoice?.audioLanguage?.takeIf { it.isNotNullOrBlank() }
// If the user has chosen a different language for the series, prefer that
val audioLanguage =
if (seriesLang != null) {
seriesLang
} else {
val pref = prefs.userPreferences?.preferredAudioLanguage
when (pref) {
UserProfileSettings.USE_USER_PROFILE -> userConfig?.audioLanguagePreference
UserProfileSettings.PREFER_ANY_LANGUAGE -> null
else -> pref
}
}
seriesLang ?: getPreferredLanguage(MediaStreamType.AUDIO, prefs, userConfig)
if (audioLanguage.isNotNullOrBlank()) {
val sorted =
candidates.sortedWith(compareBy<MediaStream> { it.language }.thenByDescending { it.channels })
@ -242,16 +232,7 @@ class StreamChoiceService
val seriesLang =
playbackLanguageChoice?.subtitleLanguage?.takeIf { it.isNotNullOrBlank() }
val subtitleLanguage =
if (seriesLang != null) {
seriesLang
} else {
val pref = prefs.userPreferences?.preferredSubtitleLanguage
when (pref) {
UserProfileSettings.USE_USER_PROFILE -> userConfig?.subtitleLanguagePreference
UserProfileSettings.PREFER_ANY_LANGUAGE -> null
else -> pref
}?.takeIf { it.isNotNullOrBlank() }
}
seriesLang ?: getPreferredLanguage(MediaStreamType.SUBTITLE, prefs, userConfig)
if (itemPlayback?.subtitleIndex == TrackIndex.ONLY_FORCED) {
// Client-side manual override: User selected "Only Forced" in player menu
return findForcedTrack(candidates, subtitleLanguage, audioStreamLang)
@ -398,3 +379,36 @@ private val String?.isUnknown: Boolean
this.equals("zxx", true)
private fun String?.equalsLangOrUnknown(lang: String): Boolean = equals(lang, ignoreCase = true) || this.isUnknown
/**
* Based on the user's preferences, get their preferred language for audio or subtitles
*
* @param prefs the [UserPreferences]
*/
fun getPreferredLanguage(
type: MediaStreamType,
prefs: UserPreferences,
userConfig: UserConfiguration?,
): String? {
val (pref, profileLang) =
when (type) {
MediaStreamType.AUDIO -> {
prefs.userPreferences?.preferredAudioLanguage to
userConfig?.audioLanguagePreference
}
MediaStreamType.SUBTITLE -> {
prefs.userPreferences?.preferredSubtitleLanguage to
userConfig?.subtitleLanguagePreference
}
else -> {
throw IllegalArgumentException("Only audio or subtitle supported, not $type")
}
}
return when (pref) {
UserProfileSettings.USE_USER_PROFILE -> profileLang
UserProfileSettings.PREFER_ANY_LANGUAGE -> null
else -> pref
}?.takeIf { it.isNotNullOrBlank() }
}

View file

@ -25,7 +25,7 @@ fun HiddenFocusBox(
modifier =
Modifier
.fillMaxWidth()
.height(1.dp)
.height(0.dp)
.focusRequester(focusRequester)
.onFocusChanged {
if (it.isFocused) onFocus.invoke()

View file

@ -28,6 +28,7 @@ import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.focus.onFocusChanged
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.pluralStringResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
@ -503,8 +504,9 @@ fun PersonHeader(
val text =
if (age != null) {
stringResource(R.string.born) + ": ${formatDate(it)} (${
stringResource(
R.string.years_old,
pluralStringResource(
R.plurals.years_old,
age,
age,
)
})"
@ -533,8 +535,9 @@ fun PersonHeader(
val text =
if (age != null) {
stringResource(R.string.died) + ": ${formatDate(it)} (${
stringResource(
R.string.years_old,
pluralStringResource(
R.plurals.years_old,
age,
age,
)
})"

View file

@ -343,6 +343,7 @@ fun CollectionDetailsContent(
modifier =
Modifier
.padding(
start = HeaderUtils.startPadding,
top = HeaderUtils.topPadding,
bottom = 8.dp,
).height(HeaderUtils.height),

View file

@ -432,6 +432,7 @@ fun NavDrawer(
viewModel.setIndex(HOME_INDEX)
if (destination is Destination.Home) {
viewModel.navigationManager.reloadHome()
onClearBackdrop.invoke()
} else {
viewModel.navigationManager.goToHome()
}

View file

@ -181,7 +181,7 @@ class PlaybackViewModel
private val _state = MutableStateFlow(PlaybackState())
val state: StateFlow<PlaybackState> = _state
private lateinit var preferences: UserPreferences
internal lateinit var preferences: UserPreferences
internal lateinit var itemId: UUID
internal lateinit var currentItem: PlaylistItem
internal var forceTranscoding: Boolean = false

View file

@ -7,6 +7,7 @@ import com.github.damontecres.wholphin.R
import com.github.damontecres.wholphin.data.model.BaseItem
import com.github.damontecres.wholphin.data.model.PlaylistItem
import com.github.damontecres.wholphin.data.model.TrackIndex
import com.github.damontecres.wholphin.services.getPreferredLanguage
import com.github.damontecres.wholphin.ui.isNotNullOrBlank
import com.github.damontecres.wholphin.ui.launchIO
import com.github.damontecres.wholphin.ui.onMain
@ -42,15 +43,17 @@ sealed interface SubtitleSearchStatus {
/**
* Trigger a search for subtitles in the given language for the currently playing media
*/
fun PlaybackViewModel.searchForSubtitles(
language: String =
serverRepository
.currentUserDto
?.configuration
?.subtitleLanguagePreference
?.takeIf { it.isNotNullOrBlank() }
?: Locale.current.language,
) {
fun PlaybackViewModel.searchForSubtitles(language: String? = null) {
val language =
language ?: getPreferredLanguage(
MediaStreamType.SUBTITLE,
preferences,
serverRepository
.currentUserDto
?.configuration,
)?.takeIf { it.isNotNullOrBlank() }
?: Locale.current.language
subtitleSearchState.update {
it.copy(
status = SubtitleSearchStatus.Searching,