diff options
author | Christian Schneppe <christian@pix-art.de> | 2017-01-25 19:50:38 +0100 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2017-01-25 19:50:38 +0100 |
commit | 5263c457f8ecddb15285dc03e187b439c0ba4cfa (patch) | |
tree | f6087961d8a711b7d59ffb6b2a2b75b5ca3d9027 /src/main/java | |
parent | 09218b3c500d72d7c4af3fd9e6bf7a9c56627ce6 (diff) |
don't quote text when '>' is followed by numeber
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java | 2 | ||||
-rw-r--r-- | src/main/java/de/pixart/messenger/utils/UIHelper.java | 17 |
2 files changed, 17 insertions, 2 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java b/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java index f4da84a0c..2f99b6b99 100644 --- a/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java +++ b/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java @@ -391,7 +391,7 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie char current = body.length() > i ? body.charAt(i) : '\n'; if (lineStart == -1) { if (previous == '\n') { - if (current == '>' || current == '\u00bb') { + if ((current == '>' && !UIHelper.isPositionFollowedByNumber(body, i)) || current == '\u00bb') { // Line start with quote lineStart = i; if (quoteStart == -1) quoteStart = i; diff --git a/src/main/java/de/pixart/messenger/utils/UIHelper.java b/src/main/java/de/pixart/messenger/utils/UIHelper.java index 7978650dc..12cd708f1 100644 --- a/src/main/java/de/pixart/messenger/utils/UIHelper.java +++ b/src/main/java/de/pixart/messenger/utils/UIHelper.java @@ -209,7 +209,7 @@ public class UIHelper { for(String l : lines) { if (l.length() > 0) { char first = l.charAt(0); - if (first != '>' && first != '\u00bb') { + if ((first != '>' || isPositionFollowedByNumber(l, 0)) && first != '\u00bb') { String line = l.trim(); if (line.isEmpty()) { continue; @@ -233,6 +233,21 @@ public class UIHelper { } } + public static boolean isPositionFollowedByNumber(CharSequence body, int pos) { + boolean previousWasNumber = false; + for (int i = pos + 1; i < body.length(); i++) { + char c = body.charAt(i); + if (Character.isDigit(body.charAt(i))) { + previousWasNumber = true; + } else if (previousWasNumber && (c == '.' || c == ',')) { + previousWasNumber = false; + } else { + return Character.isWhitespace(c) && previousWasNumber; + } + } + return previousWasNumber; + } + public static String getFileDescriptionString(final Context context, final Message message) { if (message.getType() == Message.TYPE_IMAGE) { return context.getString(R.string.image); |