TextMatchers.java 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. * Nextcloud Talk application
  3. *
  4. * @author Mario Danic
  5. * @author Tim Krüger
  6. * @author Andy Scherzinger
  7. * Copyright (C) 2022 Andy Scherzinger <info@andy-scherzinger.de>
  8. * Copyright (C) 2021 Tim Krüger <t@timkrueger.me>
  9. * Copyright (C) 2017-2018 Mario Danic <mario@lovelyhq.com>
  10. *
  11. * This program is free software: you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation, either version 3 of the License, or
  14. * at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  23. *
  24. * Partly based on https://github.com/kevalpatel2106/EmoticonGIFKeyboard/blob/master/emoticongifkeyboard/src/main/java/com/kevalpatel2106/emoticongifkeyboard/internal/emoticon/EmoticonUtils.java
  25. */
  26. package com.nextcloud.talk.utils;
  27. import com.vanniktech.emoji.EmojiInformation;
  28. import com.vanniktech.emoji.Emojis;
  29. import androidx.annotation.Nullable;
  30. public final class TextMatchers {
  31. public static boolean isMessageWithSingleEmoticonOnly(@Nullable final String text) {
  32. final EmojiInformation emojiInformation = Emojis.emojiInformation(text);
  33. return (emojiInformation.isOnlyEmojis && emojiInformation.emojis.size() == 1);
  34. }
  35. }