mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-24 02:25:19 +00:00
Ignore swipe on selected message
This commit is contained in:
parent
2988ac8b7a
commit
7a44c27936
@ -66,11 +66,7 @@ class ConversationAdapter(context: Context, cursor: Cursor, private val onItemPr
|
||||
is VisibleMessageViewHolder -> {
|
||||
val view = viewHolder.view
|
||||
val isSelected = selectedItems.contains(message)
|
||||
view.background = if (isSelected) {
|
||||
ColorDrawable(context.resources.getColorWithID(R.color.accent, context.theme))
|
||||
} else {
|
||||
null
|
||||
}
|
||||
view.snIsSelected = isSelected
|
||||
view.messageTimestampTextView.isVisible = isSelected
|
||||
val position = viewHolder.adapterPosition
|
||||
view.bind(message, getMessageBefore(position, cursor), getMessageAfter(position, cursor))
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.thoughtcrime.securesms.conversation.v2.messages
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.drawable.ColorDrawable
|
||||
import android.os.Build
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
@ -14,6 +15,7 @@ import org.session.libsession.messaging.contacts.Contact.ContactContext
|
||||
import org.session.libsession.utilities.ViewUtil
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory
|
||||
import org.thoughtcrime.securesms.database.model.MessageRecord
|
||||
import org.thoughtcrime.securesms.loki.utilities.getColorWithID
|
||||
import org.thoughtcrime.securesms.loki.utilities.toDp
|
||||
import org.thoughtcrime.securesms.util.DateUtils
|
||||
import java.util.*
|
||||
@ -27,6 +29,8 @@ class VisibleMessageView : LinearLayout {
|
||||
private val gestureHandler = Handler(Looper.getMainLooper())
|
||||
private var longPressCallback: Runnable? = null
|
||||
private var onDownTimestamp = 0L
|
||||
var snIsSelected = false
|
||||
set(value) { field = value; handleIsSelectedChanged()}
|
||||
var onPress: (() -> Unit)? = null
|
||||
var onSwipeToReply: (() -> Unit)? = null
|
||||
var onLongPress: (() -> Unit)? = null
|
||||
@ -135,6 +139,14 @@ class VisibleMessageView : LinearLayout {
|
||||
}
|
||||
}
|
||||
|
||||
private fun handleIsSelectedChanged() {
|
||||
background = if (snIsSelected) {
|
||||
ColorDrawable(context.resources.getColorWithID(R.color.accent, context.theme))
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
fun recycle() {
|
||||
profilePictureView.recycle()
|
||||
messageContentView.recycle()
|
||||
@ -162,7 +174,7 @@ class VisibleMessageView : LinearLayout {
|
||||
|
||||
private fun onMove(event: MotionEvent) {
|
||||
val translationX = toDp(event.rawX + dx, context.resources)
|
||||
if (abs(translationX) < VisibleMessageView.longPressMovementTreshold) {
|
||||
if (abs(translationX) < VisibleMessageView.longPressMovementTreshold || snIsSelected) {
|
||||
return
|
||||
} else {
|
||||
longPressCallback?.let { gestureHandler.removeCallbacks(it) }
|
||||
|
Loading…
Reference in New Issue
Block a user