forked from melod1n/fast-messenger
visual improvements
new icon
This commit is contained in:
@@ -11,6 +11,7 @@ import kotlinx.parcelize.Parcelize
|
||||
data class VkConversation(
|
||||
@PrimaryKey(autoGenerate = false)
|
||||
val id: Int,
|
||||
val ownerId: Int?,
|
||||
val title: String?,
|
||||
val photo200: String?,
|
||||
val type: String,
|
||||
@@ -22,7 +23,8 @@ data class VkConversation(
|
||||
val isMarkedUnread: Boolean,
|
||||
val lastMessageId: Int,
|
||||
val unreadCount: Int?,
|
||||
val membersCount: Int?
|
||||
val membersCount: Int?,
|
||||
val isPinned: Boolean
|
||||
) : Parcelable {
|
||||
@Ignore
|
||||
var lastMessage: VkMessage? = null
|
||||
|
||||
@@ -51,7 +51,9 @@ data class BaseVkConversation(
|
||||
isMarkedUnread = isMarkedUnread,
|
||||
lastMessageId = lastMessageId,
|
||||
unreadCount = unreadCount,
|
||||
membersCount = chatSettings?.membersCount
|
||||
membersCount = chatSettings?.membersCount,
|
||||
ownerId = chatSettings?.ownerId,
|
||||
isPinned = sortId.majorId > 0
|
||||
).apply { this.lastMessage = lastMessage }
|
||||
|
||||
@Parcelize
|
||||
|
||||
@@ -18,7 +18,7 @@ import com.meloda.fast.database.dao.UsersDao
|
||||
VkUser::class,
|
||||
VkGroup::class
|
||||
],
|
||||
version = 13,
|
||||
version = 15,
|
||||
exportSchema = false
|
||||
)
|
||||
abstract class AppDatabase : RoomDatabase() {
|
||||
|
||||
@@ -1,15 +1,19 @@
|
||||
package com.meloda.fast.screens.conversations
|
||||
|
||||
import android.content.Context
|
||||
import android.content.res.ColorStateList
|
||||
import android.graphics.drawable.ColorDrawable
|
||||
import android.text.SpannableString
|
||||
import android.text.style.ForegroundColorSpan
|
||||
import android.view.ViewGroup
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.core.view.setPadding
|
||||
import androidx.recyclerview.widget.DiffUtil
|
||||
import coil.load
|
||||
import com.meloda.fast.R
|
||||
import com.meloda.fast.api.UserConfig
|
||||
import com.meloda.fast.api.VKConstants
|
||||
import com.meloda.fast.api.VkUtils
|
||||
import com.meloda.fast.api.model.VkConversation
|
||||
import com.meloda.fast.api.model.VkGroup
|
||||
@@ -76,6 +80,7 @@ class ConversationsAdapter constructor(
|
||||
} else null
|
||||
|
||||
val avatar = when {
|
||||
conversation.ownerId == VKConstants.FAST_GROUP_ID -> null
|
||||
conversation.isUser() && chatUser != null && !chatUser.photo200.isNullOrBlank() -> chatUser.photo200
|
||||
conversation.isGroup() && chatGroup != null && !chatGroup.photo200.isNullOrBlank() -> chatGroup.photo200
|
||||
conversation.isChat() && !conversation.photo200.isNullOrBlank() -> conversation.photo200
|
||||
@@ -86,13 +91,36 @@ class ConversationsAdapter constructor(
|
||||
binding.avatarPlaceholder.isVisible = avatar == null
|
||||
|
||||
if (avatar == null) {
|
||||
binding.avatar.setImageDrawable(null)
|
||||
if (conversation.ownerId == VKConstants.FAST_GROUP_ID) {
|
||||
binding.placeholderBack.setImageDrawable(
|
||||
ColorDrawable(
|
||||
ContextCompat.getColor(context, R.color.a1_400)
|
||||
)
|
||||
)
|
||||
binding.placeholder.imageTintList =
|
||||
ColorStateList.valueOf(ContextCompat.getColor(context, R.color.a1_0))
|
||||
binding.placeholder.setImageResource(R.drawable.ic_fast_logo)
|
||||
binding.placeholder.setPadding(18)
|
||||
} else {
|
||||
binding.placeholderBack.setImageDrawable(
|
||||
ColorDrawable(
|
||||
ContextCompat.getColor(context, R.color.n1_50)
|
||||
)
|
||||
)
|
||||
binding.placeholder.imageTintList =
|
||||
ColorStateList.valueOf(ContextCompat.getColor(context, R.color.n2_500))
|
||||
binding.placeholder.setImageResource(R.drawable.ic_account_circle_cut)
|
||||
binding.placeholder.setPadding(0)
|
||||
binding.avatar.setImageDrawable(null)
|
||||
}
|
||||
} else {
|
||||
binding.avatar.load(avatar) { crossfade(200) }
|
||||
}
|
||||
|
||||
binding.online.isVisible = chatUser?.online == true
|
||||
|
||||
binding.pin.isVisible = conversation.isPinned
|
||||
|
||||
val actionMessage = VkUtils.getActionConversationText(
|
||||
message = message,
|
||||
youPrefix = youPrefix,
|
||||
@@ -157,10 +185,8 @@ class ConversationsAdapter constructor(
|
||||
prefix.length + coloredMessage.length,
|
||||
0
|
||||
)
|
||||
|
||||
binding.message.text = spanMessage
|
||||
// } else {
|
||||
// binding.message.text = messageText
|
||||
// }
|
||||
|
||||
binding.title.text =
|
||||
getItem(position).title ?: chatUser?.toString() ?: chatGroup?.name ?: "..."
|
||||
|
||||
@@ -8,6 +8,7 @@ import androidx.core.view.isVisible
|
||||
import androidx.fragment.app.viewModels
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import coil.load
|
||||
import com.google.android.material.appbar.AppBarLayout
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
import com.meloda.fast.R
|
||||
import com.meloda.fast.api.UserConfig
|
||||
@@ -19,6 +20,7 @@ import com.meloda.fast.base.viewmodel.VKEvent
|
||||
import com.meloda.fast.databinding.FragmentConversationsBinding
|
||||
import com.meloda.fast.util.AndroidUtils
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import kotlin.math.abs
|
||||
|
||||
@AndroidEntryPoint
|
||||
class ConversationsFragment :
|
||||
@@ -57,6 +59,19 @@ class ConversationsFragment :
|
||||
UserConfig.vkUser.observe(viewLifecycleOwner) {
|
||||
it?.let { user -> binding.avatar.load(user.photo200) { crossfade(100) } }
|
||||
}
|
||||
|
||||
binding.appBar.addOnOffsetChangedListener(AppBarLayout.OnOffsetChangedListener { appBarLayout, verticalOffset ->
|
||||
if (verticalOffset <= -100) {
|
||||
binding.avatarContainer.alpha = 0f
|
||||
return@OnOffsetChangedListener
|
||||
}
|
||||
|
||||
val alpha = 1 - abs(verticalOffset * 0.01).toFloat()
|
||||
|
||||
// println("offset: $verticalOffset; alpha: $alpha")
|
||||
|
||||
binding.avatarContainer.alpha = alpha
|
||||
})
|
||||
}
|
||||
|
||||
override fun onEvent(event: VKEvent) {
|
||||
|
||||
Reference in New Issue
Block a user