mirror of
https://github.com/oxen-io/session-android.git
synced 2025-01-03 13:47:45 +00:00
Cleanup VisibleMessageView
This commit is contained in:
parent
88dfceed67
commit
403058c5cf
@ -1,5 +1,6 @@
|
|||||||
package org.thoughtcrime.securesms.conversation.v2.messages
|
package org.thoughtcrime.securesms.conversation.v2.messages
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.graphics.Canvas
|
import android.graphics.Canvas
|
||||||
@ -243,12 +244,12 @@ class VisibleMessageView : LinearLayout {
|
|||||||
val disappearing = message.expiresIn > 0
|
val disappearing = message.expiresIn > 0
|
||||||
|
|
||||||
binding.messageInnerLayout.apply {
|
binding.messageInnerLayout.apply {
|
||||||
layoutParams = layoutParams.let { it as FrameLayout.LayoutParams }
|
layoutParams = (layoutParams as FrameLayout.LayoutParams)
|
||||||
.apply { gravity = if (message.isOutgoing) Gravity.END else Gravity.START }
|
.apply { gravity = if (message.isOutgoing) Gravity.END else Gravity.START }
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.statusContainer.apply {
|
binding.statusContainer.apply {
|
||||||
layoutParams = layoutParams.let { it as ConstraintLayout.LayoutParams }
|
layoutParams = (layoutParams as ConstraintLayout.LayoutParams)
|
||||||
.apply { horizontalBias = if (message.isOutgoing) 1f else 0f }
|
.apply { horizontalBias = if (message.isOutgoing) 1f else 0f }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -280,25 +281,19 @@ class VisibleMessageView : LinearLayout {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun isStartOfMessageCluster(current: MessageRecord, previous: MessageRecord?, isGroupThread: Boolean): Boolean {
|
private fun isStartOfMessageCluster(current: MessageRecord, previous: MessageRecord?, isGroupThread: Boolean): Boolean =
|
||||||
return if (isGroupThread) {
|
previous == null || previous.isUpdate || !DateUtils.isSameHour(current.timestamp, previous.timestamp) || if (isGroupThread) {
|
||||||
previous == null || previous.isUpdate || !DateUtils.isSameHour(current.timestamp, previous.timestamp)
|
current.recipient.address != previous.recipient.address
|
||||||
|| current.recipient.address != previous.recipient.address
|
|
||||||
} else {
|
} else {
|
||||||
previous == null || previous.isUpdate || !DateUtils.isSameHour(current.timestamp, previous.timestamp)
|
current.isOutgoing != previous.isOutgoing
|
||||||
|| current.isOutgoing != previous.isOutgoing
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private fun isEndOfMessageCluster(current: MessageRecord, next: MessageRecord?, isGroupThread: Boolean): Boolean {
|
private fun isEndOfMessageCluster(current: MessageRecord, next: MessageRecord?, isGroupThread: Boolean): Boolean =
|
||||||
return if (isGroupThread) {
|
next == null || next.isUpdate || !DateUtils.isSameHour(current.timestamp, next.timestamp) || if (isGroupThread) {
|
||||||
next == null || next.isUpdate || !DateUtils.isSameHour(current.timestamp, next.timestamp)
|
current.recipient.address != next.recipient.address
|
||||||
|| current.recipient.address != next.recipient.address
|
|
||||||
} else {
|
} else {
|
||||||
next == null || next.isUpdate || !DateUtils.isSameHour(current.timestamp, next.timestamp)
|
current.isOutgoing != next.isOutgoing
|
||||||
|| current.isOutgoing != next.isOutgoing
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
data class MessageStatusInfo(@DrawableRes val iconId: Int?,
|
data class MessageStatusInfo(@DrawableRes val iconId: Int?,
|
||||||
@ColorInt val iconTint: Int?,
|
@ColorInt val iconTint: Int?,
|
||||||
@ -346,11 +341,7 @@ class VisibleMessageView : LinearLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun handleIsSelectedChanged() {
|
private fun handleIsSelectedChanged() {
|
||||||
background = if (snIsSelected) {
|
background = if (snIsSelected) ColorDrawable(context.getColorFromAttr(R.attr.message_selected)) else null
|
||||||
ColorDrawable(context.getColorFromAttr(R.attr.message_selected))
|
|
||||||
} else {
|
|
||||||
null
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDraw(canvas: Canvas) {
|
override fun onDraw(canvas: Canvas) {
|
||||||
@ -387,6 +378,7 @@ class VisibleMessageView : LinearLayout {
|
|||||||
// endregion
|
// endregion
|
||||||
|
|
||||||
// region Interaction
|
// region Interaction
|
||||||
|
@SuppressLint("ClickableViewAccessibility")
|
||||||
override fun onTouchEvent(event: MotionEvent): Boolean {
|
override fun onTouchEvent(event: MotionEvent): Boolean {
|
||||||
if (onPress == null || onSwipeToReply == null || onLongPress == null) { return false }
|
if (onPress == null || onSwipeToReply == null || onLongPress == null) { return false }
|
||||||
when (event.action) {
|
when (event.action) {
|
||||||
@ -487,14 +479,13 @@ class VisibleMessageView : LinearLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun maybeShowUserDetails(publicKey: String, threadID: Long) {
|
private fun maybeShowUserDetails(publicKey: String, threadID: Long) {
|
||||||
val userDetailsBottomSheet = UserDetailsBottomSheet()
|
UserDetailsBottomSheet().apply {
|
||||||
val bundle = bundleOf(
|
arguments = bundleOf(
|
||||||
UserDetailsBottomSheet.ARGUMENT_PUBLIC_KEY to publicKey,
|
UserDetailsBottomSheet.ARGUMENT_PUBLIC_KEY to publicKey,
|
||||||
UserDetailsBottomSheet.ARGUMENT_THREAD_ID to threadID
|
UserDetailsBottomSheet.ARGUMENT_THREAD_ID to threadID
|
||||||
)
|
)
|
||||||
userDetailsBottomSheet.arguments = bundle
|
show((context as AppCompatActivity).supportFragmentManager, tag)
|
||||||
val activity = context as AppCompatActivity
|
}
|
||||||
userDetailsBottomSheet.show(activity.supportFragmentManager, userDetailsBottomSheet.tag)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun playVoiceMessage() {
|
fun playVoiceMessage() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user