mirror of
https://github.com/M66B/FairEmail.git
synced 2025-01-01 04:35:57 +00:00
Word break preview text
This commit is contained in:
parent
ca84b8130f
commit
040c76a451
1 changed files with 11 additions and 4 deletions
|
@ -1577,11 +1577,18 @@ public class HtmlHelper {
|
|||
if (full)
|
||||
return text;
|
||||
|
||||
String preview = text.substring(0, Math.min(text.length(), PREVIEW_SIZE));
|
||||
if (preview.length() < text.length())
|
||||
preview += "…";
|
||||
return truncate(text, PREVIEW_SIZE);
|
||||
}
|
||||
|
||||
return preview;
|
||||
static String truncate(String text, int at) {
|
||||
if (text.length() < at)
|
||||
return text;
|
||||
|
||||
String preview = text.substring(0, at);
|
||||
int space = preview.lastIndexOf(' ');
|
||||
if (space > 0)
|
||||
preview = preview.substring(0, space + 1);
|
||||
return preview + "…";
|
||||
}
|
||||
|
||||
static String getText(Context context, String html) {
|
||||
|
|
Loading…
Reference in a new issue