discord-jadx/app/src/main/java/com/discord/widgets/auth/WidgetAgeVerify.java

237 lines
13 KiB
Java

package com.discord.widgets.auth;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.text.SpannableStringBuilder;
import android.view.View;
import android.view.animation.AnimationUtils;
import android.widget.TextView;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentViewModelLazyKt;
import c.a.d.f;
import c.a.d.h0;
import c.a.d.j0;
import c.a.d.l;
import c.a.d.o;
import c.a.k.b;
import c.d.b.a.a;
import com.discord.app.AppFragment;
import com.discord.app.AppViewFlipper;
import com.discord.databinding.WidgetAgeVerifyBinding;
import com.discord.utilities.analytics.AnalyticsTracker;
import com.discord.utilities.birthday.BirthdayHelper;
import com.discord.utilities.resources.StringResourceUtilsKt;
import com.discord.utilities.rx.ObservableExtensionsKt;
import com.discord.utilities.view.extensions.ViewExtensions;
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.auth.WidgetAgeVerifyViewModel;
import com.google.android.material.textfield.TextInputLayout;
import d0.z.d.a0;
import d0.z.d.m;
import java.text.DateFormat;
import java.util.Calendar;
import kotlin.Lazy;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.reflect.KProperty;
/* compiled from: WidgetAgeVerify.kt */
public final class WidgetAgeVerify extends AppFragment {
public static final /* synthetic */ KProperty[] $$delegatedProperties = {a.V(WidgetAgeVerify.class, "binding", "getBinding()Lcom/discord/databinding/WidgetAgeVerifyBinding;", 0)};
public static final Companion Companion = new Companion(null);
private static final String INTENT_EXTRA_NSFW_CHANNEL = "INTENT_EXTRA_NSFW_CHANNEL";
private final FragmentViewBindingDelegate binding$delegate = FragmentViewBindingDelegateKt.viewBinding$default(this, WidgetAgeVerify$binding$2.INSTANCE, null, 2, null);
private final Lazy viewModel$delegate;
/* compiled from: WidgetAgeVerify.kt */
public static final class Companion {
private Companion() {
}
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
public static /* synthetic */ void start$default(Companion companion, Context context, boolean z2, int i, Object obj) {
if ((i & 2) != 0) {
z2 = false;
}
companion.start(context, z2);
}
public final void start(Context context, boolean z2) {
m.checkNotNullParameter(context, "context");
AnalyticsTracker.openModal$default("Age Gate", "", null, 4, null);
Bundle bundle = new Bundle();
bundle.putBoolean("INTENT_EXTRA_NSFW_CHANNEL", z2);
l.d(context, WidgetAgeVerify.class, new Intent().putExtras(bundle));
}
}
public WidgetAgeVerify() {
super(2131558847);
WidgetAgeVerify$viewModel$2 widgetAgeVerify$viewModel$2 = WidgetAgeVerify$viewModel$2.INSTANCE;
h0 h0Var = new h0(this);
this.viewModel$delegate = FragmentViewModelLazyKt.createViewModelLazy(this, a0.getOrCreateKotlinClass(WidgetAgeVerifyViewModel.class), new WidgetAgeVerify$appViewModels$$inlined$viewModels$1(h0Var), new j0(widgetAgeVerify$viewModel$2));
}
public static final /* synthetic */ void access$configureUI(WidgetAgeVerify widgetAgeVerify, WidgetAgeVerifyViewModel.ViewState viewState) {
widgetAgeVerify.configureUI(viewState);
}
public static final /* synthetic */ WidgetAgeVerifyBinding access$getBinding$p(WidgetAgeVerify widgetAgeVerify) {
return widgetAgeVerify.getBinding();
}
public static final /* synthetic */ WidgetAgeVerifyViewModel access$getViewModel$p(WidgetAgeVerify widgetAgeVerify) {
return widgetAgeVerify.getViewModel();
}
public static final /* synthetic */ void access$handleEvent(WidgetAgeVerify widgetAgeVerify, WidgetAgeVerifyViewModel.Event event) {
widgetAgeVerify.handleEvent(event);
}
private final void configureBirthdayInput(WidgetAgeVerifyViewModel.ViewState viewState) {
Long dateOfBirth = viewState.getDateOfBirth();
Calendar instance = Calendar.getInstance();
m.checkNotNullExpressionValue(instance, "Calendar.getInstance()");
instance.setTimeInMillis(dateOfBirth != null ? dateOfBirth.longValue() : BirthdayHelper.INSTANCE.getMaxDateOfBirth());
DateFormat dateInstance = DateFormat.getDateInstance(3);
if (dateOfBirth != null) {
m.checkNotNullExpressionValue(dateInstance, "formatter");
dateInstance.setTimeZone(instance.getTimeZone());
String format = dateInstance.format(Long.valueOf(instance.getTimeInMillis()));
TextInputLayout textInputLayout = getBinding().e.f185c;
m.checkNotNullExpressionValue(textInputLayout, "binding.verify.ageVerifyInputWrapper");
ViewExtensions.setText(textInputLayout, new SpannableStringBuilder(format));
}
if (viewState.getErrorStringId() != null) {
TextInputLayout textInputLayout2 = getBinding().e.f185c;
m.checkNotNullExpressionValue(textInputLayout2, "binding.verify.ageVerifyInputWrapper");
textInputLayout2.setError(b.j(this, viewState.getErrorStringId().intValue(), new Object[0], null, 4));
}
TextInputLayout textInputLayout3 = getBinding().e.f185c;
m.checkNotNullExpressionValue(textInputLayout3, "binding.verify.ageVerifyInputWrapper");
ViewExtensions.setOnEditTextClickListener(textInputLayout3, new WidgetAgeVerify$configureBirthdayInput$1(this, dateOfBirth));
}
/* JADX DEBUG: Can't convert new array creation: APUT found in different block: 0x00b9: APUT (r6v2 java.lang.Object[]), (0 ??[int, short, byte, char]), (r8v2 java.lang.String) */
private final void configureUI(WidgetAgeVerifyViewModel.ViewState viewState) {
Long dateOfBirth;
if (viewState.getShouldClose() && viewState.getDisplayedChild() != 2) {
requireActivity().finish();
}
getBinding().e.d.setIsLoading(viewState.isSubmitting());
LoadingButton loadingButton = getBinding().e.d;
m.checkNotNullExpressionValue(loadingButton, "binding.verify.ageVerifyNextButton");
loadingButton.setEnabled(viewState.getDateOfBirth() != null);
getBinding().f1674c.f191c.setIsLoading(viewState.isSubmitting());
LoadingButton loadingButton2 = getBinding().f1674c.f191c;
m.checkNotNullExpressionValue(loadingButton2, "binding.confirm.ageVerifyConfirmButton");
loadingButton2.setEnabled(viewState.getDateOfBirth() != null);
Resources resources = getResources();
m.checkNotNullExpressionValue(resources, "resources");
CharSequence quantityString = StringResourceUtilsKt.getQuantityString(resources, requireContext(), 2131755015, 30, 30);
TextView textView = getBinding().d.d;
m.checkNotNullExpressionValue(textView, "binding.underage.underageWarning");
b.m(textView, 2131886333, new Object[]{quantityString}, null, 4);
LinkifiedTextView linkifiedTextView = getBinding().d.f59c;
m.checkNotNullExpressionValue(linkifiedTextView, "binding.underage.ageVerifyUnderageDescription");
Object[] objArr = new Object[2];
String underageMessage = viewState.getUnderageMessage();
if (underageMessage == null) {
underageMessage = "";
}
objArr[0] = underageMessage;
objArr[1] = f.a.a(360040724612L, null);
b.m(linkifiedTextView, 2131886329, objArr, null, 4);
if (viewState.getDisplayedChild() == 2) {
requireAppActivity().r = false;
AppFragment.hideKeyboard$default(this, null, 1, null);
}
if (viewState.getDisplayedChild() == 1 && (dateOfBirth = viewState.getDateOfBirth()) != null) {
int age = BirthdayHelper.INSTANCE.getAge(dateOfBirth.longValue());
TextView textView2 = getBinding().f1674c.e;
m.checkNotNullExpressionValue(textView2, "binding.confirm.ageVerifyConfirmTitle");
b.m(textView2, 2131886311, new Object[]{String.valueOf(age)}, null, 4);
}
configureBirthdayInput(viewState);
configureViewFlipper(viewState.getDisplayedChild());
AppFragment.setOnBackPressed$default(this, new WidgetAgeVerify$configureUI$1(this), 0, 2, null);
}
private final void configureViewFlipper(int i) {
AppViewFlipper appViewFlipper = getBinding().b;
m.checkNotNullExpressionValue(appViewFlipper, "binding.ageVerifyViewFlipper");
if (i > appViewFlipper.getDisplayedChild()) {
AppViewFlipper appViewFlipper2 = getBinding().b;
m.checkNotNullExpressionValue(appViewFlipper2, "binding.ageVerifyViewFlipper");
appViewFlipper2.setInAnimation(AnimationUtils.loadAnimation(getContext(), 2130771990));
AppViewFlipper appViewFlipper3 = getBinding().b;
m.checkNotNullExpressionValue(appViewFlipper3, "binding.ageVerifyViewFlipper");
appViewFlipper3.setOutAnimation(AnimationUtils.loadAnimation(getContext(), 2130771991));
} else {
AppViewFlipper appViewFlipper4 = getBinding().b;
m.checkNotNullExpressionValue(appViewFlipper4, "binding.ageVerifyViewFlipper");
if (i < appViewFlipper4.getDisplayedChild()) {
AppViewFlipper appViewFlipper5 = getBinding().b;
m.checkNotNullExpressionValue(appViewFlipper5, "binding.ageVerifyViewFlipper");
appViewFlipper5.setInAnimation(AnimationUtils.loadAnimation(getContext(), 2130771988));
AppViewFlipper appViewFlipper6 = getBinding().b;
m.checkNotNullExpressionValue(appViewFlipper6, "binding.ageVerifyViewFlipper");
appViewFlipper6.setOutAnimation(AnimationUtils.loadAnimation(getContext(), 2130771989));
}
}
AppViewFlipper appViewFlipper7 = getBinding().b;
m.checkNotNullExpressionValue(appViewFlipper7, "binding.ageVerifyViewFlipper");
appViewFlipper7.setDisplayedChild(i);
}
private final WidgetAgeVerifyBinding getBinding() {
return (WidgetAgeVerifyBinding) this.binding$delegate.getValue((Fragment) this, $$delegatedProperties[0]);
}
private final WidgetAgeVerifyViewModel getViewModel() {
return (WidgetAgeVerifyViewModel) this.viewModel$delegate.getValue();
}
private final void handleEvent(WidgetAgeVerifyViewModel.Event event) {
if (m.areEqual(event, WidgetAgeVerifyViewModel.Event.Verified.INSTANCE)) {
Context context = getContext();
o.f(this, context != null ? context.getString(2131886306) : null, 1);
requireActivity().finish();
}
}
@Override // com.discord.app.AppFragment
public void onViewBound(View view) {
m.checkNotNullParameter(view, "view");
super.onViewBound(view);
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.bindToComponentLifecycle(getViewModel().observeViewState(), this), WidgetAgeVerify.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetAgeVerify$onViewBound$1(this), 62, (Object) null);
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.bindToComponentLifecycle(getViewModel().observeEvents(), this), WidgetAgeVerify.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetAgeVerify$onViewBound$2(this), 62, (Object) null);
}
@Override // com.discord.app.AppFragment
public void onViewBoundOrOnResume() {
super.onViewBoundOrOnResume();
getBinding().d.b.setOnClickListener(new WidgetAgeVerify$onViewBoundOrOnResume$1(this));
boolean booleanExtra = getMostRecentIntent().getBooleanExtra("INTENT_EXTRA_NSFW_CHANNEL", false);
LinkifiedTextView linkifiedTextView = getBinding().e.b;
m.checkNotNullExpressionValue(linkifiedTextView, "binding.verify.ageVerifyDescription");
b.m(linkifiedTextView, booleanExtra ? 2131886323 : 2131886308, new Object[]{f.a.a(360040724612L, null)}, null, 4);
LinkifiedTextView linkifiedTextView2 = getBinding().f1674c.d;
m.checkNotNullExpressionValue(linkifiedTextView2, "binding.confirm.ageVerifyConfirmDescription");
LinkifiedTextView linkifiedTextView3 = getBinding().e.b;
m.checkNotNullExpressionValue(linkifiedTextView3, "binding.verify.ageVerifyDescription");
linkifiedTextView2.setText(linkifiedTextView3.getText());
getBinding().e.d.setOnClickListener(new WidgetAgeVerify$onViewBoundOrOnResume$2(this, booleanExtra));
getBinding().f1674c.f191c.setOnClickListener(new WidgetAgeVerify$onViewBoundOrOnResume$3(this, booleanExtra));
getBinding().f1674c.b.setOnClickListener(new WidgetAgeVerify$onViewBoundOrOnResume$4(this));
}
}