don't show quoted text in message preview

This commit is contained in:
Daniel Gultsch 2016-12-20 16:35:08 +01:00
parent e5fff42b10
commit b011d46ff2

View file

@ -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);
@ -197,7 +194,28 @@ public class UIHelper {
return new Pair<>(context.getString(R.string.x_file_offered_for_download,
getFileDescriptionString(context,message)),true);
} else {
return new Pair<>(body.trim(), false);
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);
}
}
}