~singpolyma/cheogram-android

6d6800f2bbc512a84a73ef07b77aaa0fc8aff044 — Stephen Paul Weber 2 months ago 56d0feb
Linkyfy tel and sms URIs
M src/main/java/eu/siacs/conversations/ui/util/MyLinkify.java => src/main/java/eu/siacs/conversations/ui/util/MyLinkify.java +2 -0
@@ 127,6 127,8 @@ public class MyLinkify {

    public static void addLinks(Editable body, boolean includeGeo) {
        Linkify.addLinks(body, Patterns.XMPP_PATTERN, "xmpp", XMPPURI_MATCH_FILTER, null);
        Linkify.addLinks(body, Patterns.TEL_URI, "tel");
        Linkify.addLinks(body, Patterns.SMS_URI, "sms");
        Linkify.addLinks(body, Patterns.AUTOLINK_WEB_URL, "http", WEBURL_MATCH_FILTER, WEBURL_TRANSFORM_FILTER);
        if (includeGeo) {
            Linkify.addLinks(body, GeoHelper.GEO_URI, "geo");

M src/main/java/eu/siacs/conversations/utils/Patterns.java => src/main/java/eu/siacs/conversations/utils/Patterns.java +11 -3
@@ 337,9 337,10 @@ public class Patterns {
            + "\\,\\;\\?\\&\\=]|(?:\\%[a-fA-F0-9]{2})){1,64}(?:\\:(?:[a-zA-Z0-9\\$\\-\\_"
            + "\\.\\+\\!\\*\\'\\(\\)\\,\\;\\?\\&\\=]|(?:\\%[a-fA-F0-9]{2})){1,25})?\\@";
    private static final String PORT_NUMBER = "\\:\\d{1,5}";
    private static final String PATH_AND_QUERY = "\\/(?:(?:[" + LABEL_CHAR
            + "\\;\\/\\?\\:\\@\\&\\=\\#\\~"  // plus optional query params
            + "\\-\\.\\+\\!\\*\\'\\(\\)\\,\\_\\$])|(?:\\%[a-fA-F0-9]{2}))*";
    private static final String PATH_CHAR = "(?:(?:[" + LABEL_CHAR
            + "\\;\\/\\?\\:\\@\\&\\=\\#\\~"
            + "\\-\\.\\+\\!\\*\\'\\(\\)\\,\\_\\$])|(?:\\%[a-fA-F0-9]{2}))";
    private static final String PATH_AND_QUERY = "\\/" + PATH_CHAR + "*";
    /**
     *  Regular expression pattern to match most part of RFC 3987
     *  Internationalized URLs, aka IRIs.


@@ 464,6 465,13 @@ public class Patterns {
            "(\\+[0-9]+[\\- \\.]*)?"        // +<digits><sdd>*
                    + "(\\([0-9]+\\)[\\- \\.]*)?"   // (<digits>)<sdd>*
                    + "([0-9][0-9\\- \\.]+[0-9])"); // <digit><digit|sdd>+<digit>

    public static final Pattern TEL_URI =
        Pattern.compile("tel:(?:(?:\\+\\d+)|(?:\\d+;phone-context=" + PATH_CHAR + "+))");

    public static final Pattern SMS_URI =
        Pattern.compile("sms:(?:(?:\\+\\d+)|(?:\\d+;phone-context=" + PATH_CHAR + "+))");

    /**
     *  Convenience method to take all of the non-null matching groups in a
     *  regex Matcher and return them as a concatenated string.