Removing hardcoded strings

pull/1518/head
ThomasSession 7 months ago
parent ed38e507ae
commit 2861b3a02d

@ -432,7 +432,7 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
val recipient = viewModel.recipient val recipient = viewModel.recipient
val openGroup = recipient.let { viewModel.openGroup } val openGroup = recipient.let { viewModel.openGroup }
if (recipient == null || (recipient.isCommunityRecipient && openGroup == null)) { if (recipient == null || (recipient.isCommunityRecipient && openGroup == null)) {
Toast.makeText(this, "This thread has been deleted.", Toast.LENGTH_LONG).show() Toast.makeText(this, getString(R.string.conversationsDeleted), Toast.LENGTH_LONG).show()
return finish() return finish()
} }

@ -247,7 +247,6 @@ class ConversationViewModel(
else -> false else -> false
} }
// There are three types of dialogs for deletion: // There are three types of dialogs for deletion:
// 1- Delete on device only OR all devices - Used for Note to self // 1- Delete on device only OR all devices - Used for Note to self
// 2- Delete on device only OR for everyone - Used for 'admins' or a user's own messages, as long as the message have a server hash // 2- Delete on device only OR for everyone - Used for 'admins' or a user's own messages, as long as the message have a server hash
@ -347,27 +346,33 @@ class ConversationViewModel(
* Instead they will appear as a special type of message * Instead they will appear as a special type of message
* that says something like "This message was deleted" * that says something like "This message was deleted"
*/ */
private fun markAsDeletedForEveryone(message: MessageRecord) = viewModelScope.launch { private fun markAsDeletedForEveryone(messages: Set<MessageRecord>) = viewModelScope.launch {
val recipient = recipient ?: return@launch Log.w("Loki", "Recipient was null for delete for everyone - aborting delete operation.") val recipient = recipient ?: return@launch Log.w("Loki", "Recipient was null for delete for everyone - aborting delete operation.")
stopMessageAudio(message)
repository.markAsDeletedForEveryone(threadId, recipient, message) // make sure to stop audio messages, if any
messages.filterIsInstance<MmsMessageRecord>()
.mapNotNull { it.slideDeck.audioSlide }
.forEach(::stopMessageAudio)
/*repository.markAsDeletedForEveryone(threadId, recipient, messages)
.onSuccess { .onSuccess {
Log.d("Loki", "Deleted message ${message.id} ") Log.d("Loki", "Deleted messages $messages ")
} }
.onFailure { .onFailure {
Log.w("Loki", "FAILED TO delete message ${message.id} ") Log.w("Loki", "FAILED TO delete messages $messages ")
showMessage("Couldn't delete message due to error: $it") showMessage(
} application.resources.getQuantityString(R.plurals.deleteMessageFailed, messages.size, messages.size)
)
}*/
} }
fun banUser(recipient: Recipient) = viewModelScope.launch { fun banUser(recipient: Recipient) = viewModelScope.launch {
repository.banUser(threadId, recipient) repository.banUser(threadId, recipient)
.onSuccess { .onSuccess {
showMessage("Successfully banned user") showMessage(application.getString(R.string.banUserBanned))
} }
.onFailure { .onFailure {
showMessage("Couldn't ban user due to error: $it") showMessage(application.getString(R.string.banErrorFailed))
} }
} }
@ -376,13 +381,13 @@ class ConversationViewModel(
repository.banAndDeleteAll(threadId, messageRecord.individualRecipient) repository.banAndDeleteAll(threadId, messageRecord.individualRecipient)
.onSuccess { .onSuccess {
// At this point the server side messages have been successfully deleted.. // At this point the server side messages have been successfully deleted..
showMessage("Successfully banned user and deleted all their messages") showMessage(application.getString(R.string.banUserBanned))
// ..so we can now delete all their messages in this thread from local storage & remove the views. // ..so we can now delete all their messages in this thread from local storage & remove the views.
repository.deleteAllLocalMessagesInThreadFromSenderOfMessage(messageRecord) repository.deleteAllLocalMessagesInThreadFromSenderOfMessage(messageRecord)
} }
.onFailure { .onFailure {
showMessage("Couldn't execute request due to error: $it") showMessage(application.getString(R.string.banErrorFailed))
} }
} }
@ -394,9 +399,7 @@ class ConversationViewModel(
it.copy(isMessageRequestAccepted = true) it.copy(isMessageRequestAccepted = true)
} }
} }
.onFailure { .onFailure {}
showMessage("Couldn't accept message request due to error: $it")
}
} }
fun declineMessageRequest() { fun declineMessageRequest() {

@ -115,7 +115,7 @@ class ShareLogsDialog(private val updateCallback: (Boolean)->Unit): DialogFragme
} catch (e: Exception) { } catch (e: Exception) {
withContext(Main) { withContext(Main) {
Log.e("Loki", "Error saving logs", e) Log.e("Loki", "Error saving logs", e)
Toast.makeText(context,"Error saving logs", Toast.LENGTH_LONG).show() Toast.makeText(context,getString(R.string.errorUnknown), Toast.LENGTH_LONG).show()
} }
} }
}.also { shareJob -> }.also { shareJob ->

Loading…
Cancel
Save