Update UI for replies to unavailable stories.

This commit is contained in:
Rashad Sookram
2022-03-23 10:18:56 -04:00
committed by Greyson Parrelli
parent c2627dda8d
commit 19381342b3
6 changed files with 37 additions and 25 deletions

View File

@@ -27,7 +27,6 @@ import org.thoughtcrime.securesms.attachments.Attachment;
import org.thoughtcrime.securesms.components.mention.MentionAnnotation;
import org.thoughtcrime.securesms.conversation.colors.ChatColors;
import org.thoughtcrime.securesms.database.model.Mention;
import org.thoughtcrime.securesms.database.model.databaseprotos.StoryTextPost;
import org.thoughtcrime.securesms.mms.DecryptableStreamUriLoader.DecryptableUri;
import org.thoughtcrime.securesms.mms.GlideRequests;
import org.thoughtcrime.securesms.mms.Slide;
@@ -51,8 +50,9 @@ public class QuoteView extends FrameLayout implements RecipientForeverObserver {
PREVIEW(0),
OUTGOING(1),
INCOMING(2),
STORY_REPLY(3),
STORY_REPLY_PREVIEW(4);
STORY_REPLY_OUTGOING(3),
STORY_REPLY_INCOMING(4),
STORY_REPLY_PREVIEW(5);
private final int code;
@@ -185,8 +185,6 @@ public class QuoteView extends FrameLayout implements RecipientForeverObserver {
thumbHeight = getResources().getDimensionPixelOffset(R.dimen.quote_story_thumb_height);
}
mainView.setMinimumHeight(thumbHeight);
ViewGroup.LayoutParams params = thumbnailView.getLayoutParams();
params.height = thumbHeight;
params.width = thumbWidth;
@@ -211,8 +209,8 @@ public class QuoteView extends FrameLayout implements RecipientForeverObserver {
this.author.observeForever(this);
setQuoteAuthor(author);
setQuoteText(body, attachments);
setQuoteAttachment(glideRequests, body, attachments);
setQuoteText(body, attachments, originalMissing);
setQuoteAttachment(glideRequests, body, attachments, originalMissing);
setQuoteMissingFooter(originalMissing);
if (Build.VERSION.SDK_INT < 21 && messageType == MessageType.INCOMING && chatColors != null) {
@@ -251,7 +249,7 @@ public class QuoteView extends FrameLayout implements RecipientForeverObserver {
}
private void setQuoteAuthor(@NonNull Recipient author) {
boolean outgoing = messageType != MessageType.INCOMING;
boolean outgoing = messageType != MessageType.INCOMING && messageType != MessageType.STORY_REPLY_INCOMING;
boolean preview = messageType == MessageType.PREVIEW || messageType == MessageType.STORY_REPLY_PREVIEW;
if (isStoryReply()) {
@@ -262,15 +260,25 @@ public class QuoteView extends FrameLayout implements RecipientForeverObserver {
: author.getDisplayName(getContext()));
}
quoteBarView.setBackgroundColor(ContextCompat.getColor(getContext(), outgoing ? R.color.core_white : android.R.color.transparent));
mainView.setBackgroundColor(ContextCompat.getColor(getContext(), preview ? R.color.quote_preview_background : R.color.quote_view_background));
quoteBarView.setBackgroundColor(ContextCompat.getColor(getContext(), outgoing || isStoryReply() ? R.color.core_white : android.R.color.transparent));
mainView.setBackgroundColor(ContextCompat.getColor(getContext(), preview || (!outgoing && isStoryReply()) ? R.color.quote_preview_background : R.color.quote_view_background));
}
private boolean isStoryReply() {
return messageType == MessageType.STORY_REPLY || messageType == MessageType.STORY_REPLY_PREVIEW;
return messageType == MessageType.STORY_REPLY_OUTGOING ||
messageType == MessageType.STORY_REPLY_INCOMING ||
messageType == MessageType.STORY_REPLY_PREVIEW;
}
private void setQuoteText(@Nullable CharSequence body, @NonNull SlideDeck attachments) {
private void setQuoteText(@Nullable CharSequence body, @NonNull SlideDeck attachments, boolean originalMissing) {
if (originalMissing && isStoryReply()) {
bodyView.setVisibility(GONE);
mediaDescriptionText.setVisibility(VISIBLE);
mediaDescriptionText.setText(R.string.QuoteView_no_longer_available);
return;
}
boolean isTextStory = !attachments.containsMediaSlide() && isStoryReply();
if (!TextUtils.isEmpty(body) || !attachments.containsMediaSlide()) {
@@ -324,7 +332,9 @@ public class QuoteView extends FrameLayout implements RecipientForeverObserver {
}
}
private void setQuoteAttachment(@NonNull GlideRequests glideRequests, @NonNull CharSequence body, @NonNull SlideDeck slideDeck) {
private void setQuoteAttachment(@NonNull GlideRequests glideRequests, @NonNull CharSequence body, @NonNull SlideDeck slideDeck, boolean originalMissing) {
mainView.setMinimumHeight(isStoryReply() && originalMissing ? 0 : thumbHeight);
if (!attachments.containsMediaSlide() && isStoryReply()) {
StoryTextPostModel model = StoryTextPostModel.parseFrom(body.toString(), id, author.getId());
attachmentVideoOverlayView.setVisibility(GONE);
@@ -375,7 +385,7 @@ public class QuoteView extends FrameLayout implements RecipientForeverObserver {
}
private void setQuoteMissingFooter(boolean missing) {
footerView.setVisibility(missing ? VISIBLE : GONE);
footerView.setVisibility(missing && !isStoryReply() ? VISIBLE : GONE);
footerView.setBackgroundColor(ContextCompat.getColor(getContext(), R.color.quote_view_background));
}

View File

@@ -1424,7 +1424,7 @@ public final class ConversationItem extends RelativeLayout implements BindableCo
Quote quote = ((MediaMmsMessageRecord)current).getQuote();
if (((MediaMmsMessageRecord) current).getParentStoryId() != null) {
quoteView.setMessageType(QuoteView.MessageType.STORY_REPLY);
quoteView.setMessageType(current.isOutgoing() ? QuoteView.MessageType.STORY_REPLY_OUTGOING : QuoteView.MessageType.STORY_REPLY_INCOMING);
} else {
quoteView.setMessageType(current.isOutgoing() ? QuoteView.MessageType.OUTGOING : QuoteView.MessageType.INCOMING);
}

View File

@@ -43,13 +43,13 @@
<org.thoughtcrime.securesms.components.emoji.EmojiTextView
android:id="@+id/quote_author"
style="@style/Signal.Text.Caption"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:textSize="14sp"
android:textColor="@color/core_black"
android:textStyle="bold"
android:textAppearance="@style/TextAppearance.Signal.Body2.Bold"
tools:text="Peter Parker" />
<LinearLayout
@@ -83,13 +83,12 @@
<TextView
android:id="@+id/media_type"
style="@style/Signal.Text.Caption"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:paddingTop="4dp"
android:textColor="@color/core_grey_90"
android:textStyle="italic"
android:textSize="14sp"
android:textColor="@color/core_black"
android:visibility="gone"
tools:text="Photo"
tools:visibility="visible" />

View File

@@ -171,8 +171,9 @@
<enum name="preview" value="0" />
<enum name="outgoing" value="1" />
<enum name="incoming" value="2" />
<enum name="story_reply" value="3" />
<enum name="story_reply_preview" value="4" />
<enum name="story_reply_outgoing" value="3" />
<enum name="story_reply_incoming" value="4" />
<enum name="story_reply_preview" value="5" />
</attr>
<attr name="quote_colorPrimary" format="color" />
<attr name="quote_colorSecondary" format="color" />

View File

@@ -160,7 +160,7 @@
<color name="quote_view_background">@color/transparent_white_60</color>
<color name="conversation_item_outgoing_footer_fg">@color/transparent_white_80</color>
<color name="quote_preview_background">@color/core_grey_15</color>
<color name="quote_preview_background">#f2f2f2</color>
<color name="react_with_any_background">@color/core_white</color>
<color name="react_with_any_search_background">@color/core_grey_05</color>

View File

@@ -2088,9 +2088,11 @@
<string name="QuoteView_you">You</string>
<string name="QuoteView_original_missing">Original message not found</string>
<!-- Author formatting for group stories -->
<string name="QuoteView_s_story">%1$s Story</string>
<string name="QuoteView_s_story">%1$s · Story</string>
<!-- Label indicating that a quote is for a reply to a story you created -->
<string name="QuoteView_your_story">Your Story</string>
<string name="QuoteView_your_story">You · Story</string>
<!-- Label indicating that the story being replied to no longer exists -->
<string name="QuoteView_no_longer_available">No longer available</string>
<!-- conversation_fragment -->
<string name="conversation_fragment__scroll_to_the_bottom_content_description">Scroll to the bottom</string>