discord-jadx/app/src/main/java/com/discord/widgets/voice/controls/AnchoredVoiceControlsView.java

256 lines
15 KiB
Java

package com.discord.widgets.voice.controls;
import android.content.Context;
import android.content.res.ColorStateList;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import androidx.fragment.app.FragmentManager;
import c.a.j.a;
import com.discord.app.AppComponent;
import com.discord.app.AppLog;
import com.discord.databinding.AnchoredVoiceControlsViewBinding;
import com.discord.floating_view_manager.FloatingViewGravity;
import com.discord.rtcconnection.mediaengine.MediaEngineConnection;
import com.discord.stores.StoreAudioDevices;
import com.discord.tooltips.SparkleView;
import com.discord.tooltips.TooltipManager;
import com.discord.utilities.color.ColorCompat;
import com.discord.utilities.press.OnPressListener;
import com.discord.widgets.voice.model.CameraState;
import com.discord.widgets.voice.sheet.WidgetVoiceBottomSheet;
import com.google.android.material.button.MaterialButton;
import d0.z.d.m;
import java.lang.ref.WeakReference;
import java.util.Objects;
import java.util.Set;
import kotlin.Unit;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.DefaultConstructorMarker;
import rx.Observable;
/* compiled from: AnchoredVoiceControlsView.kt */
public final class AnchoredVoiceControlsView extends FrameLayout {
private final AnchoredVoiceControlsViewBinding binding;
private final TooltipManager tooltipManager;
public final /* synthetic */ class WhenMappings {
public static final /* synthetic */ int[] $EnumSwitchMapping$0;
static {
MediaEngineConnection.InputMode.values();
int[] iArr = new int[2];
$EnumSwitchMapping$0 = iArr;
iArr[MediaEngineConnection.InputMode.PUSH_TO_TALK.ordinal()] = 1;
}
}
public AnchoredVoiceControlsView(Context context) {
this(context, null, 0, 6, null);
}
public AnchoredVoiceControlsView(Context context, AttributeSet attributeSet) {
this(context, attributeSet, 0, 4, null);
}
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public AnchoredVoiceControlsView(Context context, AttributeSet attributeSet, int i) {
super(context, attributeSet, i);
m.checkNotNullParameter(context, "context");
View inflate = LayoutInflater.from(context).inflate(2131558432, (ViewGroup) this, false);
addView(inflate);
int i2 = 2131365689;
ImageView imageView = (ImageView) inflate.findViewById(2131365689);
if (imageView != null) {
i2 = 2131365690;
LinearLayout linearLayout = (LinearLayout) inflate.findViewById(2131365690);
if (linearLayout != null) {
i2 = 2131365691;
ImageView imageView2 = (ImageView) inflate.findViewById(2131365691);
if (imageView2 != null) {
i2 = 2131365692;
ImageView imageView3 = (ImageView) inflate.findViewById(2131365692);
if (imageView3 != null) {
i2 = 2131365693;
MaterialButton materialButton = (MaterialButton) inflate.findViewById(2131365693);
if (materialButton != null) {
i2 = 2131365694;
ImageView imageView4 = (ImageView) inflate.findViewById(2131365694);
if (imageView4 != null) {
i2 = 2131365695;
ImageView imageView5 = (ImageView) inflate.findViewById(2131365695);
if (imageView5 != null) {
AnchoredVoiceControlsViewBinding anchoredVoiceControlsViewBinding = new AnchoredVoiceControlsViewBinding((LinearLayout) inflate, imageView, linearLayout, imageView2, imageView3, materialButton, imageView4, imageView5);
m.checkNotNullExpressionValue(anchoredVoiceControlsViewBinding, "AnchoredVoiceControlsVie…rom(context), this, true)");
this.binding = anchoredVoiceControlsViewBinding;
AppLog appLog = AppLog.g;
m.checkNotNullParameter(appLog, "logger");
WeakReference<a> weakReference = a.b.a;
TooltipManager tooltipManager = null;
a aVar = weakReference != null ? weakReference.get() : null;
if (aVar == null) {
aVar = new a(appLog);
a.b.a = new WeakReference<>(aVar);
}
TooltipManager.a aVar2 = TooltipManager.a.d;
m.checkNotNullParameter(aVar, "floatingViewManager");
WeakReference<TooltipManager> weakReference2 = TooltipManager.a.a;
tooltipManager = weakReference2 != null ? weakReference2.get() : tooltipManager;
if (tooltipManager == null) {
tooltipManager = new TooltipManager((c.a.v.a) TooltipManager.a.b.getValue(), (Set) TooltipManager.a.f2124c.getValue(), 0, aVar, 4);
TooltipManager.a.a = new WeakReference<>(tooltipManager);
}
this.tooltipManager = tooltipManager;
return;
}
}
}
}
}
}
}
throw new NullPointerException("Missing required view with ID: ".concat(inflate.getResources().getResourceName(i2)));
}
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
public /* synthetic */ AnchoredVoiceControlsView(Context context, AttributeSet attributeSet, int i, int i2, DefaultConstructorMarker defaultConstructorMarker) {
this(context, (i2 & 2) != 0 ? null : attributeSet, (i2 & 4) != 0 ? 0 : i);
}
public static final /* synthetic */ TooltipManager access$getTooltipManager$p(AnchoredVoiceControlsView anchoredVoiceControlsView) {
return anchoredVoiceControlsView.tooltipManager;
}
private final void configureScreenShareButtonSparkle(boolean z2, AppComponent appComponent, FragmentManager fragmentManager, long j, boolean z3, WidgetVoiceBottomSheet.FeatureContext featureContext, Function0<Unit> function0, Function0<Unit> function02) {
if (z2) {
TooltipManager tooltipManager = this.tooltipManager;
ScreenShareButtonSparkleTooltip screenShareButtonSparkleTooltip = ScreenShareButtonSparkleTooltip.INSTANCE;
Objects.requireNonNull(tooltipManager);
m.checkNotNullParameter(screenShareButtonSparkleTooltip, "tooltip");
if (!(tooltipManager.a.get(screenShareButtonSparkleTooltip.getTooltipName()) != null)) {
ImageView imageView = this.binding.f;
m.checkNotNullExpressionValue(imageView, "binding.voiceFullscreenControlsScreenshare");
Context context = imageView.getContext();
m.checkNotNullExpressionValue(context, "binding.voiceFullscreenControlsScreenshare.context");
SparkleView sparkleView = new SparkleView(context, null);
sparkleView.setOnClickListener(new AnchoredVoiceControlsView$configureScreenShareButtonSparkle$1(this, fragmentManager, j, z3, featureContext, function0, function02));
TooltipManager tooltipManager2 = this.tooltipManager;
ImageView imageView2 = this.binding.f;
m.checkNotNullExpressionValue(imageView2, "binding.voiceFullscreenControlsScreenshare");
FloatingViewGravity floatingViewGravity = FloatingViewGravity.CENTER;
Observable<Unit> F = appComponent.getUnsubscribeSignal().F(AnchoredVoiceControlsView$configureScreenShareButtonSparkle$2.INSTANCE);
m.checkNotNullExpressionValue(F, "appComponent.unsubscribeSignal.map { Unit }");
tooltipManager2.d(imageView2, sparkleView, screenShareButtonSparkleTooltip, floatingViewGravity, 0, 0, false, F);
return;
}
}
if (!z2) {
this.tooltipManager.c(ScreenShareButtonSparkleTooltip.INSTANCE);
}
}
public final void configureUI(MediaEngineConnection.InputMode inputMode, StoreAudioDevices.AudioDevicesState audioDevicesState, boolean z2, boolean z3, boolean z4, CameraState cameraState, Function0<Unit> function0, Function0<Unit> function02, Function0<Unit> function03, Function0<Unit> function04, Function0<Unit> function05, AppComponent appComponent, FragmentManager fragmentManager, Function0<Unit> function06, long j, boolean z5, WidgetVoiceBottomSheet.FeatureContext featureContext) {
String str;
m.checkNotNullParameter(inputMode, "inputMode");
m.checkNotNullParameter(audioDevicesState, "audioDevicesState");
m.checkNotNullParameter(cameraState, "cameraState");
m.checkNotNullParameter(function0, "onMutePressed");
m.checkNotNullParameter(function02, "onScreenSharePressed");
m.checkNotNullParameter(function03, "onSpeakerButtonPressed");
m.checkNotNullParameter(function04, "onCameraButtonPressed");
m.checkNotNullParameter(function05, "onDisconnectPressed");
m.checkNotNullParameter(appComponent, "appComponent");
m.checkNotNullParameter(fragmentManager, "fragmentManager");
m.checkNotNullParameter(function06, "onNavigateToScreenShareNfxSheet");
m.checkNotNullParameter(featureContext, "featureContext");
MaterialButton materialButton = this.binding.e;
m.checkNotNullExpressionValue(materialButton, "binding.voiceFullscreenControlsPtt");
boolean z6 = true;
materialButton.setVisibility(inputMode.ordinal() != 1 ? 8 : 0);
this.binding.b.setOnClickListener(new AnchoredVoiceControlsView$configureUI$1(function04));
ImageView imageView = this.binding.b;
m.checkNotNullExpressionValue(imageView, "binding.voiceFullscreenControlsCamera");
if (cameraState == CameraState.CAMERA_DISABLED) {
z6 = false;
}
imageView.setVisibility(z6 ? 0 : 8);
if (cameraState == CameraState.CAMERA_ON) {
ImageView imageView2 = this.binding.b;
m.checkNotNullExpressionValue(imageView2, "binding.voiceFullscreenControlsCamera");
imageView2.setImageTintList(ColorStateList.valueOf(ColorCompat.getThemedColor(getContext(), 2130968946)));
ImageView imageView3 = this.binding.b;
m.checkNotNullExpressionValue(imageView3, "binding.voiceFullscreenControlsCamera");
imageView3.setContentDescription(getContext().getString(2131887147));
} else {
ImageView imageView4 = this.binding.b;
m.checkNotNullExpressionValue(imageView4, "binding.voiceFullscreenControlsCamera");
imageView4.setImageTintList(ColorStateList.valueOf(ColorCompat.getThemedColor(getContext(), 2130968949)));
ImageView imageView5 = this.binding.b;
m.checkNotNullExpressionValue(imageView5, "binding.voiceFullscreenControlsCamera");
imageView5.setContentDescription(getContext().getString(2131887146));
}
if (audioDevicesState.getSelectedOutputDevice() instanceof StoreAudioDevices.OutputDevice.BluetoothAudio) {
this.binding.g.setImageResource(2131231412);
} else {
this.binding.g.setImageResource(2131231413);
}
if ((audioDevicesState.getSelectedOutputDevice() instanceof StoreAudioDevices.OutputDevice.Earpiece) || (audioDevicesState.getSelectedOutputDevice() instanceof StoreAudioDevices.OutputDevice.WiredAudio)) {
ImageView imageView6 = this.binding.g;
m.checkNotNullExpressionValue(imageView6, "binding.voiceFullscreenControlsSpeaker");
int themedColor = ColorCompat.getThemedColor(imageView6.getContext(), 2130968949);
ImageView imageView7 = this.binding.g;
m.checkNotNullExpressionValue(imageView7, "binding.voiceFullscreenControlsSpeaker");
imageView7.setImageTintList(ColorStateList.valueOf(themedColor));
} else {
ImageView imageView8 = this.binding.g;
m.checkNotNullExpressionValue(imageView8, "binding.voiceFullscreenControlsSpeaker");
int themedColor2 = ColorCompat.getThemedColor(imageView8.getContext(), 2130968946);
ImageView imageView9 = this.binding.g;
m.checkNotNullExpressionValue(imageView9, "binding.voiceFullscreenControlsSpeaker");
imageView9.setImageTintList(ColorStateList.valueOf(themedColor2));
}
ImageView imageView10 = this.binding.g;
m.checkNotNullExpressionValue(imageView10, "binding.voiceFullscreenControlsSpeaker");
imageView10.setActivated(audioDevicesState.getSelectedOutputDevice() instanceof StoreAudioDevices.OutputDevice.Speaker);
this.binding.g.setOnClickListener(new AnchoredVoiceControlsView$configureUI$2(function03));
ImageView imageView11 = this.binding.d;
m.checkNotNullExpressionValue(imageView11, "binding.voiceFullscreenControlsMuteState");
imageView11.setActivated(z2);
ImageView imageView12 = this.binding.d;
m.checkNotNullExpressionValue(imageView12, "binding.voiceFullscreenControlsMuteState");
imageView12.setContentDescription(getContext().getString(z2 ? 2131894294 : 2131891452));
this.binding.d.setOnClickListener(new AnchoredVoiceControlsView$configureUI$3(function0));
ImageView imageView13 = this.binding.f;
m.checkNotNullExpressionValue(imageView13, "binding.voiceFullscreenControlsScreenshare");
imageView13.setActivated(z3);
this.binding.f.setImageResource(z3 ? 2131231783 : 2131231782);
ImageView imageView14 = this.binding.f;
m.checkNotNullExpressionValue(imageView14, "binding.voiceFullscreenControlsScreenshare");
Context context = getContext();
if (context != null) {
str = context.getString(z3 ? 2131893809 : 2131893215);
} else {
str = null;
}
imageView14.setContentDescription(str);
this.binding.f.setOnClickListener(new AnchoredVoiceControlsView$configureUI$4(function02));
configureScreenShareButtonSparkle(z4, appComponent, fragmentManager, j, z5, featureContext, function06, function02);
this.binding.f1599c.setOnClickListener(new AnchoredVoiceControlsView$configureUI$5(function05));
}
public final void hidePtt() {
MaterialButton materialButton = this.binding.e;
m.checkNotNullExpressionValue(materialButton, "binding.voiceFullscreenControlsPtt");
materialButton.setVisibility(8);
}
public final void setOnPttPressedListener(Function1<? super Boolean, Unit> function1) {
m.checkNotNullParameter(function1, "onPttPressed");
this.binding.e.setOnTouchListener(new OnPressListener(new AnchoredVoiceControlsView$setOnPttPressedListener$1(function1)));
}
}