use of org.telegram.ui.Components.voip.GroupCallMiniTextureView in project Telegram-FOSS by Telegram-FOSS-Team.
the class GroupCallActivity method fullscreenFor.
public void fullscreenFor(ChatObject.VideoParticipant videoParticipant) {
VoIPService voIPService = VoIPService.getSharedInstance();
if (voIPService == null || renderersContainer.isAnimating()) {
return;
}
if (isTabletMode) {
if (requestFullscreenListener != null) {
listView.getViewTreeObserver().removeOnPreDrawListener(requestFullscreenListener);
requestFullscreenListener = null;
}
ArrayList<ChatObject.VideoParticipant> activeSinks = new ArrayList<>();
if (videoParticipant == null) {
attachedRenderersTmp.clear();
attachedRenderersTmp.addAll(attachedRenderers);
for (int i = 0; i < attachedRenderersTmp.size(); i++) {
final GroupCallMiniTextureView miniTextureView = attachedRenderersTmp.get(i);
if (miniTextureView.primaryView != null) {
miniTextureView.primaryView.setRenderer(null);
if (miniTextureView.secondaryView != null) {
miniTextureView.secondaryView.setRenderer(null);
}
if (miniTextureView.tabletGridView != null) {
miniTextureView.tabletGridView.setRenderer(null);
}
activeSinks.add(miniTextureView.participant);
miniTextureView.forceDetach(false);
miniTextureView.animate().alpha(0f).setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
if (miniTextureView.getParent() != null) {
containerView.removeView(miniTextureView);
}
}
});
}
}
listViewVideoVisibility = false;
tabletGridAdapter.setVisibility(tabletVideoGridView, true, true);
} else {
attachedRenderersTmp.clear();
attachedRenderersTmp.addAll(attachedRenderers);
for (int i = 0; i < attachedRenderersTmp.size(); i++) {
final GroupCallMiniTextureView miniTextureView = attachedRenderersTmp.get(i);
if (miniTextureView.tabletGridView != null && (miniTextureView.participant == null || !miniTextureView.participant.equals(videoParticipant))) {
activeSinks.add(miniTextureView.participant);
miniTextureView.forceDetach(false);
if (miniTextureView.secondaryView != null) {
miniTextureView.secondaryView.setRenderer(null);
}
if (miniTextureView.primaryView != null) {
miniTextureView.primaryView.setRenderer(null);
}
miniTextureView.animate().alpha(0f).setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
if (miniTextureView.getParent() != null) {
containerView.removeView(miniTextureView);
}
}
});
}
}
listViewVideoVisibility = true;
tabletGridAdapter.setVisibility(tabletVideoGridView, false, false);
if (!activeSinks.isEmpty()) {
AndroidUtilities.runOnUIThread(() -> {
for (int i = 0; i < attachedRenderers.size(); i++) {
if (attachedRenderers.get(i).participant != null) {
activeSinks.remove(attachedRenderers.get(i).participant);
}
}
for (int i = 0; i < activeSinks.size(); i++) {
ChatObject.VideoParticipant participant = activeSinks.get(i);
if (participant.participant.self) {
if (VoIPService.getSharedInstance() != null) {
VoIPService.getSharedInstance().setLocalSink(null, participant.presentation);
}
} else {
if (VoIPService.getSharedInstance() != null) {
VoIPService.getSharedInstance().removeRemoteSink(participant.participant, participant.presentation);
}
}
}
});
}
}
boolean updateScroll = !renderersContainer.inFullscreenMode;
listView.getViewTreeObserver().addOnPreDrawListener(requestFullscreenListener = new ViewTreeObserver.OnPreDrawListener() {
@Override
public boolean onPreDraw() {
listView.getViewTreeObserver().removeOnPreDrawListener(this);
requestFullscreenListener = null;
renderersContainer.requestFullscreen(videoParticipant);
if (delayedGroupCallUpdated) {
delayedGroupCallUpdated = false;
applyCallParticipantUpdates(true);
if (updateScroll && videoParticipant != null) {
listView.scrollToPosition(0);
}
delayedGroupCallUpdated = true;
} else {
applyCallParticipantUpdates(true);
}
return false;
}
});
} else {
if (requestFullscreenListener != null) {
listView.getViewTreeObserver().removeOnPreDrawListener(requestFullscreenListener);
requestFullscreenListener = null;
}
if (videoParticipant != null) {
if (fullscreenUsersListView.getVisibility() != View.VISIBLE) {
fullscreenUsersListView.setVisibility(View.VISIBLE);
fullscreenAdapter.update(false, fullscreenUsersListView);
delayedGroupCallUpdated = true;
if (!renderersContainer.inFullscreenMode) {
fullscreenAdapter.scrollTo(videoParticipant, fullscreenUsersListView);
}
listView.getViewTreeObserver().addOnPreDrawListener(requestFullscreenListener = new ViewTreeObserver.OnPreDrawListener() {
@Override
public boolean onPreDraw() {
listView.getViewTreeObserver().removeOnPreDrawListener(this);
requestFullscreenListener = null;
renderersContainer.requestFullscreen(videoParticipant);
AndroidUtilities.updateVisibleRows(fullscreenUsersListView);
return false;
}
});
} else {
renderersContainer.requestFullscreen(videoParticipant);
AndroidUtilities.updateVisibleRows(fullscreenUsersListView);
}
} else {
if (listView.getVisibility() != View.VISIBLE) {
listView.setVisibility(View.VISIBLE);
applyCallParticipantUpdates(false);
delayedGroupCallUpdated = true;
listView.getViewTreeObserver().addOnPreDrawListener(requestFullscreenListener = new ViewTreeObserver.OnPreDrawListener() {
@Override
public boolean onPreDraw() {
listView.getViewTreeObserver().removeOnPreDrawListener(this);
renderersContainer.requestFullscreen(null);
AndroidUtilities.updateVisibleRows(fullscreenUsersListView);
return false;
}
});
} else {
listView.getViewTreeObserver().addOnPreDrawListener(requestFullscreenListener = new ViewTreeObserver.OnPreDrawListener() {
@Override
public boolean onPreDraw() {
listView.getViewTreeObserver().removeOnPreDrawListener(this);
renderersContainer.requestFullscreen(null);
AndroidUtilities.updateVisibleRows(fullscreenUsersListView);
return false;
}
});
}
}
}
}
use of org.telegram.ui.Components.voip.GroupCallMiniTextureView in project Telegram-FOSS by Telegram-FOSS-Team.
the class GroupCallActivity method runAvatarPreviewTransition.
private void runAvatarPreviewTransition(boolean enter, GroupCallUserCell view) {
float fromX, fromY, fromScale;
int fromRadius;
float left = AndroidUtilities.dp(14) + containerView.getPaddingLeft();
float top = AndroidUtilities.dp(14) + containerView.getPaddingTop();
if (hasScrimAnchorView) {
fromX = view.getAvatarImageView().getX() + view.getX() + listView.getX() - left;
fromY = view.getAvatarImageView().getY() + view.getY() + listView.getY() - top;
fromScale = view.getAvatarImageView().getMeasuredHeight() / (float) listView.getMeasuredWidth();
fromRadius = (int) ((view.getAvatarImageView().getMeasuredHeight() >> 1) / fromScale);
} else {
if (scrimRenderer == null) {
previewTextureTransitionEnabled = true;
} else {
previewTextureTransitionEnabled = enter || avatarsViewPager.getRealPosition(avatarsViewPager.getCurrentItem()) == 0;
}
if (scrimGridView != null && previewTextureTransitionEnabled) {
fromX = scrimGridView.getX() + listView.getX() - left;
fromY = scrimGridView.getY() + listView.getY() + AndroidUtilities.dp(2) - top;
fromScale = 1f;
fromRadius = 0;
} else if (scrimFullscreenView != null) {
if (scrimRenderer == null) {
fromX = scrimFullscreenView.getAvatarImageView().getX() + scrimFullscreenView.getX() + fullscreenUsersListView.getX() + renderersContainer.getX() - left;
fromY = scrimFullscreenView.getAvatarImageView().getY() + scrimFullscreenView.getY() + fullscreenUsersListView.getY() + renderersContainer.getY() - top;
fromScale = scrimFullscreenView.getAvatarImageView().getMeasuredHeight() / (float) listView.getMeasuredWidth();
fromRadius = (int) ((scrimFullscreenView.getAvatarImageView().getMeasuredHeight() >> 1) / fromScale);
} else if (previewTextureTransitionEnabled) {
fromX = scrimFullscreenView.getX() + fullscreenUsersListView.getX() + renderersContainer.getX() - left;
fromY = scrimFullscreenView.getY() + fullscreenUsersListView.getY() + renderersContainer.getY() - top;
fromScale = 1f;
fromRadius = 0;
} else {
fromX = 0;
fromY = 0;
fromScale = 0.96f;
fromRadius = 0;
}
} else {
fromX = 0;
fromY = 0;
fromScale = 0.96f;
fromRadius = 0;
}
if (!previewTextureTransitionEnabled && scrimRenderer != null) {
scrimRenderer.invalidate();
renderersContainer.invalidate();
scrimRenderer.setShowingAsScrimView(false, false);
scrimRenderer = null;
}
}
if (enter) {
avatarPreviewContainer.setScaleX(fromScale);
avatarPreviewContainer.setScaleY(fromScale);
avatarPreviewContainer.setTranslationX(fromX);
avatarPreviewContainer.setTranslationY(fromY);
avatarPagerIndicator.setAlpha(0);
}
avatarsViewPager.setRoundRadius(fromRadius, fromRadius);
if (useBlur) {
if (enter) {
blurredView.setAlpha(0f);
}
blurredView.animate().alpha(enter ? 1f : 0).setDuration(220).start();
}
avatarPagerIndicator.animate().alpha(enter ? 1f : 0).setDuration(220).start();
if (!enter && scrimRenderer != null) {
scrimRenderer.setShowingAsScrimView(false, true);
if (avatarsViewPager.getRealPosition(avatarsViewPager.getCurrentItem()) != 0) {
scrimRenderer.textureView.cancelAnimation();
scrimGridView = null;
}
}
ValueAnimator valueAnimator = ValueAnimator.ofFloat(enter ? 0 : 1f, enter ? 1f : 0);
valueAnimator.addUpdateListener((valueAnimator1) -> {
progressToAvatarPreview = (float) valueAnimator1.getAnimatedValue();
renderersContainer.progressToScrimView = progressToAvatarPreview;
float s = fromScale * (1f - progressToAvatarPreview) + 1f * progressToAvatarPreview;
avatarPreviewContainer.setScaleX(s);
avatarPreviewContainer.setScaleY(s);
avatarPreviewContainer.setTranslationX(fromX * (1f - progressToAvatarPreview));
avatarPreviewContainer.setTranslationY(fromY * (1f - progressToAvatarPreview));
if (!useBlur) {
scrimPaint.setAlpha((int) (100 * progressToAvatarPreview));
}
if (scrimRenderer != null) {
scrimRenderer.textureView.setRoundCorners(AndroidUtilities.dp(8) * (1f - progressToAvatarPreview));
}
avatarPreviewContainer.invalidate();
containerView.invalidate();
avatarsViewPager.setRoundRadius((int) (fromRadius * (1f - progressToAvatarPreview)), (int) (fromRadius * (1f - progressToAvatarPreview)));
});
popupAnimationIndex = accountInstance.getNotificationCenter().setAnimationInProgress(popupAnimationIndex, new int[] { NotificationCenter.dialogPhotosLoaded, NotificationCenter.fileLoaded, NotificationCenter.messagesDidLoad });
GroupCallMiniTextureView videoRenderer = scrimGridView == null ? null : scrimRenderer;
if (videoRenderer != null) {
videoRenderer.animateToScrimView = true;
}
valueAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
if (videoRenderer != null) {
videoRenderer.animateToScrimView = false;
}
accountInstance.getNotificationCenter().onAnimationFinish(popupAnimationIndex);
avatarPriviewTransitionInProgress = false;
progressToAvatarPreview = enter ? 1f : 0f;
renderersContainer.progressToScrimView = progressToAvatarPreview;
if (!enter) {
scrimPaint.setAlpha(0);
clearScrimView();
if (scrimPopupLayout.getParent() != null) {
containerView.removeView(scrimPopupLayout);
}
scrimPopupLayout = null;
avatarPreviewContainer.setVisibility(View.GONE);
avatarsPreviewShowed = false;
layoutManager.setCanScrollVertically(true);
blurredView.setVisibility(View.GONE);
if (delayedGroupCallUpdated) {
delayedGroupCallUpdated = false;
applyCallParticipantUpdates(true);
}
if (scrimRenderer != null) {
scrimRenderer.textureView.setRoundCorners(0);
}
} else {
avatarPreviewContainer.setAlpha(1f);
avatarPreviewContainer.setScaleX(1f);
avatarPreviewContainer.setScaleY(1f);
avatarPreviewContainer.setTranslationX(0);
avatarPreviewContainer.setTranslationY(0);
}
checkContentOverlayed();
containerView.invalidate();
avatarsViewPager.invalidate();
listView.invalidate();
}
});
if (!hasScrimAnchorView && scrimRenderer != null) {
valueAnimator.setInterpolator(CubicBezierInterpolator.DEFAULT);
valueAnimator.setDuration(220);
scrimRenderer.textureView.setAnimateNextDuration(220);
scrimRenderer.textureView.synchOrRunAnimation(valueAnimator);
} else {
valueAnimator.setInterpolator(CubicBezierInterpolator.DEFAULT);
valueAnimator.setDuration(220);
valueAnimator.start();
}
checkContentOverlayed();
}
Aggregations