Search in sources :

Example 1 with GroupCallUserCell

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

the class UsersAlertBase method setColorProgress.

protected void setColorProgress(float progress) {
    colorProgress = progress;
    backgroundColor = AndroidUtilities.getOffsetColor(Theme.getColor(keyInviteMembersBackground), Theme.getColor(keyListViewBackground), progress, 1.0f);
    shadowDrawable.setColorFilter(new PorterDuffColorFilter(backgroundColor, PorterDuff.Mode.MULTIPLY));
    frameLayout.setBackgroundColor(backgroundColor);
    navBarColor = backgroundColor;
    listView.setGlowColor(backgroundColor);
    int color = AndroidUtilities.getOffsetColor(Theme.getColor(keyLastSeenTextUnscrolled), Theme.getColor(keyLastSeenText), progress, 1.0f);
    // 
    int color2 = AndroidUtilities.getOffsetColor(Theme.getColor(keySearchIconUnscrolled), Theme.getColor(keySearchIcon), progress, 1.0f);
    for (int a = 0, N = listView.getChildCount(); a < N; a++) {
        View child = listView.getChildAt(a);
        if (child instanceof GroupCallTextCell) {
            GroupCallTextCell cell = (GroupCallTextCell) child;
            cell.setColors(color, color);
        } else if (child instanceof GroupCallUserCell) {
            GroupCallUserCell cell = (GroupCallUserCell) child;
            cell.setGrayIconColor(shadow.getTag() != null ? keySearchIcon : keySearchIconUnscrolled, color2);
        }
    }
    containerView.invalidate();
    listView.invalidate();
    container.invalidate();
}
Also used : GroupCallTextCell(org.telegram.ui.Cells.GroupCallTextCell) PorterDuffColorFilter(android.graphics.PorterDuffColorFilter) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) SuppressLint(android.annotation.SuppressLint) GroupCallUserCell(org.telegram.ui.Cells.GroupCallUserCell)

Example 2 with GroupCallUserCell

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

the class GroupCallActivity method showMenuForCell.

private boolean showMenuForCell(View rendererCell) {
    if (itemAnimator.isRunning()) {
        return false;
    }
    if (avatarPriviewTransitionInProgress || avatarsPreviewShowed) {
        dismissAvatarPreview(true);
        return false;
    }
    if (scrimPopupWindow != null) {
        scrimPopupWindow.dismiss();
        scrimPopupWindow = null;
        return false;
    }
    clearScrimView();
    GroupCallUserCell view;
    if (rendererCell instanceof GroupCallGridCell) {
        GroupCallGridCell groupCallGridCell = ((GroupCallGridCell) rendererCell);
        if (groupCallGridCell.getParticipant() == call.videoNotAvailableParticipant) {
            return false;
        }
        view = new GroupCallUserCell(groupCallGridCell.getContext());
        long selfPeerId = MessageObject.getPeerId(selfPeer);
        view.setData(accountInstance, groupCallGridCell.getParticipant().participant, call, selfPeerId, null, false);
        hasScrimAnchorView = false;
        scrimGridView = groupCallGridCell;
        scrimRenderer = groupCallGridCell.getRenderer();
        if (!isTabletMode && !isLandscapeMode) {
            scrimViewAttached = true;
            containerView.addView(view, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, 0, 14, 0, 14, 0));
        } else {
            scrimViewAttached = false;
        }
    } else if (rendererCell instanceof GroupCallFullscreenAdapter.GroupCallUserCell) {
        GroupCallFullscreenAdapter.GroupCallUserCell groupCallFullscreenCell = ((GroupCallFullscreenAdapter.GroupCallUserCell) rendererCell);
        if (groupCallFullscreenCell.getParticipant() == call.videoNotAvailableParticipant.participant) {
            return false;
        }
        view = new GroupCallUserCell(groupCallFullscreenCell.getContext());
        long selfPeerId = MessageObject.getPeerId(selfPeer);
        view.setData(accountInstance, groupCallFullscreenCell.getParticipant(), call, selfPeerId, null, false);
        hasScrimAnchorView = false;
        scrimFullscreenView = groupCallFullscreenCell;
        scrimRenderer = groupCallFullscreenCell.getRenderer();
        if (scrimRenderer != null && scrimRenderer.showingInFullscreen) {
            scrimRenderer = null;
        }
        containerView.addView(view, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, 0, 14, 0, 14, 0));
        scrimViewAttached = true;
    } else {
        view = (GroupCallUserCell) rendererCell;
        hasScrimAnchorView = true;
        scrimViewAttached = true;
    }
    if (view == null) {
        return false;
    }
    boolean showWithAvatarPreview = !isLandscapeMode && !isTabletMode && !AndroidUtilities.isInMultiwindow;
    TLRPC.TL_groupCallParticipant participant = view.getParticipant();
    Rect rect = new Rect();
    ActionBarPopupWindow.ActionBarPopupWindowLayout popupLayout = new ActionBarPopupWindow.ActionBarPopupWindowLayout(getContext());
    popupLayout.setBackgroundDrawable(null);
    popupLayout.setPadding(0, 0, 0, 0);
    popupLayout.setOnTouchListener(new View.OnTouchListener() {

        private int[] pos = new int[2];

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
                if (scrimPopupWindow != null && scrimPopupWindow.isShowing()) {
                    View contentView = scrimPopupWindow.getContentView();
                    contentView.getLocationInWindow(pos);
                    rect.set(pos[0], pos[1], pos[0] + contentView.getMeasuredWidth(), pos[1] + contentView.getMeasuredHeight());
                    if (!rect.contains((int) event.getX(), (int) event.getY())) {
                        scrimPopupWindow.dismiss();
                    }
                }
            } else if (event.getActionMasked() == MotionEvent.ACTION_OUTSIDE) {
                if (scrimPopupWindow != null && scrimPopupWindow.isShowing()) {
                    scrimPopupWindow.dismiss();
                }
            }
            return false;
        }
    });
    popupLayout.setDispatchKeyEventListener(keyEvent -> {
        if (keyEvent.getKeyCode() == KeyEvent.KEYCODE_BACK && keyEvent.getRepeatCount() == 0 && scrimPopupWindow != null && scrimPopupWindow.isShowing()) {
            scrimPopupWindow.dismiss();
        }
    });
    LinearLayout buttonsLayout = new LinearLayout(getContext());
    LinearLayout volumeLayout = !participant.muted_by_you ? new LinearLayout(getContext()) : null;
    currentOptionsLayout = buttonsLayout;
    LinearLayout linearLayout = new LinearLayout(getContext()) {

        @Override
        protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
            int width = MeasureSpec.getSize(widthMeasureSpec);
            buttonsLayout.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.AT_MOST), MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
            if (volumeLayout != null) {
                volumeLayout.measure(MeasureSpec.makeMeasureSpec(buttonsLayout.getMeasuredWidth(), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
                setMeasuredDimension(buttonsLayout.getMeasuredWidth(), buttonsLayout.getMeasuredHeight() + volumeLayout.getMeasuredHeight());
            } else {
                setMeasuredDimension(buttonsLayout.getMeasuredWidth(), buttonsLayout.getMeasuredHeight());
            }
        }
    };
    linearLayout.setMinimumWidth(AndroidUtilities.dp(240));
    linearLayout.setOrientation(LinearLayout.VERTICAL);
    VolumeSlider volumeSlider = null;
    int color = AndroidUtilities.getOffsetColor(Theme.getColor(Theme.key_voipgroup_listViewBackgroundUnscrolled), Theme.getColor(Theme.key_voipgroup_listViewBackground), colorProgress, 1.0f);
    if (volumeLayout != null && !view.isSelfUser() && !participant.muted_by_you && (!participant.muted || participant.can_self_unmute)) {
        Drawable shadowDrawable = getContext().getResources().getDrawable(R.drawable.popup_fixed_alert).mutate();
        shadowDrawable.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.MULTIPLY));
        volumeLayout.setBackgroundDrawable(shadowDrawable);
        linearLayout.addView(volumeLayout, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, 0, 0, 0, 0));
        volumeSlider = new VolumeSlider(getContext(), participant);
        volumeLayout.addView(volumeSlider, LayoutHelper.MATCH_PARENT, 48);
    }
    buttonsLayout.setMinimumWidth(AndroidUtilities.dp(240));
    buttonsLayout.setOrientation(LinearLayout.VERTICAL);
    Drawable shadowDrawable = getContext().getResources().getDrawable(R.drawable.popup_fixed_alert).mutate();
    shadowDrawable.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.MULTIPLY));
    buttonsLayout.setBackgroundDrawable(shadowDrawable);
    linearLayout.addView(buttonsLayout, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, 0, volumeSlider != null ? -8 : 0, 0, 0));
    ScrollView scrollView;
    if (Build.VERSION.SDK_INT >= 21) {
        scrollView = new ScrollView(getContext(), null, 0, R.style.scrollbarShapeStyle) {

            @Override
            protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
                super.onMeasure(widthMeasureSpec, heightMeasureSpec);
                setMeasuredDimension(linearLayout.getMeasuredWidth(), getMeasuredHeight());
            }
        };
    } else {
        scrollView = new ScrollView(getContext());
    }
    scrollView.setClipToPadding(false);
    popupLayout.addView(scrollView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT));
    long peerId = MessageObject.getPeerId(participant.peer);
    ArrayList<String> items = new ArrayList<>(2);
    ArrayList<Integer> icons = new ArrayList<>(2);
    ArrayList<Integer> options = new ArrayList<>(2);
    boolean isAdmin = false;
    if (participant.peer instanceof TLRPC.TL_peerUser) {
        if (ChatObject.isChannel(currentChat)) {
            TLRPC.ChannelParticipant p = accountInstance.getMessagesController().getAdminInChannel(participant.peer.user_id, currentChat.id);
            isAdmin = p != null && (p instanceof TLRPC.TL_channelParticipantCreator || p.admin_rights.manage_call);
        } else {
            TLRPC.ChatFull chatFull = accountInstance.getMessagesController().getChatFull(currentChat.id);
            if (chatFull != null && chatFull.participants != null) {
                for (int a = 0, N = chatFull.participants.participants.size(); a < N; a++) {
                    TLRPC.ChatParticipant chatParticipant = chatFull.participants.participants.get(a);
                    if (chatParticipant.user_id == participant.peer.user_id) {
                        isAdmin = chatParticipant instanceof TLRPC.TL_chatParticipantAdmin || chatParticipant instanceof TLRPC.TL_chatParticipantCreator;
                        break;
                    }
                }
            }
        }
    } else {
        isAdmin = peerId == -currentChat.id;
    }
    if (view.isSelfUser()) {
        if (view.isHandRaised()) {
            items.add(LocaleController.getString("VoipGroupCancelRaiseHand", R.string.VoipGroupCancelRaiseHand));
            icons.add(R.drawable.msg_handdown);
            options.add(7);
        }
        items.add(view.hasAvatarSet() ? LocaleController.getString("VoipAddPhoto", R.string.VoipAddPhoto) : LocaleController.getString("VoipSetNewPhoto", R.string.VoipSetNewPhoto));
        icons.add(R.drawable.msg_addphoto);
        options.add(9);
        if (peerId > 0) {
            items.add(TextUtils.isEmpty(participant.about) ? LocaleController.getString("VoipAddBio", R.string.VoipAddBio) : LocaleController.getString("VoipEditBio", R.string.VoipEditBio));
        } else {
            items.add(TextUtils.isEmpty(participant.about) ? LocaleController.getString("VoipAddDescription", R.string.VoipAddDescription) : LocaleController.getString("VoipEditDescription", R.string.VoipEditDescription));
        }
        icons.add(TextUtils.isEmpty(participant.about) ? R.drawable.msg_addbio : R.drawable.msg_bio);
        options.add(10);
        items.add(peerId > 0 ? LocaleController.getString("VoipEditName", R.string.VoipEditName) : LocaleController.getString("VoipEditTitle", R.string.VoipEditTitle));
        icons.add(R.drawable.msg_edit);
        options.add(11);
    } else if (ChatObject.canManageCalls(currentChat)) {
        if (!isAdmin || !participant.muted) {
            if (!participant.muted || participant.can_self_unmute) {
                items.add(LocaleController.getString("VoipGroupMute", R.string.VoipGroupMute));
                icons.add(R.drawable.msg_voice_muted);
                options.add(0);
            } else {
                items.add(LocaleController.getString("VoipGroupAllowToSpeak", R.string.VoipGroupAllowToSpeak));
                if (participant.raise_hand_rating != 0) {
                    icons.add(R.drawable.msg_allowspeak);
                } else {
                    icons.add(R.drawable.msg_voice_unmuted);
                }
                options.add(1);
            }
        }
        if (participant.peer.channel_id != 0 && !ChatObject.isMegagroup(currentAccount, participant.peer.channel_id)) {
            items.add(LocaleController.getString("VoipGroupOpenChannel", R.string.VoipGroupOpenChannel));
            icons.add(R.drawable.msg_channel);
            options.add(8);
        } else {
            items.add(LocaleController.getString("VoipGroupOpenProfile", R.string.VoipGroupOpenProfile));
            icons.add(R.drawable.msg_openprofile);
            options.add(6);
        }
        if (!isAdmin && ChatObject.canBlockUsers(currentChat)) {
            items.add(LocaleController.getString("VoipGroupUserRemove", R.string.VoipGroupUserRemove));
            icons.add(R.drawable.msg_block2);
            options.add(2);
        }
    } else {
        if (participant.muted_by_you) {
            items.add(LocaleController.getString("VoipGroupUnmuteForMe", R.string.VoipGroupUnmuteForMe));
            icons.add(R.drawable.msg_voice_unmuted);
            options.add(4);
        } else {
            items.add(LocaleController.getString("VoipGroupMuteForMe", R.string.VoipGroupMuteForMe));
            icons.add(R.drawable.msg_voice_muted);
            options.add(5);
        }
        if (participant.peer.channel_id != 0 && !ChatObject.isMegagroup(currentAccount, participant.peer.channel_id)) {
            items.add(LocaleController.getString("VoipGroupOpenChannel", R.string.VoipGroupOpenChannel));
            icons.add(R.drawable.msg_msgbubble3);
            options.add(8);
        } else {
            items.add(LocaleController.getString("VoipGroupOpenChat", R.string.VoipGroupOpenChat));
            icons.add(R.drawable.msg_msgbubble3);
            options.add(6);
        }
    }
    for (int a = 0, N = items.size(); a < N; a++) {
        ActionBarMenuSubItem cell = new ActionBarMenuSubItem(getContext(), a == 0, a == N - 1);
        if (options.get(a) != 2) {
            cell.setColors(Theme.getColor(Theme.key_voipgroup_actionBarItems), Theme.getColor(Theme.key_voipgroup_actionBarItems));
        } else {
            cell.setColors(Theme.getColor(Theme.key_voipgroup_leaveCallMenu), Theme.getColor(Theme.key_voipgroup_leaveCallMenu));
        }
        cell.setSelectorColor(Theme.getColor(Theme.key_voipgroup_listSelector));
        cell.setTextAndIcon(items.get(a), icons.get(a));
        buttonsLayout.addView(cell);
        final int i = a;
        cell.setTag(options.get(a));
        cell.setOnClickListener(v1 -> {
            if (i >= options.size()) {
                return;
            }
            TLRPC.TL_groupCallParticipant participant1 = call.participants.get(MessageObject.getPeerId(participant.peer));
            if (participant1 == null) {
                participant1 = participant;
            }
            processSelectedOption(participant1, MessageObject.getPeerId(participant1.peer), options.get(i));
            if (scrimPopupWindow != null) {
                scrimPopupWindow.dismiss();
            } else {
                if (options.get(i) != 9 && options.get(i) != 10 && options.get(i) != 11) {
                    dismissAvatarPreview(true);
                }
            }
        });
    }
    scrollView.addView(linearLayout, LayoutHelper.createScroll(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP));
    listView.stopScroll();
    layoutManager.setCanScrollVertically(false);
    scrimView = view;
    scrimView.setAboutVisible(true);
    containerView.invalidate();
    listView.invalidate();
    if (scrimAnimatorSet != null) {
        scrimAnimatorSet.cancel();
    }
    scrimPopupLayout = popupLayout;
    final ImageLocation imageLocation;
    final ImageLocation thumbLocation;
    if (peerId > 0) {
        TLRPC.User currentUser = accountInstance.getMessagesController().getUser(peerId);
        imageLocation = ImageLocation.getForUserOrChat(currentUser, ImageLocation.TYPE_BIG);
        thumbLocation = ImageLocation.getForUserOrChat(currentUser, ImageLocation.TYPE_SMALL);
    } else {
        TLRPC.Chat currentChat = accountInstance.getMessagesController().getChat(-peerId);
        imageLocation = ImageLocation.getForUserOrChat(currentChat, ImageLocation.TYPE_BIG);
        thumbLocation = ImageLocation.getForUserOrChat(currentChat, ImageLocation.TYPE_SMALL);
    }
    boolean hasAttachedRenderer = scrimRenderer != null && scrimRenderer.isAttached();
    if (imageLocation == null && !hasAttachedRenderer) {
        showWithAvatarPreview = false;
    } else if (showWithAvatarPreview) {
        avatarsViewPager.setParentAvatarImage(scrimView.getAvatarImageView());
        avatarsViewPager.setHasActiveVideo(hasAttachedRenderer);
        avatarsViewPager.setData(peerId, true);
        avatarsViewPager.setCreateThumbFromParent(true);
        avatarsViewPager.initIfEmpty(imageLocation, thumbLocation);
        if (scrimRenderer != null) {
            scrimRenderer.setShowingAsScrimView(true, true);
        }
        if (MessageObject.getPeerId(selfPeer) == peerId && currentAvatarUpdater != null && avatarUpdaterDelegate != null && avatarUpdaterDelegate.avatar != null) {
            avatarsViewPager.addUploadingImage(avatarUpdaterDelegate.uploadingImageLocation, ImageLocation.getForLocal(avatarUpdaterDelegate.avatar));
        }
    }
    if (showWithAvatarPreview) {
        avatarsPreviewShowed = true;
        popupLayout.measure(View.MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(1000), View.MeasureSpec.AT_MOST), View.MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(1000), View.MeasureSpec.AT_MOST));
        containerView.addView(scrimPopupLayout, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT));
        // scrimFullscreenView == null;
        useBlur = true;
        if (useBlur) {
            prepareBlurBitmap();
        }
        avatarPriviewTransitionInProgress = true;
        avatarPreviewContainer.setVisibility(View.VISIBLE);
        if (volumeSlider != null) {
            volumeSlider.invalidate();
        }
        runAvatarPreviewTransition(true, view);
        if (scrimFullscreenView != null) {
            scrimFullscreenView.getAvatarImageView().setAlpha(0f);
        }
    } else {
        avatarsPreviewShowed = false;
        scrimPopupWindow = new ActionBarPopupWindow(popupLayout, LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT) {

            @Override
            public void dismiss() {
                super.dismiss();
                if (scrimPopupWindow != this) {
                    return;
                }
                scrimPopupWindow = null;
                if (scrimAnimatorSet != null) {
                    scrimAnimatorSet.cancel();
                    scrimAnimatorSet = null;
                }
                layoutManager.setCanScrollVertically(true);
                scrimAnimatorSet = new AnimatorSet();
                ArrayList<Animator> animators = new ArrayList<>();
                animators.add(ObjectAnimator.ofInt(scrimPaint, AnimationProperties.PAINT_ALPHA, 0));
                scrimAnimatorSet.playTogether(animators);
                scrimAnimatorSet.setDuration(220);
                scrimAnimatorSet.addListener(new AnimatorListenerAdapter() {

                    @Override
                    public void onAnimationEnd(Animator animation) {
                        clearScrimView();
                        containerView.invalidate();
                        listView.invalidate();
                        if (delayedGroupCallUpdated) {
                            delayedGroupCallUpdated = false;
                            applyCallParticipantUpdates(true);
                        }
                    }
                });
                scrimAnimatorSet.start();
            }
        };
        scrimPopupWindow.setPauseNotifications(true);
        scrimPopupWindow.setDismissAnimationDuration(220);
        scrimPopupWindow.setOutsideTouchable(true);
        scrimPopupWindow.setClippingEnabled(true);
        scrimPopupWindow.setAnimationStyle(R.style.PopupContextAnimation);
        scrimPopupWindow.setFocusable(true);
        popupLayout.measure(View.MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(1000), View.MeasureSpec.AT_MOST), View.MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(1000), View.MeasureSpec.AT_MOST));
        scrimPopupWindow.setInputMethodMode(ActionBarPopupWindow.INPUT_METHOD_NOT_NEEDED);
        scrimPopupWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED);
        scrimPopupWindow.getContentView().setFocusableInTouchMode(true);
        int popupX, popupY;
        if (scrimFullscreenView != null) {
            if (isLandscapeMode) {
                popupX = (int) (scrimFullscreenView.getX() + fullscreenUsersListView.getX() + renderersContainer.getX()) - popupLayout.getMeasuredWidth() + AndroidUtilities.dp(32);
                popupY = (int) (scrimFullscreenView.getY() + fullscreenUsersListView.getY() + renderersContainer.getY()) - AndroidUtilities.dp(6);
            } else {
                popupX = (int) (scrimFullscreenView.getX() + fullscreenUsersListView.getX() + renderersContainer.getX()) - AndroidUtilities.dp(14);
                popupY = (int) (scrimFullscreenView.getY() + fullscreenUsersListView.getY() + renderersContainer.getY() - popupLayout.getMeasuredHeight());
            }
        } else {
            popupX = (int) (listView.getX() + listView.getMeasuredWidth() + AndroidUtilities.dp(8) - popupLayout.getMeasuredWidth());
            if (hasScrimAnchorView) {
                popupY = (int) (listView.getY() + view.getY() + view.getClipHeight());
            } else if (scrimGridView != null) {
                popupY = (int) (listView.getY() + scrimGridView.getY() + scrimGridView.getMeasuredHeight());
            } else {
                popupY = (int) listView.getY();
            }
        }
        scrimPopupWindow.showAtLocation(listView, Gravity.LEFT | Gravity.TOP, popupX, popupY);
        scrimAnimatorSet = new AnimatorSet();
        ArrayList<Animator> animators = new ArrayList<>();
        animators.add(ObjectAnimator.ofInt(scrimPaint, AnimationProperties.PAINT_ALPHA, 0, 100));
        scrimAnimatorSet.playTogether(animators);
        scrimAnimatorSet.setDuration(150);
        scrimAnimatorSet.start();
    }
    return true;
}
Also used : ArrayList(java.util.ArrayList) PorterDuffColorFilter(android.graphics.PorterDuffColorFilter) AnimatorSet(android.animation.AnimatorSet) TLRPC(org.telegram.tgnet.TLRPC) ImageLocation(org.telegram.messenger.ImageLocation) ActionBarPopupWindow(org.telegram.ui.ActionBar.ActionBarPopupWindow) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) ActionBarMenuSubItem(org.telegram.ui.ActionBar.ActionBarMenuSubItem) GroupCallFullscreenAdapter(org.telegram.ui.Components.GroupCallFullscreenAdapter) GroupCallUserCell(org.telegram.ui.Cells.GroupCallUserCell) Rect(android.graphics.Rect) Drawable(android.graphics.drawable.Drawable) AvatarDrawable(org.telegram.ui.Components.AvatarDrawable) GradientDrawable(android.graphics.drawable.GradientDrawable) CellFlickerDrawable(org.telegram.ui.Components.voip.CellFlickerDrawable) BlobDrawable(org.telegram.ui.Components.BlobDrawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) WaveDrawable(org.telegram.ui.Components.WaveDrawable) RecordStatusDrawable(org.telegram.ui.Components.RecordStatusDrawable) RLottieDrawable(org.telegram.ui.Components.RLottieDrawable) GroupCallGridCell(org.telegram.ui.Components.voip.GroupCallGridCell) ImageView(android.widget.ImageView) RadialProgressView(org.telegram.ui.Components.RadialProgressView) ProfileGalleryView(org.telegram.ui.Components.ProfileGalleryView) UndoView(org.telegram.ui.Components.UndoView) HintView(org.telegram.ui.Components.HintView) GroupCallMiniTextureView(org.telegram.ui.Components.voip.GroupCallMiniTextureView) SimpleTextView(org.telegram.ui.ActionBar.SimpleTextView) ScrollView(android.widget.ScrollView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) RLottieImageView(org.telegram.ui.Components.RLottieImageView) TextView(android.widget.TextView) BackupImageView(org.telegram.ui.Components.BackupImageView) RecyclerListView(org.telegram.ui.Components.RecyclerListView) Paint(android.graphics.Paint) SuppressLint(android.annotation.SuppressLint) MotionEvent(android.view.MotionEvent) ValueAnimator(android.animation.ValueAnimator) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) DefaultItemAnimator(androidx.recyclerview.widget.DefaultItemAnimator) ScrollView(android.widget.ScrollView) LinearLayout(android.widget.LinearLayout)

Example 3 with GroupCallUserCell

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

the class GroupCallActivity method didReceivedNotification.

@Override
public void didReceivedNotification(int id, int account, Object... args) {
    if (id == NotificationCenter.groupCallUpdated) {
        Long callId = (Long) args[1];
        if (call != null && call.call.id == callId) {
            if (call.call instanceof TLRPC.TL_groupCallDiscarded) {
                dismiss();
            } else {
                if (creatingServiceTime == 0 && (muteButtonState == MUTE_BUTTON_STATE_CANCEL_REMINDER || muteButtonState == MUTE_BUTTON_STATE_START_NOW || muteButtonState == MUTE_BUTTON_STATE_SET_REMINDER) && !call.isScheduled()) {
                    try {
                        Intent intent = new Intent(parentActivity, VoIPService.class);
                        intent.putExtra("chat_id", currentChat.id);
                        intent.putExtra("createGroupCall", false);
                        intent.putExtra("hasFewPeers", scheduleHasFewPeers);
                        intent.putExtra("peerChannelId", schedulePeer.channel_id);
                        intent.putExtra("peerChatId", schedulePeer.chat_id);
                        intent.putExtra("peerUserId", schedulePeer.user_id);
                        intent.putExtra("hash", scheduledHash);
                        intent.putExtra("peerAccessHash", schedulePeer.access_hash);
                        intent.putExtra("is_outgoing", true);
                        intent.putExtra("start_incall_activity", false);
                        intent.putExtra("account", accountInstance.getCurrentAccount());
                        intent.putExtra("scheduleDate", scheduleStartAt);
                        parentActivity.startService(intent);
                    } catch (Throwable e) {
                        FileLog.e(e);
                    }
                    creatingServiceTime = SystemClock.elapsedRealtime();
                    AndroidUtilities.runOnUIThread(() -> {
                        if (!isStillConnecting()) {
                            return;
                        }
                        updateState(true, false);
                    }, 3000);
                }
                if (!callInitied && VoIPService.getSharedInstance() != null) {
                    call.addSelfDummyParticipant(false);
                    initCreatedGroupCall();
                    VoIPService.getSharedInstance().playConnectedSound();
                }
                updateItems();
                for (int a = 0, N = listView.getChildCount(); a < N; a++) {
                    View child = listView.getChildAt(a);
                    if (child instanceof GroupCallUserCell) {
                        ((GroupCallUserCell) child).applyParticipantChanges(true);
                    }
                }
                if (scrimView != null) {
                    delayedGroupCallUpdated = true;
                } else {
                    applyCallParticipantUpdates(true);
                }
                updateSubtitle();
                boolean selfUpdate = (Boolean) args[2];
                boolean raisedHand = muteButtonState == MUTE_BUTTON_STATE_RAISED_HAND;
                updateState(true, selfUpdate);
                updateTitle(true);
                if (raisedHand && (muteButtonState == MUTE_BUTTON_STATE_MUTE || muteButtonState == MUTE_BUTTON_STATE_UNMUTE)) {
                    getUndoView().showWithAction(0, UndoView.ACTION_VOIP_CAN_NOW_SPEAK, null);
                    if (VoIPService.getSharedInstance() != null) {
                        VoIPService.getSharedInstance().playAllowTalkSound();
                    }
                }
                if (args.length >= 4) {
                    long justJoinedId = (Long) args[3];
                    if (justJoinedId != 0) {
                        boolean hasInDialogs = false;
                        try {
                            ArrayList<TLRPC.Dialog> dialogs = accountInstance.getMessagesController().getAllDialogs();
                            if (dialogs != null) {
                                for (TLRPC.Dialog dialog : dialogs) {
                                    if (dialog.id == justJoinedId) {
                                        hasInDialogs = true;
                                        break;
                                    }
                                }
                            }
                        } catch (Exception ignore) {
                        }
                        if (DialogObject.isUserDialog(justJoinedId)) {
                            TLRPC.User user = accountInstance.getMessagesController().getUser(justJoinedId);
                            if (user != null && (call.call.participants_count < 250 || UserObject.isContact(user) || user.verified || hasInDialogs)) {
                                getUndoView().showWithAction(0, UndoView.ACTION_VOIP_USER_JOINED, user, currentChat, null, null);
                            }
                        } else {
                            TLRPC.Chat chat = accountInstance.getMessagesController().getChat(-justJoinedId);
                            if (chat != null && (call.call.participants_count < 250 || !ChatObject.isNotInChat(chat) || chat.verified || hasInDialogs)) {
                                getUndoView().showWithAction(0, UndoView.ACTION_VOIP_USER_JOINED, chat, currentChat, null, null);
                            }
                        }
                    }
                }
            }
        }
    } else if (id == NotificationCenter.groupCallSpeakingUsersUpdated) {
        if (renderersContainer.inFullscreenMode && call != null) {
            boolean autoPinEnabled = renderersContainer.autoPinEnabled();
            if (call != null && renderersContainer.inFullscreenMode && renderersContainer.fullscreenParticipant != null && call.participants.get(MessageObject.getPeerId(renderersContainer.fullscreenParticipant.participant.peer)) == null) {
                autoPinEnabled = true;
            }
            if (autoPinEnabled) {
                ChatObject.VideoParticipant currentSpeaker = null;
                for (int i = 0; i < visibleVideoParticipants.size(); i++) {
                    ChatObject.VideoParticipant participant = visibleVideoParticipants.get(i);
                    boolean newSpeaking = call.currentSpeakingPeers.get(MessageObject.getPeerId(participant.participant.peer), null) != null;
                    if (newSpeaking && !participant.participant.muted_by_you && renderersContainer.fullscreenPeerId != MessageObject.getPeerId(participant.participant.peer)) {
                        currentSpeaker = participant;
                    }
                }
                if (currentSpeaker != null) {
                    fullscreenFor(currentSpeaker);
                }
            }
        }
        renderersContainer.setVisibleParticipant(true);
        updateSubtitle();
    } else if (id == NotificationCenter.webRtcMicAmplitudeEvent) {
        float amplitude = (float) args[0];
        setMicAmplitude(amplitude);
    } else if (id == NotificationCenter.needShowAlert) {
        int num = (Integer) args[0];
        if (num == 6) {
            String text = (String) args[1];
            String error;
            if ("GROUPCALL_PARTICIPANTS_TOO_MUCH".equals(text)) {
                if (ChatObject.isChannelOrGiga(currentChat)) {
                    error = LocaleController.getString("VoipChannelTooMuch", R.string.VoipChannelTooMuch);
                } else {
                    error = LocaleController.getString("VoipGroupTooMuch", R.string.VoipGroupTooMuch);
                }
            } else if ("ANONYMOUS_CALLS_DISABLED".equals(text) || "GROUPCALL_ANONYMOUS_FORBIDDEN".equals(text)) {
                if (ChatObject.isChannelOrGiga(currentChat)) {
                    error = LocaleController.getString("VoipChannelJoinAnonymousAdmin", R.string.VoipChannelJoinAnonymousAdmin);
                } else {
                    error = LocaleController.getString("VoipGroupJoinAnonymousAdmin", R.string.VoipGroupJoinAnonymousAdmin);
                }
            } else {
                error = LocaleController.getString("ErrorOccurred", R.string.ErrorOccurred) + "\n" + text;
            }
            AlertDialog.Builder builder = AlertsCreator.createSimpleAlert(getContext(), LocaleController.getString("VoipGroupVoiceChat", R.string.VoipGroupVoiceChat), error);
            builder.setOnDismissListener(dialog -> dismiss());
            try {
                builder.show();
            } catch (Exception e) {
                FileLog.e(e);
            }
        }
    } else if (id == NotificationCenter.didEndCall) {
        if (VoIPService.getSharedInstance() == null) {
            dismiss();
        }
    } else if (id == NotificationCenter.chatInfoDidLoad) {
        TLRPC.ChatFull chatFull = (TLRPC.ChatFull) args[0];
        if (chatFull.id == currentChat.id) {
            updateItems();
            updateState(isShowing(), false);
        }
        long selfId = MessageObject.getPeerId(selfPeer);
        if (call != null && chatFull.id == -selfId) {
            TLRPC.TL_groupCallParticipant participant = call.participants.get(selfId);
            if (participant != null) {
                participant.about = chatFull.about;
                applyCallParticipantUpdates(true);
                AndroidUtilities.updateVisibleRows(listView);
                if (currentOptionsLayout != null) {
                    for (int i = 0; i < currentOptionsLayout.getChildCount(); i++) {
                        View child = currentOptionsLayout.getChildAt(i);
                        if (child instanceof ActionBarMenuSubItem && child.getTag() != null && (Integer) child.getTag() == 10) {
                            ((ActionBarMenuSubItem) child).setTextAndIcon(TextUtils.isEmpty(participant.about) ? LocaleController.getString("VoipAddDescription", R.string.VoipAddDescription) : LocaleController.getString("VoipEditDescription", R.string.VoipEditDescription), TextUtils.isEmpty(participant.about) ? R.drawable.msg_addbio : R.drawable.msg_bio);
                        }
                    }
                }
            }
        }
    } else if (id == NotificationCenter.didLoadChatAdmins) {
        long chatId = (Long) args[0];
        if (chatId == currentChat.id) {
            updateItems();
            updateState(isShowing(), false);
        }
    } else if (id == NotificationCenter.applyGroupCallVisibleParticipants) {
        int count = listView.getChildCount();
        long time = (Long) args[0];
        for (int a = 0; a < count; a++) {
            View child = listView.getChildAt(a);
            RecyclerView.ViewHolder holder = listView.findContainingViewHolder(child);
            if (holder != null && holder.itemView instanceof GroupCallUserCell) {
                GroupCallUserCell cell = (GroupCallUserCell) holder.itemView;
                cell.getParticipant().lastVisibleDate = time;
            }
        }
    } else if (id == NotificationCenter.userInfoDidLoad) {
        Long uid = (Long) args[0];
        long selfId = MessageObject.getPeerId(selfPeer);
        if (call != null && selfId == uid) {
            TLRPC.TL_groupCallParticipant participant = call.participants.get(selfId);
            if (participant != null) {
                TLRPC.UserFull userInfo = (TLRPC.UserFull) args[1];
                participant.about = userInfo.about;
                applyCallParticipantUpdates(true);
                AndroidUtilities.updateVisibleRows(listView);
                if (currentOptionsLayout != null) {
                    for (int i = 0; i < currentOptionsLayout.getChildCount(); i++) {
                        View child = currentOptionsLayout.getChildAt(i);
                        if (child instanceof ActionBarMenuSubItem && child.getTag() != null && (Integer) child.getTag() == 10) {
                            ((ActionBarMenuSubItem) child).setTextAndIcon(TextUtils.isEmpty(participant.about) ? LocaleController.getString("VoipAddBio", R.string.VoipAddBio) : LocaleController.getString("VoipEditBio", R.string.VoipEditBio), TextUtils.isEmpty(participant.about) ? R.drawable.msg_addbio : R.drawable.msg_bio);
                        }
                    }
                }
            }
        }
    } else if (id == NotificationCenter.mainUserInfoChanged) {
        applyCallParticipantUpdates(true);
        AndroidUtilities.updateVisibleRows(listView);
    } else if (id == NotificationCenter.updateInterfaces) {
        int mask = (int) args[0];
        if ((mask & MessagesController.UPDATE_MASK_CHAT_NAME) != 0) {
            applyCallParticipantUpdates(true);
            AndroidUtilities.updateVisibleRows(listView);
        }
    } else if (id == NotificationCenter.groupCallScreencastStateChanged) {
        if (previewDialog != null) {
            previewDialog.dismiss(true, true);
        }
        updateItems();
    }
}
Also used : Bundle(android.os.Bundle) NonNull(androidx.annotation.NonNull) MediaProjectionManager(android.media.projection.MediaProjectionManager) FrameLayout(android.widget.FrameLayout) ImageView(android.widget.ImageView) EditTextBoldCursor(org.telegram.ui.Components.EditTextBoldCursor) GroupCallFullscreenAdapter(org.telegram.ui.Components.GroupCallFullscreenAdapter) GroupVoipInviteAlert(org.telegram.ui.Components.GroupVoipInviteAlert) Drawable(android.graphics.drawable.Drawable) RadialGradient(android.graphics.RadialGradient) Property(android.util.Property) AvatarDrawable(org.telegram.ui.Components.AvatarDrawable) RadialProgressView(org.telegram.ui.Components.RadialProgressView) Manifest(android.Manifest) ActionBarMenuSubItem(org.telegram.ui.ActionBar.ActionBarMenuSubItem) ProfileGalleryView(org.telegram.ui.Components.ProfileGalleryView) Shader(android.graphics.Shader) Canvas(android.graphics.Canvas) GroupCallStatusIcon(org.telegram.ui.Components.voip.GroupCallStatusIcon) ListUpdateCallback(androidx.recyclerview.widget.ListUpdateCallback) UndoView(org.telegram.ui.Components.UndoView) AnimationProperties(org.telegram.ui.Components.AnimationProperties) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) NotificationCenter(org.telegram.messenger.NotificationCenter) HapticFeedbackConstants(android.view.HapticFeedbackConstants) Nullable(androidx.annotation.Nullable) AUDIO_SERVICE(android.content.Context.AUDIO_SERVICE) HintView(org.telegram.ui.Components.HintView) PorterDuffColorFilter(android.graphics.PorterDuffColorFilter) Paint(android.graphics.Paint) GroupCallTextCell(org.telegram.ui.Cells.GroupCallTextCell) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) PrivateVideoPreviewDialog(org.telegram.ui.Components.voip.PrivateVideoPreviewDialog) TextWatcher(android.text.TextWatcher) GroupCallMiniTextureView(org.telegram.ui.Components.voip.GroupCallMiniTextureView) FileLoader(org.telegram.messenger.FileLoader) GroupCallPip(org.telegram.ui.Components.GroupCallPip) Path(android.graphics.Path) ViewPager(androidx.viewpager.widget.ViewPager) Dialog(android.app.Dialog) SystemClock(android.os.SystemClock) AlertsCreator(org.telegram.ui.Components.AlertsCreator) Editable(android.text.Editable) ArrayList(java.util.ArrayList) SpannableStringBuilder(android.text.SpannableStringBuilder) Calendar(java.util.Calendar) Log(com.google.android.exoplayer2.util.Log) TLRPC(org.telegram.tgnet.TLRPC) GradientDrawable(android.graphics.drawable.GradientDrawable) Settings(android.provider.Settings) CellFlickerDrawable(org.telegram.ui.Components.voip.CellFlickerDrawable) ColorFilter(android.graphics.ColorFilter) LongSparseIntArray(org.telegram.messenger.support.LongSparseIntArray) SimpleTextView(org.telegram.ui.ActionBar.SimpleTextView) LinearGradient(android.graphics.LinearGradient) R(org.telegram.messenger.R) BottomSheet(org.telegram.ui.ActionBar.BottomSheet) JoinCallAlert(org.telegram.ui.Components.JoinCallAlert) TextUtils(android.text.TextUtils) File(java.io.File) CheckBoxSquare(org.telegram.ui.Components.CheckBoxSquare) Gravity(android.view.Gravity) SparseBooleanArray(android.util.SparseBooleanArray) UserObject(org.telegram.messenger.UserObject) SharedPreferences(android.content.SharedPreferences) TypedValue(android.util.TypedValue) ScrollView(android.widget.ScrollView) ColorUtils(androidx.core.graphics.ColorUtils) ChatObject(org.telegram.messenger.ChatObject) AlertDialog(org.telegram.ui.ActionBar.AlertDialog) AudioPlayerAlert(org.telegram.ui.Components.AudioPlayerAlert) ValueAnimator(android.animation.ValueAnimator) ThemeDescription(org.telegram.ui.ActionBar.ThemeDescription) Rect(android.graphics.Rect) LinearLayout(android.widget.LinearLayout) ActionBarMenuItem(org.telegram.ui.ActionBar.ActionBarMenuItem) ImageUpdater(org.telegram.ui.Components.ImageUpdater) PackageManager(android.content.pm.PackageManager) BlobDrawable(org.telegram.ui.Components.BlobDrawable) WindowManager(android.view.WindowManager) AccountInstance(org.telegram.messenger.AccountInstance) AndroidUtilities(org.telegram.messenger.AndroidUtilities) CubicBezierInterpolator(org.telegram.ui.Components.CubicBezierInterpolator) Animator(android.animation.Animator) TypefaceSpan(org.telegram.ui.Components.TypefaceSpan) ViewConfiguration(android.view.ViewConfiguration) CheckBoxCell(org.telegram.ui.Cells.CheckBoxCell) Locale(java.util.Locale) View(android.view.View) Button(android.widget.Button) RecyclerView(androidx.recyclerview.widget.RecyclerView) Matrix(android.graphics.Matrix) RectF(android.graphics.RectF) ImageLoader(org.telegram.messenger.ImageLoader) Utilities(org.telegram.messenger.Utilities) GroupCallUserCell(org.telegram.ui.Cells.GroupCallUserCell) DiffUtil(androidx.recyclerview.widget.DiffUtil) RLottieImageView(org.telegram.ui.Components.RLottieImageView) ObjectAnimator(android.animation.ObjectAnimator) ImageLocation(org.telegram.messenger.ImageLocation) InputType(android.text.InputType) BaseFragment(org.telegram.ui.ActionBar.BaseFragment) BitmapDrawable(android.graphics.drawable.BitmapDrawable) Instance(org.telegram.messenger.voip.Instance) PorterDuff(android.graphics.PorterDuff) ConnectionsManager(org.telegram.tgnet.ConnectionsManager) ViewGroup(android.view.ViewGroup) ShareAlert(org.telegram.ui.Components.ShareAlert) DefaultItemAnimator(androidx.recyclerview.widget.DefaultItemAnimator) SparseArray(android.util.SparseArray) TextView(android.widget.TextView) VoIPToggleButton(org.telegram.ui.Components.voip.VoIPToggleButton) EditorInfo(android.view.inputmethod.EditorInfo) GroupCallInvitedCell(org.telegram.ui.Cells.GroupCallInvitedCell) ActionBarPopupWindow(org.telegram.ui.ActionBar.ActionBarPopupWindow) GroupCallRenderersContainer(org.telegram.ui.Components.voip.GroupCallRenderersContainer) Context(android.content.Context) AccessibilityNodeInfo(android.view.accessibility.AccessibilityNodeInfo) KeyEvent(android.view.KeyEvent) GridLayoutManager(androidx.recyclerview.widget.GridLayoutManager) VoIPService(org.telegram.messenger.voip.VoIPService) SparseIntArray(android.util.SparseIntArray) Theme(org.telegram.ui.ActionBar.Theme) Intent(android.content.Intent) LocaleController(org.telegram.messenger.LocaleController) HashMap(java.util.HashMap) PixelFormat(android.graphics.PixelFormat) AudioManager(android.media.AudioManager) WaveDrawable(org.telegram.ui.Components.WaveDrawable) GroupCallGridCell(org.telegram.ui.Components.voip.GroupCallGridCell) HashSet(java.util.HashSet) SuppressLint(android.annotation.SuppressLint) MotionEvent(android.view.MotionEvent) ActionBar(org.telegram.ui.ActionBar.ActionBar) GroupCallRecordAlert(org.telegram.ui.Components.GroupCallRecordAlert) TLObject(org.telegram.tgnet.TLObject) AnimatorSet(android.animation.AnimatorSet) MessageObject(org.telegram.messenger.MessageObject) SharedConfig(org.telegram.messenger.SharedConfig) Build(android.os.Build) NumberPicker(org.telegram.ui.Components.NumberPicker) DialogInterface(android.content.DialogInterface) LongSparseArray(androidx.collection.LongSparseArray) DialogObject(org.telegram.messenger.DialogObject) BackupImageView(org.telegram.ui.Components.BackupImageView) LayoutHelper(org.telegram.ui.Components.LayoutHelper) FileLog(org.telegram.messenger.FileLog) AccountSelectCell(org.telegram.ui.Cells.AccountSelectCell) MessagesController(org.telegram.messenger.MessagesController) Color(android.graphics.Color) RecordStatusDrawable(org.telegram.ui.Components.RecordStatusDrawable) Bitmap(android.graphics.Bitmap) OvershootInterpolator(android.view.animation.OvershootInterpolator) ViewTreeObserver(android.view.ViewTreeObserver) FillLastGridLayoutManager(org.telegram.ui.Components.FillLastGridLayoutManager) RecyclerListView(org.telegram.ui.Components.RecyclerListView) RLottieDrawable(org.telegram.ui.Components.RLottieDrawable) SpannableStringBuilder(android.text.SpannableStringBuilder) TLRPC(org.telegram.tgnet.TLRPC) PrivateVideoPreviewDialog(org.telegram.ui.Components.voip.PrivateVideoPreviewDialog) Dialog(android.app.Dialog) AlertDialog(org.telegram.ui.ActionBar.AlertDialog) ActionBarMenuSubItem(org.telegram.ui.ActionBar.ActionBarMenuSubItem) GroupCallUserCell(org.telegram.ui.Cells.GroupCallUserCell) Intent(android.content.Intent) ImageView(android.widget.ImageView) RadialProgressView(org.telegram.ui.Components.RadialProgressView) ProfileGalleryView(org.telegram.ui.Components.ProfileGalleryView) UndoView(org.telegram.ui.Components.UndoView) HintView(org.telegram.ui.Components.HintView) GroupCallMiniTextureView(org.telegram.ui.Components.voip.GroupCallMiniTextureView) SimpleTextView(org.telegram.ui.ActionBar.SimpleTextView) ScrollView(android.widget.ScrollView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) RLottieImageView(org.telegram.ui.Components.RLottieImageView) TextView(android.widget.TextView) BackupImageView(org.telegram.ui.Components.BackupImageView) RecyclerListView(org.telegram.ui.Components.RecyclerListView) Paint(android.graphics.Paint) SuppressLint(android.annotation.SuppressLint)

Example 4 with GroupCallUserCell

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

the class GroupCallActivity method applyCallParticipantUpdates.

private void applyCallParticipantUpdates(boolean animated) {
    if (renderersContainer.inFullscreenMode) {
        renderersContainer.setVisibleParticipant(true);
    }
    if (call == null || delayedGroupCallUpdated) {
        return;
    }
    long self = MessageObject.getPeerId(call.selfPeer);
    long dummyPeer = MessageObject.getPeerId(selfPeer);
    if (self != dummyPeer && call.participants.get(self) != null) {
        selfPeer = call.selfPeer;
    }
    int count = listView.getChildCount();
    View minChild = null;
    int minPosition = 0;
    int minTop = Integer.MAX_VALUE;
    for (int a = 0; a < count; a++) {
        View child = listView.getChildAt(a);
        RecyclerView.ViewHolder holder = listView.findContainingViewHolder(child);
        if (holder != null && holder.getAdapterPosition() != RecyclerView.NO_POSITION && holder.getLayoutPosition() != RecyclerView.NO_POSITION) {
            if (minChild == null || child.getTop() < minTop) {
                minChild = child;
                minPosition = holder.getLayoutPosition();
                minTop = child.getTop();
            }
        }
    }
    updateVideoParticipantList();
    if (listView.getItemAnimator() != null && !animated) {
        listView.setItemAnimator(null);
    } else if (listView.getItemAnimator() == null && animated) {
        listView.setItemAnimator(itemAnimator);
    }
    try {
        UpdateCallback updateCallback = new UpdateCallback(listAdapter);
        setOldRows(listAdapter.addMemberRow, listAdapter.usersStartRow, listAdapter.usersEndRow, listAdapter.invitedStartRow, listAdapter.invitedEndRow, listAdapter.usersVideoGridStartRow, listAdapter.usersVideoGridEndRow, listAdapter.videoGridDividerRow, listAdapter.videoNotAvailableRow);
        listAdapter.updateRows();
        DiffUtil.calculateDiff(diffUtilsCallback).dispatchUpdatesTo(updateCallback);
    } catch (Exception e) {
        FileLog.e(e);
        listAdapter.notifyDataSetChanged();
    }
    call.saveActiveDates();
    if (minChild != null) {
        layoutManager.scrollToPositionWithOffset(minPosition, minChild.getTop() - listView.getPaddingTop());
    }
    oldParticipants.clear();
    oldParticipants.addAll(call.visibleParticipants);
    oldVideoParticipants.clear();
    oldVideoParticipants.addAll(visibleVideoParticipants);
    oldInvited.clear();
    oldInvited.addAll(call.invitedUsers);
    oldCount = listAdapter.getItemCount();
    for (int a = 0; a < count; a++) {
        View child = listView.getChildAt(a);
        if (child instanceof GroupCallUserCell || child instanceof GroupCallInvitedCell) {
            RecyclerView.ViewHolder holder = listView.findContainingViewHolder(child);
            if (holder != null) {
                if (child instanceof GroupCallUserCell) {
                    ((GroupCallUserCell) child).setDrawDivider(holder.getAdapterPosition() != listAdapter.getItemCount() - 2);
                } else {
                    ((GroupCallInvitedCell) child).setDrawDivider(holder.getAdapterPosition() != listAdapter.getItemCount() - 2);
                }
            }
        }
    }
    boolean autoPinEnabled = renderersContainer.autoPinEnabled();
    if (renderersContainer.inFullscreenMode && renderersContainer.fullscreenParticipant != null && !ChatObject.Call.videoIsActive(renderersContainer.fullscreenParticipant.participant, renderersContainer.fullscreenParticipant.presentation, call)) {
        boolean foundAnotherVideoParticipant = false;
        if (!visibleVideoParticipants.isEmpty()) {
            foundAnotherVideoParticipant = true;
            if (autoPinEnabled) {
                fullscreenFor(visibleVideoParticipants.get(0));
            }
        }
        if (!foundAnotherVideoParticipant) {
            fullscreenFor(null);
        }
    }
    fullscreenAdapter.update(true, fullscreenUsersListView);
    if (fullscreenUsersListView.getVisibility() == View.VISIBLE) {
        AndroidUtilities.updateVisibleRows(fullscreenUsersListView);
    }
    if (isTabletMode) {
        tabletGridAdapter.update(true, tabletVideoGridView);
    }
    if (listView.getVisibility() == View.VISIBLE) {
        AndroidUtilities.updateVisibleRows(listView);
    }
    attachedRenderersTmp.clear();
    attachedRenderersTmp.addAll(attachedRenderers);
    for (int i = 0; i < attachedRenderersTmp.size(); i++) {
        attachedRenderersTmp.get(i).updateAttachState(true);
    }
    if (call != null && renderersContainer.inFullscreenMode && renderersContainer.fullscreenParticipant != null && call.participants.get(MessageObject.getPeerId(renderersContainer.fullscreenParticipant.participant.peer)) == null) {
        autoPinEnabled = true;
    }
    boolean hasVideoLocal = !call.visibleVideoParticipants.isEmpty();
    if (hasVideoLocal != hasVideo) {
        hasVideo = hasVideoLocal;
        if (isTabletMode) {
            containerView.requestLayout();
        }
    }
}
Also used : RecyclerView(androidx.recyclerview.widget.RecyclerView) ImageView(android.widget.ImageView) RadialProgressView(org.telegram.ui.Components.RadialProgressView) ProfileGalleryView(org.telegram.ui.Components.ProfileGalleryView) UndoView(org.telegram.ui.Components.UndoView) HintView(org.telegram.ui.Components.HintView) GroupCallMiniTextureView(org.telegram.ui.Components.voip.GroupCallMiniTextureView) SimpleTextView(org.telegram.ui.ActionBar.SimpleTextView) ScrollView(android.widget.ScrollView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) RLottieImageView(org.telegram.ui.Components.RLottieImageView) TextView(android.widget.TextView) BackupImageView(org.telegram.ui.Components.BackupImageView) RecyclerListView(org.telegram.ui.Components.RecyclerListView) Paint(android.graphics.Paint) SuppressLint(android.annotation.SuppressLint) ListUpdateCallback(androidx.recyclerview.widget.ListUpdateCallback) GroupCallInvitedCell(org.telegram.ui.Cells.GroupCallInvitedCell) GroupCallUserCell(org.telegram.ui.Cells.GroupCallUserCell)

Example 5 with GroupCallUserCell

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

the class GroupCallActivity method setColorProgress.

private void setColorProgress(float progress) {
    colorProgress = progress;
    float finalColorProgress = colorProgress;
    float finalColorProgress2 = Math.max(colorProgress, renderersContainer == null ? 0 : renderersContainer.progressToFullscreenMode);
    backgroundColor = AndroidUtilities.getOffsetColor(Theme.getColor(Theme.key_voipgroup_actionBarUnscrolled), Theme.getColor(Theme.key_voipgroup_actionBar), finalColorProgress, 1.0f);
    actionBarBackground.setBackgroundColor(backgroundColor);
    otherItem.redrawPopup(0xff232A33);
    shadowDrawable.setColorFilter(new PorterDuffColorFilter(backgroundColor, PorterDuff.Mode.MULTIPLY));
    navBarColor = AndroidUtilities.getOffsetColor(Theme.getColor(Theme.key_voipgroup_actionBarUnscrolled), Theme.getColor(Theme.key_voipgroup_actionBar), finalColorProgress2, 1.0f);
    int color = AndroidUtilities.getOffsetColor(Theme.getColor(Theme.key_voipgroup_listViewBackgroundUnscrolled), Theme.getColor(Theme.key_voipgroup_listViewBackground), finalColorProgress, 1.0f);
    listViewBackgroundPaint.setColor(color);
    listView.setGlowColor(color);
    if (muteButtonState == MUTE_BUTTON_STATE_CONNECTING || isGradientState(muteButtonState)) {
        muteButton.invalidate();
    }
    if (buttonsBackgroundGradientView != null) {
        gradientColors[0] = backgroundColor;
        gradientColors[1] = Color.TRANSPARENT;
        if (Build.VERSION.SDK_INT > Build.VERSION_CODES.Q) {
            buttonsBackgroundGradient.setColors(gradientColors);
        } else {
            buttonsBackgroundGradientView.setBackground(buttonsBackgroundGradient = new GradientDrawable(GradientDrawable.Orientation.BOTTOM_TOP, gradientColors));
        }
        buttonsBackgroundGradientView2.setBackgroundColor(gradientColors[0]);
    }
    color = AndroidUtilities.getOffsetColor(Theme.getColor(Theme.key_voipgroup_leaveButton), Theme.getColor(Theme.key_voipgroup_leaveButtonScrolled), finalColorProgress, 1.0f);
    leaveButton.setBackgroundColor(color, color);
    color = AndroidUtilities.getOffsetColor(Theme.getColor(Theme.key_voipgroup_lastSeenTextUnscrolled), Theme.getColor(Theme.key_voipgroup_lastSeenText), finalColorProgress, 1.0f);
    int color2 = AndroidUtilities.getOffsetColor(Theme.getColor(Theme.key_voipgroup_mutedIconUnscrolled), Theme.getColor(Theme.key_voipgroup_mutedIcon), finalColorProgress, 1.0f);
    for (int a = 0, N = listView.getChildCount(); a < N; a++) {
        View child = listView.getChildAt(a);
        if (child instanceof GroupCallTextCell) {
            GroupCallTextCell cell = (GroupCallTextCell) child;
            cell.setColors(color2, color);
        } else if (child instanceof GroupCallUserCell) {
            GroupCallUserCell cell = (GroupCallUserCell) child;
            cell.setGrayIconColor(actionBar.getTag() != null ? Theme.key_voipgroup_mutedIcon : Theme.key_voipgroup_mutedIconUnscrolled, color2);
        } else if (child instanceof GroupCallInvitedCell) {
            GroupCallInvitedCell cell = (GroupCallInvitedCell) child;
            cell.setGrayIconColor(actionBar.getTag() != null ? Theme.key_voipgroup_mutedIcon : Theme.key_voipgroup_mutedIconUnscrolled, color2);
        }
    }
    containerView.invalidate();
    listView.invalidate();
    container.invalidate();
}
Also used : GroupCallTextCell(org.telegram.ui.Cells.GroupCallTextCell) PorterDuffColorFilter(android.graphics.PorterDuffColorFilter) ImageView(android.widget.ImageView) RadialProgressView(org.telegram.ui.Components.RadialProgressView) ProfileGalleryView(org.telegram.ui.Components.ProfileGalleryView) UndoView(org.telegram.ui.Components.UndoView) HintView(org.telegram.ui.Components.HintView) GroupCallMiniTextureView(org.telegram.ui.Components.voip.GroupCallMiniTextureView) SimpleTextView(org.telegram.ui.ActionBar.SimpleTextView) ScrollView(android.widget.ScrollView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) RLottieImageView(org.telegram.ui.Components.RLottieImageView) TextView(android.widget.TextView) BackupImageView(org.telegram.ui.Components.BackupImageView) RecyclerListView(org.telegram.ui.Components.RecyclerListView) Paint(android.graphics.Paint) SuppressLint(android.annotation.SuppressLint) GradientDrawable(android.graphics.drawable.GradientDrawable) GroupCallInvitedCell(org.telegram.ui.Cells.GroupCallInvitedCell) GroupCallUserCell(org.telegram.ui.Cells.GroupCallUserCell)

Aggregations

SuppressLint (android.annotation.SuppressLint)6 RecyclerView (androidx.recyclerview.widget.RecyclerView)6 GroupCallUserCell (org.telegram.ui.Cells.GroupCallUserCell)6 Paint (android.graphics.Paint)5 View (android.view.View)5 ImageView (android.widget.ImageView)5 PorterDuffColorFilter (android.graphics.PorterDuffColorFilter)4 ScrollView (android.widget.ScrollView)4 TextView (android.widget.TextView)4 SimpleTextView (org.telegram.ui.ActionBar.SimpleTextView)4 BackupImageView (org.telegram.ui.Components.BackupImageView)4 HintView (org.telegram.ui.Components.HintView)4 ProfileGalleryView (org.telegram.ui.Components.ProfileGalleryView)4 RLottieImageView (org.telegram.ui.Components.RLottieImageView)4 RadialProgressView (org.telegram.ui.Components.RadialProgressView)4 RecyclerListView (org.telegram.ui.Components.RecyclerListView)4 UndoView (org.telegram.ui.Components.UndoView)4 GroupCallMiniTextureView (org.telegram.ui.Components.voip.GroupCallMiniTextureView)4 GradientDrawable (android.graphics.drawable.GradientDrawable)3 TLRPC (org.telegram.tgnet.TLRPC)3