mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-20 12:09:45 +01:00
WIP: show conversation avatar
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
60534aca61
commit
c3b468118a
@ -41,8 +41,9 @@ import com.nextcloud.talk.application.NextcloudTalkApplication.Companion.sharedA
|
|||||||
import com.nextcloud.talk.data.user.model.User
|
import com.nextcloud.talk.data.user.model.User
|
||||||
import com.nextcloud.talk.databinding.RvItemConversationWithLastMessageBinding
|
import com.nextcloud.talk.databinding.RvItemConversationWithLastMessageBinding
|
||||||
import com.nextcloud.talk.extensions.loadAvatar
|
import com.nextcloud.talk.extensions.loadAvatar
|
||||||
import com.nextcloud.talk.extensions.loadGroupCallAvatar
|
import com.nextcloud.talk.extensions.loadConversationAvatar
|
||||||
import com.nextcloud.talk.extensions.loadPublicCallAvatar
|
import com.nextcloud.talk.extensions.loadDefaultGroupCallAvatar
|
||||||
|
import com.nextcloud.talk.extensions.loadDefaultPublicCallAvatar
|
||||||
import com.nextcloud.talk.extensions.loadSystemAvatar
|
import com.nextcloud.talk.extensions.loadSystemAvatar
|
||||||
import com.nextcloud.talk.models.json.chat.ChatMessage
|
import com.nextcloud.talk.models.json.chat.ChatMessage
|
||||||
import com.nextcloud.talk.models.json.conversations.Conversation
|
import com.nextcloud.talk.models.json.conversations.Conversation
|
||||||
@ -169,17 +170,24 @@ class ConversationItem(
|
|||||||
}
|
}
|
||||||
if (shouldLoadAvatar) {
|
if (shouldLoadAvatar) {
|
||||||
when (model.type) {
|
when (model.type) {
|
||||||
ConversationType.ROOM_TYPE_ONE_TO_ONE_CALL -> if (!TextUtils.isEmpty(model.name)) {
|
ConversationType.ROOM_TYPE_ONE_TO_ONE_CALL -> {
|
||||||
holder.binding.dialogAvatar.loadAvatar(user, model.name!!)
|
if (!TextUtils.isEmpty(model.name)) {
|
||||||
} else {
|
holder.binding.dialogAvatar.loadAvatar(user, model.name!!)
|
||||||
holder.binding.dialogAvatar.visibility = View.GONE
|
} else {
|
||||||
|
holder.binding.dialogAvatar.visibility = View.GONE
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ConversationType.ROOM_GROUP_CALL ->
|
ConversationType.ROOM_GROUP_CALL ->
|
||||||
holder.binding.dialogAvatar.loadGroupCallAvatar(viewThemeUtils)
|
// holder.binding.dialogAvatar.loadDefaultGroupCallAvatar(viewThemeUtils)
|
||||||
|
holder.binding.dialogAvatar.loadConversationAvatar(user, model.token!!)
|
||||||
|
|
||||||
ConversationType.FORMER_ONE_TO_ONE ->
|
ConversationType.FORMER_ONE_TO_ONE ->
|
||||||
holder.binding.dialogAvatar.loadGroupCallAvatar(viewThemeUtils)
|
holder.binding.dialogAvatar.loadDefaultGroupCallAvatar(viewThemeUtils)
|
||||||
|
|
||||||
ConversationType.ROOM_PUBLIC_CALL ->
|
ConversationType.ROOM_PUBLIC_CALL ->
|
||||||
holder.binding.dialogAvatar.loadPublicCallAvatar(viewThemeUtils)
|
holder.binding.dialogAvatar.loadDefaultPublicCallAvatar(viewThemeUtils)
|
||||||
|
|
||||||
else -> holder.binding.dialogAvatar.visibility = View.GONE
|
else -> holder.binding.dialogAvatar.visibility = View.GONE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -198,6 +206,7 @@ class ConversationItem(
|
|||||||
)
|
)
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
Conversation.ObjectType.FILE -> {
|
Conversation.ObjectType.FILE -> {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
holder.binding.dialogAvatar.loadAvatar(
|
holder.binding.dialogAvatar.loadAvatar(
|
||||||
@ -213,6 +222,7 @@ class ConversationItem(
|
|||||||
}
|
}
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> true
|
else -> true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -147,7 +147,7 @@ public class ParticipantItem extends AbstractFlexibleItem<ParticipantItem.Partic
|
|||||||
"groups".equals(participant.getSource()) ||
|
"groups".equals(participant.getSource()) ||
|
||||||
participant.getCalculatedActorType() == Participant.ActorType.CIRCLES ||
|
participant.getCalculatedActorType() == Participant.ActorType.CIRCLES ||
|
||||||
"circles".equals(participant.getSource())) {
|
"circles".equals(participant.getSource())) {
|
||||||
ImageViewExtensionsKt.loadGroupCallAvatar(holder.binding.avatarView, viewThemeUtils);
|
ImageViewExtensionsKt.loadDefaultGroupCallAvatar(holder.binding.avatarView, viewThemeUtils);
|
||||||
} else if (participant.getCalculatedActorType() == Participant.ActorType.EMAILS) {
|
} else if (participant.getCalculatedActorType() == Participant.ActorType.EMAILS) {
|
||||||
ImageViewExtensionsKt.loadMailAvatar(holder.binding.avatarView, viewThemeUtils);
|
ImageViewExtensionsKt.loadMailAvatar(holder.binding.avatarView, viewThemeUtils);
|
||||||
} else if (participant.getCalculatedActorType() == Participant.ActorType.GUESTS ||
|
} else if (participant.getCalculatedActorType() == Participant.ActorType.GUESTS ||
|
||||||
|
@ -61,8 +61,8 @@ import com.nextcloud.talk.data.user.model.User
|
|||||||
import com.nextcloud.talk.databinding.ControllerConversationInfoBinding
|
import com.nextcloud.talk.databinding.ControllerConversationInfoBinding
|
||||||
import com.nextcloud.talk.events.EventStatus
|
import com.nextcloud.talk.events.EventStatus
|
||||||
import com.nextcloud.talk.extensions.loadAvatar
|
import com.nextcloud.talk.extensions.loadAvatar
|
||||||
import com.nextcloud.talk.extensions.loadGroupCallAvatar
|
import com.nextcloud.talk.extensions.loadDefaultGroupCallAvatar
|
||||||
import com.nextcloud.talk.extensions.loadPublicCallAvatar
|
import com.nextcloud.talk.extensions.loadDefaultPublicCallAvatar
|
||||||
import com.nextcloud.talk.extensions.loadSystemAvatar
|
import com.nextcloud.talk.extensions.loadSystemAvatar
|
||||||
import com.nextcloud.talk.jobs.DeleteConversationWorker
|
import com.nextcloud.talk.jobs.DeleteConversationWorker
|
||||||
import com.nextcloud.talk.jobs.LeaveConversationWorker
|
import com.nextcloud.talk.jobs.LeaveConversationWorker
|
||||||
@ -763,10 +763,10 @@ class ConversationInfoActivity :
|
|||||||
conversation!!.name?.let { binding?.avatarImage?.loadAvatar(conversationUser!!, it) }
|
conversation!!.name?.let { binding?.avatarImage?.loadAvatar(conversationUser!!, it) }
|
||||||
}
|
}
|
||||||
Conversation.ConversationType.ROOM_GROUP_CALL -> {
|
Conversation.ConversationType.ROOM_GROUP_CALL -> {
|
||||||
binding?.avatarImage?.loadGroupCallAvatar(viewThemeUtils)
|
binding?.avatarImage?.loadDefaultGroupCallAvatar(viewThemeUtils)
|
||||||
}
|
}
|
||||||
Conversation.ConversationType.ROOM_PUBLIC_CALL -> {
|
Conversation.ConversationType.ROOM_PUBLIC_CALL -> {
|
||||||
binding?.avatarImage?.loadPublicCallAvatar(viewThemeUtils)
|
binding?.avatarImage?.loadDefaultPublicCallAvatar(viewThemeUtils)
|
||||||
}
|
}
|
||||||
Conversation.ConversationType.ROOM_SYSTEM -> {
|
Conversation.ConversationType.ROOM_SYSTEM -> {
|
||||||
binding?.avatarImage?.loadSystemAvatar()
|
binding?.avatarImage?.loadSystemAvatar()
|
||||||
|
@ -47,6 +47,20 @@ import com.nextcloud.talk.utils.ApiUtils
|
|||||||
private const val ROUNDING_PIXEL = 16f
|
private const val ROUNDING_PIXEL = 16f
|
||||||
private const val TAG = "ImageViewExtensions"
|
private const val TAG = "ImageViewExtensions"
|
||||||
|
|
||||||
|
fun ImageView.loadConversationAvatar(
|
||||||
|
user: User,
|
||||||
|
roomToken: String
|
||||||
|
): io.reactivex.disposables
|
||||||
|
.Disposable {
|
||||||
|
val imageRequestUri = ApiUtils.getUrlForConversationAvatar(
|
||||||
|
1,
|
||||||
|
user.baseUrl,
|
||||||
|
roomToken
|
||||||
|
)
|
||||||
|
|
||||||
|
return loadAvatarInternal(user, imageRequestUri, false)
|
||||||
|
}
|
||||||
|
|
||||||
fun ImageView.loadAvatar(
|
fun ImageView.loadAvatar(
|
||||||
user: User,
|
user: User,
|
||||||
avatar: String,
|
avatar: String,
|
||||||
@ -223,7 +237,7 @@ fun ImageView.loadBotsAvatar(): io.reactivex.disposables.Disposable {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun ImageView.loadGroupCallAvatar(viewThemeUtils: ViewThemeUtils): io.reactivex.disposables.Disposable {
|
fun ImageView.loadDefaultGroupCallAvatar(viewThemeUtils: ViewThemeUtils): io.reactivex.disposables.Disposable {
|
||||||
val data: Any = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
val data: Any = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
viewThemeUtils.talk.themePlaceholderAvatar(this, R.drawable.ic_avatar_group) as Any
|
viewThemeUtils.talk.themePlaceholderAvatar(this, R.drawable.ic_avatar_group) as Any
|
||||||
} else {
|
} else {
|
||||||
@ -232,7 +246,7 @@ fun ImageView.loadGroupCallAvatar(viewThemeUtils: ViewThemeUtils): io.reactivex.
|
|||||||
return loadAvatar(data)
|
return loadAvatar(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun ImageView.loadPublicCallAvatar(viewThemeUtils: ViewThemeUtils): io.reactivex.disposables.Disposable {
|
fun ImageView.loadDefaultPublicCallAvatar(viewThemeUtils: ViewThemeUtils): io.reactivex.disposables.Disposable {
|
||||||
val data: Any = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
val data: Any = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
viewThemeUtils.talk.themePlaceholderAvatar(this, R.drawable.ic_avatar_link) as Any
|
viewThemeUtils.talk.themePlaceholderAvatar(this, R.drawable.ic_avatar_link) as Any
|
||||||
} else {
|
} else {
|
||||||
|
@ -375,6 +375,10 @@ public class ApiUtils {
|
|||||||
return baseUrl + "/index.php/avatar/guest/" + Uri.encode(name) + "/" + avatarSize;
|
return baseUrl + "/index.php/avatar/guest/" + Uri.encode(name) + "/" + avatarSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getUrlForConversationAvatar(int version, String baseUrl, String token) {
|
||||||
|
return getUrlForRoom(version, baseUrl, token) + "/avatar";
|
||||||
|
}
|
||||||
|
|
||||||
public static String getCredentials(String username, String token) {
|
public static String getCredentials(String username, String token) {
|
||||||
if (TextUtils.isEmpty(username) && TextUtils.isEmpty(token)) {
|
if (TextUtils.isEmpty(username) && TextUtils.isEmpty(token)) {
|
||||||
return null;
|
return null;
|
||||||
|
Loading…
Reference in New Issue
Block a user