Merge pull request #5668 from osmandapp/UiImprovements

Telegram UI Improvements
This commit is contained in:
Alexander Sytnyk 2018-07-13 19:01:34 +03:00 committed by GitHub
commit 1ddb1a76fd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 18 additions and 5 deletions

View file

@ -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
}

View file

@ -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) {

View file

@ -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) {

View file

@ -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) {

View file

@ -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 {