aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2016-12-25 18:44:07 +0100
committerChristian Schneppe <christian@pix-art.de>2016-12-25 18:44:07 +0100
commit3f34a3aff0902b37b4e94b5d8c1c38b8285532ab (patch)
tree392d51ab50768d72c201dd8041400eef4662b8f6 /src
parent9867e3b1fc9ef6ac9a3fc851dc001478177b80d7 (diff)
skip empty lines in message preview. prevents indexoutofbounds exception
and don't show quoted text in message preview
Diffstat (limited to 'src')
-rw-r--r--src/main/java/de/pixart/messenger/utils/UIHelper.java26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/main/java/de/pixart/messenger/utils/UIHelper.java b/src/main/java/de/pixart/messenger/utils/UIHelper.java
index 0bb87e6c7..dce1b031c 100644
--- a/src/main/java/de/pixart/messenger/utils/UIHelper.java
+++ b/src/main/java/de/pixart/messenger/utils/UIHelper.java
@@ -202,7 +202,31 @@ 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();
+ if (line.isEmpty()) {
+ continue;
+ }
+ 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);
}
}
}