Java Code Examples for org.telegram.tgnet.TLRPC#TL_documentAttributeSticker
The following examples show how to use
org.telegram.tgnet.TLRPC#TL_documentAttributeSticker .
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: StickerEmojiCell.java From Telegram with GNU General Public License v2.0 | 6 votes |
@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 2
Source File: StickerCell.java From Telegram with GNU General Public License v2.0 | 6 votes |
@Override public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info){ super.onInitializeAccessibilityNodeInfo(info); if (sticker == null) return; String emoji = null; for (int a = 0; a < sticker.attributes.size(); a++) { TLRPC.DocumentAttribute attribute = sticker.attributes.get(a); if (attribute instanceof TLRPC.TL_documentAttributeSticker) { emoji = attribute.alt != null && attribute.alt.length() > 0 ? attribute.alt : null; } } if (emoji != null) info.setText(emoji + " " + LocaleController.getString("AttachSticker", R.string.AttachSticker)); else info.setText(LocaleController.getString("AttachSticker", R.string.AttachSticker)); info.setEnabled(true); }
Example 3
Source File: StickersAdapter.java From Telegram with GNU General Public License v2.0 | 6 votes |
private void addStickersToResult(ArrayList<TLRPC.Document> documents, Object parent) { if (documents == null || documents.isEmpty()) { return; } for (int a = 0, size = documents.size(); a < size; a++) { TLRPC.Document document = documents.get(a); String key = document.dc_id + "_" + document.id; if (stickersMap != null && stickersMap.containsKey(key)) { continue; } if (stickers == null) { stickers = new ArrayList<>(); stickersMap = new HashMap<>(); } for (int b = 0, size2 = document.attributes.size(); b < size2; b++) { TLRPC.DocumentAttribute attribute = document.attributes.get(b); if (attribute instanceof TLRPC.TL_documentAttributeSticker) { parent = attribute.stickerset; break; } } stickers.add(new StickerResult(document, parent)); stickersMap.put(key, document); } }
Example 4
Source File: StickersAdapter.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
private void addStickersToResult(ArrayList<TLRPC.Document> documents, Object parent) { if (documents == null || documents.isEmpty()) { return; } for (int a = 0, size = documents.size(); a < size; a++) { TLRPC.Document document = documents.get(a); String key = document.dc_id + "_" + document.id; if (stickersMap != null && stickersMap.containsKey(key)) { continue; } if (stickers == null) { stickers = new ArrayList<>(); stickersMap = new HashMap<>(); } for (int b = 0, size2 = document.attributes.size(); b < size2; b++) { TLRPC.DocumentAttribute attribute = document.attributes.get(b); if (attribute instanceof TLRPC.TL_documentAttributeSticker) { parent = attribute.stickerset; break; } } stickers.add(new StickerResult(document, parent)); stickersMap.put(key, document); } }
Example 5
Source File: StickerCell.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
@Override public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info){ super.onInitializeAccessibilityNodeInfo(info); if (sticker == null) return; String emoji = null; for (int a = 0; a < sticker.attributes.size(); a++) { TLRPC.DocumentAttribute attribute = sticker.attributes.get(a); if (attribute instanceof TLRPC.TL_documentAttributeSticker) { emoji = attribute.alt != null && attribute.alt.length() > 0 ? attribute.alt : null; } } if (emoji != null) info.setText(emoji + " " + LocaleController.getString("AttachSticker", R.string.AttachSticker)); else info.setText(LocaleController.getString("AttachSticker", R.string.AttachSticker)); info.setEnabled(true); }
Example 6
Source File: PhotoPaintView.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
private StickerPosition calculateStickerPosition(TLRPC.Document document) { TLRPC.TL_maskCoords maskCoords = null; for (int a = 0; a < document.attributes.size(); a++) { TLRPC.DocumentAttribute attribute = document.attributes.get(a); if (attribute instanceof TLRPC.TL_documentAttributeSticker) { maskCoords = attribute.mask_coords; break; } } StickerPosition defaultPosition = new StickerPosition(centerPositionForEntity(), 0.75f, 0.0f); /* if (maskCoords == null || faces == null || faces.size() == 0) { return defaultPosition; } else { int anchor = maskCoords.n; PhotoFace face = getRandomFaceWithVacantAnchor(anchor, document.id, maskCoords); if (face == null) {*/ return defaultPosition; }
Example 7
Source File: StickerEmojiCell.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
@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: StickerEmojiCell.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
public void setSticker(TLRPC.Document document, boolean showEmoji) { if (document != null) { sticker = document; if (document.thumb != null) { imageView.setImage(document.thumb.location, null, "webp", null); } if (showEmoji) { boolean set = false; for (int a = 0; a < document.attributes.size(); a++) { TLRPC.DocumentAttribute attribute = document.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)); set = true; } break; } } if (!set) { emojiTextView.setText(Emoji.replaceEmoji(DataQuery.getInstance(currentAccount).getEmojiForSticker(sticker.id), emojiTextView.getPaint().getFontMetricsInt(), AndroidUtilities.dp(16), false)); } emojiTextView.setVisibility(VISIBLE); } else { emojiTextView.setVisibility(INVISIBLE); } } }
Example 9
Source File: StickerView.java From Telegram with GNU General Public License v2.0 | 5 votes |
public StickerView(Context context, Point position, float angle, float scale, Size baseSize, TLRPC.Document sticker, Object parentObject) { super(context, position); setRotation(angle); setScale(scale); this.sticker = sticker; this.baseSize = baseSize; this.parentObject = parentObject; for (int a = 0; a < sticker.attributes.size(); a++) { TLRPC.DocumentAttribute attribute = sticker.attributes.get(a); if (attribute instanceof TLRPC.TL_documentAttributeSticker) { if (attribute.mask_coords != null) { anchor = attribute.mask_coords.n; } break; } } containerView = new FrameLayoutDrawer(context); addView(containerView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT)); centerImage.setAspectFit(true); centerImage.setInvalidateAll(true); centerImage.setParentView(containerView); TLRPC.PhotoSize thumb = FileLoader.getClosestPhotoSizeWithSize(sticker.thumbs, 90); centerImage.setImage(ImageLocation.getForDocument(sticker), null, ImageLocation.getForDocument(thumb, sticker), null, "webp", parentObject, 1); updatePosition(); }
Example 10
Source File: StickersAdapter.java From Telegram with GNU General Public License v2.0 | 5 votes |
private boolean isValidSticker(TLRPC.Document document, String emoji) { for (int b = 0, size2 = document.attributes.size(); b < size2; b++) { TLRPC.DocumentAttribute attribute = document.attributes.get(b); if (attribute instanceof TLRPC.TL_documentAttributeSticker) { if (attribute.alt != null && attribute.alt.contains(emoji)) { return true; } break; } } return false; }
Example 11
Source File: StickerView.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
public StickerView(Context context, Point position, float angle, float scale, Size baseSize, TLRPC.Document sticker, Object parentObject) { super(context, position); setRotation(angle); setScale(scale); this.sticker = sticker; this.baseSize = baseSize; this.parentObject = parentObject; for (int a = 0; a < sticker.attributes.size(); a++) { TLRPC.DocumentAttribute attribute = sticker.attributes.get(a); if (attribute instanceof TLRPC.TL_documentAttributeSticker) { if (attribute.mask_coords != null) { anchor = attribute.mask_coords.n; } break; } } containerView = new FrameLayoutDrawer(context); addView(containerView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT)); centerImage.setAspectFit(true); centerImage.setInvalidateAll(true); centerImage.setParentView(containerView); TLRPC.PhotoSize thumb = FileLoader.getClosestPhotoSizeWithSize(sticker.thumbs, 90); centerImage.setImage(ImageLocation.getForDocument(sticker), null, ImageLocation.getForDocument(thumb, sticker), null, "webp", parentObject, 1); updatePosition(); }
Example 12
Source File: StickersAdapter.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
private boolean isValidSticker(TLRPC.Document document, String emoji) { for (int b = 0, size2 = document.attributes.size(); b < size2; b++) { TLRPC.DocumentAttribute attribute = document.attributes.get(b); if (attribute instanceof TLRPC.TL_documentAttributeSticker) { if (attribute.alt != null && attribute.alt.contains(emoji)) { return true; } break; } } return false; }
Example 13
Source File: StickerView.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
public StickerView(Context context, Point position, float angle, float scale, Size baseSize, TLRPC.Document sticker) { super(context, position); setRotation(angle); setScale(scale); this.sticker = sticker; this.baseSize = baseSize; for (int a = 0; a < sticker.attributes.size(); a++) { TLRPC.DocumentAttribute attribute = sticker.attributes.get(a); if (attribute instanceof TLRPC.TL_documentAttributeSticker) { if (attribute.mask_coords != null) anchor = attribute.mask_coords.n; break; } } containerView = new FrameLayoutDrawer(context); addView(containerView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT)); centerImage.setAspectFit(true); centerImage.setInvalidateAll(true); centerImage.setParentView(containerView); centerImage.setImage(sticker, null, sticker.thumb.location, null, "webp", 1); updatePosition(); }
Example 14
Source File: StickerEmojiCell.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
public void setSticker(TLRPC.Document document, boolean showEmoji) { if (document != null) { sticker = document; if (document.thumb != null) { imageView.setImage(document.thumb.location, null, "webp", null); } if (showEmoji) { boolean set = false; for (int a = 0; a < document.attributes.size(); a++) { TLRPC.DocumentAttribute attribute = document.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)); set = true; } break; } } if (!set) { emojiTextView.setText(Emoji.replaceEmoji(DataQuery.getInstance(currentAccount).getEmojiForSticker(sticker.id), emojiTextView.getPaint().getFontMetricsInt(), AndroidUtilities.dp(16), false)); } emojiTextView.setVisibility(VISIBLE); } else { emojiTextView.setVisibility(INVISIBLE); } } }
Example 15
Source File: StickersAdapter.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private boolean isValidSticker(TLRPC.Document document, String emoji) { for (int b = 0, size2 = document.attributes.size(); b < size2; b++) { TLRPC.DocumentAttribute attribute = document.attributes.get(b); if (attribute instanceof TLRPC.TL_documentAttributeSticker) { if (attribute.alt != null && attribute.alt.contains(emoji)) { return true; } break; } } return false; }
Example 16
Source File: StickerView.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
public StickerView(Context context, Point position, float angle, float scale, Size baseSize, TLRPC.Document sticker) { super(context, position); setRotation(angle); setScale(scale); this.sticker = sticker; this.baseSize = baseSize; for (int a = 0; a < sticker.attributes.size(); a++) { TLRPC.DocumentAttribute attribute = sticker.attributes.get(a); if (attribute instanceof TLRPC.TL_documentAttributeSticker) { if (attribute.mask_coords != null) anchor = attribute.mask_coords.n; break; } } containerView = new FrameLayoutDrawer(context); addView(containerView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT)); centerImage.setAspectFit(true); centerImage.setInvalidateAll(true); centerImage.setParentView(containerView); centerImage.setImage(sticker, null, sticker.thumb.location, null, "webp", 1); updatePosition(); }
Example 17
Source File: StickersAdapter.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private boolean isValidSticker(TLRPC.Document document, String emoji) { for (int b = 0, size2 = document.attributes.size(); b < size2; b++) { TLRPC.DocumentAttribute attribute = document.attributes.get(b); if (attribute instanceof TLRPC.TL_documentAttributeSticker) { if (attribute.alt != null && attribute.alt.contains(emoji)) { return true; } break; } } return false; }
Example 18
Source File: StickerEmojiCell.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
public void setSticker(TLRPC.Document document, Object parent, String emoji, boolean showEmoji) { if (document != null) { sticker = document; parentObject = parent; TLRPC.PhotoSize thumb = FileLoader.getClosestPhotoSizeWithSize(document.thumbs, 90); if (MessageObject.canAutoplayAnimatedSticker(document)) { if (thumb != null) { imageView.setImage(ImageLocation.getForDocument(document), "80_80", ImageLocation.getForDocument(thumb, document), null, 0, parentObject); } else { imageView.setImage(ImageLocation.getForDocument(document), "80_80", null, null, parentObject); } } else { if (thumb != null) { imageView.setImage(ImageLocation.getForDocument(thumb, document), null, "webp", null, parentObject); } else { imageView.setImage(ImageLocation.getForDocument(document), null, "webp", null, parentObject); } } if (emoji != null) { emojiTextView.setText(Emoji.replaceEmoji(emoji, emojiTextView.getPaint().getFontMetricsInt(), AndroidUtilities.dp(16), false)); emojiTextView.setVisibility(VISIBLE); } else if (showEmoji) { boolean set = false; for (int a = 0; a < document.attributes.size(); a++) { TLRPC.DocumentAttribute attribute = document.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)); set = true; } break; } } if (!set) { emojiTextView.setText(Emoji.replaceEmoji(MediaDataController.getInstance(currentAccount).getEmojiForSticker(sticker.id), emojiTextView.getPaint().getFontMetricsInt(), AndroidUtilities.dp(16), false)); } emojiTextView.setVisibility(VISIBLE); } else { emojiTextView.setVisibility(INVISIBLE); } } }
Example 19
Source File: StickerEmojiCell.java From Telegram with GNU General Public License v2.0 | 4 votes |
public void setSticker(TLRPC.Document document, Object parent, String emoji, boolean showEmoji) { if (document != null) { sticker = document; parentObject = parent; TLRPC.PhotoSize thumb = FileLoader.getClosestPhotoSizeWithSize(document.thumbs, 90); if (MessageObject.canAutoplayAnimatedSticker(document)) { if (thumb != null) { imageView.setImage(ImageLocation.getForDocument(document), "80_80", ImageLocation.getForDocument(thumb, document), null, 0, parentObject); } else { imageView.setImage(ImageLocation.getForDocument(document), "80_80", null, null, parentObject); } } else { if (thumb != null) { imageView.setImage(ImageLocation.getForDocument(thumb, document), null, "webp", null, parentObject); } else { imageView.setImage(ImageLocation.getForDocument(document), null, "webp", null, parentObject); } } if (emoji != null) { emojiTextView.setText(Emoji.replaceEmoji(emoji, emojiTextView.getPaint().getFontMetricsInt(), AndroidUtilities.dp(16), false)); emojiTextView.setVisibility(VISIBLE); } else if (showEmoji) { boolean set = false; for (int a = 0; a < document.attributes.size(); a++) { TLRPC.DocumentAttribute attribute = document.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)); set = true; } break; } } if (!set) { emojiTextView.setText(Emoji.replaceEmoji(MediaDataController.getInstance(currentAccount).getEmojiForSticker(sticker.id), emojiTextView.getPaint().getFontMetricsInt(), AndroidUtilities.dp(16), false)); } emojiTextView.setVisibility(VISIBLE); } else { emojiTextView.setVisibility(INVISIBLE); } } }