made a few exceptions to quote parser for emoticons and quotes
This commit is contained in:
parent
00e8ba00c4
commit
2302122d8e
|
@ -352,7 +352,8 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie
|
||||||
char current = body.length() > i ? body.charAt(i) : '\n';
|
char current = body.length() > i ? body.charAt(i) : '\n';
|
||||||
if (lineStart == -1) {
|
if (lineStart == -1) {
|
||||||
if (previous == '\n') {
|
if (previous == '\n') {
|
||||||
if ((current == '>' && UIHelper.isPositionFollowedByQuoteableCharacter(body,i)) || current == '\u00bb') {
|
if ((current == '>' && UIHelper.isPositionFollowedByQuoteableCharacter(body,i))
|
||||||
|
|| current == '\u00bb' && !UIHelper.isPositionFollowedByQuote(body,i)) {
|
||||||
// Line start with quote
|
// Line start with quote
|
||||||
lineStart = i;
|
lineStart = i;
|
||||||
if (quoteStart == -1) quoteStart = i;
|
if (quoteStart == -1) quoteStart = i;
|
||||||
|
|
|
@ -8,7 +8,6 @@ import android.widget.PopupMenu;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
@ -25,8 +24,6 @@ import eu.siacs.conversations.entities.Message;
|
||||||
import eu.siacs.conversations.entities.MucOptions;
|
import eu.siacs.conversations.entities.MucOptions;
|
||||||
import eu.siacs.conversations.entities.Presence;
|
import eu.siacs.conversations.entities.Presence;
|
||||||
import eu.siacs.conversations.entities.Transferable;
|
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;
|
import eu.siacs.conversations.xmpp.jid.Jid;
|
||||||
|
|
||||||
public class UIHelper {
|
public class UIHelper {
|
||||||
|
@ -233,7 +230,8 @@ public class UIHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isPositionFollowedByQuoteableCharacter(CharSequence body, int pos) {
|
public static boolean isPositionFollowedByQuoteableCharacter(CharSequence body, int pos) {
|
||||||
return !isPositionFollowedByNumber(body, pos) && !isPositionFollowedByBigGrin(body,pos);
|
return !isPositionFollowedByNumber(body, pos)
|
||||||
|
&& !isPositionFollowedByEmoticon(body,pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isPositionFollowedByNumber(CharSequence body, int pos) {
|
private static boolean isPositionFollowedByNumber(CharSequence body, int pos) {
|
||||||
|
@ -251,9 +249,45 @@ public class UIHelper {
|
||||||
return previousWasNumber;
|
return previousWasNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isPositionFollowedByBigGrin(CharSequence body, int pos) {
|
private static boolean isPositionFollowedByEmoticon(CharSequence body, int pos) {
|
||||||
return body.length() <= pos + 1
|
if (body.length() <= pos +1) {
|
||||||
|| ((body.charAt(pos + 1) == '<') && (body.length() == pos + 2 || Character.isWhitespace(body.charAt(pos + 2))));
|
return false;
|
||||||
|
} else {
|
||||||
|
final char first = body.charAt(pos +1);
|
||||||
|
return first == ';'
|
||||||
|
|| first == ':'
|
||||||
|
|| smallerThanBeforeWhitespace(body,pos+1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean smallerThanBeforeWhitespace(CharSequence body, int pos) {
|
||||||
|
for(int i = pos; i < body.length(); ++i) {
|
||||||
|
final char c = body.charAt(i);
|
||||||
|
if (Character.isWhitespace(c)) {
|
||||||
|
return false;
|
||||||
|
} else if (c == '<') {
|
||||||
|
return body.length() == i + 1 || Character.isWhitespace(body.charAt(i + 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isPositionFollowedByQuote(CharSequence body, int pos) {
|
||||||
|
if (body.length() <= pos + 1 || Character.isWhitespace(body.charAt(pos+1))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
boolean previousWasWhitespace = false;
|
||||||
|
for (int i = pos +1; i < body.length(); i++) {
|
||||||
|
char c = body.charAt(i);
|
||||||
|
if (c == '\n' || c == '»') {
|
||||||
|
return false;
|
||||||
|
} else if (c == '«' && !previousWasWhitespace) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
previousWasWhitespace = Character.isWhitespace(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getDisplayName(MucOptions.User user) {
|
public static String getDisplayName(MucOptions.User user) {
|
||||||
|
|
Loading…
Reference in New Issue