use of org.telegram.ui.Components.voip.PrivateVideoPreviewDialog in project Telegram-FOSS by Telegram-FOSS-Team.
the class VoIPFragment method toggleCameraInput.
private void toggleCameraInput() {
VoIPService service = VoIPService.getSharedInstance();
if (service != null) {
if (accessibilityManager.isTouchExplorationEnabled()) {
final String text;
if (!currentUserIsVideo) {
text = LocaleController.getString("AccDescrVoipCamOn", R.string.AccDescrVoipCamOn);
} else {
text = LocaleController.getString("AccDescrVoipCamOff", R.string.AccDescrVoipCamOff);
}
fragmentView.announceForAccessibility(text);
}
if (!currentUserIsVideo) {
if (Build.VERSION.SDK_INT >= 21) {
if (previewDialog == null) {
service.createCaptureDevice(false);
if (!service.isFrontFaceCamera()) {
service.switchCamera();
}
windowView.setLockOnScreen(true);
previewDialog = new PrivateVideoPreviewDialog(fragmentView.getContext(), false, true) {
@Override
public void onDismiss(boolean screencast, boolean apply) {
previewDialog = null;
VoIPService service = VoIPService.getSharedInstance();
windowView.setLockOnScreen(false);
if (apply) {
currentUserIsVideo = true;
if (service != null && !screencast) {
service.requestVideoCall(false);
service.setVideoState(false, Instance.VIDEO_STATE_ACTIVE);
}
} else {
if (service != null) {
service.setVideoState(false, Instance.VIDEO_STATE_INACTIVE);
}
}
previousState = currentState;
updateViewState();
}
};
if (lastInsets != null) {
previewDialog.setBottomPadding(lastInsets.getSystemWindowInsetBottom());
}
fragmentView.addView(previewDialog);
}
return;
} else {
currentUserIsVideo = true;
if (!service.isSpeakerphoneOn()) {
VoIPService.getSharedInstance().toggleSpeakerphoneOrShowRouteSheet(activity, false);
}
service.requestVideoCall(false);
service.setVideoState(false, Instance.VIDEO_STATE_ACTIVE);
}
} else {
currentUserTextureView.saveCameraLastBitmap();
service.setVideoState(false, Instance.VIDEO_STATE_INACTIVE);
if (Build.VERSION.SDK_INT >= 21) {
service.clearCamera();
}
}
previousState = currentState;
updateViewState();
}
}
Aggregations