354 lines
16 KiB
Java
354 lines
16 KiB
Java
|
package com.discord.widgets.channels.permissions;
|
||
|
|
||
|
import a0.a.a.b;
|
||
|
import android.content.Context;
|
||
|
import android.view.View;
|
||
|
import android.widget.LinearLayout;
|
||
|
import androidx.fragment.app.Fragment;
|
||
|
import androidx.recyclerview.widget.RecyclerView;
|
||
|
import c.d.b.a.a;
|
||
|
import com.discord.api.channel.Channel;
|
||
|
import com.discord.api.permission.PermissionOverwrite;
|
||
|
import com.discord.api.role.GuildRole;
|
||
|
import com.discord.app.AppFragment;
|
||
|
import com.discord.databinding.WidgetChannelSettingsPermissionsAdvancedBinding;
|
||
|
import com.discord.models.guild.Guild;
|
||
|
import com.discord.models.user.MeUser;
|
||
|
import com.discord.stores.StoreStream;
|
||
|
import com.discord.utilities.mg_recycler.MGRecyclerAdapter;
|
||
|
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.widgets.channels.SimpleMembersAdapter;
|
||
|
import com.discord.widgets.channels.SimpleRolesAdapter;
|
||
|
import d0.t.n;
|
||
|
import d0.t.o;
|
||
|
import d0.t.u;
|
||
|
import d0.z.d.m;
|
||
|
import java.util.ArrayList;
|
||
|
import java.util.Collection;
|
||
|
import java.util.List;
|
||
|
import java.util.Map;
|
||
|
import java.util.concurrent.TimeUnit;
|
||
|
import kotlin.jvm.functions.Function0;
|
||
|
import kotlin.jvm.functions.Function1;
|
||
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
||
|
import kotlin.reflect.KProperty;
|
||
|
import rx.Observable;
|
||
|
/* compiled from: WidgetChannelSettingsPermissionsAdvanced.kt */
|
||
|
public final class WidgetChannelSettingsPermissionsAdvanced extends AppFragment {
|
||
|
public static final /* synthetic */ KProperty[] $$delegatedProperties = {a.V(WidgetChannelSettingsPermissionsAdvanced.class, "viewBinding", "getViewBinding()Lcom/discord/databinding/WidgetChannelSettingsPermissionsAdvancedBinding;", 0)};
|
||
|
private SimpleMembersAdapter membersAdapter;
|
||
|
private SimpleRolesAdapter rolesAdapter;
|
||
|
private final FragmentViewBindingDelegate viewBinding$delegate = FragmentViewBindingDelegateKt.viewBinding$default(this, WidgetChannelSettingsPermissionsAdvanced$viewBinding$2.INSTANCE, null, 2, null);
|
||
|
|
||
|
/* compiled from: WidgetChannelSettingsPermissionsAdvanced.kt */
|
||
|
public static final class Model {
|
||
|
public static final Companion Companion = new Companion(null);
|
||
|
private final boolean canAddRole;
|
||
|
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 f2149me;
|
||
|
private final List<SimpleMembersAdapter.MemberItem> memberItems;
|
||
|
private final long myPermissions;
|
||
|
private final List<SimpleRolesAdapter.RoleItem> roleItems;
|
||
|
|
||
|
/* compiled from: WidgetChannelSettingsPermissionsAdvanced.kt */
|
||
|
public static final class Companion {
|
||
|
private Companion() {
|
||
|
}
|
||
|
|
||
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
||
|
this();
|
||
|
}
|
||
|
|
||
|
public static final /* synthetic */ Collection access$getOverwriteIds(Companion companion, Channel channel, PermissionOverwrite.Type type) {
|
||
|
return companion.getOverwriteIds(channel, type);
|
||
|
}
|
||
|
|
||
|
private final Collection<Long> getOverwriteIds(Channel channel, PermissionOverwrite.Type type) {
|
||
|
List<PermissionOverwrite> s2 = channel.s();
|
||
|
if (s2 == null) {
|
||
|
return n.emptyList();
|
||
|
}
|
||
|
ArrayList<PermissionOverwrite> arrayList = new ArrayList();
|
||
|
for (Object obj : s2) {
|
||
|
if (((PermissionOverwrite) obj).f() == type) {
|
||
|
arrayList.add(obj);
|
||
|
}
|
||
|
}
|
||
|
ArrayList arrayList2 = new ArrayList(o.collectionSizeOrDefault(arrayList, 10));
|
||
|
for (PermissionOverwrite permissionOverwrite : arrayList) {
|
||
|
arrayList2.add(Long.valueOf(permissionOverwrite.e()));
|
||
|
}
|
||
|
return arrayList2;
|
||
|
}
|
||
|
|
||
|
public final Observable<Model> get(long j) {
|
||
|
Observable<R> Y = StoreStream.Companion.getChannels().observeChannel(j).Y(new WidgetChannelSettingsPermissionsAdvanced$Model$Companion$get$1(j));
|
||
|
m.checkNotNullExpressionValue(Y, "getChannels()\n … }\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, List<SimpleMembersAdapter.MemberItem> list) {
|
||
|
m.checkNotNullParameter(meUser, "me");
|
||
|
m.checkNotNullParameter(guild, "guild");
|
||
|
m.checkNotNullParameter(channel, "channel");
|
||
|
m.checkNotNullParameter(map, "guildRoles");
|
||
|
m.checkNotNullParameter(list, "memberItems");
|
||
|
this.f2149me = meUser;
|
||
|
this.guild = guild;
|
||
|
this.channel = channel;
|
||
|
this.myPermissions = j;
|
||
|
this.guildRoles = map;
|
||
|
this.memberItems = list;
|
||
|
boolean z2 = false;
|
||
|
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());
|
||
|
List<SimpleRolesAdapter.RoleItem> buildRoleItems = buildRoleItems();
|
||
|
this.roleItems = buildRoleItems;
|
||
|
this.canAddRole = map.size() > buildRoleItems.size() ? true : z2;
|
||
|
}
|
||
|
|
||
|
private final List<SimpleRolesAdapter.RoleItem> buildRoleItems() {
|
||
|
ArrayList arrayList = new ArrayList();
|
||
|
for (Number number : Companion.access$getOverwriteIds(Companion, this.channel, PermissionOverwrite.Type.ROLE)) {
|
||
|
GuildRole guildRole = this.guildRoles.get(Long.valueOf(number.longValue()));
|
||
|
if (guildRole != null) {
|
||
|
arrayList.add(new SimpleRolesAdapter.RoleItem(guildRole));
|
||
|
}
|
||
|
}
|
||
|
return u.sorted(arrayList);
|
||
|
}
|
||
|
|
||
|
/* JADX DEBUG: Multi-variable search result rejected for r5v0, resolved type: com.discord.widgets.channels.permissions.WidgetChannelSettingsPermissionsAdvanced$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, List list, int i, Object obj) {
|
||
|
if ((i & 1) != 0) {
|
||
|
meUser = model.f2149me;
|
||
|
}
|
||
|
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;
|
||
|
}
|
||
|
if ((i & 32) != 0) {
|
||
|
list = model.memberItems;
|
||
|
}
|
||
|
return model.copy(meUser, guild, channel, j, map, list);
|
||
|
}
|
||
|
|
||
|
public final MeUser component1() {
|
||
|
return this.f2149me;
|
||
|
}
|
||
|
|
||
|
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 List<SimpleMembersAdapter.MemberItem> component6() {
|
||
|
return this.memberItems;
|
||
|
}
|
||
|
|
||
|
public final Model copy(MeUser meUser, Guild guild, Channel channel, long j, Map<Long, GuildRole> map, List<SimpleMembersAdapter.MemberItem> list) {
|
||
|
m.checkNotNullParameter(meUser, "me");
|
||
|
m.checkNotNullParameter(guild, "guild");
|
||
|
m.checkNotNullParameter(channel, "channel");
|
||
|
m.checkNotNullParameter(map, "guildRoles");
|
||
|
m.checkNotNullParameter(list, "memberItems");
|
||
|
return new Model(meUser, guild, channel, j, map, list);
|
||
|
}
|
||
|
|
||
|
public boolean equals(Object obj) {
|
||
|
if (this == obj) {
|
||
|
return true;
|
||
|
}
|
||
|
if (!(obj instanceof Model)) {
|
||
|
return false;
|
||
|
}
|
||
|
Model model = (Model) obj;
|
||
|
return m.areEqual(this.f2149me, model.f2149me) && m.areEqual(this.guild, model.guild) && m.areEqual(this.channel, model.channel) && this.myPermissions == model.myPermissions && m.areEqual(this.guildRoles, model.guildRoles) && m.areEqual(this.memberItems, model.memberItems);
|
||
|
}
|
||
|
|
||
|
public final boolean getCanAddRole() {
|
||
|
return this.canAddRole;
|
||
|
}
|
||
|
|
||
|
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.f2149me;
|
||
|
}
|
||
|
|
||
|
public final List<SimpleMembersAdapter.MemberItem> getMemberItems() {
|
||
|
return this.memberItems;
|
||
|
}
|
||
|
|
||
|
public final long getMyPermissions() {
|
||
|
return this.myPermissions;
|
||
|
}
|
||
|
|
||
|
public final List<SimpleRolesAdapter.RoleItem> getRoleItems() {
|
||
|
return this.roleItems;
|
||
|
}
|
||
|
|
||
|
public int hashCode() {
|
||
|
MeUser meUser = this.f2149me;
|
||
|
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;
|
||
|
int hashCode3 = (a + (map != null ? map.hashCode() : 0)) * 31;
|
||
|
List<SimpleMembersAdapter.MemberItem> list = this.memberItems;
|
||
|
if (list != null) {
|
||
|
i = list.hashCode();
|
||
|
}
|
||
|
return hashCode3 + i;
|
||
|
}
|
||
|
|
||
|
public String toString() {
|
||
|
StringBuilder K = a.K("Model(me=");
|
||
|
K.append(this.f2149me);
|
||
|
K.append(", guild=");
|
||
|
K.append(this.guild);
|
||
|
K.append(", channel=");
|
||
|
K.append(this.channel);
|
||
|
K.append(", myPermissions=");
|
||
|
K.append(this.myPermissions);
|
||
|
K.append(", guildRoles=");
|
||
|
K.append(this.guildRoles);
|
||
|
K.append(", memberItems=");
|
||
|
return a.D(K, this.memberItems, ")");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public WidgetChannelSettingsPermissionsAdvanced() {
|
||
|
super(2131558897);
|
||
|
}
|
||
|
|
||
|
public static final /* synthetic */ void access$configureUI(WidgetChannelSettingsPermissionsAdvanced widgetChannelSettingsPermissionsAdvanced, Model model) {
|
||
|
widgetChannelSettingsPermissionsAdvanced.configureUI(model);
|
||
|
}
|
||
|
|
||
|
private final void configureMembers(Model model) {
|
||
|
if (model.getMemberItems().isEmpty()) {
|
||
|
LinearLayout linearLayout = getViewBinding().d;
|
||
|
m.checkNotNullExpressionValue(linearLayout, "viewBinding.membersContainer");
|
||
|
linearLayout.setVisibility(8);
|
||
|
return;
|
||
|
}
|
||
|
SimpleMembersAdapter simpleMembersAdapter = this.membersAdapter;
|
||
|
if (simpleMembersAdapter == null) {
|
||
|
m.throwUninitializedPropertyAccessException("membersAdapter");
|
||
|
}
|
||
|
simpleMembersAdapter.setData(model.getMemberItems(), new WidgetChannelSettingsPermissionsAdvanced$configureMembers$1(this, model));
|
||
|
LinearLayout linearLayout2 = getViewBinding().d;
|
||
|
m.checkNotNullExpressionValue(linearLayout2, "viewBinding.membersContainer");
|
||
|
linearLayout2.setVisibility(0);
|
||
|
}
|
||
|
|
||
|
private final void configureRoles(Model model) {
|
||
|
if (model.getRoleItems().isEmpty()) {
|
||
|
LinearLayout linearLayout = getViewBinding().f;
|
||
|
m.checkNotNullExpressionValue(linearLayout, "viewBinding.rolesContainer");
|
||
|
linearLayout.setVisibility(8);
|
||
|
return;
|
||
|
}
|
||
|
SimpleRolesAdapter simpleRolesAdapter = this.rolesAdapter;
|
||
|
if (simpleRolesAdapter == null) {
|
||
|
m.throwUninitializedPropertyAccessException("rolesAdapter");
|
||
|
}
|
||
|
simpleRolesAdapter.setData(model.getRoleItems(), new WidgetChannelSettingsPermissionsAdvanced$configureRoles$1(this, model));
|
||
|
LinearLayout linearLayout2 = getViewBinding().f;
|
||
|
m.checkNotNullExpressionValue(linearLayout2, "viewBinding.rolesContainer");
|
||
|
linearLayout2.setVisibility(0);
|
||
|
}
|
||
|
|
||
|
private final void configureUI(Model model) {
|
||
|
if (model != null && model.getCanManage()) {
|
||
|
getViewBinding().f1707c.setOnClickListener(new WidgetChannelSettingsPermissionsAdvanced$configureUI$1(this, model));
|
||
|
getViewBinding().b.setOnClickListener(new WidgetChannelSettingsPermissionsAdvanced$configureUI$2(this, model));
|
||
|
configureRoles(model);
|
||
|
configureMembers(model);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private final WidgetChannelSettingsPermissionsAdvancedBinding getViewBinding() {
|
||
|
return (WidgetChannelSettingsPermissionsAdvancedBinding) this.viewBinding$delegate.getValue((Fragment) this, $$delegatedProperties[0]);
|
||
|
}
|
||
|
|
||
|
@Override // com.discord.app.AppFragment
|
||
|
public void onViewBound(View view) {
|
||
|
m.checkNotNullParameter(view, "view");
|
||
|
super.onViewBound(view);
|
||
|
MGRecyclerAdapter.Companion companion = MGRecyclerAdapter.Companion;
|
||
|
RecyclerView recyclerView = getViewBinding().g;
|
||
|
m.checkNotNullExpressionValue(recyclerView, "viewBinding.rolesRecycler");
|
||
|
this.rolesAdapter = (SimpleRolesAdapter) companion.configure(new SimpleRolesAdapter(recyclerView));
|
||
|
RecyclerView recyclerView2 = getViewBinding().g;
|
||
|
m.checkNotNullExpressionValue(recyclerView2, "viewBinding.rolesRecycler");
|
||
|
recyclerView2.setNestedScrollingEnabled(false);
|
||
|
getViewBinding().g.setHasFixedSize(false);
|
||
|
RecyclerView recyclerView3 = getViewBinding().e;
|
||
|
m.checkNotNullExpressionValue(recyclerView3, "viewBinding.membersRecycler");
|
||
|
this.membersAdapter = (SimpleMembersAdapter) companion.configure(new SimpleMembersAdapter(recyclerView3));
|
||
|
RecyclerView recyclerView4 = getViewBinding().e;
|
||
|
m.checkNotNullExpressionValue(recyclerView4, "viewBinding.membersRecycler");
|
||
|
recyclerView4.setNestedScrollingEnabled(false);
|
||
|
getViewBinding().e.setHasFixedSize(false);
|
||
|
}
|
||
|
|
||
|
@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)).o(1, TimeUnit.SECONDS).r();
|
||
|
m.checkNotNullExpressionValue(r, "Model[channelId]\n … .distinctUntilChanged()");
|
||
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(ObservableExtensionsKt.computationLatest(r), this, null, 2, null), WidgetChannelSettingsPermissionsAdvanced.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetChannelSettingsPermissionsAdvanced$onViewBoundOrOnResume$1(this), 62, (Object) null);
|
||
|
}
|
||
|
}
|