mirror of
https://github.com/nextcloud/talk-android
synced 2025-07-08 13:29:49 +01:00
26 lines
637 B
Java
26 lines
637 B
Java
package com.nextcloud.talk.utils;
|
|
|
|
|
|
import java.util.regex.Matcher;
|
|
import java.util.regex.Pattern;
|
|
|
|
import androidx.annotation.Nullable;
|
|
|
|
public final class TextMatchers {
|
|
|
|
public static boolean isMessageWithSingleEmoticonOnly(@Nullable final String text) {
|
|
if (text == null || text.isEmpty()) {
|
|
return false;
|
|
}
|
|
String emojiRegex = "([\\p{So}\\p{Sk}])";
|
|
Pattern pattern = Pattern.compile(emojiRegex);
|
|
Matcher matcher = pattern.matcher(text);
|
|
|
|
int emojiCount = 0;
|
|
while (matcher.find()) {
|
|
emojiCount++;
|
|
}
|
|
return emojiCount == 1;
|
|
}
|
|
}
|