Strings update

This commit is contained in:
ThomasSession 2024-09-04 16:44:05 +10:00 committed by fanchao
parent bc067b6848
commit 3db8b46be1
4 changed files with 51 additions and 8 deletions

View File

@ -8,6 +8,7 @@ import android.view.ViewGroup
import androidx.core.view.isVisible import androidx.core.view.isVisible
import com.google.android.material.bottomsheet.BottomSheetDialogFragment import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import dagger.hilt.android.AndroidEntryPoint import dagger.hilt.android.AndroidEntryPoint
import network.loki.messenger.R
import network.loki.messenger.databinding.FragmentConversationBottomSheetBinding import network.loki.messenger.databinding.FragmentConversationBottomSheetBinding
import org.thoughtcrime.securesms.database.model.ThreadRecord import org.thoughtcrime.securesms.database.model.ThreadRecord
import org.thoughtcrime.securesms.dependencies.ConfigFactory import org.thoughtcrime.securesms.dependencies.ConfigFactory
@ -82,7 +83,33 @@ class ConversationOptionsBottomSheet(private val parentContext: Context) : Botto
binding.muteNotificationsTextView.setOnClickListener(this) binding.muteNotificationsTextView.setOnClickListener(this)
binding.notificationsTextView.isVisible = recipient.isGroupRecipient && !recipient.isMuted binding.notificationsTextView.isVisible = recipient.isGroupRecipient && !recipient.isMuted
binding.notificationsTextView.setOnClickListener(this) binding.notificationsTextView.setOnClickListener(this)
binding.deleteTextView.setOnClickListener(this)
// delete
binding.deleteTextView.apply {
setOnClickListener(this@ConversationOptionsBottomSheet)
// the text and content description will change depending on the type
when{
// groups and communities
recipient.isGroupRecipient -> {
text = context.getString(R.string.leave)
contentDescription = context.getString(R.string.AccessibilityId_leave)
}
// note to self
recipient.isLocalNumber -> {
text = context.getString(R.string.clear)
contentDescription = context.getString(R.string.AccessibilityId_clear)
}
// 1on1
else -> {
text = context.getString(R.string.delete)
contentDescription = context.getString(R.string.AccessibilityId_delete)
}
}
}
binding.markAllAsReadTextView.isVisible = thread.unreadCount > 0 || configFactory.convoVolatile?.getConversationUnread(thread) == true binding.markAllAsReadTextView.isVisible = thread.unreadCount > 0 || configFactory.convoVolatile?.getConversationUnread(thread) == true
binding.markAllAsReadTextView.setOnClickListener(this) binding.markAllAsReadTextView.setOnClickListener(this)
binding.pinTextView.isVisible = !thread.isPinned binding.pinTextView.isVisible = !thread.isPinned

View File

@ -583,16 +583,20 @@ class HomeActivity : PassphraseRequiredActionBarActivity(),
val recipient = thread.recipient val recipient = thread.recipient
val title: String val title: String
val message: CharSequence val message: CharSequence
var positiveButtonId: Int = R.string.yes
var negativeButtonId: Int = R.string.no
if (recipient.isGroupRecipient) { if (recipient.isGroupRecipient) {
val group = groupDatabase.getGroup(recipient.address.toString()).orNull() val group = groupDatabase.getGroup(recipient.address.toString()).orNull()
// If you are an admin of this group you can delete it // If you are an admin of this group you can delete it
if (group != null && group.admins.map { it.toString() }.contains(textSecurePreferences.getLocalNumber())) { if (group != null && group.admins.map { it.toString() }.contains(textSecurePreferences.getLocalNumber())) {
title = getString(R.string.groupDelete) title = getString(R.string.groupLeave)
message = Phrase.from(this.applicationContext, R.string.groupDeleteDescription) message = Phrase.from(this.applicationContext, R.string.groupDeleteDescription)
.put(GROUP_NAME_KEY, group.title) .put(GROUP_NAME_KEY, group.title)
.format() .format()
positiveButtonId = R.string.leave
negativeButtonId = R.string.cancel
} else { } else {
// Otherwise this is either a community, or it's a group you're not an admin of // Otherwise this is either a community, or it's a group you're not an admin of
title = if (recipient.isCommunityRecipient) getString(R.string.communityLeave) else getString(R.string.groupLeave) title = if (recipient.isCommunityRecipient) getString(R.string.communityLeave) else getString(R.string.groupLeave)
@ -610,15 +614,17 @@ class HomeActivity : PassphraseRequiredActionBarActivity(),
} }
else { else {
// If not group-related and we don't have a recipient name then this must be our Note to Self conversation // If not group-related and we don't have a recipient name then this must be our Note to Self conversation
title = getString(R.string.noteToSelf) title = getString(R.string.clearMessages)
message = getString(R.string.clearMessagesNoteToSelfDescription) message = getString(R.string.clearMessagesNoteToSelfDescription)
positiveButtonId = R.string.clear
negativeButtonId = R.string.cancel
} }
} }
showSessionDialog { showSessionDialog {
title(title) title(title)
text(message) text(message)
button(R.string.yes) { dangerButton(positiveButtonId) {
lifecycleScope.launch(Dispatchers.Main) { lifecycleScope.launch(Dispatchers.Main) {
val context = this@HomeActivity val context = this@HomeActivity
// Cancel any outstanding jobs // Cancel any outstanding jobs
@ -650,7 +656,7 @@ class HomeActivity : PassphraseRequiredActionBarActivity(),
Toast.makeText(context, toastMessage, Toast.LENGTH_LONG).show() Toast.makeText(context, toastMessage, Toast.LENGTH_LONG).show()
} }
} }
button(R.string.no) button(negativeButtonId)
} }
} }

View File

@ -66,6 +66,8 @@
<string name="AccessibilityId_blockConfirm">Confirm block</string> <string name="AccessibilityId_blockConfirm">Confirm block</string>
<string name="AccessibilityId_unblockConfirm">Confirm unblock</string> <string name="AccessibilityId_unblockConfirm">Confirm unblock</string>
<string name="AccessibilityId_delete">Delete</string> <string name="AccessibilityId_delete">Delete</string>
<string name="AccessibilityId_leave">Leave</string>
<string name="AccessibilityId_clear">Clear</string>
<string name="AccessibilityId_disappearingMessages">Disappearing messages</string> <string name="AccessibilityId_disappearingMessages">Disappearing messages</string>
<string name="AccessibilityId_enable">Enable</string> <string name="AccessibilityId_enable">Enable</string>
<string name="AccessibilityId_notificationsMute">Mute notifications</string> <string name="AccessibilityId_notificationsMute">Mute notifications</string>
@ -73,7 +75,7 @@
<string name="AccessibilityId_search">Search</string> <string name="AccessibilityId_search">Search</string>
<!-- Conversation options for closed group--> <!-- Conversation options for closed group-->
<string name="AccessibilityId_groupNameNew">Accept name change</string> <string name="AccessibilityId_groupNameNew">Accept name change</string>
<string name="AccessibilityId_membersInvite">Add members</string> <string name="AccessibilityId_membersInvite">Invite Contacts</string>
<string name="AccessibilityId_set">Apply changes</string> <string name="AccessibilityId_set">Apply changes</string>
<string name="AccessibilityId_groupNameChangeCancel">Cancel name change</string> <string name="AccessibilityId_groupNameChangeCancel">Cancel name change</string>
<string name="AccessibilityId_contactMentions">Contact mentions</string> <string name="AccessibilityId_contactMentions">Contact mentions</string>

View File

@ -196,11 +196,19 @@ object UpdateMessageBuilder {
if (duration <= 0) { if (duration <= 0) {
// ..by you.. // ..by you..
return if (isOutgoing) { return if (isOutgoing) {
context.getText(R.string.disappearingMessagesTurnedOffYou) // in a group
if(isGroup) context.getText(R.string.disappearingMessagesTurnedOffYouGroup)
// 1on1
else context.getText(R.string.disappearingMessagesTurnedOffYou)
} }
else // ..or by someone else. else // ..or by someone else.
{ {
Phrase.from(context, R.string.disappearingMessagesTurnedOff) Phrase.from(context,
// in a group
if(isGroup) R.string.disappearingMessagesTurnedOffGroup
// 1on1
else R.string.disappearingMessagesTurnedOff
)
.put(NAME_KEY, senderName) .put(NAME_KEY, senderName)
.format() .format()
} }