discord-jadx/app/src/main/java/com/discord/widgets/voice/controls/VoiceControlsSheetView.java
2021-07-24 04:37:17 +02:00

449 lines
24 KiB
Java

package com.discord.widgets.voice.controls;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.SeekBar;
import android.widget.TextView;
import androidx.cardview.widget.CardView;
import androidx.core.content.ContextCompat;
import c.a.k.b;
import com.airbnb.lottie.parser.AnimatableValueParser;
import com.discord.databinding.VoiceControlsSheetViewBinding;
import com.discord.utilities.color.ColorCompat;
import com.discord.utilities.color.ColorCompatKt;
import com.discord.utilities.display.DisplayUtils;
import com.discord.utilities.press.OnPressListener;
import com.discord.utilities.view.extensions.ViewExtensions;
import com.discord.views.NumericBadgingView;
import com.discord.views.calls.VolumeSliderView;
import com.discord.widgets.stage.StageRoles;
import com.discord.widgets.voice.model.CallModel;
import com.google.android.material.textview.MaterialTextView;
import d0.a0.a;
import d0.z.d.m;
import kotlin.NoWhenBranchMatchedException;
import kotlin.Unit;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.functions.Function2;
import kotlin.jvm.internal.DefaultConstructorMarker;
/* compiled from: VoiceControlsSheetView.kt */
public final class VoiceControlsSheetView extends LinearLayout {
private final VoiceControlsSheetViewBinding binding;
private boolean isGestureNavigationEnabled;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public VoiceControlsSheetView(Context context) {
super(context);
m.checkNotNullParameter(context, "context");
VoiceControlsSheetViewBinding a = VoiceControlsSheetViewBinding.a(LayoutInflater.from(getContext()), this);
m.checkNotNullExpressionValue(a, "VoiceControlsSheetViewBi…ater.from(context), this)");
this.binding = a;
Resources resources = getResources();
m.checkNotNullExpressionValue(resources, "resources");
this.isGestureNavigationEnabled = DisplayUtils.isGestureNavigationEnabled(resources);
CardView cardView = a.r;
m.checkNotNullExpressionValue(cardView, "binding.secondaryActionsCard");
cardView.setVisibility(this.isGestureNavigationEnabled ? 0 : 4);
}
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public VoiceControlsSheetView(Context context, AttributeSet attributeSet) {
super(context, attributeSet);
m.checkNotNullParameter(context, "context");
VoiceControlsSheetViewBinding a = VoiceControlsSheetViewBinding.a(LayoutInflater.from(getContext()), this);
m.checkNotNullExpressionValue(a, "VoiceControlsSheetViewBi…ater.from(context), this)");
this.binding = a;
Resources resources = getResources();
m.checkNotNullExpressionValue(resources, "resources");
this.isGestureNavigationEnabled = DisplayUtils.isGestureNavigationEnabled(resources);
CardView cardView = a.r;
m.checkNotNullExpressionValue(cardView, "binding.secondaryActionsCard");
cardView.setVisibility(this.isGestureNavigationEnabled ? 0 : 4);
}
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public VoiceControlsSheetView(Context context, AttributeSet attributeSet, int i) {
super(context, attributeSet, i);
m.checkNotNullParameter(context, "context");
VoiceControlsSheetViewBinding a = VoiceControlsSheetViewBinding.a(LayoutInflater.from(getContext()), this);
m.checkNotNullExpressionValue(a, "VoiceControlsSheetViewBi…ater.from(context), this)");
this.binding = a;
Resources resources = getResources();
m.checkNotNullExpressionValue(resources, "resources");
this.isGestureNavigationEnabled = DisplayUtils.isGestureNavigationEnabled(resources);
CardView cardView = a.r;
m.checkNotNullExpressionValue(cardView, "binding.secondaryActionsCard");
cardView.setVisibility(this.isGestureNavigationEnabled ? 0 : 4);
}
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
public /* synthetic */ VoiceControlsSheetView(Context context, AttributeSet attributeSet, int i, int i2, DefaultConstructorMarker defaultConstructorMarker) {
this(context, (i2 & 2) != 0 ? null : attributeSet, (i2 & 4) != 0 ? 0 : i);
}
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
public /* synthetic */ VoiceControlsSheetView(Context context, AttributeSet attributeSet, int i, DefaultConstructorMarker defaultConstructorMarker) {
this(context, (i & 2) != 0 ? null : attributeSet);
}
private final void configureInviteButtons(CallModel callModel, Function0<Unit> function0, boolean z2) {
this.binding.h.setOnClickListener(new VoiceControlsSheetView$configureInviteButtons$1(function0));
this.binding.i.setOnClickListener(new VoiceControlsSheetView$configureInviteButtons$2(function0));
ImageView imageView = this.binding.h;
m.checkNotNullExpressionValue(imageView, "binding.inviteButton");
boolean z3 = true;
int i = 8;
imageView.setVisibility(callModel.canInvite() && z2 ? 0 : 8);
TextView textView = this.binding.i;
m.checkNotNullExpressionValue(textView, "binding.inviteSecondaryButton");
if (!callModel.canInvite() || z2) {
z3 = false;
}
if (z3) {
i = 0;
}
textView.setVisibility(i);
ImageView imageView2 = this.binding.h;
m.checkNotNullExpressionValue(imageView2, "binding.inviteButton");
Context context = getContext();
m.checkNotNullExpressionValue(context, "context");
imageView2.setBackgroundTintList(ColorStateList.valueOf(getDefaultButtonBackgroundTint(context, false)));
}
/* renamed from: configureMoveToAudienceButton-yox5PQY reason: not valid java name */
private final void m60configureMoveToAudienceButtonyox5PQY(StageRoles stageRoles, Function0<Unit> function0) {
ImageView imageView = this.binding.j;
int i = 0;
boolean z2 = true;
if (stageRoles == null || !StageRoles.m26isSpeakerimpl(stageRoles.m28unboximpl()) || StageRoles.m25isModeratorimpl(stageRoles.m28unboximpl())) {
z2 = false;
}
if (!z2) {
i = 8;
}
imageView.setVisibility(i);
ImageView imageView2 = this.binding.j;
m.checkNotNullExpressionValue(imageView2, "binding.moveToAudienceButton");
imageView2.setBackgroundTintList(ColorStateList.valueOf(ColorCompat.getColor(imageView.getContext(), 2131100463)));
imageView.setOnClickListener(new VoiceControlsSheetView$configureMoveToAudienceButton$$inlined$apply$lambda$1(this, stageRoles, function0));
}
/* renamed from: configureMuteButton-P2fzehM reason: not valid java name */
private final void m61configureMuteButtonP2fzehM(CallModel callModel, StageRoles stageRoles, Function0<Unit> function0) {
if (stageRoles == null || StageRoles.m26isSpeakerimpl(stageRoles.m28unboximpl())) {
ImageView imageView = this.binding.k;
m.checkNotNullExpressionValue(imageView, "binding.muteButton");
imageView.setVisibility(0);
boolean isMeMutedByAnySource = callModel.isMeMutedByAnySource();
Context context = getContext();
m.checkNotNullExpressionValue(context, "context");
int defaultButtonBackgroundTint = getDefaultButtonBackgroundTint(context, isMeMutedByAnySource);
ImageView imageView2 = this.binding.k;
m.checkNotNullExpressionValue(imageView2, "binding.muteButton");
imageView2.setBackgroundTintList(ColorStateList.valueOf(defaultButtonBackgroundTint));
this.binding.k.setImageResource(isMeMutedByAnySource ? 2131231768 : 2131231779);
this.binding.k.setOnClickListener(new VoiceControlsSheetView$configureMuteButton$1(function0));
ImageView imageView3 = this.binding.k;
m.checkNotNullExpressionValue(imageView3, "binding.muteButton");
Context context2 = getContext();
m.checkNotNullExpressionValue(context2, "context");
imageView3.setContentDescription(b.g(context2, isMeMutedByAnySource ? 2131894294 : 2131891452, new Object[0], null, 4));
return;
}
ImageView imageView4 = this.binding.k;
m.checkNotNullExpressionValue(imageView4, "binding.muteButton");
imageView4.setVisibility(8);
}
private final void configureOutputSelectors(VoiceControlsOutputSelectorState voiceControlsOutputSelectorState, Function0<Unit> function0, boolean z2) {
FrameLayout frameLayout = this.binding.f1670c;
m.checkNotNullExpressionValue(frameLayout, "binding.audioOutputContainer");
int i = 0;
frameLayout.setVisibility(z2 ? 0 : 8);
this.binding.b.setImageDrawable(ContextCompat.getDrawable(getContext(), voiceControlsOutputSelectorState.getAudioOutputIconRes()));
ImageView imageView = this.binding.b;
m.checkNotNullExpressionValue(imageView, "binding.audioOutputButton");
Context context = getContext();
m.checkNotNullExpressionValue(context, "context");
imageView.setBackgroundTintList(ColorStateList.valueOf(getDefaultButtonBackgroundTint(context, voiceControlsOutputSelectorState.isButtonActive())));
TextView textView = this.binding.e;
m.checkNotNullExpressionValue(textView, "binding.audioOutputSecondaryButton");
textView.setVisibility(z2 ^ true ? 0 : 8);
TextView textView2 = this.binding.e;
m.checkNotNullExpressionValue(textView2, "binding.audioOutputSecondaryButton");
ViewExtensions.setCompoundDrawableWithIntrinsicBounds$default(textView2, voiceControlsOutputSelectorState.getAudioOutputIconRes(), 0, 0, 0, 14, null);
Context context2 = getContext();
m.checkNotNullExpressionValue(context2, "context");
int defaultButtonIconTint = getDefaultButtonIconTint(context2, voiceControlsOutputSelectorState.isButtonActive());
ImageView imageView2 = this.binding.b;
m.checkNotNullExpressionValue(imageView2, "binding.audioOutputButton");
ColorCompatKt.tintWithColor(imageView2, defaultButtonIconTint);
ImageView imageView3 = this.binding.d;
m.checkNotNullExpressionValue(imageView3, "binding.audioOutputMore");
ColorCompatKt.tintWithColor(imageView3, defaultButtonIconTint);
ImageView imageView4 = this.binding.d;
m.checkNotNullExpressionValue(imageView4, "binding.audioOutputMore");
if (!voiceControlsOutputSelectorState.getShowMoreOptions()) {
i = 8;
}
imageView4.setVisibility(i);
this.binding.b.setOnClickListener(new VoiceControlsSheetView$configureOutputSelectors$1(function0));
this.binding.e.setOnClickListener(new VoiceControlsSheetView$configureOutputSelectors$2(function0));
}
/* renamed from: configureRaiseHandButton-fw_bWyM reason: not valid java name */
private final void m62configureRaiseHandButtonfw_bWyM(CallModel callModel, StageRoles stageRoles, int i, boolean z2, Function0<Unit> function0) {
if (stageRoles == null || (!StageRoles.m25isModeratorimpl(stageRoles.m28unboximpl()) && !StageRoles.m23isAudienceimpl(stageRoles.m28unboximpl()))) {
NumericBadgingView numericBadgingView = this.binding.n;
m.checkNotNullExpressionValue(numericBadgingView, "binding.raiseHandBadge");
numericBadgingView.setVisibility(8);
return;
}
NumericBadgingView numericBadgingView2 = this.binding.n;
boolean z3 = false;
numericBadgingView2.setVisibility(0);
if (!StageRoles.m25isModeratorimpl(stageRoles.m28unboximpl())) {
i = 0;
}
numericBadgingView2.setBadgeNumber(i);
ImageView imageView = this.binding.o;
if (StageRoles.m25isModeratorimpl(stageRoles.m28unboximpl())) {
imageView.setContentDescription(imageView.getResources().getString(2131892800));
ViewExtensions.setEnabledAndAlpha$default(imageView, true, 0.0f, 2, null);
imageView.setImageDrawable(ContextCompat.getDrawable(imageView.getContext(), 2131231984));
} else {
imageView.setContentDescription(imageView.getResources().getString(!callModel.canRequestToSpeak() ? 2131886741 : callModel.isMyHandRaised() ? 2131886738 : 2131886739));
ViewExtensions.setEnabledAndAlpha(imageView, !z2 && callModel.canRequestToSpeak(), 0.2f);
imageView.setImageDrawable(ContextCompat.getDrawable(imageView.getContext(), 2131231981));
}
if (callModel.isMyHandRaised() && !StageRoles.m25isModeratorimpl(stageRoles.m28unboximpl())) {
z3 = true;
}
Context context = imageView.getContext();
m.checkNotNullExpressionValue(context, "context");
int defaultButtonBackgroundTint = getDefaultButtonBackgroundTint(context, z3);
Context context2 = imageView.getContext();
m.checkNotNullExpressionValue(context2, "context");
int defaultButtonIconTint = getDefaultButtonIconTint(context2, z3);
imageView.setBackgroundTintList(ColorStateList.valueOf(defaultButtonBackgroundTint));
ColorCompatKt.tintWithColor(imageView, defaultButtonIconTint);
imageView.setOnClickListener(new VoiceControlsSheetView$configureRaiseHandButton$$inlined$apply$lambda$1(this, stageRoles, callModel, z2, function0));
}
private final void configureScreenshareButtons(CallModel callModel, Function0<Unit> function0, boolean z2) {
boolean z3 = true;
boolean z4 = !AnimatableValueParser.w1(callModel.getChannel());
boolean isStreaming = callModel.isStreaming();
int i = isStreaming ? 2131893809 : 2131891393;
ImageView imageView = this.binding.p;
m.checkNotNullExpressionValue(imageView, "binding.screenShareButton");
int i2 = 0;
imageView.setVisibility(z4 && z2 ? 0 : 8);
int i3 = isStreaming ? 2131231783 : 2131231782;
int i4 = isStreaming ? -16777216 : -1;
Context context = getContext();
m.checkNotNullExpressionValue(context, "context");
int defaultButtonBackgroundTint = getDefaultButtonBackgroundTint(context, isStreaming);
this.binding.p.setImageResource(i3);
ImageView imageView2 = this.binding.p;
m.checkNotNullExpressionValue(imageView2, "binding.screenShareButton");
imageView2.setBackgroundTintList(ColorStateList.valueOf(defaultButtonBackgroundTint));
ImageView imageView3 = this.binding.p;
m.checkNotNullExpressionValue(imageView3, "binding.screenShareButton");
imageView3.setImageTintList(ColorStateList.valueOf(i4));
this.binding.p.setOnClickListener(new VoiceControlsSheetView$configureScreenshareButtons$1(function0));
TextView textView = this.binding.q;
m.checkNotNullExpressionValue(textView, "binding.screenShareSecondaryButton");
if (!z4 || z2) {
z3 = false;
}
if (!z3) {
i2 = 8;
}
textView.setVisibility(i2);
this.binding.q.setOnClickListener(new VoiceControlsSheetView$configureScreenshareButtons$2(function0));
TextView textView2 = this.binding.q;
m.checkNotNullExpressionValue(textView2, "binding.screenShareSecondaryButton");
ViewExtensions.setCompoundDrawableWithIntrinsicBounds$default(textView2, i3, 0, 0, 0, 14, null);
this.binding.q.setText(i);
}
private final void configureStreamVolume(boolean z2, float f, Function2<? super Float, ? super Boolean, Unit> function2) {
TextView textView = this.binding.u;
m.checkNotNullExpressionValue(textView, "binding.streamVolumeLabel");
int i = 8;
textView.setVisibility(z2 ? 0 : 8);
VolumeSliderView volumeSliderView = this.binding.v;
m.checkNotNullExpressionValue(volumeSliderView, "binding.streamVolumeSlider");
if (z2) {
i = 0;
}
volumeSliderView.setVisibility(i);
VolumeSliderView volumeSliderView2 = this.binding.v;
int roundToInt = a.roundToInt(f);
SeekBar seekBar = volumeSliderView2.i.d;
m.checkNotNullExpressionValue(seekBar, "binding.volumeSliderSeekBar");
seekBar.setProgress(roundToInt);
this.binding.v.setOnVolumeChange(function2);
}
private final void configureVideoButton(CallModel callModel, Function0<Unit> function0, boolean z2) {
boolean z3 = true;
int i = 0;
boolean z4 = callModel.getSelectedVideoDevice() != null;
boolean z5 = !callModel.getVideoDevices().isEmpty();
ImageView imageView = this.binding.w;
m.checkNotNullExpressionValue(imageView, "binding.videoButton");
if (!z5 || !z2) {
z3 = false;
}
if (!z3) {
i = 8;
}
imageView.setVisibility(i);
int i2 = z4 ? -16777216 : -1;
ImageView imageView2 = this.binding.w;
m.checkNotNullExpressionValue(imageView2, "binding.videoButton");
imageView2.setImageTintList(ColorStateList.valueOf(i2));
Context context = getContext();
m.checkNotNullExpressionValue(context, "context");
int defaultButtonBackgroundTint = getDefaultButtonBackgroundTint(context, z4);
ImageView imageView3 = this.binding.w;
m.checkNotNullExpressionValue(imageView3, "binding.videoButton");
imageView3.setBackgroundTintList(ColorStateList.valueOf(defaultButtonBackgroundTint));
this.binding.w.setOnClickListener(new VoiceControlsSheetView$configureVideoButton$1(function0));
}
private final int getDefaultButtonBackgroundTint(Context context, boolean z2) {
if (z2) {
return ColorCompat.getColor(context, 2131100428);
}
if (!z2) {
return ColorCompat.getColor(context, 2131100463);
}
throw new NoWhenBranchMatchedException();
}
private final int getDefaultButtonIconTint(Context context, boolean z2) {
if (!z2) {
return ColorCompat.getColor(context, 2131100428);
}
TypedValue typedValue = new TypedValue();
context.getTheme().resolveAttribute(2130968761, typedValue, true);
return ColorCompat.getColor(context, typedValue.resourceId);
}
/* renamed from: configureUI-3jxq49Y reason: not valid java name */
public final void m63configureUI3jxq49Y(CallModel callModel, VoiceControlsOutputSelectorState voiceControlsOutputSelectorState, boolean z2, boolean z3, boolean z4, boolean z5, boolean z6, boolean z7, Function0<Unit> function0, Function0<Unit> function02, Function0<Unit> function03, Function0<Unit> function04, Function0<Unit> function05, Function0<Unit> function06, Function0<Unit> function07, boolean z8, float f, Function2<? super Float, ? super Boolean, Unit> function2, Function0<Unit> function08, int i, Function0<Unit> function09, Function0<Unit> function010, boolean z9, StageRoles stageRoles) {
int i2;
m.checkNotNullParameter(callModel, "model");
m.checkNotNullParameter(voiceControlsOutputSelectorState, "outputSelectorState");
m.checkNotNullParameter(function0, "onStopWatchingClick");
m.checkNotNullParameter(function02, "onDisconnectClick");
m.checkNotNullParameter(function03, "onAudioOutputClick");
m.checkNotNullParameter(function04, "onVideoClick");
m.checkNotNullParameter(function05, "onMuteClick");
m.checkNotNullParameter(function06, "onInviteClick");
m.checkNotNullParameter(function07, "onScreenshareClick");
m.checkNotNullParameter(function2, "onStreamVolumeChange");
m.checkNotNullParameter(function08, "onDeafenPressed");
m.checkNotNullParameter(function09, "onRaiseHandClick");
m.checkNotNullParameter(function010, "onMoveToAudienceClick");
ImageView imageView = this.binding.t;
m.checkNotNullExpressionValue(imageView, "binding.stopWatchingButton");
imageView.setVisibility(z6 ? 0 : 8);
this.binding.t.setOnClickListener(new VoiceControlsSheetView$configureUI$1(function0));
if (stageRoles == null || StageRoles.m26isSpeakerimpl(stageRoles.m28unboximpl())) {
MaterialTextView materialTextView = this.binding.f1671s;
m.checkNotNullExpressionValue(materialTextView, "binding.stageDisconnectButtonLarge");
i2 = 8;
materialTextView.setVisibility(8);
ImageView imageView2 = this.binding.g;
imageView2.setImageResource(stageRoles == null ? 2131231464 : 2131231978);
imageView2.setVisibility(z7 ? 0 : 8);
imageView2.setOnClickListener(new VoiceControlsSheetView$configureUI$$inlined$apply$lambda$2(stageRoles, z7, function02));
m.checkNotNullExpressionValue(imageView2, "binding.disconnectButton…sconnectClick() }\n }");
} else {
ImageView imageView3 = this.binding.g;
m.checkNotNullExpressionValue(imageView3, "binding.disconnectButton");
imageView3.setVisibility(8);
MaterialTextView materialTextView2 = this.binding.f1671s;
materialTextView2.setVisibility(z7 ? 0 : 8);
materialTextView2.setOnClickListener(new VoiceControlsSheetView$configureUI$$inlined$apply$lambda$1(z7, function02));
m.checkNotNullExpressionValue(materialTextView2, "binding.stageDisconnectB…Click()\n }\n }");
i2 = 8;
}
Button button = this.binding.m;
m.checkNotNullExpressionValue(button, "binding.pushToTalkButton");
if ((stageRoles == null || StageRoles.m26isSpeakerimpl(stageRoles.m28unboximpl())) && z3) {
i2 = 0;
}
button.setVisibility(i2);
TextView textView = this.binding.f;
m.checkNotNullExpressionValue(textView, "binding.deafenSecondaryButton");
b.m(textView, z4 ? 2131894286 : 2131888045, new Object[0], null, 4);
this.binding.f.setOnClickListener(new VoiceControlsSheetView$configureUI$4(function08));
TextView textView2 = this.binding.f;
m.checkNotNullExpressionValue(textView2, "binding.deafenSecondaryButton");
textView2.setActivated(z4);
m60configureMoveToAudienceButtonyox5PQY(stageRoles, function010);
m62configureRaiseHandButtonfw_bWyM(callModel, stageRoles, i, z9, function09);
m61configureMuteButtonP2fzehM(callModel, stageRoles, function05);
configureOutputSelectors(voiceControlsOutputSelectorState, function03, !z5 && !AnimatableValueParser.w1(callModel.getChannel()));
configureVideoButton(callModel, function04, z2);
configureScreenshareButtons(callModel, function07, z5);
configureStreamVolume(z8, f, function2);
configureInviteButtons(callModel, function06, AnimatableValueParser.w1(callModel.getChannel()));
}
public final int getPeekHeight() {
LinearLayout linearLayout = this.binding.l;
m.checkNotNullExpressionValue(linearLayout, "binding.peekContainer");
return linearLayout.getMeasuredHeight();
}
public final void handleSheetState(int i) {
CardView cardView = this.binding.r;
m.checkNotNullExpressionValue(cardView, "binding.secondaryActionsCard");
int i2 = 4;
if (i != 4 || this.isGestureNavigationEnabled) {
i2 = 0;
}
cardView.setVisibility(i2);
}
@Override // android.view.View, android.view.ViewGroup
public void onAttachedToWindow() {
int i;
super.onAttachedToWindow();
Resources resources = getResources();
m.checkNotNullExpressionValue(resources, "resources");
if (resources.getConfiguration().orientation == 1) {
Resources resources2 = getResources();
m.checkNotNullExpressionValue(resources2, "resources");
i = resources2.getDisplayMetrics().widthPixels;
} else {
Resources resources3 = getResources();
m.checkNotNullExpressionValue(resources3, "resources");
i = resources3.getDisplayMetrics().heightPixels;
}
ViewGroup.LayoutParams layoutParams = getLayoutParams();
layoutParams.width = i;
setLayoutParams(layoutParams);
}
public final void setOnPTTListener(OnPressListener onPressListener) {
m.checkNotNullParameter(onPressListener, "listener");
this.binding.m.setOnTouchListener(onPressListener);
}
}