diff --git a/res/layout-sw420dp/attachment_type_selector.xml b/res/layout-sw420dp/attachment_type_selector.xml
index 6d71246d6b..c17d36400c 100644
--- a/res/layout-sw420dp/attachment_type_selector.xml
+++ b/res/layout-sw420dp/attachment_type_selector.xml
@@ -34,8 +34,8 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
+ android:layout_marginTop="2dp"
android:layout_marginEnd="16dp"
- android:layout_marginTop="16dp"
android:weightSum="3">
+ android:layout_height="1dp"
+ android:layout_marginStart="@dimen/large_spacing"
+ android:layout_marginEnd="@dimen/large_spacing"
+ android:layout_marginBottom="4dp"
+ android:background="@color/text" />
\ No newline at end of file
diff --git a/res/layout/conversation_item_received.xml b/res/layout/conversation_item_received.xml
index 24d76569ea..87abafba24 100644
--- a/res/layout/conversation_item_received.xml
+++ b/res/layout/conversation_item_received.xml
@@ -25,8 +25,8 @@
@@ -61,6 +60,8 @@
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/message_bubble_edge_margin"
android:layout_marginStart="@dimen/large_spacing"
+ android:paddingTop="@dimen/medium_spacing"
+ android:paddingBottom="@dimen/medium_spacing"
android:orientation="vertical"
android:clipToPadding="false"
android:clipChildren="false"
@@ -71,9 +72,8 @@
android:id="@+id/group_sender_holder"
android:layout_width="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_marginBottom="@dimen/medium_spacing"
android:layout_marginEnd="@dimen/message_bubble_horizontal_padding"
android:orientation="horizontal"
android:visibility="gone"
@@ -87,6 +87,8 @@
style="@style/Signal.Text.Preview"
android:fontFamily="sans-serif-medium"
android:textColor="?conversation_item_received_text_primary_color"
+ android:textSize="@dimen/small_font_size"
+ android:alpha="0.6"
android:maxLines="1"
android:ellipsize="end"
tools:visibility="visible"
@@ -112,13 +114,13 @@
android:id="@+id/quote_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_marginTop="@dimen/message_bubble_top_padding"
- android:layout_marginStart="6dp"
- android:layout_marginEnd="6dp"
+ android:layout_marginStart="@dimen/large_spacing"
+ android:layout_marginBottom="@dimen/medium_spacing"
+ android:layout_marginEnd="@dimen/large_spacing"
android:visibility="gone"
app:message_type="incoming"
- app:quote_colorPrimary="?attr/conversation_item_quote_text_color"
- app:quote_colorSecondary="?attr/conversation_item_quote_text_color"
+ app:quote_colorPrimary="@color/text"
+ app:quote_colorSecondary="@color/text"
tools:visibility="visible"/>
@@ -171,8 +171,6 @@
android:id="@+id/conversation_item_body"
android:layout_width="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_marginEnd="@dimen/message_bubble_horizontal_padding"
style="@style/Signal.Text.Body"
@@ -187,10 +185,9 @@
android:id="@+id/conversation_item_footer"
android:layout_width="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_marginEnd="@dimen/message_bubble_horizontal_padding"
- android:layout_marginBottom="@dimen/message_bubble_bottom_padding"
android:clipChildren="false"
android:clipToPadding="false"
android:alpha="0.6"
diff --git a/res/layout/conversation_item_sent.xml b/res/layout/conversation_item_sent.xml
index bc45a2b774..851b84a84d 100644
--- a/res/layout/conversation_item_sent.xml
+++ b/res/layout/conversation_item_sent.xml
@@ -37,6 +37,7 @@
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginStart="@dimen/message_bubble_edge_margin"
+ android:paddingTop="@dimen/medium_spacing"
android:paddingBottom="@dimen/medium_spacing"
android:layout_gravity="end"
android:clipToPadding="false"
@@ -48,13 +49,13 @@
android:id="@+id/quote_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_marginTop="@dimen/message_bubble_top_padding"
- android:layout_marginStart="6dp"
- android:layout_marginEnd="6dp"
+ android:layout_marginStart="@dimen/large_spacing"
+ android:layout_marginBottom="@dimen/medium_spacing"
+ android:layout_marginEnd="@dimen/large_spacing"
android:visibility="gone"
app:message_type="outgoing"
- app:quote_colorPrimary="?attr/conversation_item_quote_text_color"
- app:quote_colorSecondary="?attr/conversation_item_quote_text_color"
+ app:quote_colorPrimary="@color/text"
+ app:quote_colorSecondary="@color/text"
tools:visibility="visible"/>
@@ -43,8 +43,9 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/Signal.Text.Caption"
- android:textColor="@color/core_black"
- android:textStyle="bold"
+ android:textColor="@color/text"
+ android:fontFamily="sans-serif-medium"
+ android:textSize="@dimen/small_font_size"
android:maxLines="1"
android:ellipsize="end"
tools:text="Peter Parker" />
@@ -71,7 +72,8 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
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:ellipsize="end"
tools:text="The-Amazing-Spider-Man.cba" />
@@ -95,6 +97,7 @@
android:id="@+id/quote_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:layout_marginTop="4dp"
style="@style/Signal.Text.Body"
android:ellipsize="end"
android:maxLines="2"
@@ -154,7 +157,7 @@
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:src="@drawable/ic_broken_link"
- android:tint="?attr/quote_missing_icon_color"/>
+ android:tint="@color/text"/>
+ android:textColor="@color/text"/>
@@ -178,6 +181,6 @@
android:layout_gravity="top|end"
android:background="@drawable/dismiss_background"
android:src="@drawable/ic_close_white_18dp"
- android:tint="@color/gray70" />
+ android:tint="#99FFFFFF" />
\ No newline at end of file
diff --git a/res/values/colors.xml b/res/values/colors.xml
index e26bd5ff2c..b9ea0718c7 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -24,6 +24,7 @@
#141414
#222325
#3F4146
+ #99FFFFFF
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 41a10deae5..5891ca6bcb 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -110,8 +110,8 @@
36dp
10dp
- 4dp
- 18dp
+ 2dp
+ 16dp
3
10dp
diff --git a/src/org/thoughtcrime/securesms/ConversationListItem.java b/src/org/thoughtcrime/securesms/ConversationListItem.java
index d2ca8aaa4c..2c5bba6f1b 100644
--- a/src/org/thoughtcrime/securesms/ConversationListItem.java
+++ b/src/org/thoughtcrime/securesms/ConversationListItem.java
@@ -38,7 +38,7 @@ import org.thoughtcrime.securesms.components.ThumbnailView;
import org.thoughtcrime.securesms.components.TypingIndicatorView;
import org.thoughtcrime.securesms.database.model.ThreadRecord;
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.recipients.Recipient;
import org.thoughtcrime.securesms.recipients.RecipientModifiedListener;
diff --git a/src/org/thoughtcrime/securesms/components/InputPanel.java b/src/org/thoughtcrime/securesms/components/InputPanel.java
index 7e51d9ea14..e00b454f03 100644
--- a/src/org/thoughtcrime/securesms/components/InputPanel.java
+++ b/src/org/thoughtcrime/securesms/components/InputPanel.java
@@ -31,6 +31,7 @@ import org.thoughtcrime.securesms.conversation.ConversationStickerSuggestionAdap
import org.thoughtcrime.securesms.database.model.StickerRecord;
import org.thoughtcrime.securesms.linkpreview.LinkPreview;
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.GlideRequests;
import org.thoughtcrime.securesms.mms.QuoteModel;
@@ -152,8 +153,8 @@ public class InputPanel extends LinearLayout
composeText.setMediaListener(listener);
}
- public void setQuote(@NonNull GlideRequests glideRequests, long id, @NonNull Recipient author, @NonNull String body, @NonNull SlideDeck attachments, @NonNull Recipient conversationRecipient) {
- this.quoteView.setQuote(glideRequests, id, author, body, false, attachments, 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, MentionUtilities.highlightMentions(body, threadID, getContext()), false, attachments, conversationRecipient);
this.quoteView.setVisibility(View.VISIBLE);
if (this.linkPreview.getVisibility() == View.VISIBLE) {
diff --git a/src/org/thoughtcrime/securesms/components/QuoteView.java b/src/org/thoughtcrime/securesms/components/QuoteView.java
index cfb6a1bc3b..b4943f9993 100644
--- a/src/org/thoughtcrime/securesms/components/QuoteView.java
+++ b/src/org/thoughtcrime/securesms/components/QuoteView.java
@@ -105,7 +105,7 @@ public class QuoteView extends FrameLayout implements RecipientModifiedListener
this.dismissView = findViewById(R.id.quote_dismiss);
this.mediaDescriptionText = findViewById(R.id.media_type);
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);
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);
// We use the raw color resource because Android 4.x was struggling with tints here
- quoteBarView.setImageResource(author.getColor().toQuoteBarColorResource(getContext(), outgoing));
- mainView.setBackgroundColor(author.getColor().toQuoteBackgroundColor(getContext(), outgoing));
+ quoteBarView.setImageResource(R.color.accent);
+ mainView.setBackgroundColor(getResources().getColor(outgoing ? R.color.received_message_background : R.color.sent_message_background));
}
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) {
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() {
diff --git a/src/org/thoughtcrime/securesms/conversation/ConversationActivity.java b/src/org/thoughtcrime/securesms/conversation/ConversationActivity.java
index fb1f15543d..83daccb943 100644
--- a/src/org/thoughtcrime/securesms/conversation/ConversationActivity.java
+++ b/src/org/thoughtcrime/securesms/conversation/ConversationActivity.java
@@ -2902,7 +2902,8 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
author,
body,
slideDeck,
- recipient);
+ recipient,
+ threadId);
} else if (messageRecord.isMms() && !((MmsMessageRecord) messageRecord).getLinkPreviews().isEmpty()) {
LinkPreview linkPreview = ((MmsMessageRecord) messageRecord).getLinkPreviews().get(0);
@@ -2917,14 +2918,16 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
author,
messageRecord.getBody(),
slideDeck,
- recipient);
+ recipient,
+ threadId);
} else {
inputPanel.setQuote(GlideApp.with(this),
messageRecord.getDateSent(),
author,
messageRecord.getBody(),
messageRecord.isMms() ? ((MmsMessageRecord) messageRecord).getSlideDeck() : new SlideDeck(),
- recipient);
+ recipient,
+ threadId);
}
}
diff --git a/src/org/thoughtcrime/securesms/conversation/ConversationItem.java b/src/org/thoughtcrime/securesms/conversation/ConversationItem.java
index 163a5c74fb..44743687d8 100644
--- a/src/org/thoughtcrime/securesms/conversation/ConversationItem.java
+++ b/src/org/thoughtcrime/securesms/conversation/ConversationItem.java
@@ -87,7 +87,7 @@ import org.thoughtcrime.securesms.linkpreview.LinkPreview;
import org.thoughtcrime.securesms.linkpreview.LinkPreviewUtil;
import org.thoughtcrime.securesms.logging.Log;
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.FriendRequestViewDelegate;
import org.thoughtcrime.securesms.loki.redesign.views.ProfilePictureView;
@@ -267,6 +267,7 @@ public class ConversationItem extends LinearLayout
setGroupAuthorColor(messageRecord);
setAuthor(messageRecord, previousMessageRecord, nextMessageRecord, groupThread);
setQuote(messageRecord, previousMessageRecord, nextMessageRecord, groupThread);
+ adjustMarginsIfNeeded(messageRecord);
setMessageSpacing(context, messageRecord, previousMessageRecord, nextMessageRecord, groupThread);
setFooter(messageRecord, nextMessageRecord, locale, groupThread);
setFriendRequestView(messageRecord);
@@ -423,6 +424,16 @@ public class ConversationItem extends LinearLayout
!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) {
return messageRecord.isMms() && ((MmsMessageRecord)messageRecord).getSlideDeck().getDocumentSlide() != null;
}
@@ -461,10 +472,6 @@ public class ConversationItem extends LinearLayout
bodyText.setClickable(false);
bodyText.setFocusable(false);
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)) {
bodyText.setVisibility(View.GONE);
} 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,
@NonNull Optional previousRecord,
@NonNull Optional nextRecord,
@@ -741,7 +775,9 @@ public class ConversationItem extends LinearLayout
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 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);
if (profilePictureView == null) return;
profilePictureView.setHexEncodedPublicKey(recipient.getAddress().toString());
@@ -921,7 +957,9 @@ public class ConversationItem extends LinearLayout
}
private void setAuthor(@NonNull MessageRecord current, @NonNull Optional previous, @NonNull Optional 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);
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);
}
- 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);
int visibility = View.GONE;
diff --git a/src/org/thoughtcrime/securesms/loki/MentionUtilities.kt b/src/org/thoughtcrime/securesms/loki/redesign/utilities/MentionUtilities.kt
similarity index 58%
rename from src/org/thoughtcrime/securesms/loki/MentionUtilities.kt
rename to src/org/thoughtcrime/securesms/loki/redesign/utilities/MentionUtilities.kt
index 82ded332cb..4a29eef131 100644
--- a/src/org/thoughtcrime/securesms/loki/MentionUtilities.kt
+++ b/src/org/thoughtcrime/securesms/loki/redesign/utilities/MentionUtilities.kt
@@ -1,12 +1,16 @@
-package org.thoughtcrime.securesms.loki
+package org.thoughtcrime.securesms.loki.redesign.utilities
import android.content.Context
+import android.graphics.Typeface
import android.text.Spannable
import android.text.SpannableString
-import android.text.style.BackgroundColorSpan
+import android.text.style.ForegroundColorSpan
+import android.text.style.StyleSpan
import android.util.Range
import network.loki.messenger.R
+import nl.komponents.kovenant.combine.Tuple2
import org.thoughtcrime.securesms.database.DatabaseFactory
+import org.thoughtcrime.securesms.loki.getColorWithID
import org.thoughtcrime.securesms.util.TextSecurePreferences
import java.util.regex.Pattern
@@ -14,7 +18,7 @@ object MentionUtilities {
@JvmStatic
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
@@ -22,13 +26,14 @@ object MentionUtilities {
var text = text
val pattern = Pattern.compile("@[0-9a-fA-F]*")
var matcher = pattern.matcher(text)
- val mentions = mutableListOf>()
+ val mentions = mutableListOf, String>>()
var startIndex = 0
val publicChat = DatabaseFactory.getLokiThreadDatabase(context).getPublicChat(threadID)
+ val userHexEncodedPublicKey = TextSecurePreferences.getLocalNumber(context)
if (matcher.find(startIndex)) {
while (true) {
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)
} else if (publicChat != null) {
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)
val endIndex = matcher.start() + 1 + userDisplayName.length
startIndex = endIndex
- mentions.add(Range.create(matcher.start(), endIndex))
+ mentions.add(Tuple2(Range.create(matcher.start(), endIndex), hexEncodedPublicKey))
} else {
startIndex = matcher.end()
}
@@ -48,9 +53,12 @@ object MentionUtilities {
}
}
val result = SpannableString(text)
- for (range in mentions) {
- val highlightColor = if (isOutgoingMessage) context.resources.getColor(R.color.loki_dark_green) else context.resources.getColor(R.color.loki_green)
- result.setSpan(BackgroundColorSpan(highlightColor), range.lower, range.upper, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE)
+ val userLinkedDeviceHexEncodedPublicKeys = DatabaseFactory.getLokiAPIDatabase(context).getPairingAuthorisations(userHexEncodedPublicKey).flatMap { listOf( it.primaryDevicePublicKey, it.secondaryDevicePublicKey ) }.toMutableSet()
+ userLinkedDeviceHexEncodedPublicKeys.add(userHexEncodedPublicKey)
+ 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
}
diff --git a/src/org/thoughtcrime/securesms/loki/redesign/views/ConversationView.kt b/src/org/thoughtcrime/securesms/loki/redesign/views/ConversationView.kt
index f145b4a9f5..5371bfce5a 100644
--- a/src/org/thoughtcrime/securesms/loki/redesign/views/ConversationView.kt
+++ b/src/org/thoughtcrime/securesms/loki/redesign/views/ConversationView.kt
@@ -10,7 +10,7 @@ import kotlinx.android.synthetic.main.view_conversation.view.*
import network.loki.messenger.R
import org.thoughtcrime.securesms.database.model.ThreadRecord
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.util.DateUtils
import org.whispersystems.signalservice.loki.api.LokiAPI