add string resources

This commit is contained in:
greenart7c3 2023-06-21 11:38:34 -03:00
parent 68e8abecb2
commit 143f58fd68
3 changed files with 54 additions and 28 deletions

View File

@ -308,10 +308,9 @@ fun ServerConfig(
Toast
.makeText(
context,
"An error ocurred trying to get relay information",
context.getString(R.string.an_error_ocurred_trying_to_get_relay_information),
Toast.LENGTH_SHORT
)
.show()
).show()
}
}
}
@ -323,10 +322,9 @@ fun ServerConfig(
Toast
.makeText(
context,
"An error ocurred trying to get relay information",
context.getString(R.string.an_error_ocurred_trying_to_get_relay_information),
Toast.LENGTH_SHORT
)
.show()
).show()
}
}
})

View File

@ -35,6 +35,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalUriHandler
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextOverflow
@ -118,7 +119,7 @@ fun RelayInformationDialog(onClose: () -> Unit, relayInfo: RelayInformation, bas
SectionContent(relayInfo.description ?: "")
Section("Owner")
Section(stringResource(R.string.owner))
Row {
UserPicture(
@ -237,7 +238,7 @@ fun RelayInformationDialog(onClose: () -> Unit, relayInfo: RelayInformation, bas
}
}
Section("Software")
Section(stringResource(R.string.software))
val url = (relayInfo.software ?: "").replace("git+", "")
Box(modifier = Modifier.padding(start = 10.dp)) {
@ -247,17 +248,17 @@ fun RelayInformationDialog(onClose: () -> Unit, relayInfo: RelayInformation, bas
)
}
Section("Version")
Section(stringResource(R.string.version))
SectionContent(relayInfo.version ?: "")
Section("Contact")
Section(stringResource(R.string.contact))
Box(modifier = Modifier.padding(start = 10.dp)) {
ClickableEmail(relayInfo.contact ?: "")
}
Section("Supports")
Section(stringResource(R.string.supports))
FlowRow {
relayInfo.supported_nips?.forEach { item ->
@ -283,7 +284,7 @@ fun RelayInformationDialog(onClose: () -> Unit, relayInfo: RelayInformation, bas
relayInfo.fees?.admission?.let {
if (it.isNotEmpty()) {
Section("Admission Fees")
Section(stringResource(R.string.admission_fees))
it.forEach { item ->
SectionContent("${item.amount?.div(1000) ?: 0} sats")
@ -292,7 +293,7 @@ fun RelayInformationDialog(onClose: () -> Unit, relayInfo: RelayInformation, bas
}
relayInfo.payments_url?.let {
Section("Payments url")
Section(stringResource(R.string.payments_url))
Box(modifier = Modifier.padding(start = 10.dp)) {
ClickableUrl(
@ -303,24 +304,28 @@ fun RelayInformationDialog(onClose: () -> Unit, relayInfo: RelayInformation, bas
}
relayInfo.limitation?.let {
Section("Limitations")
Section(stringResource(R.string.limitations))
val authRequired = it.auth_required ?: false
val authRequiredText = if (authRequired) stringResource(R.string.yes) else stringResource(R.string.no)
val paymentRequired = it.payment_required ?: false
val paymentRequiredText = if (paymentRequired) stringResource(R.string.yes) else stringResource(R.string.no)
Column {
SectionContent("Message length: ${it.max_message_length ?: 0}")
SectionContent("Subscriptions: ${it.max_subscriptions ?: 0}")
SectionContent("Filters: ${it.max_subscriptions ?: 0}")
SectionContent("Subscription id length: ${it.max_subid_length ?: 0}")
SectionContent("Minimum prefix: ${it.min_prefix ?: 0}")
SectionContent("Maximum event tags: ${it.max_event_tags ?: 0}")
SectionContent("Content length: ${it.max_content_length ?: 0}")
SectionContent("Minimum PoW: ${it.min_pow_difficulty ?: 0}")
SectionContent("Auth: ${it.auth_required ?: false}")
SectionContent("Payment: ${it.payment_required ?: false}")
SectionContent("${stringResource(R.string.message_length)}: ${it.max_message_length ?: 0}")
SectionContent("${stringResource(R.string.subscriptions)}: ${it.max_subscriptions ?: 0}")
SectionContent("${stringResource(R.string.filters)}: ${it.max_subscriptions ?: 0}")
SectionContent("${stringResource(R.string.subscription_id_length)}: ${it.max_subid_length ?: 0}")
SectionContent("${stringResource(R.string.minimum_prefix)}: ${it.min_prefix ?: 0}")
SectionContent("${stringResource(R.string.maximum_event_tags)}: ${it.max_event_tags ?: 0}")
SectionContent("${stringResource(R.string.content_length)}: ${it.max_content_length ?: 0}")
SectionContent("${stringResource(R.string.minimum_pow)}: ${it.min_pow_difficulty ?: 0}")
SectionContent("${stringResource(R.string.auth)}: $authRequiredText")
SectionContent("${stringResource(R.string.payment)}: $paymentRequiredText")
}
}
relayInfo.relay_countries?.let {
Section("Countries")
Section(stringResource(R.string.countries))
FlowRow {
it.forEach { item ->
@ -330,7 +335,7 @@ fun RelayInformationDialog(onClose: () -> Unit, relayInfo: RelayInformation, bas
}
relayInfo.language_tags?.let {
Section("Languages")
Section(stringResource(R.string.languages))
FlowRow {
it.forEach { item ->
@ -340,7 +345,7 @@ fun RelayInformationDialog(onClose: () -> Unit, relayInfo: RelayInformation, bas
}
relayInfo.tags?.let {
Section("Tags")
Section(stringResource(R.string.tags))
FlowRow {
it.forEach { item ->
@ -350,7 +355,7 @@ fun RelayInformationDialog(onClose: () -> Unit, relayInfo: RelayInformation, bas
}
relayInfo.posting_policy?.let {
Section("Posting policy")
Section(stringResource(R.string.posting_policy))
Box(Modifier.padding(10.dp)) {
ClickableUrl(

View File

@ -425,4 +425,27 @@
<string name="sats_to_complete">Zapraiser at %1$s. %2$s sats to goal</string>
<string name="read_from_relay">Read from Relay</string>
<string name="write_to_relay">Write to Relay</string>
<string name="an_error_ocurred_trying_to_get_relay_information">An error ocurred trying to get relay information</string>
<string name="owner">Owner</string>
<string name="version">Version</string>
<string name="software">Software</string>
<string name="contact">Contact</string>
<string name="supports">Supports</string>
<string name="admission_fees">Admission Fees</string>
<string name="payments_url">Payments url</string>
<string name="limitations">Limitations</string>
<string name="countries">Countries</string>
<string name="languages">Languages</string>
<string name="tags">Tags</string>
<string name="posting_policy">Posting policy</string>
<string name="message_length">Message length</string>
<string name="subscriptions">Subscriptions</string>
<string name="filters">Filters</string>
<string name="subscription_id_length">Subscription id length</string>
<string name="minimum_prefix">Minimum prefix</string>
<string name="maximum_event_tags">Maximum event tags</string>
<string name="content_length">Content length</string>
<string name="minimum_pow">Minimum PoW</string>
<string name="auth">Auth</string>
<string name="payment">Payment</string>
</resources>