mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-11-22 21:15:30 +03:00
System Messages and Error handling
This commit is contained in:
parent
718369d80e
commit
80c843227e
4 changed files with 38 additions and 2 deletions
|
@ -84,6 +84,7 @@ import android.widget.RelativeLayout.BELOW
|
||||||
import android.widget.RelativeLayout.LayoutParams
|
import android.widget.RelativeLayout.LayoutParams
|
||||||
import android.widget.SeekBar
|
import android.widget.SeekBar
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
|
import android.widget.Toast
|
||||||
import androidx.activity.OnBackPressedCallback
|
import androidx.activity.OnBackPressedCallback
|
||||||
import androidx.appcompat.view.ContextThemeWrapper
|
import androidx.appcompat.view.ContextThemeWrapper
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
|
@ -893,8 +894,25 @@ class ChatActivity :
|
||||||
// unused atm
|
// unused atm
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onNext(t: ChatOCSSingleMessage) {
|
override fun onNext(message: ChatOCSSingleMessage) {
|
||||||
//unused atm
|
//unused atm
|
||||||
|
when(message.meta!!.statusCode){
|
||||||
|
HTTP_BAD_REQUEST -> {
|
||||||
|
Toast.makeText(context,
|
||||||
|
getString(R.string.edit_error_24_hours_old_message),Toast.LENGTH_SHORT)
|
||||||
|
.show()
|
||||||
|
}
|
||||||
|
HTTP_FORBIDDEN -> {
|
||||||
|
Toast.makeText(context,
|
||||||
|
getString(R.string.conversation_is_read_only),
|
||||||
|
Toast.LENGTH_SHORT).show()
|
||||||
|
}
|
||||||
|
HTTP_NOT_FOUND -> {
|
||||||
|
Toast.makeText(context,
|
||||||
|
"Conversation Cannot be Found",
|
||||||
|
Toast.LENGTH_SHORT).show()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onError(e: Throwable) {
|
override fun onError(e: Throwable) {
|
||||||
|
@ -904,7 +922,7 @@ class ChatActivity :
|
||||||
clearEditUI()
|
clearEditUI()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
// remove last item from list
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun clearEditUI() {
|
private fun clearEditUI() {
|
||||||
|
@ -912,6 +930,7 @@ class ChatActivity :
|
||||||
binding.messageInputView.clearEditMessage.visibility = View.GONE
|
binding.messageInputView.clearEditMessage.visibility = View.GONE
|
||||||
editableBehaviorSubject.onNext(false)
|
editableBehaviorSubject.onNext(false)
|
||||||
binding.messageInputView.inputEditText.setText("")
|
binding.messageInputView.inputEditText.setText("")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun themeMessageInputView() {
|
private fun themeMessageInputView() {
|
||||||
|
@ -3820,6 +3839,10 @@ class ChatActivity :
|
||||||
} else if (isPollVotedMessage(currentMessage)) {
|
} else if (isPollVotedMessage(currentMessage)) {
|
||||||
// delete poll system messages
|
// delete poll system messages
|
||||||
chatMessageIterator.remove()
|
chatMessageIterator.remove()
|
||||||
|
}else if(isEditMessage(currentMessage)){
|
||||||
|
if (!chatMessageMap.containsKey(currentMessage.value.parentMessage!!.id)){
|
||||||
|
chatMessageIterator.remove()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return chatMessageMap.values.toList()
|
return chatMessageMap.values.toList()
|
||||||
|
@ -3860,6 +3883,11 @@ class ChatActivity :
|
||||||
currentMessage.value.systemMessageType == ChatMessage.SystemMessageType.REACTION_REVOKED
|
currentMessage.value.systemMessageType == ChatMessage.SystemMessageType.REACTION_REVOKED
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun isEditMessage(currentMessage:MutableMap.MutableEntry<String,ChatMessage>):Boolean{
|
||||||
|
return currentMessage.value.parentMessage != null && currentMessage.value.systemMessageType == ChatMessage
|
||||||
|
.SystemMessageType.MESSAGE_EDITED
|
||||||
|
}
|
||||||
|
|
||||||
private fun isPollVotedMessage(currentMessage: MutableMap.MutableEntry<String, ChatMessage>): Boolean {
|
private fun isPollVotedMessage(currentMessage: MutableMap.MutableEntry<String, ChatMessage>): Boolean {
|
||||||
return currentMessage.value.systemMessageType == ChatMessage.SystemMessageType.POLL_VOTED
|
return currentMessage.value.systemMessageType == ChatMessage.SystemMessageType.POLL_VOTED
|
||||||
}
|
}
|
||||||
|
@ -4672,6 +4700,9 @@ class ChatActivity :
|
||||||
private const val STATUS_SIZE_IN_DP = 9f
|
private const val STATUS_SIZE_IN_DP = 9f
|
||||||
private const val HTTP_CODE_NOT_MODIFIED = 304
|
private const val HTTP_CODE_NOT_MODIFIED = 304
|
||||||
private const val HTTP_CODE_PRECONDITION_FAILED = 412
|
private const val HTTP_CODE_PRECONDITION_FAILED = 412
|
||||||
|
private const val HTTP_BAD_REQUEST = 400
|
||||||
|
private const val HTTP_FORBIDDEN = 403
|
||||||
|
private const val HTTP_NOT_FOUND = 404
|
||||||
private const val QUOTED_MESSAGE_IMAGE_MAX_HEIGHT = 96f
|
private const val QUOTED_MESSAGE_IMAGE_MAX_HEIGHT = 96f
|
||||||
private const val MENTION_AUTO_COMPLETE_ELEVATION = 6f
|
private const val MENTION_AUTO_COMPLETE_ELEVATION = 6f
|
||||||
private const val MESSAGE_PULL_LIMIT = 100
|
private const val MESSAGE_PULL_LIMIT = 100
|
||||||
|
|
|
@ -507,6 +507,7 @@ data class ChatMessage(
|
||||||
GUEST_MODERATOR_PROMOTED,
|
GUEST_MODERATOR_PROMOTED,
|
||||||
GUEST_MODERATOR_DEMOTED,
|
GUEST_MODERATOR_DEMOTED,
|
||||||
MESSAGE_DELETED,
|
MESSAGE_DELETED,
|
||||||
|
MESSAGE_EDITED,
|
||||||
FILE_SHARED,
|
FILE_SHARED,
|
||||||
OBJECT_SHARED,
|
OBJECT_SHARED,
|
||||||
MATTERBRIDGE_CONFIG_ADDED,
|
MATTERBRIDGE_CONFIG_ADDED,
|
||||||
|
|
|
@ -127,6 +127,7 @@ class EnumSystemMessageTypeConverter : StringBasedTypeConverter<ChatMessage.Syst
|
||||||
"guest_moderator_promoted" -> GUEST_MODERATOR_PROMOTED
|
"guest_moderator_promoted" -> GUEST_MODERATOR_PROMOTED
|
||||||
"guest_moderator_demoted" -> GUEST_MODERATOR_DEMOTED
|
"guest_moderator_demoted" -> GUEST_MODERATOR_DEMOTED
|
||||||
"message_deleted" -> MESSAGE_DELETED
|
"message_deleted" -> MESSAGE_DELETED
|
||||||
|
"message_edited" -> ChatMessage.SystemMessageType.MESSAGE_EDITED
|
||||||
"file_shared" -> FILE_SHARED
|
"file_shared" -> FILE_SHARED
|
||||||
"object_shared" -> OBJECT_SHARED
|
"object_shared" -> OBJECT_SHARED
|
||||||
"matterbridge_config_added" -> MATTERBRIDGE_CONFIG_ADDED
|
"matterbridge_config_added" -> MATTERBRIDGE_CONFIG_ADDED
|
||||||
|
@ -193,6 +194,7 @@ class EnumSystemMessageTypeConverter : StringBasedTypeConverter<ChatMessage.Syst
|
||||||
GUEST_MODERATOR_PROMOTED -> "guest_moderator_promoted"
|
GUEST_MODERATOR_PROMOTED -> "guest_moderator_promoted"
|
||||||
GUEST_MODERATOR_DEMOTED -> "guest_moderator_demoted"
|
GUEST_MODERATOR_DEMOTED -> "guest_moderator_demoted"
|
||||||
MESSAGE_DELETED -> "message_deleted"
|
MESSAGE_DELETED -> "message_deleted"
|
||||||
|
ChatMessage.SystemMessageType.MESSAGE_EDITED -> "message_edited"
|
||||||
FILE_SHARED -> "file_shared"
|
FILE_SHARED -> "file_shared"
|
||||||
OBJECT_SHARED -> "object_shared"
|
OBJECT_SHARED -> "object_shared"
|
||||||
MATTERBRIDGE_CONFIG_ADDED -> "matterbridge_config_added"
|
MATTERBRIDGE_CONFIG_ADDED -> "matterbridge_config_added"
|
||||||
|
|
|
@ -790,4 +790,6 @@ How to translate with transifex:
|
||||||
<string name="nc_edit_message">Edit message</string>
|
<string name="nc_edit_message">Edit message</string>
|
||||||
<string name="nc_send_edit_message">Send Edit Message</string>
|
<string name="nc_send_edit_message">Send Edit Message</string>
|
||||||
<string name="nc_clear_edit_message">Clear Edit Message</string>
|
<string name="nc_clear_edit_message">Clear Edit Message</string>
|
||||||
|
<string name="edit_error_24_hours_old_message">Cannot Edit Messages older than 24 hours</string>
|
||||||
|
<string name="conversation_is_read_only">Conversation is read Only</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Reference in a new issue