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