Search in sources :

Example 1 with ContextLinkCell

use of org.telegram.ui.Cells.ContextLinkCell in project Telegram-FOSS by Telegram-FOSS-Team.

the class EmojiView method startStopVisibleGifs.

private void startStopVisibleGifs(boolean start) {
    if (gifGridView == null) {
        return;
    }
    int count = gifGridView.getChildCount();
    for (int a = 0; a < count; a++) {
        View child = gifGridView.getChildAt(a);
        if (child instanceof ContextLinkCell) {
            ContextLinkCell cell = (ContextLinkCell) child;
            ImageReceiver imageReceiver = cell.getPhotoImage();
            if (start) {
                imageReceiver.setAllowStartAnimation(true);
                imageReceiver.startAnimation();
            } else {
                imageReceiver.setAllowStartAnimation(false);
                imageReceiver.stopAnimation();
            }
        }
    }
}
Also used : ImageReceiver(org.telegram.messenger.ImageReceiver) ContextLinkCell(org.telegram.ui.Cells.ContextLinkCell) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView) Paint(android.graphics.Paint) SuppressLint(android.annotation.SuppressLint)

Example 2 with ContextLinkCell

use of org.telegram.ui.Cells.ContextLinkCell in project Telegram-FOSS by Telegram-FOSS-Team.

the class MentionsAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    int type = holder.getItemViewType();
    if (type == 4) {
        StickerCell stickerCell = (StickerCell) holder.itemView;
        StickerResult result = stickers.get(position);
        stickerCell.setSticker(result.sticker, result.parent);
        stickerCell.setClearsInputField(true);
    } else if (type == 3) {
        TextView textView = (TextView) holder.itemView;
        TLRPC.Chat chat = parentFragment.getCurrentChat();
        if (chat != null) {
            if (!ChatObject.hasAdminRights(chat) && chat.default_banned_rights != null && chat.default_banned_rights.send_inline) {
                textView.setText(LocaleController.getString("GlobalAttachInlineRestricted", R.string.GlobalAttachInlineRestricted));
            } else if (AndroidUtilities.isBannedForever(chat.banned_rights)) {
                textView.setText(LocaleController.getString("AttachInlineRestrictedForever", R.string.AttachInlineRestrictedForever));
            } else {
                textView.setText(LocaleController.formatString("AttachInlineRestricted", R.string.AttachInlineRestricted, LocaleController.formatDateForBan(chat.banned_rights.until_date)));
            }
        }
    } else if (searchResultBotContext != null) {
        boolean hasTop = searchResultBotContextSwitch != null;
        if (holder.getItemViewType() == 2) {
            if (hasTop) {
                ((BotSwitchCell) holder.itemView).setText(searchResultBotContextSwitch.text);
            }
        } else {
            if (hasTop) {
                position--;
            }
            ((ContextLinkCell) holder.itemView).setLink(searchResultBotContext.get(position), foundContextBot, contextMedia, position != searchResultBotContext.size() - 1, hasTop && position == 0, "gif".equals(searchingContextUsername));
        }
    } else {
        if (searchResultUsernames != null) {
            TLObject object = searchResultUsernames.get(position);
            if (object instanceof TLRPC.User) {
                ((MentionCell) holder.itemView).setUser((TLRPC.User) object);
            } else if (object instanceof TLRPC.Chat) {
                ((MentionCell) holder.itemView).setChat((TLRPC.Chat) object);
            }
        } else if (searchResultHashtags != null) {
            ((MentionCell) holder.itemView).setText(searchResultHashtags.get(position));
        } else if (searchResultSuggestions != null) {
            ((MentionCell) holder.itemView).setEmojiSuggestion(searchResultSuggestions.get(position));
        } else if (searchResultCommands != null) {
            ((MentionCell) holder.itemView).setBotCommand(searchResultCommands.get(position), searchResultCommandsHelp.get(position), searchResultCommandsUsers != null ? searchResultCommandsUsers.get(position) : null);
        }
    }
}
Also used : ContextLinkCell(org.telegram.ui.Cells.ContextLinkCell) TLRPC(org.telegram.tgnet.TLRPC) StickerCell(org.telegram.ui.Cells.StickerCell) MentionCell(org.telegram.ui.Cells.MentionCell) TLObject(org.telegram.tgnet.TLObject) TextView(android.widget.TextView) BotSwitchCell(org.telegram.ui.Cells.BotSwitchCell)

Example 3 with ContextLinkCell

use of org.telegram.ui.Cells.ContextLinkCell in project Telegram-FOSS by Telegram-FOSS-Team.

the class MentionsAdapter method onCreateViewHolder.

@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    View view;
    switch(viewType) {
        case 0:
            view = new MentionCell(mContext);
            ((MentionCell) view).setIsDarkTheme(isDarkTheme);
            break;
        case 1:
            view = new ContextLinkCell(mContext);
            ((ContextLinkCell) view).setDelegate(cell -> delegate.onContextClick(cell.getResult()));
            break;
        case 2:
            view = new BotSwitchCell(mContext);
            break;
        case 3:
            TextView textView = new TextView(mContext);
            textView.setPadding(AndroidUtilities.dp(8), AndroidUtilities.dp(8), AndroidUtilities.dp(8), AndroidUtilities.dp(8));
            textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
            textView.setTextColor(getThemedColor(Theme.key_windowBackgroundWhiteGrayText2));
            view = textView;
            break;
        case 4:
        default:
            view = new StickerCell(mContext);
            break;
    }
    return new RecyclerListView.Holder(view);
}
Also used : StickerCell(org.telegram.ui.Cells.StickerCell) MentionCell(org.telegram.ui.Cells.MentionCell) ContextLinkCell(org.telegram.ui.Cells.ContextLinkCell) TextView(android.widget.TextView) BotSwitchCell(org.telegram.ui.Cells.BotSwitchCell) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView) EmojiView(org.telegram.ui.Components.EmojiView) RecyclerListView(org.telegram.ui.Components.RecyclerListView)

Example 4 with ContextLinkCell

use of org.telegram.ui.Cells.ContextLinkCell in project Telegram-FOSS by Telegram-FOSS-Team.

the class SharedMediaLayout method onItemClick.

private void onItemClick(int index, View view, MessageObject message, int a, int selectedMode) {
    if (message == null || photoVideoChangeColumnsAnimation) {
        return;
    }
    if (isActionModeShowed) {
        int loadIndex = message.getDialogId() == dialog_id ? 0 : 1;
        if (selectedFiles[loadIndex].indexOfKey(message.getId()) >= 0) {
            selectedFiles[loadIndex].remove(message.getId());
            if (!message.canDeleteMessage(false, null)) {
                cantDeleteMessagesCount--;
            }
        } else {
            if (selectedFiles[0].size() + selectedFiles[1].size() >= 100) {
                return;
            }
            selectedFiles[loadIndex].put(message.getId(), message);
            if (!message.canDeleteMessage(false, null)) {
                cantDeleteMessagesCount++;
            }
        }
        if (selectedFiles[0].size() == 0 && selectedFiles[1].size() == 0) {
            showActionMode(false);
        } else {
            selectedMessagesCountTextView.setNumber(selectedFiles[0].size() + selectedFiles[1].size(), true);
            deleteItem.setVisibility(cantDeleteMessagesCount == 0 ? View.VISIBLE : View.GONE);
            if (gotoItem != null) {
                gotoItem.setVisibility(selectedFiles[0].size() == 1 ? View.VISIBLE : View.GONE);
            }
        }
        scrolling = false;
        if (view instanceof SharedDocumentCell) {
            ((SharedDocumentCell) view).setChecked(selectedFiles[loadIndex].indexOfKey(message.getId()) >= 0, true);
        } else if (view instanceof SharedPhotoVideoCell) {
            ((SharedPhotoVideoCell) view).setChecked(a, selectedFiles[loadIndex].indexOfKey(message.getId()) >= 0, true);
        } else if (view instanceof SharedLinkCell) {
            ((SharedLinkCell) view).setChecked(selectedFiles[loadIndex].indexOfKey(message.getId()) >= 0, true);
        } else if (view instanceof SharedAudioCell) {
            ((SharedAudioCell) view).setChecked(selectedFiles[loadIndex].indexOfKey(message.getId()) >= 0, true);
        } else if (view instanceof ContextLinkCell) {
            ((ContextLinkCell) view).setChecked(selectedFiles[loadIndex].indexOfKey(message.getId()) >= 0, true);
        } else if (view instanceof SharedPhotoVideoCell2) {
            ((SharedPhotoVideoCell2) view).setChecked(selectedFiles[loadIndex].indexOfKey(message.getId()) >= 0, true);
        }
    } else {
        if (selectedMode == 0) {
            int i = index - sharedMediaData[selectedMode].startOffset;
            if (i >= 0 && i < sharedMediaData[selectedMode].messages.size()) {
                PhotoViewer.getInstance().setParentActivity(profileActivity.getParentActivity());
                PhotoViewer.getInstance().openPhoto(sharedMediaData[selectedMode].messages, i, dialog_id, mergeDialogId, provider);
            }
        } else if (selectedMode == 2 || selectedMode == 4) {
            if (view instanceof SharedAudioCell) {
                ((SharedAudioCell) view).didPressedButton();
            }
        } else if (selectedMode == 5) {
            PhotoViewer.getInstance().setParentActivity(profileActivity.getParentActivity());
            index = sharedMediaData[selectedMode].messages.indexOf(message);
            if (index < 0) {
                ArrayList<MessageObject> documents = new ArrayList<>();
                documents.add(message);
                PhotoViewer.getInstance().openPhoto(documents, 0, 0, 0, provider);
            } else {
                PhotoViewer.getInstance().openPhoto(sharedMediaData[selectedMode].messages, index, dialog_id, mergeDialogId, provider);
            }
        } else if (selectedMode == 1) {
            if (view instanceof SharedDocumentCell) {
                SharedDocumentCell cell = (SharedDocumentCell) view;
                TLRPC.Document document = message.getDocument();
                if (cell.isLoaded()) {
                    if (message.canPreviewDocument()) {
                        PhotoViewer.getInstance().setParentActivity(profileActivity.getParentActivity());
                        index = sharedMediaData[selectedMode].messages.indexOf(message);
                        if (index < 0) {
                            ArrayList<MessageObject> documents = new ArrayList<>();
                            documents.add(message);
                            PhotoViewer.getInstance().openPhoto(documents, 0, 0, 0, provider);
                        } else {
                            PhotoViewer.getInstance().openPhoto(sharedMediaData[selectedMode].messages, index, dialog_id, mergeDialogId, provider);
                        }
                        return;
                    }
                    AndroidUtilities.openDocument(message, profileActivity.getParentActivity(), profileActivity);
                } else if (!cell.isLoading()) {
                    MessageObject messageObject = cell.getMessage();
                    profileActivity.getFileLoader().loadFile(document, messageObject, 0, 0);
                    cell.updateFileExistIcon(true);
                } else {
                    profileActivity.getFileLoader().cancelLoadFile(document);
                    cell.updateFileExistIcon(true);
                }
            }
        } else if (selectedMode == 3) {
            try {
                TLRPC.WebPage webPage = message.messageOwner.media != null ? message.messageOwner.media.webpage : null;
                String link = null;
                if (webPage != null && !(webPage instanceof TLRPC.TL_webPageEmpty)) {
                    if (webPage.cached_page != null) {
                        ArticleViewer.getInstance().setParentActivity(profileActivity.getParentActivity(), profileActivity);
                        ArticleViewer.getInstance().open(message);
                        return;
                    } else if (webPage.embed_url != null && webPage.embed_url.length() != 0) {
                        openWebView(webPage, message);
                        return;
                    } else {
                        link = webPage.url;
                    }
                }
                if (link == null) {
                    link = ((SharedLinkCell) view).getLink(0);
                }
                if (link != null) {
                    openUrl(link);
                }
            } catch (Exception e) {
                FileLog.e(e);
            }
        }
    }
    updateForwardItem();
}
Also used : ContextLinkCell(org.telegram.ui.Cells.ContextLinkCell) ArrayList(java.util.ArrayList) Paint(android.graphics.Paint) SharedDocumentCell(org.telegram.ui.Cells.SharedDocumentCell) TLRPC(org.telegram.tgnet.TLRPC) SharedPhotoVideoCell2(org.telegram.ui.Cells.SharedPhotoVideoCell2) SharedPhotoVideoCell(org.telegram.ui.Cells.SharedPhotoVideoCell) SharedAudioCell(org.telegram.ui.Cells.SharedAudioCell) MessageObject(org.telegram.messenger.MessageObject) SharedLinkCell(org.telegram.ui.Cells.SharedLinkCell)

Example 5 with ContextLinkCell

use of org.telegram.ui.Cells.ContextLinkCell in project Telegram-FOSS by Telegram-FOSS-Team.

the class SharedMediaLayout method startStopVisibleGifs.

private void startStopVisibleGifs() {
    for (int b = 0; b < mediaPages.length; b++) {
        int count = mediaPages[b].listView.getChildCount();
        for (int a = 0; a < count; a++) {
            View child = mediaPages[b].listView.getChildAt(a);
            if (child instanceof ContextLinkCell) {
                ContextLinkCell cell = (ContextLinkCell) child;
                ImageReceiver imageReceiver = cell.getPhotoImage();
                if (b == 0) {
                    imageReceiver.setAllowStartAnimation(true);
                    imageReceiver.startAnimation();
                } else {
                    imageReceiver.setAllowStartAnimation(false);
                    imageReceiver.stopAnimation();
                }
            }
        }
    }
}
Also used : ImageReceiver(org.telegram.messenger.ImageReceiver) ContextLinkCell(org.telegram.ui.Cells.ContextLinkCell) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView) Paint(android.graphics.Paint)

Aggregations

ContextLinkCell (org.telegram.ui.Cells.ContextLinkCell)10 Paint (android.graphics.Paint)7 View (android.view.View)7 TextView (android.widget.TextView)5 StickerCell (org.telegram.ui.Cells.StickerCell)5 RecyclerView (androidx.recyclerview.widget.RecyclerView)4 EmojiView (org.telegram.ui.Components.EmojiView)4 RecyclerListView (org.telegram.ui.Components.RecyclerListView)4 SuppressLint (android.annotation.SuppressLint)3 ImageView (android.widget.ImageView)3 MessageObject (org.telegram.messenger.MessageObject)3 Animator (android.animation.Animator)2 AnimatorSet (android.animation.AnimatorSet)2 ObjectAnimator (android.animation.ObjectAnimator)2 ValueAnimator (android.animation.ValueAnimator)2 ArrayList (java.util.ArrayList)2 ImageReceiver (org.telegram.messenger.ImageReceiver)2 TLRPC (org.telegram.tgnet.TLRPC)2 BotSwitchCell (org.telegram.ui.Cells.BotSwitchCell)2 MentionCell (org.telegram.ui.Cells.MentionCell)2