discord-jadx/app/src/main/java/com/discord/widgets/channels/list/WidgetChannelsListItemChann...

329 lines
15 KiB
Java
Raw Normal View History

2021-06-27 20:44:35 +00:00
package com.discord.widgets.channels.list;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import c.a.l.b;
import c.d.b.a.a;
import com.airbnb.lottie.parser.AnimatableValueParser;
import com.discord.api.channel.Channel;
import com.discord.app.AppBottomSheet;
import com.discord.databinding.WidgetChannelsListItemTextActionsBinding;
import com.discord.models.guild.Guild;
import com.discord.models.user.User;
import com.discord.stores.StoreStream;
import com.discord.utilities.drawable.DrawableCompat;
import com.discord.utilities.icon.IconUtils;
import com.discord.utilities.images.MGImages;
import com.discord.utilities.permissions.PermissionUtils;
import com.discord.utilities.rx.ObservableExtensionsKt;
2021-07-03 23:36:06 +00:00
import com.discord.utilities.threads.ThreadUtils;
2021-06-27 20:44:35 +00:00
import com.discord.utilities.viewbinding.FragmentViewBindingDelegate;
import com.discord.utilities.viewbinding.FragmentViewBindingDelegateKt;
import com.facebook.drawee.view.SimpleDraweeView;
import d0.z.d.m;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.reflect.KProperty;
import rx.Observable;
import rx.subscriptions.CompositeSubscription;
/* compiled from: WidgetChannelsListItemChannelActions.kt */
public final class WidgetChannelsListItemChannelActions extends AppBottomSheet {
public static final /* synthetic */ KProperty[] $$delegatedProperties = {a.W(WidgetChannelsListItemChannelActions.class, "binding", "getBinding()Lcom/discord/databinding/WidgetChannelsListItemTextActionsBinding;", 0)};
public static final Companion Companion = new Companion(null);
private static final String INTENT_EXTRA_CHANNEL_ID = "INTENT_EXTRA_CHANNEL_ID";
private final FragmentViewBindingDelegate binding$delegate = FragmentViewBindingDelegateKt.viewBinding$default(this, WidgetChannelsListItemChannelActions$binding$2.INSTANCE, null, 2, null);
/* compiled from: WidgetChannelsListItemChannelActions.kt */
public static final class Companion {
private Companion() {
}
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
public final void show(FragmentManager fragmentManager, long j) {
m.checkNotNullParameter(fragmentManager, "fragmentManager");
WidgetChannelsListItemChannelActions widgetChannelsListItemChannelActions = new WidgetChannelsListItemChannelActions();
Bundle bundle = new Bundle();
bundle.putLong("INTENT_EXTRA_CHANNEL_ID", j);
widgetChannelsListItemChannelActions.setArguments(bundle);
widgetChannelsListItemChannelActions.show(fragmentManager, WidgetChannelsListItemChannelActions.class.getName());
}
}
/* compiled from: WidgetChannelsListItemChannelActions.kt */
public static final class Model {
public static final Companion Companion = new Companion(null);
private final boolean canCreateInstantInvite;
private final boolean canManageChannel;
private final Channel channel;
private final Guild guild;
private final boolean isDeveloper = StoreStream.Companion.getUserSettings().getIsDeveloperMode();
private final boolean isMuted;
private final Long permissions;
/* compiled from: WidgetChannelsListItemChannelActions.kt */
public static final class Companion {
private Companion() {
}
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
public final Observable<Model> get(long j) {
StoreStream.Companion companion = StoreStream.Companion;
Observable h = Observable.h(companion.getChannels().observeChannel(j), companion.getGuilds().observeFromChannelId(j), companion.getPermissions().observePermissionsForChannel(j), companion.getUserGuildSettings().observeGuildSettings(), WidgetChannelsListItemChannelActions$Model$Companion$get$1.INSTANCE);
m.checkNotNullExpressionValue(h, "Observable\n .co… }\n }");
2021-07-03 23:36:06 +00:00
Observable<Model> r = ObservableExtensionsKt.computationLatest(h).r();
m.checkNotNullExpressionValue(r, "Observable\n .co… .distinctUntilChanged()");
return r;
2021-06-27 20:44:35 +00:00
}
}
public Model(Channel channel, Guild guild, Long l, boolean z2) {
m.checkNotNullParameter(channel, "channel");
this.channel = channel;
this.guild = guild;
this.permissions = l;
this.isMuted = z2;
2021-07-03 23:36:06 +00:00
this.canManageChannel = PermissionUtils.can(16, l) || AnimatableValueParser.q1(channel);
2021-06-27 20:44:35 +00:00
this.canCreateInstantInvite = PermissionUtils.can(1, l);
}
public static /* synthetic */ Model copy$default(Model model, Channel channel, Guild guild, Long l, boolean z2, int i, Object obj) {
if ((i & 1) != 0) {
channel = model.channel;
}
if ((i & 2) != 0) {
guild = model.guild;
}
if ((i & 4) != 0) {
l = model.permissions;
}
if ((i & 8) != 0) {
z2 = model.isMuted;
}
return model.copy(channel, guild, l, z2);
}
public final Channel component1() {
return this.channel;
}
public final Guild component2() {
return this.guild;
}
public final Long component3() {
return this.permissions;
}
public final boolean component4() {
return this.isMuted;
}
public final Model copy(Channel channel, Guild guild, Long l, boolean z2) {
m.checkNotNullParameter(channel, "channel");
return new Model(channel, guild, l, z2);
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof Model)) {
return false;
}
Model model = (Model) obj;
return m.areEqual(this.channel, model.channel) && m.areEqual(this.guild, model.guild) && m.areEqual(this.permissions, model.permissions) && this.isMuted == model.isMuted;
}
public final boolean getCanCreateInstantInvite() {
return this.canCreateInstantInvite;
}
public final boolean getCanManageChannel() {
return this.canManageChannel;
}
public final Channel getChannel() {
return this.channel;
}
public final Guild getGuild() {
return this.guild;
}
public final CharSequence getMuteChannelText(Context context) {
m.checkNotNullParameter(context, "context");
2021-07-13 20:23:20 +00:00
return this.isMuted ? b.g(context, 2131894269, new Object[0], null, 4) : b.g(context, 2131891439, new Object[]{AnimatableValueParser.A0(this.channel, context, false, 2)}, null, 4);
2021-06-27 20:44:35 +00:00
}
public final int getMuteIconResId(Context context) {
m.checkNotNullParameter(context, "context");
2021-07-13 20:23:20 +00:00
return DrawableCompat.getThemedDrawableRes$default(context, this.isMuted ? 2130969390 : 2130969389, 0, 2, (Object) null);
2021-06-27 20:44:35 +00:00
}
public final Long getPermissions() {
return this.permissions;
}
public int hashCode() {
Channel channel = this.channel;
int i = 0;
int hashCode = (channel != null ? channel.hashCode() : 0) * 31;
Guild guild = this.guild;
int hashCode2 = (hashCode + (guild != null ? guild.hashCode() : 0)) * 31;
Long l = this.permissions;
if (l != null) {
i = l.hashCode();
}
int i2 = (hashCode2 + i) * 31;
boolean z2 = this.isMuted;
if (z2) {
z2 = true;
}
int i3 = z2 ? 1 : 0;
int i4 = z2 ? 1 : 0;
int i5 = z2 ? 1 : 0;
return i2 + i3;
}
public final boolean isDeveloper() {
return this.isDeveloper;
}
public final boolean isMuted() {
return this.isMuted;
}
public String toString() {
StringBuilder L = a.L("Model(channel=");
L.append(this.channel);
L.append(", guild=");
L.append(this.guild);
L.append(", permissions=");
L.append(this.permissions);
L.append(", isMuted=");
return a.G(L, this.isMuted, ")");
}
}
public WidgetChannelsListItemChannelActions() {
super(false, 1, null);
}
public static final /* synthetic */ void access$configureUI(WidgetChannelsListItemChannelActions widgetChannelsListItemChannelActions, Model model) {
widgetChannelsListItemChannelActions.configureUI(model);
}
private final void configureUI(Model model) {
if (model == null) {
dismiss();
return;
}
if (model.getGuild() != null) {
SimpleDraweeView simpleDraweeView = getBinding().f;
m.checkNotNullExpressionValue(simpleDraweeView, "binding.channelsListItemTextActionsIcon");
IconUtils.setIcon$default((ImageView) simpleDraweeView, model.getGuild(), 0, (MGImages.ChangeDetector) null, false, 28, (Object) null);
} else {
SimpleDraweeView simpleDraweeView2 = getBinding().f;
m.checkNotNullExpressionValue(simpleDraweeView2, "binding.channelsListItemTextActionsIcon");
IconUtils.setIcon$default(simpleDraweeView2, model.getChannel(), 0, null, 12, null);
}
TextView textView = getBinding().l;
m.checkNotNullExpressionValue(textView, "binding.channelsListItemTextActionsTitle");
Channel channel = model.getChannel();
Context requireContext = requireContext();
m.checkNotNullExpressionValue(requireContext, "requireContext()");
int i = 0;
textView.setText(AnimatableValueParser.A0(channel, requireContext, false, 2));
User v0 = AnimatableValueParser.v0(model.getChannel());
TextView textView2 = getBinding().j;
m.checkNotNullExpressionValue(textView2, "binding.channelsListItemTextActionsProfile");
boolean z2 = true;
textView2.setVisibility(v0 != null ? 0 : 8);
getBinding().j.setOnClickListener(new WidgetChannelsListItemChannelActions$configureUI$1(this, v0));
TextView textView3 = getBinding().g;
2021-07-03 23:36:06 +00:00
textView3.setVisibility(model.getCanCreateInstantInvite() && AnimatableValueParser.y1(model.getChannel()) ? 0 : 8);
2021-06-27 20:44:35 +00:00
setOnClickAndDismissListener(textView3, new WidgetChannelsListItemChannelActions$configureUI$$inlined$apply$lambda$1(textView3, this, model));
TextView textView4 = getBinding().i;
setOnClickAndDismissListener(textView4, new WidgetChannelsListItemChannelActions$configureUI$$inlined$apply$lambda$2(textView4, this, model));
Context context = textView4.getContext();
m.checkNotNullExpressionValue(context, "context");
textView4.setCompoundDrawablesWithIntrinsicBounds(model.getMuteIconResId(context), 0, 0, 0);
Context context2 = textView4.getContext();
m.checkNotNullExpressionValue(context2, "context");
textView4.setText(model.getMuteChannelText(context2));
TextView textView5 = getBinding().k;
2021-07-03 23:36:06 +00:00
textView5.setVisibility(ThreadUtils.INSTANCE.isThreadsEnabled(model.getChannel().f()) && AnimatableValueParser.A1(model.getChannel()) ? 0 : 8);
2021-06-27 20:44:35 +00:00
setOnClickAndDismissListener(textView5, new WidgetChannelsListItemChannelActions$configureUI$$inlined$apply$lambda$3(textView5, this, model));
2021-07-13 20:23:20 +00:00
TextView textView6 = getBinding().f1719c;
2021-06-27 20:44:35 +00:00
textView6.setVisibility(model.getCanManageChannel() ? 0 : 8);
setOnClickAndDismissListener(textView6, new WidgetChannelsListItemChannelActions$configureUI$$inlined$apply$lambda$4(this, model));
textView6.setText(getSettingsText(model.getChannel(), model.getCanManageChannel()));
TextView textView7 = getBinding().b;
m.checkNotNullExpressionValue(textView7, "binding.channelsListItem…tionsChannelNotifications");
2021-07-03 23:36:06 +00:00
if (!AnimatableValueParser.k1(model.getChannel()) && !AnimatableValueParser.f1(model.getChannel())) {
2021-06-27 20:44:35 +00:00
z2 = false;
}
textView7.setVisibility(z2 ? 0 : 8);
getBinding().b.setOnClickListener(new WidgetChannelsListItemChannelActions$configureUI$6(model));
View view = getBinding().h;
m.checkNotNullExpressionValue(view, "binding.channelsListItemTextActionsMarkAsRead");
setOnClickAndDismissListener(view, new WidgetChannelsListItemChannelActions$configureUI$7(model));
View view2 = getBinding().e;
m.checkNotNullExpressionValue(view2, "binding.channelsListItem…xtActionsDeveloperDivider");
view2.setVisibility(model.isDeveloper() ? 0 : 8);
TextView textView8 = getBinding().d;
m.checkNotNullExpressionValue(textView8, "binding.channelsListItemTextActionsCopyId");
if (!model.isDeveloper()) {
i = 8;
}
textView8.setVisibility(i);
View view3 = getBinding().d;
m.checkNotNullExpressionValue(view3, "binding.channelsListItemTextActionsCopyId");
setOnClickAndDismissListener(view3, new WidgetChannelsListItemChannelActions$configureUI$8(model));
}
private final WidgetChannelsListItemTextActionsBinding getBinding() {
return (WidgetChannelsListItemTextActionsBinding) this.binding$delegate.getValue((Fragment) this, $$delegatedProperties[0]);
}
private final String getSettingsText(Channel channel, boolean z2) {
2021-07-13 20:23:20 +00:00
String string = getString((!AnimatableValueParser.y1(channel) || !z2) ? (!AnimatableValueParser.y1(channel) || z2) ? AnimatableValueParser.f1(channel) ? 2131888200 : 2131893098 : 2131887327 : 2131888201);
2021-06-27 20:44:35 +00:00
m.checkNotNullExpressionValue(string, "getString(\n when {\n…_empty_string\n }\n )");
return string;
}
public static final void show(FragmentManager fragmentManager, long j) {
Companion.show(fragmentManager, j);
}
@Override // com.discord.app.AppBottomSheet
public void bindSubscriptions(CompositeSubscription compositeSubscription) {
m.checkNotNullParameter(compositeSubscription, "compositeSubscription");
super.bindSubscriptions(compositeSubscription);
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(Model.Companion.get(getArgumentsOrDefault().getLong("INTENT_EXTRA_CHANNEL_ID", -1)), this, null, 2, null), WidgetChannelsListItemChannelActions.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetChannelsListItemChannelActions$bindSubscriptions$1(this), 62, (Object) null);
}
@Override // com.discord.app.AppBottomSheet
public int getContentViewResId() {
2021-07-13 20:23:20 +00:00
return 2131558914;
2021-06-27 20:44:35 +00:00
}
@Override // com.discord.app.AppBottomSheet, androidx.fragment.app.Fragment
public void onPause() {
super.onPause();
dismiss();
}
}