Skip to content

Commit

Permalink
app: Fix strings
Browse files Browse the repository at this point in the history
* Fix #250 #251 #252 #253 #254
* Move toast strings to strings
  • Loading branch information
mikooomich committed Jan 27, 2025
1 parent b5c1c3f commit 49e437f
Show file tree
Hide file tree
Showing 9 changed files with 98 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ fun AddToPlaylistDialog(

item {
Text(
text = "Note: Adding local songs to synced/remote playlists is unsupported. Any other combination is valid.",
text = stringResource(R.string.playlist_add_local_to_synced_note),
fontSize = TextUnit(12F, TextUnitType.Sp),
modifier = Modifier.padding(horizontal = 20.dp)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import androidx.compose.material.icons.rounded.DragHandle
import androidx.compose.material.icons.rounded.FolderCopy
import androidx.compose.material.icons.rounded.MoreHoriz
import androidx.compose.material.icons.rounded.Palette
import androidx.compose.material.icons.rounded.PlaylistAdd
import androidx.compose.material.icons.rounded.Reorder
import androidx.compose.material.icons.rounded.Tab
import androidx.compose.material3.ExperimentalMaterial3Api
Expand Down Expand Up @@ -314,7 +313,7 @@ fun AppearanceSettings(
NavigationTab.ALBUM -> stringResource(R.string.albums)
NavigationTab.PLAYLIST -> stringResource(R.string.playlists)
else -> {
"--- Drag below here to disable ---"
stringResource(R.string.tab_arrangement_disable_tip)
}
}
)
Expand All @@ -328,7 +327,7 @@ fun AppearanceSettings(
}
}

InfoLabel(text = "The Home tab is required.")
InfoLabel(stringResource(R.string.tab_arrangement_home_required))
}

if (newInterfaceStyle) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ fun ContentSettings(
)

PreferenceGroupTitle(
title = stringResource(R.string.localization)
title = stringResource(R.string.grp_localization)
)
ListPreference(
title = { Text(stringResource(R.string.content_language)) },
Expand Down Expand Up @@ -231,7 +231,7 @@ fun ContentSettings(
)

PreferenceGroupTitle(
title = stringResource(R.string.proxy)
title = stringResource(R.string.grp_proxy)
)
SwitchPreference(
title = { Text(stringResource(R.string.enable_proxy)) },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,13 @@ fun ExperimentalSettings(

// TODO: move to home screen as button?
PreferenceEntry(
title = { Text("Trigger manual sync") },
title = { Text(stringResource(R.string.scanner_manual_btn)) },
icon = { Icon(Icons.Rounded.Sync, null) },
onClick = {
Toast.makeText(context, "Syncing with YouTube account...", Toast.LENGTH_SHORT).show()
Toast.makeText(context, context.getString(R.string.sync_progress_active), Toast.LENGTH_SHORT).show()
coroutineScope.launch(Dispatchers.Main) {
syncUtils.syncAll()
Toast.makeText(context, "Sync complete", Toast.LENGTH_SHORT).show()
Toast.makeText(context, context.getString(R.string.sync_progress_active), Toast.LENGTH_SHORT).show()
}
}
)
Expand All @@ -138,12 +138,12 @@ fun ExperimentalSettings(
title = { Text("DEBUG: Force local to remote artist migration NOW") },
icon = { Icon(Icons.Rounded.Backup, null) },
onClick = {
Toast.makeText(context, "Starting YouTube artist linking...", Toast.LENGTH_SHORT).show()
Toast.makeText(context, context.getString(R.string.scanner_ytm_link_start), Toast.LENGTH_SHORT).show()
coroutineScope.launch(Dispatchers.IO) {
val scanner = LocalMediaScanner.getScanner(context, ScannerImpl.TAGLIB)
Timber.tag("Settings").d("Force Migrating local artists to YTM (MANUAL TRIGGERED)")
scanner.localToRemoteArtist(database)
Toast.makeText(context, "YouTube artist linking job complete", Toast.LENGTH_SHORT).show()
Toast.makeText(context, context.getString(R.string.scanner_ytm_link_success), Toast.LENGTH_SHORT).show()
}
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ import androidx.compose.material3.Switch
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.material3.TopAppBarScrollBehavior
import androidx.compose.material3.VerticalDivider
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.LaunchedEffect
Expand Down Expand Up @@ -101,7 +100,6 @@ import com.dd3boh.outertune.utils.scanners.LocalMediaScanner.Companion.scannerRe
import com.dd3boh.outertune.utils.scanners.LocalMediaScanner.Companion.scannerShowLoading
import com.dd3boh.outertune.utils.scanners.ScannerAbortException
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.launch
import java.time.LocalDateTime
import java.time.ZoneOffset
Expand Down Expand Up @@ -159,7 +157,10 @@ fun LocalPlayerSettings(

// other vars
var tempScanPaths by remember { mutableStateOf("") }
val (lastLocalScan, onLastLocalScanChange) = rememberPreference(LastLocalScanKey, LocalDateTime.now().atOffset(ZoneOffset.UTC).toEpochSecond())
val (lastLocalScan, onLastLocalScanChange) = rememberPreference(
LastLocalScanKey,
LocalDateTime.now().atOffset(ZoneOffset.UTC).toEpochSecond()
)

Column(
Modifier
Expand Down Expand Up @@ -305,7 +306,7 @@ fun LocalPlayerSettings(
}

PreferenceGroupTitle(
title = stringResource(R.string.manual_scanner_title)
title = stringResource(R.string.grp_manual_scanner)
)
// scanner
Row(
Expand All @@ -329,7 +330,7 @@ fun LocalPlayerSettings(

Toast.makeText(
context,
"The scanner requires storage permissions",
context.getString(R.string.scanner_missing_storage_perm),
Toast.LENGTH_SHORT
).show()

Expand Down Expand Up @@ -371,14 +372,20 @@ fun LocalPlayerSettings(
coroutineScope.launch(Dispatchers.IO) {
Looper.prepare()
try {
Toast.makeText(context, "Starting YouTube artist linking...", Toast.LENGTH_SHORT).show()
Toast.makeText(
context, context.getString(R.string.scanner_ytm_link_start),
Toast.LENGTH_SHORT
).show()
scanner.localToRemoteArtist(database)
Toast.makeText(context, "YouTube artist linking job complete", Toast.LENGTH_SHORT).show()
Toast.makeText(
context, context.getString(R.string.scanner_ytm_link_success),
Toast.LENGTH_SHORT
).show()
} catch (e: ScannerAbortException) {
Looper.prepare()
Toast.makeText(
context,
"Scanner (background task) failed: ${e.message}",
"${context.getString(R.string.scanner_ytm_link_success)}: ${e.message}",
Toast.LENGTH_LONG
).show()
}
Expand All @@ -390,7 +397,7 @@ fun LocalPlayerSettings(
Looper.prepare()
Toast.makeText(
context,
"Scanner failed: ${e.message}",
"${context.getString(R.string.scanner_scan_fail)}: ${e.message}",
Toast.LENGTH_LONG
).show()
} finally {
Expand All @@ -416,13 +423,21 @@ fun LocalPlayerSettings(
coroutineScope.launch(Dispatchers.IO) {
Looper.prepare()
try {
Toast.makeText(context, "Starting YouTube artist linking...", Toast.LENGTH_SHORT).show()
Toast.makeText(
context,
context.getString(R.string.scanner_ytm_link_start),
Toast.LENGTH_SHORT
).show()
scanner.localToRemoteArtist(database)
Toast.makeText(context, "YouTube artist linking job complete", Toast.LENGTH_SHORT).show()
Toast.makeText(
context,
context.getString(R.string.scanner_ytm_link_success),
Toast.LENGTH_SHORT
).show()
} catch (e: ScannerAbortException) {
Toast.makeText(
context,
"Scanner (background task) failed: ${e.message}",
"${context.getString(R.string.scanner_ytm_link_fail)}: ${e.message}",
Toast.LENGTH_LONG
).show()
}
Expand All @@ -434,7 +449,7 @@ fun LocalPlayerSettings(
Looper.prepare()
Toast.makeText(
context,
"Scanner failed: ${e.message}",
"${context.getString(R.string.scanner_scan_fail)}: ${e.message}",
Toast.LENGTH_LONG
).show()
} finally {
Expand Down Expand Up @@ -486,18 +501,22 @@ fun LocalPlayerSettings(
Column {
val isSyncing = scannerProgressCurrent > -1
Text(
text = if (isSyncing) "Syncing..." else "Scanning...",
text = if (isSyncing) {
stringResource(R.string.scanner_progress_syncing)
} else {
stringResource(R.string.scanner_progress_scanning)
},
color = MaterialTheme.colorScheme.secondary,
fontSize = 12.sp
)
Text(
text = "${if (isSyncing) scannerProgressCurrent else ""}/${
pluralStringResource(
R.plurals.n_song,
if (isSyncing) R.plurals.scanner_n_song_processed else R.plurals.scanner_n_song_found,
scannerProgressTotal,
scannerProgressTotal
)
} ${if (isSyncing) "processed" else "found"}",
}",
color = MaterialTheme.colorScheme.secondary,
fontSize = 12.sp
)
Expand Down Expand Up @@ -555,7 +574,7 @@ fun LocalPlayerSettings(
}

PreferenceGroupTitle(
title = stringResource(R.string.scanner_settings_title)
title = stringResource(R.string.grp_extra_scanner_settings)
)
// scanner sensitivity
EnumListPreference(
Expand Down Expand Up @@ -597,7 +616,8 @@ fun LocalPlayerSettings(
if (it == ScannerImpl.FFMPEG_EXT && isFFmpegInstalled) {
onScannerImplChange(it)
} else {
Toast.makeText(context, "FFmpeg extractor not detected.", Toast.LENGTH_LONG).show()
Toast.makeText(context, context.getString(R.string.scanner_missing_ffmpeg), Toast.LENGTH_LONG)
.show()
// Explicitly revert to TagLib if FFmpeg is not available
onScannerImplChange(ScannerImpl.TAGLIB)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ fun LyricsSettings(
.verticalScroll(rememberScrollState())
) {
PreferenceGroupTitle(
title = "Lyric sources"
title = stringResource(R.string.grp_lyrics_source)
)
SwitchPreference(
title = { Text(stringResource(R.string.enable_lrclib)) },
Expand All @@ -112,7 +112,7 @@ fun LyricsSettings(
)

PreferenceGroupTitle(
title = "Parser"
title = stringResource(R.string.grp_lyrics_parser)
)
// multiline lyrics
SwitchPreference(
Expand All @@ -132,7 +132,7 @@ fun LyricsSettings(
)

PreferenceGroupTitle(
title = "Formatting"
title = stringResource(R.string.grp_lyrics_format)
)
// lyrics position
EnumListPreference(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.navigation.NavController
Expand Down Expand Up @@ -119,7 +118,7 @@ fun PlayerSettings(
)

PreferenceGroupTitle(
title = stringResource(R.string.audio)
title = stringResource(R.string.grp_audio)
)
EnumListPreference(
title = { Text(stringResource(R.string.audio_quality)) },
Expand Down
Loading

0 comments on commit 49e437f

Please sign in to comment.