mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-21 17:29:32 +01:00
Convert SignalService, Database, Group, Payment, and other remaining protos to wire.
This commit is contained in:
committed by
Alex Hart
parent
a6b7d0bcc5
commit
efbd5cab85
@@ -1060,10 +1060,10 @@ public final class ConversationItem extends RelativeLayout implements BindableCo
|
||||
|
||||
if (conversationMessage.getBottomButton() != null) {
|
||||
callToActionStub.get().setVisibility(View.VISIBLE);
|
||||
callToActionStub.get().setText(conversationMessage.getBottomButton().getLabel());
|
||||
callToActionStub.get().setText(conversationMessage.getBottomButton().label);
|
||||
callToActionStub.get().setOnClickListener(v -> {
|
||||
if (eventListener != null) {
|
||||
eventListener.onCallToAction(conversationMessage.getBottomButton().getAction());
|
||||
eventListener.onCallToAction(conversationMessage.getBottomButton().action);
|
||||
}
|
||||
});
|
||||
} else if (callToActionStub.resolved()) {
|
||||
|
||||
@@ -454,7 +454,7 @@ public final class ConversationUpdateItem extends FrameLayout
|
||||
if (Util.hasItems(acis)) {
|
||||
if (acis.contains(SignalStore.account().requireAci())) {
|
||||
text = R.string.ConversationUpdateItem_return_to_call;
|
||||
} else if (GroupCallUpdateDetailsUtil.parse(conversationMessage.getMessageRecord().getBody()).getIsCallFull()) {
|
||||
} else if (GroupCallUpdateDetailsUtil.parse(conversationMessage.getMessageRecord().getBody()).isCallFull) {
|
||||
text = R.string.ConversationUpdateItem_call_is_full;
|
||||
} else {
|
||||
text = R.string.ConversationUpdateItem_join_call;
|
||||
|
||||
@@ -63,13 +63,13 @@ object MessageStyler {
|
||||
var bottomButton: BodyRange.Button? = null
|
||||
|
||||
messageRanges
|
||||
.rangesList
|
||||
.ranges
|
||||
.filter { r -> r.start >= 0 && r.start < span.length && r.start + r.length >= 0 }
|
||||
.forEach { range ->
|
||||
val start = range.start
|
||||
val end = (range.start + range.length).coerceAtMost(span.length)
|
||||
|
||||
if (range.hasStyle()) {
|
||||
if (range.style != null) {
|
||||
val styleSpan: Any? = when (range.style) {
|
||||
BodyRange.Style.BOLD -> boldStyle()
|
||||
BodyRange.Style.ITALIC -> italicStyle()
|
||||
@@ -90,10 +90,10 @@ object MessageStyler {
|
||||
span.setSpan(styleSpan, start, end, SPAN_FLAGS)
|
||||
appliedStyle = true
|
||||
}
|
||||
} else if (range.hasLink() && range.link != null) {
|
||||
} else if (range.link != null) {
|
||||
span.setSpan(PlaceholderURLSpan(range.link), start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
|
||||
hasLinks = true
|
||||
} else if (range.hasButton() && range.button != null) {
|
||||
} else if (range.button != null) {
|
||||
bottomButton = range.button
|
||||
}
|
||||
}
|
||||
@@ -245,7 +245,7 @@ object MessageStyler {
|
||||
}
|
||||
|
||||
if (spanLength > 0 && style != null) {
|
||||
BodyRange.newBuilder().setStart(spanStart).setLength(spanLength).setStyle(style).build()
|
||||
BodyRange(start = spanStart, length = spanLength, style = style)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
@@ -255,7 +255,7 @@ object MessageStyler {
|
||||
}
|
||||
|
||||
return if (bodyRanges.isNotEmpty()) {
|
||||
BodyRangeList.newBuilder().addAllRanges(bodyRanges).build()
|
||||
BodyRangeList(ranges = bodyRanges)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
|
||||
@@ -73,20 +73,20 @@ class ChatColors(
|
||||
}
|
||||
|
||||
fun serialize(): ChatColor {
|
||||
val builder: ChatColor.Builder = ChatColor.newBuilder()
|
||||
val builder: ChatColor.Builder = ChatColor.Builder()
|
||||
|
||||
if (linearGradient != null) {
|
||||
val gradientBuilder = ChatColor.LinearGradient.newBuilder()
|
||||
val gradientBuilder = ChatColor.LinearGradient.Builder()
|
||||
|
||||
gradientBuilder.rotation = linearGradient.degrees
|
||||
linearGradient.colors.forEach { gradientBuilder.addColors(it) }
|
||||
linearGradient.positions.forEach { gradientBuilder.addPositions(it) }
|
||||
gradientBuilder.colors = linearGradient.colors.toList()
|
||||
gradientBuilder.positions = linearGradient.positions.toList()
|
||||
|
||||
builder.setLinearGradient(gradientBuilder)
|
||||
builder.linearGradient(gradientBuilder.build())
|
||||
}
|
||||
|
||||
if (singleColor != null) {
|
||||
builder.setSingleColor(ChatColor.SingleColor.newBuilder().setColor(singleColor))
|
||||
builder.singleColor(ChatColor.SingleColor.Builder().color(singleColor).build())
|
||||
}
|
||||
|
||||
return builder.build()
|
||||
@@ -142,18 +142,18 @@ class ChatColors(
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun forChatColor(id: Id, chatColor: ChatColor): ChatColors {
|
||||
assert(chatColor.hasSingleColor() xor chatColor.hasLinearGradient())
|
||||
assert((chatColor.singleColor != null) xor (chatColor.linearGradient != null))
|
||||
|
||||
return if (chatColor.hasLinearGradient()) {
|
||||
return if (chatColor.linearGradient != null) {
|
||||
val linearGradient = LinearGradient(
|
||||
chatColor.linearGradient.rotation,
|
||||
chatColor.linearGradient.colorsList.toIntArray(),
|
||||
chatColor.linearGradient.positionsList.toFloatArray()
|
||||
chatColor.linearGradient.colors.toIntArray(),
|
||||
chatColor.linearGradient.positions.toFloatArray()
|
||||
)
|
||||
|
||||
forGradient(id, linearGradient)
|
||||
} else {
|
||||
val singleColor = chatColor.singleColor.color
|
||||
val singleColor = chatColor.singleColor!!.color
|
||||
|
||||
forColor(id, singleColor)
|
||||
}
|
||||
|
||||
@@ -191,7 +191,7 @@ class DraftRepository(
|
||||
var updatedText: Spannable? = null
|
||||
|
||||
if (textDraft != null && bodyRangesDraft != null) {
|
||||
val bodyRanges: BodyRangeList = BodyRangeList.parseFrom(Base64.decodeOrThrow(bodyRangesDraft.value))
|
||||
val bodyRanges: BodyRangeList = BodyRangeList.ADAPTER.decode(Base64.decodeOrThrow(bodyRangesDraft.value))
|
||||
val mentions: List<Mention> = MentionUtil.bodyRangeListToMentions(bodyRanges)
|
||||
|
||||
val updated = MentionUtil.updateBodyAndMentionsWithDisplayNames(context, textDraft.value, mentions)
|
||||
|
||||
@@ -62,7 +62,7 @@ class DraftViewModel @JvmOverloads constructor(
|
||||
} else if (mentionRanges == null) {
|
||||
styleBodyRanges
|
||||
} else {
|
||||
styleBodyRanges.toBuilder().addAllRanges(mentionRanges.rangesList).build()
|
||||
styleBodyRanges.newBuilder().apply { ranges += mentionRanges.ranges }.build()
|
||||
}
|
||||
|
||||
saveDrafts(it.copy(textDraft = text.toTextDraft(), bodyRangesDraft = bodyRanges?.toDraft(), messageEditDraft = Draft(Draft.MESSAGE_EDIT, messageId.serialize())))
|
||||
@@ -84,7 +84,7 @@ class DraftViewModel @JvmOverloads constructor(
|
||||
} else if (mentionRanges == null) {
|
||||
styleBodyRanges
|
||||
} else {
|
||||
styleBodyRanges.toBuilder().addAllRanges(mentionRanges.rangesList).build()
|
||||
styleBodyRanges.newBuilder().apply { ranges += mentionRanges.ranges }.build()
|
||||
}
|
||||
|
||||
saveDrafts(it.copy(textDraft = text.toTextDraft(), bodyRangesDraft = bodyRanges?.toDraft()))
|
||||
@@ -148,5 +148,5 @@ private fun String.toTextDraft(): Draft? {
|
||||
}
|
||||
|
||||
private fun BodyRangeList.toDraft(): Draft {
|
||||
return Draft(Draft.BODY_RANGES, Base64.encodeBytes(toByteArray()))
|
||||
return Draft(Draft.BODY_RANGES, Base64.encodeBytes(encode()))
|
||||
}
|
||||
|
||||
@@ -1787,7 +1787,7 @@ class ConversationFragment :
|
||||
return
|
||||
}
|
||||
|
||||
if (SignalStore.uiHints().hasNotSeenTextFormattingAlert() && bodyRanges != null && bodyRanges.rangesCount > 0) {
|
||||
if (SignalStore.uiHints().hasNotSeenTextFormattingAlert() && bodyRanges != null && bodyRanges.ranges.isNotEmpty()) {
|
||||
Dialogs.showFormattedTextDialog(requireContext()) {
|
||||
sendMessage(body, mentions, bodyRanges, messageToEdit, quote, scheduledDate, slideDeck, contacts, clearCompose, linkPreviews, preUploadResults, bypassPreSendSafetyNumberCheck, isViewOnce, afterSendComplete)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user