show conversation avatars in chat appbar

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
Marcel Hibbe 2023-04-25 14:09:06 +02:00
parent 6152fa50fe
commit dd4b797ef8
No known key found for this signature in database
GPG Key ID: C793F8B59F43CE7B

View File

@ -755,6 +755,7 @@ class ChatActivity :
downX = event.x downX = event.x
showRecordAudioUi(true) showRecordAudioUi(true)
} }
MotionEvent.ACTION_CANCEL -> { MotionEvent.ACTION_CANCEL -> {
Log.d(TAG, "ACTION_CANCEL. same as for UP") Log.d(TAG, "ACTION_CANCEL. same as for UP")
if (!isVoiceRecordingInProgress || !isRecordAudioPermissionGranted()) { if (!isVoiceRecordingInProgress || !isRecordAudioPermissionGranted()) {
@ -765,6 +766,7 @@ class ChatActivity :
showRecordAudioUi(false) showRecordAudioUi(false)
binding?.messageInputView?.slideToCancelDescription?.x = sliderInitX binding?.messageInputView?.slideToCancelDescription?.x = sliderInitX
} }
MotionEvent.ACTION_UP -> { MotionEvent.ACTION_UP -> {
Log.d(TAG, "ACTION_UP. stop recording??") Log.d(TAG, "ACTION_UP. stop recording??")
if (!isVoiceRecordingInProgress || !isRecordAudioPermissionGranted()) { if (!isVoiceRecordingInProgress || !isRecordAudioPermissionGranted()) {
@ -791,6 +793,7 @@ class ChatActivity :
binding?.messageInputView?.slideToCancelDescription?.x = sliderInitX binding?.messageInputView?.slideToCancelDescription?.x = sliderInitX
} }
MotionEvent.ACTION_MOVE -> { MotionEvent.ACTION_MOVE -> {
Log.d(TAG, "ACTION_MOVE.") Log.d(TAG, "ACTION_MOVE.")
@ -986,12 +989,22 @@ class ChatActivity :
} }
private fun loadAvatarForStatusBar() { private fun loadAvatarForStatusBar() {
if (isOneToOneConversation()) { if (isOneToOneConversation() || isGroupConversation() || isPublicConversation()) {
val url = ApiUtils.getUrlForAvatar( var url = ""
conversationUser!!.baseUrl, if (isOneToOneConversation()) {
currentConversation!!.name, url = ApiUtils.getUrlForAvatar(
true conversationUser!!.baseUrl,
) currentConversation!!.name,
true
)
} else if (isGroupConversation() || isPublicConversation()) {
url = ApiUtils.getUrlForConversationAvatar(
1,
conversationUser!!.baseUrl,
currentConversation!!.token
)
}
val target = object : Target { val target = object : Target {
private fun setIcon(drawable: Drawable?) { private fun setIcon(drawable: Drawable?) {
@ -1032,8 +1045,13 @@ class ChatActivity :
} }
fun isOneToOneConversation() = currentConversation != null && currentConversation?.type != null && fun isOneToOneConversation() = currentConversation != null && currentConversation?.type != null &&
currentConversation?.type == Conversation.ConversationType currentConversation?.type == Conversation.ConversationType.ROOM_TYPE_ONE_TO_ONE_CALL
.ROOM_TYPE_ONE_TO_ONE_CALL
private fun isGroupConversation() = currentConversation != null && currentConversation?.type != null &&
currentConversation?.type == Conversation.ConversationType.ROOM_GROUP_CALL
private fun isPublicConversation() = currentConversation != null && currentConversation?.type != null &&
currentConversation?.type == Conversation.ConversationType.ROOM_PUBLIC_CALL
private fun switchToRoom(token: String, startCallAfterRoomSwitch: Boolean, isVoiceOnlyCall: Boolean) { private fun switchToRoom(token: String, startCallAfterRoomSwitch: Boolean, isVoiceOnlyCall: Boolean) {
if (conversationUser != null) { if (conversationUser != null) {
@ -1585,6 +1603,7 @@ class ChatActivity :
} }
} }
} }
REQUEST_CODE_CHOOSE_FILE -> { REQUEST_CODE_CHOOSE_FILE -> {
try { try {
checkNotNull(intent) checkNotNull(intent)
@ -1612,6 +1631,7 @@ class ChatActivity :
1 -> context.resources?.getString(R.string.nc_upload_confirm_send_single)?.let { 1 -> context.resources?.getString(R.string.nc_upload_confirm_send_single)?.let {
String.format(it, title.trim()) String.format(it, title.trim())
} }
else -> context.resources?.getString(R.string.nc_upload_confirm_send_multiple)?.let { else -> context.resources?.getString(R.string.nc_upload_confirm_send_multiple)?.let {
String.format(it, title.trim()) String.format(it, title.trim())
} }
@ -1651,6 +1671,7 @@ class ChatActivity :
Log.e(javaClass.simpleName, "Something went wrong when trying to upload file", e) Log.e(javaClass.simpleName, "Something went wrong when trying to upload file", e)
} }
} }
REQUEST_CODE_SELECT_CONTACT -> { REQUEST_CODE_SELECT_CONTACT -> {
val contactUri = intent?.data ?: return val contactUri = intent?.data ?: return
val cursor: Cursor? = contentResolver!!.query(contactUri, null, null, null, null) val cursor: Cursor? = contentResolver!!.query(contactUri, null, null, null, null)
@ -1670,6 +1691,7 @@ class ChatActivity :
} }
cursor?.close() cursor?.close()
} }
REQUEST_CODE_PICK_CAMERA -> { REQUEST_CODE_PICK_CAMERA -> {
if (resultCode == RESULT_OK) { if (resultCode == RESULT_OK) {
try { try {
@ -1713,6 +1735,7 @@ class ChatActivity :
} }
} }
} }
REQUEST_CODE_MESSAGE_SEARCH -> { REQUEST_CODE_MESSAGE_SEARCH -> {
val messageId = intent?.getStringExtra(MessageSearchActivity.RESULT_KEY_MESSAGE_ID) val messageId = intent?.getStringExtra(MessageSearchActivity.RESULT_KEY_MESSAGE_ID)
messageId?.let { id -> messageId?.let { id ->
@ -2340,6 +2363,7 @@ class ChatActivity :
pullChatMessages(true, setReadMarker, xChatLastCommonRead) pullChatMessages(true, setReadMarker, xChatLastCommonRead)
} }
} }
HTTP_CODE_PRECONDITION_FAILED -> { HTTP_CODE_PRECONDITION_FAILED -> {
Log.d(TAG, "pullChatMessages - HTTP_CODE_PRECONDITION_FAILED.") Log.d(TAG, "pullChatMessages - HTTP_CODE_PRECONDITION_FAILED.")
@ -2349,6 +2373,7 @@ class ChatActivity :
pastPreconditionFailed = true pastPreconditionFailed = true
} }
} }
HTTP_CODE_OK -> { HTTP_CODE_OK -> {
Log.d(TAG, "pullChatMessages - HTTP_CODE_OK.") Log.d(TAG, "pullChatMessages - HTTP_CODE_OK.")
@ -2763,22 +2788,27 @@ class ChatActivity :
startACall(false, false) startACall(false, false)
true true
} }
R.id.conversation_voice_call -> { R.id.conversation_voice_call -> {
startACall(true, false) startACall(true, false)
true true
} }
R.id.conversation_info -> { R.id.conversation_info -> {
showConversationInfoScreen() showConversationInfoScreen()
true true
} }
R.id.shared_items -> { R.id.shared_items -> {
showSharedItems() showSharedItems()
true true
} }
R.id.conversation_search -> { R.id.conversation_search -> {
startMessageSearch() startMessageSearch()
true true
} }
else -> super.onOptionsItemSelected(item) else -> super.onOptionsItemSelected(item)
} }
} }