srctree

Robin Linden parent a0deb758 9f98a246
Make the default contact name translatable

inlinesplit
atox/src/main/kotlin/ui/NotificationHelper.kt added: 22, removed: 10, total 12
@@ -92,7 +92,7 @@ class NotificationHelper @Inject constructor(
val notificationBuilder = NotificationCompat.Builder(context, MESSAGE)
.setCategory(NotificationCompat.CATEGORY_MESSAGE)
.setSmallIcon(android.R.drawable.sym_action_chat)
.setContentTitle(contact.name)
.setContentTitle(contact.name.ifEmpty { context.getText(R.string.contact_default_name) })
.setContentText(message)
.setContentIntent(
NavDeepLinkBuilder(context)
@@ -134,7 +134,7 @@ class NotificationHelper @Inject constructor(
} else null
 
val chatPartner = Person.Builder()
.setName(contact.name)
.setName(contact.name.ifEmpty { context.getText(R.string.contact_default_name) })
.setKey(if (outgoing) "myself" else contact.publicKey)
.setIcon(icon)
.setImportant(true)
@@ -182,7 +182,12 @@ class NotificationHelper @Inject constructor(
.setCategory(NotificationCompat.CATEGORY_CALL)
.setSmallIcon(android.R.drawable.ic_menu_call)
.setContentTitle(context.getString(R.string.ongoing_call))
.setContentText(context.getString(R.string.in_call_with, contact.name))
.setContentText(
context.getString(
R.string.in_call_with,
contact.name.ifEmpty { context.getString(R.string.contact_default_name) }
)
)
.setUsesChronometer(true)
.setWhen(System.currentTimeMillis())
.setContentIntent(
 
atox/src/main/kotlin/ui/chat/ChatFragment.kt added: 22, removed: 10, total 12
@@ -105,6 +105,8 @@ class ChatFragment : BaseFragment<FragmentChatBinding>(FragmentChatBinding::infl
}
 
viewModel.contact.observe(viewLifecycleOwner) {
it.name = it.name.ifEmpty { getString(R.string.contact_default_name) }
 
contactName = it.name
viewModel.contactOnline = it.connectionStatus != ConnectionStatus.None
 
 
atox/src/main/kotlin/ui/contact_profile/ContactProfileFragment.kt added: 22, removed: 10, total 12
@@ -34,6 +34,8 @@ class ContactProfileFragment : BaseFragment<FragmentContactProfileBinding>(Fragm
 
viewModel.publicKey = PublicKey(requireStringArg(CONTACT_PUBLIC_KEY))
viewModel.contact.observe(viewLifecycleOwner) { contact ->
contact.name = contact.name.ifEmpty { getString(R.string.contact_default_name) }
 
headerMainText.text = contact.name
setAvatarFromContact(profileLayout.profileImage, contact)
profileLayout.statusIndicator.setColorFilter(colorByStatus(resources, contact))
 
atox/src/main/kotlin/ui/contactlist/ContactAdapter.kt added: 22, removed: 10, total 12
@@ -80,6 +80,8 @@ class ContactAdapter(
}
 
contacts[position - friendRequests.size].run {
name = name.ifEmpty { resources.getString(R.string.contact_default_name) }
 
val shortId = publicKey.take(8)
vh.publicKey.text = String.format("%s %s", shortId.take(4), shortId.takeLast(4))
vh.name.text = name
 
atox/src/main/res/values/strings.xml added: 22, removed: 10, total 12
@@ -149,4 +149,5 @@
<string name="pref_nospam_description">Changing your nospam means that your Tox ID changes, and that your current Tox ID can no longer be used to send you friend requests</string>
<string name="saved">Saved</string>
<string name="delete_message">Delete message</string>
<string name="contact_default_name">Unknown</string>
</resources>
No newline at end of file
 
core/src/main/kotlin/vo/Contact.kt added: 22, removed: 10, total 12
@@ -24,7 +24,7 @@ data class Contact(
val publicKey: String,
 
@ColumnInfo(name = "name")
var name: String = "Unknown",
var name: String = "",
 
@ColumnInfo(name = "status_message")
var statusMessage: String = "...",