Merge pull request #5668 from osmandapp/UiImprovements
Telegram UI Improvements
This commit is contained in:
commit
1ddb1a76fd
5 changed files with 18 additions and 5 deletions
|
@ -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
|
||||
}
|
||||
|
|
|
@ -15,7 +15,8 @@ object TelegramUiHelper {
|
|||
app: TelegramApplication,
|
||||
iv: ImageView?,
|
||||
photoPath: String?,
|
||||
placeholderId: Int = R.drawable.img_user_picture
|
||||
placeholderId: Int,
|
||||
useThemedIcon: Boolean
|
||||
) {
|
||||
if (iv == null) {
|
||||
return
|
||||
|
@ -26,7 +27,11 @@ object TelegramUiHelper {
|
|||
bitmap = app.uiUtils.getCircleBitmap(photoPath)
|
||||
}
|
||||
if (bitmap == null) {
|
||||
drawable = app.uiUtils.getIcon(placeholderId)
|
||||
drawable = if (useThemedIcon) {
|
||||
app.uiUtils.getThemedIcon(placeholderId)
|
||||
} else {
|
||||
app.uiUtils.getIcon(placeholderId)
|
||||
}
|
||||
}
|
||||
if (bitmap != null) {
|
||||
iv.setImageBitmap(bitmap)
|
||||
|
@ -60,8 +65,10 @@ object TelegramUiHelper {
|
|||
}
|
||||
}
|
||||
} else if (type is TdApi.ChatTypeBasicGroup) {
|
||||
res.placeholderId = R.drawable.img_group_picture
|
||||
res.membersCount = helper.getBasicGroupFullInfo(type.basicGroupId)?.members?.size ?: 0
|
||||
} else if (type is TdApi.ChatTypeSupergroup) {
|
||||
res.placeholderId = R.drawable.img_group_picture
|
||||
res.membersCount = helper.getSupergroupFullInfo(type.supergroupId)?.memberCount ?: 0
|
||||
}
|
||||
if (!res.privateChat) {
|
||||
|
|
|
@ -244,7 +244,7 @@ class LiveNowTabFragment : Fragment(), TelegramListener, TelegramIncomingMessage
|
|||
val canBeOpenedOnMap = item.canBeOpenedOnMap()
|
||||
val openOnMapView = holder.getOpenOnMapClickView()
|
||||
|
||||
TelegramUiHelper.setupPhoto(app, holder.icon, item.photoPath, item.placeholderId)
|
||||
TelegramUiHelper.setupPhoto(app, holder.icon, item.photoPath, item.placeholderId, false)
|
||||
holder.title?.text = item.getVisibleName()
|
||||
openOnMapView?.isEnabled = canBeOpenedOnMap
|
||||
if (canBeOpenedOnMap) {
|
||||
|
|
|
@ -355,9 +355,10 @@ class MyLocationTabFragment : Fragment(), TelegramListener {
|
|||
override fun onBindViewHolder(holder: ChatViewHolder, position: Int) {
|
||||
val chat = chats[position]
|
||||
val lastItem = position == itemCount - 1
|
||||
val placeholderId = if (telegramHelper.isGroup(chat)) R.drawable.img_group_picture else R.drawable.img_user_picture
|
||||
val live = app.settings.isSharingLocationToChat(chat.id)
|
||||
|
||||
TelegramUiHelper.setupPhoto(app, holder.icon, chat.photo?.small?.local?.path)
|
||||
TelegramUiHelper.setupPhoto(app, holder.icon, chat.photo?.small?.local?.path, placeholderId, false)
|
||||
holder.title?.text = chat.title
|
||||
holder.description?.text = "Some description" // FIXME
|
||||
if (live) {
|
||||
|
|
|
@ -212,8 +212,9 @@ class SetTimeDialogFragment : DialogFragment() {
|
|||
|
||||
override fun onBindViewHolder(holder: ChatViewHolder, position: Int) {
|
||||
val chat = chats[position]
|
||||
val placeholderId = 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)
|
||||
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 {
|
||||
|
|
Loading…
Reference in a new issue