178 lines
9.6 KiB
Java
178 lines
9.6 KiB
Java
package com.discord.widgets.guilds.join;
|
|
|
|
import android.app.Activity;
|
|
import android.content.Context;
|
|
import android.os.Bundle;
|
|
import android.view.View;
|
|
import android.widget.TextView;
|
|
import androidx.fragment.app.Fragment;
|
|
import androidx.fragment.app.FragmentActivity;
|
|
import androidx.fragment.app.FragmentKt;
|
|
import androidx.fragment.app.FragmentManager;
|
|
import b.a.k.b;
|
|
import b.d.b.a.a;
|
|
import com.discord.R;
|
|
import com.discord.app.AppBottomSheet;
|
|
import com.discord.app.AppFragment;
|
|
import com.discord.databinding.WidgetGuildJoinCaptchaBottomSheetBinding;
|
|
import com.discord.stores.StoreNotices;
|
|
import com.discord.stores.StoreStream;
|
|
import com.discord.utilities.captcha.CaptchaErrorBody;
|
|
import com.discord.utilities.captcha.CaptchaHelper;
|
|
import com.discord.utilities.captcha.CaptchaService;
|
|
import com.discord.utilities.font.FontUtils;
|
|
import com.discord.utilities.rx.ObservableExtensionsKt;
|
|
import com.discord.utilities.viewbinding.FragmentViewBindingDelegate;
|
|
import com.discord.utilities.viewbinding.FragmentViewBindingDelegateKt;
|
|
import com.discord.widgets.tabs.WidgetTabsHost;
|
|
import com.google.android.material.button.MaterialButton;
|
|
import d0.g;
|
|
import d0.z.d.a0;
|
|
import d0.z.d.m;
|
|
import kotlin.Lazy;
|
|
import kotlin.Unit;
|
|
import kotlin.jvm.functions.Function0;
|
|
import kotlin.jvm.functions.Function1;
|
|
import kotlin.jvm.functions.Function2;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
import kotlin.reflect.KProperty;
|
|
/* compiled from: WidgetGuildJoinCaptchaBottomSheet.kt */
|
|
public final class WidgetGuildJoinCaptchaBottomSheet extends AppBottomSheet {
|
|
public static final /* synthetic */ KProperty[] $$delegatedProperties = {a.b0(WidgetGuildJoinCaptchaBottomSheet.class, "binding", "getBinding()Lcom/discord/databinding/WidgetGuildJoinCaptchaBottomSheetBinding;", 0)};
|
|
private static final String ARG_REQUEST_KEY = "INTENT_EXTRA_REQUEST_CODE";
|
|
public static final Companion Companion = new Companion(null);
|
|
private static final String NOTICE_NAME = "guild captcha notice";
|
|
private static final String RESULT_EXTRA_CAPTCHA_RQTOKEN = "INTENT_EXTRA_CAPTCHA_RQTOKEN";
|
|
private static final String RESULT_EXTRA_CAPTCHA_TOKEN = "INTENT_EXTRA_CAPTCHA_TOKEN";
|
|
private final FragmentViewBindingDelegate binding$delegate = FragmentViewBindingDelegateKt.viewBinding$default(this, WidgetGuildJoinCaptchaBottomSheet$binding$2.INSTANCE, null, 2, null);
|
|
private final Lazy captchaErrorBody$delegate = g.lazy(new WidgetGuildJoinCaptchaBottomSheet$captchaErrorBody$2(this));
|
|
private final Lazy requestCode$delegate = g.lazy(new WidgetGuildJoinCaptchaBottomSheet$requestCode$2(this));
|
|
|
|
/* compiled from: WidgetGuildJoinCaptchaBottomSheet.kt */
|
|
public static final class Companion {
|
|
private Companion() {
|
|
}
|
|
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
|
|
public final void enqueue(String str, Function2<? super AppFragment, ? super CaptchaHelper.CaptchaPayload, Unit> function2, CaptchaErrorBody captchaErrorBody) {
|
|
m.checkNotNullParameter(str, "requestKey");
|
|
m.checkNotNullParameter(function2, "onCaptchaPayloadReceived");
|
|
StoreStream.Companion.getNotices().requestToShow(new StoreNotices.Notice(WidgetGuildJoinCaptchaBottomSheet.NOTICE_NAME, null, 0, 0, false, d0.t.m.listOf(a0.getOrCreateKotlinClass(WidgetTabsHost.class)), 0, false, 0, new WidgetGuildJoinCaptchaBottomSheet$Companion$enqueue$guildCaptchaNotice$1(str, captchaErrorBody, function2), FontUtils.MAX_FONT_SCALING, null));
|
|
}
|
|
|
|
public final void registerForResult(AppFragment appFragment, String str, Function2<? super AppFragment, ? super CaptchaHelper.CaptchaPayload, Unit> function2) {
|
|
m.checkNotNullParameter(appFragment, "fragment");
|
|
m.checkNotNullParameter(str, "requestKey");
|
|
m.checkNotNullParameter(function2, "onCaptchaPayloadReceived");
|
|
FragmentKt.setFragmentResultListener(appFragment, str, new WidgetGuildJoinCaptchaBottomSheet$Companion$registerForResult$1(str, function2, appFragment));
|
|
}
|
|
|
|
public final void show(FragmentManager fragmentManager, String str, CaptchaErrorBody captchaErrorBody) {
|
|
m.checkNotNullParameter(fragmentManager, "fragmentManager");
|
|
m.checkNotNullParameter(str, "requestKey");
|
|
WidgetGuildJoinCaptchaBottomSheet widgetGuildJoinCaptchaBottomSheet = new WidgetGuildJoinCaptchaBottomSheet();
|
|
Bundle bundle = new Bundle();
|
|
bundle.putSerializable("INTENT_EXTRA_CAPTCHA_ERROR_BODY", captchaErrorBody);
|
|
bundle.putString(WidgetGuildJoinCaptchaBottomSheet.ARG_REQUEST_KEY, str);
|
|
widgetGuildJoinCaptchaBottomSheet.setArguments(bundle);
|
|
widgetGuildJoinCaptchaBottomSheet.show(fragmentManager, WidgetGuildJoinCaptchaBottomSheet.class.getName());
|
|
}
|
|
}
|
|
|
|
public WidgetGuildJoinCaptchaBottomSheet() {
|
|
super(false, 1, null);
|
|
}
|
|
|
|
public static final /* synthetic */ void access$finishIfCaptchaTokenReceived(WidgetGuildJoinCaptchaBottomSheet widgetGuildJoinCaptchaBottomSheet, Activity activity) {
|
|
widgetGuildJoinCaptchaBottomSheet.finishIfCaptchaTokenReceived(activity);
|
|
}
|
|
|
|
public static final /* synthetic */ Bundle access$getArgumentsOrDefault$p(WidgetGuildJoinCaptchaBottomSheet widgetGuildJoinCaptchaBottomSheet) {
|
|
return widgetGuildJoinCaptchaBottomSheet.getArgumentsOrDefault();
|
|
}
|
|
|
|
public static final /* synthetic */ void access$openCaptcha(WidgetGuildJoinCaptchaBottomSheet widgetGuildJoinCaptchaBottomSheet) {
|
|
widgetGuildJoinCaptchaBottomSheet.openCaptcha();
|
|
}
|
|
|
|
private final void configureUI() {
|
|
TextView textView = getBinding().d;
|
|
m.checkNotNullExpressionValue(textView, "binding.guildJoinCaptchaTitle");
|
|
b.n(textView, R.string.guild_join_captcha_header, new Object[0], null, 4);
|
|
TextView textView2 = getBinding().f2404b;
|
|
m.checkNotNullExpressionValue(textView2, "binding.guildJoinCaptchaBody");
|
|
b.n(textView2, R.string.guild_join_captcha_description, new Object[0], null, 4);
|
|
MaterialButton materialButton = getBinding().c;
|
|
m.checkNotNullExpressionValue(materialButton, "binding.guildJoinCaptchaButton");
|
|
b.n(materialButton, R.string.confirm, new Object[0], null, 4);
|
|
getBinding().c.setOnClickListener(new WidgetGuildJoinCaptchaBottomSheet$configureUI$1(this));
|
|
}
|
|
|
|
private final void finishIfCaptchaTokenReceived(Activity activity) {
|
|
CaptchaHelper captchaHelper = CaptchaHelper.INSTANCE;
|
|
String captchaToken = captchaHelper.getCaptchaToken();
|
|
if (captchaToken != null) {
|
|
String captchaRqtoken = captchaHelper.getCaptchaRqtoken();
|
|
captchaHelper.setCaptchaToken(null);
|
|
captchaHelper.setCaptchaRqtoken(null);
|
|
String requestCode = getRequestCode();
|
|
Bundle bundle = new Bundle();
|
|
bundle.putString(RESULT_EXTRA_CAPTCHA_TOKEN, captchaToken);
|
|
bundle.putString(RESULT_EXTRA_CAPTCHA_RQTOKEN, captchaRqtoken);
|
|
FragmentKt.setFragmentResult(this, requestCode, bundle);
|
|
dismiss();
|
|
}
|
|
}
|
|
|
|
private final WidgetGuildJoinCaptchaBottomSheetBinding getBinding() {
|
|
return (WidgetGuildJoinCaptchaBottomSheetBinding) this.binding$delegate.getValue((Fragment) this, $$delegatedProperties[0]);
|
|
}
|
|
|
|
private final CaptchaErrorBody getCaptchaErrorBody() {
|
|
return (CaptchaErrorBody) this.captchaErrorBody$delegate.getValue();
|
|
}
|
|
|
|
private final String getRequestCode() {
|
|
return (String) this.requestCode$delegate.getValue();
|
|
}
|
|
|
|
private final void openCaptcha() {
|
|
CaptchaHelper.CaptchaRequest captchaRequest;
|
|
String captchaSitekey = getCaptchaErrorBody().getCaptchaSitekey();
|
|
CaptchaService captchaService = getCaptchaErrorBody().getCaptchaService();
|
|
String captchaRqdata = getCaptchaErrorBody().getCaptchaRqdata();
|
|
String captchaRqtoken = getCaptchaErrorBody().getCaptchaRqtoken();
|
|
CaptchaHelper captchaHelper = CaptchaHelper.INSTANCE;
|
|
captchaHelper.setCaptchaRqtoken(captchaRqtoken);
|
|
if (captchaSitekey == null || captchaService != CaptchaService.HCAPTCHA) {
|
|
FragmentActivity requireActivity = requireActivity();
|
|
m.checkNotNullExpressionValue(requireActivity, "requireActivity()");
|
|
captchaRequest = new CaptchaHelper.CaptchaRequest.ReCaptcha(requireActivity);
|
|
} else {
|
|
FragmentActivity requireActivity2 = requireActivity();
|
|
m.checkNotNullExpressionValue(requireActivity2, "requireActivity()");
|
|
captchaRequest = new CaptchaHelper.CaptchaRequest.HCaptcha(captchaSitekey, requireActivity2, captchaRqdata);
|
|
}
|
|
ObservableExtensionsKt.appSubscribe$default(captchaHelper.tryShowCaptcha(captchaRequest), WidgetGuildJoinCaptchaBottomSheet.class, (Context) null, (Function1) null, new WidgetGuildJoinCaptchaBottomSheet$openCaptcha$2(this), (Function0) null, (Function0) null, new WidgetGuildJoinCaptchaBottomSheet$openCaptcha$1(this), 54, (Object) null);
|
|
}
|
|
|
|
public static final void show(FragmentManager fragmentManager, String str, CaptchaErrorBody captchaErrorBody) {
|
|
Companion.show(fragmentManager, str, captchaErrorBody);
|
|
}
|
|
|
|
@Override // com.discord.app.AppBottomSheet
|
|
public int getContentViewResId() {
|
|
return R.layout.widget_guild_join_captcha_bottom_sheet;
|
|
}
|
|
|
|
@Override // com.discord.app.AppBottomSheet, androidx.fragment.app.Fragment
|
|
public void onViewCreated(View view, Bundle bundle) {
|
|
m.checkNotNullParameter(view, "view");
|
|
super.onViewCreated(view, bundle);
|
|
configureUI();
|
|
}
|
|
}
|