344 lines
15 KiB
Java
344 lines
15 KiB
Java
package com.discord.widgets.channels.permissions;
|
|
|
|
import a0.a.a.b;
|
|
import android.content.Context;
|
|
import android.content.Intent;
|
|
import android.view.View;
|
|
import androidx.fragment.app.Fragment;
|
|
import androidx.fragment.app.FragmentViewModelLazyKt;
|
|
import c.a.d.h0;
|
|
import c.a.d.j0;
|
|
import c.a.d.l;
|
|
import c.d.b.a.a;
|
|
import com.airbnb.lottie.parser.AnimatableValueParser;
|
|
import com.discord.api.channel.Channel;
|
|
import com.discord.api.role.GuildRole;
|
|
import com.discord.app.AppFragment;
|
|
import com.discord.app.AppViewFlipper;
|
|
import com.discord.databinding.WidgetChannelSettingsPermissionsOverviewBinding;
|
|
import com.discord.models.guild.Guild;
|
|
import com.discord.models.user.MeUser;
|
|
import com.discord.stores.StoreStream;
|
|
import com.discord.utilities.permissions.PermissionUtils;
|
|
import com.discord.utilities.rx.ObservableExtensionsKt;
|
|
import com.discord.utilities.viewbinding.FragmentViewBindingDelegate;
|
|
import com.discord.utilities.viewbinding.FragmentViewBindingDelegateKt;
|
|
import com.discord.views.segmentedcontrol.SegmentedControlContainer;
|
|
import com.discord.widgets.channels.permissions.WidgetChannelSettingsPermissionsOverviewViewModel;
|
|
import d0.z.d.a0;
|
|
import d0.z.d.m;
|
|
import java.util.Map;
|
|
import kotlin.Lazy;
|
|
import kotlin.NoWhenBranchMatchedException;
|
|
import kotlin.jvm.functions.Function0;
|
|
import kotlin.jvm.functions.Function1;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
import kotlin.reflect.KProperty;
|
|
import rx.Observable;
|
|
/* compiled from: WidgetChannelSettingsPermissionsOverview.kt */
|
|
public final class WidgetChannelSettingsPermissionsOverview extends AppFragment {
|
|
public static final /* synthetic */ KProperty[] $$delegatedProperties = {a.V(WidgetChannelSettingsPermissionsOverview.class, "viewBinding", "getViewBinding()Lcom/discord/databinding/WidgetChannelSettingsPermissionsOverviewBinding;", 0)};
|
|
public static final Companion Companion = new Companion(null);
|
|
private static final int TAB_INDEX_ADVANCED = 1;
|
|
private static final int TAB_INDEX_MODERATOR = 0;
|
|
private static final int VIEW_INDEX_ADVANCED = 1;
|
|
private static final int VIEW_INDEX_STAGE_MODERATOR = 0;
|
|
private final FragmentViewBindingDelegate viewBinding$delegate = FragmentViewBindingDelegateKt.viewBinding$default(this, WidgetChannelSettingsPermissionsOverview$viewBinding$2.INSTANCE, null, 2, null);
|
|
private final Lazy viewModel$delegate;
|
|
|
|
/* compiled from: WidgetChannelSettingsPermissionsOverview.kt */
|
|
public static final class Companion {
|
|
private Companion() {
|
|
}
|
|
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
|
|
public final void launch(Context context, long j) {
|
|
m.checkNotNullParameter(context, "context");
|
|
Intent intent = new Intent();
|
|
intent.putExtra("com.discord.intent.extra.EXTRA_CHANNEL_ID", j);
|
|
l.d(context, WidgetChannelSettingsPermissionsOverview.class, intent);
|
|
}
|
|
}
|
|
|
|
/* compiled from: WidgetChannelSettingsPermissionsOverview.kt */
|
|
public static final class Model {
|
|
public static final Companion Companion = new Companion(null);
|
|
private final boolean canManage;
|
|
private final Channel channel;
|
|
private final Guild guild;
|
|
private final Map<Long, GuildRole> guildRoles;
|
|
|
|
/* renamed from: me reason: collision with root package name */
|
|
private final MeUser f2150me;
|
|
private final long myPermissions;
|
|
|
|
/* compiled from: WidgetChannelSettingsPermissionsOverview.kt */
|
|
public static final class Companion {
|
|
private Companion() {
|
|
}
|
|
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
|
|
public final Observable<Model> get(long j) {
|
|
Observable<R> Y = StoreStream.Companion.getChannels().observeChannel(j).Y(new WidgetChannelSettingsPermissionsOverview$Model$Companion$get$1(j));
|
|
m.checkNotNullExpressionValue(Y, "StoreStream.getChannels(… }\n }");
|
|
return Y;
|
|
}
|
|
|
|
public final boolean isValid(MeUser meUser, Guild guild, Channel channel, Long l) {
|
|
return (meUser == null || guild == null || channel == null || l == null) ? false : true;
|
|
}
|
|
}
|
|
|
|
public Model(MeUser meUser, Guild guild, Channel channel, long j, Map<Long, GuildRole> map) {
|
|
m.checkNotNullParameter(meUser, "me");
|
|
m.checkNotNullParameter(guild, "guild");
|
|
m.checkNotNullParameter(channel, "channel");
|
|
m.checkNotNullParameter(map, "guildRoles");
|
|
this.f2150me = meUser;
|
|
this.guild = guild;
|
|
this.channel = channel;
|
|
this.myPermissions = j;
|
|
this.guildRoles = map;
|
|
this.canManage = guild.getOwnerId() == meUser.getId() || PermissionUtils.canAndIsElevated(268435456, Long.valueOf(j), meUser.getMfaEnabled(), guild.getMfaLevel()) || PermissionUtils.canAndIsElevated(8, Long.valueOf(j), meUser.getMfaEnabled(), guild.getMfaLevel());
|
|
}
|
|
|
|
/* JADX DEBUG: Multi-variable search result rejected for r4v0, resolved type: com.discord.widgets.channels.permissions.WidgetChannelSettingsPermissionsOverview$Model */
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
public static /* synthetic */ Model copy$default(Model model, MeUser meUser, Guild guild, Channel channel, long j, Map map, int i, Object obj) {
|
|
if ((i & 1) != 0) {
|
|
meUser = model.f2150me;
|
|
}
|
|
if ((i & 2) != 0) {
|
|
guild = model.guild;
|
|
}
|
|
if ((i & 4) != 0) {
|
|
channel = model.channel;
|
|
}
|
|
if ((i & 8) != 0) {
|
|
j = model.myPermissions;
|
|
}
|
|
if ((i & 16) != 0) {
|
|
map = model.guildRoles;
|
|
}
|
|
return model.copy(meUser, guild, channel, j, map);
|
|
}
|
|
|
|
public final MeUser component1() {
|
|
return this.f2150me;
|
|
}
|
|
|
|
public final Guild component2() {
|
|
return this.guild;
|
|
}
|
|
|
|
public final Channel component3() {
|
|
return this.channel;
|
|
}
|
|
|
|
public final long component4() {
|
|
return this.myPermissions;
|
|
}
|
|
|
|
public final Map<Long, GuildRole> component5() {
|
|
return this.guildRoles;
|
|
}
|
|
|
|
public final Model copy(MeUser meUser, Guild guild, Channel channel, long j, Map<Long, GuildRole> map) {
|
|
m.checkNotNullParameter(meUser, "me");
|
|
m.checkNotNullParameter(guild, "guild");
|
|
m.checkNotNullParameter(channel, "channel");
|
|
m.checkNotNullParameter(map, "guildRoles");
|
|
return new Model(meUser, guild, channel, j, map);
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (this == obj) {
|
|
return true;
|
|
}
|
|
if (!(obj instanceof Model)) {
|
|
return false;
|
|
}
|
|
Model model = (Model) obj;
|
|
return m.areEqual(this.f2150me, model.f2150me) && m.areEqual(this.guild, model.guild) && m.areEqual(this.channel, model.channel) && this.myPermissions == model.myPermissions && m.areEqual(this.guildRoles, model.guildRoles);
|
|
}
|
|
|
|
public final boolean getCanManage() {
|
|
return this.canManage;
|
|
}
|
|
|
|
public final Channel getChannel() {
|
|
return this.channel;
|
|
}
|
|
|
|
public final Guild getGuild() {
|
|
return this.guild;
|
|
}
|
|
|
|
public final Map<Long, GuildRole> getGuildRoles() {
|
|
return this.guildRoles;
|
|
}
|
|
|
|
public final MeUser getMe() {
|
|
return this.f2150me;
|
|
}
|
|
|
|
public final long getMyPermissions() {
|
|
return this.myPermissions;
|
|
}
|
|
|
|
public int hashCode() {
|
|
MeUser meUser = this.f2150me;
|
|
int i = 0;
|
|
int hashCode = (meUser != null ? meUser.hashCode() : 0) * 31;
|
|
Guild guild = this.guild;
|
|
int hashCode2 = (hashCode + (guild != null ? guild.hashCode() : 0)) * 31;
|
|
Channel channel = this.channel;
|
|
int a = (b.a(this.myPermissions) + ((hashCode2 + (channel != null ? channel.hashCode() : 0)) * 31)) * 31;
|
|
Map<Long, GuildRole> map = this.guildRoles;
|
|
if (map != null) {
|
|
i = map.hashCode();
|
|
}
|
|
return a + i;
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuilder K = a.K("Model(me=");
|
|
K.append(this.f2150me);
|
|
K.append(", guild=");
|
|
K.append(this.guild);
|
|
K.append(", channel=");
|
|
K.append(this.channel);
|
|
K.append(", myPermissions=");
|
|
K.append(this.myPermissions);
|
|
K.append(", guildRoles=");
|
|
return a.E(K, this.guildRoles, ")");
|
|
}
|
|
}
|
|
|
|
public final /* synthetic */ class WhenMappings {
|
|
public static final /* synthetic */ int[] $EnumSwitchMapping$0;
|
|
public static final /* synthetic */ int[] $EnumSwitchMapping$1;
|
|
|
|
static {
|
|
WidgetChannelSettingsPermissionsOverviewViewModel.Tab.values();
|
|
int[] iArr = new int[2];
|
|
$EnumSwitchMapping$0 = iArr;
|
|
WidgetChannelSettingsPermissionsOverviewViewModel.Tab tab = WidgetChannelSettingsPermissionsOverviewViewModel.Tab.MODERATOR;
|
|
iArr[tab.ordinal()] = 1;
|
|
WidgetChannelSettingsPermissionsOverviewViewModel.Tab tab2 = WidgetChannelSettingsPermissionsOverviewViewModel.Tab.ADVANCED;
|
|
iArr[tab2.ordinal()] = 2;
|
|
WidgetChannelSettingsPermissionsOverviewViewModel.Tab.values();
|
|
int[] iArr2 = new int[2];
|
|
$EnumSwitchMapping$1 = iArr2;
|
|
iArr2[tab.ordinal()] = 1;
|
|
iArr2[tab2.ordinal()] = 2;
|
|
}
|
|
}
|
|
|
|
public WidgetChannelSettingsPermissionsOverview() {
|
|
super(2131558898);
|
|
WidgetChannelSettingsPermissionsOverview$viewModel$2 widgetChannelSettingsPermissionsOverview$viewModel$2 = new WidgetChannelSettingsPermissionsOverview$viewModel$2(this);
|
|
h0 h0Var = new h0(this);
|
|
this.viewModel$delegate = FragmentViewModelLazyKt.createViewModelLazy(this, a0.getOrCreateKotlinClass(WidgetChannelSettingsPermissionsOverviewViewModel.class), new WidgetChannelSettingsPermissionsOverview$appViewModels$$inlined$viewModels$1(h0Var), new j0(widgetChannelSettingsPermissionsOverview$viewModel$2));
|
|
}
|
|
|
|
public static final /* synthetic */ void access$configureTabs(WidgetChannelSettingsPermissionsOverview widgetChannelSettingsPermissionsOverview, WidgetChannelSettingsPermissionsOverviewViewModel.ViewState viewState) {
|
|
widgetChannelSettingsPermissionsOverview.configureTabs(viewState);
|
|
}
|
|
|
|
public static final /* synthetic */ void access$configureUI(WidgetChannelSettingsPermissionsOverview widgetChannelSettingsPermissionsOverview, Model model) {
|
|
widgetChannelSettingsPermissionsOverview.configureUI(model);
|
|
}
|
|
|
|
public static final /* synthetic */ long access$getChannelIdFromIntent(WidgetChannelSettingsPermissionsOverview widgetChannelSettingsPermissionsOverview) {
|
|
return widgetChannelSettingsPermissionsOverview.getChannelIdFromIntent();
|
|
}
|
|
|
|
public static final /* synthetic */ WidgetChannelSettingsPermissionsOverviewViewModel access$getViewModel$p(WidgetChannelSettingsPermissionsOverview widgetChannelSettingsPermissionsOverview) {
|
|
return widgetChannelSettingsPermissionsOverview.getViewModel();
|
|
}
|
|
|
|
private final void configureTabs(WidgetChannelSettingsPermissionsOverviewViewModel.ViewState viewState) {
|
|
int i;
|
|
int ordinal = viewState.getSelectedTab().ordinal();
|
|
int i2 = 0;
|
|
boolean z2 = true;
|
|
if (ordinal == 0) {
|
|
AppViewFlipper appViewFlipper = getViewBinding().b;
|
|
m.checkNotNullExpressionValue(appViewFlipper, "viewBinding.flipper");
|
|
appViewFlipper.setDisplayedChild(0);
|
|
} else if (ordinal == 1) {
|
|
AppViewFlipper appViewFlipper2 = getViewBinding().b;
|
|
m.checkNotNullExpressionValue(appViewFlipper2, "viewBinding.flipper");
|
|
appViewFlipper2.setDisplayedChild(1);
|
|
}
|
|
SegmentedControlContainer segmentedControlContainer = getViewBinding().f1708c;
|
|
int ordinal2 = viewState.getSelectedTab().ordinal();
|
|
if (ordinal2 == 0) {
|
|
i = 0;
|
|
} else if (ordinal2 == 1) {
|
|
i = 1;
|
|
} else {
|
|
throw new NoWhenBranchMatchedException();
|
|
}
|
|
segmentedControlContainer.a(i);
|
|
getViewBinding().f1708c.setOnSegmentSelectedChangeListener(new WidgetChannelSettingsPermissionsOverview$configureTabs$1(this));
|
|
SegmentedControlContainer segmentedControlContainer2 = getViewBinding().f1708c;
|
|
m.checkNotNullExpressionValue(segmentedControlContainer2, "viewBinding.segmentedControl");
|
|
if (viewState.getAvailableTabs().size() <= 1) {
|
|
z2 = false;
|
|
}
|
|
if (!z2) {
|
|
i2 = 8;
|
|
}
|
|
segmentedControlContainer2.setVisibility(i2);
|
|
}
|
|
|
|
private final void configureToolbar(Channel channel) {
|
|
setActionBarTitle(AnimatableValueParser.f1(channel) ? 2131887210 : 2131887329);
|
|
setActionBarSubtitle(AnimatableValueParser.z0(channel, requireContext(), true));
|
|
}
|
|
|
|
private final void configureUI(Model model) {
|
|
if (model == null || !model.getCanManage()) {
|
|
requireActivity().finish();
|
|
} else {
|
|
configureToolbar(model.getChannel());
|
|
}
|
|
}
|
|
|
|
private final long getChannelIdFromIntent() {
|
|
return getMostRecentIntent().getLongExtra("com.discord.intent.extra.EXTRA_CHANNEL_ID", -1);
|
|
}
|
|
|
|
private final WidgetChannelSettingsPermissionsOverviewBinding getViewBinding() {
|
|
return (WidgetChannelSettingsPermissionsOverviewBinding) this.viewBinding$delegate.getValue((Fragment) this, $$delegatedProperties[0]);
|
|
}
|
|
|
|
private final WidgetChannelSettingsPermissionsOverviewViewModel getViewModel() {
|
|
return (WidgetChannelSettingsPermissionsOverviewViewModel) this.viewModel$delegate.getValue();
|
|
}
|
|
|
|
@Override // com.discord.app.AppFragment
|
|
public void onViewBound(View view) {
|
|
m.checkNotNullParameter(view, "view");
|
|
super.onViewBound(view);
|
|
AppFragment.setActionBarDisplayHomeAsUpEnabled$default(this, false, 1, null);
|
|
}
|
|
|
|
@Override // com.discord.app.AppFragment
|
|
public void onViewBoundOrOnResume() {
|
|
super.onViewBoundOrOnResume();
|
|
Observable<Model> r = Model.Companion.get(getMostRecentIntent().getLongExtra("com.discord.intent.extra.EXTRA_CHANNEL_ID", -1)).r();
|
|
m.checkNotNullExpressionValue(r, "Model\n .get(chann… .distinctUntilChanged()");
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(ObservableExtensionsKt.computationLatest(r), this, null, 2, null), WidgetChannelSettingsPermissionsOverview.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetChannelSettingsPermissionsOverview$onViewBoundOrOnResume$1(this), 62, (Object) null);
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.bindToComponentLifecycle(getViewModel().observeViewState(), this), WidgetChannelSettingsPermissionsOverview.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetChannelSettingsPermissionsOverview$onViewBoundOrOnResume$2(this), 62, (Object) null);
|
|
}
|
|
}
|