This commit is contained in:
Niels Andriesse 2020-01-15 12:20:10 +11:00
parent 23336cc2ea
commit bfb6435d72
16 changed files with 130 additions and 78 deletions

View File

@ -34,8 +34,8 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="16dp" android:layout_marginStart="16dp"
android:layout_marginTop="2dp"
android:layout_marginEnd="16dp" android:layout_marginEnd="16dp"
android:layout_marginTop="16dp"
android:weightSum="3"> android:weightSum="3">
<LinearLayout <LinearLayout

View File

@ -34,8 +34,8 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="16dp" android:layout_marginStart="16dp"
android:layout_marginTop="2dp"
android:layout_marginEnd="16dp" android:layout_marginEnd="16dp"
android:layout_marginTop="16dp"
android:weightSum="3"> android:weightSum="3">
<LinearLayout <LinearLayout

View File

@ -49,7 +49,10 @@
android:layout_marginBottom="@dimen/medium_spacing" android:layout_marginBottom="@dimen/medium_spacing"
android:layout_gravity="bottom|end" android:layout_gravity="bottom|end"
android:background="@drawable/scroll_to_bottom_button_background" android:background="@drawable/scroll_to_bottom_button_background"
android:padding="@dimen/small_spacing" android:paddingLeft="@dimen/small_spacing"
android:paddingTop="10dp"
android:paddingRight="@dimen/small_spacing"
android:paddingBottom="6dp"
android:tint="@color/text" android:tint="@color/text"
android:elevation="10dp" android:elevation="10dp"
android:contentDescription="@string/conversation_fragment__scroll_to_the_bottom_content_description" android:contentDescription="@string/conversation_fragment__scroll_to_the_bottom_content_description"

View File

@ -10,11 +10,11 @@
<View <View
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="4dp" android:layout_height="1dp"
android:layout_marginStart="28dp" android:layout_marginStart="@dimen/large_spacing"
android:layout_marginEnd="28dp" android:layout_marginEnd="@dimen/large_spacing"
android:layout_marginBottom="3dp" android:layout_marginBottom="4dp"
android:background="?attr/conversation_item_last_seen_line_color" /> android:background="@color/text" />
<TextView <TextView
android:id="@+id/text" android:id="@+id/text"
@ -22,9 +22,8 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="center"
style="@style/Signal.Text.Caption" style="@style/Signal.Text.Caption"
android:textAllCaps="true" android:textColor="@color/text"
android:fontFamily="sans-serif-medium" android:textSize="@dimen/small_font_size"
android:textColor="?attr/conversation_item_last_seen_text_color"
tools:text="3 unread messages" /> tools:text="3 unread messages" />
</LinearLayout> </LinearLayout>

View File

@ -25,8 +25,8 @@
<RelativeLayout <RelativeLayout
android:id="@+id/contact_photo_container" android:id="@+id/contact_photo_container"
android:layout_width="@dimen/small_profile_picture_size" android:layout_width="36dp"
android:layout_height="wrap_content" android:layout_height="42dp"
android:layout_alignParentStart="true"> android:layout_alignParentStart="true">
<org.thoughtcrime.securesms.loki.redesign.views.ProfilePictureView <org.thoughtcrime.securesms.loki.redesign.views.ProfilePictureView
@ -37,9 +37,8 @@
<ImageView <ImageView
android:id="@+id/moderator_icon_image_view" android:id="@+id/moderator_icon_image_view"
android:layout_width="16dp" android:layout_width="20dp"
android:layout_height="16dp" android:layout_height="20dp"
android:layout_marginEnd="1.5dp"
android:src="@drawable/icon_crown" android:src="@drawable/icon_crown"
android:layout_alignParentEnd="true" android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true" /> android:layout_alignParentBottom="true" />
@ -61,6 +60,8 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/message_bubble_edge_margin" android:layout_marginEnd="@dimen/message_bubble_edge_margin"
android:layout_marginStart="@dimen/large_spacing" android:layout_marginStart="@dimen/large_spacing"
android:paddingTop="@dimen/medium_spacing"
android:paddingBottom="@dimen/medium_spacing"
android:orientation="vertical" android:orientation="vertical"
android:clipToPadding="false" android:clipToPadding="false"
android:clipChildren="false" android:clipChildren="false"
@ -71,9 +72,8 @@
android:id="@+id/group_sender_holder" android:id="@+id/group_sender_holder"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="@dimen/message_bubble_top_padding"
android:layout_marginBottom="2dp"
android:layout_marginStart="@dimen/message_bubble_horizontal_padding" android:layout_marginStart="@dimen/message_bubble_horizontal_padding"
android:layout_marginBottom="@dimen/medium_spacing"
android:layout_marginEnd="@dimen/message_bubble_horizontal_padding" android:layout_marginEnd="@dimen/message_bubble_horizontal_padding"
android:orientation="horizontal" android:orientation="horizontal"
android:visibility="gone" android:visibility="gone"
@ -87,6 +87,8 @@
style="@style/Signal.Text.Preview" style="@style/Signal.Text.Preview"
android:fontFamily="sans-serif-medium" android:fontFamily="sans-serif-medium"
android:textColor="?conversation_item_received_text_primary_color" android:textColor="?conversation_item_received_text_primary_color"
android:textSize="@dimen/small_font_size"
android:alpha="0.6"
android:maxLines="1" android:maxLines="1"
android:ellipsize="end" android:ellipsize="end"
tools:visibility="visible" tools:visibility="visible"
@ -112,13 +114,13 @@
android:id="@+id/quote_view" android:id="@+id/quote_view"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="@dimen/message_bubble_top_padding" android:layout_marginStart="@dimen/large_spacing"
android:layout_marginStart="6dp" android:layout_marginBottom="@dimen/medium_spacing"
android:layout_marginEnd="6dp" android:layout_marginEnd="@dimen/large_spacing"
android:visibility="gone" android:visibility="gone"
app:message_type="incoming" app:message_type="incoming"
app:quote_colorPrimary="?attr/conversation_item_quote_text_color" app:quote_colorPrimary="@color/text"
app:quote_colorSecondary="?attr/conversation_item_quote_text_color" app:quote_colorSecondary="@color/text"
tools:visibility="visible"/> tools:visibility="visible"/>
<ViewStub <ViewStub
@ -152,9 +154,8 @@
android:layout="@layout/conversation_item_received_audio" android:layout="@layout/conversation_item_received_audio"
android:layout_width="210dp" android:layout_width="210dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="@dimen/message_bubble_top_padding"
android:layout_marginBottom="@dimen/message_bubble_collapsed_footer_padding"
android:layout_marginStart="@dimen/message_bubble_horizontal_padding" android:layout_marginStart="@dimen/message_bubble_horizontal_padding"
android:layout_marginBottom="6dp"
android:layout_marginEnd="@dimen/message_bubble_horizontal_padding" /> android:layout_marginEnd="@dimen/message_bubble_horizontal_padding" />
<ViewStub <ViewStub
@ -162,8 +163,7 @@
android:layout="@layout/conversation_item_received_document" android:layout="@layout/conversation_item_received_document"
android:layout_width="210dp" android:layout_width="210dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="@dimen/message_bubble_top_padding" android:layout_marginBottom="@dimen/medium_spacing"
android:layout_marginBottom="@dimen/message_bubble_collapsed_footer_padding"
android:layout_marginStart="@dimen/message_bubble_horizontal_padding" android:layout_marginStart="@dimen/message_bubble_horizontal_padding"
android:layout_marginEnd="@dimen/message_bubble_horizontal_padding" /> android:layout_marginEnd="@dimen/message_bubble_horizontal_padding" />
@ -171,8 +171,6 @@
android:id="@+id/conversation_item_body" android:id="@+id/conversation_item_body"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="14dp"
android:layout_marginBottom="@dimen/message_bubble_collapsed_footer_padding"
android:layout_marginStart="@dimen/message_bubble_horizontal_padding" android:layout_marginStart="@dimen/message_bubble_horizontal_padding"
android:layout_marginEnd="@dimen/message_bubble_horizontal_padding" android:layout_marginEnd="@dimen/message_bubble_horizontal_padding"
style="@style/Signal.Text.Body" style="@style/Signal.Text.Body"
@ -187,10 +185,9 @@
android:id="@+id/conversation_item_footer" android:id="@+id/conversation_item_footer"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="-4dp" android:layout_marginTop="4dp"
android:layout_marginStart="@dimen/message_bubble_horizontal_padding" android:layout_marginStart="@dimen/message_bubble_horizontal_padding"
android:layout_marginEnd="@dimen/message_bubble_horizontal_padding" android:layout_marginEnd="@dimen/message_bubble_horizontal_padding"
android:layout_marginBottom="@dimen/message_bubble_bottom_padding"
android:clipChildren="false" android:clipChildren="false"
android:clipToPadding="false" android:clipToPadding="false"
android:alpha="0.6" android:alpha="0.6"

View File

@ -37,6 +37,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:orientation="vertical"
android:layout_marginStart="@dimen/message_bubble_edge_margin" android:layout_marginStart="@dimen/message_bubble_edge_margin"
android:paddingTop="@dimen/medium_spacing"
android:paddingBottom="@dimen/medium_spacing" android:paddingBottom="@dimen/medium_spacing"
android:layout_gravity="end" android:layout_gravity="end"
android:clipToPadding="false" android:clipToPadding="false"
@ -48,13 +49,13 @@
android:id="@+id/quote_view" android:id="@+id/quote_view"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="@dimen/message_bubble_top_padding" android:layout_marginStart="@dimen/large_spacing"
android:layout_marginStart="6dp" android:layout_marginBottom="@dimen/medium_spacing"
android:layout_marginEnd="6dp" android:layout_marginEnd="@dimen/large_spacing"
android:visibility="gone" android:visibility="gone"
app:message_type="outgoing" app:message_type="outgoing"
app:quote_colorPrimary="?attr/conversation_item_quote_text_color" app:quote_colorPrimary="@color/text"
app:quote_colorSecondary="?attr/conversation_item_quote_text_color" app:quote_colorSecondary="@color/text"
tools:visibility="visible"/> tools:visibility="visible"/>
<ViewStub <ViewStub
@ -62,7 +63,7 @@
android:layout="@layout/conversation_item_sent_shared_contact" android:layout="@layout/conversation_item_sent_shared_contact"
android:layout_width="@dimen/media_bubble_default_dimens" android:layout_width="@dimen/media_bubble_default_dimens"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="@dimen/message_bubble_top_padding" android:layout_marginBottom="@dimen/medium_spacing"
android:visibility="gone"/> android:visibility="gone"/>
<ViewStub <ViewStub
@ -88,8 +89,8 @@
android:layout="@layout/conversation_item_sent_audio" android:layout="@layout/conversation_item_sent_audio"
android:layout_width="210dp" android:layout_width="210dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="@dimen/message_bubble_top_padding"
android:layout_marginStart="@dimen/message_bubble_horizontal_padding" android:layout_marginStart="@dimen/message_bubble_horizontal_padding"
android:layout_marginBottom="6dp"
android:layout_marginEnd="@dimen/message_bubble_horizontal_padding" /> android:layout_marginEnd="@dimen/message_bubble_horizontal_padding" />
<ViewStub <ViewStub
@ -97,16 +98,14 @@
android:layout="@layout/conversation_item_sent_document" android:layout="@layout/conversation_item_sent_document"
android:layout_width="210dp" android:layout_width="210dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="@dimen/message_bubble_top_padding"
android:layout_marginBottom="@dimen/message_bubble_collapsed_footer_padding"
android:layout_marginStart="@dimen/message_bubble_horizontal_padding" android:layout_marginStart="@dimen/message_bubble_horizontal_padding"
android:layout_marginBottom="@dimen/medium_spacing"
android:layout_marginEnd="@dimen/message_bubble_horizontal_padding" /> android:layout_marginEnd="@dimen/message_bubble_horizontal_padding" />
<org.thoughtcrime.securesms.components.emoji.EmojiTextView <org.thoughtcrime.securesms.components.emoji.EmojiTextView
android:id="@+id/conversation_item_body" android:id="@+id/conversation_item_body"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="14dp"
android:layout_marginStart="@dimen/message_bubble_horizontal_padding" android:layout_marginStart="@dimen/message_bubble_horizontal_padding"
android:layout_marginEnd="@dimen/message_bubble_horizontal_padding" android:layout_marginEnd="@dimen/message_bubble_horizontal_padding"
style="@style/Signal.Text.Body" style="@style/Signal.Text.Body"

View File

@ -23,7 +23,7 @@
<ImageView <ImageView
android:id="@+id/quote_bar" android:id="@+id/quote_bar"
android:layout_width="@dimen/quote_corner_radius_bottom" android:layout_width="@dimen/accent_line_thickness"
android:layout_height="match_parent" android:layout_height="match_parent"
android:src="@color/white" android:src="@color/white"
tools:tint="@color/purple_400" /> tools:tint="@color/purple_400" />
@ -43,8 +43,9 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
style="@style/Signal.Text.Caption" style="@style/Signal.Text.Caption"
android:textColor="@color/core_black" android:textColor="@color/text"
android:textStyle="bold" android:fontFamily="sans-serif-medium"
android:textSize="@dimen/small_font_size"
android:maxLines="1" android:maxLines="1"
android:ellipsize="end" android:ellipsize="end"
tools:text="Peter Parker" /> tools:text="Peter Parker" />
@ -71,7 +72,8 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
style="@style/Signal.Text.Body" style="@style/Signal.Text.Body"
android:textColor="@color/core_grey_90" android:textColor="@color/text"
android:textSize="@dimen/medium_font_size"
android:maxLines="1" android:maxLines="1"
android:ellipsize="end" android:ellipsize="end"
tools:text="The-Amazing-Spider-Man.cba" /> tools:text="The-Amazing-Spider-Man.cba" />
@ -95,6 +97,7 @@
android:id="@+id/quote_text" android:id="@+id/quote_text"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="4dp"
style="@style/Signal.Text.Body" style="@style/Signal.Text.Body"
android:ellipsize="end" android:ellipsize="end"
android:maxLines="2" android:maxLines="2"
@ -154,7 +157,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="8dp" android:layout_marginEnd="8dp"
android:src="@drawable/ic_broken_link" android:src="@drawable/ic_broken_link"
android:tint="?attr/quote_missing_icon_color"/> android:tint="@color/text"/>
<TextView <TextView
android:id="@+id/quote_missing_text" android:id="@+id/quote_missing_text"
@ -162,7 +165,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
style="@style/Signal.Text.Caption" style="@style/Signal.Text.Caption"
android:text="@string/QuoteView_original_missing" android:text="@string/QuoteView_original_missing"
android:textColor="@color/core_grey_90"/> android:textColor="@color/text"/>
</LinearLayout> </LinearLayout>
@ -178,6 +181,6 @@
android:layout_gravity="top|end" android:layout_gravity="top|end"
android:background="@drawable/dismiss_background" android:background="@drawable/dismiss_background"
android:src="@drawable/ic_close_white_18dp" android:src="@drawable/ic_close_white_18dp"
android:tint="@color/gray70" /> android:tint="#99FFFFFF" />
</merge> </merge>

View File

@ -24,6 +24,7 @@
<color name="compose_text_view_background">#141414</color> <color name="compose_text_view_background">#141414</color>
<color name="received_message_background">#222325</color> <color name="received_message_background">#222325</color>
<color name="sent_message_background">#3F4146</color> <color name="sent_message_background">#3F4146</color>
<color name="quote_not_found_background">#99FFFFFF</color>
<!-- Session --> <!-- Session -->
<!-- Loki --> <!-- Loki -->

View File

@ -110,8 +110,8 @@
<dimen name="conversation_item_avatar_size">36dp</dimen> <dimen name="conversation_item_avatar_size">36dp</dimen>
<dimen name="quote_corner_radius_large">10dp</dimen> <dimen name="quote_corner_radius_large">10dp</dimen>
<dimen name="quote_corner_radius_bottom">4dp</dimen> <dimen name="quote_corner_radius_bottom">2dp</dimen>
<dimen name="quote_corner_radius_preview">18dp</dimen> <dimen name="quote_corner_radius_preview">16dp</dimen>
<integer name="media_overview_cols">3</integer> <integer name="media_overview_cols">3</integer>
<dimen name="message_details_table_row_pad">10dp</dimen> <dimen name="message_details_table_row_pad">10dp</dimen>

View File

@ -38,7 +38,7 @@ import org.thoughtcrime.securesms.components.ThumbnailView;
import org.thoughtcrime.securesms.components.TypingIndicatorView; import org.thoughtcrime.securesms.components.TypingIndicatorView;
import org.thoughtcrime.securesms.database.model.ThreadRecord; import org.thoughtcrime.securesms.database.model.ThreadRecord;
import org.thoughtcrime.securesms.loki.LokiAPIUtilities; import org.thoughtcrime.securesms.loki.LokiAPIUtilities;
import org.thoughtcrime.securesms.loki.MentionUtilities; import org.thoughtcrime.securesms.loki.redesign.utilities.MentionUtilities;
import org.thoughtcrime.securesms.mms.GlideRequests; import org.thoughtcrime.securesms.mms.GlideRequests;
import org.thoughtcrime.securesms.recipients.Recipient; import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.recipients.RecipientModifiedListener; import org.thoughtcrime.securesms.recipients.RecipientModifiedListener;

View File

@ -31,6 +31,7 @@ import org.thoughtcrime.securesms.conversation.ConversationStickerSuggestionAdap
import org.thoughtcrime.securesms.database.model.StickerRecord; import org.thoughtcrime.securesms.database.model.StickerRecord;
import org.thoughtcrime.securesms.linkpreview.LinkPreview; import org.thoughtcrime.securesms.linkpreview.LinkPreview;
import org.thoughtcrime.securesms.logging.Log; import org.thoughtcrime.securesms.logging.Log;
import org.thoughtcrime.securesms.loki.redesign.utilities.MentionUtilities;
import org.thoughtcrime.securesms.mms.GlideApp; import org.thoughtcrime.securesms.mms.GlideApp;
import org.thoughtcrime.securesms.mms.GlideRequests; import org.thoughtcrime.securesms.mms.GlideRequests;
import org.thoughtcrime.securesms.mms.QuoteModel; import org.thoughtcrime.securesms.mms.QuoteModel;
@ -152,8 +153,8 @@ public class InputPanel extends LinearLayout
composeText.setMediaListener(listener); composeText.setMediaListener(listener);
} }
public void setQuote(@NonNull GlideRequests glideRequests, long id, @NonNull Recipient author, @NonNull String body, @NonNull SlideDeck attachments, @NonNull Recipient conversationRecipient) { public void setQuote(@NonNull GlideRequests glideRequests, long id, @NonNull Recipient author, @NonNull String body, @NonNull SlideDeck attachments, @NonNull Recipient conversationRecipient, long threadID) {
this.quoteView.setQuote(glideRequests, id, author, body, false, attachments, conversationRecipient); this.quoteView.setQuote(glideRequests, id, author, MentionUtilities.highlightMentions(body, threadID, getContext()), false, attachments, conversationRecipient);
this.quoteView.setVisibility(View.VISIBLE); this.quoteView.setVisibility(View.VISIBLE);
if (this.linkPreview.getVisibility() == View.VISIBLE) { if (this.linkPreview.getVisibility() == View.VISIBLE) {

View File

@ -105,7 +105,7 @@ public class QuoteView extends FrameLayout implements RecipientModifiedListener
this.dismissView = findViewById(R.id.quote_dismiss); this.dismissView = findViewById(R.id.quote_dismiss);
this.mediaDescriptionText = findViewById(R.id.media_type); this.mediaDescriptionText = findViewById(R.id.media_type);
this.missingLinkText = findViewById(R.id.quote_missing_text); this.missingLinkText = findViewById(R.id.quote_missing_text);
this.largeCornerRadius = getResources().getDimensionPixelSize(R.dimen.quote_corner_radius_large); this.largeCornerRadius = getResources().getDimensionPixelSize(R.dimen.quote_corner_radius_bottom);
this.smallCornerRadius = getResources().getDimensionPixelSize(R.dimen.quote_corner_radius_bottom); this.smallCornerRadius = getResources().getDimensionPixelSize(R.dimen.quote_corner_radius_bottom);
cornerMask = new CornerMask(this); cornerMask = new CornerMask(this);
@ -209,8 +209,8 @@ public class QuoteView extends FrameLayout implements RecipientModifiedListener
authorView.setText(isOwnNumber ? getContext().getString(R.string.QuoteView_you) : quoteeDisplayName); authorView.setText(isOwnNumber ? getContext().getString(R.string.QuoteView_you) : quoteeDisplayName);
// We use the raw color resource because Android 4.x was struggling with tints here // We use the raw color resource because Android 4.x was struggling with tints here
quoteBarView.setImageResource(author.getColor().toQuoteBarColorResource(getContext(), outgoing)); quoteBarView.setImageResource(R.color.accent);
mainView.setBackgroundColor(author.getColor().toQuoteBackgroundColor(getContext(), outgoing)); mainView.setBackgroundColor(getResources().getColor(outgoing ? R.color.received_message_background : R.color.sent_message_background));
} }
private void setQuoteText(@Nullable String body, @NonNull SlideDeck attachments) { private void setQuoteText(@Nullable String body, @NonNull SlideDeck attachments) {
@ -278,7 +278,7 @@ public class QuoteView extends FrameLayout implements RecipientModifiedListener
private void setQuoteMissingFooter(boolean missing) { private void setQuoteMissingFooter(boolean missing) {
footerView.setVisibility(missing ? VISIBLE : GONE); footerView.setVisibility(missing ? VISIBLE : GONE);
footerView.setBackgroundColor(author.getColor().toQuoteFooterColor(getContext(), messageType != MESSAGE_TYPE_INCOMING)); footerView.setBackgroundColor(getResources().getColor(R.color.quote_not_found_background));
} }
public long getQuoteId() { public long getQuoteId() {

View File

@ -2902,7 +2902,8 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
author, author,
body, body,
slideDeck, slideDeck,
recipient); recipient,
threadId);
} else if (messageRecord.isMms() && !((MmsMessageRecord) messageRecord).getLinkPreviews().isEmpty()) { } else if (messageRecord.isMms() && !((MmsMessageRecord) messageRecord).getLinkPreviews().isEmpty()) {
LinkPreview linkPreview = ((MmsMessageRecord) messageRecord).getLinkPreviews().get(0); LinkPreview linkPreview = ((MmsMessageRecord) messageRecord).getLinkPreviews().get(0);
@ -2917,14 +2918,16 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
author, author,
messageRecord.getBody(), messageRecord.getBody(),
slideDeck, slideDeck,
recipient); recipient,
threadId);
} else { } else {
inputPanel.setQuote(GlideApp.with(this), inputPanel.setQuote(GlideApp.with(this),
messageRecord.getDateSent(), messageRecord.getDateSent(),
author, author,
messageRecord.getBody(), messageRecord.getBody(),
messageRecord.isMms() ? ((MmsMessageRecord) messageRecord).getSlideDeck() : new SlideDeck(), messageRecord.isMms() ? ((MmsMessageRecord) messageRecord).getSlideDeck() : new SlideDeck(),
recipient); recipient,
threadId);
} }
} }

View File

@ -87,7 +87,7 @@ import org.thoughtcrime.securesms.linkpreview.LinkPreview;
import org.thoughtcrime.securesms.linkpreview.LinkPreviewUtil; import org.thoughtcrime.securesms.linkpreview.LinkPreviewUtil;
import org.thoughtcrime.securesms.logging.Log; import org.thoughtcrime.securesms.logging.Log;
import org.thoughtcrime.securesms.loki.LokiMessageDatabase; import org.thoughtcrime.securesms.loki.LokiMessageDatabase;
import org.thoughtcrime.securesms.loki.MentionUtilities; import org.thoughtcrime.securesms.loki.redesign.utilities.MentionUtilities;
import org.thoughtcrime.securesms.loki.redesign.views.FriendRequestView; import org.thoughtcrime.securesms.loki.redesign.views.FriendRequestView;
import org.thoughtcrime.securesms.loki.redesign.views.FriendRequestViewDelegate; import org.thoughtcrime.securesms.loki.redesign.views.FriendRequestViewDelegate;
import org.thoughtcrime.securesms.loki.redesign.views.ProfilePictureView; import org.thoughtcrime.securesms.loki.redesign.views.ProfilePictureView;
@ -267,6 +267,7 @@ public class ConversationItem extends LinearLayout
setGroupAuthorColor(messageRecord); setGroupAuthorColor(messageRecord);
setAuthor(messageRecord, previousMessageRecord, nextMessageRecord, groupThread); setAuthor(messageRecord, previousMessageRecord, nextMessageRecord, groupThread);
setQuote(messageRecord, previousMessageRecord, nextMessageRecord, groupThread); setQuote(messageRecord, previousMessageRecord, nextMessageRecord, groupThread);
adjustMarginsIfNeeded(messageRecord);
setMessageSpacing(context, messageRecord, previousMessageRecord, nextMessageRecord, groupThread); setMessageSpacing(context, messageRecord, previousMessageRecord, nextMessageRecord, groupThread);
setFooter(messageRecord, nextMessageRecord, locale, groupThread); setFooter(messageRecord, nextMessageRecord, locale, groupThread);
setFriendRequestView(messageRecord); setFriendRequestView(messageRecord);
@ -423,6 +424,16 @@ public class ConversationItem extends LinearLayout
!hasSticker(messageRecord); !hasSticker(messageRecord);
} }
private boolean hasOnlyText(MessageRecord messageRecord) {
return messageRecord.getBody().length() != 0 &&
!hasThumbnail(messageRecord) &&
!hasAudio(messageRecord) &&
!hasDocument(messageRecord) &&
!hasSharedContact(messageRecord) &&
!hasSticker(messageRecord) &&
!hasQuote(messageRecord);
}
private boolean hasDocument(MessageRecord messageRecord) { private boolean hasDocument(MessageRecord messageRecord) {
return messageRecord.isMms() && ((MmsMessageRecord)messageRecord).getSlideDeck().getDocumentSlide() != null; return messageRecord.isMms() && ((MmsMessageRecord)messageRecord).getSlideDeck().getDocumentSlide() != null;
} }
@ -461,10 +472,6 @@ public class ConversationItem extends LinearLayout
bodyText.setClickable(false); bodyText.setClickable(false);
bodyText.setFocusable(false); bodyText.setFocusable(false);
bodyText.setTextSize(TypedValue.COMPLEX_UNIT_SP, TextSecurePreferences.getMessageBodyTextSize(context)); bodyText.setTextSize(TypedValue.COMPLEX_UNIT_SP, TextSecurePreferences.getMessageBodyTextSize(context));
bodyBubble.setPadding(0, 0, 0, 0);
if (messageRecord.isOutgoing() && !(isCaptionlessMms(messageRecord) && !hasAudio(messageRecord))) {
bodyBubble.setPadding(0, 0, 0, (int) getResources().getDimension(R.dimen.medium_spacing));
}
if (isCaptionlessMms(messageRecord)) { if (isCaptionlessMms(messageRecord)) {
bodyText.setVisibility(View.GONE); bodyText.setVisibility(View.GONE);
} else { } else {
@ -483,6 +490,33 @@ public class ConversationItem extends LinearLayout
} }
} }
private void adjustMarginsIfNeeded(MessageRecord messageRecord) {
LinearLayout.LayoutParams bodyTextLayoutParams = (LinearLayout.LayoutParams)bodyText.getLayoutParams();
bodyTextLayoutParams.topMargin = 0;
if (hasOnlyThumbnail(messageRecord)) {
int topPadding = 0;
if (groupSenderHolder.getVisibility() == VISIBLE) {
topPadding = (int)getResources().getDimension(R.dimen.medium_spacing);
}
int bottomPadding = 0;
if (messageRecord.getBody().length() > 0) {
bodyTextLayoutParams.topMargin = (int)getResources().getDimension(R.dimen.medium_spacing);
bottomPadding = (int)getResources().getDimension(R.dimen.medium_spacing);
}
bodyBubble.setPadding(0, topPadding, 0, bottomPadding);
} else {
bodyBubble.setPadding(0, (int)getResources().getDimension(R.dimen.medium_spacing), 0, (int)getResources().getDimension(R.dimen.medium_spacing));
}
bodyText.setLayoutParams(bodyTextLayoutParams);
LinearLayout.LayoutParams senderHolderLayoutParams = (LinearLayout.LayoutParams)groupSenderHolder.getLayoutParams();
if (groupSenderHolder.getVisibility() == VISIBLE && hasOnlyText(messageRecord)) {
senderHolderLayoutParams.bottomMargin = (int)(getResources().getDisplayMetrics().density * 4);
} else {
senderHolderLayoutParams.bottomMargin = (int)getResources().getDimension(R.dimen.medium_spacing);
}
groupSenderHolder.setLayoutParams(senderHolderLayoutParams);
}
private void setMediaAttributes(@NonNull MessageRecord messageRecord, private void setMediaAttributes(@NonNull MessageRecord messageRecord,
@NonNull Optional<MessageRecord> previousRecord, @NonNull Optional<MessageRecord> previousRecord,
@NonNull Optional<MessageRecord> nextRecord, @NonNull Optional<MessageRecord> nextRecord,
@ -741,7 +775,9 @@ public class ConversationItem extends LinearLayout
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams)bodyBubble.getLayoutParams(); LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams)bodyBubble.getLayoutParams();
int groupThreadMargin = (int)(getResources().getDimension(R.dimen.large_spacing) + getResources().getDimension(R.dimen.small_profile_picture_size)); int groupThreadMargin = (int)(getResources().getDimension(R.dimen.large_spacing) + getResources().getDimension(R.dimen.small_profile_picture_size));
int defaultMargin = 0; int defaultMargin = 0;
layoutParams.setMarginStart(groupThread ? groupThreadMargin : defaultMargin); String threadName = DatabaseFactory.getThreadDatabase(context).getRecipientForThreadId(messageRecord.getThreadId()).getName();
boolean isRSSFeed = threadName.equals("Loki News") || threadName.equals("Loki Messenger Updates");
layoutParams.setMarginStart((groupThread && !isRSSFeed) ? groupThreadMargin : defaultMargin);
bodyBubble.setLayoutParams(layoutParams); bodyBubble.setLayoutParams(layoutParams);
if (profilePictureView == null) return; if (profilePictureView == null) return;
profilePictureView.setHexEncodedPublicKey(recipient.getAddress().toString()); profilePictureView.setHexEncodedPublicKey(recipient.getAddress().toString());
@ -921,7 +957,9 @@ public class ConversationItem extends LinearLayout
} }
private void setAuthor(@NonNull MessageRecord current, @NonNull Optional<MessageRecord> previous, @NonNull Optional<MessageRecord> next, boolean isGroupThread) { private void setAuthor(@NonNull MessageRecord current, @NonNull Optional<MessageRecord> previous, @NonNull Optional<MessageRecord> next, boolean isGroupThread) {
if (isGroupThread && !current.isOutgoing()) { String threadName = DatabaseFactory.getThreadDatabase(context).getRecipientForThreadId(current.getThreadId()).getName();
boolean isRSSFeed = threadName.equals("Loki News") || threadName.equals("Loki Messenger Updates");
if (isGroupThread && !isRSSFeed && !current.isOutgoing()) {
contactPhotoHolder.setVisibility(VISIBLE); contactPhotoHolder.setVisibility(VISIBLE);
if (!previous.isPresent() || previous.get().isUpdate() || !current.getRecipient().getAddress().equals(previous.get().getRecipient().getAddress()) || if (!previous.isPresent() || previous.get().isUpdate() || !current.getRecipient().getAddress().equals(previous.get().getRecipient().getAddress()) ||
@ -932,7 +970,7 @@ public class ConversationItem extends LinearLayout
groupSenderHolder.setVisibility(GONE); groupSenderHolder.setVisibility(GONE);
} }
if (!next.isPresent() || next.get().isUpdate() || !current.getRecipient().getAddress().equals(next.get().getRecipient().getAddress())) { if (!previous.isPresent() || previous.get().isUpdate() || !current.getRecipient().getAddress().equals(previous.get().getRecipient().getAddress())) {
profilePictureView.setVisibility(VISIBLE); profilePictureView.setVisibility(VISIBLE);
int visibility = View.GONE; int visibility = View.GONE;

View File

@ -1,12 +1,16 @@
package org.thoughtcrime.securesms.loki package org.thoughtcrime.securesms.loki.redesign.utilities
import android.content.Context import android.content.Context
import android.graphics.Typeface
import android.text.Spannable import android.text.Spannable
import android.text.SpannableString import android.text.SpannableString
import android.text.style.BackgroundColorSpan import android.text.style.ForegroundColorSpan
import android.text.style.StyleSpan
import android.util.Range import android.util.Range
import network.loki.messenger.R import network.loki.messenger.R
import nl.komponents.kovenant.combine.Tuple2
import org.thoughtcrime.securesms.database.DatabaseFactory import org.thoughtcrime.securesms.database.DatabaseFactory
import org.thoughtcrime.securesms.loki.getColorWithID
import org.thoughtcrime.securesms.util.TextSecurePreferences import org.thoughtcrime.securesms.util.TextSecurePreferences
import java.util.regex.Pattern import java.util.regex.Pattern
@ -14,7 +18,7 @@ object MentionUtilities {
@JvmStatic @JvmStatic
fun highlightMentions(text: CharSequence, threadID: Long, context: Context): String { fun highlightMentions(text: CharSequence, threadID: Long, context: Context): String {
return MentionUtilities.highlightMentions(text, false, threadID, context).toString() // isOutgoingMessage is irrelevant return highlightMentions(text, false, threadID, context).toString() // isOutgoingMessage is irrelevant
} }
@JvmStatic @JvmStatic
@ -22,13 +26,14 @@ object MentionUtilities {
var text = text var text = text
val pattern = Pattern.compile("@[0-9a-fA-F]*") val pattern = Pattern.compile("@[0-9a-fA-F]*")
var matcher = pattern.matcher(text) var matcher = pattern.matcher(text)
val mentions = mutableListOf<Range<Int>>() val mentions = mutableListOf<Tuple2<Range<Int>, String>>()
var startIndex = 0 var startIndex = 0
val publicChat = DatabaseFactory.getLokiThreadDatabase(context).getPublicChat(threadID) val publicChat = DatabaseFactory.getLokiThreadDatabase(context).getPublicChat(threadID)
val userHexEncodedPublicKey = TextSecurePreferences.getLocalNumber(context)
if (matcher.find(startIndex)) { if (matcher.find(startIndex)) {
while (true) { while (true) {
val hexEncodedPublicKey = text.subSequence(matcher.start() + 1, matcher.end()).toString() // +1 to get rid of the @ val hexEncodedPublicKey = text.subSequence(matcher.start() + 1, matcher.end()).toString() // +1 to get rid of the @
val userDisplayName: String? = if (hexEncodedPublicKey.toLowerCase() == TextSecurePreferences.getLocalNumber(context).toLowerCase()) { val userDisplayName: String? = if (hexEncodedPublicKey.toLowerCase() == userHexEncodedPublicKey.toLowerCase()) {
TextSecurePreferences.getProfileName(context) TextSecurePreferences.getProfileName(context)
} else if (publicChat != null) { } else if (publicChat != null) {
DatabaseFactory.getLokiUserDatabase(context).getServerDisplayName(publicChat.id, hexEncodedPublicKey) DatabaseFactory.getLokiUserDatabase(context).getServerDisplayName(publicChat.id, hexEncodedPublicKey)
@ -39,7 +44,7 @@ object MentionUtilities {
text = text.subSequence(0, matcher.start()).toString() + "@" + userDisplayName + text.subSequence(matcher.end(), text.length) text = text.subSequence(0, matcher.start()).toString() + "@" + userDisplayName + text.subSequence(matcher.end(), text.length)
val endIndex = matcher.start() + 1 + userDisplayName.length val endIndex = matcher.start() + 1 + userDisplayName.length
startIndex = endIndex startIndex = endIndex
mentions.add(Range.create(matcher.start(), endIndex)) mentions.add(Tuple2(Range.create(matcher.start(), endIndex), hexEncodedPublicKey))
} else { } else {
startIndex = matcher.end() startIndex = matcher.end()
} }
@ -48,9 +53,12 @@ object MentionUtilities {
} }
} }
val result = SpannableString(text) val result = SpannableString(text)
for (range in mentions) { val userLinkedDeviceHexEncodedPublicKeys = DatabaseFactory.getLokiAPIDatabase(context).getPairingAuthorisations(userHexEncodedPublicKey).flatMap { listOf( it.primaryDevicePublicKey, it.secondaryDevicePublicKey ) }.toMutableSet()
val highlightColor = if (isOutgoingMessage) context.resources.getColor(R.color.loki_dark_green) else context.resources.getColor(R.color.loki_green) userLinkedDeviceHexEncodedPublicKeys.add(userHexEncodedPublicKey)
result.setSpan(BackgroundColorSpan(highlightColor), range.lower, range.upper, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE) for (mention in mentions) {
if (!userLinkedDeviceHexEncodedPublicKeys.contains(mention.second)) { continue }
result.setSpan(ForegroundColorSpan(context.resources.getColorWithID(R.color.accent, context.theme)), mention.first.lower, mention.first.upper, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE)
result.setSpan(StyleSpan(Typeface.BOLD), mention.first.lower, mention.first.upper, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE)
} }
return result return result
} }

View File

@ -10,7 +10,7 @@ import kotlinx.android.synthetic.main.view_conversation.view.*
import network.loki.messenger.R import network.loki.messenger.R
import org.thoughtcrime.securesms.database.model.ThreadRecord import org.thoughtcrime.securesms.database.model.ThreadRecord
import org.thoughtcrime.securesms.loki.LokiAPIUtilities.populateUserHexEncodedPublicKeyCacheIfNeeded import org.thoughtcrime.securesms.loki.LokiAPIUtilities.populateUserHexEncodedPublicKeyCacheIfNeeded
import org.thoughtcrime.securesms.loki.MentionUtilities.highlightMentions import org.thoughtcrime.securesms.loki.redesign.utilities.MentionUtilities.highlightMentions
import org.thoughtcrime.securesms.mms.GlideRequests import org.thoughtcrime.securesms.mms.GlideRequests
import org.thoughtcrime.securesms.util.DateUtils import org.thoughtcrime.securesms.util.DateUtils
import org.whispersystems.signalservice.loki.api.LokiAPI import org.whispersystems.signalservice.loki.api.LokiAPI