From 8c1c81f38b130515654ddc581f9f876589d08c5b Mon Sep 17 00:00:00 2001 From: Mattias Buelens Date: Thu, 12 Dec 2024 14:22:08 +0100 Subject: [PATCH 01/13] Extract string resources for text --- app/src/main/res/values-en/strings.xml | 3 + .../theoplayer/android/ui/ChromecastButton.kt | 7 +- .../android/ui/ChromecastDisplay.kt | 25 ++++++- .../android/ui/CurrentTimeDisplay.kt | 27 +++++-- .../com/theoplayer/android/ui/DefaultUI.kt | 1 + .../com/theoplayer/android/ui/ErrorDisplay.kt | 3 +- .../theoplayer/android/ui/FullscreenButton.kt | 5 +- .../com/theoplayer/android/ui/LanguageMenu.kt | 26 ++++--- .../android/ui/LanguageMenuButton.kt | 3 +- .../com/theoplayer/android/ui/LiveButton.kt | 8 ++- .../java/com/theoplayer/android/ui/Menu.kt | 3 +- .../com/theoplayer/android/ui/MuteButton.kt | 5 +- .../com/theoplayer/android/ui/PlayButton.kt | 7 +- .../theoplayer/android/ui/PlaybackRateList.kt | 11 +-- .../com/theoplayer/android/ui/SeekButton.kt | 5 +- .../com/theoplayer/android/ui/SettingsMenu.kt | 13 ++-- .../android/ui/SettingsMenuButton.kt | 3 +- ui/src/main/res/values/strings.xml | 70 ++++++++++++++++++- 18 files changed, 176 insertions(+), 49 deletions(-) create mode 100644 app/src/main/res/values-en/strings.xml diff --git a/app/src/main/res/values-en/strings.xml b/app/src/main/res/values-en/strings.xml new file mode 100644 index 0000000..497968c --- /dev/null +++ b/app/src/main/res/values-en/strings.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/ui/src/main/java/com/theoplayer/android/ui/ChromecastButton.kt b/ui/src/main/java/com/theoplayer/android/ui/ChromecastButton.kt index 935999d..6e317b3 100644 --- a/ui/src/main/java/com/theoplayer/android/ui/ChromecastButton.kt +++ b/ui/src/main/java/com/theoplayer/android/ui/ChromecastButton.kt @@ -7,6 +7,7 @@ import androidx.compose.material.icons.rounded.CastConnected import androidx.compose.material3.Icon import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier +import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp import com.theoplayer.android.api.cast.chromecast.PlayerCastState @@ -31,19 +32,19 @@ fun ChromecastButton( availableIcon: @Composable () -> Unit = { Icon( Icons.Rounded.Cast, - contentDescription = "Start casting" + contentDescription = stringResource(R.string.theoplayer_ui_btn_chromecast_start) ) }, connectingIcon: @Composable () -> Unit = { Icon( Icons.Rounded.Cast, - contentDescription = "Stop casting" + contentDescription = stringResource(R.string.theoplayer_ui_btn_chromecast_stop) ) }, connectedIcon: @Composable () -> Unit = { Icon( Icons.Rounded.CastConnected, - contentDescription = "Stop casting" + contentDescription = stringResource(R.string.theoplayer_ui_btn_chromecast_stop) ) } ) { diff --git a/ui/src/main/java/com/theoplayer/android/ui/ChromecastDisplay.kt b/ui/src/main/java/com/theoplayer/android/ui/ChromecastDisplay.kt index 526db64..df7817f 100644 --- a/ui/src/main/java/com/theoplayer/android/ui/ChromecastDisplay.kt +++ b/ui/src/main/java/com/theoplayer/android/ui/ChromecastDisplay.kt @@ -15,6 +15,7 @@ import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp import com.theoplayer.android.api.cast.chromecast.PlayerCastState @@ -68,7 +69,13 @@ fun ChromecastDisplayCompact( ) Spacer(Modifier.size(ButtonDefaults.IconSpacing)) Text( - text = "Playing on ${player.castReceiverName ?: "Chromecast"}" + text = player.castReceiverName?.let { + stringResource( + R.string.theoplayer_ui_chromecast_playing_on_receiver, + it + ) + } + ?: stringResource(R.string.theoplayer_ui_chromecast_playing_on_unknown_receiver) ) } } @@ -101,11 +108,23 @@ fun ChromecastDisplayExpanded( } Column { Text( - text = "Playing on", + text = player.castReceiverName?.let { + stringResource( + R.string.theoplayer_ui_chromecast_playing_on_receiver_expanded_first_line, + it + ) + } + ?: stringResource(R.string.theoplayer_ui_chromecast_playing_on_unknown_receiver_expanded_first_line), style = MaterialTheme.typography.bodyLarge ) Text( - text = player.castReceiverName ?: "Chromecast", + text = player.castReceiverName?.let { + stringResource( + R.string.theoplayer_ui_chromecast_playing_on_receiver_expanded_second_line, + it + ) + } + ?: stringResource(R.string.theoplayer_ui_chromecast_playing_on_unknown_receiver_expanded_second_line), style = MaterialTheme.typography.headlineSmall ) } diff --git a/ui/src/main/java/com/theoplayer/android/ui/CurrentTimeDisplay.kt b/ui/src/main/java/com/theoplayer/android/ui/CurrentTimeDisplay.kt index 0b83c76..fb392e5 100644 --- a/ui/src/main/java/com/theoplayer/android/ui/CurrentTimeDisplay.kt +++ b/ui/src/main/java/com/theoplayer/android/ui/CurrentTimeDisplay.kt @@ -3,6 +3,7 @@ package com.theoplayer.android.ui import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier +import androidx.compose.ui.res.stringResource /** * A text display that shows the player's current time. @@ -29,12 +30,26 @@ fun CurrentTimeDisplay( currentTime } - val text = StringBuilder() - text.append(formatTime(time, duration)) - if (showDuration) { - text.append(" / ") - text.append(formatTime(duration)) + val text = if (showDuration) { + stringResource( + if (showRemaining) { + R.string.theoplayer_ui_current_time_remaining_with_duration + } else { + R.string.theoplayer_ui_current_time_with_duration + }, + formatTime(time, duration), + formatTime(duration) + ) + } else { + stringResource( + if (showRemaining) { + R.string.theoplayer_ui_current_time_remaining + } else { + R.string.theoplayer_ui_current_time + }, + formatTime(time, duration), + ) } - Text(modifier = modifier, text = text.toString()) + Text(modifier = modifier, text = text) } \ No newline at end of file diff --git a/ui/src/main/java/com/theoplayer/android/ui/DefaultUI.kt b/ui/src/main/java/com/theoplayer/android/ui/DefaultUI.kt index f433613..09b973f 100644 --- a/ui/src/main/java/com/theoplayer/android/ui/DefaultUI.kt +++ b/ui/src/main/java/com/theoplayer/android/ui/DefaultUI.kt @@ -90,6 +90,7 @@ fun DefaultUI( } Spacer(modifier = Modifier.weight(1f)) LanguageMenuButton() + SettingsMenuButton() ChromecastButton() } } diff --git a/ui/src/main/java/com/theoplayer/android/ui/ErrorDisplay.kt b/ui/src/main/java/com/theoplayer/android/ui/ErrorDisplay.kt index edcedd4..b44a93a 100644 --- a/ui/src/main/java/com/theoplayer/android/ui/ErrorDisplay.kt +++ b/ui/src/main/java/com/theoplayer/android/ui/ErrorDisplay.kt @@ -14,6 +14,7 @@ import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp /** @@ -43,7 +44,7 @@ fun ErrorDisplay( contentAlignment = Alignment.CenterStart ) { Text( - text = "An error occurred", + text = stringResource(R.string.theoplayer_ui_error_title), style = MaterialTheme.typography.headlineMedium ) } diff --git a/ui/src/main/java/com/theoplayer/android/ui/FullscreenButton.kt b/ui/src/main/java/com/theoplayer/android/ui/FullscreenButton.kt index 5863fdd..16b63c8 100644 --- a/ui/src/main/java/com/theoplayer/android/ui/FullscreenButton.kt +++ b/ui/src/main/java/com/theoplayer/android/ui/FullscreenButton.kt @@ -7,6 +7,7 @@ import androidx.compose.material.icons.rounded.FullscreenExit import androidx.compose.material3.Icon import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier +import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp /** @@ -25,13 +26,13 @@ fun FullscreenButton( enter: @Composable () -> Unit = { Icon( Icons.Rounded.Fullscreen, - contentDescription = "Enter fullscreen" + contentDescription = stringResource(R.string.theoplayer_ui_btn_fullscreen_enter) ) }, exit: @Composable () -> Unit = { Icon( Icons.Rounded.FullscreenExit, - contentDescription = "Exit fullscreen" + contentDescription = stringResource(R.string.theoplayer_ui_btn_fullscreen_exit) ) } ) { diff --git a/ui/src/main/java/com/theoplayer/android/ui/LanguageMenu.kt b/ui/src/main/java/com/theoplayer/android/ui/LanguageMenu.kt index 911aa18..a7a6ae2 100644 --- a/ui/src/main/java/com/theoplayer/android/ui/LanguageMenu.kt +++ b/ui/src/main/java/com/theoplayer/android/ui/LanguageMenu.kt @@ -14,6 +14,7 @@ import androidx.compose.material3.Text import androidx.compose.material3.TextButton import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier +import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp @@ -26,11 +27,11 @@ import androidx.compose.ui.unit.dp @Composable fun MenuScope.LanguageMenu() { Menu( - title = { Text(text = "Language") }, + title = { Text(text = stringResource(R.string.theoplayer_ui_menu_language)) }, backIcon = { Icon( Icons.Rounded.Close, - contentDescription = "Close" + contentDescription = stringResource(R.string.theoplayer_ui_btn_menu_close) ) }, ) { @@ -75,7 +76,7 @@ fun MenuScope.LanguageMenuCompact() { modifier = Modifier .weight(1f) .alignByBaseline(), - text = "Audio" + text = stringResource(R.string.theoplayer_ui_menu_audio) ) TextButton( modifier = Modifier @@ -85,7 +86,10 @@ fun MenuScope.LanguageMenuCompact() { ) { Text( modifier = Modifier.weight(1f), - text = player?.activeAudioTrack?.let { formatTrackLabel(it) } ?: "None", + text = player?.activeAudioTrack?.let { formatTrackLabel(it) } + ?: stringResource( + R.string.theoplayer_ui_menu_audio_none + ), textAlign = TextAlign.Center ) Icon( @@ -101,7 +105,7 @@ fun MenuScope.LanguageMenuCompact() { modifier = Modifier .weight(1f) .alignByBaseline(), - text = "Subtitles" + text = stringResource(R.string.theoplayer_ui_menu_subtitles) ) TextButton( modifier = Modifier @@ -111,7 +115,9 @@ fun MenuScope.LanguageMenuCompact() { ) { Text( modifier = Modifier.weight(1f), - text = player?.activeSubtitleTrack?.let { formatTrackLabel(it) } ?: "Off", + text = player?.activeSubtitleTrack?.let { formatTrackLabel(it) } ?: stringResource( + R.string.theoplayer_ui_menu_subtitles_off + ), textAlign = TextAlign.Center ) Icon( @@ -142,7 +148,7 @@ fun MenuScope.LanguageMenuExpanded() { modifier = Modifier .fillMaxWidth(1f) .padding(0.dp, 8.dp), - text = "Audio", + text = stringResource(R.string.theoplayer_ui_menu_audio), textAlign = TextAlign.Center, style = MaterialTheme.typography.titleMedium ) @@ -155,7 +161,7 @@ fun MenuScope.LanguageMenuExpanded() { modifier = Modifier .fillMaxWidth(1f) .padding(0.dp, 8.dp), - text = "Subtitles", + text = stringResource(R.string.theoplayer_ui_menu_subtitles), textAlign = TextAlign.Center, style = MaterialTheme.typography.titleMedium ) @@ -173,7 +179,7 @@ fun MenuScope.LanguageMenuExpanded() { @Composable fun MenuScope.AudioTrackMenu() { Menu( - title = { Text(text = "Audio") } + title = { Text(text = stringResource(R.string.theoplayer_ui_menu_audio)) } ) { AudioTrackList(onClick = { closeCurrentMenu() }) } @@ -187,7 +193,7 @@ fun MenuScope.AudioTrackMenu() { @Composable fun MenuScope.SubtitleMenu() { Menu( - title = { Text(text = "Subtitles") } + title = { Text(text = stringResource(R.string.theoplayer_ui_menu_subtitles)) } ) { SubtitleTrackList(onClick = { closeCurrentMenu() }) } diff --git a/ui/src/main/java/com/theoplayer/android/ui/LanguageMenuButton.kt b/ui/src/main/java/com/theoplayer/android/ui/LanguageMenuButton.kt index 99f5836..d736449 100644 --- a/ui/src/main/java/com/theoplayer/android/ui/LanguageMenuButton.kt +++ b/ui/src/main/java/com/theoplayer/android/ui/LanguageMenuButton.kt @@ -5,6 +5,7 @@ import androidx.compose.material3.Icon import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.res.painterResource +import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp /** @@ -21,7 +22,7 @@ fun MenuScope.LanguageMenuButton( content: @Composable () -> Unit = { Icon( painter = painterResource(id = R.drawable.language), - contentDescription = "Language" + contentDescription = stringResource(R.string.theoplayer_ui_menu_language) ) } ) { diff --git a/ui/src/main/java/com/theoplayer/android/ui/LiveButton.kt b/ui/src/main/java/com/theoplayer/android/ui/LiveButton.kt index ca1d1c3..68d2c41 100644 --- a/ui/src/main/java/com/theoplayer/android/ui/LiveButton.kt +++ b/ui/src/main/java/com/theoplayer/android/ui/LiveButton.kt @@ -14,6 +14,7 @@ import androidx.compose.material3.Text import androidx.compose.material3.TextButton import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier +import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp import com.theoplayer.android.ui.theme.THEOplayerTheme @@ -46,7 +47,7 @@ fun LiveButton( tint = THEOplayerTheme.playerColors.liveButtonLive, contentDescription = null ) - Text(text = " LIVE") + Text(text = " " + stringResource(R.string.theoplayer_ui_btn_live)) }, dvr: @Composable RowScope. () -> Unit = { Icon( @@ -55,13 +56,14 @@ fun LiveButton( tint = THEOplayerTheme.playerColors.liveButtonDvr, contentDescription = null ) - Text(text = " LIVE") + Text(text = " " + stringResource(R.string.theoplayer_ui_btn_live)) } ) { val player = Player.current if (player?.streamType == StreamType.Live || player?.streamType == StreamType.Dvr) { val isLive = - !player.paused && ((player.seekable.lastEnd ?: 0.0) - player.currentTime) <= liveThreshold + !player.paused && ((player.seekable.lastEnd + ?: 0.0) - player.currentTime) <= liveThreshold TextButton( modifier = modifier, contentPadding = contentPadding, diff --git a/ui/src/main/java/com/theoplayer/android/ui/Menu.kt b/ui/src/main/java/com/theoplayer/android/ui/Menu.kt index efbe422..49b6f1d 100644 --- a/ui/src/main/java/com/theoplayer/android/ui/Menu.kt +++ b/ui/src/main/java/com/theoplayer/android/ui/Menu.kt @@ -15,6 +15,7 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.remember import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.res.stringResource /** * The content for a new menu, typically this should draw a single [Menu]. @@ -38,7 +39,7 @@ fun MenuScope.Menu( backIcon: @Composable () -> Unit = { Icon( Icons.AutoMirrored.Rounded.ArrowBack, - contentDescription = "Back" + contentDescription = stringResource(R.string.theoplayer_ui_btn_back) ) }, content: @Composable () -> Unit, diff --git a/ui/src/main/java/com/theoplayer/android/ui/MuteButton.kt b/ui/src/main/java/com/theoplayer/android/ui/MuteButton.kt index aad606a..c892e07 100644 --- a/ui/src/main/java/com/theoplayer/android/ui/MuteButton.kt +++ b/ui/src/main/java/com/theoplayer/android/ui/MuteButton.kt @@ -7,6 +7,7 @@ import androidx.compose.material.icons.automirrored.rounded.VolumeUp import androidx.compose.material3.Icon import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier +import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp /** @@ -25,13 +26,13 @@ fun MuteButton( mute: @Composable () -> Unit = { Icon( Icons.AutoMirrored.Rounded.VolumeUp, - contentDescription = "Mute" + contentDescription = stringResource(R.string.theoplayer_ui_btn_mute) ) }, unmute: @Composable () -> Unit = { Icon( Icons.AutoMirrored.Rounded.VolumeOff, - contentDescription = "Unmute" + contentDescription = stringResource(R.string.theoplayer_ui_btn_unmute) ) } ) { diff --git a/ui/src/main/java/com/theoplayer/android/ui/PlayButton.kt b/ui/src/main/java/com/theoplayer/android/ui/PlayButton.kt index a0d6479..9e448fd 100644 --- a/ui/src/main/java/com/theoplayer/android/ui/PlayButton.kt +++ b/ui/src/main/java/com/theoplayer/android/ui/PlayButton.kt @@ -7,6 +7,7 @@ import androidx.compose.material3.Icon import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.res.painterResource +import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp /** @@ -29,21 +30,21 @@ fun PlayButton( Icon( painter = painterResource(id = R.drawable.play), modifier = iconModifier, - contentDescription = "Play" + contentDescription = stringResource(id = R.string.theoplayer_ui_btn_play) ) }, pause: @Composable () -> Unit = { Icon( painter = painterResource(id = R.drawable.pause), modifier = iconModifier, - contentDescription = "Pause" + contentDescription = stringResource(id = R.string.theoplayer_ui_btn_pause) ) }, replay: @Composable () -> Unit = { Icon( Icons.Rounded.Replay, modifier = iconModifier, - contentDescription = "Replay" + contentDescription = stringResource(id = R.string.theoplayer_ui_btn_replay) ) } ) { diff --git a/ui/src/main/java/com/theoplayer/android/ui/PlaybackRateList.kt b/ui/src/main/java/com/theoplayer/android/ui/PlaybackRateList.kt index ba98a15..81adba7 100644 --- a/ui/src/main/java/com/theoplayer/android/ui/PlaybackRateList.kt +++ b/ui/src/main/java/com/theoplayer/android/ui/PlaybackRateList.kt @@ -6,7 +6,9 @@ import androidx.compose.material3.ListItem import androidx.compose.material3.RadioButton import androidx.compose.material3.Text import androidx.compose.runtime.Composable +import androidx.compose.runtime.remember import androidx.compose.ui.Modifier +import androidx.compose.ui.res.stringResource import java.text.DecimalFormat /** @@ -47,12 +49,13 @@ fun PlaybackRateList( } } -private val playbackRateFormat = DecimalFormat("#.##") - +@Composable internal fun formatPlaybackRate(rate: Double): String { return if (rate == 1.0) { - "Normal" + stringResource(R.string.theoplayer_ui_playback_rate_normal, rate) } else { - "${playbackRateFormat.format(rate)}x" + val format = stringResource(R.string.theoplayer_ui_playback_rate_format) + val decimalFormat = remember(format) { DecimalFormat(format) } + decimalFormat.format(rate) } } \ No newline at end of file diff --git a/ui/src/main/java/com/theoplayer/android/ui/SeekButton.kt b/ui/src/main/java/com/theoplayer/android/ui/SeekButton.kt index 209d77f..86a09b4 100644 --- a/ui/src/main/java/com/theoplayer/android/ui/SeekButton.kt +++ b/ui/src/main/java/com/theoplayer/android/ui/SeekButton.kt @@ -12,6 +12,7 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.scale +import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp @@ -50,9 +51,9 @@ fun SeekButton( .size(iconSize) .scale(scaleX = if (seekOffset >= 0) -1f else 1f, scaleY = 1f), contentDescription = if (seekOffset >= 0) { - "Seek forward by $seekOffset seconds" + stringResource(R.string.theoplayer_ui_btn_seek_forward, seekOffset) } else { - "Seek backward by $seekOffset seconds" + stringResource(R.string.theoplayer_ui_btn_seek_backward, seekOffset) } ) Text( diff --git a/ui/src/main/java/com/theoplayer/android/ui/SettingsMenu.kt b/ui/src/main/java/com/theoplayer/android/ui/SettingsMenu.kt index 0232429..65aa532 100644 --- a/ui/src/main/java/com/theoplayer/android/ui/SettingsMenu.kt +++ b/ui/src/main/java/com/theoplayer/android/ui/SettingsMenu.kt @@ -11,6 +11,7 @@ import androidx.compose.material3.Text import androidx.compose.material3.TextButton import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier +import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp import com.theoplayer.android.api.player.track.mediatrack.quality.VideoQuality @@ -24,11 +25,11 @@ import com.theoplayer.android.api.player.track.mediatrack.quality.VideoQuality @Composable fun MenuScope.SettingsMenu() { Menu( - title = { Text(text = "Settings") }, + title = { Text(text = stringResource(R.string.theoplayer_ui_menu_settings)) }, backIcon = { Icon( Icons.Rounded.Close, - contentDescription = "Close" + contentDescription = stringResource(R.string.theoplayer_ui_btn_menu_close) ) }, ) { @@ -39,7 +40,7 @@ fun MenuScope.SettingsMenu() { modifier = Modifier .weight(1f) .alignByBaseline(), - text = "Quality" + text = stringResource(R.string.theoplayer_ui_menu_quality) ) TextButton( modifier = Modifier @@ -66,7 +67,7 @@ fun MenuScope.SettingsMenu() { modifier = Modifier .weight(1f) .alignByBaseline(), - text = "Playback speed" + text = stringResource(R.string.theoplayer_ui_menu_playback_rate) ) TextButton( modifier = Modifier @@ -97,7 +98,7 @@ fun MenuScope.SettingsMenu() { @Composable fun MenuScope.QualityMenu() { Menu( - title = { Text(text = "Quality") } + title = { Text(text = stringResource(R.string.theoplayer_ui_menu_quality)) } ) { QualityList(onClick = { closeCurrentMenu() }) } @@ -111,7 +112,7 @@ fun MenuScope.QualityMenu() { @Composable fun MenuScope.PlaybackRateMenu() { Menu( - title = { Text(text = "Playback speed") } + title = { Text(text = stringResource(R.string.theoplayer_ui_menu_playback_rate)) } ) { PlaybackRateList(onClick = { closeCurrentMenu() }) } diff --git a/ui/src/main/java/com/theoplayer/android/ui/SettingsMenuButton.kt b/ui/src/main/java/com/theoplayer/android/ui/SettingsMenuButton.kt index e9f92d2..7a10fd0 100644 --- a/ui/src/main/java/com/theoplayer/android/ui/SettingsMenuButton.kt +++ b/ui/src/main/java/com/theoplayer/android/ui/SettingsMenuButton.kt @@ -6,6 +6,7 @@ import androidx.compose.material.icons.rounded.Settings import androidx.compose.material3.Icon import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier +import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp /** @@ -22,7 +23,7 @@ fun MenuScope.SettingsMenuButton( content: @Composable () -> Unit = { Icon( Icons.Rounded.Settings, - contentDescription = "Settings" + contentDescription = stringResource(R.string.theoplayer_ui_menu_settings) ) } ) { diff --git a/ui/src/main/res/values/strings.xml b/ui/src/main/res/values/strings.xml index 73862c4..c8dd5fc 100644 --- a/ui/src/main/res/values/strings.xml +++ b/ui/src/main/res/values/strings.xml @@ -1 +1,69 @@ - \ No newline at end of file + + Play + Pause + Replay + Start casting + Stop casting + Enter fullscreen + Exit fullscreen + Close + Back + Mute + Unmute + Seek forward by %1$s seconds + Seek backward by %1$s seconds + LIVE + + + %1$s + + %1$s + + %1$s / %2$s + + %1$s / %2$s + + + Playing on %1$s + + Playing on + %1$s + + Playing on Chromecast + + Playing on + Chromecast + + + Language + + Settings + + Audio + + None + + Subtitles + + Off + + Playback speed + + Quality + + + Normal + + #.##x + + + An error occurred + \ No newline at end of file From 9d0a5b5dca40c8f886f836e9c72c500bc10d588b Mon Sep 17 00:00:00 2001 From: Mattias Buelens Date: Thu, 12 Dec 2024 14:39:47 +0100 Subject: [PATCH 02/13] Make more strings localizable --- .../java/com/theoplayer/android/ui/Helper.kt | 5 ++- .../com/theoplayer/android/ui/LanguageMenu.kt | 4 +-- .../com/theoplayer/android/ui/QualityList.kt | 35 ++++++++++++------- .../com/theoplayer/android/ui/SettingsMenu.kt | 17 +++++++-- .../android/ui/SubtitleTrackList.kt | 3 +- ui/src/main/res/values/strings.xml | 27 +++++++++++--- 6 files changed, 68 insertions(+), 23 deletions(-) diff --git a/ui/src/main/java/com/theoplayer/android/ui/Helper.kt b/ui/src/main/java/com/theoplayer/android/ui/Helper.kt index 7605c07..86df6b5 100644 --- a/ui/src/main/java/com/theoplayer/android/ui/Helper.kt +++ b/ui/src/main/java/com/theoplayer/android/ui/Helper.kt @@ -1,5 +1,7 @@ package com.theoplayer.android.ui +import androidx.compose.runtime.Composable +import androidx.compose.ui.res.stringResource import com.theoplayer.android.api.player.track.Track import java.util.Locale import kotlin.math.absoluteValue @@ -60,6 +62,7 @@ fun formatTime(time: Double, guide: Double = 0.0, preferNegative: Boolean = fals * * @param track the media track or text track */ +@Composable fun formatTrackLabel(track: Track): String { val label = track.label if (!label.isNullOrEmpty()) { @@ -74,5 +77,5 @@ fun formatTrackLabel(track: Track): String { } return languageCode } - return "" + return stringResource(R.string.theoplayer_ui_track_unknown) } \ No newline at end of file diff --git a/ui/src/main/java/com/theoplayer/android/ui/LanguageMenu.kt b/ui/src/main/java/com/theoplayer/android/ui/LanguageMenu.kt index a7a6ae2..c3824d4 100644 --- a/ui/src/main/java/com/theoplayer/android/ui/LanguageMenu.kt +++ b/ui/src/main/java/com/theoplayer/android/ui/LanguageMenu.kt @@ -88,7 +88,7 @@ fun MenuScope.LanguageMenuCompact() { modifier = Modifier.weight(1f), text = player?.activeAudioTrack?.let { formatTrackLabel(it) } ?: stringResource( - R.string.theoplayer_ui_menu_audio_none + R.string.theoplayer_ui_audio_none ), textAlign = TextAlign.Center ) @@ -116,7 +116,7 @@ fun MenuScope.LanguageMenuCompact() { Text( modifier = Modifier.weight(1f), text = player?.activeSubtitleTrack?.let { formatTrackLabel(it) } ?: stringResource( - R.string.theoplayer_ui_menu_subtitles_off + R.string.theoplayer_ui_subtitles_off ), textAlign = TextAlign.Center ) diff --git a/ui/src/main/java/com/theoplayer/android/ui/QualityList.kt b/ui/src/main/java/com/theoplayer/android/ui/QualityList.kt index 01a937d..29cc90e 100644 --- a/ui/src/main/java/com/theoplayer/android/ui/QualityList.kt +++ b/ui/src/main/java/com/theoplayer/android/ui/QualityList.kt @@ -6,7 +6,9 @@ import androidx.compose.material3.ListItem import androidx.compose.material3.RadioButton import androidx.compose.material3.Text import androidx.compose.runtime.Composable +import androidx.compose.runtime.remember import androidx.compose.ui.Modifier +import androidx.compose.ui.res.stringResource import java.text.DecimalFormat /** @@ -26,7 +28,7 @@ fun QualityList( LazyColumn(modifier = modifier) { item(key = null) { ListItem( - headlineContent = { Text(text = "Automatic") }, + headlineContent = { Text(text = stringResource(R.string.theoplayer_ui_quality_automatic)) }, leadingContent = { RadioButton( selected = (targetVideoQuality == null), @@ -45,7 +47,14 @@ fun QualityList( ) { val quality = videoQualities[it] ListItem( - headlineContent = { Text(text = "${quality.height}p") }, + headlineContent = { + Text( + text = stringResource( + R.string.theoplayer_ui_quality_with_height, + quality.height + ) + ) + }, supportingContent = { Text(text = formatBandwidth(quality.bandwidth)) }, leadingContent = { RadioButton( @@ -62,15 +71,17 @@ fun QualityList( } } -private val zeroPrecisionFormat = DecimalFormat("#") -private val singlePrecisionFormat = DecimalFormat("#.#") - +@Composable internal fun formatBandwidth(bandwidth: Long): String { - return if (bandwidth > 1e7) { - "${zeroPrecisionFormat.format(bandwidth / 1e6)}Mbps" - } else if (bandwidth > 1e6) { - "${singlePrecisionFormat.format(bandwidth / 1e6)}Mbps" - } else { - "${zeroPrecisionFormat.format(bandwidth / 1e3)}kbps" - } + val format = stringResource( + if (bandwidth >= 1e7) { + R.string.theoplayer_ui_bandwidth_format_10mbps + } else if (bandwidth >= 1e6) { + R.string.theoplayer_ui_bandwidth_format_1mbps + } else { + R.string.theoplayer_ui_bandwidth_format_kbps + } + ) + val decimalFormat = remember(format) { DecimalFormat(format) } + return decimalFormat.format(bandwidth / (if (bandwidth >= 1e6) 1e6 else 1e3)) } \ No newline at end of file diff --git a/ui/src/main/java/com/theoplayer/android/ui/SettingsMenu.kt b/ui/src/main/java/com/theoplayer/android/ui/SettingsMenu.kt index 65aa532..1279685 100644 --- a/ui/src/main/java/com/theoplayer/android/ui/SettingsMenu.kt +++ b/ui/src/main/java/com/theoplayer/android/ui/SettingsMenu.kt @@ -118,11 +118,22 @@ fun MenuScope.PlaybackRateMenu() { } } +@Composable internal fun formatActiveQualityLabel( targetVideoQuality: VideoQuality?, activeVideoQuality: VideoQuality? ): String { - return targetVideoQuality?.let { "${it.height}p" } - ?: activeVideoQuality?.let { "Automatic (${it.height}p)" } - ?: "Automatic" + return if (targetVideoQuality != null) { + stringResource( + R.string.theoplayer_ui_quality_with_height, + targetVideoQuality.height + ) + } else if (activeVideoQuality != null) { + stringResource( + R.string.theoplayer_ui_quality_automatic_with_height, + activeVideoQuality.height + ) + } else { + stringResource(R.string.theoplayer_ui_quality_automatic) + } } \ No newline at end of file diff --git a/ui/src/main/java/com/theoplayer/android/ui/SubtitleTrackList.kt b/ui/src/main/java/com/theoplayer/android/ui/SubtitleTrackList.kt index 1a900c5..8e70f19 100644 --- a/ui/src/main/java/com/theoplayer/android/ui/SubtitleTrackList.kt +++ b/ui/src/main/java/com/theoplayer/android/ui/SubtitleTrackList.kt @@ -7,6 +7,7 @@ import androidx.compose.material3.RadioButton import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier +import androidx.compose.ui.res.stringResource /** * A list of subtitle tracks, from which the user can choose an active subtitle track. @@ -25,7 +26,7 @@ fun SubtitleTrackList( LazyColumn(modifier = modifier) { item(key = null) { ListItem( - headlineContent = { Text(text = "Off") }, + headlineContent = { Text(text = stringResource(R.string.theoplayer_ui_subtitles_off)) }, leadingContent = { RadioButton( selected = (activeSubtitleTrack == null), diff --git a/ui/src/main/res/values/strings.xml b/ui/src/main/res/values/strings.xml index c8dd5fc..4173bdd 100644 --- a/ui/src/main/res/values/strings.xml +++ b/ui/src/main/res/values/strings.xml @@ -45,17 +45,19 @@ Settings Audio - - None Subtitles - - Off Playback speed Quality + + None + + + Off + Normal #.##x + + %1$sp + + Automatic + + Automatic (%1$sp) + + + #Mbps + + #.#Mbps + + #kbps + + + Unknown + An error occurred \ No newline at end of file From 6b2e662ad1073e372161627f1c2656e9114c2ee5 Mon Sep 17 00:00:00 2001 From: Mattias Buelens Date: Thu, 12 Dec 2024 14:53:51 +0100 Subject: [PATCH 03/13] Add Dutch translation to demo --- app/src/main/res/values-en/strings.xml | 3 --- app/src/main/res/values-nl/strings.xml | 36 ++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 3 deletions(-) delete mode 100644 app/src/main/res/values-en/strings.xml create mode 100644 app/src/main/res/values-nl/strings.xml diff --git a/app/src/main/res/values-en/strings.xml b/app/src/main/res/values-en/strings.xml deleted file mode 100644 index 497968c..0000000 --- a/app/src/main/res/values-en/strings.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml new file mode 100644 index 0000000..4fe60ba --- /dev/null +++ b/app/src/main/res/values-nl/strings.xml @@ -0,0 +1,36 @@ + + + THEOplayer Open Video UI voor Android Demo + Afspelen + Pauzeren + Opnieuw spelen + Starten met casten + Stop casting + Volledig scherm + Volledig scherm sluiten + Sluiten + Terug + Dempen + Dempen opheffen + Spring vooruit met %1$s seconden + Spring terug met %1$s seconden + LIVE + Speelt op %1$s + Speelt op + Speelt op Chromecast + Speelt op + Chromecast + Taal + Instellingen + Audio + Ondertitels + Afspeelsnelheid + Kwaliteit + Geen + Uit + Normaal + Automatisch + Automatisch (%1$sp) + Onbekend + Fout + \ No newline at end of file From 9b44e20e998dd617d17e4db92224c2104bc89441 Mon Sep 17 00:00:00 2001 From: Mattias Buelens Date: Thu, 12 Dec 2024 15:46:12 +0100 Subject: [PATCH 04/13] Use plurals for SeekButton content --- app/src/main/res/values-nl/strings.xml | 10 ++++++++-- .../java/com/theoplayer/android/ui/SeekButton.kt | 16 ++++++++++------ ui/src/main/res/values/strings.xml | 10 ++++++++-- 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index 4fe60ba..bfbf216 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -12,8 +12,14 @@ Terug Dempen Dempen opheffen - Spring vooruit met %1$s seconden - Spring terug met %1$s seconden + + Spring %1$s seconde vooruit + Spring %1$s seconden vooruit + + + Spring %1$s seconde achteruit + Spring %1$s seconden achteruit + LIVE Speelt op %1$s Speelt op diff --git a/ui/src/main/java/com/theoplayer/android/ui/SeekButton.kt b/ui/src/main/java/com/theoplayer/android/ui/SeekButton.kt index 86a09b4..74e179f 100644 --- a/ui/src/main/java/com/theoplayer/android/ui/SeekButton.kt +++ b/ui/src/main/java/com/theoplayer/android/ui/SeekButton.kt @@ -12,7 +12,7 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.scale -import androidx.compose.ui.res.stringResource +import androidx.compose.ui.res.pluralStringResource import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp @@ -50,11 +50,15 @@ fun SeekButton( modifier = Modifier .size(iconSize) .scale(scaleX = if (seekOffset >= 0) -1f else 1f, scaleY = 1f), - contentDescription = if (seekOffset >= 0) { - stringResource(R.string.theoplayer_ui_btn_seek_forward, seekOffset) - } else { - stringResource(R.string.theoplayer_ui_btn_seek_backward, seekOffset) - } + contentDescription = pluralStringResource( + if (seekOffset >= 0) { + R.plurals.theoplayer_ui_btn_seek_forward + } else { + R.plurals.theoplayer_ui_btn_seek_backward + }, + seekOffset, + seekOffset + ) ) Text( modifier = Modifier diff --git a/ui/src/main/res/values/strings.xml b/ui/src/main/res/values/strings.xml index 4173bdd..e4cdaf6 100644 --- a/ui/src/main/res/values/strings.xml +++ b/ui/src/main/res/values/strings.xml @@ -10,8 +10,14 @@ Back Mute Unmute - Seek forward by %1$s seconds - Seek backward by %1$s seconds + + Seek forward by %1$s second + Seek forward by %1$s seconds + + + Seek backward by %1$s second + Seek backward by %1$s seconds + LIVE From eebebd4435725429ccc7ddb1730ff77867c6d5cf Mon Sep 17 00:00:00 2001 From: Mattias Buelens Date: Thu, 12 Dec 2024 15:47:01 +0100 Subject: [PATCH 05/13] Fix SeekButton description --- ui/src/main/java/com/theoplayer/android/ui/SeekButton.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/src/main/java/com/theoplayer/android/ui/SeekButton.kt b/ui/src/main/java/com/theoplayer/android/ui/SeekButton.kt index 74e179f..2b3bf32 100644 --- a/ui/src/main/java/com/theoplayer/android/ui/SeekButton.kt +++ b/ui/src/main/java/com/theoplayer/android/ui/SeekButton.kt @@ -56,8 +56,8 @@ fun SeekButton( } else { R.plurals.theoplayer_ui_btn_seek_backward }, - seekOffset, - seekOffset + seekOffset.absoluteValue, + seekOffset.absoluteValue ) ) Text( From c0f94e210bc41961ad12f764a149e6e93dfacc3c Mon Sep 17 00:00:00 2001 From: Mattias Buelens Date: Thu, 12 Dec 2024 15:54:33 +0100 Subject: [PATCH 06/13] Tweaks --- app/src/main/res/values-nl/strings.xml | 10 +++++----- ui/src/main/res/values/strings.xml | 27 +++++++++++++++++--------- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index bfbf216..c25c4f4 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -13,12 +13,12 @@ Dempen Dempen opheffen - Spring %1$s seconde vooruit - Spring %1$s seconden vooruit + Spring %1$d seconde vooruit + Spring %1$d seconden vooruit - Spring %1$s seconde achteruit - Spring %1$s seconden achteruit + Spring %1$d seconde achteruit + Spring %1$d seconden achteruit LIVE Speelt op %1$s @@ -36,7 +36,7 @@ Uit Normaal Automatisch - Automatisch (%1$sp) + Automatisch (%1$dp) Onbekend Fout \ No newline at end of file diff --git a/ui/src/main/res/values/strings.xml b/ui/src/main/res/values/strings.xml index e4cdaf6..e950ac1 100644 --- a/ui/src/main/res/values/strings.xml +++ b/ui/src/main/res/values/strings.xml @@ -11,12 +11,12 @@ Mute Unmute - Seek forward by %1$s second - Seek forward by %1$s seconds + Seek forward by %1$d second + Seek forward by %1$d seconds - Seek backward by %1$s second - Seek backward by %1$s seconds + Seek backward by %1$d second + Seek backward by %1$d seconds LIVE @@ -73,17 +73,26 @@ #.##x - %1$sp + %1$dp Automatic - Automatic (%1$sp) + Automatic (%1$dp) - + #Mbps - + #.#Mbps - + #kbps From 36d90a1303de4f14f8b20ee3b55c1bec64a7426a Mon Sep 17 00:00:00 2001 From: Mattias Buelens Date: Fri, 13 Dec 2024 16:43:53 +0100 Subject: [PATCH 07/13] Prefer negative times for remaining time display --- .../main/java/com/theoplayer/android/ui/CurrentTimeDisplay.kt | 4 ++-- ui/src/main/java/com/theoplayer/android/ui/Helper.kt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ui/src/main/java/com/theoplayer/android/ui/CurrentTimeDisplay.kt b/ui/src/main/java/com/theoplayer/android/ui/CurrentTimeDisplay.kt index fb392e5..c5187de 100644 --- a/ui/src/main/java/com/theoplayer/android/ui/CurrentTimeDisplay.kt +++ b/ui/src/main/java/com/theoplayer/android/ui/CurrentTimeDisplay.kt @@ -37,7 +37,7 @@ fun CurrentTimeDisplay( } else { R.string.theoplayer_ui_current_time_with_duration }, - formatTime(time, duration), + formatTime(time, duration, preferNegative = showRemaining), formatTime(duration) ) } else { @@ -47,7 +47,7 @@ fun CurrentTimeDisplay( } else { R.string.theoplayer_ui_current_time }, - formatTime(time, duration), + formatTime(time, duration, preferNegative = showRemaining), ) } diff --git a/ui/src/main/java/com/theoplayer/android/ui/Helper.kt b/ui/src/main/java/com/theoplayer/android/ui/Helper.kt index 86df6b5..cef88a0 100644 --- a/ui/src/main/java/com/theoplayer/android/ui/Helper.kt +++ b/ui/src/main/java/com/theoplayer/android/ui/Helper.kt @@ -18,7 +18,7 @@ import kotlin.math.absoluteValue * for example because it represents the time remaining in the video. */ fun formatTime(time: Double, guide: Double = 0.0, preferNegative: Boolean = false): String { - val isNegative = time < 0 || (preferNegative && time == 0.0); + val isNegative = time < 0 || (preferNegative && time == 0.0) val absoluteTime = time.absoluteValue.toInt() val guideMinutes = ((guide / 60) % 60).toInt() From 24efccb441ebd16cf0634ae39952c55614d37229 Mon Sep 17 00:00:00 2001 From: Mattias Buelens Date: Fri, 13 Dec 2024 16:59:52 +0100 Subject: [PATCH 08/13] Add tags around non-translatable parts See https://developer.android.com/guide/topics/resources/localization#mark-message-parts --- ui/src/main/res/values/strings.xml | 35 +++++++++++++----------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/ui/src/main/res/values/strings.xml b/ui/src/main/res/values/strings.xml index e950ac1..4e7355e 100644 --- a/ui/src/main/res/values/strings.xml +++ b/ui/src/main/res/values/strings.xml @@ -1,4 +1,4 @@ - + Play Pause Replay @@ -11,35 +11,30 @@ Mute Unmute - Seek forward by %1$d second - Seek forward by %1$d seconds + Seek forward by %1$d second + Seek forward by %1$d seconds - Seek backward by %1$d second - Seek backward by %1$d seconds + Seek backward by %1$d second + Seek backward by %1$d seconds LIVE - %1$s + %1$s - %1$s + %1$s - %1$s / %2$s + %1$s / %2$s - %1$s / %2$s + %1$s / %2$s - - Playing on %1$s + + Playing on %1$s Playing on - %1$s - + %1$s + Playing on Chromecast Playing on @@ -73,11 +68,11 @@ #.##x - %1$dp + %1$dp Automatic - Automatic (%1$dp) + Automatic (%1$dp) + + ``` + + :::tip + You can also use + the [Translations Editor in Android Studio](https://developer.android.com/studio/write/translations-editor) + to edit these values. + ::: + +3. Build and run your app. The translated texts should now appear in your player UI. + +## Add alternative languages {#add-alternative-languages} + +If your app targets many audiences speaking different languages, you can add multiple translations using +locale-specific resources. + +1. Copy the English string resources + from [`res/values/strings.xml`](https://github.com/THEOplayer/android-ui/blob/main/ui/src/main/res/values/strings.xml) + to your app's resources for the default locale (i.e. `res/values/strings.xml`). +2. Add a new string resources file for a new locale. + For example, for French, create the file: `res/values-fr/strings.xml`. +3. Add translated versions for each English string resource to the new resources file. + For example, to translate the title of the "Language" menu, you would add an entry for `theoplayer_ui_menu_language`: + ```xml title="res/values-fr/strings.xml" + + Langue + + ``` + +## Remarks + +### Update translations when upgrading Open Video UI + +Newer versions of the Open Video UI for Android may add new string resources that need to be translated. + +When using custom translations in your app, we recommend pinning the `com.theoplayer.android-ui:android-ui` dependency +in your app's `build.gradle` to a specific version. Avoid using `+` in the dependency's version range. + +```groovy title="build.gradle" +dependencies { + implementation "com.theoplayer.android-ui:android-ui:1.9.0" +} +``` + +When you decide to upgrade Open Video UI to the latest version, make sure to also update your translations. +Check the history for [`res/values/strings.xml`](https://github.com/THEOplayer/android-ui/commits/main/ui/src/main/res/values/strings.xml) +to see whether any string resources were added or changed since the previous version. + +## More information + +- [Localize your app on Android Developers](https://developer.android.com/guide/topics/resources/localization) +- [Support different languages and cultures on Android Developers](https://developer.android.com/training/basics/supporting-devices/languages) From 21d5ec22697cd30d7ea3a3b2c25c022d1c85bf32 Mon Sep 17 00:00:00 2001 From: Mattias Buelens Date: Mon, 16 Dec 2024 15:13:44 +0100 Subject: [PATCH 11/13] Tweak LiveButton alignment --- .../com/theoplayer/android/ui/LiveButton.kt | 29 ++++++++++++++++--- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/ui/src/main/java/com/theoplayer/android/ui/LiveButton.kt b/ui/src/main/java/com/theoplayer/android/ui/LiveButton.kt index 68d2c41..ad0ad9f 100644 --- a/ui/src/main/java/com/theoplayer/android/ui/LiveButton.kt +++ b/ui/src/main/java/com/theoplayer/android/ui/LiveButton.kt @@ -2,7 +2,9 @@ package com.theoplayer.android.ui import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.RowScope +import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.size +import androidx.compose.foundation.layout.width import androidx.compose.material.icons.Icons import androidx.compose.material.icons.rounded.Circle import androidx.compose.material3.ButtonColors @@ -13,6 +15,7 @@ import androidx.compose.material3.IconButtonDefaults import androidx.compose.material3.Text import androidx.compose.material3.TextButton import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp @@ -43,20 +46,38 @@ fun LiveButton( live: @Composable RowScope.() -> Unit = { Icon( Icons.Rounded.Circle, - modifier = Modifier.size(12.dp), + modifier = Modifier + .size(12.dp) + .align(Alignment.CenterVertically), tint = THEOplayerTheme.playerColors.liveButtonLive, contentDescription = null ) - Text(text = " " + stringResource(R.string.theoplayer_ui_btn_live)) + Spacer( + modifier = Modifier + .width(4.dp) + ) + Text( + modifier = Modifier.align(Alignment.CenterVertically), + text = stringResource(R.string.theoplayer_ui_btn_live) + ) }, dvr: @Composable RowScope. () -> Unit = { Icon( Icons.Rounded.Circle, - modifier = Modifier.size(12.dp), + modifier = Modifier + .size(12.dp) + .align(Alignment.CenterVertically), tint = THEOplayerTheme.playerColors.liveButtonDvr, contentDescription = null ) - Text(text = " " + stringResource(R.string.theoplayer_ui_btn_live)) + Spacer( + modifier = Modifier + .width(4.dp) + ) + Text( + modifier = Modifier.align(Alignment.CenterVertically), + text = stringResource(R.string.theoplayer_ui_btn_live) + ) } ) { val player = Player.current From 45fd7ae9efb23dda54f7e889cc784bbfe2376734 Mon Sep 17 00:00:00 2001 From: Mattias Buelens Date: Mon, 16 Dec 2024 15:32:16 +0100 Subject: [PATCH 12/13] Copy default string resources to app --- app/src/main/res/values/strings.xml | 52 ++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 3d1a3a8..d696adc 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,3 +1,53 @@ - + THEOplayer Open Video UI for Android Demo + + + Play + Pause + Replay + Start casting + Stop casting + Enter fullscreen + Exit fullscreen + Close + Back + Mute + Unmute + + Seek forward by %1$d second + Seek forward by %1$d seconds + + + Seek backward by %1$d second + Seek backward by %1$d seconds + + LIVE + %1$s + %1$s + %1$s / %2$s + %1$s / %2$s + Playing on %1$s + Playing on + %1$s + Playing on Chromecast + Playing on + Chromecast + Language + Settings + Audio + Subtitles + Playback speed + Quality + None + Off + Normal + #.##x + Automatic + %1$dp + Automatic (%1$dp) + #Mbps + #.#Mbps + #kbps + Unknown + An error occurred \ No newline at end of file From 63ecbf623a56a9c9220cb5bf49c2ce0f5aa1246d Mon Sep 17 00:00:00 2001 From: Mattias Buelens Date: Mon, 16 Dec 2024 15:36:28 +0100 Subject: [PATCH 13/13] Set locale on resource files --- app/src/main/res/values-nl/strings.xml | 2 +- app/src/main/res/values/strings.xml | 2 +- ui/src/main/res/values/strings.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index c25c4f4..e3a7129 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -1,5 +1,5 @@ - + THEOplayer Open Video UI voor Android Demo Afspelen Pauzeren diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index d696adc..611cf98 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,4 +1,4 @@ - + THEOplayer Open Video UI for Android Demo diff --git a/ui/src/main/res/values/strings.xml b/ui/src/main/res/values/strings.xml index 4e7355e..98c3479 100644 --- a/ui/src/main/res/values/strings.xml +++ b/ui/src/main/res/values/strings.xml @@ -1,4 +1,4 @@ - + Play Pause Replay