discord-jadx/app/src/main/java/com/discord/widgets/notice/WidgetNoticeDialog.java

470 lines
24 KiB
Java

package com.discord.widgets.notice;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.res.Resources;
import android.os.Bundle;
import android.text.Spannable;
import android.text.method.LinkMovementMethod;
import android.util.TypedValue;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.AttrRes;
import androidx.annotation.LayoutRes;
import androidx.annotation.StringRes;
import androidx.appcompat.widget.ActivityChooserModel;
import androidx.core.app.NotificationCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import b.a.k.b;
import b.d.b.a.a;
import com.discord.R;
import com.discord.app.AppActivity;
import com.discord.app.AppDialog;
import com.discord.app.AppLog;
import com.discord.databinding.WidgetNoticeDialogBinding;
import com.discord.stores.StoreNotices;
import com.discord.stores.StoreStream;
import com.discord.utilities.logging.Logger;
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.google.android.material.button.MaterialButton;
import d0.g0.t;
import d0.o;
import d0.t.h0;
import d0.z.d.m;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
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: WidgetNoticeDialog.kt */
public final class WidgetNoticeDialog extends AppDialog {
public static final /* synthetic */ KProperty[] $$delegatedProperties = {a.b0(WidgetNoticeDialog.class, "binding", "getBinding()Lcom/discord/databinding/WidgetNoticeDialogBinding;", 0)};
private static final String ARG_ABOVE_LAYOUT_ID = "above_layout_id";
private static final String ARG_BELOW_LAYOUT_ID = "below_layout_id";
private static final String ARG_BODY_TEXT = "body_text";
private static final String ARG_BODY_TEXT_ALIGNMENT = "body_text_alignment";
private static final String ARG_CANCELABLE = "cancelable";
private static final String ARG_CANCEL_TEXT = "cancel_text";
private static final String ARG_HEADER_TEXT = "header_text";
private static final String ARG_NOTICE_TYPE = "notice_type";
private static final String ARG_OK_TEXT = "ok_text";
private static final String ARG_STACK_TRACE_CALLER_FRAME = "stack_trace_caller_frame";
private static final String ARG_THEME_ID = "theme_id";
/* renamed from: CANCEL_BUTTON */
public static final int notice_cancel = 2131364478;
public static final Companion Companion = new Companion(null);
/* renamed from: OK_BUTTON */
public static final int notice_ok = 2131364483;
public static final int ON_SHOW = 0;
private final FragmentViewBindingDelegate binding$delegate = FragmentViewBindingDelegateKt.viewBinding$default(this, WidgetNoticeDialog$binding$2.INSTANCE, null, 2, null);
private Map<Integer, ? extends Function1<? super View, Unit>> listenerMap;
private Function0<Unit> onDismiss;
/* compiled from: WidgetNoticeDialog.kt */
public static final class ActionLinkMovementMethod extends LinkMovementMethod {
private final Function0<Unit> linkAction;
public ActionLinkMovementMethod(Function0<Unit> function0) {
m.checkNotNullParameter(function0, "linkAction");
this.linkAction = function0;
}
@Override // android.text.method.LinkMovementMethod, android.text.method.ScrollingMovementMethod, android.text.method.BaseMovementMethod, android.text.method.MovementMethod
public boolean onTouchEvent(TextView textView, Spannable spannable, MotionEvent motionEvent) {
m.checkNotNullParameter(textView, "widget");
m.checkNotNullParameter(spannable, "buffer");
m.checkNotNullParameter(motionEvent, "event");
boolean onTouchEvent = super.onTouchEvent(textView, spannable, motionEvent);
if (motionEvent.getAction() == 1) {
this.linkAction.mo1invoke();
}
return onTouchEvent;
}
}
/* compiled from: WidgetNoticeDialog.kt */
public static final class Builder {
private String cancelText = "";
private String confirmText = "";
private final Context context;
private boolean isCancelable;
private CharSequence message = "";
private Function1<? super View, Unit> onCancel = WidgetNoticeDialog$Builder$onCancel$1.INSTANCE;
private Function1<? super View, Unit> onConfirm = WidgetNoticeDialog$Builder$onConfirm$1.INSTANCE;
private String tag;
private Integer themeId;
private CharSequence title = "";
public Builder(Context context) {
m.checkNotNullParameter(context, "context");
this.context = context;
}
/* JADX DEBUG: Multi-variable search result rejected for r0v0, resolved type: com.discord.widgets.notice.WidgetNoticeDialog$Builder */
/* JADX WARN: Multi-variable type inference failed */
public static /* synthetic */ Builder setNegativeButton$default(Builder builder, int i, Function1 function1, int i2, Object obj) {
if ((i2 & 2) != 0) {
function1 = WidgetNoticeDialog$Builder$setNegativeButton$2.INSTANCE;
}
return builder.setNegativeButton(i, function1);
}
/* JADX DEBUG: Multi-variable search result rejected for r0v0, resolved type: com.discord.widgets.notice.WidgetNoticeDialog$Builder */
/* JADX WARN: Multi-variable type inference failed */
public static /* synthetic */ Builder setNegativeButton$default(Builder builder, String str, Function1 function1, int i, Object obj) {
if ((i & 2) != 0) {
function1 = WidgetNoticeDialog$Builder$setNegativeButton$1.INSTANCE;
}
return builder.setNegativeButton(str, function1);
}
/* JADX DEBUG: Multi-variable search result rejected for r0v0, resolved type: com.discord.widgets.notice.WidgetNoticeDialog$Builder */
/* JADX WARN: Multi-variable type inference failed */
public static /* synthetic */ Builder setPositiveButton$default(Builder builder, int i, Function1 function1, int i2, Object obj) {
if ((i2 & 2) != 0) {
function1 = WidgetNoticeDialog$Builder$setPositiveButton$2.INSTANCE;
}
return builder.setPositiveButton(i, function1);
}
/* JADX DEBUG: Multi-variable search result rejected for r0v0, resolved type: com.discord.widgets.notice.WidgetNoticeDialog$Builder */
/* JADX WARN: Multi-variable type inference failed */
public static /* synthetic */ Builder setPositiveButton$default(Builder builder, String str, Function1 function1, int i, Object obj) {
if ((i & 2) != 0) {
function1 = WidgetNoticeDialog$Builder$setPositiveButton$1.INSTANCE;
}
return builder.setPositiveButton(str, function1);
}
public final Context getContext() {
return this.context;
}
public final Builder setCancelable(boolean z2) {
this.isCancelable = z2;
return this;
}
public final Builder setDialogAttrTheme(@AttrRes int i) {
this.themeId = Integer.valueOf(i);
return this;
}
public final Builder setMessage(@StringRes int i) {
this.message = b.h(this.context, i, new Object[0], null, 4);
return this;
}
public final Builder setMessage(CharSequence charSequence) {
m.checkNotNullParameter(charSequence, NotificationCompat.MessagingStyle.Message.KEY_TEXT);
this.message = charSequence;
return this;
}
public final Builder setNegativeButton(@StringRes int i, Function1<? super View, Unit> function1) {
m.checkNotNullParameter(function1, "onCancel");
String string = this.context.getString(i);
m.checkNotNullExpressionValue(string, "context.getString(stringResId)");
this.cancelText = string;
this.onCancel = function1;
return this;
}
public final Builder setNegativeButton(String str, Function1<? super View, Unit> function1) {
m.checkNotNullParameter(str, NotificationCompat.MessagingStyle.Message.KEY_TEXT);
m.checkNotNullParameter(function1, "onCancel");
this.cancelText = str;
this.onCancel = function1;
return this;
}
public final Builder setPositiveButton(@StringRes int i, Function1<? super View, Unit> function1) {
m.checkNotNullParameter(function1, "onConfirm");
String string = this.context.getString(i);
m.checkNotNullExpressionValue(string, "context.getString(stringResId)");
this.confirmText = string;
this.onConfirm = function1;
return this;
}
public final Builder setPositiveButton(String str, Function1<? super View, Unit> function1) {
m.checkNotNullParameter(str, NotificationCompat.MessagingStyle.Message.KEY_TEXT);
m.checkNotNullParameter(function1, "onConfirm");
this.confirmText = str;
this.onConfirm = function1;
return this;
}
public final Builder setTag(String str) {
m.checkNotNullParameter(str, "tag");
this.tag = str;
return this;
}
public final Builder setTitle(@StringRes int i) {
String string = this.context.getString(i);
m.checkNotNullExpressionValue(string, "context.getString(stringResId)");
this.title = string;
return this;
}
public final Builder setTitle(CharSequence charSequence) {
m.checkNotNullParameter(charSequence, NotificationCompat.MessagingStyle.Message.KEY_TEXT);
this.title = charSequence;
return this;
}
public final void show(FragmentManager fragmentManager) {
m.checkNotNullParameter(fragmentManager, "fragmentManager");
Companion.show$default(WidgetNoticeDialog.Companion, fragmentManager, this.title, this.message, this.confirmText, this.cancelText, h0.mapOf(o.to(Integer.valueOf((int) R.id.notice_ok), this.onConfirm), o.to(Integer.valueOf((int) R.id.notice_cancel), this.onCancel)), null, null, null, this.themeId, null, null, 0, null, 15808, null);
}
}
/* compiled from: WidgetNoticeDialog.kt */
public static final class Companion {
private Companion() {
}
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
public static /* synthetic */ void show$default(Companion companion, FragmentManager fragmentManager, CharSequence charSequence, CharSequence charSequence2, CharSequence charSequence3, CharSequence charSequence4, Map map, StoreNotices.Dialog.Type type, Integer num, Integer num2, Integer num3, Boolean bool, String str, int i, Function0 function0, int i2, Object obj) {
companion.show(fragmentManager, (i2 & 2) != 0 ? null : charSequence, charSequence2, charSequence3, (i2 & 16) != 0 ? null : charSequence4, (i2 & 32) != 0 ? null : map, (i2 & 64) != 0 ? null : type, (i2 & 128) != 0 ? null : num, (i2 & 256) != 0 ? null : num2, (i2 & 512) != 0 ? null : num3, (i2 & 1024) != 0 ? null : bool, (i2 & 2048) != 0 ? null : str, (i2 & 4096) != 0 ? 2 : i, (i2 & 8192) != 0 ? null : function0);
}
public static /* synthetic */ void showInputModal$default(Companion companion, AppActivity appActivity, CharSequence charSequence, CharSequence charSequence2, CharSequence charSequence3, Function2 function2, Function0 function0, Boolean bool, int i, Object obj) {
companion.showInputModal(appActivity, charSequence, charSequence2, charSequence3, function2, (i & 32) != 0 ? null : function0, (i & 64) != 0 ? null : bool);
}
public final void show(FragmentManager fragmentManager, CharSequence charSequence, CharSequence charSequence2, CharSequence charSequence3, CharSequence charSequence4, Map<Integer, ? extends Function1<? super View, Unit>> map, StoreNotices.Dialog.Type type, @LayoutRes Integer num, @LayoutRes Integer num2, Integer num3, Boolean bool, String str, int i, Function0<Unit> function0) {
m.checkNotNullParameter(fragmentManager, "fragmentManager");
m.checkNotNullParameter(charSequence2, "bodyText");
WidgetNoticeDialog widgetNoticeDialog = new WidgetNoticeDialog();
widgetNoticeDialog.setListenerMap(map);
widgetNoticeDialog.setOnDismiss(function0);
Bundle bundle = new Bundle();
bundle.putCharSequence(WidgetNoticeDialog.ARG_HEADER_TEXT, charSequence);
bundle.putCharSequence(WidgetNoticeDialog.ARG_BODY_TEXT, charSequence2);
bundle.putCharSequence(WidgetNoticeDialog.ARG_OK_TEXT, charSequence3);
bundle.putCharSequence(WidgetNoticeDialog.ARG_CANCEL_TEXT, charSequence4);
if (type != null) {
bundle.putString(WidgetNoticeDialog.ARG_NOTICE_TYPE, type.name());
}
if (num != null) {
bundle.putInt(WidgetNoticeDialog.ARG_ABOVE_LAYOUT_ID, num.intValue());
}
if (num2 != null) {
bundle.putInt(WidgetNoticeDialog.ARG_BELOW_LAYOUT_ID, num2.intValue());
}
if (num3 != null) {
bundle.putInt(WidgetNoticeDialog.ARG_THEME_ID, num3.intValue());
}
if (bool != null) {
bundle.putBoolean(WidgetNoticeDialog.ARG_CANCELABLE, bool.booleanValue());
}
bundle.putInt(WidgetNoticeDialog.ARG_BODY_TEXT_ALIGNMENT, i);
Thread currentThread = Thread.currentThread();
m.checkNotNullExpressionValue(currentThread, "Thread.currentThread()");
StackTraceElement[] stackTrace = currentThread.getStackTrace();
String stackTraceElement = stackTrace.length > 4 ? stackTrace[4].toString() : "";
m.checkNotNullExpressionValue(stackTraceElement, "if (stacktrace.size > 4)…ace[4].toString() else \"\"");
bundle.putString(WidgetNoticeDialog.ARG_STACK_TRACE_CALLER_FRAME, stackTraceElement);
widgetNoticeDialog.setArguments(bundle);
if (str == null) {
str = WidgetNoticeDialog.class.getSimpleName();
}
widgetNoticeDialog.show(fragmentManager, str);
}
public final void showInputModal(AppActivity appActivity, CharSequence charSequence, CharSequence charSequence2, CharSequence charSequence3, Function2<? super Context, ? super String, Unit> function2, Function0<Unit> function0, Boolean bool) {
m.checkNotNullParameter(appActivity, ActivityChooserModel.ATTRIBUTE_ACTIVITY);
m.checkNotNullParameter(charSequence, "headerText");
m.checkNotNullParameter(charSequence2, "bodyText");
m.checkNotNullParameter(charSequence3, "hintText");
m.checkNotNullParameter(function2, "onOKClicked");
HashMap hashMap = new HashMap();
hashMap.put(Integer.valueOf((int) R.id.notice_ok), new WidgetNoticeDialog$Companion$showInputModal$1(function2));
if (function0 != null) {
hashMap.put(Integer.valueOf((int) R.id.notice_cancel), new WidgetNoticeDialog$Companion$showInputModal$2(function0));
}
hashMap.put(0, new WidgetNoticeDialog$Companion$showInputModal$3(charSequence3));
FragmentManager supportFragmentManager = appActivity.getSupportFragmentManager();
m.checkNotNullExpressionValue(supportFragmentManager, "activity.supportFragmentManager");
show$default(this, supportFragmentManager, charSequence, charSequence2, appActivity.getString(R.string.confirm), appActivity.getString(R.string.cancel), hashMap, null, null, Integer.valueOf((int) R.layout.view_input_modal), null, bool, null, 0, null, 15040, null);
}
}
public WidgetNoticeDialog() {
super(R.layout.widget_notice_dialog);
}
private final WidgetNoticeDialogBinding getBinding() {
return (WidgetNoticeDialogBinding) this.binding$delegate.getValue((Fragment) this, $$delegatedProperties[0]);
}
private final Integer insertLayoutInBundle(Bundle bundle, String str, int i) {
if (bundle == null) {
return null;
}
Integer valueOf = Integer.valueOf(bundle.getInt(str));
if (!(valueOf.intValue() != 0)) {
valueOf = null;
}
if (valueOf == null) {
return null;
}
getBinding().f2479b.addView(getLayoutInflater().inflate(valueOf.intValue(), (ViewGroup) getBinding().f2479b, false), i);
return valueOf;
}
public static /* synthetic */ Integer insertLayoutInBundle$default(WidgetNoticeDialog widgetNoticeDialog, Bundle bundle, String str, int i, int i2, Object obj) {
if ((i2 & 2) != 0) {
i = 0;
}
return widgetNoticeDialog.insertLayoutInBundle(bundle, str, i);
}
public static final void show(FragmentManager fragmentManager, CharSequence charSequence, CharSequence charSequence2, CharSequence charSequence3, CharSequence charSequence4, Map<Integer, ? extends Function1<? super View, Unit>> map, StoreNotices.Dialog.Type type, @LayoutRes Integer num, @LayoutRes Integer num2, Integer num3, Boolean bool, String str, int i, Function0<Unit> function0) {
Companion.show(fragmentManager, charSequence, charSequence2, charSequence3, charSequence4, map, type, num, num2, num3, bool, str, i, function0);
}
/* JADX DEBUG: Type inference failed for r0v0. Raw type applied. Possible types: java.util.Map<java.lang.Integer, ? extends kotlin.jvm.functions.Function1<? super android.view.View, kotlin.Unit>>, java.util.Map<java.lang.Integer, kotlin.jvm.functions.Function1<android.view.View, kotlin.Unit>> */
public final Map<Integer, Function1<View, Unit>> getListenerMap() {
return this.listenerMap;
}
public final Function0<Unit> getOnDismiss() {
return this.onDismiss;
}
public final void logOnStartError(Exception exc) {
m.checkNotNullParameter(exc, "exception");
Bundle arguments = getArguments();
Serializable serializable = arguments != null ? arguments.getSerializable(ARG_STACK_TRACE_CALLER_FRAME) : null;
AppLog appLog = AppLog.g;
Logger.e$default(appLog, "failed to start WidgetNoticeDialog from " + serializable, exc, null, 4, null);
}
@Override // com.discord.app.AppDialog, androidx.fragment.app.DialogFragment
public Dialog onCreateDialog(Bundle bundle) {
Resources.Theme theme;
Bundle arguments = getArguments();
if (arguments != null) {
TypedValue typedValue = new TypedValue();
Context context = getContext();
if (!(context == null || (theme = context.getTheme()) == null)) {
theme.resolveAttribute(arguments.getInt(ARG_THEME_ID, R.attr.dialogTheme), typedValue, true);
}
setStyle(1, typedValue.resourceId);
}
return super.onCreateDialog(bundle);
}
@Override // androidx.fragment.app.DialogFragment, android.content.DialogInterface.OnDismissListener
public void onDismiss(DialogInterface dialogInterface) {
m.checkNotNullParameter(dialogInterface, "dialog");
Function0<Unit> function0 = this.onDismiss;
if (function0 != null) {
function0.mo1invoke();
}
super.onDismiss(dialogInterface);
}
@Override // com.discord.app.AppDialog
public void onViewBound(View view) {
Map<Integer, ? extends Function1<? super View, Unit>> map;
Function1 function1;
String string;
m.checkNotNullParameter(view, "view");
super.onViewBound(view);
Bundle arguments = getArguments();
setCancelable(arguments != null ? arguments.getBoolean(ARG_CANCELABLE, true) : true);
Bundle arguments2 = getArguments();
if (!(arguments2 == null || (string = arguments2.getString(ARG_NOTICE_TYPE)) == null)) {
StoreNotices notices = StoreStream.Companion.getNotices();
m.checkNotNullExpressionValue(string, "it");
notices.markDialogSeen(string);
}
Bundle arguments3 = getArguments();
CharSequence charSequence = null;
CharSequence charSequence2 = arguments3 != null ? arguments3.getCharSequence(ARG_HEADER_TEXT) : null;
TextView textView = getBinding().e;
m.checkNotNullExpressionValue(textView, "binding.noticeHeader");
textView.setText(charSequence2);
LinearLayout linearLayout = getBinding().f;
m.checkNotNullExpressionValue(linearLayout, "binding.noticeHeaderContainer");
linearLayout.setVisibility((charSequence2 == null || t.isBlank(charSequence2)) ^ true ? 0 : 8);
LinkifiedTextView linkifiedTextView = getBinding().c;
m.checkNotNullExpressionValue(linkifiedTextView, "binding.noticeBodyText");
Bundle arguments4 = getArguments();
linkifiedTextView.setText(arguments4 != null ? arguments4.getCharSequence(ARG_BODY_TEXT) : null);
if (isCancelable()) {
LinkifiedTextView linkifiedTextView2 = getBinding().c;
m.checkNotNullExpressionValue(linkifiedTextView2, "binding.noticeBodyText");
linkifiedTextView2.setMovementMethod(new ActionLinkMovementMethod(new WidgetNoticeDialog$onViewBound$2(this)));
}
LinkifiedTextView linkifiedTextView3 = getBinding().c;
m.checkNotNullExpressionValue(linkifiedTextView3, "binding.noticeBodyText");
Bundle arguments5 = getArguments();
linkifiedTextView3.setTextAlignment(arguments5 != null ? arguments5.getInt(ARG_BODY_TEXT_ALIGNMENT) : 2);
MaterialButton materialButton = getBinding().g;
m.checkNotNullExpressionValue(materialButton, "binding.noticeOk");
Bundle arguments6 = getArguments();
ViewExtensions.setTextAndVisibilityBy(materialButton, arguments6 != null ? arguments6.getCharSequence(ARG_OK_TEXT) : null);
Bundle arguments7 = getArguments();
if (arguments7 != null) {
charSequence = arguments7.getCharSequence(ARG_CANCEL_TEXT);
}
MaterialButton materialButton2 = getBinding().d;
m.checkNotNullExpressionValue(materialButton2, "binding.noticeCancel");
ViewExtensions.setTextAndVisibilityBy(materialButton2, charSequence);
Bundle arguments8 = getArguments();
if (arguments8 != null) {
insertLayoutInBundle(arguments8, ARG_ABOVE_LAYOUT_ID, 0);
}
Bundle arguments9 = getArguments();
if (arguments9 != null) {
LinearLayout linearLayout2 = getBinding().f2479b;
m.checkNotNullExpressionValue(linearLayout2, "binding.noticeBodyContainer");
insertLayoutInBundle(arguments9, ARG_BELOW_LAYOUT_ID, linearLayout2.getChildCount());
}
getBinding().g.setOnClickListener(new WidgetNoticeDialog$onViewBound$4(this));
getBinding().d.setOnClickListener(new WidgetNoticeDialog$onViewBound$5(this));
Map<Integer, ? extends Function1<? super View, Unit>> map2 = this.listenerMap;
if (map2 != null) {
for (Map.Entry<Integer, ? extends Function1<? super View, Unit>> entry : map2.entrySet()) {
View findViewById = view.findViewById(entry.getKey().intValue());
if (findViewById != null) {
findViewById.setOnClickListener(new WidgetNoticeDialog$onViewBound$$inlined$forEach$lambda$1(entry, this, view));
}
}
}
if (!(getContext() == null || (map = this.listenerMap) == null || (function1 = (Function1) map.get(0)) == null)) {
Unit unit = (Unit) function1.invoke(view);
}
}
public final void setListenerMap(Map<Integer, ? extends Function1<? super View, Unit>> map) {
this.listenerMap = map;
}
public final void setOnDismiss(Function0<Unit> function0) {
this.onDismiss = function0;
}
}