Switch to LinkifyCompat.

We've seen some inconsistencies across OEMs with Linkify. Hopefully
LinkifyCompat will resolve them.
This commit is contained in:
Greyson Parrelli
2021-06-26 00:27:06 -04:00
parent 5bf23dcfb3
commit fce362960f
4 changed files with 8 additions and 4 deletions

View File

@@ -10,6 +10,7 @@ import android.text.util.Linkify;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import androidx.core.text.util.LinkifyCompat;
import com.annimon.stream.Collectors;
import com.annimon.stream.Stream;
@@ -53,7 +54,7 @@ public final class LinkPreviewUtil {
*/
public static @NonNull Links findValidPreviewUrls(@NonNull String text) {
SpannableString spannable = new SpannableString(text);
boolean found = Linkify.addLinks(spannable, Linkify.WEB_URLS);
boolean found = LinkifyCompat.addLinks(spannable, Linkify.WEB_URLS);
if (!found) {
return Links.EMPTY;