Skip to content

Commit

Permalink
Don't ellipsize multi-line text in conversation list.
Browse files Browse the repository at this point in the history
Instead, basically convert newlines to spaces.
  • Loading branch information
greyson-signal committed Jul 28, 2020
1 parent 8ce5c4b commit 7446c20
Showing 1 changed file with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
import org.thoughtcrime.securesms.util.MediaUtil;
import org.thoughtcrime.securesms.util.SearchUtil;
import org.thoughtcrime.securesms.util.ThemeUtil;
import org.thoughtcrime.securesms.util.Util;
import org.thoughtcrime.securesms.util.ViewUtil;

import java.util.Collections;
Expand Down Expand Up @@ -454,11 +453,23 @@ private static SpannableString getThreadDisplayBody(@NonNull Context context, @N
} else if (extra != null && extra.isRemoteDelete()) {
return new SpannableString(emphasisAdded(context.getString(thread.isOutgoing() ? R.string.ThreadRecord_you_deleted_this_message : R.string.ThreadRecord_this_message_was_deleted)));
} else {
return new SpannableString(Util.emptyIfNull(thread.getBody()));
return new SpannableString(removeNewlines(thread.getBody()));
}
}
}

private static @NonNull String removeNewlines(@Nullable String text) {
if (text == null) {
return "";
}

if (text.indexOf('\n') >= 0) {
return text.replaceAll("\n", " ");
} else {
return text;
}
}

private static @NonNull SpannableString emphasisAdded(String sequence) {
return emphasisAdded(sequence, 0, sequence.length());
}
Expand Down

0 comments on commit 7446c20

Please sign in to comment.