mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-05-04 07:25:25 +01:00
committed by
jeffrey-signal
parent
469421fcf3
commit
e6cbb0073c
@@ -3,9 +3,6 @@ package org.thoughtcrime.securesms.service.webrtc.collections;
|
||||
import androidx.annotation.CheckResult;
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.annimon.stream.ComparatorCompat;
|
||||
import com.annimon.stream.Stream;
|
||||
|
||||
import org.thoughtcrime.securesms.events.CallParticipant;
|
||||
import org.thoughtcrime.securesms.events.CallParticipantId;
|
||||
|
||||
@@ -34,9 +31,9 @@ public class ParticipantCollection {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
private static final Comparator<CallParticipant> COMPLEX_COMPARATOR_CHAIN = ComparatorCompat.chain(HAND_RAISED)
|
||||
.thenComparing(MOST_RECENTLY_SPOKEN)
|
||||
.thenComparing(LEAST_RECENTLY_ADDED);
|
||||
private static final Comparator<CallParticipant> COMPLEX_COMPARATOR_CHAIN = HAND_RAISED
|
||||
.thenComparing(MOST_RECENTLY_SPOKEN)
|
||||
.thenComparing(LEAST_RECENTLY_ADDED);
|
||||
|
||||
private final int maxGridCellCount;
|
||||
private final List<CallParticipant> participants;
|
||||
@@ -63,18 +60,18 @@ public class ParticipantCollection {
|
||||
List<CallParticipant> newParticipants = new ArrayList<>(participants);
|
||||
Collections.sort(newParticipants, COMPLEX_COMPARATOR_CHAIN);
|
||||
|
||||
List<CallParticipantId> oldGridParticipantIds = Stream.of(getGridParticipants())
|
||||
.map(CallParticipant::getCallParticipantId)
|
||||
.toList();
|
||||
List<CallParticipantId> oldGridParticipantIds = getGridParticipants().stream()
|
||||
.map(CallParticipant::getCallParticipantId)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
for (int i = 0; i < oldGridParticipantIds.size(); i++) {
|
||||
CallParticipantId oldId = oldGridParticipantIds.get(i);
|
||||
|
||||
int newIndex = Stream.of(newParticipants)
|
||||
.takeUntilIndexed((j, p) -> j >= maxGridCellCount)
|
||||
.map(CallParticipant::getCallParticipantId)
|
||||
.toList()
|
||||
.indexOf(oldId);
|
||||
int newIndex = newParticipants.stream()
|
||||
.limit(maxGridCellCount)
|
||||
.map(CallParticipant::getCallParticipantId)
|
||||
.collect(Collectors.toList())
|
||||
.indexOf(oldId);
|
||||
|
||||
if (newIndex != -1 && newIndex != i) {
|
||||
Collections.swap(newParticipants, newIndex, Math.min(i, newParticipants.size() - 1));
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package org.thoughtcrime.securesms.service.webrtc.state
|
||||
|
||||
import com.annimon.stream.OptionalLong
|
||||
import org.signal.ringrtc.CallId
|
||||
import org.signal.ringrtc.CallManager.CallEndReason
|
||||
import org.signal.ringrtc.GroupCall
|
||||
@@ -13,6 +12,7 @@ import org.thoughtcrime.securesms.recipients.RecipientId
|
||||
import org.thoughtcrime.securesms.ringrtc.RemotePeer
|
||||
import org.thoughtcrime.securesms.service.webrtc.CallLinkDisconnectReason
|
||||
import org.thoughtcrime.securesms.service.webrtc.PendingParticipantCollection
|
||||
import java.util.Optional
|
||||
|
||||
/**
|
||||
* General state of ongoing calls.
|
||||
@@ -29,7 +29,7 @@ data class CallInfoState(
|
||||
var groupCall: GroupCall? = null,
|
||||
@get:JvmName("getGroupCallState") var groupState: WebRtcViewModel.GroupCallState = WebRtcViewModel.GroupCallState.IDLE,
|
||||
var identityChangedRecipients: MutableSet<RecipientId> = mutableSetOf(),
|
||||
var remoteDevicesCount: OptionalLong = OptionalLong.empty(),
|
||||
var remoteDevicesCount: Optional<Long> = Optional.empty(),
|
||||
var participantLimit: Long? = null,
|
||||
var pendingParticipants: PendingParticipantCollection = PendingParticipantCollection(),
|
||||
var callLinkDisconnectReason: CallLinkDisconnectReason? = null,
|
||||
|
||||
@@ -3,8 +3,6 @@ package org.thoughtcrime.securesms.service.webrtc.state;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.annimon.stream.OptionalLong;
|
||||
|
||||
import org.checkerframework.checker.units.qual.N;
|
||||
import org.signal.ringrtc.CallId;
|
||||
import org.signal.ringrtc.CallManager;
|
||||
@@ -28,6 +26,7 @@ import org.webrtc.PeerConnection;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
@@ -359,7 +358,7 @@ public class WebRtcServiceStateBuilder {
|
||||
}
|
||||
|
||||
public @NonNull CallInfoStateBuilder remoteDevicesCount(long remoteDevicesCount) {
|
||||
toBuild.setRemoteDevicesCount(OptionalLong.of(remoteDevicesCount));
|
||||
toBuild.setRemoteDevicesCount(Optional.of(remoteDevicesCount));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user