Extract strings

This commit is contained in:
Andrew 2024-05-09 02:07:50 +09:30
parent 9935b641e1
commit 1445d56d08
7 changed files with 26 additions and 15 deletions

View File

@ -59,7 +59,7 @@ class InviteFriendFragment : Fragment() {
@Composable
private fun InviteFriend() {
Column(modifier = Modifier.background(MaterialTheme.colors.primarySurface)) {
AppBar("Invite a Friend", onBack = { delegate.onDialogBackPressed() }, onClose = { delegate.onDialogClosePressed() })
AppBar(stringResource(R.string.invite_a_friend), onBack = { delegate.onDialogBackPressed() }, onClose = { delegate.onDialogClosePressed() })
Column(
modifier = Modifier.padding(horizontal = 24.dp),
verticalArrangement = spacedBy(10.dp)
@ -84,7 +84,7 @@ class InviteFriendFragment : Fragment() {
}
Text(
"Invite your friend to chat with you on Session by sharing your Account ID with them.",
stringResource(R.string.invite_your_friend_to_chat_with_you_on_session_by_sharing_your_account_id_with_them),
textAlign = TextAlign.Center,
style = MaterialTheme.typography.small,
color = classicDarkColors[5],

View File

@ -62,10 +62,13 @@ class NewConversationHomeFragment : Fragment() {
ItemButton(textId = R.string.dialog_join_community_title, icon = R.drawable.ic_globe) { delegate.onJoinCommunitySelected() }
Divider(modifier = Modifier.padding(start = 80.dp))
ItemButton(textId = R.string.activity_settings_invite_button_title, icon = R.drawable.ic_invite_friend) { delegate.onInviteFriend() }
Column(modifier = Modifier.padding(horizontal = 32.dp).padding(top = 20.dp)) {
Text(text = "Your Account ID", style = MaterialTheme.typography.medium)
Column(
modifier = Modifier
.padding(horizontal = 32.dp)
.padding(top = 20.dp)) {
Text(text = stringResource(R.string.accountIdYours), style = MaterialTheme.typography.medium)
Spacer(modifier = Modifier.height(4.dp))
Text(text = "Friends can message you by scanning your QR code.", color = classicDarkColors[5], style = MaterialTheme.typography.small)
Text(text = stringResource(R.string.qrYoursDescription), color = classicDarkColors[5], style = MaterialTheme.typography.small)
Spacer(modifier = Modifier.height(20.dp))
QrImage(string = TextSecurePreferences.getLocalNumber(requireContext())!!, contentDescription = "Your session id")
}

View File

@ -70,7 +70,7 @@ class NewMessageViewModel @Inject constructor(
}
private fun Exception.toMessage() = when (this) {
is SnodeAPI.Error.Generic -> "We couldnt recognize this ONS. Please check and try again."
is SnodeAPI.Error.Generic -> application.getString(R.string.onsErrorNotRecognized)
else -> localizedMessage ?: application.getString(R.string.fragment_enter_public_key_error_message)
}
}

View File

@ -12,6 +12,7 @@ import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
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 network.loki.messenger.R
@ -27,7 +28,6 @@ import org.thoughtcrime.securesms.ui.components.QrImage
import org.thoughtcrime.securesms.ui.components.SessionTabRow
import org.thoughtcrime.securesms.ui.setComposeContent
import org.thoughtcrime.securesms.ui.small
import org.thoughtcrime.securesms.util.ScanQRCodeWrapperFragmentDelegate
import org.thoughtcrime.securesms.util.start
private val TITLES = listOf(R.string.view, R.string.scan)
@ -79,7 +79,9 @@ fun Tabs(sessionId: String, onScan: (String) -> Unit) {
@Composable
fun QrPage(string: String) {
Column(modifier = Modifier.padding(horizontal = 32.dp).fillMaxSize()) {
Column(modifier = Modifier
.padding(horizontal = 32.dp)
.fillMaxSize()) {
QrImage(
string = string,
contentDescription = "Your session id",
@ -88,7 +90,7 @@ fun QrPage(string: String) {
)
Text(
text = "This is your Account ID. Other users can scan it to start a conversation with you.",
text = stringResource(R.string.this_is_your_account_id_other_users_can_scan_it_to_start_a_conversation_with_you),
textAlign = TextAlign.Center,
style = MaterialTheme.typography.small
)

View File

@ -13,11 +13,10 @@ fun Context.sendInvitation() {
action = Intent.ACTION_SEND
putExtra(
Intent.EXTRA_TEXT,
"""Hey, I've been using Session to chat with complete privacy and security. Come join me! My Account ID is
${TextSecurePreferences.getLocalNumber(this@sendInvitation)}
Download it at https://getsession.org/"""
getString(
R.string.accountIdShare,
TextSecurePreferences.getLocalNumber(this@sendInvitation)
)
)
type = "text/plain"
}.let { Intent.createChooser(it, getString(R.string.activity_settings_invite_button_title)) }

View File

@ -38,7 +38,7 @@ fun AppBar(title: String, onClose: () -> Unit = {}, onBack: (() -> Unit)? = null
Spacer(modifier = Modifier.weight(1f))
Box(contentAlignment = Alignment.Center, modifier = Modifier.size(64.dp)) {
IconButton(onClick = onClose) {
Icon(painter = painterResource(id = R.drawable.ic_x), contentDescription = "back")
Icon(painter = painterResource(id = R.drawable.ic_x), contentDescription = "close")
}
}
}

View File

@ -1125,4 +1125,11 @@
<string name="unknown">Unknown</string>
<string name="contacts">Contacts</string>
<string name="conversations">Conversations</string>
<string name="invite_your_friend_to_chat_with_you_on_session_by_sharing_your_account_id_with_them">Invite your friend to chat with you on Session by sharing your Account ID with them.</string>
<string name="invite_a_friend">Invite a Friend</string>
<string name="accountIdYours">Your Account ID</string>
<string name="qrYoursDescription">Friends can message you by scanning your QR code.</string>
<string name="onsErrorNotRecognized">We couldn\'t recognize this ONS. Please check it and try again.</string>
<string name="this_is_your_account_id_other_users_can_scan_it_to_start_a_conversation_with_you">This is your Account ID. Other users can scan it to start a conversation with you.</string>
<string name="accountIdShare">Hey, I\'ve been using Session to chat with complete privacy and security. Come join me! My Account ID is \n\n%1$s\n\nDownload it at https://getsession.org/</string>
</resources>