mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-24 16:57:50 +00:00
parent
9c40de5bf1
commit
8cf3ba424a
@ -61,6 +61,8 @@ public class ConversationListItem extends RelativeLayout
|
||||
private final static Typeface BOLD_TYPEFACE = Typeface.create("sans-serif-medium", Typeface.NORMAL);
|
||||
private final static Typeface LIGHT_TYPEFACE = Typeface.create("sans-serif", Typeface.NORMAL);
|
||||
|
||||
private static final int MAX_SNIPPET_LENGTH = 500;
|
||||
|
||||
private Set<Long> selectedThreads;
|
||||
private Recipient recipient;
|
||||
private long threadId;
|
||||
@ -156,7 +158,7 @@ public class ConversationListItem extends RelativeLayout
|
||||
this.typingView.stopAnimation();
|
||||
|
||||
this.subjectView.setVisibility(VISIBLE);
|
||||
this.subjectView.setText(thread.getDisplayBody(getContext()));
|
||||
this.subjectView.setText(getTrimmedSnippet(thread.getDisplayBody(getContext())));
|
||||
this.subjectView.setTypeface(unreadCount == 0 ? LIGHT_TYPEFACE : BOLD_TYPEFACE);
|
||||
this.subjectView.setTextColor(unreadCount == 0 ? ThemeUtil.getThemedColor(getContext(), R.attr.conversation_list_item_subject_color)
|
||||
: ThemeUtil.getThemedColor(getContext(), R.attr.conversation_list_item_unread_color));
|
||||
@ -265,6 +267,11 @@ public class ConversationListItem extends RelativeLayout
|
||||
return lastSeen;
|
||||
}
|
||||
|
||||
private @NonNull CharSequence getTrimmedSnippet(@NonNull CharSequence snippet) {
|
||||
return snippet.length() <= MAX_SNIPPET_LENGTH ? snippet
|
||||
: snippet.subSequence(0, MAX_SNIPPET_LENGTH);
|
||||
}
|
||||
|
||||
private void setThumbnailSnippet(ThreadRecord thread) {
|
||||
if (thread.getSnippetUri() != null) {
|
||||
this.thumbnailView.setVisibility(View.VISIBLE);
|
||||
|
@ -42,6 +42,8 @@ public class LongMessageActivity extends PassphraseRequiredActionBarActivity imp
|
||||
private static final String KEY_MESSAGE_ID = "message_id";
|
||||
private static final String KEY_IS_MMS = "is_mms";
|
||||
|
||||
private static final int MAX_DISPLAY_LENGTH = 64 * 1024;
|
||||
|
||||
private final DynamicLanguage dynamicLanguage = new DynamicLanguage();
|
||||
private final DynamicTheme dynamicTheme = new DynamicTheme();
|
||||
|
||||
@ -150,14 +152,22 @@ public class LongMessageActivity extends PassphraseRequiredActionBarActivity imp
|
||||
TextView text = bubble.findViewById(R.id.longmessage_text);
|
||||
ConversationItemFooter footer = bubble.findViewById(R.id.longmessage_footer);
|
||||
|
||||
String trimmedBody = getTrimmedBody(message.get().getFullBody());
|
||||
SpannableString styledBody = linkifyMessageBody(new SpannableString(trimmedBody));
|
||||
|
||||
bubble.setVisibility(View.VISIBLE);
|
||||
text.setText(linkifyMessageBody(new SpannableString(message.get().getFullBody())));
|
||||
text.setText(styledBody);
|
||||
text.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
text.setTextSize(TypedValue.COMPLEX_UNIT_SP, TextSecurePreferences.getMessageBodyTextSize(this));
|
||||
footer.setMessageRecord(message.get().getMessageRecord(), dynamicLanguage.getCurrentLocale());
|
||||
});
|
||||
}
|
||||
|
||||
private String getTrimmedBody(@NonNull String text) {
|
||||
return text.length() <= MAX_DISPLAY_LENGTH ? text
|
||||
: text.substring(0, MAX_DISPLAY_LENGTH);
|
||||
}
|
||||
|
||||
private SpannableString linkifyMessageBody(SpannableString messageBody) {
|
||||
int linkPattern = Linkify.WEB_URLS | Linkify.EMAIL_ADDRESSES | Linkify.PHONE_NUMBERS;
|
||||
boolean hasLinks = Linkify.addLinks(messageBody, linkPattern);
|
||||
|
@ -22,6 +22,8 @@ public abstract class AbstractNotificationBuilder extends NotificationCompat.Bui
|
||||
@SuppressWarnings("unused")
|
||||
private static final String TAG = AbstractNotificationBuilder.class.getSimpleName();
|
||||
|
||||
private static final int MAX_DISPLAY_LENGTH = 500;
|
||||
|
||||
protected Context context;
|
||||
protected NotificationPrivacyPreference privacy;
|
||||
|
||||
@ -74,7 +76,7 @@ public abstract class AbstractNotificationBuilder extends NotificationCompat.Bui
|
||||
|
||||
public void setTicker(@NonNull Recipient recipient, @Nullable CharSequence message) {
|
||||
if (privacy.isDisplayMessage()) {
|
||||
setTicker(getStyledMessage(recipient, message));
|
||||
setTicker(getStyledMessage(recipient, trimToDisplayLength(message)));
|
||||
} else if (privacy.isDisplayContact()) {
|
||||
setTicker(getStyledMessage(recipient, context.getString(R.string.AbstractNotificationBuilder_new_message)));
|
||||
} else {
|
||||
@ -88,4 +90,11 @@ public abstract class AbstractNotificationBuilder extends NotificationCompat.Bui
|
||||
|
||||
return blinkPattern.split(",");
|
||||
}
|
||||
|
||||
protected @NonNull CharSequence trimToDisplayLength(@Nullable CharSequence text) {
|
||||
text = text == null ? "" : text;
|
||||
|
||||
return text.length() <= MAX_DISPLAY_LENGTH ? text
|
||||
: text.subSequence(0, MAX_DISPLAY_LENGTH);
|
||||
}
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ public class MultipleRecipientNotificationBuilder extends AbstractNotificationBu
|
||||
NotificationCompat.InboxStyle style = new NotificationCompat.InboxStyle();
|
||||
|
||||
for (CharSequence body : messageBodies) {
|
||||
style.addLine(body);
|
||||
style.addLine(trimToDisplayLength(body));
|
||||
}
|
||||
|
||||
setStyle(style);
|
||||
|
@ -257,15 +257,15 @@ public class SingleRecipientNotificationBuilder extends AbstractNotificationBuil
|
||||
}
|
||||
|
||||
public NotificationCompat.Builder setContentText(CharSequence contentText) {
|
||||
this.contentText = contentText;
|
||||
return super.setContentText(contentText);
|
||||
this.contentText = trimToDisplayLength(contentText);
|
||||
return super.setContentText(this.contentText);
|
||||
}
|
||||
|
||||
private CharSequence getBigText(List<CharSequence> messageBodies) {
|
||||
SpannableStringBuilder content = new SpannableStringBuilder();
|
||||
|
||||
for (int i = 0; i < messageBodies.size(); i++) {
|
||||
content.append(messageBodies.get(i));
|
||||
content.append(trimToDisplayLength(messageBodies.get(i)));
|
||||
if (i < messageBodies.size() - 1) {
|
||||
content.append('\n');
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user