mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-25 09:17:44 +00:00
Fix gestures interfering with eachother
This commit is contained in:
parent
48df733773
commit
ae078d8ee9
@ -30,6 +30,7 @@ import org.thoughtcrime.securesms.conversation.v2.input_bar.InputBarRecordingVie
|
|||||||
import org.thoughtcrime.securesms.conversation.v2.input_bar.mentions.MentionCandidatesView
|
import org.thoughtcrime.securesms.conversation.v2.input_bar.mentions.MentionCandidatesView
|
||||||
import org.thoughtcrime.securesms.conversation.v2.menus.ConversationActionModeCallback
|
import org.thoughtcrime.securesms.conversation.v2.menus.ConversationActionModeCallback
|
||||||
import org.thoughtcrime.securesms.conversation.v2.menus.ConversationMenuHelper
|
import org.thoughtcrime.securesms.conversation.v2.menus.ConversationMenuHelper
|
||||||
|
import org.thoughtcrime.securesms.conversation.v2.messages.VisibleMessageView
|
||||||
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.toPx
|
import org.thoughtcrime.securesms.loki.utilities.toPx
|
||||||
@ -54,8 +55,8 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
|
|||||||
val adapter = ConversationAdapter(
|
val adapter = ConversationAdapter(
|
||||||
this,
|
this,
|
||||||
cursor,
|
cursor,
|
||||||
onItemPress = { message, position ->
|
onItemPress = { message, position, view ->
|
||||||
handlePress(message, position)
|
handlePress(message, position, view)
|
||||||
},
|
},
|
||||||
onItemSwipeToReply = { message, position ->
|
onItemSwipeToReply = { message, position ->
|
||||||
handleSwipeToReply(message, position)
|
handleSwipeToReply(message, position)
|
||||||
@ -285,7 +286,7 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
|
|||||||
}
|
}
|
||||||
|
|
||||||
// `position` is the adapter position; not the visual position
|
// `position` is the adapter position; not the visual position
|
||||||
private fun handlePress(message: MessageRecord, position: Int) {
|
private fun handlePress(message: MessageRecord, position: Int, view: VisibleMessageView) {
|
||||||
val actionMode = this.actionMode
|
val actionMode = this.actionMode
|
||||||
if (actionMode != null) {
|
if (actionMode != null) {
|
||||||
adapter.toggleSelection(message, position)
|
adapter.toggleSelection(message, position)
|
||||||
@ -295,6 +296,8 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
|
|||||||
actionMode.finish()
|
actionMode.finish()
|
||||||
this.actionMode = null
|
this.actionMode = null
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
view.onContentClick()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ import org.thoughtcrime.securesms.database.model.MessageRecord
|
|||||||
import org.thoughtcrime.securesms.loki.utilities.getColorWithID
|
import org.thoughtcrime.securesms.loki.utilities.getColorWithID
|
||||||
import java.lang.IllegalStateException
|
import java.lang.IllegalStateException
|
||||||
|
|
||||||
class ConversationAdapter(context: Context, cursor: Cursor, private val onItemPress: (MessageRecord, Int) -> Unit,
|
class ConversationAdapter(context: Context, cursor: Cursor, private val onItemPress: (MessageRecord, Int, VisibleMessageView) -> Unit,
|
||||||
private val onItemSwipeToReply: (MessageRecord, Int) -> Unit, private val onItemLongPress: (MessageRecord, Int) -> Unit)
|
private val onItemSwipeToReply: (MessageRecord, Int) -> Unit, private val onItemLongPress: (MessageRecord, Int) -> Unit)
|
||||||
: CursorRecyclerViewAdapter<ViewHolder>(context, cursor) {
|
: CursorRecyclerViewAdapter<ViewHolder>(context, cursor) {
|
||||||
private val messageDB = DatabaseFactory.getMmsSmsDatabase(context)
|
private val messageDB = DatabaseFactory.getMmsSmsDatabase(context)
|
||||||
@ -70,7 +70,7 @@ class ConversationAdapter(context: Context, cursor: Cursor, private val onItemPr
|
|||||||
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))
|
||||||
view.onPress = { onItemPress(message, viewHolder.adapterPosition) }
|
view.onPress = { onItemPress(message, viewHolder.adapterPosition, view) }
|
||||||
view.onSwipeToReply = { onItemSwipeToReply(message, viewHolder.adapterPosition) }
|
view.onSwipeToReply = { onItemSwipeToReply(message, viewHolder.adapterPosition) }
|
||||||
view.onLongPress = { onItemLongPress(message, viewHolder.adapterPosition) }
|
view.onLongPress = { onItemLongPress(message, viewHolder.adapterPosition) }
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@ import org.thoughtcrime.securesms.loki.utilities.toPx
|
|||||||
import java.lang.IllegalStateException
|
import java.lang.IllegalStateException
|
||||||
|
|
||||||
class VisibleMessageContentView : LinearLayout {
|
class VisibleMessageContentView : LinearLayout {
|
||||||
|
var onContentClick: (() -> Unit)? = null
|
||||||
|
|
||||||
// TODO: Large emojis
|
// TODO: Large emojis
|
||||||
|
|
||||||
@ -50,6 +51,7 @@ class VisibleMessageContentView : LinearLayout {
|
|||||||
setBackground(background)
|
setBackground(background)
|
||||||
// Body
|
// Body
|
||||||
mainContainer.removeAllViews()
|
mainContainer.removeAllViews()
|
||||||
|
onContentClick = null
|
||||||
if (message is MmsMessageRecord && message.linkPreviews.isNotEmpty()) {
|
if (message is MmsMessageRecord && message.linkPreviews.isNotEmpty()) {
|
||||||
val linkPreviewView = LinkPreviewView(context)
|
val linkPreviewView = LinkPreviewView(context)
|
||||||
linkPreviewView.bind(message)
|
linkPreviewView.bind(message)
|
||||||
@ -66,6 +68,7 @@ class VisibleMessageContentView : LinearLayout {
|
|||||||
val voiceMessageView = VoiceMessageView(context)
|
val voiceMessageView = VoiceMessageView(context)
|
||||||
voiceMessageView.bind(message, background)
|
voiceMessageView.bind(message, background)
|
||||||
mainContainer.addView(voiceMessageView)
|
mainContainer.addView(voiceMessageView)
|
||||||
|
onContentClick = { voiceMessageView.togglePlayback() }
|
||||||
} else if (message is MmsMessageRecord && message.slideDeck.documentSlide != null) {
|
} else if (message is MmsMessageRecord && message.slideDeck.documentSlide != null) {
|
||||||
val documentView = DocumentView(context)
|
val documentView = DocumentView(context)
|
||||||
documentView.bind(message, getTextColor(message))
|
documentView.bind(message, getTextColor(message))
|
||||||
|
@ -257,5 +257,9 @@ class VisibleMessageView : LinearLayout {
|
|||||||
performHapticFeedback(HapticFeedbackConstants.LONG_PRESS)
|
performHapticFeedback(HapticFeedbackConstants.LONG_PRESS)
|
||||||
onLongPress?.invoke()
|
onLongPress?.invoke()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun onContentClick() {
|
||||||
|
messageContentView.onContentClick?.invoke()
|
||||||
|
}
|
||||||
// endregion
|
// endregion
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,6 @@ class VoiceMessageView : LinearLayout {
|
|||||||
|
|
||||||
private fun initialize() {
|
private fun initialize() {
|
||||||
LayoutInflater.from(context).inflate(R.layout.view_voice_message, this)
|
LayoutInflater.from(context).inflate(R.layout.view_voice_message, this)
|
||||||
setOnClickListener { togglePlayBack() }
|
|
||||||
voiceMessageViewDurationTextView.text = String.format("%01d:%02d",
|
voiceMessageViewDurationTextView.text = String.format("%01d:%02d",
|
||||||
TimeUnit.MILLISECONDS.toMinutes(mockDuration),
|
TimeUnit.MILLISECONDS.toMinutes(mockDuration),
|
||||||
TimeUnit.MILLISECONDS.toSeconds(mockDuration))
|
TimeUnit.MILLISECONDS.toSeconds(mockDuration))
|
||||||
@ -63,7 +62,7 @@ class VoiceMessageView : LinearLayout {
|
|||||||
// endregion
|
// endregion
|
||||||
|
|
||||||
// region Interaction
|
// region Interaction
|
||||||
private fun togglePlayBack() {
|
fun togglePlayback() {
|
||||||
mockIsPlaying = !mockIsPlaying
|
mockIsPlaying = !mockIsPlaying
|
||||||
val iconID = if (mockIsPlaying) R.drawable.exo_icon_pause else R.drawable.exo_icon_play
|
val iconID = if (mockIsPlaying) R.drawable.exo_icon_pause else R.drawable.exo_icon_play
|
||||||
voiceMessagePlaybackImageView.setImageResource(iconID)
|
voiceMessagePlaybackImageView.setImageResource(iconID)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user