Add option to override user profile settings for audio & subtitle languages (#1680)

## Description
Adds settings under the "User profile settings" section which allows for
specifying preferred languages for audio and subtitles and the preferred
subtitle mode.

By default (matching existing Wholphin behavior), the preferred
languages and subtitle mode are derived from the user's profile settings
provided by the server which can be set on the WebUI:
User->Settings->Playback or Subtitles. However, this isn't well
understood and Wholphin doesn't display these values anywhere, so many
users were confused.

The preferred languages and subtitle mode can now be configured from
within Wholphin. Setting these will **not** update the server. The
settings are **only** used locally.

### Related issues
Related to #319
Closes #790

### Testing
Emulator manually changing some settings, added additional unit tests to
ensure the overrides are respected when choosing tracks

## Screenshots
### Settings page
<img width="1280" height="720" alt="settings_01 Large"
src="https://github.com/user-attachments/assets/28cc2f6b-3a60-42a4-b268-48695086d566"
/>

### Clicking into "More user profile settings"
<img width="1280" height="720" alt="settings_02 Large"
src="https://github.com/user-attachments/assets/6c3be3aa-c177-4d44-8060-b76d15fb10d7"
/>

### Language choice dialog

Can filter languages by typing in the search box at the top

<img width="1280" height="720" alt="settings_03 Large"
src="https://github.com/user-attachments/assets/c014d0ba-8d5b-4201-a6ee-4876b478148c"
/>


## AI or LLM usage
None
This commit is contained in:
Damontecres 2026-07-14 14:17:31 -04:00 • committed by GitHub
parent 077b7e4570
commit 3f60fa7550
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
26 changed files with 1751 additions and 48 deletions

View file

@ -49,7 +49,7 @@ import java.util.UUID
SeerrUser::class,
RememberedTab::class,
],
version = 34,
version = 35,
exportSchema = true,
autoMigrations = [
AutoMigration(3, 4),
@ -67,6 +67,7 @@ import java.util.UUID
AutoMigration(31, 32),
AutoMigration(32, 33),
AutoMigration(33, 34),
AutoMigration(34, 35),
],
)
@TypeConverters(Converters::class)

View file

@ -9,6 +9,7 @@ import androidx.room.Update
import com.github.damontecres.wholphin.data.model.JellyfinServer
import com.github.damontecres.wholphin.data.model.JellyfinServerUsers
import com.github.damontecres.wholphin.data.model.JellyfinUser
import kotlinx.coroutines.flow.Flow
import java.util.UUID
@Dao
@ -56,6 +57,12 @@ interface JellyfinServerDao {
userId: UUID,
): JellyfinUser?
@Query("SELECT * FROM users WHERE serverId = :serverId AND id = :userId")
fun getUserFlow(
serverId: UUID,
userId: UUID,
): Flow<JellyfinUser?>
@Query("DELETE FROM servers WHERE id = :serverId")
fun deleteServer(serverId: UUID)

View file

@ -12,9 +12,12 @@ import com.github.damontecres.wholphin.ui.toServerString
import com.github.damontecres.wholphin.util.WholphinDispatchers
import dagger.hilt.android.qualifiers.ApplicationContext
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.flatMapLatest
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.update
import kotlinx.coroutines.withContext
@ -57,7 +60,18 @@ class ServerRepository
val currentServer: JellyfinServer? get() = _current.value?.server
val currentServerFlow: Flow<JellyfinServer?> get() = _current.map { it?.server }
val currentUser: JellyfinUser? get() = _current.value?.user
val currentUserFlow: Flow<JellyfinUser?> get() = _current.map { it?.user }
@OptIn(ExperimentalCoroutinesApi::class)
val currentUserFlow: Flow<JellyfinUser?>
get() =
_current
.flatMapLatest { user ->
if (user?.user != null) {
serverDao.getUserFlow(user.user.serverId, user.user.id)
} else {
flow { emit(null) }
}
}
/**
* Adds a server to the app database and updated the [ApiClient] to the server's URL

View file

@ -11,6 +11,8 @@ import androidx.room.Index
import androidx.room.PrimaryKey
import androidx.room.Relation
import com.github.damontecres.wholphin.data.ZonedDateTimeSerializer
import com.github.damontecres.wholphin.preferences.SubtitleModePreference
import com.github.damontecres.wholphin.preferences.UserProfileSettings
import com.github.damontecres.wholphin.ui.isNotNullOrBlank
import kotlinx.serialization.Serializable
import kotlinx.serialization.UseSerializers
@ -65,11 +67,15 @@ data class JellyfinUser(
val requireLogin: Boolean = false,
val lastUsed: ZonedDateTime? = null,
val uiLanguage: String? = null,
@Embedded val appPreferences: JellyfinUserPreferences = JellyfinUserPreferences(),
) {
val hasPin: Boolean get() = pin.isNotNullOrBlank()
override fun toString(): String =
"JellyfinUser(rowId=$rowId, id=$id, name=$name, serverId=$serverId, lastUsed=$lastUsed, accessToken?=${accessToken.isNotNullOrBlank()}, pin?=${pin.isNotNullOrBlank()})"
"JellyfinUser(rowId=$rowId, id=$id, name=$name, serverId=$serverId, lastUsed=$lastUsed, " +
"accessToken?=${accessToken.isNotNullOrBlank()}, pin?=${pin.isNotNullOrBlank()}), " +
"requireLogin=$requireLogin, lastUsed=$lastUsed, uiLanguage=$uiLanguage, " +
"appPreferences=$appPreferences"
}
/**
@ -83,3 +89,13 @@ data class JellyfinServerUsers(
)
val users: List<JellyfinUser>,
)
@Serializable
data class JellyfinUserPreferences(
@ColumnInfo(defaultValue = "")
val preferredAudioLanguage: String = UserProfileSettings.USE_USER_PROFILE,
@ColumnInfo(defaultValue = "")
val preferredSubtitleLanguage: String = UserProfileSettings.USE_USER_PROFILE,
@ColumnInfo(defaultValue = "USE_USER_PROFILE")
val subtitleMode: SubtitleModePreference = SubtitleModePreference.USE_USER_PROFILE,
)