aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger/utils/UIHelper.java
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2017-03-26 20:13:28 +0200
committerChristian Schneppe <christian@pix-art.de>2017-03-26 21:44:05 +0200
commite1feeb7571657cc442f59f5905796c3086fb3903 (patch)
tree7d6ccc38dafc877ad5e3597a38df973db4908a81 /src/main/java/de/pixart/messenger/utils/UIHelper.java
parent69b66b3d2781bfa63dd327ac2a102354d5306df8 (diff)
made a few exceptions to quote parser for emoticons and quotes
Diffstat (limited to 'src/main/java/de/pixart/messenger/utils/UIHelper.java')
-rw-r--r--src/main/java/de/pixart/messenger/utils/UIHelper.java45
1 files changed, 41 insertions, 4 deletions
diff --git a/src/main/java/de/pixart/messenger/utils/UIHelper.java b/src/main/java/de/pixart/messenger/utils/UIHelper.java
index 68f9297e9..37483ad1a 100644
--- a/src/main/java/de/pixart/messenger/utils/UIHelper.java
+++ b/src/main/java/de/pixart/messenger/utils/UIHelper.java
@@ -239,7 +239,8 @@ public class UIHelper {
}
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) {
@@ -257,9 +258,45 @@ 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))));
+ private static boolean isPositionFollowedByEmoticon(CharSequence body, int pos) {
+ if (body.length() <= pos + 1) {
+ 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) {