Search in sources :

Example 6 with CallParticipantsState

use of org.thoughtcrime.securesms.components.webrtc.CallParticipantsState in project Signal-Android by signalapp.

the class WebRtcCallActivity method onPause.

@Override
public void onPause() {
    Log.i(TAG, "onPause");
    super.onPause();
    if (!isInPipMode() || isFinishing()) {
        EventBus.getDefault().unregister(this);
    }
    if (!viewModel.isCallStarting()) {
        CallParticipantsState state = viewModel.getCallParticipantsState().getValue();
        if (state != null && state.getCallState().isPreJoinOrNetworkUnavailable()) {
            finish();
        }
    }
}
Also used : CallParticipantsState(org.thoughtcrime.securesms.components.webrtc.CallParticipantsState)

Example 7 with CallParticipantsState

use of org.thoughtcrime.securesms.components.webrtc.CallParticipantsState in project Signal-Android by signalapp.

the class WebRtcCallActivity method initializeViewModel.

private void initializeViewModel(boolean isLandscapeEnabled) {
    deviceOrientationMonitor = new DeviceOrientationMonitor(this);
    getLifecycle().addObserver(deviceOrientationMonitor);
    WebRtcCallViewModel.Factory factory = new WebRtcCallViewModel.Factory(deviceOrientationMonitor);
    viewModel = ViewModelProviders.of(this, factory).get(WebRtcCallViewModel.class);
    viewModel.setIsLandscapeEnabled(isLandscapeEnabled);
    viewModel.setIsInPipMode(isInPipMode());
    viewModel.getMicrophoneEnabled().observe(this, callScreen::setMicEnabled);
    viewModel.getWebRtcControls().observe(this, callScreen::setWebRtcControls);
    viewModel.getEvents().observe(this, this::handleViewModelEvent);
    viewModel.getCallTime().observe(this, this::handleCallTime);
    LiveDataUtil.combineLatest(viewModel.getCallParticipantsState(), viewModel.getOrientationAndLandscapeEnabled(), (s, o) -> new CallParticipantsViewState(s, o.first == PORTRAIT_BOTTOM_EDGE, o.second)).observe(this, p -> callScreen.updateCallParticipants(p));
    viewModel.getCallParticipantListUpdate().observe(this, participantUpdateWindow::addCallParticipantListUpdate);
    viewModel.getSafetyNumberChangeEvent().observe(this, this::handleSafetyNumberChangeEvent);
    viewModel.getGroupMembersChanged().observe(this, unused -> updateGroupMembersForGroupCall());
    viewModel.getGroupMemberCount().observe(this, this::handleGroupMemberCountChange);
    viewModel.shouldShowSpeakerHint().observe(this, this::updateSpeakerHint);
    callScreen.getViewTreeObserver().addOnGlobalLayoutListener(() -> {
        CallParticipantsState state = viewModel.getCallParticipantsState().getValue();
        if (state != null) {
            if (state.needsNewRequestSizes()) {
                requestNewSizesThrottle.publish(() -> ApplicationDependencies.getSignalCallManager().updateRenderedResolutions());
            }
        }
    });
    viewModel.getOrientationAndLandscapeEnabled().observe(this, pair -> ApplicationDependencies.getSignalCallManager().orientationChanged(pair.second, pair.first.getDegrees()));
    viewModel.getControlsRotation().observe(this, callScreen::rotateControls);
}
Also used : SignalAudioManager(org.thoughtcrime.securesms.webrtc.audio.SignalAudioManager) Rect(android.graphics.Rect) Bundle(android.os.Bundle) MessageSender(org.thoughtcrime.securesms.sms.MessageSender) PackageManager(android.content.pm.PackageManager) NonNull(androidx.annotation.NonNull) WindowManager(android.view.WindowManager) Manifest(android.Manifest) RecipientId(org.thoughtcrime.securesms.recipients.RecipientId) CallParticipantsListUpdatePopupWindow(org.thoughtcrime.securesms.components.webrtc.CallParticipantsListUpdatePopupWindow) WebRtcControls(org.thoughtcrime.securesms.components.webrtc.WebRtcControls) ActivityInfo(android.content.pm.ActivityInfo) WebRtcCallViewModel(org.thoughtcrime.securesms.components.webrtc.WebRtcCallViewModel) ViewModelProviders(androidx.lifecycle.ViewModelProviders) Recipient(org.thoughtcrime.securesms.recipients.Recipient) ContextCompat(androidx.core.content.ContextCompat) SignalExecutors(org.signal.core.util.concurrent.SignalExecutors) ApplicationDependencies(org.thoughtcrime.securesms.dependencies.ApplicationDependencies) WebRtcAudioOutput(org.thoughtcrime.securesms.components.webrtc.WebRtcAudioOutput) SignalCallManager(org.thoughtcrime.securesms.service.webrtc.SignalCallManager) ThreadMode(org.greenrobot.eventbus.ThreadMode) DeviceOrientationMonitor(org.thoughtcrime.securesms.components.sensors.DeviceOrientationMonitor) IdentityKey(org.whispersystems.libsignal.IdentityKey) Consumer(androidx.core.util.Consumer) Log(org.signal.core.util.logging.Log) EllapsedTimeFormatter(org.thoughtcrime.securesms.util.EllapsedTimeFormatter) FeatureFlags(org.thoughtcrime.securesms.util.FeatureFlags) List(java.util.List) Rational(android.util.Rational) FoldingFeature(androidx.window.FoldingFeature) Optional(java.util.Optional) PictureInPictureParams(android.app.PictureInPictureParams) Window(android.view.Window) Context(android.content.Context) AlertDialog(androidx.appcompat.app.AlertDialog) WindowLayoutInfo(androidx.window.WindowLayoutInfo) Util(org.thoughtcrime.securesms.util.Util) Intent(android.content.Intent) CallParticipantsViewState(org.thoughtcrime.securesms.webrtc.CallParticipantsViewState) GroupCallSafetyNumberChangeNotificationUtil(org.thoughtcrime.securesms.components.webrtc.GroupCallSafetyNumberChangeNotificationUtil) AudioManager(android.media.AudioManager) TextSecurePreferences(org.thoughtcrime.securesms.util.TextSecurePreferences) TooltipPopup(org.thoughtcrime.securesms.components.TooltipPopup) SuppressLint(android.annotation.SuppressLint) CallParticipantsListDialog(org.thoughtcrime.securesms.components.webrtc.participantslist.CallParticipantsListDialog) HangupMessage(org.whispersystems.signalservice.api.messages.calls.HangupMessage) Toast(android.widget.Toast) EventBus(org.greenrobot.eventbus.EventBus) DisplayFeature(androidx.window.DisplayFeature) Build(android.os.Build) CalleeMustAcceptMessageRequestActivity(org.thoughtcrime.securesms.messagerequests.CalleeMustAcceptMessageRequestActivity) WebRtcViewModel(org.thoughtcrime.securesms.events.WebRtcViewModel) WebRtcCallView(org.thoughtcrime.securesms.components.webrtc.WebRtcCallView) FullscreenHelper(org.thoughtcrime.securesms.util.FullscreenHelper) AppCompatDelegate(androidx.appcompat.app.AppCompatDelegate) Permissions(org.thoughtcrime.securesms.permissions.Permissions) SafetyNumberChangeDialog(org.thoughtcrime.securesms.conversation.ui.error.SafetyNumberChangeDialog) TimeUnit(java.util.concurrent.TimeUnit) PORTRAIT_BOTTOM_EDGE(org.thoughtcrime.securesms.components.sensors.Orientation.PORTRAIT_BOTTOM_EDGE) Subscribe(org.greenrobot.eventbus.Subscribe) Configuration(android.content.res.Configuration) CallToastPopupWindow(org.thoughtcrime.securesms.components.webrtc.CallToastPopupWindow) CallParticipantsState(org.thoughtcrime.securesms.components.webrtc.CallParticipantsState) ThrottledDebouncer(org.thoughtcrime.securesms.util.ThrottledDebouncer) LiveDataUtil(org.thoughtcrime.securesms.util.livedata.LiveDataUtil) CallParticipantsViewState(org.thoughtcrime.securesms.webrtc.CallParticipantsViewState) DeviceOrientationMonitor(org.thoughtcrime.securesms.components.sensors.DeviceOrientationMonitor) WebRtcCallViewModel(org.thoughtcrime.securesms.components.webrtc.WebRtcCallViewModel) CallParticipantsState(org.thoughtcrime.securesms.components.webrtc.CallParticipantsState)

Example 8 with CallParticipantsState

use of org.thoughtcrime.securesms.components.webrtc.CallParticipantsState in project Signal-Android by signalapp.

the class WebRtcCallActivity method onCanceled.

@Override
public void onCanceled() {
    CallParticipantsState state = viewModel.getCallParticipantsState().getValue();
    if (state != null && state.getGroupCallState().isNotIdle()) {
        if (state.getCallState().isPreJoinOrNetworkUnavailable()) {
            ApplicationDependencies.getSignalCallManager().cancelPreJoin();
            finish();
        } else {
            handleEndCall();
        }
    } else {
        handleTerminate(viewModel.getRecipient().get(), HangupMessage.Type.NORMAL);
    }
}
Also used : CallParticipantsState(org.thoughtcrime.securesms.components.webrtc.CallParticipantsState)

Aggregations

CallParticipantsState (org.thoughtcrime.securesms.components.webrtc.CallParticipantsState)8 Manifest (android.Manifest)2 SuppressLint (android.annotation.SuppressLint)2 PictureInPictureParams (android.app.PictureInPictureParams)2 Context (android.content.Context)2 Intent (android.content.Intent)2 ActivityInfo (android.content.pm.ActivityInfo)2 PackageManager (android.content.pm.PackageManager)2 Configuration (android.content.res.Configuration)2 Rect (android.graphics.Rect)2 AudioManager (android.media.AudioManager)2 Build (android.os.Build)2 Bundle (android.os.Bundle)2 Rational (android.util.Rational)2 Window (android.view.Window)2 WindowManager (android.view.WindowManager)2 Toast (android.widget.Toast)2 NonNull (androidx.annotation.NonNull)2 AlertDialog (androidx.appcompat.app.AlertDialog)2 AppCompatDelegate (androidx.appcompat.app.AppCompatDelegate)2