mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-11-23 21:45:42 +03:00
Use avatars from server (depending on light/dark mode)
Placeholder avatars now also come from the server. This means themed avatars from the android app itself are no longer used here. The static placeholder icons defined in loadConversationAvatar are only used when the http request fails completely. Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
ad15bca8ec
commit
ed4fa3690d
5 changed files with 22 additions and 23 deletions
|
@ -42,8 +42,6 @@ import com.nextcloud.talk.data.user.model.User
|
|||
import com.nextcloud.talk.databinding.RvItemConversationWithLastMessageBinding
|
||||
import com.nextcloud.talk.extensions.loadAvatar
|
||||
import com.nextcloud.talk.extensions.loadConversationAvatar
|
||||
import com.nextcloud.talk.extensions.loadDefaultGroupCallAvatar
|
||||
import com.nextcloud.talk.extensions.loadDefaultPublicCallAvatar
|
||||
import com.nextcloud.talk.extensions.loadSystemAvatar
|
||||
import com.nextcloud.talk.models.json.chat.ChatMessage
|
||||
import com.nextcloud.talk.models.json.conversations.Conversation
|
||||
|
@ -178,15 +176,9 @@ class ConversationItem(
|
|||
}
|
||||
}
|
||||
|
||||
ConversationType.ROOM_GROUP_CALL ->
|
||||
ConversationType.ROOM_GROUP_CALL, ConversationType.FORMER_ONE_TO_ONE, ConversationType.ROOM_PUBLIC_CALL ->
|
||||
holder.binding.dialogAvatar.loadConversationAvatar(user, model)
|
||||
|
||||
ConversationType.FORMER_ONE_TO_ONE ->
|
||||
holder.binding.dialogAvatar.loadDefaultGroupCallAvatar(viewThemeUtils)
|
||||
|
||||
ConversationType.ROOM_PUBLIC_CALL ->
|
||||
holder.binding.dialogAvatar.loadDefaultPublicCallAvatar(viewThemeUtils)
|
||||
|
||||
else -> holder.binding.dialogAvatar.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,8 +61,7 @@ import com.nextcloud.talk.data.user.model.User
|
|||
import com.nextcloud.talk.databinding.ControllerConversationInfoBinding
|
||||
import com.nextcloud.talk.events.EventStatus
|
||||
import com.nextcloud.talk.extensions.loadAvatar
|
||||
import com.nextcloud.talk.extensions.loadDefaultGroupCallAvatar
|
||||
import com.nextcloud.talk.extensions.loadDefaultPublicCallAvatar
|
||||
import com.nextcloud.talk.extensions.loadConversationAvatar
|
||||
import com.nextcloud.talk.extensions.loadSystemAvatar
|
||||
import com.nextcloud.talk.jobs.DeleteConversationWorker
|
||||
import com.nextcloud.talk.jobs.LeaveConversationWorker
|
||||
|
@ -760,16 +759,13 @@ class ConversationInfoActivity :
|
|||
private fun loadConversationAvatar() {
|
||||
when (conversation!!.type) {
|
||||
Conversation.ConversationType.ROOM_TYPE_ONE_TO_ONE_CALL -> if (!TextUtils.isEmpty(conversation!!.name)) {
|
||||
conversation!!.name?.let { binding?.avatarImage?.loadAvatar(conversationUser!!, it) }
|
||||
conversation!!.name?.let { binding.avatarImage.loadAvatar(conversationUser, it) }
|
||||
}
|
||||
Conversation.ConversationType.ROOM_GROUP_CALL -> {
|
||||
binding?.avatarImage?.loadDefaultGroupCallAvatar(viewThemeUtils)
|
||||
}
|
||||
Conversation.ConversationType.ROOM_PUBLIC_CALL -> {
|
||||
binding?.avatarImage?.loadDefaultPublicCallAvatar(viewThemeUtils)
|
||||
Conversation.ConversationType.ROOM_GROUP_CALL, Conversation.ConversationType.ROOM_PUBLIC_CALL -> {
|
||||
binding.avatarImage.loadConversationAvatar(conversationUser, conversation!!)
|
||||
}
|
||||
Conversation.ConversationType.ROOM_SYSTEM -> {
|
||||
binding?.avatarImage?.loadSystemAvatar()
|
||||
binding.avatarImage.loadSystemAvatar()
|
||||
}
|
||||
|
||||
else -> {
|
||||
|
|
|
@ -44,6 +44,7 @@ import com.nextcloud.talk.data.user.model.User
|
|||
import com.nextcloud.talk.models.json.conversations.Conversation
|
||||
import com.nextcloud.talk.ui.theme.ViewThemeUtils
|
||||
import com.nextcloud.talk.utils.ApiUtils
|
||||
import com.nextcloud.talk.utils.DisplayUtils
|
||||
|
||||
private const val ROUNDING_PIXEL = 16f
|
||||
private const val TAG = "ImageViewExtensions"
|
||||
|
@ -59,9 +60,8 @@ fun ImageView.loadConversationAvatar(
|
|||
conversation.token
|
||||
)
|
||||
|
||||
// TODO: improve this! using the "old" drawables for now. because the themed drawables are not rounded by
|
||||
// themselves and coil is
|
||||
// not able to make placeholders rounded!! https://github.com/coil-kt/coil/issues/37
|
||||
// these placeholders are only used when the request fails completely. The server also return default avatars
|
||||
// when no own images are set. (although these default avatars can not be themed for the android app..)
|
||||
val placeholder =
|
||||
when (conversation.type) {
|
||||
Conversation.ConversationType.ROOM_GROUP_CALL ->
|
||||
|
@ -125,8 +125,14 @@ private fun ImageView.loadAvatarInternal(
|
|||
diskCacheKey?.let { diskCache?.remove(it) }
|
||||
}
|
||||
|
||||
val finalUrl = if (DisplayUtils.isDarkModeOn(this.context)) {
|
||||
"$url/dark"
|
||||
} else {
|
||||
url
|
||||
}
|
||||
|
||||
return DisposableWrapper(
|
||||
load(url) {
|
||||
load(finalUrl) {
|
||||
user?.let {
|
||||
addHeader(
|
||||
"Authorization",
|
||||
|
|
|
@ -108,6 +108,11 @@ public class DisplayUtils {
|
|||
|
||||
private static final int DATE_TIME_PARTS_SIZE = 2;
|
||||
|
||||
public static Boolean isDarkModeOn(Context context) {
|
||||
int currentNightMode = context.getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
|
||||
return currentNightMode == Configuration.UI_MODE_NIGHT_YES;
|
||||
}
|
||||
|
||||
public static void setClickableString(String string, String url, TextView textView) {
|
||||
SpannableString spannableString = new SpannableString(string);
|
||||
spannableString.setSpan(new ClickableSpan() {
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="#61000000"
|
||||
android:fillColor="#DBDBDB"
|
||||
android:fillType="nonZero"
|
||||
android:pathData="M12,20.64C9,20.64 6.348,19.104 4.8,16.8C4.836,14.4 9.6,13.08 12,13.08C14.4,13.08 19.164,14.4 19.2,16.8C17.652,19.104 15,20.64 12,20.64M12,3.6C13.9752,3.6 15.6,5.2248 15.6,7.2C15.6,9.1752 13.9752,10.8 12,10.8C10.0248,10.8 8.4,9.1752 8.4,7.2C8.4,5.2248 10.0248,3.6 12,3.6M12,0C5.4168,0 0,5.4168 0,12C0,18.5832 5.4168,24 12,24C18.5832,24 24,18.5832 24,12C24,5.364 18.6,0 12,0Z" />
|
||||
</vector>
|
||||
|
|
Loading…
Reference in a new issue