Search in sources :

Example 1 with GroupCallInvitedCell

use of org.telegram.ui.Cells.GroupCallInvitedCell 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 2 with GroupCallInvitedCell

use of org.telegram.ui.Cells.GroupCallInvitedCell 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)2 Paint (android.graphics.Paint)2 View (android.view.View)2 ImageView (android.widget.ImageView)2 ScrollView (android.widget.ScrollView)2 TextView (android.widget.TextView)2 RecyclerView (androidx.recyclerview.widget.RecyclerView)2 SimpleTextView (org.telegram.ui.ActionBar.SimpleTextView)2 GroupCallInvitedCell (org.telegram.ui.Cells.GroupCallInvitedCell)2 GroupCallUserCell (org.telegram.ui.Cells.GroupCallUserCell)2 BackupImageView (org.telegram.ui.Components.BackupImageView)2 HintView (org.telegram.ui.Components.HintView)2 ProfileGalleryView (org.telegram.ui.Components.ProfileGalleryView)2 RLottieImageView (org.telegram.ui.Components.RLottieImageView)2 RadialProgressView (org.telegram.ui.Components.RadialProgressView)2 RecyclerListView (org.telegram.ui.Components.RecyclerListView)2 UndoView (org.telegram.ui.Components.UndoView)2 GroupCallMiniTextureView (org.telegram.ui.Components.voip.GroupCallMiniTextureView)2 PorterDuffColorFilter (android.graphics.PorterDuffColorFilter)1 GradientDrawable (android.graphics.drawable.GradientDrawable)1