From 5280a96ae1b78553e624a0c3fc10b6b362d2d39b Mon Sep 17 00:00:00 2001 From: Christian Schneppe Date: Thu, 9 Mar 2017 20:45:52 +0100 Subject: do not interpret grin >< as quote --- src/main/java/de/pixart/messenger/utils/UIHelper.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src/main/java/de/pixart/messenger/utils/UIHelper.java') diff --git a/src/main/java/de/pixart/messenger/utils/UIHelper.java b/src/main/java/de/pixart/messenger/utils/UIHelper.java index caa466b04..c350268d6 100644 --- a/src/main/java/de/pixart/messenger/utils/UIHelper.java +++ b/src/main/java/de/pixart/messenger/utils/UIHelper.java @@ -212,7 +212,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; @@ -236,7 +236,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); @@ -251,6 +255,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); -- cgit v1.2.3