Better support for building webrtc call view off of model

Fixes #6144
// FREEBIE
This commit is contained in:
Moxie Marlinspike
2017-02-02 18:34:51 -08:00
parent 8dc6f2b15b
commit 9a93a8b28d
7 changed files with 207 additions and 166 deletions

View File

@@ -1,52 +0,0 @@
package org.thoughtcrime.securesms.events;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import org.thoughtcrime.securesms.recipients.Recipient;
public class WebRtcCallEvent {
public enum Type {
CALL_CONNECTED,
WAITING_FOR_RESPONDER,
SERVER_FAILURE,
PERFORMING_HANDSHAKE,
HANDSHAKE_FAILED,
CONNECTING_TO_INITIATOR,
CALL_DISCONNECTED,
CALL_RINGING,
RECIPIENT_UNAVAILABLE,
INCOMING_CALL,
OUTGOING_CALL,
CALL_BUSY,
LOGIN_FAILED,
DEBUG_INFO,
NO_SUCH_USER,
REMOTE_VIDEO_ENABLED,
REMOTE_VIDEO_DISABLED,
UNTRUSTED_IDENTITY
}
private final @NonNull Type type;
private final @NonNull Recipient recipient;
private final @Nullable Object extra;
public WebRtcCallEvent(@NonNull Type type, @NonNull Recipient recipient, @Nullable Object extra) {
this.type = type;
this.recipient = recipient;
this.extra = extra;
}
public @NonNull Type getType() {
return type;
}
public @NonNull Recipient getRecipient() {
return recipient;
}
public @Nullable Object getExtra() {
return extra;
}
}

View File

@@ -0,0 +1,74 @@
package org.thoughtcrime.securesms.events;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import org.thoughtcrime.securesms.recipients.Recipient;
import org.whispersystems.libsignal.IdentityKey;
public class WebRtcViewModel {
public enum State {
// Normal states
CALL_INCOMING,
CALL_OUTGOING,
CALL_CONNECTED,
CALL_RINGING,
CALL_BUSY,
CALL_DISCONNECTED,
// Error states
NETWORK_FAILURE,
RECIPIENT_UNAVAILABLE,
NO_SUCH_USER,
UNTRUSTED_IDENTITY,
}
private final @NonNull State state;
private final @NonNull Recipient recipient;
private final @Nullable IdentityKey identityKey;
private final boolean remoteVideoEnabled;
private final boolean localVideoEnabled;
public WebRtcViewModel(@NonNull State state, @NonNull Recipient recipient, boolean localVideoEnabled, boolean remoteVideoEnabled) {
this(state, recipient, null, localVideoEnabled, remoteVideoEnabled);
}
public WebRtcViewModel(@NonNull State state, @NonNull Recipient recipient,
@Nullable IdentityKey identityKey,
boolean localVideoEnabled, boolean remoteVideoEnabled)
{
this.state = state;
this.recipient = recipient;
this.identityKey = identityKey;
this.localVideoEnabled = localVideoEnabled;
this.remoteVideoEnabled = remoteVideoEnabled;
}
public @NonNull State getState() {
return state;
}
public @NonNull Recipient getRecipient() {
return recipient;
}
@Nullable
public IdentityKey getIdentityKey() {
return identityKey;
}
public boolean isRemoteVideoEnabled() {
return remoteVideoEnabled;
}
public boolean isLocalVideoEnabled() {
return localVideoEnabled;
}
public String toString() {
return "[State: " + state + ", recipient: " + recipient.getNumber() + ", identity: " + identityKey + ", remoteVideo: " + remoteVideoEnabled + ", localVideo: " + localVideoEnabled + "]";
}
}