mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-25 17:27:45 +00:00
auto play next audio
This commit is contained in:
parent
69b05afbd9
commit
a1e63c5f8e
@ -847,8 +847,8 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun playNextAudioIfPossible(current: Int) {
|
override fun playNextAudioIfPossible(current: Int) {
|
||||||
if (current < conversationRecyclerView.childCount) {
|
if (current > 0) {
|
||||||
val nextVisibleMessageView = conversationRecyclerView[current + 1] as? VisibleMessageView
|
val nextVisibleMessageView = conversationRecyclerView[current - 1] as? VisibleMessageView
|
||||||
nextVisibleMessageView?.let { visibleMessageView ->
|
nextVisibleMessageView?.let { visibleMessageView ->
|
||||||
visibleMessageView.messageContentView.mainContainer.children.forEach { child ->
|
visibleMessageView.messageContentView.mainContainer.children.forEach { child ->
|
||||||
val nextVoiceMessageView = child as? VoiceMessageView
|
val nextVoiceMessageView = child as? VoiceMessageView
|
||||||
|
@ -72,6 +72,7 @@ class ConversationAdapter(context: Context, cursor: Cursor, private val onItemPr
|
|||||||
view.snIsSelected = isSelected
|
view.snIsSelected = isSelected
|
||||||
view.messageTimestampTextView.isVisible = isSelected
|
view.messageTimestampTextView.isVisible = isSelected
|
||||||
val position = viewHolder.adapterPosition
|
val position = viewHolder.adapterPosition
|
||||||
|
view.viewHolderIndex = position
|
||||||
view.bind(message, getMessageBefore(position, cursor), getMessageAfter(position, cursor), glide, searchQuery)
|
view.bind(message, getMessageBefore(position, cursor), getMessageAfter(position, cursor), glide, searchQuery)
|
||||||
view.onPress = { event -> onItemPress(message, viewHolder.adapterPosition, view, event) }
|
view.onPress = { event -> onItemPress(message, viewHolder.adapterPosition, view, event) }
|
||||||
view.onSwipeToReply = { onItemSwipeToReply(message, viewHolder.adapterPosition) }
|
view.onSwipeToReply = { onItemSwipeToReply(message, viewHolder.adapterPosition) }
|
||||||
|
@ -32,6 +32,7 @@ import org.session.libsession.utilities.ViewUtil
|
|||||||
import org.session.libsession.utilities.recipients.Recipient
|
import org.session.libsession.utilities.recipients.Recipient
|
||||||
import org.thoughtcrime.securesms.conversation.v2.components.AlbumThumbnailView
|
import org.thoughtcrime.securesms.conversation.v2.components.AlbumThumbnailView
|
||||||
import org.thoughtcrime.securesms.components.emoji.EmojiTextView
|
import org.thoughtcrime.securesms.components.emoji.EmojiTextView
|
||||||
|
import org.thoughtcrime.securesms.conversation.v2.ConversationActivityV2
|
||||||
import org.thoughtcrime.securesms.conversation.v2.dialogs.OpenURLDialog
|
import org.thoughtcrime.securesms.conversation.v2.dialogs.OpenURLDialog
|
||||||
import org.thoughtcrime.securesms.conversation.v2.utilities.ModalURLSpan
|
import org.thoughtcrime.securesms.conversation.v2.utilities.ModalURLSpan
|
||||||
import org.thoughtcrime.securesms.conversation.v2.utilities.TextUtilities.getIntersectedModalSpans
|
import org.thoughtcrime.securesms.conversation.v2.utilities.TextUtilities.getIntersectedModalSpans
|
||||||
@ -48,6 +49,7 @@ class VisibleMessageContentView : LinearLayout {
|
|||||||
var onContentClick: ((event: MotionEvent) -> Unit)? = null
|
var onContentClick: ((event: MotionEvent) -> Unit)? = null
|
||||||
var onContentDoubleTap: (() -> Unit)? = null
|
var onContentDoubleTap: (() -> Unit)? = null
|
||||||
var delegate: VisibleMessageContentViewDelegate? = null
|
var delegate: VisibleMessageContentViewDelegate? = null
|
||||||
|
var viewHolderIndex: Int = -1
|
||||||
|
|
||||||
// region Lifecycle
|
// region Lifecycle
|
||||||
constructor(context: Context) : super(context) { initialize() }
|
constructor(context: Context) : super(context) { initialize() }
|
||||||
@ -107,9 +109,10 @@ class VisibleMessageContentView : LinearLayout {
|
|||||||
}
|
}
|
||||||
} else if (message is MmsMessageRecord && message.slideDeck.audioSlide != null) {
|
} else if (message is MmsMessageRecord && message.slideDeck.audioSlide != null) {
|
||||||
val voiceMessageView = VoiceMessageView(context)
|
val voiceMessageView = VoiceMessageView(context)
|
||||||
|
voiceMessageView.index = viewHolderIndex
|
||||||
|
voiceMessageView.delegate = context as? ConversationActivityV2
|
||||||
voiceMessageView.bind(message, isStartOfMessageCluster, isEndOfMessageCluster)
|
voiceMessageView.bind(message, isStartOfMessageCluster, isEndOfMessageCluster)
|
||||||
mainContainer.addView(voiceMessageView)
|
mainContainer.addView(voiceMessageView)
|
||||||
voiceMessageView.delegate = delegate
|
|
||||||
// We have to use onContentClick (rather than a click listener directly on the voice
|
// We have to use onContentClick (rather than a click listener directly on the voice
|
||||||
// message view) so as to not interfere with all the other gestures.
|
// message view) so as to not interfere with all the other gestures.
|
||||||
onContentClick = { voiceMessageView.togglePlayback() }
|
onContentClick = { voiceMessageView.togglePlayback() }
|
||||||
|
@ -47,6 +47,7 @@ class VisibleMessageView : LinearLayout {
|
|||||||
private var longPressCallback: Runnable? = null
|
private var longPressCallback: Runnable? = null
|
||||||
private var onDownTimestamp = 0L
|
private var onDownTimestamp = 0L
|
||||||
private var onDoubleTap: (() -> Unit)? = null
|
private var onDoubleTap: (() -> Unit)? = null
|
||||||
|
var viewHolderIndex: Int = -1
|
||||||
var snIsSelected = false
|
var snIsSelected = false
|
||||||
set(value) { field = value; handleIsSelectedChanged()}
|
set(value) { field = value; handleIsSelectedChanged()}
|
||||||
var onPress: ((event: MotionEvent) -> Unit)? = null
|
var onPress: ((event: MotionEvent) -> Unit)? = null
|
||||||
@ -151,6 +152,7 @@ class VisibleMessageView : LinearLayout {
|
|||||||
var maxWidth = screenWidth - startPadding - endPadding
|
var maxWidth = screenWidth - startPadding - endPadding
|
||||||
if (profilePictureContainer.visibility != View.GONE) { maxWidth -= profilePictureContainer.width }
|
if (profilePictureContainer.visibility != View.GONE) { maxWidth -= profilePictureContainer.width }
|
||||||
// Populate content view
|
// Populate content view
|
||||||
|
messageContentView.viewHolderIndex = viewHolderIndex
|
||||||
messageContentView.bind(message, isStartOfMessageCluster, isEndOfMessageCluster, glide, maxWidth, thread, searchQuery)
|
messageContentView.bind(message, isStartOfMessageCluster, isEndOfMessageCluster, glide, maxWidth, thread, searchQuery)
|
||||||
messageContentView.delegate = contentViewDelegate
|
messageContentView.delegate = contentViewDelegate
|
||||||
onDoubleTap = { messageContentView.onContentDoubleTap?.invoke() }
|
onDoubleTap = { messageContentView.onContentDoubleTap?.invoke() }
|
||||||
|
@ -32,8 +32,8 @@ class VoiceMessageView : LinearLayout, AudioSlidePlayer.Listener {
|
|||||||
private var duration = 0L
|
private var duration = 0L
|
||||||
private var player: AudioSlidePlayer? = null
|
private var player: AudioSlidePlayer? = null
|
||||||
private var isPreparing = false
|
private var isPreparing = false
|
||||||
var delegate: VisibleMessageContentViewDelegate? = null
|
var delegate: VoiceMessageViewDelegate? = null
|
||||||
var index = 0
|
var index = -1
|
||||||
|
|
||||||
// region Lifecycle
|
// region Lifecycle
|
||||||
constructor(context: Context) : super(context) { initialize() }
|
constructor(context: Context) : super(context) { initialize() }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user