Merge pull request #5770 from osmandapp/TelegramUiImprovements
Telegram ui improvements
This commit is contained in:
commit
d3b1900185
6 changed files with 50 additions and 10 deletions
|
@ -40,6 +40,7 @@
|
|||
android:animateLayoutChanges="true"
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="@dimen/my_location_text_sides_margin"
|
||||
android:layout_marginBottom="@dimen/content_padding_standard"
|
||||
android:paddingRight="@dimen/my_location_text_sides_margin">
|
||||
|
||||
<LinearLayout
|
||||
|
@ -93,7 +94,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/content_padding_half"
|
||||
android:layout_marginRight="@dimen/content_padding_half"
|
||||
android:layout_marginTop="@dimen/content_padding_standard"
|
||||
android:visibility="gone"
|
||||
tools:background="@drawable/btn_round">
|
||||
|
||||
<LinearLayout
|
||||
|
|
|
@ -89,7 +89,8 @@
|
|||
android:layout_marginRight="4dp"
|
||||
android:text="•"
|
||||
android:textColor="?attr/android:textColorSecondary"
|
||||
android:textSize="@dimen/list_item_description_text_size"/>
|
||||
android:textSize="@dimen/list_item_description_text_size"
|
||||
android:visibility="invisible" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
|
|
@ -87,7 +87,8 @@
|
|||
android:layout_marginRight="4dp"
|
||||
android:text="•"
|
||||
android:textColor="?attr/android:textColorSecondary"
|
||||
android:textSize="@dimen/list_item_description_text_size"/>
|
||||
android:textSize="@dimen/list_item_description_text_size"
|
||||
android:visibility="invisible" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
|
|
@ -67,6 +67,7 @@ class TelegramHelper private constructor() {
|
|||
private var telegramAuthorizationRequestHandler: TelegramAuthorizationRequestHandler? = null
|
||||
|
||||
private var client: Client? = null
|
||||
private var currentUser: TdApi.User? = null
|
||||
|
||||
private var haveFullChatList: Boolean = false
|
||||
private var needRefreshActiveLiveLocationMessages: Boolean = true
|
||||
|
@ -103,6 +104,8 @@ class TelegramHelper private constructor() {
|
|||
|
||||
fun getUser(id: Int) = users[id]
|
||||
|
||||
fun getCurrentUser() = currentUser
|
||||
|
||||
fun getUserMessage(user: TdApi.User) =
|
||||
usersLocationMessages.values.firstOrNull { it.senderUserId == user.id }
|
||||
|
||||
|
@ -133,6 +136,8 @@ class TelegramHelper private constructor() {
|
|||
return chat.type is TdApi.ChatTypeSupergroup || chat.type is TdApi.ChatTypeBasicGroup
|
||||
}
|
||||
|
||||
fun isPrivateChat(chat: TdApi.Chat): Boolean = chat.type is TdApi.ChatTypePrivate
|
||||
|
||||
private fun isChannel(chat: TdApi.Chat): Boolean {
|
||||
return chat.type is TdApi.ChatTypeSupergroup && (chat.type as TdApi.ChatTypeSupergroup).isChannel
|
||||
}
|
||||
|
@ -345,6 +350,20 @@ class TelegramHelper private constructor() {
|
|||
listener?.onTelegramChatsRead()
|
||||
}
|
||||
|
||||
private fun requestCurrentUser(){
|
||||
client?.send(TdApi.GetMe()) { obj ->
|
||||
when (obj.constructor) {
|
||||
TdApi.Error.CONSTRUCTOR -> {
|
||||
val error = obj as TdApi.Error
|
||||
if (error.code != IGNORED_ERROR_CODE) {
|
||||
listener?.onTelegramError(error.code, error.message)
|
||||
}
|
||||
}
|
||||
TdApi.User.CONSTRUCTOR -> currentUser = obj as TdApi.User
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun requestMessage(chatId: Long, messageId: Long, onComplete: (TdApi.Message) -> Unit) {
|
||||
client?.send(TdApi.GetMessage(chatId, messageId)) { obj ->
|
||||
when (obj.constructor) {
|
||||
|
@ -589,6 +608,7 @@ class TelegramHelper private constructor() {
|
|||
needRefreshActiveLiveLocationMessages = true
|
||||
if (haveAuthorization) {
|
||||
requestChats(true)
|
||||
requestCurrentUser()
|
||||
}
|
||||
}
|
||||
val newAuthState = getTelegramAuthorizationState()
|
||||
|
|
|
@ -283,7 +283,7 @@ class LiveNowTabFragment : Fragment(), TelegramListener, TelegramIncomingMessage
|
|||
holder.showOnMapState?.text = menuList[stateTextInd]
|
||||
holder.bottomDivider?.visibility = if (nextIsLocation) View.VISIBLE else View.GONE
|
||||
} else if (item is LocationItem && holder is ContactViewHolder) {
|
||||
holder.description?.text = "Some description"
|
||||
holder.description?.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -292,11 +292,11 @@ class LiveNowTabFragment : Fragment(), TelegramListener, TelegramIncomingMessage
|
|||
private fun getChatItemDescription(item: ChatItem): String {
|
||||
return when {
|
||||
item.chatWithBot -> getString(R.string.shared_string_bot)
|
||||
item.privateChat -> "Chat description" // FIXME
|
||||
item.privateChat -> "" // FIXME
|
||||
else -> {
|
||||
val live = getString(R.string.shared_string_live)
|
||||
val all = getString(R.string.shared_string_all)
|
||||
"$live ${item.liveMembersCount} • $all ${item.membersCount}"
|
||||
// val all = getString(R.string.shared_string_all)
|
||||
"$live ${item.liveMembersCount}"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -95,7 +95,7 @@ class MyLocationTabFragment : Fragment(), TelegramListener {
|
|||
if (collapsed != appBarCollapsed) {
|
||||
appBarCollapsed = collapsed
|
||||
adjustText()
|
||||
adjustSearchBox()
|
||||
adjustAppbar()
|
||||
optionsBtn.visibility = if (collapsed) View.VISIBLE else View.GONE
|
||||
}
|
||||
}
|
||||
|
@ -279,6 +279,17 @@ class MyLocationTabFragment : Fragment(), TelegramListener {
|
|||
description.gravity = gravity
|
||||
}
|
||||
|
||||
private fun adjustAppbar() {
|
||||
updateTitleTextColor()
|
||||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
if (appBarCollapsed) {
|
||||
appBarLayout.outlineProvider = appBarOutlineProvider
|
||||
} else {
|
||||
appBarLayout.outlineProvider = null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun adjustSearchBox() {
|
||||
val cornerRadiusFrom = if (appBarCollapsed) searchBoxHeight / 2 else 0
|
||||
val cornerRadiusTo = if (appBarCollapsed) 0 else searchBoxHeight / 2
|
||||
|
@ -329,9 +340,15 @@ class MyLocationTabFragment : Fragment(), TelegramListener {
|
|||
private fun updateList() {
|
||||
val chatList = telegramHelper.getChatList()
|
||||
val chats: MutableList<TdApi.Chat> = mutableListOf()
|
||||
val currentUser = telegramHelper.getCurrentUser()
|
||||
for (orderedChat in chatList) {
|
||||
val chat = telegramHelper.getChat(orderedChat.chatId)
|
||||
if (chat != null) {
|
||||
if (telegramHelper.isPrivateChat(chat)) {
|
||||
if ((chat.type as TdApi.ChatTypePrivate).userId == currentUser?.id) {
|
||||
continue
|
||||
}
|
||||
}
|
||||
chats.add(chat)
|
||||
}
|
||||
}
|
||||
|
@ -360,7 +377,7 @@ class MyLocationTabFragment : Fragment(), TelegramListener {
|
|||
|
||||
TelegramUiHelper.setupPhoto(app, holder.icon, chat.photo?.small?.local?.path, placeholderId, false)
|
||||
holder.title?.text = chat.title
|
||||
holder.description?.text = "Some description" // FIXME
|
||||
holder.description?.visibility = View.GONE
|
||||
if (live) {
|
||||
holder.checkBox?.visibility = View.GONE
|
||||
holder.textInArea?.visibility = View.VISIBLE
|
||||
|
|
Loading…
Reference in a new issue