Add confirmation dialog for lowering a raised hand.

This commit is contained in:
Nicholas Tinsley
2023-12-11 17:37:19 -05:00
committed by Cody Henthorne
parent c2f5a6390e
commit 9ed80d46b6
17 changed files with 136 additions and 65 deletions

View File

@@ -50,7 +50,7 @@ public class BeginCallActionProcessorDelegate extends WebRtcActionProcessor {
true,
true,
false,
currentState.getCallInfoState().getRaisedHands().contains(remotePeer.getRecipient()),
CallParticipant.HAND_LOWERED,
0,
true,
0,
@@ -109,7 +109,7 @@ public class BeginCallActionProcessorDelegate extends WebRtcActionProcessor {
true,
true,
false,
currentState.getCallInfoState().getRaisedHands().contains(remotePeer.getRecipient()),
CallParticipant.HAND_LOWERED,
0,
true,
0,

View File

@@ -108,6 +108,8 @@ public class GroupActionProcessor extends DeviceAwareActionProcessor {
videoSink = new BroadcastVideoSink();
}
long handRaisedTimestamp = callParticipant != null ? callParticipant.getHandRaisedTimestamp() : CallParticipant.HAND_LOWERED;
builder.putParticipant(callParticipantId,
CallParticipant.createRemote(callParticipantId,
recipient,
@@ -116,7 +118,7 @@ public class GroupActionProcessor extends DeviceAwareActionProcessor {
device.getForwardingVideo() == null || device.getForwardingVideo(),
Boolean.FALSE.equals(device.getAudioMuted()),
Boolean.FALSE.equals(device.getVideoMuted()),
currentState.getCallInfoState().getRaisedHands().contains(recipient),
handRaisedTimestamp,
device.getSpeakerTime(),
device.getMediaKeysReceived(),
device.getAddedTime(),

View File

@@ -14,7 +14,6 @@ import org.signal.ringrtc.GroupCall;
import org.signal.ringrtc.PeekInfo;
import org.thoughtcrime.securesms.events.CallParticipant;
import org.thoughtcrime.securesms.events.CallParticipantId;
import org.thoughtcrime.securesms.events.GroupCallRaiseHandEvent;
import org.thoughtcrime.securesms.events.GroupCallReactionEvent;
import org.thoughtcrime.securesms.events.WebRtcViewModel;
import org.thoughtcrime.securesms.keyvalue.SignalStore;
@@ -24,18 +23,13 @@ import org.thoughtcrime.securesms.ringrtc.RemotePeer;
import org.thoughtcrime.securesms.service.webrtc.state.CallInfoState;
import org.thoughtcrime.securesms.service.webrtc.state.WebRtcEphemeralState;
import org.thoughtcrime.securesms.service.webrtc.state.WebRtcServiceState;
import org.thoughtcrime.securesms.service.webrtc.state.WebRtcServiceStateBuilder;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;
import ezvcard.util.StringUtils;
/**
* Process actions for when the call has at least once been connected and joined.
@@ -266,34 +260,38 @@ public class GroupConnectedActionProcessor extends GroupActionProcessor {
@Override
protected @NonNull WebRtcServiceState handleGroupCallRaisedHand(@NonNull WebRtcServiceState currentState, List<Long> raisedHands) {
Log.i(tag, "handleGroupCallRaisedHand():");
List<GroupCallRaiseHandEvent> existingHands = currentState.getCallInfoState().getRaisedHands();
Log.i(TAG, "handleGroupCallRaisedHand():");
long now = System.currentTimeMillis();
WebRtcServiceStateBuilder.CallInfoStateBuilder builder = currentState.builder().changeCallInfoState();
Long localDemuxId = currentState.getCallInfoState().requireGroupCall().getLocalDeviceState().getDemuxId();
List<CallParticipant> participants = currentState.getCallInfoState().getRemoteCallParticipants();
List<GroupCallRaiseHandEvent> currentRaisedHands = raisedHands
.stream().map(demuxId -> {
if (Objects.equals(demuxId, currentState.getCallInfoState().requireGroupCall().getLocalDeviceState().getDemuxId())) {
return Recipient.self();
}
CallParticipant participant = participants.stream().filter(it -> it.getCallParticipantId().getDemuxId() == demuxId).findFirst().orElse(null);
if (participant == null) {
Log.v(TAG, "Could not find CallParticipantId in list of call participants based on demuxId for raise hand.");
return null;
}
return participant.getRecipient();
})
.filter(Objects::nonNull)
.map(recipient -> {
final Optional<GroupCallRaiseHandEvent> matchingEvent = existingHands.stream().filter(existingEvent -> existingEvent.getSender().equals(recipient)).findFirst();
if (matchingEvent.isPresent()) {
return matchingEvent.get();
} else {
return new GroupCallRaiseHandEvent(recipient, System.currentTimeMillis());
}
})
.collect(Collectors.toList());
for (CallParticipant updatedParticipant : participants) {
boolean isHandCurrentlyRaised = raisedHands.contains(updatedParticipant.getCallParticipantId().getDemuxId());
boolean wasHandAlreadyRaised = updatedParticipant.isHandRaised();
if (isHandCurrentlyRaised && !wasHandAlreadyRaised) {
builder.putParticipant(updatedParticipant.getCallParticipantId(), updatedParticipant.withHandRaisedTimestamp(now));
} else if (!isHandCurrentlyRaised && wasHandAlreadyRaised) {
builder.putParticipant(updatedParticipant.getCallParticipantId(), updatedParticipant.withHandRaisedTimestamp(CallParticipant.HAND_LOWERED));
}
}
return currentState.builder().changeCallInfoState().setRaisedHand(currentRaisedHands).build();
if (localDemuxId != null) {
if (raisedHands.contains(localDemuxId)) {
builder.setLocalParticipant(CallParticipant.createLocal(currentState.getLocalDeviceState().getCameraState(),
currentState.getVideoState().requireLocalSink(),
currentState.getLocalDeviceState().isMicrophoneEnabled(),
now,
new CallParticipantId(localDemuxId, Recipient.self().getId())));
} else {
builder.setLocalParticipant(CallParticipant.createLocal(currentState.getLocalDeviceState().getCameraState(),
currentState.getVideoState().requireLocalSink(),
currentState.getLocalDeviceState().isMicrophoneEnabled(),
CallParticipant.HAND_LOWERED,
new CallParticipantId(localDemuxId, Recipient.self().getId())));
}
}
return builder.build();
}
}

View File

@@ -137,7 +137,7 @@ public class GroupPreJoinActionProcessor extends GroupActionProcessor {
true,
true,
true,
currentState.getCallInfoState().getRaisedHands().contains(recipient),
CallParticipant.HAND_LOWERED,
0,
false,
0,

View File

@@ -167,7 +167,7 @@ public final class IncomingGroupCallActionProcessor extends DeviceAwareActionPro
true,
true,
false,
currentState.getCallInfoState().getRaisedHands().contains(remotePeerGroup.getRecipient()),
CallParticipant.HAND_LOWERED,
0,
true,
0,

View File

@@ -5,7 +5,6 @@ import org.signal.ringrtc.CallId
import org.signal.ringrtc.GroupCall
import org.thoughtcrime.securesms.events.CallParticipant
import org.thoughtcrime.securesms.events.CallParticipantId
import org.thoughtcrime.securesms.events.GroupCallRaiseHandEvent
import org.thoughtcrime.securesms.events.WebRtcViewModel
import org.thoughtcrime.securesms.recipients.Recipient
import org.thoughtcrime.securesms.recipients.RecipientId
@@ -23,6 +22,7 @@ data class CallInfoState(
var callRecipient: Recipient = Recipient.UNKNOWN,
var callConnectedTime: Long = -1,
@get:JvmName("getRemoteCallParticipantsMap") var remoteParticipants: MutableMap<CallParticipantId, CallParticipant> = mutableMapOf(),
var localParticipant: CallParticipant? = null,
var peerMap: MutableMap<Int, RemotePeer> = mutableMapOf(),
var activePeer: RemotePeer? = null,
var groupCall: GroupCall? = null,
@@ -31,8 +31,7 @@ data class CallInfoState(
var remoteDevicesCount: OptionalLong = OptionalLong.empty(),
var participantLimit: Long? = null,
var pendingParticipants: PendingParticipantCollection = PendingParticipantCollection(),
var callLinkDisconnectReason: CallLinkDisconnectReason? = null,
var raisedHands: List<GroupCallRaiseHandEvent> = emptyList()
var callLinkDisconnectReason: CallLinkDisconnectReason? = null
) {
val remoteCallParticipants: List<CallParticipant>

View File

@@ -12,7 +12,6 @@ import org.thoughtcrime.securesms.components.webrtc.BroadcastVideoSink;
import org.thoughtcrime.securesms.components.webrtc.EglBaseWrapper;
import org.thoughtcrime.securesms.events.CallParticipant;
import org.thoughtcrime.securesms.events.CallParticipantId;
import org.thoughtcrime.securesms.events.GroupCallRaiseHandEvent;
import org.thoughtcrime.securesms.events.WebRtcViewModel;
import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.recipients.RecipientId;
@@ -366,8 +365,8 @@ public class WebRtcServiceStateBuilder {
return this;
}
public @NonNull CallInfoStateBuilder setRaisedHand(@NonNull List<GroupCallRaiseHandEvent> raisedHands) {
toBuild.setRaisedHands(raisedHands);
public @NonNull CallInfoStateBuilder setLocalParticipant(@NonNull CallParticipant callParticipant) {
toBuild.setLocalParticipant(callParticipant);
return this;
}
}