From 8ca16a6f63a7bca52455206186faf99dcf721f4f Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Wed, 8 Mar 2017 20:21:04 +0100 Subject: [PATCH] do not interpret grin >< as quote --- .../conversations/ui/adapter/MessageAdapter.java | 2 +- .../eu/siacs/conversations/utils/UIHelper.java | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 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 1364f0d27..0a405b958 100644 --- a/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java +++ b/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java @@ -352,7 +352,7 @@ public class MessageAdapter extends ArrayAdapter implements CopyTextVie char current = body.length() > i ? body.charAt(i) : '\n'; if (lineStart == -1) { if (previous == '\n') { - if ((current == '>' && !UIHelper.isPositionFollowedByNumber(body,i)) || current == '\u00bb') { + if ((current == '>' && UIHelper.isPositionFollowedByQuoteableCharacter(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 773fd11d8..401303eb9 100644 --- a/src/main/java/eu/siacs/conversations/utils/UIHelper.java +++ b/src/main/java/eu/siacs/conversations/utils/UIHelper.java @@ -25,6 +25,7 @@ import eu.siacs.conversations.entities.Message; import eu.siacs.conversations.entities.Presence; import eu.siacs.conversations.entities.Transferable; import eu.siacs.conversations.ui.XmppActivity; +import eu.siacs.conversations.xmpp.chatstate.ChatState; import eu.siacs.conversations.xmpp.jid.Jid; public class UIHelper { @@ -205,7 +206,7 @@ public class UIHelper { for(String l : lines) { if (l.length() > 0) { char first = l.charAt(0); - if ((first != '>' || isPositionFollowedByNumber(l,0)) && first != '\u00bb') { + if ((first != '>' || !isPositionFollowedByQuoteableCharacter(l,0)) && first != '\u00bb') { String line = l.trim(); if (line.isEmpty()) { continue; @@ -229,7 +230,11 @@ public class UIHelper { } } - public static boolean isPositionFollowedByNumber(CharSequence body, int pos) { + public static boolean isPositionFollowedByQuoteableCharacter(CharSequence body, int pos) { + return !isPositionFollowedByNumber(body, pos) && !isPositionFollowedByBigGrin(body,pos); + } + + private static boolean isPositionFollowedByNumber(CharSequence body, int pos) { boolean previousWasNumber = false; for (int i = pos +1; i < body.length(); i++) { char c = body.charAt(i); @@ -244,6 +249,11 @@ public class UIHelper { return previousWasNumber; } + private static boolean isPositionFollowedByBigGrin(CharSequence body, int pos) { + return body.length() <= pos + 1 + || ((body.charAt(pos+1) == '<') && (body.length() == pos+2 || Character.isWhitespace(body.charAt(pos+2)))); + } + public static String getFileDescriptionString(final Context context, final Message message) { if (message.getType() == Message.TYPE_IMAGE) { return context.getString(R.string.image);