diff options
author | Daniel Gultsch <daniel@gultsch.de> | 2016-12-20 16:35:08 +0100 |
---|---|---|
committer | Daniel Gultsch <daniel@gultsch.de> | 2016-12-20 16:35:08 +0100 |
commit | b011d46ff2c5bebcf6d9577462cef6596a88c4b3 (patch) | |
tree | de488c2344acc7c764c4f9ba448ac923dad530fc /src/main/java | |
parent | e5fff42b10ba21bffa68c4c091e7c6126f8f0652 (diff) |
don't show quoted text in message preview
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/eu/siacs/conversations/utils/UIHelper.java | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/src/main/java/eu/siacs/conversations/utils/UIHelper.java b/src/main/java/eu/siacs/conversations/utils/UIHelper.java index faf4b3a5..ebb800d4 100644 --- a/src/main/java/eu/siacs/conversations/utils/UIHelper.java +++ b/src/main/java/eu/siacs/conversations/utils/UIHelper.java @@ -180,10 +180,7 @@ public class UIHelper { return new Pair<>(getFileDescriptionString(context,message),true); } } else { - String body = message.getBody(); - if (body.length() > 256) { - body = body.substring(0,256); - } + final String body = message.getBody(); if (body.startsWith(Message.ME_COMMAND)) { return new Pair<>(body.replaceAll("^" + Message.ME_COMMAND, UIHelper.getMessageDisplayName(message) + " "), false); @@ -196,8 +193,29 @@ public class UIHelper { } else if (message.treatAsDownloadable() == Message.Decision.MUST) { return new Pair<>(context.getString(R.string.x_file_offered_for_download, getFileDescriptionString(context,message)),true); - } else{ - return new Pair<>(body.trim(), false); + } else { + String[] lines = body.split("\n"); + StringBuilder builder = new StringBuilder(); + for(String l : lines) { + if (l.length() > 0) { + char first = l.charAt(0); + if (first != '>' && first != '\u00bb') { + String line = l.trim(); + char last = line.charAt(line.length()-1); + if (builder.length() != 0) { + builder.append(' '); + } + builder.append(line); + if (last != '.' && last != '!' && last != '?' && last != ',') { + break; + } + } + } + } + if (builder.length() == 0) { + builder.append(body.trim()); + } + return new Pair<>(builder.length() > 256 ? builder.substring(0,256) : builder.toString(), false); } } } |