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();
}
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;
}
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();
}
}
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();
}
}
}
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();
}
Aggregations