diff --git a/OsmAnd-telegram/src/net/osmand/telegram/helpers/TelegramHelper.kt b/OsmAnd-telegram/src/net/osmand/telegram/helpers/TelegramHelper.kt index d055bae924..b38de9a5cd 100644 --- a/OsmAnd-telegram/src/net/osmand/telegram/helpers/TelegramHelper.kt +++ b/OsmAnd-telegram/src/net/osmand/telegram/helpers/TelegramHelper.kt @@ -129,6 +129,10 @@ class TelegramHelper private constructor() { fun getSupergroupFullInfo(id: Int) = supergroupsFullInfo[id] + fun isGroup(chat: TdApi.Chat): Boolean { + return chat.type is TdApi.ChatTypeSupergroup || chat.type is TdApi.ChatTypeBasicGroup + } + private fun isChannel(chat: TdApi.Chat): Boolean { return chat.type is TdApi.ChatTypeSupergroup && (chat.type as TdApi.ChatTypeSupergroup).isChannel } diff --git a/OsmAnd-telegram/src/net/osmand/telegram/helpers/TelegramUiHelper.kt b/OsmAnd-telegram/src/net/osmand/telegram/helpers/TelegramUiHelper.kt index 9c4146612f..7a6894e348 100644 --- a/OsmAnd-telegram/src/net/osmand/telegram/helpers/TelegramUiHelper.kt +++ b/OsmAnd-telegram/src/net/osmand/telegram/helpers/TelegramUiHelper.kt @@ -15,7 +15,8 @@ object TelegramUiHelper { app: TelegramApplication, iv: ImageView?, photoPath: String?, - placeholderId: Int = R.drawable.img_user_picture + placeholderId: Int = R.drawable.img_user_picture, + useThemedIcon: Boolean = true ) { if (iv == null) { return @@ -26,12 +27,11 @@ object TelegramUiHelper { bitmap = app.uiUtils.getCircleBitmap(photoPath) } if (bitmap == null) { - drawable = - if (placeholderId == R.drawable.img_user_picture || placeholderId == R.drawable.img_group_picture) { - app.uiUtils.getIcon(placeholderId) - } else { - app.uiUtils.getThemedIcon(placeholderId) - } + drawable = if (useThemedIcon) { + app.uiUtils.getThemedIcon(placeholderId) + } else { + app.uiUtils.getIcon(placeholderId) + } } if (bitmap != null) { iv.setImageBitmap(bitmap) diff --git a/OsmAnd-telegram/src/net/osmand/telegram/ui/MyLocationTabFragment.kt b/OsmAnd-telegram/src/net/osmand/telegram/ui/MyLocationTabFragment.kt index d5bb51fb1b..b76a56ff77 100644 --- a/OsmAnd-telegram/src/net/osmand/telegram/ui/MyLocationTabFragment.kt +++ b/OsmAnd-telegram/src/net/osmand/telegram/ui/MyLocationTabFragment.kt @@ -344,14 +344,9 @@ class MyLocationTabFragment : Fragment(), TelegramListener { override fun onBindViewHolder(holder: ChatViewHolder, position: Int) { val chat = chats[position] val lastItem = position == itemCount - 1 - val placeholderId: Int = - if (chat.type is TdApi.ChatTypeBasicGroup || chat.type is TdApi.ChatTypeSupergroup) { - R.drawable.img_group_picture - } else { - R.drawable.img_user_picture - } + val placeholderId: Int = if (telegramHelper.isGroup(chat)) R.drawable.img_group_picture else R.drawable.img_user_picture - TelegramUiHelper.setupPhoto(app, holder.icon, chat.photo?.small?.local?.path, placeholderId) + TelegramUiHelper.setupPhoto(app, holder.icon, chat.photo?.small?.local?.path, placeholderId, false) holder.title?.text = chat.title holder.description?.text = "Some description" // FIXME holder.checkBox?.apply { diff --git a/OsmAnd-telegram/src/net/osmand/telegram/ui/SetTimeDialogFragment.kt b/OsmAnd-telegram/src/net/osmand/telegram/ui/SetTimeDialogFragment.kt index 5f907c14b8..401dde0643 100644 --- a/OsmAnd-telegram/src/net/osmand/telegram/ui/SetTimeDialogFragment.kt +++ b/OsmAnd-telegram/src/net/osmand/telegram/ui/SetTimeDialogFragment.kt @@ -208,14 +208,9 @@ class SetTimeDialogFragment : DialogFragment() { override fun onBindViewHolder(holder: ChatViewHolder, position: Int) { val chat = chats[position] - val placeholderId: Int = - if (chat.type is TdApi.ChatTypeBasicGroup || chat.type is TdApi.ChatTypeSupergroup) { - R.drawable.img_group_picture - } else { - R.drawable.img_user_picture - } + val placeholderId: Int = if (telegramHelper.isGroup(chat)) R.drawable.img_group_picture else R.drawable.img_user_picture - TelegramUiHelper.setupPhoto(app, holder.icon, chat.photo?.small?.local?.path, placeholderId) + TelegramUiHelper.setupPhoto(app, holder.icon, chat.photo?.small?.local?.path, placeholderId, false) holder.title?.text = chat.title holder.description?.text = "Some description" // FIXME holder.textInArea?.apply {