discord-jadx/app/src/main/java/com/discord/widgets/tos/WidgetTosReportViolation.java

313 lines
14 KiB
Java

package com.discord.widgets.tos;
import a0.a.a.b;
import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;
import androidx.core.view.ViewCompat;
import androidx.core.view.ViewGroupKt;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentViewModelLazyKt;
import c.a.d.h0;
import c.a.d.j0;
import c.a.d.l;
import c.a.d.o;
import c.d.b.a.a;
import com.discord.api.report.ReportReason;
import com.discord.app.AppActivity;
import com.discord.app.AppFragment;
import com.discord.databinding.WidgetTosReportViolationBinding;
import com.discord.utilities.rx.ObservableExtensionsKt;
import com.discord.utilities.view.text.LinkifiedTextView;
import com.discord.utilities.viewbinding.FragmentViewBindingDelegate;
import com.discord.utilities.viewbinding.FragmentViewBindingDelegateKt;
import com.discord.views.LoadingButton;
import com.discord.widgets.notice.WidgetNoticeDialog;
import com.discord.widgets.tos.WidgetTosReportViolationViewModel;
import d0.g;
import d0.z.d.a0;
import d0.z.d.m;
import java.util.List;
import kotlin.Lazy;
import kotlin.NoWhenBranchMatchedException;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.reflect.KProperty;
/* compiled from: WidgetTosReportViolation.kt */
public final class WidgetTosReportViolation extends AppFragment {
public static final /* synthetic */ KProperty[] $$delegatedProperties = {a.W(WidgetTosReportViolation.class, "binding", "getBinding()Lcom/discord/databinding/WidgetTosReportViolationBinding;", 0)};
public static final Companion Companion = new Companion(null);
private static final String EXTRA_CHANNEL_ID = "EXTRA_CHANNEL_ID";
private static final String EXTRA_MESSAGE_ID = "EXTRA_MESSAGE_ID";
private static final String EXTRA_TARGET = "EXTRA_TARGET";
private final Lazy args$delegate;
private final FragmentViewBindingDelegate binding$delegate = FragmentViewBindingDelegateKt.viewBinding$default(this, WidgetTosReportViolation$binding$2.INSTANCE, null, 2, null);
private final Lazy viewModel$delegate;
/* compiled from: WidgetTosReportViolation.kt */
public static final class Companion {
/* compiled from: WidgetTosReportViolation.kt */
public static final class Arguments {
private final long channelId;
private final long messageId;
private final String target;
public Arguments(String str, long j, long j2) {
m.checkNotNullParameter(str, "target");
this.target = str;
this.channelId = j;
this.messageId = j2;
}
public static /* synthetic */ Arguments copy$default(Arguments arguments, String str, long j, long j2, int i, Object obj) {
if ((i & 1) != 0) {
str = arguments.target;
}
if ((i & 2) != 0) {
j = arguments.channelId;
}
if ((i & 4) != 0) {
j2 = arguments.messageId;
}
return arguments.copy(str, j, j2);
}
public final String component1() {
return this.target;
}
public final long component2() {
return this.channelId;
}
public final long component3() {
return this.messageId;
}
public final Arguments copy(String str, long j, long j2) {
m.checkNotNullParameter(str, "target");
return new Arguments(str, j, j2);
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof Arguments)) {
return false;
}
Arguments arguments = (Arguments) obj;
return m.areEqual(this.target, arguments.target) && this.channelId == arguments.channelId && this.messageId == arguments.messageId;
}
public final long getChannelId() {
return this.channelId;
}
public final long getMessageId() {
return this.messageId;
}
public final String getTarget() {
return this.target;
}
public int hashCode() {
String str = this.target;
int hashCode = str != null ? str.hashCode() : 0;
return b.a(this.messageId) + ((b.a(this.channelId) + (hashCode * 31)) * 31);
}
public String toString() {
StringBuilder L = a.L("Arguments(target=");
L.append(this.target);
L.append(", channelId=");
L.append(this.channelId);
L.append(", messageId=");
return a.A(L, this.messageId, ")");
}
}
private Companion() {
}
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
public static /* synthetic */ void show$default(Companion companion, Context context, String str, Long l, Long l2, int i, Object obj) {
if ((i & 4) != 0) {
l = null;
}
if ((i & 8) != 0) {
l2 = null;
}
companion.show(context, str, l, l2);
}
public final void show(Context context, String str, Long l, Long l2) {
m.checkNotNullParameter(context, "context");
m.checkNotNullParameter(str, "target");
Intent intent = new Intent();
intent.putExtra("EXTRA_CHANNEL_ID", l);
intent.putExtra("EXTRA_MESSAGE_ID", l2);
intent.putExtra("EXTRA_TARGET", str);
l.d(context, WidgetTosReportViolation.class, intent);
}
}
public WidgetTosReportViolation() {
super(2131559262);
WidgetTosReportViolation$viewModel$2 widgetTosReportViolation$viewModel$2 = new WidgetTosReportViolation$viewModel$2(this);
h0 h0Var = new h0(this);
this.viewModel$delegate = FragmentViewModelLazyKt.createViewModelLazy(this, a0.getOrCreateKotlinClass(WidgetTosReportViolationViewModel.class), new WidgetTosReportViolation$appViewModels$$inlined$viewModels$1(h0Var), new j0(widgetTosReportViolation$viewModel$2));
this.args$delegate = g.lazy(new WidgetTosReportViolation$args$2(this));
}
public static final /* synthetic */ void access$configureUI(WidgetTosReportViolation widgetTosReportViolation, WidgetTosReportViolationViewModel.ViewState viewState) {
widgetTosReportViolation.configureUI(viewState);
}
public static final /* synthetic */ Companion.Arguments access$getArgs$p(WidgetTosReportViolation widgetTosReportViolation) {
return widgetTosReportViolation.getArgs();
}
public static final /* synthetic */ WidgetTosReportViolationBinding access$getBinding$p(WidgetTosReportViolation widgetTosReportViolation) {
return widgetTosReportViolation.getBinding();
}
public static final /* synthetic */ Intent access$getMostRecentIntent$p(WidgetTosReportViolation widgetTosReportViolation) {
return widgetTosReportViolation.getMostRecentIntent();
}
public static final /* synthetic */ WidgetTosReportViolationViewModel access$getViewModel$p(WidgetTosReportViolation widgetTosReportViolation) {
return widgetTosReportViolation.getViewModel();
}
private final void configureUI(WidgetTosReportViolationViewModel.ViewState viewState) {
if (viewState instanceof WidgetTosReportViolationViewModel.ViewState.Loading) {
handleLoading();
} else if (viewState instanceof WidgetTosReportViolationViewModel.ViewState.Loaded) {
handleLoaded(((WidgetTosReportViolationViewModel.ViewState.Loaded) viewState).getReasons());
} else if (viewState instanceof WidgetTosReportViolationViewModel.ViewState.Submitting) {
handleReportSubmitting(((WidgetTosReportViolationViewModel.ViewState.Submitting) viewState).getReason());
} else if (viewState instanceof WidgetTosReportViolationViewModel.ViewState.Submitted) {
handleReportSubmitted();
} else if (viewState instanceof WidgetTosReportViolationViewModel.ViewState.SubmissionError) {
handleReportSubmissionError();
} else {
throw new NoWhenBranchMatchedException();
}
}
private final Companion.Arguments getArgs() {
return (Companion.Arguments) this.args$delegate.getValue();
}
private final WidgetTosReportViolationBinding getBinding() {
return (WidgetTosReportViolationBinding) this.binding$delegate.getValue((Fragment) this, $$delegatedProperties[0]);
}
private final WidgetTosReportViolationViewModel getViewModel() {
return (WidgetTosReportViolationViewModel) this.viewModel$delegate.getValue();
}
private final void handleLoaded(List<ReportReason> list) {
ProgressBar progressBar = getBinding().f;
m.checkNotNullExpressionValue(progressBar, "binding.reportReasonsLoading");
progressBar.setVisibility(8);
LoadingButton loadingButton = getBinding().b;
m.checkNotNullExpressionValue(loadingButton, "binding.reportButton");
loadingButton.setEnabled(getViewModel().getReasonSelected() != null);
getBinding().b.setIsLoading(false);
getBinding().b.setOnClickListener(new WidgetTosReportViolation$handleLoaded$1(this));
TextView textView = getBinding().e;
m.checkNotNullExpressionValue(textView, "binding.reportReasonsHeader");
textView.setVisibility(0);
getBinding().d.removeAllViews();
for (ReportReason reportReason : list) {
WidgetTosReportViolationReasonView widgetTosReportViolationReasonView = new WidgetTosReportViolationReasonView(requireContext(), null, 0, 6, null);
if (!ViewCompat.isLaidOut(widgetTosReportViolationReasonView) || widgetTosReportViolationReasonView.isLayoutRequested()) {
widgetTosReportViolationReasonView.addOnLayoutChangeListener(new WidgetTosReportViolation$handleLoaded$$inlined$forEach$lambda$2(widgetTosReportViolationReasonView, reportReason, this));
} else {
widgetTosReportViolationReasonView.setReason(reportReason);
widgetTosReportViolationReasonView.setChecked(m.areEqual(reportReason, access$getViewModel$p(this).getReasonSelected()));
widgetTosReportViolationReasonView.setOnClickListener(new WidgetTosReportViolation$handleLoaded$$inlined$forEach$lambda$1(widgetTosReportViolationReasonView, reportReason, this));
}
getBinding().d.addView(widgetTosReportViolationReasonView);
}
}
private final void handleLoading() {
ProgressBar progressBar = getBinding().f;
m.checkNotNullExpressionValue(progressBar, "binding.reportReasonsLoading");
progressBar.setVisibility(0);
LoadingButton loadingButton = getBinding().b;
m.checkNotNullExpressionValue(loadingButton, "binding.reportButton");
loadingButton.setEnabled(false);
getBinding().d.removeAllViews();
}
private final void handleReportSubmissionError() {
LoadingButton loadingButton = getBinding().b;
m.checkNotNullExpressionValue(loadingButton, "binding.reportButton");
loadingButton.setEnabled(false);
getBinding().b.setIsLoading(false);
WidgetNoticeDialog.Companion companion = WidgetNoticeDialog.Companion;
FragmentManager parentFragmentManager = getParentFragmentManager();
m.checkNotNullExpressionValue(parentFragmentManager, "parentFragmentManager");
WidgetNoticeDialog.Companion.show$default(companion, parentFragmentManager, c.a.l.b.j(this, 2131891530, new Object[0], null, 4), c.a.l.b.j(this, 2131892683, new Object[]{"https://dis.gd/request"}, null, 4), c.a.l.b.j(this, 2131891735, new Object[0], null, 4), null, null, null, null, null, null, null, null, 0, new WidgetTosReportViolation$handleReportSubmissionError$1(this), 8176, null);
}
private final void handleReportSubmitted() {
o.i(this, 2131892692, 0, 4);
AppActivity appActivity = getAppActivity();
if (appActivity != null) {
appActivity.finish();
}
}
private final void handleReportSubmitting(int i) {
LinearLayout linearLayout = getBinding().d;
m.checkNotNullExpressionValue(linearLayout, "binding.reportReasonsContainer");
for (View view : ViewGroupKt.getChildren(linearLayout)) {
view.setEnabled(false);
}
LoadingButton loadingButton = getBinding().b;
m.checkNotNullExpressionValue(loadingButton, "binding.reportButton");
loadingButton.setEnabled(false);
getBinding().b.setIsLoading(true);
getViewModel().sendReportAPICall(i, getArgs().getChannelId(), getArgs().getMessageId());
}
@Override // com.discord.app.AppFragment
public void onViewBound(View view) {
m.checkNotNullParameter(view, "view");
super.onViewBound(view);
setActionBarTitle(2131892676);
AppFragment.setActionBarDisplayHomeAsUpEnabled$default(this, false, 1, null);
TextView textView = getBinding().f1982c;
m.checkNotNullExpressionValue(textView, "binding.reportHeader");
c.a.l.b.m(textView, 2131892677, new Object[]{getArgs().getTarget()}, null, 4);
LinkifiedTextView linkifiedTextView = getBinding().g;
m.checkNotNullExpressionValue(linkifiedTextView, "binding.reportTooltip");
c.a.l.b.m(linkifiedTextView, 2131888776, new Object[]{"https://discord.com/guidelines"}, null, 4);
getBinding().b.setIsLoading(false);
LoadingButton loadingButton = getBinding().b;
m.checkNotNullExpressionValue(loadingButton, "binding.reportButton");
loadingButton.setEnabled(false);
}
@Override // com.discord.app.AppFragment
public void onViewBoundOrOnResume() {
super.onViewBoundOrOnResume();
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.bindToComponentLifecycle(getViewModel().observeViewState(), this), WidgetTosReportViolation.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetTosReportViolation$onViewBoundOrOnResume$1(this), 62, (Object) null);
}
}