Fixed some poor quality drawables + changes to allow swipe action to reply to chat message (disabled for now)
This commit is contained in:
parent
9395ea88a5
commit
0378848f10
7 changed files with 54 additions and 20 deletions
|
@ -36,6 +36,7 @@ import androidx.databinding.ViewDataBinding
|
|||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import androidx.recyclerview.widget.ItemTouchHelper
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import java.io.File
|
||||
|
@ -225,27 +226,32 @@ class DetailChatRoomFragment : MasterFragment<ChatRoomDetailFragmentBinding, Cha
|
|||
}
|
||||
)
|
||||
|
||||
// Swipe action
|
||||
/*val swipeConfiguration = RecyclerViewSwipeConfiguration()
|
||||
swipeConfiguration.leftToRightAction = RecyclerViewSwipeConfiguration.Action(icon = R.drawable.menu_reply_default)
|
||||
val swipeListener = object : RecyclerViewSwipeListener {
|
||||
override fun onLeftToRightSwipe(viewHolder: RecyclerView.ViewHolder) {
|
||||
adapter.notifyItemChanged(viewHolder.adapterPosition)
|
||||
if (corePreferences.allowSwipeActionOnChatMessage) {
|
||||
// Swipe action
|
||||
val swipeConfiguration = RecyclerViewSwipeConfiguration()
|
||||
swipeConfiguration.leftToRightAction = RecyclerViewSwipeConfiguration.Action(
|
||||
icon = R.drawable.menu_reply,
|
||||
preventFor = ChatMessagesListAdapter.EventViewHolder::class.java
|
||||
)
|
||||
val swipeListener = object : RecyclerViewSwipeListener {
|
||||
override fun onLeftToRightSwipe(viewHolder: RecyclerView.ViewHolder) {
|
||||
adapter.notifyItemChanged(viewHolder.bindingAdapterPosition)
|
||||
|
||||
val chatMessageEventLog = adapter.currentList[viewHolder.adapterPosition]
|
||||
val chatMessage = chatMessageEventLog.chatMessage
|
||||
if (chatMessage != null) {
|
||||
chatSendingViewModel.pendingChatMessageToReplyTo.value?.destroy()
|
||||
chatSendingViewModel.pendingChatMessageToReplyTo.value =
|
||||
ChatMessageData(chatMessage)
|
||||
chatSendingViewModel.isPendingAnswer.value = true
|
||||
val chatMessageEventLog = adapter.currentList[viewHolder.bindingAdapterPosition]
|
||||
val chatMessage = chatMessageEventLog.eventLog.chatMessage
|
||||
if (chatMessage != null) {
|
||||
chatSendingViewModel.pendingChatMessageToReplyTo.value?.destroy()
|
||||
chatSendingViewModel.pendingChatMessageToReplyTo.value =
|
||||
ChatMessageData(chatMessage)
|
||||
chatSendingViewModel.isPendingAnswer.value = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onRightToLeftSwipe(viewHolder: RecyclerView.ViewHolder) {}
|
||||
override fun onRightToLeftSwipe(viewHolder: RecyclerView.ViewHolder) {}
|
||||
}
|
||||
RecyclerViewSwipeUtils(ItemTouchHelper.RIGHT, swipeConfiguration, swipeListener)
|
||||
.attachToRecyclerView(binding.chatMessagesList)
|
||||
}
|
||||
RecyclerViewSwipeUtils(ItemTouchHelper.RIGHT, swipeConfiguration, swipeListener)
|
||||
.attachToRecyclerView(binding.chatMessagesList)*/
|
||||
|
||||
val chatScrollListener = object : ChatScrollListener(layoutManager) {
|
||||
override fun onLoadMore(totalItemsCount: Int) {
|
||||
|
|
|
@ -465,6 +465,9 @@ class CorePreferences constructor(private val context: Context) {
|
|||
val showAllRingtones: Boolean
|
||||
get() = config.getBool("app", "show_all_available_ringtones", false)
|
||||
|
||||
val allowSwipeActionOnChatMessage: Boolean
|
||||
get() = config.getBool("app", "swipe_action_on_chat_messages", false)
|
||||
|
||||
/* Default values related */
|
||||
|
||||
val echoCancellerCalibration: Int
|
||||
|
|
|
@ -46,7 +46,8 @@ class RecyclerViewSwipeConfiguration {
|
|||
val textColor: Int = Color.WHITE,
|
||||
val backgroundColor: Int = 0,
|
||||
val icon: Int = 0,
|
||||
val iconTint: Int = 0
|
||||
val iconTint: Int = 0,
|
||||
val preventFor: Class<*>? = null
|
||||
)
|
||||
|
||||
val iconMargin = 16f
|
||||
|
@ -61,7 +62,7 @@ class RecyclerViewSwipeConfiguration {
|
|||
}
|
||||
|
||||
private class RecyclerViewSwipeUtilsCallback(
|
||||
direction: Int,
|
||||
val direction: Int,
|
||||
val configuration: RecyclerViewSwipeConfiguration,
|
||||
val listener: RecyclerViewSwipeListener
|
||||
) : ItemTouchHelper.SimpleCallback(0, direction) {
|
||||
|
@ -234,6 +235,30 @@ private class RecyclerViewSwipeUtilsCallback(
|
|||
}
|
||||
}
|
||||
|
||||
override fun getSwipeDirs(
|
||||
recyclerView: RecyclerView,
|
||||
viewHolder: RecyclerView.ViewHolder
|
||||
): Int {
|
||||
var dirFlags = direction
|
||||
if (direction and ItemTouchHelper.RIGHT != 0) {
|
||||
val classToPrevent = configuration.leftToRightAction.preventFor
|
||||
if (classToPrevent != null) {
|
||||
if (classToPrevent.isInstance(viewHolder)) {
|
||||
dirFlags = dirFlags and ItemTouchHelper.RIGHT.inv()
|
||||
}
|
||||
}
|
||||
}
|
||||
if (direction or ItemTouchHelper.LEFT != 0) {
|
||||
val classToPrevent = configuration.rightToLeftAction.preventFor
|
||||
if (classToPrevent != null) {
|
||||
if (classToPrevent.isInstance(viewHolder)) {
|
||||
dirFlags = dirFlags and ItemTouchHelper.LEFT.inv()
|
||||
}
|
||||
}
|
||||
}
|
||||
return dirFlags
|
||||
}
|
||||
|
||||
override fun onMove(
|
||||
recyclerView: RecyclerView,
|
||||
viewHolder: RecyclerView.ViewHolder,
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 12 KiB |
Binary file not shown.
Before Width: | Height: | Size: 1.6 KiB |
Binary file not shown.
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 12 KiB |
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item>
|
||||
<bitmap android:src="@drawable/menu_imdn_info_default"
|
||||
<bitmap android:src="@drawable/menu_group_info_default"
|
||||
android:tint="?attr/drawableTintColor"/>
|
||||
</item>
|
||||
</selector>
|
||||
|
|
Loading…
Reference in a new issue