discord-jadx/app/src/main/java/com/discord/widgets/chat/input/WidgetChatInputAttachments....

156 lines
9.2 KiB
Java

package com.discord.widgets.chat.input;
import android.content.ContentResolver;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.IdRes;
import androidx.annotation.LayoutRes;
import androidx.core.view.inputmethod.InputContentInfoCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import c.a.i.t4;
import c.a.k.b;
import com.discord.R;
import com.discord.app.AppFragment;
import com.discord.utilities.analytics.AnalyticsTracker;
import com.discord.widgets.chat.input.expression.WidgetExpressionTray;
import com.google.android.material.button.MaterialButton;
import com.lytefast.flexinput.FlexInputListener;
import com.lytefast.flexinput.adapters.AttachmentPreviewAdapter;
import com.lytefast.flexinput.adapters.EmptyListAdapter;
import com.lytefast.flexinput.fragment.FilesFragment;
import com.lytefast.flexinput.fragment.FlexInputFragment;
import com.lytefast.flexinput.fragment.MediaFragment;
import com.lytefast.flexinput.model.Attachment;
import com.lytefast.flexinput.viewmodel.FlexInputViewModel;
import d0.z.d.m;
import java.util.Objects;
/* compiled from: WidgetChatInputAttachments.kt */
public final class WidgetChatInputAttachments {
private final FlexInputFragment flexInputFragment;
/* compiled from: WidgetChatInputAttachments.kt */
public static final class DiscordFilesFragment extends FilesFragment {
@Override // com.lytefast.flexinput.fragment.FilesFragment
public EmptyListAdapter newPermissionsRequestAdapter(View.OnClickListener onClickListener) {
m.checkNotNullParameter(onClickListener, "onClickListener");
return new PermissionsEmptyListAdapter(R.layout.widget_chat_input_perm_req_files, R.id.action_btn, onClickListener);
}
}
/* compiled from: WidgetChatInputAttachments.kt */
public static final class DiscordMediaFragment extends MediaFragment {
@Override // com.lytefast.flexinput.fragment.MediaFragment
public EmptyListAdapter newPermissionsRequestAdapter(View.OnClickListener onClickListener) {
m.checkNotNullParameter(onClickListener, "onClickListener");
return new PermissionsEmptyListAdapter(R.layout.widget_chat_input_perm_req_files, R.id.action_btn, onClickListener);
}
}
/* compiled from: WidgetChatInputAttachments.kt */
public static final class PermissionsEmptyListAdapter extends EmptyListAdapter {
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public PermissionsEmptyListAdapter(@LayoutRes int i, @IdRes int i2, View.OnClickListener onClickListener) {
super(i, i2, onClickListener);
m.checkNotNullParameter(onClickListener, "onClickListener");
}
@Override // com.lytefast.flexinput.adapters.EmptyListAdapter, androidx.recyclerview.widget.RecyclerView.Adapter
public EmptyListAdapter.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
m.checkNotNullParameter(viewGroup, "parent");
EmptyListAdapter.ViewHolder onCreateViewHolder = super.onCreateViewHolder(viewGroup, i);
View view = onCreateViewHolder.itemView;
int i2 = R.id.action_btn;
MaterialButton materialButton = (MaterialButton) view.findViewById(R.id.action_btn);
if (materialButton != null) {
i2 = R.id.perm_req_text;
TextView textView = (TextView) view.findViewById(R.id.perm_req_text);
if (textView != null) {
m.checkNotNullExpressionValue(new t4((LinearLayout) view, materialButton, textView), "WidgetChatInputPermReqFi…ing.bind(holder.itemView)");
m.checkNotNullExpressionValue(textView, "binding.permReqText");
b.n(textView, R.string.system_permission_request_files, new Object[0], null, 4);
return onCreateViewHolder;
}
}
throw new NullPointerException("Missing required view with ID: ".concat(view.getResources().getResourceName(i2)));
}
}
public WidgetChatInputAttachments(FlexInputFragment flexInputFragment) {
m.checkNotNullParameter(flexInputFragment, "flexInputFragment");
this.flexInputFragment = flexInputFragment;
}
public static final /* synthetic */ Fragment access$createAndConfigureExpressionFragment(WidgetChatInputAttachments widgetChatInputAttachments, FragmentManager fragmentManager, TextView textView) {
return widgetChatInputAttachments.createAndConfigureExpressionFragment(fragmentManager, textView);
}
public static final /* synthetic */ AttachmentPreviewAdapter access$createPreviewAdapter(WidgetChatInputAttachments widgetChatInputAttachments, Context context) {
return widgetChatInputAttachments.createPreviewAdapter(context);
}
public static final /* synthetic */ FlexInputFragment access$getFlexInputFragment$p(WidgetChatInputAttachments widgetChatInputAttachments) {
return widgetChatInputAttachments.flexInputFragment;
}
public static final /* synthetic */ void access$setAttachmentFromPicker(WidgetChatInputAttachments widgetChatInputAttachments, Context context, InputContentInfoCompat inputContentInfoCompat) {
widgetChatInputAttachments.setAttachmentFromPicker(context, inputContentInfoCompat);
}
private final Fragment createAndConfigureExpressionFragment(FragmentManager fragmentManager, TextView textView) {
WidgetChatInputAttachments$createAndConfigureExpressionFragment$emojiPickerListener$1 widgetChatInputAttachments$createAndConfigureExpressionFragment$emojiPickerListener$1 = new WidgetChatInputAttachments$createAndConfigureExpressionFragment$emojiPickerListener$1(this);
WidgetChatInputAttachments$createAndConfigureExpressionFragment$stickerPickerListener$1 widgetChatInputAttachments$createAndConfigureExpressionFragment$stickerPickerListener$1 = new WidgetChatInputAttachments$createAndConfigureExpressionFragment$stickerPickerListener$1(this);
WidgetChatInputAttachments$createAndConfigureExpressionFragment$onBackspacePressedListener$1 widgetChatInputAttachments$createAndConfigureExpressionFragment$onBackspacePressedListener$1 = new WidgetChatInputAttachments$createAndConfigureExpressionFragment$onBackspacePressedListener$1(textView);
Fragment findFragmentById = fragmentManager.findFragmentById(R.id.expression_tray_container);
if (!(findFragmentById instanceof WidgetExpressionTray)) {
findFragmentById = null;
}
WidgetExpressionTray widgetExpressionTray = (WidgetExpressionTray) findFragmentById;
if (widgetExpressionTray == null) {
widgetExpressionTray = new WidgetExpressionTray();
}
widgetExpressionTray.setEmojiPickerListener(widgetChatInputAttachments$createAndConfigureExpressionFragment$emojiPickerListener$1);
widgetExpressionTray.setStickerPickerListener(widgetChatInputAttachments$createAndConfigureExpressionFragment$stickerPickerListener$1);
widgetExpressionTray.setOnBackspacePressedListener(widgetChatInputAttachments$createAndConfigureExpressionFragment$onBackspacePressedListener$1);
widgetExpressionTray.setOnEmojiSearchOpenedListener(new WidgetChatInputAttachments$createAndConfigureExpressionFragment$1(this));
return widgetExpressionTray;
}
private final <T extends Attachment<? extends Object>> AttachmentPreviewAdapter<T> createPreviewAdapter(Context context) {
return new AttachmentPreviewAdapter<>(new WidgetChatInputAttachments$createPreviewAdapter$1(this, context));
}
private final void setAttachmentFromPicker(Context context, InputContentInfoCompat inputContentInfoCompat) {
ContentResolver contentResolver = context.getContentResolver();
if (contentResolver != null) {
this.flexInputFragment.f(new SourcedAttachment(Attachment.Companion.b(inputContentInfoCompat, contentResolver, true, b.h(context, R.string.attachment_filename_unknown, new Object[0], null, 4).toString()), AnalyticsTracker.ATTACHMENT_SOURCE_KEYBOARD));
}
}
public final void addExternalAttachment(Attachment<? extends Object> attachment) {
m.checkNotNullParameter(attachment, "attachment");
this.flexInputFragment.i(new WidgetChatInputAttachments$addExternalAttachment$1(this, attachment));
}
public final void configureFlexInputFragment(AppFragment appFragment, boolean z2) {
m.checkNotNullParameter(appFragment, "fragment");
this.flexInputFragment.i(new WidgetChatInputAttachments$configureFlexInputFragment$1(this, z2, appFragment));
appFragment.setOnBackPressed(new WidgetChatInputAttachments$configureFlexInputFragment$2(this), 1);
}
public final void setInputListener(FlexInputListener flexInputListener) {
m.checkNotNullParameter(flexInputListener, "inputListener");
FlexInputFragment flexInputFragment = this.flexInputFragment;
Objects.requireNonNull(flexInputFragment);
m.checkNotNullParameter(flexInputListener, "inputListener");
flexInputFragment.n = flexInputListener;
}
public final void setViewModel(FlexInputViewModel flexInputViewModel) {
this.flexInputFragment.r = flexInputViewModel;
}
}