aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel@gultsch.de>2017-01-21 11:07:23 +0100
committerDaniel Gultsch <daniel@gultsch.de>2017-01-21 11:07:23 +0100
commit96a6460744d2a4ef7b9caaa38383de16eb2f38d2 (patch)
tree5a828b9291f011e36163288e0940108fe8668aa6 /src
parent780d1daf7e24899d21f8cf350f88dd0e9a075b81 (diff)
don't quote text when '>' is followed by numeber
Diffstat (limited to 'src')
-rw-r--r--src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java2
-rw-r--r--src/main/java/eu/siacs/conversations/utils/UIHelper.java17
2 files changed, 17 insertions, 2 deletions
diff --git a/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java b/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java
index a01689ec..e8b3459a 100644
--- a/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java
+++ b/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java
@@ -351,7 +351,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/eu/siacs/conversations/utils/UIHelper.java b/src/main/java/eu/siacs/conversations/utils/UIHelper.java
index cc8f68ee..c9f50bed 100644
--- a/src/main/java/eu/siacs/conversations/utils/UIHelper.java
+++ b/src/main/java/eu/siacs/conversations/utils/UIHelper.java
@@ -202,7 +202,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;
@@ -226,6 +226,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);