From 7480ea66ecb6078a7117ffa3f39db3cb70a35120 Mon Sep 17 00:00:00 2001 From: Alex Hart Date: Mon, 16 Aug 2021 11:36:03 -0300 Subject: [PATCH] Fix issue where a document with text would cause a crash and not be multiselectable. --- .../conversation/ConversationItem.java | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationItem.java b/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationItem.java index d1953abd2..85a286f44 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationItem.java +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationItem.java @@ -533,8 +533,17 @@ public final class ConversationItem extends RelativeLayout implements BindableCo } else { return top; } + } else if (hasDocument(messageRecord)) { + Projection documentProjection = Projection.relativeToParent(this, documentViewStub.get(), null); + float documentBoundary = documentProjection.getY() + documentProjection.getHeight(); + + if (lastYDownRelativeToThis > documentBoundary) { + return bottom; + } else { + return top; + } } else { - throw new IllegalStateException("Found a situation where we have something other than a thumbnail."); + throw new IllegalStateException("Found a situation where we have something other than a thumbnail or a document."); } } @@ -543,9 +552,15 @@ public final class ConversationItem extends RelativeLayout implements BindableCo if (multiselectPart instanceof MultiselectPart.Attachments && hasThumbnail(messageRecord)) { Projection projection = Projection.relativeToViewRoot(mediaThumbnailStub.require(), null); return (int) projection.getY(); + } if (multiselectPart instanceof MultiselectPart.Attachments && hasDocument(messageRecord)) { + Projection projection = Projection.relativeToViewRoot(documentViewStub.get(), null); + return (int) projection.getY(); } else if (multiselectPart instanceof MultiselectPart.Text && hasThumbnail(messageRecord)) { Projection projection = Projection.relativeToViewRoot(mediaThumbnailStub.require(), null); return (int) projection.getY() + projection.getHeight(); + } else if (multiselectPart instanceof MultiselectPart.Text && hasDocument(messageRecord)) { + Projection projection = Projection.relativeToViewRoot(documentViewStub.get(), null); + return (int) projection.getY() + projection.getHeight(); } else if (hasNoBubble(messageRecord)) { return getTop(); } else { @@ -559,6 +574,9 @@ public final class ConversationItem extends RelativeLayout implements BindableCo if (multiselectPart instanceof MultiselectPart.Attachments && hasThumbnail(messageRecord)) { Projection projection = Projection.relativeToViewRoot(mediaThumbnailStub.require(), null); return (int) projection.getY() + projection.getHeight(); + } else if (multiselectPart instanceof MultiselectPart.Attachments && hasDocument(messageRecord)) { + Projection projection = Projection.relativeToViewRoot(documentViewStub.get(), null); + return (int) projection.getY() + projection.getHeight(); } else if (hasNoBubble(messageRecord)) { return getBottom(); } else {