mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-22 01:40:07 +01:00
Convert CallParticipantId to Kotlin.
This commit is contained in:
@@ -69,11 +69,11 @@ public final class CallParticipantListUpdate {
|
||||
@NonNull List<CallParticipant> newList)
|
||||
{
|
||||
Set<CallParticipantListUpdate.Wrapper> oldParticipants = Stream.of(oldList)
|
||||
.filter(p -> p.getCallParticipantId().getDemuxId() != CallParticipantId.DEFAULT_ID)
|
||||
.filter(p -> p.getCallParticipantId().demuxId != CallParticipantId.DEFAULT_ID)
|
||||
.map(CallParticipantListUpdate::createWrapper)
|
||||
.collect(Collectors.toSet());
|
||||
Set<CallParticipantListUpdate.Wrapper> newParticipants = Stream.of(newList)
|
||||
.filter(p -> p.getCallParticipantId().getDemuxId() != CallParticipantId.DEFAULT_ID)
|
||||
.filter(p -> p.getCallParticipantId().demuxId != CallParticipantId.DEFAULT_ID)
|
||||
.map(CallParticipantListUpdate::createWrapper)
|
||||
.collect(Collectors.toSet());
|
||||
Set<CallParticipantListUpdate.Wrapper> added = SetUtil.difference(newParticipants, oldParticipants);
|
||||
|
||||
@@ -1,90 +0,0 @@
|
||||
package org.thoughtcrime.securesms.events;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.os.ParcelCompat;
|
||||
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.recipients.RecipientId;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Allow system to identify a call participant by their device demux id and their
|
||||
* recipient id.
|
||||
*/
|
||||
public final class CallParticipantId implements Parcelable {
|
||||
|
||||
public static final long DEFAULT_ID = -1;
|
||||
|
||||
private final long demuxId;
|
||||
private final RecipientId recipientId;
|
||||
|
||||
public CallParticipantId(@NonNull Recipient recipient) {
|
||||
this(DEFAULT_ID, recipient.getId());
|
||||
}
|
||||
|
||||
public CallParticipantId(long demuxId, @NonNull RecipientId recipientId) {
|
||||
this.demuxId = demuxId;
|
||||
this.recipientId = recipientId;
|
||||
}
|
||||
|
||||
public long getDemuxId() {
|
||||
return demuxId;
|
||||
}
|
||||
|
||||
public @NonNull RecipientId getRecipientId() {
|
||||
return recipientId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
final CallParticipantId that = (CallParticipantId) o;
|
||||
return demuxId == that.demuxId &&
|
||||
recipientId.equals(that.recipientId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(demuxId, recipientId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(@NonNull Parcel dest, int flags) {
|
||||
dest.writeLong(demuxId);
|
||||
dest.writeParcelable(recipientId, flags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull String toString() {
|
||||
return "CallParticipantId(demuxId=" + demuxId + ", recipientId=" + recipientId + ')';
|
||||
}
|
||||
|
||||
public static final Parcelable.Creator<CallParticipantId> CREATOR = new Parcelable.Creator<CallParticipantId>() {
|
||||
@Override
|
||||
public CallParticipantId createFromParcel(Parcel in) {
|
||||
return new CallParticipantId(
|
||||
in.readLong(),
|
||||
Objects.requireNonNull(
|
||||
ParcelCompat.readParcelable(in,
|
||||
RecipientId.class.getClassLoader(),
|
||||
RecipientId.class)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CallParticipantId[] newArray(int size) {
|
||||
return new CallParticipantId[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package org.thoughtcrime.securesms.events
|
||||
|
||||
import android.os.Parcelable
|
||||
import kotlinx.parcelize.Parcelize
|
||||
import org.thoughtcrime.securesms.recipients.Recipient
|
||||
import org.thoughtcrime.securesms.recipients.RecipientId
|
||||
|
||||
/**
|
||||
* Allow system to identify a call participant by their device demux id and their
|
||||
* recipient id.
|
||||
*/
|
||||
@Parcelize
|
||||
data class CallParticipantId(@JvmField val demuxId: Long, val recipientId: RecipientId) : Parcelable {
|
||||
constructor(recipient: Recipient) : this(DEFAULT_ID, recipient.id)
|
||||
|
||||
companion object {
|
||||
const val DEFAULT_ID: Long = -1
|
||||
}
|
||||
}
|
||||
@@ -204,7 +204,7 @@ public class GroupActionProcessor extends DeviceAwareActionProcessor {
|
||||
BroadcastVideoSink videoSink = entry.getValue().getVideoSink();
|
||||
BroadcastVideoSink.RequestedSize maxSize = videoSink.getMaxRequestingSize();
|
||||
|
||||
resolutionRequests.add(new GroupCall.VideoRequest(entry.getKey().getDemuxId(), maxSize.getWidth(), maxSize.getHeight(), null));
|
||||
resolutionRequests.add(new GroupCall.VideoRequest(entry.getKey().demuxId, maxSize.getWidth(), maxSize.getHeight(), null));
|
||||
videoSink.setCurrentlyRequestedMaxSize(maxSize);
|
||||
}
|
||||
|
||||
|
||||
@@ -135,7 +135,7 @@ public class GroupConnectedActionProcessor extends GroupActionProcessor {
|
||||
}
|
||||
|
||||
for (Map.Entry<CallParticipantId, CallParticipant> entry : participants.entrySet()) {
|
||||
if (entry.getKey().getDemuxId() == sourceDemuxId) {
|
||||
if (entry.getKey().demuxId == sourceDemuxId) {
|
||||
try {
|
||||
groupCall.setOutgoingAudioMutedRemotely(sourceDemuxId);
|
||||
} catch (CallException e) {
|
||||
@@ -161,7 +161,7 @@ public class GroupConnectedActionProcessor extends GroupActionProcessor {
|
||||
source = Recipient.self();
|
||||
} else {
|
||||
for (Map.Entry<CallParticipantId, CallParticipant> entry : participants.entrySet()) {
|
||||
if (entry.getKey().getDemuxId() == sourceDemuxId) {
|
||||
if (entry.getKey().demuxId == sourceDemuxId) {
|
||||
source = entry.getValue().getRecipient();
|
||||
}
|
||||
}
|
||||
@@ -172,7 +172,7 @@ public class GroupConnectedActionProcessor extends GroupActionProcessor {
|
||||
}
|
||||
|
||||
for (Map.Entry<CallParticipantId, CallParticipant> entry : participants.entrySet()) {
|
||||
if (entry.getKey().getDemuxId() == targetDemuxId) {
|
||||
if (entry.getKey().demuxId == targetDemuxId) {
|
||||
WebRtcServiceStateBuilder.CallInfoStateBuilder builder = currentState.builder().changeCallInfoState().putParticipant(entry.getKey(), entry.getValue().withRemotelyMutedBy(source));
|
||||
return builder.build();
|
||||
}
|
||||
@@ -193,7 +193,7 @@ public class GroupConnectedActionProcessor extends GroupActionProcessor {
|
||||
CallParticipantId callParticipantId = participant.getCallParticipantId();
|
||||
|
||||
if (remoteDeviceStates != null) {
|
||||
GroupCall.RemoteDeviceState state = remoteDeviceStates.get(callParticipantId.getDemuxId());
|
||||
GroupCall.RemoteDeviceState state = remoteDeviceStates.get(callParticipantId.demuxId);
|
||||
if (state != null) {
|
||||
remoteAudioLevels.put(callParticipantId, CallParticipant.AudioLevel.fromRawAudioLevel(state.getAudioLevel()));
|
||||
}
|
||||
@@ -308,7 +308,7 @@ public class GroupConnectedActionProcessor extends GroupActionProcessor {
|
||||
|
||||
@Nullable
|
||||
private GroupCallReactionEvent createGroupCallReaction(Collection<CallParticipant> participants, final GroupCall.Reaction reaction) {
|
||||
CallParticipant participant = participants.stream().filter(it -> it.getCallParticipantId().getDemuxId() == reaction.demuxId).findFirst().orElse(null);
|
||||
CallParticipant participant = participants.stream().filter(it -> it.getCallParticipantId().demuxId == reaction.demuxId).findFirst().orElse(null);
|
||||
if (participant == null) {
|
||||
Log.v(TAG, "Could not find CallParticipantId in list of call participants based on demuxId for reaction.");
|
||||
return null;
|
||||
@@ -329,7 +329,7 @@ public class GroupConnectedActionProcessor extends GroupActionProcessor {
|
||||
List<CallParticipant> participants = currentState.getCallInfoState().getRemoteCallParticipants();
|
||||
|
||||
for (CallParticipant updatedParticipant : participants) {
|
||||
int raisedHandIndex = raisedHands.indexOf(updatedParticipant.getCallParticipantId().getDemuxId());
|
||||
int raisedHandIndex = raisedHands.indexOf(updatedParticipant.getCallParticipantId().demuxId);
|
||||
boolean wasHandAlreadyRaised = updatedParticipant.isHandRaised();
|
||||
|
||||
if (wasHandAlreadyRaised) {
|
||||
|
||||
Reference in New Issue
Block a user