aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2018-12-14 20:48:25 +0100
committerChristian Schneppe <christian@pix-art.de>2018-12-14 21:13:31 +0100
commitfe3f14d9b13f2cd97c24bc241dddaa2c2bca755f (patch)
treeafdb45362c7bee8da2632be0e98424386d02544a /src/main/java/de/pixart
parent7967a35cd3fa9983a559c937a7ab24ef815d87c6 (diff)
Checkout `xmpp-addr` library 0.8.0 (fa47cac8) locally
xmpp-addr: Backfill missing class method for Java 1.7 This backfills missing class methods for `java.nio.charset.StandardCharsets` and `java.util.Objects` for compatibility with platforms which do not support these (mainly Android SDK versions <= 18). Change `minSdkVersion` to 18, backfill missing methods This reduces the minimum SDK version to 18 (Android 4.3), which notably is the last supported version for the BlackBerry OS 10.3 Android compatibility layer. Drop support for Android 4.1 and 4.2
Diffstat (limited to 'src/main/java/de/pixart')
-rw-r--r--src/main/java/de/pixart/messenger/ui/util/MyLinkify.java21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/util/MyLinkify.java b/src/main/java/de/pixart/messenger/ui/util/MyLinkify.java
index 2817c55c7..8f2aa4e61 100644
--- a/src/main/java/de/pixart/messenger/ui/util/MyLinkify.java
+++ b/src/main/java/de/pixart/messenger/ui/util/MyLinkify.java
@@ -40,6 +40,8 @@ import de.pixart.messenger.utils.GeoHelper;
import de.pixart.messenger.utils.Patterns;
import de.pixart.messenger.utils.XmppUri;
+import static java.lang.Character.isAlphabetic;
+
public class MyLinkify {
private static final Linkify.TransformFilter WEBURL_TRANSFORM_FILTER = (matcher, url) -> {
@@ -81,7 +83,7 @@ public class MyLinkify {
if (end < cs.length()) {
// Reject strings that were probably matched only because they contain a dot followed by
// by some known TLD (see also comment for WORD_BOUNDARY in Patterns.java)
- if (Character.isAlphabetic(cs.charAt(end - 1)) && Character.isAlphabetic(cs.charAt(end))) {
+ if (isAlphabetic(cs.charAt(end - 1)) && isAlphabetic(cs.charAt(end))) {
return false;
}
}
@@ -95,6 +97,23 @@ public class MyLinkify {
return uri.isJidValid();
};
+ private static boolean isAlphabetic(final int code) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
+ return Character.isAlphabetic(code);
+ }
+ switch (Character.getType(code)) {
+ case Character.UPPERCASE_LETTER:
+ case Character.LOWERCASE_LETTER:
+ case Character.TITLECASE_LETTER:
+ case Character.MODIFIER_LETTER:
+ case Character.OTHER_LETTER:
+ case Character.LETTER_NUMBER:
+ return true;
+ default:
+ return false;
+ }
+ }
+
public static void addLinks(Editable body, boolean includeGeo) {
Linkify.addLinks(body, Patterns.XMPP_PATTERN, "xmpp", XMPPURI_MATCH_FILTER, null);
Linkify.addLinks(body, Patterns.AUTOLINK_WEB_URL, "http", WEBURL_MATCH_FILTER, WEBURL_TRANSFORM_FILTER);