325 lines
20 KiB
Java
325 lines
20 KiB
Java
package com.discord.widgets.status;
|
|
|
|
import android.content.Context;
|
|
import android.graphics.drawable.Drawable;
|
|
import android.os.Build;
|
|
import android.text.SpannableStringBuilder;
|
|
import android.view.View;
|
|
import android.widget.ImageView;
|
|
import android.widget.LinearLayout;
|
|
import android.widget.TextView;
|
|
import androidx.core.content.ContextCompat;
|
|
import androidx.core.view.ViewCompat;
|
|
import androidx.fragment.app.Fragment;
|
|
import androidx.fragment.app.FragmentViewModelLazyKt;
|
|
import androidx.vectordrawable.graphics.drawable.AnimatedVectorDrawableCompat;
|
|
import c.a.d.f0;
|
|
import c.a.d.h0;
|
|
import c.a.k.b;
|
|
import c.d.b.a.a;
|
|
import c0.z.d.a0;
|
|
import c0.z.d.m;
|
|
import com.discord.R;
|
|
import com.discord.api.channel.ChannelUtils;
|
|
import com.discord.api.stageinstance.StageInstance;
|
|
import com.discord.app.AppFragment;
|
|
import com.discord.databinding.WidgetGlobalStatusIndicatorBinding;
|
|
import com.discord.models.guild.Guild;
|
|
import com.discord.utilities.color.ColorCompat;
|
|
import com.discord.utilities.color.ColorCompatKt;
|
|
import com.discord.utilities.drawable.DrawableCompat;
|
|
import com.discord.utilities.resources.StringResourceUtilsKt;
|
|
import com.discord.utilities.rx.ObservableExtensionsKt;
|
|
import com.discord.utilities.textprocessing.SpannableUtilsKt;
|
|
import com.discord.utilities.viewbinding.FragmentViewBindingDelegate;
|
|
import com.discord.utilities.viewbinding.FragmentViewBindingDelegateKt;
|
|
import com.discord.utilities.voice.VoiceViewUtils;
|
|
import com.discord.widgets.status.WidgetGlobalStatusIndicatorState;
|
|
import com.discord.widgets.status.WidgetGlobalStatusIndicatorViewModel;
|
|
import com.google.android.material.button.MaterialButton;
|
|
import kotlin.Lazy;
|
|
import kotlin.jvm.functions.Function0;
|
|
import kotlin.jvm.functions.Function1;
|
|
import kotlin.reflect.KProperty;
|
|
import rx.Observable;
|
|
/* compiled from: WidgetGlobalStatusIndicator.kt */
|
|
public final class WidgetGlobalStatusIndicator extends AppFragment {
|
|
public static final /* synthetic */ KProperty[] $$delegatedProperties = {a.Z(WidgetGlobalStatusIndicator.class, "binding", "getBinding()Lcom/discord/databinding/WidgetGlobalStatusIndicatorBinding;", 0)};
|
|
private final FragmentViewBindingDelegate binding$delegate = FragmentViewBindingDelegateKt.viewBinding(this, WidgetGlobalStatusIndicator$binding$2.INSTANCE, new WidgetGlobalStatusIndicator$binding$3(this));
|
|
private AnimatedVectorDrawableCompat connectingVector;
|
|
private final WidgetGlobalStatusIndicator$connectingVectorReplayCallback$1 connectingVectorReplayCallback;
|
|
private final WidgetGlobalStatusIndicatorState indicatorState = WidgetGlobalStatusIndicatorState.Provider.get();
|
|
private WidgetGlobalStatusIndicatorState.State lastIndicatorState;
|
|
private final Lazy viewModel$delegate;
|
|
|
|
public WidgetGlobalStatusIndicator() {
|
|
super(R.layout.widget_global_status_indicator);
|
|
WidgetGlobalStatusIndicator$viewModel$2 widgetGlobalStatusIndicator$viewModel$2 = WidgetGlobalStatusIndicator$viewModel$2.INSTANCE;
|
|
f0 f0Var = new f0(this);
|
|
this.viewModel$delegate = FragmentViewModelLazyKt.createViewModelLazy(this, a0.getOrCreateKotlinClass(WidgetGlobalStatusIndicatorViewModel.class), new WidgetGlobalStatusIndicator$appViewModels$$inlined$viewModels$1(f0Var), new h0(widgetGlobalStatusIndicator$viewModel$2));
|
|
this.connectingVectorReplayCallback = new WidgetGlobalStatusIndicator$connectingVectorReplayCallback$1(this);
|
|
}
|
|
|
|
public static final /* synthetic */ void access$configureUI(WidgetGlobalStatusIndicator widgetGlobalStatusIndicator, WidgetGlobalStatusIndicatorViewModel.ViewState viewState) {
|
|
widgetGlobalStatusIndicator.configureUI(viewState);
|
|
}
|
|
|
|
public static final /* synthetic */ void access$configureUIVisibility(WidgetGlobalStatusIndicator widgetGlobalStatusIndicator, WidgetGlobalStatusIndicatorState.State state) {
|
|
widgetGlobalStatusIndicator.configureUIVisibility(state);
|
|
}
|
|
|
|
public static final /* synthetic */ AnimatedVectorDrawableCompat access$getConnectingVector$p(WidgetGlobalStatusIndicator widgetGlobalStatusIndicator) {
|
|
return widgetGlobalStatusIndicator.connectingVector;
|
|
}
|
|
|
|
public static final /* synthetic */ WidgetGlobalStatusIndicatorViewModel access$getViewModel$p(WidgetGlobalStatusIndicator widgetGlobalStatusIndicator) {
|
|
return widgetGlobalStatusIndicator.getViewModel();
|
|
}
|
|
|
|
public static final /* synthetic */ void access$onViewBindingDestroy(WidgetGlobalStatusIndicator widgetGlobalStatusIndicator, WidgetGlobalStatusIndicatorBinding widgetGlobalStatusIndicatorBinding) {
|
|
widgetGlobalStatusIndicator.onViewBindingDestroy(widgetGlobalStatusIndicatorBinding);
|
|
}
|
|
|
|
public static final /* synthetic */ void access$setConnectingVector$p(WidgetGlobalStatusIndicator widgetGlobalStatusIndicator, AnimatedVectorDrawableCompat animatedVectorDrawableCompat) {
|
|
widgetGlobalStatusIndicator.connectingVector = animatedVectorDrawableCompat;
|
|
}
|
|
|
|
private final Observable<WidgetGlobalStatusIndicatorViewModel.ViewState> bindDelay(Observable<WidgetGlobalStatusIndicatorViewModel.ViewState> observable) {
|
|
return observable.Y(new WidgetGlobalStatusIndicator$bindDelay$1(observable));
|
|
}
|
|
|
|
private final void configureUI(WidgetGlobalStatusIndicatorViewModel.ViewState viewState) {
|
|
boolean z2 = true;
|
|
WidgetGlobalStatusIndicatorState.updateState$default(this.indicatorState, !m.areEqual(viewState, WidgetGlobalStatusIndicatorViewModel.ViewState.Inactive.INSTANCE), viewState.isSpeakingInOngoingCall(), false, 4, null);
|
|
AnimatedVectorDrawableCompat animatedVectorDrawableCompat = this.connectingVector;
|
|
if (animatedVectorDrawableCompat != null) {
|
|
animatedVectorDrawableCompat.unregisterAnimationCallback(this.connectingVectorReplayCallback);
|
|
}
|
|
AnimatedVectorDrawableCompat animatedVectorDrawableCompat2 = this.connectingVector;
|
|
if (animatedVectorDrawableCompat2 != null) {
|
|
animatedVectorDrawableCompat2.stop();
|
|
}
|
|
if (viewState instanceof WidgetGlobalStatusIndicatorViewModel.ViewState.Offline) {
|
|
setupOfflineState(((WidgetGlobalStatusIndicatorViewModel.ViewState.Offline) viewState).getAirplaneMode());
|
|
} else if (viewState instanceof WidgetGlobalStatusIndicatorViewModel.ViewState.Connecting) {
|
|
setupConnectingState();
|
|
} else if (viewState instanceof WidgetGlobalStatusIndicatorViewModel.ViewState.CallOngoing) {
|
|
WidgetGlobalStatusIndicatorViewModel.ViewState.CallOngoing callOngoing = (WidgetGlobalStatusIndicatorViewModel.ViewState.CallOngoing) viewState;
|
|
setupContainerClicks(callOngoing);
|
|
setupIndicatorStatus(callOngoing);
|
|
} else if (viewState instanceof WidgetGlobalStatusIndicatorViewModel.ViewState.StageChannelOngoing) {
|
|
WidgetGlobalStatusIndicatorViewModel.ViewState.StageChannelOngoing stageChannelOngoing = (WidgetGlobalStatusIndicatorViewModel.ViewState.StageChannelOngoing) viewState;
|
|
setupStageContainerClicks(stageChannelOngoing);
|
|
setupStageIndicatorStatus(stageChannelOngoing);
|
|
} else {
|
|
resetContentVisibility(getBinding());
|
|
}
|
|
WidgetGlobalStatusIndicatorState.State state = this.lastIndicatorState;
|
|
if (state != null && state.isViewingCall()) {
|
|
LinearLayout linearLayout = getBinding().f2246c;
|
|
m.checkNotNullExpressionValue(linearLayout, "binding.indicator");
|
|
LinearLayout linearLayout2 = getBinding().e;
|
|
m.checkNotNullExpressionValue(linearLayout2, "binding.indicatorActions");
|
|
int i = 0;
|
|
if (linearLayout2.getVisibility() != 0) {
|
|
z2 = false;
|
|
}
|
|
if (!z2) {
|
|
i = 8;
|
|
}
|
|
linearLayout.setVisibility(i);
|
|
}
|
|
}
|
|
|
|
private final void configureUIVisibility(WidgetGlobalStatusIndicatorState.State state) {
|
|
this.lastIndicatorState = state;
|
|
LinearLayout linearLayout = getBinding().f2246c;
|
|
m.checkNotNullExpressionValue(linearLayout, "binding.indicator");
|
|
linearLayout.setVisibility(state.isVisible() ? 0 : 8);
|
|
}
|
|
|
|
private final WidgetGlobalStatusIndicatorBinding getBinding() {
|
|
return (WidgetGlobalStatusIndicatorBinding) this.binding$delegate.getValue((Fragment) this, $$delegatedProperties[0]);
|
|
}
|
|
|
|
private final WidgetGlobalStatusIndicatorViewModel getViewModel() {
|
|
return (WidgetGlobalStatusIndicatorViewModel) this.viewModel$delegate.getValue();
|
|
}
|
|
|
|
private final void onViewBindingDestroy(WidgetGlobalStatusIndicatorBinding widgetGlobalStatusIndicatorBinding) {
|
|
resetContentVisibility(widgetGlobalStatusIndicatorBinding);
|
|
}
|
|
|
|
private final void resetContentVisibility(WidgetGlobalStatusIndicatorBinding widgetGlobalStatusIndicatorBinding) {
|
|
LinearLayout linearLayout = widgetGlobalStatusIndicatorBinding.f;
|
|
m.checkNotNullExpressionValue(linearLayout, "binding.indicatorContent");
|
|
linearLayout.setVisibility(0);
|
|
TextView textView = widgetGlobalStatusIndicatorBinding.b;
|
|
m.checkNotNullExpressionValue(textView, "binding.alertText");
|
|
textView.setVisibility(8);
|
|
}
|
|
|
|
private final void setupConnectingState() {
|
|
resetContentVisibility(getBinding());
|
|
getBinding().f2246c.setBackgroundColor(ColorCompat.getThemedColor(requireContext(), (int) R.attr.colorBackgroundTertiary));
|
|
getBinding().i.setTextColor(ColorCompat.getThemedColor(requireContext(), (int) R.attr.colorHeaderPrimary));
|
|
TextView textView = getBinding().i;
|
|
m.checkNotNullExpressionValue(textView, "binding.indicatorText");
|
|
textView.setText(getString(R.string.connecting));
|
|
AnimatedVectorDrawableCompat animatedVectorDrawableCompat = null;
|
|
if (this.connectingVector == null && Build.VERSION.SDK_INT != 28) {
|
|
this.connectingVector = AnimatedVectorDrawableCompat.create(requireContext(), DrawableCompat.getThemedDrawableRes$default(requireContext(), (int) R.attr.ic_network_connecting_animated_vector, 0, 2, (Object) null));
|
|
}
|
|
ImageView imageView = getBinding().h;
|
|
imageView.setVisibility(0);
|
|
if (Build.VERSION.SDK_INT != 28) {
|
|
AnimatedVectorDrawableCompat animatedVectorDrawableCompat2 = this.connectingVector;
|
|
if (animatedVectorDrawableCompat2 != null) {
|
|
animatedVectorDrawableCompat2.registerAnimationCallback(this.connectingVectorReplayCallback);
|
|
animatedVectorDrawableCompat2.start();
|
|
animatedVectorDrawableCompat = animatedVectorDrawableCompat2;
|
|
}
|
|
imageView.setImageDrawable(animatedVectorDrawableCompat);
|
|
return;
|
|
}
|
|
imageView.setImageResource(DrawableCompat.getThemedDrawableRes$default(requireContext(), (int) R.attr.ic_network_connecting, 0, 2, (Object) null));
|
|
}
|
|
|
|
private final void setupContainerClicks(WidgetGlobalStatusIndicatorViewModel.ViewState.CallOngoing callOngoing) {
|
|
getBinding().f2246c.setOnClickListener(new WidgetGlobalStatusIndicator$setupContainerClicks$1(this, callOngoing));
|
|
}
|
|
|
|
private final void setupIndicatorStatus(WidgetGlobalStatusIndicatorViewModel.ViewState.CallOngoing callOngoing) {
|
|
String name;
|
|
String v;
|
|
LinearLayout linearLayout = getBinding().e;
|
|
m.checkNotNullExpressionValue(linearLayout, "binding.indicatorActions");
|
|
linearLayout.setVisibility(8);
|
|
LinearLayout linearLayout2 = getBinding().f2246c;
|
|
VoiceViewUtils voiceViewUtils = VoiceViewUtils.INSTANCE;
|
|
linearLayout2.setBackgroundColor(voiceViewUtils.getConnectionStatusColor(callOngoing.getConnectionState(), callOngoing.getConnectionQuality(), requireContext()));
|
|
String e = ChannelUtils.e(callOngoing.getSelectedVoiceChannel(), requireContext(), false, 2);
|
|
CharSequence connectedText = voiceViewUtils.getConnectedText(requireContext(), callOngoing.getConnectionState(), callOngoing.getStreamContext(), callOngoing.getHasVideo());
|
|
Guild guild = callOngoing.getGuild();
|
|
if (!(guild == null || (name = guild.getName()) == null || (v = a.v(name, " / ", e)) == null)) {
|
|
e = v;
|
|
}
|
|
String str = connectedText + ": " + e;
|
|
TextView textView = getBinding().i;
|
|
m.checkNotNullExpressionValue(textView, "binding.indicatorText");
|
|
textView.setText(str);
|
|
getBinding().i.setTextColor(ColorCompat.getColor(getContext(), (int) R.color.white));
|
|
ImageView imageView = getBinding().h;
|
|
imageView.setVisibility(0);
|
|
imageView.setImageResource(voiceViewUtils.getCallIndicatorIcon(callOngoing.getHasVideo(), callOngoing.getStreamContext()));
|
|
}
|
|
|
|
private final void setupOfflineState(boolean z2) {
|
|
resetContentVisibility(getBinding());
|
|
getBinding().f2246c.setBackgroundColor(ColorCompat.getThemedColor(requireContext(), (int) R.attr.colorBackgroundTertiary));
|
|
getBinding().i.setTextColor(ColorCompat.getThemedColor(requireContext(), (int) R.attr.colorHeaderPrimary));
|
|
getBinding().i.setText(z2 ? R.string.network_offline_airplane_mode : R.string.network_offline);
|
|
ImageView imageView = getBinding().h;
|
|
imageView.setVisibility(0);
|
|
imageView.setImageResource(z2 ? DrawableCompat.getThemedDrawableRes$default(requireContext(), (int) R.attr.ic_network_airplane_mode, 0, 2, (Object) null) : DrawableCompat.getThemedDrawableRes$default(requireContext(), (int) R.attr.ic_network_offline, 0, 2, (Object) null));
|
|
}
|
|
|
|
private final void setupStageContainerClicks(WidgetGlobalStatusIndicatorViewModel.ViewState.StageChannelOngoing stageChannelOngoing) {
|
|
getBinding().f2246c.setOnClickListener(new WidgetGlobalStatusIndicator$setupStageContainerClicks$1(this, stageChannelOngoing));
|
|
getBinding().d.setOnClickListener(new WidgetGlobalStatusIndicator$setupStageContainerClicks$2(this));
|
|
getBinding().g.setOnClickListener(new WidgetGlobalStatusIndicator$setupStageContainerClicks$3(this));
|
|
}
|
|
|
|
/* JADX DEBUG: Can't convert new array creation: APUT found in different block: 0x014c: APUT (r3v4 java.lang.Object[]), (0 ??[int, short, byte, char]), (r11v3 java.lang.CharSequence) */
|
|
private final void setupStageIndicatorStatus(WidgetGlobalStatusIndicatorViewModel.ViewState.StageChannelOngoing stageChannelOngoing) {
|
|
resetContentVisibility(getBinding());
|
|
int color = stageChannelOngoing.isSpeakingInOngoingCall() ? ContextCompat.getColor(requireContext(), R.color.white) : ColorCompat.getThemedColor(requireContext(), (int) R.attr.colorHeaderPrimary);
|
|
getBinding().f2246c.setBackgroundColor(stageChannelOngoing.isSpeakingInOngoingCall() ? ContextCompat.getColor(requireContext(), R.color.status_green_600) : ColorCompat.getThemedColor(requireContext(), (int) R.attr.colorBackgroundTertiary));
|
|
getBinding().i.setTextColor(color);
|
|
getBinding().g.setTextColor(color);
|
|
LinearLayout linearLayout = getBinding().e;
|
|
m.checkNotNullExpressionValue(linearLayout, "binding.indicatorActions");
|
|
int i = 8;
|
|
linearLayout.setVisibility(stageChannelOngoing.isInvitedToSpeak() ? 0 : 8);
|
|
ImageView imageView = getBinding().h;
|
|
WidgetGlobalStatusIndicatorState.State state = this.lastIndicatorState;
|
|
imageView.setVisibility(state != null && !state.isViewingCall() ? 0 : 8);
|
|
Drawable drawable = ContextCompat.getDrawable(imageView.getContext(), R.drawable.ic_channel_stage_16dp);
|
|
CharSequence charSequence = null;
|
|
if (drawable != null) {
|
|
m.checkNotNullExpressionValue(drawable, "drawable");
|
|
ColorCompatKt.setTint(drawable, color, false);
|
|
} else {
|
|
drawable = null;
|
|
}
|
|
imageView.setImageDrawable(drawable);
|
|
if (stageChannelOngoing.isInvitedToSpeak()) {
|
|
getBinding().i.setText(R.string.stage_speak_invite_header);
|
|
getBinding().d.setText(R.string.stage_speak_invite_accept);
|
|
MaterialButton materialButton = getBinding().d;
|
|
m.checkNotNullExpressionValue(materialButton, "binding.indicatorAccept");
|
|
materialButton.setEnabled(!stageChannelOngoing.isAckingInvitation());
|
|
getBinding().g.setText(R.string.stage_speak_invite_decline);
|
|
MaterialButton materialButton2 = getBinding().g;
|
|
m.checkNotNullExpressionValue(materialButton2, "binding.indicatorDecline");
|
|
materialButton2.setEnabled(!stageChannelOngoing.isAckingInvitation());
|
|
TextView textView = getBinding().b;
|
|
m.checkNotNullExpressionValue(textView, "binding.alertText");
|
|
if (stageChannelOngoing.getBlockedUsersOnStage() != 0) {
|
|
i = 0;
|
|
}
|
|
textView.setVisibility(i);
|
|
TextView textView2 = getBinding().b;
|
|
m.checkNotNullExpressionValue(textView2, "binding.alertText");
|
|
Context context = getContext();
|
|
if (context != null) {
|
|
Object[] objArr = new Object[1];
|
|
Context context2 = getContext();
|
|
objArr[0] = context2 != null ? StringResourceUtilsKt.getI18nPluralString(context2, R.plurals.stage_speak_invite_blocked_users_number, stageChannelOngoing.getBlockedUsersOnStage(), Integer.valueOf(stageChannelOngoing.getBlockedUsersOnStage())) : null;
|
|
charSequence = b.h(context, R.string.stage_speak_invite_blocked_users, objArr, null, 4);
|
|
}
|
|
textView2.setText(charSequence);
|
|
return;
|
|
}
|
|
StageInstance stageInstance = stageChannelOngoing.getStageInstance();
|
|
String f = stageInstance != null ? stageInstance.f() : null;
|
|
Guild guild = stageChannelOngoing.getGuild();
|
|
if (guild != null) {
|
|
charSequence = guild.getName();
|
|
}
|
|
String m = stageChannelOngoing.getSelectedVoiceChannel().m();
|
|
Context requireContext = requireContext();
|
|
TextView textView3 = getBinding().i;
|
|
m.checkNotNullExpressionValue(textView3, "binding.indicatorText");
|
|
SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder();
|
|
if (f != null) {
|
|
SpannableUtilsKt.appendWithFont(spannableStringBuilder, requireContext, R.attr.font_primary_semibold, f);
|
|
SpannableUtilsKt.appendWithFont(spannableStringBuilder, requireContext, R.attr.font_primary_semibold, ": ");
|
|
}
|
|
if (charSequence != null) {
|
|
SpannableUtilsKt.appendWithFont(spannableStringBuilder, requireContext, R.attr.font_primary_normal, charSequence);
|
|
SpannableUtilsKt.appendWithFont(spannableStringBuilder, requireContext, R.attr.font_primary_normal, ": ");
|
|
}
|
|
if (m != null) {
|
|
SpannableUtilsKt.appendWithFont(spannableStringBuilder, requireContext, R.attr.font_primary_normal, m);
|
|
}
|
|
textView3.setText(spannableStringBuilder);
|
|
}
|
|
|
|
@Override // com.discord.app.AppFragment
|
|
public void onViewBound(View view) {
|
|
m.checkNotNullParameter(view, "view");
|
|
super.onViewBound(view);
|
|
ViewCompat.setOnApplyWindowInsetsListener(view, WidgetGlobalStatusIndicator$onViewBound$1.INSTANCE);
|
|
}
|
|
|
|
@Override // com.discord.app.AppFragment
|
|
public void onViewBoundOrOnResume() {
|
|
super.onViewBoundOrOnResume();
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.bindToComponentLifecycle$default(this.indicatorState.observeState(), this, null, 2, null), WidgetGlobalStatusIndicator.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetGlobalStatusIndicator$onViewBoundOrOnResume$1(this), 62, (Object) null);
|
|
Observable<WidgetGlobalStatusIndicatorViewModel.ViewState> bindDelay = bindDelay(getViewModel().observeViewState());
|
|
m.checkNotNullExpressionValue(bindDelay, "viewModel\n .obser…te()\n .bindDelay()");
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(bindDelay, this, null, 2, null), WidgetGlobalStatusIndicator.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetGlobalStatusIndicator$onViewBoundOrOnResume$2(this), 62, (Object) null);
|
|
}
|
|
}
|