Reduce 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.
This commit is contained in:
Alex Palaistras 2018-12-08 19:50:13 +00:00
parent 69ca58d0db
commit 08529041a5
2 changed files with 21 additions and 2 deletions

View file

@ -73,7 +73,7 @@ android {
compileSdkVersion 28 compileSdkVersion 28
defaultConfig { defaultConfig {
minSdkVersion 19 minSdkVersion 18
targetSdkVersion 28 targetSdkVersion 28
versionCode 307 versionCode 307
versionName "2.3.9" versionName "2.3.9"

View file

@ -29,6 +29,7 @@
package eu.siacs.conversations.ui.util; package eu.siacs.conversations.ui.util;
import android.os.Build;
import android.text.Editable; import android.text.Editable;
import android.text.util.Linkify; import android.text.util.Linkify;
@ -80,7 +81,7 @@ public class MyLinkify {
if (end < cs.length()) { if (end < cs.length()) {
// Reject strings that were probably matched only because they contain a dot followed by // 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) // 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; return false;
} }
} }
@ -93,6 +94,24 @@ public class MyLinkify {
return uri.isJidValid(); 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) { public static void addLinks(Editable body, boolean includeGeo) {
Linkify.addLinks(body, Patterns.XMPP_PATTERN, "xmpp", XMPPURI_MATCH_FILTER, null); 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); Linkify.addLinks(body, Patterns.AUTOLINK_WEB_URL, "http", WEBURL_MATCH_FILTER, WEBURL_TRANSFORM_FILTER);