コード例 #1
0
        public static Drawable getEmojiBigDrawable(ulong code)
        {
            EmojiDrawable ed = getEmojiDrawable(code);

            if (ed == null)
            {
                return(null);
            }
            ed.SetBounds(0, 0, bigImgSize, bigImgSize);
            //ed.fullSize = true;
            return(ed);
        }
コード例 #2
0
 public EmojiSpan(EmojiDrawable d, int verticalAlignment, int s, Paint.FontMetricsInt original) :
     base(d)
 {
     fontMetrics = original;
     if (original != null)
     {
         size = System.Math.Abs(fontMetrics.Descent) + System.Math.Abs(fontMetrics.Ascent);
         if (size == 0)
         {
             size = AndroidUtilities.dp(20);
         }
     }
 }
コード例 #3
0
        public static EmojiDrawable getEmojiDrawable(ulong code)
        {
            DrawableInfo info = rects[code];

            if (info == null)
            {
                // FileLog.e("tmessages", "No emoji drawable for code " + String.format("%016X", code));
                return(null);
            }
            EmojiDrawable ed = new EmojiDrawable(info);

            ed.SetBounds(0, 0, drawImgSize, drawImgSize);
            return(ed);
        }
コード例 #4
0
        public static ICharSequence replaceEmoji(ICharSequence cs, Paint.FontMetricsInt fontMetrics, int size)
        {
            if (cs == null || cs.Length() == 0)
            {
                return(cs);
            }
            ISpannable s;

            if (cs is ISpannable)
            {
                s = (ISpannable)cs;
            }
            else
            {
                s = SpannableFactory.Instance.NewSpannable(cs);
            }
            ulong buf        = 0;
            int   emojiCount = 0;

            try
            {
                for (int i = 0; i < cs.Length(); i++)
                {
                    char c = cs.CharAt(i);
                    if (c == 0xD83C || c == 0xD83D || (buf != 0 && (buf & 0xFFFFFFFF00000000L) == 0 && (c >= 0xDDE6 && c <= 0xDDFA)))
                    {
                        buf <<= 16;
                        buf  |= c;
                    }
                    else if (buf > 0 && (c & 0xF000) == 0xD000)
                    {
                        buf <<= 16;
                        buf  |= c;
                        EmojiDrawable d = Emoji.getEmojiDrawable(buf);
                        if (d != null)
                        {
                            var span = new EmojiSpan(d, (int)SpanAlign.Bottom, size, fontMetrics);
                            emojiCount++;
                            if (c >= 0xDDE6 && c <= 0xDDFA)
                            {
                                s.SetSpan(span, i - 3, i + 1, 0);
                            }
                            else
                            {
                                s.SetSpan(span, i - 1, i + 1, 0);
                            }
                        }
                        buf = 0;
                    }
                    else if (c == 0x20E3)
                    {
                        if (i > 0)
                        {
                            char c2 = cs.CharAt(i - 1);
                            if ((c2 >= '0' && c2 <= '9') || c2 == '#')
                            {
                                buf   = c2;
                                buf <<= 16;
                                buf  |= c;
                                EmojiDrawable d = Emoji.getEmojiDrawable(buf);
                                if (d != null)
                                {
                                    EmojiSpan span = new EmojiSpan(d, (int)SpanAlign.Bottom, size, fontMetrics);
                                    emojiCount++;
                                    s.SetSpan(span, i - 1, i + 1, 0);
                                }
                                buf = 0;
                            }
                        }
                    }
                    else if (inArray(c, emojiChars) == Java.Lang.Boolean.True)
                    {
                        EmojiDrawable d = Emoji.getEmojiDrawable(c);
                        if (d != null)
                        {
                            EmojiSpan span = new EmojiSpan(d, (int)SpanAlign.Bottom, size, fontMetrics);
                            emojiCount++;
                            s.SetSpan(span, i, i + 1, 0);
                        }
                    }
                    if (emojiCount >= 50)
                    {
                        break;
                    }
                }
            }
            catch (Java.Lang.Exception e)
            {
                //FileLog.e("tmessages", e);
                return(cs);
            }
            return(s);
        }