Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EmojiUtils: Add some documentation to public methods and clean a few things up. #151

Merged
merged 1 commit into from
Jun 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions emoji/src/main/java/com/vanniktech/emoji/EmojiUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
import java.util.regex.Pattern;

public final class EmojiUtils {
private static final Pattern SPACE_REMOVAL = Pattern.compile("[ \r\n\t]");
private static final Pattern SPACE_REMOVAL = Pattern.compile("[\\s]");

public static boolean isOnlyEmojis(final @Nullable String text) {
/** returns true when the string only contains emojis. Note that whitespace will be filtered out. */
public static boolean isOnlyEmojis(@Nullable final String text) {
if (TextUtils.isEmpty(text)) {
return false;
}
Expand All @@ -22,7 +23,8 @@ public static boolean isOnlyEmojis(final @Nullable String text) {
.matches();
}

public static int emojisCount(final @Nullable String text) {
/** returns the number of all emojis that were found in the given text */
public static int emojisCount(@Nullable final String text) {
return TextUtils.isEmpty(text) ? 0 : EmojiManager.getInstance().findAllEmojis(text).size();
}

Expand Down
8 changes: 4 additions & 4 deletions emoji/src/test/java/com/vanniktech/emoji/EmojiUtilsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
import static org.assertj.core.api.Java6Assertions.assertThat;

@Config(manifest = Config.NONE) @RunWith(RobolectricTestRunner.class) public class EmojiUtilsTest {
private static final String EMOJI_1 = "\u1234";
public static final int CODE_POINT_1 = EMOJI_1.codePointAt(0);
private static final String EMOJI_2 = "\u4321";
public static final int CODE_POINT_2 = EMOJI_2.codePointAt(0);
static final String EMOJI_1 = "\u1234";
static final int CODE_POINT_1 = EMOJI_1.codePointAt(0);
static final String EMOJI_2 = "\u4321";
static final int CODE_POINT_2 = EMOJI_2.codePointAt(0);

@Before public void setUp() {
EmojiManager.install(new EmojiProvider() {
Expand Down