add translatable strings to VideoPlayerUI

This commit is contained in:
Christian Schabesberger 2024-07-03 13:25:32 +02:00
parent 1b72a1b2b7
commit d8e7c5880c
2 changed files with 68 additions and 52 deletions

View File

@ -26,7 +26,6 @@ import androidx.compose.material.icons.filled.SkipNext
import androidx.compose.material.icons.filled.SkipPrevious import androidx.compose.material.icons.filled.SkipPrevious
import androidx.compose.material.icons.filled.Subtitles import androidx.compose.material.icons.filled.Subtitles
import androidx.compose.material.icons.filled.Translate import androidx.compose.material.icons.filled.Translate
import androidx.compose.material.icons.filled.VolumeUp
import androidx.compose.material3.Button import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.DropdownMenu import androidx.compose.material3.DropdownMenu
@ -48,11 +47,13 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.layout.onPlaced import androidx.compose.ui.layout.onPlaced
import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.DpOffset import androidx.compose.ui.unit.DpOffset
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp import androidx.compose.ui.unit.sp
import net.newpipe.newplayer.R
import net.newpipe.newplayer.ui.theme.VideoPlayerTheme import net.newpipe.newplayer.ui.theme.VideoPlayerTheme
import net.newpipe.newplayer.ui.theme.video_player_onSurface import net.newpipe.newplayer.ui.theme.video_player_onSurface
@ -130,7 +131,7 @@ private fun TopUI(modifier: Modifier) {
) { ) {
Icon( Icon(
imageVector = Icons.AutoMirrored.Filled.MenuBook, imageVector = Icons.AutoMirrored.Filled.MenuBook,
contentDescription = "Chapter Selection" contentDescription = stringResource(R.string.widget_description_chapter_selection)
) )
} }
IconButton( IconButton(
@ -138,7 +139,7 @@ private fun TopUI(modifier: Modifier) {
) { ) {
Icon( Icon(
imageVector = Icons.AutoMirrored.Filled.List, imageVector = Icons.AutoMirrored.Filled.List,
contentDescription = "Playlist Selection" contentDescription = stringResource(R.string.widget_descriptoin_playlist_item_selection)
) )
} }
MainMenu() MainMenu()
@ -165,7 +166,7 @@ private fun MainMenu() {
}) { }) {
Icon( Icon(
imageVector = Icons.Filled.MoreVert, imageVector = Icons.Filled.MoreVert,
contentDescription = "More settings" contentDescription = stringResource(R.string.menu_item_more_settings)
) )
} }
DropdownMenu( DropdownMenu(
@ -174,56 +175,56 @@ private fun MainMenu() {
expanded = showMainMenu, expanded = showMainMenu,
onDismissRequest = { showMainMenu = false }) { onDismissRequest = { showMainMenu = false }) {
DropdownMenuItem( DropdownMenuItem(
text = { Text("Open in browser") }, text = { Text(stringResource(R.string.menu_item_open_in_browser)) },
leadingIcon = { leadingIcon = {
Icon( Icon(
imageVector = Icons.Filled.Language, imageVector = Icons.Filled.Language,
contentDescription = "Open In Browser" contentDescription = stringResource(R.string.menu_item_open_in_browser)
) )
}, },
onClick = { /*TODO*/ showMainMenu = false }) onClick = { /*TODO*/ showMainMenu = false })
DropdownMenuItem( DropdownMenuItem(
text = { Text("Share Timestamp") }, text = { Text(stringResource(R.string.menu_item_share_timestamp)) },
leadingIcon = { leadingIcon = {
Icon( Icon(
imageVector = Icons.Filled.Share, imageVector = Icons.Filled.Share,
contentDescription = "Share Time Stamp" contentDescription = stringResource(R.string.menu_item_share_timestamp)
) )
}, },
onClick = { /*TODO*/ showMainMenu = false }) onClick = { /*TODO*/ showMainMenu = false })
DropdownMenuItem( DropdownMenuItem(
text = { Text("Mute") }, text = { Text(stringResource(R.string.mute)) },
leadingIcon = { leadingIcon = {
Icon( Icon(
imageVector = Icons.AutoMirrored.Filled.VolumeUp, imageVector = Icons.AutoMirrored.Filled.VolumeUp,
contentDescription = "Mute" contentDescription = stringResource(R.string.mute)
) )
}, },
onClick = { /*TODO*/ showMainMenu = false }) onClick = { /*TODO*/ showMainMenu = false })
DropdownMenuItem( DropdownMenuItem(
text = { Text("Fit Screen") }, text = { Text(stringResource(R.string.menu_item_fit_screen)) },
leadingIcon = { leadingIcon = {
Icon( Icon(
imageVector = Icons.Filled.FitScreen, imageVector = Icons.Filled.FitScreen,
contentDescription = "Fit Screen" contentDescription = stringResource(R.string.menu_item_fit_screen)
) )
}, },
onClick = { /*TODO*/ showMainMenu = false }) onClick = { /*TODO*/ showMainMenu = false })
DropdownMenuItem( DropdownMenuItem(
text = { Text("Sub Titles") }, text = { Text(stringResource(R.string.menu_item_sub_titles)) },
leadingIcon = { leadingIcon = {
Icon( Icon(
imageVector = Icons.Filled.Subtitles, imageVector = Icons.Filled.Subtitles,
contentDescription = "Sub Titles" contentDescription = stringResource(R.string.menu_item_sub_titles)
) )
}, },
onClick = { /*TODO*/ showMainMenu = false }) onClick = { /*TODO*/ showMainMenu = false })
DropdownMenuItem( DropdownMenuItem(
text = { Text("Language") }, text = { Text(stringResource(R.string.menu_item_language)) },
leadingIcon = { leadingIcon = {
Icon( Icon(
imageVector = Icons.Filled.Translate, imageVector = Icons.Filled.Translate,
contentDescription = "Language" contentDescription = stringResource(R.string.menu_item_language)
) )
}, },
onClick = { /*TODO*/ showMainMenu = false }) onClick = { /*TODO*/ showMainMenu = false })
@ -247,7 +248,7 @@ private fun CenterUI(modifier: Modifier) {
buttonModifier = Modifier.size(80.dp), buttonModifier = Modifier.size(80.dp),
iconModifier = Modifier.size(40.dp), iconModifier = Modifier.size(40.dp),
icon = Icons.Filled.SkipPrevious, icon = Icons.Filled.SkipPrevious,
contentDescriptoion = "Previous Stream", contentDescriptoion = stringResource(R.string.widget_description_previous_stream),
onClick = {} onClick = {}
) )
@ -255,14 +256,14 @@ private fun CenterUI(modifier: Modifier) {
buttonModifier = Modifier.size(80.dp), buttonModifier = Modifier.size(80.dp),
iconModifier = Modifier.size(60.dp), iconModifier = Modifier.size(60.dp),
icon = Icons.Filled.PlayArrow, icon = Icons.Filled.PlayArrow,
contentDescriptoion = "Previous Stream", contentDescriptoion = stringResource(R.string.widget_description_play),
onClick = {} onClick = {}
) )
CenterControllButton( CenterControllButton(
buttonModifier = Modifier.size(80.dp), buttonModifier = Modifier.size(80.dp),
iconModifier = Modifier.size(40.dp), iconModifier = Modifier.size(40.dp),
icon = Icons.Filled.SkipNext, icon = Icons.Filled.SkipNext,
contentDescriptoion = "Next Stream", contentDescriptoion = stringResource(R.string.widget_description_next_stream),
onClick = {} onClick = {}
) )
} }
@ -310,13 +311,13 @@ private fun BottomUI(modifier: Modifier) {
horizontalArrangement = Arrangement.SpaceBetween, horizontalArrangement = Arrangement.SpaceBetween,
modifier = modifier modifier = modifier
) { ) {
Text("06:45") Text("00:06:45")
Slider(value = 0.4F, onValueChange = {}, modifier = Modifier.weight(1F)) Slider(value = 0.4F, onValueChange = {}, modifier = Modifier.weight(1F))
Text("09:40") Text("00:09:40")
IconButton(onClick = { isFullscreen = !isFullscreen }) { IconButton(onClick = { isFullscreen = !isFullscreen }) {
Icon( Icon(
imageVector = Icons.Filled.Fullscreen, imageVector = Icons.Filled.Fullscreen,
contentDescription = "Fullscreen" contentDescription = stringResource(R.string.widget_description_fullscreen)
) )
} }
} }

View File

@ -1,3 +1,18 @@
<resources> <resources>
<string name="app_name">NewPlayer</string> <string name="app_name">NewPlayer</string>
<string name="menu_item_open_in_browser">Open in browser</string>
<string name="menu_item_share_timestamp">Share timestamp</string>
<string name="menu_item_more_settings">More settings</string>
<string name="mute">Mute</string>
<string name="unmute">Unmute</string>
<string name="menu_item_fit_screen">Fit screen</string>
<string name="menu_item_sub_titles">Subtitles</string>
<string name="menu_item_language">Language</string>
<string name="widget_description_previous_stream">Previous stream</string>
<string name="widget_description_next_stream">Previous stream</string>
<string name="widget_description_play">Play</string>
<string name="widget_description_pause">Pause</string>
<string name="widget_description_fullscreen">Fullscreen</string>
<string name="widget_description_chapter_selection">Chapter selection</string>
<string name="widget_descriptoin_playlist_item_selection">Playlist item selection</string>
</resources> </resources>