org.telegram.messenger.Emoji Java Examples

The following examples show how to use org.telegram.messenger.Emoji. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EmojiView.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
private void sendEmoji(String override) {
    String code = override != null ? override : (String) getTag();
    SpannableStringBuilder builder = new SpannableStringBuilder();
    builder.append(code);
    if (override == null) {
        if (pager.getCurrentItem() != 0) {
            String color = Emoji.emojiColor.get(code);
            if (color != null) {
                code = addColorToCode(code, color);
            }
        }
        addEmojiToRecent(code);
        if (listener != null) {
            listener.onEmojiSelected(Emoji.fixEmoji(code));
        }
    } else {
        if (listener != null) {
            listener.onEmojiSelected(Emoji.fixEmoji(override));
        }
    }
}
 
Example #2
Source File: ChatActivityEnterView.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public void replaceWithText(int start, int len, CharSequence text, boolean parseEmoji)
{
    try
    {
        SpannableStringBuilder builder = new SpannableStringBuilder(messageEditText.getText());
        builder.replace(start, start + len, text);
        if (parseEmoji)
        {
            Emoji.replaceEmoji(builder, messageEditText.getPaint().getFontMetricsInt(), AndroidUtilities.dp(20), false);
        }
        messageEditText.setText(builder);
        messageEditText.setSelection(start + text.length());
    }
    catch (Exception e)
    {
        FileLog.e(e);
    }
}
 
Example #3
Source File: StickerSetNameCell.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public void setText(CharSequence text, int resId, int index, int searchLength) {
    if (text == null) {
        empty = true;
        textView.setText("");
        buttonView.setVisibility(INVISIBLE);
    } else {
        if (searchLength != 0) {
            SpannableStringBuilder builder = new SpannableStringBuilder(text);
            try {
                builder.setSpan(new ForegroundColorSpan(Theme.getColor(Theme.key_windowBackgroundWhiteBlueText4)), index, index + searchLength, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
            } catch (Exception ignore) {

            }
            textView.setText(builder);
        } else {
            textView.setText(Emoji.replaceEmoji(text, textView.getPaint().getFontMetricsInt(), AndroidUtilities.dp(14), false));
        }
        if (resId != 0) {
            buttonView.setImageResource(resId);
            buttonView.setVisibility(VISIBLE);
        } else {
            buttonView.setVisibility(INVISIBLE);
        }
    }
}
 
Example #4
Source File: PhotoViewerCaptionEnterView.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
public void replaceWithText(int start, int len, CharSequence text, boolean parseEmoji) {
    try {
        SpannableStringBuilder builder = new SpannableStringBuilder(messageEditText.getText());
        builder.replace(start, start + len, text);
        if (parseEmoji) {
            Emoji.replaceEmoji(builder, messageEditText.getPaint().getFontMetricsInt(), AndroidUtilities.dp(20), false);
        }
        messageEditText.setText(builder);
        if (start + text.length() <= messageEditText.length()) {
            messageEditText.setSelection(start + text.length());
        } else {
            messageEditText.setSelection(messageEditText.length());
        }
    } catch (Exception e) {
        FileLog.e(e);
    }
}
 
Example #5
Source File: EmojiView.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void setVisibility(int visibility) {
    super.setVisibility(visibility);
    if (visibility != GONE) {
        Emoji.sortEmoji();
        adapters.get(0).notifyDataSetChanged();
        if (stickersGridAdapter != null) {
            NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.stickersDidLoaded);
            NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.recentDocumentsDidLoaded);
            updateStickerTabs();
            reloadStickersAdapter();
            if (gifsGridView != null && gifsGridView.getVisibility() == VISIBLE && listener != null) {
                listener.onGifTab(pager != null && pager.getCurrentItem() >= 6);
            }
        }
        if (trendingGridAdapter != null) {
            trendingLoaded = false;
            trendingGridAdapter.notifyDataSetChanged();
        }
        checkDocuments(true);
        checkDocuments(false);
        DataQuery.getInstance(currentAccount).loadRecents(DataQuery.TYPE_IMAGE, true, true, false);
        DataQuery.getInstance(currentAccount).loadRecents(DataQuery.TYPE_IMAGE, false, true, false);
        DataQuery.getInstance(currentAccount).loadRecents(DataQuery.TYPE_FAVE, false, true, false);
    }
}
 
Example #6
Source File: MentionCell.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public void setBotCommand(String command, String help, TLRPC.User user) {
    if (user != null) {
        imageView.setVisibility(VISIBLE);
        avatarDrawable.setInfo(user);
        if (user.photo != null && user.photo.photo_small != null) {
            imageView.setImage(user.photo.photo_small, "50_50", avatarDrawable);
        } else {
            imageView.setImageDrawable(avatarDrawable);
        }
    } else {
        imageView.setVisibility(INVISIBLE);
    }
    usernameTextView.setVisibility(VISIBLE);
    nameTextView.setText(command);
    usernameTextView.setText(Emoji.replaceEmoji(help, usernameTextView.getPaint().getFontMetricsInt(), AndroidUtilities.dp(20), false));
}
 
Example #7
Source File: StickerEmojiCell.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
    super.onInitializeAccessibilityNodeInfo(info);
    String descr = LocaleController.getString("AttachSticker", R.string.AttachSticker);
    for (int a = 0; a < sticker.attributes.size(); a++) {
        TLRPC.DocumentAttribute attribute = sticker.attributes.get(a);
        if (attribute instanceof TLRPC.TL_documentAttributeSticker) {
            if (attribute.alt != null && attribute.alt.length() > 0) {
                emojiTextView.setText(Emoji.replaceEmoji(attribute.alt, emojiTextView.getPaint().getFontMetricsInt(), AndroidUtilities.dp(16), false));
                descr = attribute.alt + " " + descr;
            }
            break;
        }
    }
    info.setContentDescription(descr);
    info.setEnabled(true);
}
 
Example #8
Source File: MentionCell.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
public void setBotCommand(String command, String help, TLRPC.User user) {
    if (user != null) {
        imageView.setVisibility(VISIBLE);
        avatarDrawable.setInfo(user);
        if (user.photo != null && user.photo.photo_small != null) {
            imageView.setImage(ImageLocation.getForUser(user, false), "50_50", avatarDrawable, user);
        } else {
            imageView.setImageDrawable(avatarDrawable);
        }
    } else {
        imageView.setVisibility(INVISIBLE);
    }
    usernameTextView.setVisibility(VISIBLE);
    nameTextView.setText(command);
    usernameTextView.setText(Emoji.replaceEmoji(help, usernameTextView.getPaint().getFontMetricsInt(), AndroidUtilities.dp(20), false));
}
 
Example #9
Source File: EmojiView.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
private void sendEmoji(String override) {
    String code = override != null ? override : (String) getTag();
    SpannableStringBuilder builder = new SpannableStringBuilder();
    builder.append(code);
    if (override == null) {
        if (pager.getCurrentItem() != 0) {
            String color = Emoji.emojiColor.get(code);
            if (color != null) {
                code = addColorToCode(code, color);
            }
        }
        addEmojiToRecent(code);
        if (listener != null) {
            listener.onEmojiSelected(Emoji.fixEmoji(code));
        }
    } else {
        if (listener != null) {
            listener.onEmojiSelected(Emoji.fixEmoji(override));
        }
    }
}
 
Example #10
Source File: PhotoViewerCaptionEnterView.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public void replaceWithText(int start, int len, CharSequence text, boolean parseEmoji) {
    try {
        SpannableStringBuilder builder = new SpannableStringBuilder(messageEditText.getText());
        builder.replace(start, start + len, text);
        if (parseEmoji) {
            Emoji.replaceEmoji(builder, messageEditText.getPaint().getFontMetricsInt(), AndroidUtilities.dp(20), false);
        }
        messageEditText.setText(builder);
        if (start + text.length() <= messageEditText.length()) {
            messageEditText.setSelection(start + text.length());
        } else {
            messageEditText.setSelection(messageEditText.length());
        }
    } catch (Exception e) {
        FileLog.e(e);
    }
}
 
Example #11
Source File: VoIPActivity.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
private void updateKeyView() {
     if(VoIPService.getSharedInstance()==null)
         return;
     IdenticonDrawable img = new IdenticonDrawable();
     img.setColors(new int[]{0x00FFFFFF, 0xFFFFFFFF, 0x99FFFFFF, 0x33FFFFFF});
     TLRPC.EncryptedChat encryptedChat = new TLRPC.TL_encryptedChat();
     try {
         ByteArrayOutputStream buf = new ByteArrayOutputStream();
         buf.write(VoIPService.getSharedInstance().getEncryptionKey());
buf.write(VoIPService.getSharedInstance().getGA());
         encryptedChat.auth_key = buf.toByteArray();
     }catch(Exception checkedExceptionsAreBad){}
     byte[] sha256 = Utilities.computeSHA256(encryptedChat.auth_key, 0, encryptedChat.auth_key.length);
     String[] emoji=EncryptionKeyEmojifier.emojifyForCall(sha256);
     //keyEmojiText.setText(Emoji.replaceEmoji(TextUtils.join(" ", emoji), keyEmojiText.getPaint().getFontMetricsInt(), AndroidUtilities.dp(32), false));
     for(int i=0;i<4;i++) {
         Drawable drawable = Emoji.getEmojiDrawable(emoji[i]);
         if (drawable != null) {
             drawable.setBounds(0, 0, AndroidUtilities.dp(22), AndroidUtilities.dp(22));
             keyEmojiViews[i].setImageDrawable(drawable);
         }
     }
 }
 
Example #12
Source File: StickerSetNameCell.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public void setText(CharSequence text, int resId, int index, int searchLength) {
    if (text == null) {
        empty = true;
        textView.setText("");
        buttonView.setVisibility(INVISIBLE);
    } else {
        if (searchLength != 0) {
            SpannableStringBuilder builder = new SpannableStringBuilder(text);
            try {
                builder.setSpan(new ForegroundColorSpan(Theme.getColor(Theme.key_windowBackgroundWhiteBlueText4)), index, index + searchLength, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
            } catch (Exception ignore) {

            }
            textView.setText(builder);
        } else {
            textView.setText(Emoji.replaceEmoji(text, textView.getPaint().getFontMetricsInt(), AndroidUtilities.dp(14), false));
        }
        if (resId != 0) {
            buttonView.setImageResource(resId);
            buttonView.setVisibility(VISIBLE);
        } else {
            buttonView.setVisibility(INVISIBLE);
        }
    }
}
 
Example #13
Source File: AboutLinkCell.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public void setTextAndIcon(String text, int resId, boolean parseLinks) {
    if (TextUtils.isEmpty(text) || text != null && oldText != null && text.equals(oldText)) {
        return;
    }
    oldText = text;
    stringBuilder = new SpannableStringBuilder(oldText);
    if (parseLinks) {
        MessageObject.addLinks(false, stringBuilder, false);
    }
    Emoji.replaceEmoji(stringBuilder, Theme.profile_aboutTextPaint.getFontMetricsInt(), AndroidUtilities.dp(20), false);
    requestLayout();
    if (resId == 0) {
        imageView.setImageDrawable(null);
    } else {
        imageView.setImageResource(resId);
    }
}
 
Example #14
Source File: MentionCell.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public void setBotCommand(String command, String help, TLRPC.User user) {
    if (user != null) {
        imageView.setVisibility(VISIBLE);
        avatarDrawable.setInfo(user);
        if (user.photo != null && user.photo.photo_small != null) {
            imageView.setImage(user.photo.photo_small, "50_50", avatarDrawable);
        } else {
            imageView.setImageDrawable(avatarDrawable);
        }
    } else {
        imageView.setVisibility(INVISIBLE);
    }
    usernameTextView.setVisibility(VISIBLE);
    nameTextView.setText(command);
    usernameTextView.setText(Emoji.replaceEmoji(help, usernameTextView.getPaint().getFontMetricsInt(), AndroidUtilities.dp(20), false));
}
 
Example #15
Source File: AboutLinkCell.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
public void setTextAndValue(String text, String value, boolean parseLinks) {
    if (TextUtils.isEmpty(text) || text != null && text.equals(oldText)) {
        return;
    }
    oldText = text;
    stringBuilder = new SpannableStringBuilder(oldText);
    if (parseLinks) {
        MessageObject.addLinks(false, stringBuilder, false, false);
    }
    Emoji.replaceEmoji(stringBuilder, Theme.profile_aboutTextPaint.getFontMetricsInt(), AndroidUtilities.dp(20), false);
    if (TextUtils.isEmpty(value)) {
        valueTextView.setVisibility(GONE);
    } else {
        valueTextView.setText(value);
        valueTextView.setVisibility(VISIBLE);
    }
    requestLayout();
}
 
Example #16
Source File: VoIPActivity.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
private void updateKeyView() {
     if(VoIPService.getSharedInstance()==null)
         return;
     IdenticonDrawable img = new IdenticonDrawable();
     img.setColors(new int[]{0x00FFFFFF, 0xFFFFFFFF, 0x99FFFFFF, 0x33FFFFFF});
     TLRPC.EncryptedChat encryptedChat = new TLRPC.TL_encryptedChat();
     try {
         ByteArrayOutputStream buf = new ByteArrayOutputStream();
         buf.write(VoIPService.getSharedInstance().getEncryptionKey());
buf.write(VoIPService.getSharedInstance().getGA());
         encryptedChat.auth_key = buf.toByteArray();
     }catch(Exception checkedExceptionsAreBad){}
     byte[] sha256 = Utilities.computeSHA256(encryptedChat.auth_key, 0, encryptedChat.auth_key.length);
     String[] emoji=EncryptionKeyEmojifier.emojifyForCall(sha256);
     //keyEmojiText.setText(Emoji.replaceEmoji(TextUtils.join(" ", emoji), keyEmojiText.getPaint().getFontMetricsInt(), AndroidUtilities.dp(32), false));
     for(int i=0;i<4;i++) {
         Drawable drawable = Emoji.getEmojiDrawable(emoji[i]);
         if (drawable != null) {
             drawable.setBounds(0, 0, AndroidUtilities.dp(22), AndroidUtilities.dp(22));
             keyEmojiViews[i].setImageDrawable(drawable);
         }
     }
 }
 
Example #17
Source File: StickerSetNameCell.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
public void setText(CharSequence text, int resId, int index, int searchLength) {
    stickerSetName = text;
    stickerSetNameSearchIndex = index;
    stickerSetNameSearchLength = searchLength;
    if (text == null) {
        empty = true;
        textView.setText("");
        buttonView.setVisibility(INVISIBLE);
    } else {
        if (searchLength != 0) {
            updateTextSearchSpan();
        } else {
            textView.setText(Emoji.replaceEmoji(text, textView.getPaint().getFontMetricsInt(), AndroidUtilities.dp(14), false));
        }
        if (resId != 0) {
            buttonView.setImageResource(resId);
            buttonView.setVisibility(VISIBLE);
        } else {
            buttonView.setVisibility(INVISIBLE);
        }
    }
}
 
Example #18
Source File: EmojiView.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void setVisibility(int visibility) {
    super.setVisibility(visibility);
    if (visibility != GONE) {
        Emoji.sortEmoji();
        adapters.get(0).notifyDataSetChanged();
        if (stickersGridAdapter != null) {
            NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.stickersDidLoaded);
            NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.recentDocumentsDidLoaded);
            updateStickerTabs();
            reloadStickersAdapter();
            if (gifsGridView != null && gifsGridView.getVisibility() == VISIBLE && listener != null) {
                listener.onGifTab(pager != null && pager.getCurrentItem() >= 6);
            }
        }
        if (trendingGridAdapter != null) {
            trendingLoaded = false;
            trendingGridAdapter.notifyDataSetChanged();
        }
        checkDocuments(true);
        checkDocuments(false);
        DataQuery.getInstance(currentAccount).loadRecents(DataQuery.TYPE_IMAGE, true, true, false);
        DataQuery.getInstance(currentAccount).loadRecents(DataQuery.TYPE_IMAGE, false, true, false);
        DataQuery.getInstance(currentAccount).loadRecents(DataQuery.TYPE_FAVE, false, true, false);
    }
}
 
Example #19
Source File: EmojiView.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
public View getView(int position, View view, ViewGroup paramViewGroup) {
    ImageViewEmoji imageView = (ImageViewEmoji) view;
    if (imageView == null) {
        imageView = new ImageViewEmoji(getContext());
    }
    String code;
    String coloredCode;
    if (emojiPage == -1) {
        coloredCode = code = Emoji.recentEmoji.get(position);
    } else {
        coloredCode = code = EmojiData.dataColored[emojiPage][position];
        String color = Emoji.emojiColor.get(code);
        if (color != null) {
            coloredCode = addColorToCode(coloredCode, color);
        }
    }
    imageView.setImageDrawable(Emoji.getEmojiBigDrawable(coloredCode));
    imageView.setTag(code);
    return imageView;
}
 
Example #20
Source File: ChatActivityEnterView.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public void replaceWithText(int start, int len, CharSequence text, boolean parseEmoji)
{
    try
    {
        SpannableStringBuilder builder = new SpannableStringBuilder(messageEditText.getText());
        builder.replace(start, start + len, text);
        if (parseEmoji)
        {
            Emoji.replaceEmoji(builder, messageEditText.getPaint().getFontMetricsInt(), AndroidUtilities.dp(20), false);
        }
        messageEditText.setText(builder);
        messageEditText.setSelection(start + text.length());
    }
    catch (Exception e)
    {
        FileLog.e(e);
    }
}
 
Example #21
Source File: PhotoViewerCaptionEnterView.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public void replaceWithText(int start, int len, CharSequence text, boolean parseEmoji) {
    try {
        SpannableStringBuilder builder = new SpannableStringBuilder(messageEditText.getText());
        builder.replace(start, start + len, text);
        if (parseEmoji) {
            Emoji.replaceEmoji(builder, messageEditText.getPaint().getFontMetricsInt(), AndroidUtilities.dp(20), false);
        }
        messageEditText.setText(builder);
        if (start + text.length() <= messageEditText.length()) {
            messageEditText.setSelection(start + text.length());
        } else {
            messageEditText.setSelection(messageEditText.length());
        }
    } catch (Exception e) {
        FileLog.e(e);
    }
}
 
Example #22
Source File: VoIPActivity.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
private void updateKeyView() {
    if (VoIPService.getSharedInstance() == null)
        return;
    IdenticonDrawable img = new IdenticonDrawable();
    img.setColors(new int[]{0x00FFFFFF, 0xFFFFFFFF, 0x99FFFFFF, 0x33FFFFFF});
    TLRPC.EncryptedChat encryptedChat = new TLRPC.TL_encryptedChat();
    try {
        ByteArrayOutputStream buf = new ByteArrayOutputStream();
        buf.write(VoIPService.getSharedInstance().getEncryptionKey());
        buf.write(VoIPService.getSharedInstance().getGA());
        encryptedChat.auth_key = buf.toByteArray();
    } catch (Exception checkedExceptionsAreBad) {
    }
    byte[] sha256 = Utilities.computeSHA256(encryptedChat.auth_key, 0, encryptedChat.auth_key.length);
    String[] emoji = EncryptionKeyEmojifier.emojifyForCall(sha256);
    //keyEmojiText.setText(Emoji.replaceEmoji(TextUtils.join(" ", emoji), keyEmojiText.getPaint().getFontMetricsInt(), AndroidUtilities.dp(32), false));
    emojiWrap.setContentDescription(LocaleController.getString("EncryptionKey", R.string.EncryptionKey) + ", " + TextUtils.join(", ", emoji));
    for (int i = 0; i < 4; i++) {
        Drawable drawable = Emoji.getEmojiDrawable(emoji[i]);
        if (drawable != null) {
            drawable.setBounds(0, 0, AndroidUtilities.dp(22), AndroidUtilities.dp(22));
            keyEmojiViews[i].setImageDrawable(drawable);
        }
    }
}
 
Example #23
Source File: EmojiReplacementCell.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
public void setEmoji(String e, int side) {
    emoji = e;
    imageView.setImageDrawable(Emoji.getEmojiBigDrawable(e));
    if (side == -1) {
        setBackgroundResource(R.drawable.stickers_back_left);
        setPadding(AndroidUtilities.dp(7), 0, 0, 0);
    } else if (side == 0) {
        setBackgroundResource(R.drawable.stickers_back_center);
        setPadding(0, 0, 0, 0);
    } else if (side == 1) {
        setBackgroundResource(R.drawable.stickers_back_right);
        setPadding(0, 0, AndroidUtilities.dp(7), 0);
    } else if (side == 2) {
        setBackgroundResource(R.drawable.stickers_back_all);
        setPadding(AndroidUtilities.dp(3), 0, AndroidUtilities.dp(3), 0);
    }
    Drawable background = getBackground();
    if (background != null) {
        background.setAlpha(230);
        background.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chat_stickersHintPanel), PorterDuff.Mode.MULTIPLY));
    }
}
 
Example #24
Source File: EmojiReplacementCell.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
public void setEmoji(String e, int side) {
    emoji = e;
    imageView.setImageDrawable(Emoji.getEmojiBigDrawable(e));
    if (side == -1) {
        setBackgroundResource(R.drawable.stickers_back_left);
        setPadding(AndroidUtilities.dp(7), 0, 0, 0);
    } else if (side == 0) {
        setBackgroundResource(R.drawable.stickers_back_center);
        setPadding(0, 0, 0, 0);
    } else if (side == 1) {
        setBackgroundResource(R.drawable.stickers_back_right);
        setPadding(0, 0, AndroidUtilities.dp(7), 0);
    } else if (side == 2) {
        setBackgroundResource(R.drawable.stickers_back_all);
        setPadding(AndroidUtilities.dp(3), 0, AndroidUtilities.dp(3), 0);
    }
    Drawable background = getBackground();
    if (background != null) {
        background.setAlpha(230);
        background.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chat_stickersHintPanel), PorterDuff.Mode.MULTIPLY));
    }
}
 
Example #25
Source File: StickerSetNameCell.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
public void setText(CharSequence text, int resId, int index, int searchLength) {
    stickerSetName = text;
    stickerSetNameSearchIndex = index;
    stickerSetNameSearchLength = searchLength;
    if (text == null) {
        empty = true;
        textView.setText("");
        buttonView.setVisibility(INVISIBLE);
    } else {
        if (searchLength != 0) {
            updateTextSearchSpan();
        } else {
            textView.setText(Emoji.replaceEmoji(text, textView.getPaint().getFontMetricsInt(), AndroidUtilities.dp(14), false));
        }
        if (resId != 0) {
            buttonView.setImageResource(resId);
            buttonView.setVisibility(VISIBLE);
        } else {
            buttonView.setVisibility(INVISIBLE);
        }
    }
}
 
Example #26
Source File: VoIPActivity.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
private void updateKeyView() {
    if (VoIPService.getSharedInstance() == null)
        return;
    IdenticonDrawable img = new IdenticonDrawable();
    img.setColors(new int[]{0x00FFFFFF, 0xFFFFFFFF, 0x99FFFFFF, 0x33FFFFFF});
    TLRPC.EncryptedChat encryptedChat = new TLRPC.TL_encryptedChat();
    try {
        ByteArrayOutputStream buf = new ByteArrayOutputStream();
        buf.write(VoIPService.getSharedInstance().getEncryptionKey());
        buf.write(VoIPService.getSharedInstance().getGA());
        encryptedChat.auth_key = buf.toByteArray();
    } catch (Exception checkedExceptionsAreBad) {
    }
    byte[] sha256 = Utilities.computeSHA256(encryptedChat.auth_key, 0, encryptedChat.auth_key.length);
    String[] emoji = EncryptionKeyEmojifier.emojifyForCall(sha256);
    //keyEmojiText.setText(Emoji.replaceEmoji(TextUtils.join(" ", emoji), keyEmojiText.getPaint().getFontMetricsInt(), AndroidUtilities.dp(32), false));
    emojiWrap.setContentDescription(LocaleController.getString("EncryptionKey", R.string.EncryptionKey) + ", " + TextUtils.join(", ", emoji));
    for (int i = 0; i < 4; i++) {
        Drawable drawable = Emoji.getEmojiDrawable(emoji[i]);
        if (drawable != null) {
            drawable.setBounds(0, 0, AndroidUtilities.dp(22), AndroidUtilities.dp(22));
            keyEmojiViews[i].setImageDrawable(drawable);
        }
    }
}
 
Example #27
Source File: AboutLinkCell.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
public void setTextAndValue(String text, String value, boolean parseLinks) {
    if (TextUtils.isEmpty(text) || text != null && text.equals(oldText)) {
        return;
    }
    oldText = text;
    stringBuilder = new SpannableStringBuilder(oldText);
    if (parseLinks) {
        MessageObject.addLinks(false, stringBuilder, false, false);
    }
    Emoji.replaceEmoji(stringBuilder, Theme.profile_aboutTextPaint.getFontMetricsInt(), AndroidUtilities.dp(20), false);
    if (TextUtils.isEmpty(value)) {
        valueTextView.setVisibility(GONE);
    } else {
        valueTextView.setText(value);
        valueTextView.setVisibility(VISIBLE);
    }
    requestLayout();
}
 
Example #28
Source File: PhotoViewerCaptionEnterView.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
public void replaceWithText(int start, int len, CharSequence text, boolean parseEmoji) {
    try {
        SpannableStringBuilder builder = new SpannableStringBuilder(messageEditText.getText());
        builder.replace(start, start + len, text);
        if (parseEmoji) {
            Emoji.replaceEmoji(builder, messageEditText.getPaint().getFontMetricsInt(), AndroidUtilities.dp(20), false);
        }
        messageEditText.setText(builder);
        if (start + text.length() <= messageEditText.length()) {
            messageEditText.setSelection(start + text.length());
        } else {
            messageEditText.setSelection(messageEditText.length());
        }
    } catch (Exception e) {
        FileLog.e(e);
    }
}
 
Example #29
Source File: StickerEmojiCell.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
    super.onInitializeAccessibilityNodeInfo(info);
    String descr = LocaleController.getString("AttachSticker", R.string.AttachSticker);
    for (int a = 0; a < sticker.attributes.size(); a++) {
        TLRPC.DocumentAttribute attribute = sticker.attributes.get(a);
        if (attribute instanceof TLRPC.TL_documentAttributeSticker) {
            if (attribute.alt != null && attribute.alt.length() > 0) {
                emojiTextView.setText(Emoji.replaceEmoji(attribute.alt, emojiTextView.getPaint().getFontMetricsInt(), AndroidUtilities.dp(16), false));
                descr = attribute.alt + " " + descr;
            }
            break;
        }
    }
    info.setContentDescription(descr);
    info.setEnabled(true);
}
 
Example #30
Source File: MentionCell.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
public void setBotCommand(String command, String help, TLRPC.User user) {
    if (user != null) {
        imageView.setVisibility(VISIBLE);
        avatarDrawable.setInfo(user);
        if (user.photo != null && user.photo.photo_small != null) {
            imageView.setImage(ImageLocation.getForUser(user, false), "50_50", avatarDrawable, user);
        } else {
            imageView.setImageDrawable(avatarDrawable);
        }
    } else {
        imageView.setVisibility(INVISIBLE);
    }
    usernameTextView.setVisibility(VISIBLE);
    nameTextView.setText(command);
    usernameTextView.setText(Emoji.replaceEmoji(help, usernameTextView.getPaint().getFontMetricsInt(), AndroidUtilities.dp(20), false));
}