Use Resources for string access (#3620)

This commit is contained in:
Phil Oliver 2025-11-05 00:59:45 -05:00 committed by GitHub
parent 0833a6767e
commit 8b83273a4f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 59 additions and 38 deletions

View file

@ -119,13 +119,17 @@ class MainActivity : AppCompatActivity() {
Timber.d("App link data is a channel set")
model.requestChannelUrl(
url = it,
onFailure = { Toast.makeText(this, Res.string.channel_invalid, Toast.LENGTH_SHORT).show() },
onFailure = {
Toast.makeText(this, getString(Res.string.channel_invalid), Toast.LENGTH_SHORT).show()
},
)
} else if (it.path?.startsWith("/v/") == true || it.path?.startsWith("/V/") == true) {
Timber.d("App link data is a shared contact")
model.setSharedContactRequested(
url = it,
onFailure = { Toast.makeText(this, Res.string.contact_invalid, Toast.LENGTH_SHORT).show() },
onFailure = {
Toast.makeText(this, getString(Res.string.contact_invalid), Toast.LENGTH_SHORT).show()
},
)
} else {
Timber.d("App link data is not a channel set")

View file

@ -325,9 +325,9 @@ fun DeleteConfirmationDialog(
if (showDialog) {
val deleteMessage =
pluralStringResource(
id = Res.plurals.delete_messages,
count = selectedCount,
formatArgs = arrayOf(selectedCount), // Pass the count as a format argument
Res.plurals.delete_messages,
selectedCount,
arrayOf(selectedCount), // Pass the count as a format argument
)
AlertDialog(

View file

@ -78,6 +78,7 @@ import androidx.compose.ui.platform.ClipEntry
import androidx.compose.ui.platform.LocalClipboard
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalFocusManager
import androidx.compose.ui.platform.LocalResources
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.input.ImeAction
@ -181,11 +182,12 @@ fun ChannelScreen(
}
val context = LocalContext.current
val resources = LocalResources.current
val barcodeLauncher =
rememberLauncherForActivityResult(ScanContract()) { result ->
if (result.contents != null) {
viewModel.requestChannelUrl(result.contents.toUri()) {
Toast.makeText(context, Res.string.channel_invalid, Toast.LENGTH_SHORT).show()
Toast.makeText(context, resources.getString(Res.string.channel_invalid), Toast.LENGTH_SHORT).show()
}
}
}
@ -223,7 +225,7 @@ fun ChannelScreen(
channelSet = channels // Throw away user edits
// Tell the user to try again
Toast.makeText(context, Res.string.cant_change_no_radio, Toast.LENGTH_SHORT).show()
Toast.makeText(context, resources.getString(Res.string.cant_change_no_radio), Toast.LENGTH_SHORT).show()
}
}
@ -312,7 +314,8 @@ fun ChannelScreen(
onTrackShare = viewModel::trackShare,
onConfirm = {
viewModel.requestChannelUrl(it) {
Toast.makeText(context, Res.string.channel_invalid, Toast.LENGTH_SHORT).show()
Toast.makeText(context, resources.getString(Res.string.channel_invalid), Toast.LENGTH_SHORT)
.show()
}
},
)