diff --git a/build.gradle b/build.gradle index 87ed2ac3f..908fece82 100644 --- a/build.gradle +++ b/build.gradle @@ -73,7 +73,7 @@ android { compileSdkVersion 28 defaultConfig { - minSdkVersion 19 + minSdkVersion 18 targetSdkVersion 28 versionCode 307 versionName "2.3.9" diff --git a/src/main/java/eu/siacs/conversations/ui/util/MyLinkify.java b/src/main/java/eu/siacs/conversations/ui/util/MyLinkify.java index d350e51f9..d944f2d08 100644 --- a/src/main/java/eu/siacs/conversations/ui/util/MyLinkify.java +++ b/src/main/java/eu/siacs/conversations/ui/util/MyLinkify.java @@ -29,6 +29,7 @@ package eu.siacs.conversations.ui.util; +import android.os.Build; import android.text.Editable; import android.text.util.Linkify; @@ -80,7 +81,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; } } @@ -93,6 +94,24 @@ 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);