130 lines
6.8 KiB
Java
130 lines
6.8 KiB
Java
package com.discord.utilities.voice;
|
|
|
|
import android.content.Context;
|
|
import android.os.Build;
|
|
import androidx.annotation.ColorInt;
|
|
import androidx.annotation.DrawableRes;
|
|
import c.a.k.b;
|
|
import com.discord.R;
|
|
import com.discord.rtcconnection.RtcConnection;
|
|
import com.discord.utilities.color.ColorCompat;
|
|
import com.discord.utilities.streams.StreamContext;
|
|
import d0.z.d.m;
|
|
import kotlin.NoWhenBranchMatchedException;
|
|
/* compiled from: VoiceViewUtils.kt */
|
|
public final class VoiceViewUtils {
|
|
public static final VoiceViewUtils INSTANCE = new VoiceViewUtils();
|
|
|
|
public final /* synthetic */ class WhenMappings {
|
|
public static final /* synthetic */ int[] $EnumSwitchMapping$0;
|
|
public static final /* synthetic */ int[] $EnumSwitchMapping$1;
|
|
|
|
static {
|
|
RtcConnection.Quality.values();
|
|
int[] iArr = new int[4];
|
|
$EnumSwitchMapping$0 = iArr;
|
|
RtcConnection.Quality quality = RtcConnection.Quality.BAD;
|
|
iArr[quality.ordinal()] = 1;
|
|
RtcConnection.Quality quality2 = RtcConnection.Quality.AVERAGE;
|
|
iArr[quality2.ordinal()] = 2;
|
|
RtcConnection.Quality quality3 = RtcConnection.Quality.FINE;
|
|
iArr[quality3.ordinal()] = 3;
|
|
RtcConnection.Quality quality4 = RtcConnection.Quality.UNKNOWN;
|
|
iArr[quality4.ordinal()] = 4;
|
|
RtcConnection.Quality.values();
|
|
int[] iArr2 = new int[4];
|
|
$EnumSwitchMapping$1 = iArr2;
|
|
iArr2[quality.ordinal()] = 1;
|
|
iArr2[quality2.ordinal()] = 2;
|
|
iArr2[quality3.ordinal()] = 3;
|
|
iArr2[quality4.ordinal()] = 4;
|
|
}
|
|
}
|
|
|
|
private VoiceViewUtils() {
|
|
}
|
|
|
|
public static /* synthetic */ CharSequence getConnectedText$default(VoiceViewUtils voiceViewUtils, Context context, RtcConnection.State state, StreamContext streamContext, boolean z2, int i, Object obj) {
|
|
if ((i & 8) != 0) {
|
|
z2 = false;
|
|
}
|
|
return voiceViewUtils.getConnectedText(context, state, streamContext, z2);
|
|
}
|
|
|
|
public final int getCallIndicatorIcon(boolean z2, StreamContext streamContext) {
|
|
return (streamContext == null || !streamContext.isCurrentUserParticipating()) ? z2 ? R.drawable.ic_videocam_white_16dp : R.drawable.ic_call_indicator_voice_16dp : streamContext.isSelfStream() ? R.drawable.ic_call_indicator_mobile_screenshare_16dp : R.drawable.ic_call_indicator_streaming_16dp;
|
|
}
|
|
|
|
/* JADX DEBUG: Can't convert new array creation: APUT found in different block: 0x0039: APUT (r2v1 java.lang.Object[]), (0 ??[int, short, byte, char]), (r3v1 java.lang.String) */
|
|
public final CharSequence getConnectedText(Context context, RtcConnection.State state, StreamContext streamContext, boolean z2) {
|
|
int i;
|
|
m.checkNotNullParameter(context, "context");
|
|
RtcConnection.State.f fVar = RtcConnection.State.f.a;
|
|
if (state != fVar || streamContext == null || !streamContext.isCurrentUserParticipating()) {
|
|
if (m.areEqual(state, RtcConnection.State.c.a)) {
|
|
i = R.string.connection_status_connecting;
|
|
} else if (m.areEqual(state, RtcConnection.State.e.a)) {
|
|
i = R.string.connection_status_no_route;
|
|
} else if (m.areEqual(state, RtcConnection.State.b.a)) {
|
|
i = R.string.connection_status_awaiting_endpoint;
|
|
} else if (m.areEqual(state, RtcConnection.State.a.a)) {
|
|
i = R.string.connection_status_authenticating;
|
|
} else if (m.areEqual(state, RtcConnection.State.g.a)) {
|
|
i = R.string.connection_status_rtc_connecting;
|
|
} else if (m.areEqual(state, fVar)) {
|
|
i = z2 ? R.string.connection_status_video_connected : R.string.connection_status_voice_connected;
|
|
} else if (!(state instanceof RtcConnection.State.d) && !m.areEqual(state, RtcConnection.State.h.a) && state != null) {
|
|
throw new NoWhenBranchMatchedException();
|
|
} else {
|
|
i = R.string.connection_status_disconnected;
|
|
}
|
|
String string = context.getString(i);
|
|
m.checkNotNullExpressionValue(string, "context.getString(resId)");
|
|
return string;
|
|
} else if (streamContext.isSelfStream()) {
|
|
return b.h(context, R.string.connection_status_stream_self_connected, new Object[0], null, 4);
|
|
} else {
|
|
Object[] objArr = new Object[1];
|
|
String userNickname = streamContext.getUserNickname();
|
|
if (userNickname == null) {
|
|
userNickname = streamContext.getUser().getUsername();
|
|
}
|
|
objArr[0] = userNickname;
|
|
return b.h(context, R.string.connection_status_stream_connected, objArr, null, 4);
|
|
}
|
|
}
|
|
|
|
/* JADX WARNING: Code restructure failed: missing block: B:11:0x0026, code lost:
|
|
if (r5 != 3) goto L_0x0028;
|
|
*/
|
|
@ColorInt
|
|
public final int getConnectionStatusColor(RtcConnection.State state, RtcConnection.Quality quality, Context context) {
|
|
m.checkNotNullParameter(context, "context");
|
|
if (!m.areEqual(state, RtcConnection.State.f.a)) {
|
|
return (!m.areEqual(state, RtcConnection.State.b.a) && !m.areEqual(state, RtcConnection.State.c.a) && !m.areEqual(state, RtcConnection.State.a.a) && !m.areEqual(state, RtcConnection.State.g.a)) ? m.areEqual(state, RtcConnection.State.e.a) ? ColorCompat.getColor(context, (int) R.color.status_red_500) : (!(state instanceof RtcConnection.State.d) && !m.areEqual(state, RtcConnection.State.h.a)) ? ColorCompat.getColor(context, (int) R.color.status_red_500) : ColorCompat.getColor(context, (int) R.color.status_red_500) : ColorCompat.getColor(context, (int) R.color.status_yellow_500);
|
|
}
|
|
if (quality != null) {
|
|
int ordinal = quality.ordinal();
|
|
if (ordinal != 0) {
|
|
if (ordinal == 1) {
|
|
return ColorCompat.getColor(context, (int) R.color.status_red_500);
|
|
}
|
|
if (ordinal == 2) {
|
|
return ColorCompat.getColor(context, (int) R.color.status_yellow_500);
|
|
}
|
|
}
|
|
return ColorCompat.getColor(context, (int) R.color.status_green_600);
|
|
}
|
|
return ColorCompat.getColor(context, (int) R.color.status_green_600);
|
|
}
|
|
|
|
public final boolean getIsSoundshareSupported() {
|
|
return Build.VERSION.SDK_INT >= 29;
|
|
}
|
|
|
|
@DrawableRes
|
|
public final int getQualityIndicator(RtcConnection.Quality quality) {
|
|
int ordinal;
|
|
return (quality == null || (ordinal = quality.ordinal()) == 0) ? R.drawable.ic_voice_quality_unknown : ordinal != 1 ? ordinal != 2 ? ordinal != 3 ? R.drawable.ic_voice_quality_unknown : R.drawable.ic_voice_quality_fine : R.drawable.ic_voice_quality_average : R.drawable.ic_voice_quality_bad;
|
|
}
|
|
}
|