mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-02-25 12:17:22 +00:00
Fix context usage in ConversationDataSource.
This commit is contained in:
committed by
Cody Henthorne
parent
9e836ba586
commit
9f2dbf7b6c
@@ -47,12 +47,12 @@ private object ThreadHeaderKey : ConversationElementKey
|
||||
* ConversationDataSource for V2. Assumes that ThreadId is never -1L.
|
||||
*/
|
||||
class ConversationDataSource(
|
||||
private val context: Context,
|
||||
private val localContext: Context,
|
||||
private val threadId: Long,
|
||||
private val messageRequestData: ConversationData.MessageRequestData,
|
||||
private val showUniversalExpireTimerUpdate: Boolean,
|
||||
private var baseSize: Int,
|
||||
private val messageRequestRepository: MessageRequestRepository = MessageRequestRepository(context)
|
||||
private val messageRequestRepository: MessageRequestRepository = MessageRequestRepository(localContext)
|
||||
) : PagedDataSource<ConversationElementKey, ConversationElement> {
|
||||
|
||||
companion object {
|
||||
@@ -130,9 +130,9 @@ class ConversationDataSource(
|
||||
|
||||
val messages = records.map { record ->
|
||||
ConversationMessageFactory.createWithUnresolvedData(
|
||||
context,
|
||||
localContext,
|
||||
record,
|
||||
record.getDisplayBody(context),
|
||||
record.getDisplayBody(localContext),
|
||||
extraData.mentionsById[record.id],
|
||||
extraData.hasBeenQuoted.contains(record.id),
|
||||
threadRecipient
|
||||
@@ -192,7 +192,7 @@ class ConversationDataSource(
|
||||
stopwatch.split("models")
|
||||
|
||||
return ConversationMessageFactory.createWithUnresolvedData(
|
||||
ApplicationDependencies.getApplication(),
|
||||
localContext,
|
||||
record,
|
||||
record.getDisplayBody(ApplicationDependencies.getApplication()),
|
||||
extraData.mentionsById[record.id],
|
||||
@@ -222,13 +222,13 @@ class ConversationDataSource(
|
||||
return if (messageRecord.isUpdate) {
|
||||
ConversationUpdate(this)
|
||||
} else if (messageRecord.isOutgoing) {
|
||||
if (this.isTextOnly(context)) {
|
||||
if (this.isTextOnly(localContext)) {
|
||||
OutgoingTextOnly(this)
|
||||
} else {
|
||||
OutgoingMedia(this)
|
||||
}
|
||||
} else {
|
||||
if (this.isTextOnly(context)) {
|
||||
if (this.isTextOnly(localContext)) {
|
||||
IncomingTextOnly(this)
|
||||
} else {
|
||||
IncomingMedia(this)
|
||||
|
||||
@@ -31,7 +31,10 @@ class V2ConversationItemShape(
|
||||
private val clusterTimeout = 3.minutes
|
||||
}
|
||||
|
||||
var corners: Projection.Corners = Projection.Corners(bigRadius)
|
||||
var cornersLTR: Projection.Corners = Projection.Corners(bigRadius)
|
||||
private set
|
||||
|
||||
var cornersRTL: Projection.Corners = Projection.Corners(bigRadius)
|
||||
private set
|
||||
|
||||
/**
|
||||
@@ -80,7 +83,8 @@ class V2ConversationItemShape(
|
||||
bottomStart
|
||||
)
|
||||
|
||||
corners = newCorners
|
||||
cornersLTR = newCorners
|
||||
cornersRTL = Projection.Corners(newCorners.toRelativeRadii(false))
|
||||
}
|
||||
|
||||
private fun isSingularMessage(
|
||||
|
||||
@@ -238,7 +238,7 @@ open class V2ConversationItemTextOnlyViewHolder<Model : MappingModel<Model>>(
|
||||
} else {
|
||||
conversationMessage.threadRecipient.chatColors
|
||||
},
|
||||
shapeDelegate.corners
|
||||
shapeDelegate.cornersLTR
|
||||
)
|
||||
|
||||
binding.reply.setBackgroundColor(themeDelegate.getReplyIconBackgroundColor())
|
||||
@@ -266,7 +266,7 @@ open class V2ConversationItemTextOnlyViewHolder<Model : MappingModel<Model>>(
|
||||
Projection.relativeToParent(
|
||||
coordinateRoot,
|
||||
binding.bodyWrapper,
|
||||
shapeDelegate.corners
|
||||
shapeDelegate.cornersLTR
|
||||
).translateX(binding.bodyWrapper.translationX).translateY(root.translationY)
|
||||
)
|
||||
|
||||
@@ -318,7 +318,7 @@ open class V2ConversationItemTextOnlyViewHolder<Model : MappingModel<Model>>(
|
||||
return Projection.relativeToParent(
|
||||
coordinateRoot,
|
||||
binding.bodyWrapper,
|
||||
shapeDelegate.corners
|
||||
shapeDelegate.cornersLTR
|
||||
)
|
||||
.translateY(root.translationY)
|
||||
.translateX(binding.bodyWrapper.translationX)
|
||||
@@ -337,7 +337,7 @@ open class V2ConversationItemTextOnlyViewHolder<Model : MappingModel<Model>>(
|
||||
val projection = Projection.relativeToParent(
|
||||
coordinateRoot,
|
||||
binding.footerBackground,
|
||||
shapeDelegate.corners
|
||||
shapeDelegate.cornersLTR
|
||||
)
|
||||
|
||||
footerDrawable.applyMaskProjection(projection)
|
||||
@@ -345,7 +345,13 @@ open class V2ConversationItemTextOnlyViewHolder<Model : MappingModel<Model>>(
|
||||
}
|
||||
|
||||
private fun invalidateBodyBubbleDrawable(coordinateRoot: ViewGroup) {
|
||||
bodyBubbleDrawable.setCorners(shapeDelegate.corners.toRelativeRadii(ViewUtil.isLtr(coordinateRoot)))
|
||||
val corners: Projection.Corners = if (ViewUtil.isLtr(coordinateRoot)) {
|
||||
shapeDelegate.cornersLTR
|
||||
} else {
|
||||
shapeDelegate.cornersRTL
|
||||
}
|
||||
|
||||
bodyBubbleDrawable.setCorners(corners.toRadii())
|
||||
|
||||
if (bodyBubbleDrawable.isSolidColor()) {
|
||||
return
|
||||
@@ -354,7 +360,7 @@ open class V2ConversationItemTextOnlyViewHolder<Model : MappingModel<Model>>(
|
||||
val projection = Projection.relativeToParent(
|
||||
coordinateRoot,
|
||||
binding.bodyWrapper,
|
||||
shapeDelegate.corners
|
||||
corners
|
||||
)
|
||||
|
||||
bodyBubbleDrawable.applyMaskProjection(projection)
|
||||
|
||||
Reference in New Issue
Block a user