do not interpret grin >< as quote

This commit is contained in:
Daniel Gultsch 2017-03-08 20:21:04 +01:00
parent 064926a18b
commit 8ca16a6f63
2 changed files with 13 additions and 3 deletions

View file

@ -352,7 +352,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 == '>' && !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;

View file

@ -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);