734 lines
32 KiB
Java
734 lines
32 KiB
Java
package com.discord.widgets.servers;
|
|
|
|
import a0.a.a.b;
|
|
import android.content.Context;
|
|
import android.content.Intent;
|
|
import android.graphics.Color;
|
|
import android.graphics.PorterDuff;
|
|
import android.graphics.PorterDuffColorFilter;
|
|
import android.graphics.drawable.Drawable;
|
|
import android.view.View;
|
|
import androidx.annotation.ColorInt;
|
|
import androidx.appcompat.widget.Toolbar;
|
|
import androidx.core.content.ContextCompat;
|
|
import androidx.fragment.app.Fragment;
|
|
import androidx.fragment.app.FragmentManager;
|
|
import c.a.d.l;
|
|
import c.a.d.q;
|
|
import c.d.b.a.a;
|
|
import c.k.a.a.e;
|
|
import com.discord.api.role.GuildRole;
|
|
import com.discord.app.AppActivity;
|
|
import com.discord.app.AppFragment;
|
|
import com.discord.databinding.WidgetEditRoleBinding;
|
|
import com.discord.restapi.RestAPIParams;
|
|
import com.discord.stores.StoreStream;
|
|
import com.discord.stores.StoreUser;
|
|
import com.discord.utilities.color.ColorCompat;
|
|
import com.discord.utilities.font.FontUtils;
|
|
import com.discord.utilities.guilds.RoleUtils;
|
|
import com.discord.utilities.permissions.PermissionUtils;
|
|
import com.discord.utilities.rest.RestAPI;
|
|
import com.discord.utilities.rx.ObservableExtensionsKt;
|
|
import com.discord.utilities.stateful.StatefulViews;
|
|
import com.discord.utilities.view.extensions.ViewExtensions;
|
|
import com.discord.utilities.viewbinding.FragmentViewBindingDelegate;
|
|
import com.discord.utilities.viewbinding.FragmentViewBindingDelegateKt;
|
|
import com.discord.views.CheckedSetting;
|
|
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
|
import com.google.android.material.textfield.TextInputLayout;
|
|
import d0.t.n;
|
|
import d0.z.d.m;
|
|
import java.util.ArrayList;
|
|
import java.util.Collection;
|
|
import java.util.Map;
|
|
import kotlin.jvm.functions.Function0;
|
|
import kotlin.jvm.functions.Function1;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
import kotlin.reflect.KProperty;
|
|
import rx.Observable;
|
|
/* compiled from: WidgetServerSettingsEditRole.kt */
|
|
public final class WidgetServerSettingsEditRole extends AppFragment {
|
|
public static final /* synthetic */ KProperty[] $$delegatedProperties = {a.W(WidgetServerSettingsEditRole.class, "binding", "getBinding()Lcom/discord/databinding/WidgetEditRoleBinding;", 0)};
|
|
public static final Companion Companion = new Companion(null);
|
|
private static final String DIALOG_TAG_COLOR_PICKER = "DIALOG_TAG_COLOR_PICKER";
|
|
private static final String INTENT_EXTRA_GUILD_ID = "INTENT_EXTRA_GUILD_ID";
|
|
private static final String INTENT_EXTRA_ROLE_ID = "INTENT_EXTRA_ROLE_ID";
|
|
private final FragmentViewBindingDelegate binding$delegate = FragmentViewBindingDelegateKt.viewBinding$default(this, WidgetServerSettingsEditRole$binding$2.INSTANCE, null, 2, null);
|
|
private final StatefulViews state = new StatefulViews(2131363052);
|
|
|
|
/* compiled from: WidgetServerSettingsEditRole.kt */
|
|
public static final class Companion {
|
|
private Companion() {
|
|
}
|
|
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
|
|
public final void launch(long j, long j2, Context context) {
|
|
m.checkNotNullParameter(context, "context");
|
|
Intent intent = new Intent();
|
|
intent.putExtra("INTENT_EXTRA_GUILD_ID", j);
|
|
intent.putExtra("INTENT_EXTRA_ROLE_ID", j2);
|
|
l.d(context, WidgetServerSettingsEditRole.class, intent);
|
|
}
|
|
}
|
|
|
|
/* compiled from: WidgetServerSettingsEditRole.kt */
|
|
public static final class Model {
|
|
public static final Companion Companion = new Companion(null);
|
|
private final long guildId;
|
|
private final boolean isCommunityServer;
|
|
private final ManageStatus manageStatus;
|
|
private final Long myPermissions;
|
|
private final long myPermissionsFromOtherRoles;
|
|
private final boolean owner;
|
|
private final GuildRole role;
|
|
|
|
/* compiled from: WidgetServerSettingsEditRole.kt */
|
|
public static final class Companion {
|
|
private Companion() {
|
|
}
|
|
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
|
|
public static final /* synthetic */ ManageStatus access$computeManageStatus(Companion companion, boolean z2, boolean z3, Long l, GuildRole guildRole, GuildRole guildRole2) {
|
|
return companion.computeManageStatus(z2, z3, l, guildRole, guildRole2);
|
|
}
|
|
|
|
public static final /* synthetic */ long access$computeMyOtherPermissions(Companion companion, Collection collection, Map map, long j, long j2) {
|
|
return companion.computeMyOtherPermissions(collection, map, j, j2);
|
|
}
|
|
|
|
private final ManageStatus computeManageStatus(boolean z2, boolean z3, Long l, GuildRole guildRole, GuildRole guildRole2) {
|
|
return (z2 || (PermissionUtils.can(8, l) && RoleUtils.rankIsHigher(guildRole, guildRole2) && z3)) ? ManageStatus.CAN_MANAGE_ADMIN : RoleUtils.rankIsHigher(guildRole2, guildRole) ? ManageStatus.LOCKED_HIGHER : RoleUtils.rankEquals(guildRole, guildRole2) ? ManageStatus.LOCKED_HIGHEST : (!PermissionUtils.can(268435456, l) || !z3) ? !z3 ? ManageStatus.USER_NOT_ELEVATED : ManageStatus.NO_MANAGE_ROLES_PERMISSION : ManageStatus.CAN_MANAGE_CONDITIONAL;
|
|
}
|
|
|
|
private final long computeMyOtherPermissions(Collection<Long> collection, Map<Long, GuildRole> map, long j, long j2) {
|
|
GuildRole guildRole = map.get(Long.valueOf(j2));
|
|
long j3 = 0;
|
|
if (!(guildRole == null || j == j2)) {
|
|
j3 = guildRole.g() | 0 | guildRole.g();
|
|
}
|
|
for (Number number : collection) {
|
|
long longValue = number.longValue();
|
|
GuildRole guildRole2 = map.get(Long.valueOf(longValue));
|
|
if (!(guildRole2 == null || longValue == j)) {
|
|
j3 = guildRole2.g() | j3;
|
|
}
|
|
}
|
|
return j3;
|
|
}
|
|
|
|
public final Observable<Model> get(long j, long j2) {
|
|
Observable<Model> r = StoreUser.observeMe$default(StoreStream.Companion.getUsers(), false, 1, null).Y(new WidgetServerSettingsEditRole$Model$Companion$get$1(j, j2)).r();
|
|
m.checkNotNullExpressionValue(r, "getUsers()\n .… .distinctUntilChanged()");
|
|
return r;
|
|
}
|
|
}
|
|
|
|
/* compiled from: WidgetServerSettingsEditRole.kt */
|
|
public enum ManageStatus {
|
|
NO_MANAGE_ROLES_PERMISSION,
|
|
LOCKED_HIGHER,
|
|
LOCKED_HIGHEST,
|
|
USER_NOT_ELEVATED,
|
|
CAN_MANAGE_CONDITIONAL,
|
|
CAN_MANAGE_ADMIN
|
|
}
|
|
|
|
public Model(boolean z2, long j, GuildRole guildRole, ManageStatus manageStatus, Long l, long j2, boolean z3) {
|
|
m.checkNotNullParameter(guildRole, "role");
|
|
this.owner = z2;
|
|
this.guildId = j;
|
|
this.role = guildRole;
|
|
this.manageStatus = manageStatus;
|
|
this.myPermissions = l;
|
|
this.myPermissionsFromOtherRoles = j2;
|
|
this.isCommunityServer = z3;
|
|
}
|
|
|
|
public static /* synthetic */ Model copy$default(Model model, boolean z2, long j, GuildRole guildRole, ManageStatus manageStatus, Long l, long j2, boolean z3, int i, Object obj) {
|
|
return model.copy((i & 1) != 0 ? model.owner : z2, (i & 2) != 0 ? model.guildId : j, (i & 4) != 0 ? model.role : guildRole, (i & 8) != 0 ? model.manageStatus : manageStatus, (i & 16) != 0 ? model.myPermissions : l, (i & 32) != 0 ? model.myPermissionsFromOtherRoles : j2, (i & 64) != 0 ? model.isCommunityServer : z3);
|
|
}
|
|
|
|
public final boolean canManage() {
|
|
ManageStatus manageStatus = this.manageStatus;
|
|
return manageStatus == ManageStatus.CAN_MANAGE_CONDITIONAL || manageStatus == ManageStatus.CAN_MANAGE_ADMIN;
|
|
}
|
|
|
|
public final boolean component1() {
|
|
return this.owner;
|
|
}
|
|
|
|
public final long component2() {
|
|
return this.guildId;
|
|
}
|
|
|
|
public final GuildRole component3() {
|
|
return this.role;
|
|
}
|
|
|
|
public final ManageStatus component4() {
|
|
return this.manageStatus;
|
|
}
|
|
|
|
public final Long component5() {
|
|
return this.myPermissions;
|
|
}
|
|
|
|
public final long component6() {
|
|
return this.myPermissionsFromOtherRoles;
|
|
}
|
|
|
|
public final boolean component7() {
|
|
return this.isCommunityServer;
|
|
}
|
|
|
|
public final Model copy(boolean z2, long j, GuildRole guildRole, ManageStatus manageStatus, Long l, long j2, boolean z3) {
|
|
m.checkNotNullParameter(guildRole, "role");
|
|
return new Model(z2, j, guildRole, manageStatus, l, j2, z3);
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (this == obj) {
|
|
return true;
|
|
}
|
|
if (!(obj instanceof Model)) {
|
|
return false;
|
|
}
|
|
Model model = (Model) obj;
|
|
return this.owner == model.owner && this.guildId == model.guildId && m.areEqual(this.role, model.role) && m.areEqual(this.manageStatus, model.manageStatus) && m.areEqual(this.myPermissions, model.myPermissions) && this.myPermissionsFromOtherRoles == model.myPermissionsFromOtherRoles && this.isCommunityServer == model.isCommunityServer;
|
|
}
|
|
|
|
public final long getGuildId() {
|
|
return this.guildId;
|
|
}
|
|
|
|
public final ManageStatus getManageStatus() {
|
|
return this.manageStatus;
|
|
}
|
|
|
|
public final Long getMyPermissions() {
|
|
return this.myPermissions;
|
|
}
|
|
|
|
public final long getMyPermissionsFromOtherRoles() {
|
|
return this.myPermissionsFromOtherRoles;
|
|
}
|
|
|
|
public final boolean getOwner() {
|
|
return this.owner;
|
|
}
|
|
|
|
public final GuildRole getRole() {
|
|
return this.role;
|
|
}
|
|
|
|
public int hashCode() {
|
|
boolean z2 = this.owner;
|
|
int i = 1;
|
|
if (z2) {
|
|
z2 = true;
|
|
}
|
|
int i2 = z2 ? 1 : 0;
|
|
int i3 = z2 ? 1 : 0;
|
|
int i4 = z2 ? 1 : 0;
|
|
int a = (b.a(this.guildId) + (i2 * 31)) * 31;
|
|
GuildRole guildRole = this.role;
|
|
int i5 = 0;
|
|
int hashCode = (a + (guildRole != null ? guildRole.hashCode() : 0)) * 31;
|
|
ManageStatus manageStatus = this.manageStatus;
|
|
int hashCode2 = (hashCode + (manageStatus != null ? manageStatus.hashCode() : 0)) * 31;
|
|
Long l = this.myPermissions;
|
|
if (l != null) {
|
|
i5 = l.hashCode();
|
|
}
|
|
int a2 = (b.a(this.myPermissionsFromOtherRoles) + ((hashCode2 + i5) * 31)) * 31;
|
|
boolean z3 = this.isCommunityServer;
|
|
if (!z3) {
|
|
i = z3 ? 1 : 0;
|
|
}
|
|
return a2 + i;
|
|
}
|
|
|
|
public final boolean isCommunityServer() {
|
|
return this.isCommunityServer;
|
|
}
|
|
|
|
public final boolean isEveryoneRole() {
|
|
return this.role.getId() == this.guildId;
|
|
}
|
|
|
|
public final boolean isSingular(long j) {
|
|
return !this.owner && (this.myPermissionsFromOtherRoles & j) != j;
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuilder L = a.L("Model(owner=");
|
|
L.append(this.owner);
|
|
L.append(", guildId=");
|
|
L.append(this.guildId);
|
|
L.append(", role=");
|
|
L.append(this.role);
|
|
L.append(", manageStatus=");
|
|
L.append(this.manageStatus);
|
|
L.append(", myPermissions=");
|
|
L.append(this.myPermissions);
|
|
L.append(", myPermissionsFromOtherRoles=");
|
|
L.append(this.myPermissionsFromOtherRoles);
|
|
L.append(", isCommunityServer=");
|
|
return a.G(L, this.isCommunityServer, ")");
|
|
}
|
|
}
|
|
|
|
public final /* synthetic */ class WhenMappings {
|
|
public static final /* synthetic */ int[] $EnumSwitchMapping$0;
|
|
public static final /* synthetic */ int[] $EnumSwitchMapping$1;
|
|
|
|
static {
|
|
Model.ManageStatus.values();
|
|
int[] iArr = new int[6];
|
|
$EnumSwitchMapping$0 = iArr;
|
|
iArr[Model.ManageStatus.CAN_MANAGE_CONDITIONAL.ordinal()] = 1;
|
|
iArr[Model.ManageStatus.CAN_MANAGE_ADMIN.ordinal()] = 2;
|
|
Model.ManageStatus.values();
|
|
int[] iArr2 = new int[6];
|
|
$EnumSwitchMapping$1 = iArr2;
|
|
iArr2[Model.ManageStatus.NO_MANAGE_ROLES_PERMISSION.ordinal()] = 1;
|
|
iArr2[Model.ManageStatus.LOCKED_HIGHER.ordinal()] = 2;
|
|
iArr2[Model.ManageStatus.LOCKED_HIGHEST.ordinal()] = 3;
|
|
iArr2[Model.ManageStatus.USER_NOT_ELEVATED.ordinal()] = 4;
|
|
}
|
|
}
|
|
|
|
public WidgetServerSettingsEditRole() {
|
|
super(2131559007);
|
|
}
|
|
|
|
public static final /* synthetic */ void access$configureUI(WidgetServerSettingsEditRole widgetServerSettingsEditRole, Model model) {
|
|
widgetServerSettingsEditRole.configureUI(model);
|
|
}
|
|
|
|
public static final /* synthetic */ WidgetEditRoleBinding access$getBinding$p(WidgetServerSettingsEditRole widgetServerSettingsEditRole) {
|
|
return widgetServerSettingsEditRole.getBinding();
|
|
}
|
|
|
|
public static final /* synthetic */ String access$getLockMessage(WidgetServerSettingsEditRole widgetServerSettingsEditRole, Model model, boolean z2) {
|
|
return widgetServerSettingsEditRole.getLockMessage(model, z2);
|
|
}
|
|
|
|
public static final /* synthetic */ void access$launchColorPicker(WidgetServerSettingsEditRole widgetServerSettingsEditRole, Model model) {
|
|
widgetServerSettingsEditRole.launchColorPicker(model);
|
|
}
|
|
|
|
public static final /* synthetic */ void access$patchRole(WidgetServerSettingsEditRole widgetServerSettingsEditRole, long j, RestAPIParams.Role role) {
|
|
widgetServerSettingsEditRole.patchRole(j, role);
|
|
}
|
|
|
|
private final void configureUI(Model model) {
|
|
if ((model != null ? model.getRole() : null) == null) {
|
|
AppActivity appActivity = getAppActivity();
|
|
if (appActivity != null) {
|
|
appActivity.finish();
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
setupMenu(model);
|
|
setupActionBar(model);
|
|
setupRoleName(model);
|
|
setupHoistAndMentionSettings(model);
|
|
setupPermissionsSettings(model);
|
|
setupColorSetting(model);
|
|
this.state.configureSaveActionView(getBinding().f1775c);
|
|
getBinding().f1775c.setOnClickListener(new WidgetServerSettingsEditRole$configureUI$1(this, model));
|
|
}
|
|
|
|
private final void enableSetting(CheckedSetting checkedSetting, Model model, long j) {
|
|
checkedSetting.e(new WidgetServerSettingsEditRole$enableSetting$1(this, model, j));
|
|
}
|
|
|
|
private final WidgetEditRoleBinding getBinding() {
|
|
return (WidgetEditRoleBinding) this.binding$delegate.getValue((Fragment) this, $$delegatedProperties[0]);
|
|
}
|
|
|
|
@ColorInt
|
|
private final int[] getColorsToDisplay(@ColorInt int i) {
|
|
int[] intArray = getResources().getIntArray(2130903044);
|
|
m.checkNotNullExpressionValue(intArray, "resources.getIntArray(R.…ray.color_picker_palette)");
|
|
ArrayList arrayList = new ArrayList();
|
|
boolean z2 = false;
|
|
for (int i2 : intArray) {
|
|
arrayList.add(Integer.valueOf(i2));
|
|
if (i2 == i) {
|
|
z2 = true;
|
|
}
|
|
}
|
|
if (!z2) {
|
|
arrayList.add(Integer.valueOf(i));
|
|
}
|
|
int[] iArr = new int[arrayList.size()];
|
|
int size = arrayList.size();
|
|
for (int i3 = 0; i3 < size; i3++) {
|
|
iArr[i3] = ((Number) arrayList.get(i3)).intValue();
|
|
}
|
|
return iArr;
|
|
}
|
|
|
|
private final String getLockMessage(Model model, boolean z2) {
|
|
String str;
|
|
if (!z2 || !model.isEveryoneRole()) {
|
|
Model.ManageStatus manageStatus = model.getManageStatus();
|
|
if (manageStatus != null) {
|
|
int ordinal = manageStatus.ordinal();
|
|
if (ordinal == 0) {
|
|
str = getString(2131890225);
|
|
} else if (ordinal == 1) {
|
|
str = getString(2131890227);
|
|
} else if (ordinal == 2) {
|
|
str = getString(2131890228);
|
|
} else if (ordinal == 3) {
|
|
str = getString(2131894215);
|
|
}
|
|
m.checkNotNullExpressionValue(str, "when (data.manageStatus)…s)\n else -> \"\"\n }");
|
|
return str;
|
|
}
|
|
str = "";
|
|
m.checkNotNullExpressionValue(str, "when (data.manageStatus)…s)\n else -> \"\"\n }");
|
|
return str;
|
|
}
|
|
String string = getString(2131888642);
|
|
m.checkNotNullExpressionValue(string, "getString(R.string.form_…el_disabled_for_everyone)");
|
|
return string;
|
|
}
|
|
|
|
public static final void launch(long j, long j2, Context context) {
|
|
Companion.launch(j, j2, context);
|
|
}
|
|
|
|
private final void launchColorPicker(Model model) {
|
|
int roleColor$default = RoleUtils.getRoleColor$default(model.getRole(), requireContext(), null, 2, null);
|
|
e.k kVar = new e.k();
|
|
kVar.h = roleColor$default;
|
|
kVar.f1458s = ColorCompat.getThemedColor(getContext(), 2130968904);
|
|
kVar.i = false;
|
|
kVar.g = getColorsToDisplay(roleColor$default);
|
|
kVar.a = 2131892827;
|
|
kVar.r = ColorCompat.getThemedColor(getContext(), 2130968932);
|
|
FontUtils fontUtils = FontUtils.INSTANCE;
|
|
kVar.f1459x = fontUtils.getThemedFontResId(getContext(), 2130969320);
|
|
kVar.o = ColorCompat.getThemedColor(getContext(), 2130968892);
|
|
kVar.f1457c = 2131887418;
|
|
kVar.v = ColorCompat.getColor(getContext(), 2131100428);
|
|
kVar.b = 2131887419;
|
|
kVar.p = ColorCompat.getThemedColor(getContext(), 2130968994);
|
|
kVar.d = 2131893293;
|
|
kVar.l = true;
|
|
kVar.e = 2131892800;
|
|
kVar.w = ColorCompat.getColor(getContext(), 2131100428);
|
|
kVar.f1460y = fontUtils.getThemedFontResId(getContext(), 2130969326);
|
|
kVar.q = ColorCompat.getThemedColor(getContext(), 2130968900);
|
|
kVar.t = ColorCompat.getThemedColor(getContext(), 2130968988);
|
|
kVar.u = 2131231107;
|
|
kVar.f1461z = fontUtils.getThemedFontResId(getContext(), 2130969325);
|
|
e a = kVar.a();
|
|
a.j = new WidgetServerSettingsEditRole$launchColorPicker$1(this, model);
|
|
AppFragment.hideKeyboard$default(this, null, 1, null);
|
|
a.show(getParentFragmentManager(), "DIALOG_TAG_COLOR_PICKER");
|
|
}
|
|
|
|
private final void patchRole(long j, RestAPIParams.Role role) {
|
|
ObservableExtensionsKt.ui$default(ObservableExtensionsKt.restSubscribeOn$default(RestAPI.Companion.getApi().updateRole(j, role.getId(), role), false, 1, null), this, null, 2, null).k(q.j(WidgetServerSettingsEditRole$patchRole$1.INSTANCE, getContext(), null, 4));
|
|
}
|
|
|
|
private final void setupActionBar(Model model) {
|
|
int i;
|
|
AppActivity appActivity = getAppActivity();
|
|
Toolbar toolbar = appActivity != null ? appActivity.t : null;
|
|
if (toolbar != null) {
|
|
int roleColor = RoleUtils.getRoleColor(model.getRole(), requireContext(), Integer.valueOf(ColorCompat.getThemedColor(requireContext(), 2130968994)));
|
|
if (RoleUtils.isDefaultColor(model.getRole())) {
|
|
i = ColorCompat.getThemedColor(this, 2130969006);
|
|
} else {
|
|
float[] fArr = new float[3];
|
|
Color.colorToHSV(roleColor, fArr);
|
|
fArr[2] = fArr[2] * 0.5f;
|
|
i = Color.HSVToColor(fArr);
|
|
}
|
|
boolean isColorDark$default = ColorCompat.isColorDark$default(roleColor, 0.0f, 2, null);
|
|
int color = ColorCompat.getColor(requireContext(), isColorDark$default ? 2131100112 : 2131100128);
|
|
ColorCompat.setStatusBarColor(this, i, isColorDark$default);
|
|
WidgetServerSettingsEditRole$setupActionBar$1 widgetServerSettingsEditRole$setupActionBar$1 = WidgetServerSettingsEditRole$setupActionBar$1.INSTANCE;
|
|
AppFragment.setActionBarDisplayHomeAsUpEnabled$default(this, false, 1, null);
|
|
String string = getString(2131888730);
|
|
m.checkNotNullExpressionValue(string, "getString(R.string.form_label_role_settings)");
|
|
setActionBarTitle(widgetServerSettingsEditRole$setupActionBar$1.invoke(string, color));
|
|
setActionBarSubtitle(widgetServerSettingsEditRole$setupActionBar$1.invoke(model.getRole().f(), color));
|
|
toolbar.setBackgroundColor(roleColor);
|
|
Drawable navigationIcon = toolbar.getNavigationIcon();
|
|
if (navigationIcon != null) {
|
|
navigationIcon.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP));
|
|
}
|
|
Drawable overflowIcon = toolbar.getOverflowIcon();
|
|
if (overflowIcon != null) {
|
|
overflowIcon.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP));
|
|
}
|
|
}
|
|
}
|
|
|
|
private final void setupColorSetting(Model model) {
|
|
View view = getBinding().l;
|
|
m.checkNotNullExpressionValue(view, "binding.roleSettingsCurrentColorDisplay");
|
|
Drawable drawable = ContextCompat.getDrawable(view.getContext(), 2131231096);
|
|
if (drawable != null) {
|
|
drawable.setColorFilter(new PorterDuffColorFilter(RoleUtils.getRoleColor$default(model.getRole(), requireContext(), null, 2, null), PorterDuff.Mode.SRC_ATOP));
|
|
View view2 = getBinding().l;
|
|
m.checkNotNullExpressionValue(view2, "binding.roleSettingsCurrentColorDisplay");
|
|
view2.setBackground(drawable);
|
|
}
|
|
if (!model.canManage() || model.isEveryoneRole()) {
|
|
View view3 = getBinding().i;
|
|
m.checkNotNullExpressionValue(view3, "binding.roleSettingsColorDisabledOverlay");
|
|
view3.setVisibility(0);
|
|
getBinding().i.setOnClickListener(new WidgetServerSettingsEditRole$setupColorSetting$2(this, model));
|
|
return;
|
|
}
|
|
getBinding().j.setOnClickListener(new WidgetServerSettingsEditRole$setupColorSetting$1(this, model));
|
|
View view4 = getBinding().i;
|
|
m.checkNotNullExpressionValue(view4, "binding.roleSettingsColorDisabledOverlay");
|
|
view4.setVisibility(8);
|
|
getBinding().i.setOnClickListener(null);
|
|
}
|
|
|
|
private final void setupHoistAndMentionSettings(Model model) {
|
|
CheckedSetting checkedSetting = getBinding().o;
|
|
m.checkNotNullExpressionValue(checkedSetting, "binding.roleSettingsHoistCheckedsetting");
|
|
checkedSetting.setChecked(model.getRole().c());
|
|
CheckedSetting checkedSetting2 = getBinding().f1779z;
|
|
m.checkNotNullExpressionValue(checkedSetting2, "binding.roleSettingsMentionableCheckedsetting");
|
|
checkedSetting2.setChecked(model.getRole().e());
|
|
if (!model.canManage() || model.isEveryoneRole()) {
|
|
String lockMessage = getLockMessage(model, true);
|
|
getBinding().o.c(lockMessage);
|
|
getBinding().f1779z.c(lockMessage);
|
|
return;
|
|
}
|
|
getBinding().o.e(new WidgetServerSettingsEditRole$setupHoistAndMentionSettings$1(this, model));
|
|
getBinding().f1779z.e(new WidgetServerSettingsEditRole$setupHoistAndMentionSettings$2(this, model));
|
|
}
|
|
|
|
private final void setupMenu(Model model) {
|
|
if (!model.canManage() || model.isEveryoneRole() || model.getRole().d()) {
|
|
AppFragment.setActionBarOptionsMenu$default(this, 2131623951, null, null, 4, null);
|
|
} else {
|
|
AppFragment.setActionBarOptionsMenu$default(this, 2131623950, new WidgetServerSettingsEditRole$setupMenu$1(this, model), null, 4, null);
|
|
}
|
|
}
|
|
|
|
/* JADX WARNING: Removed duplicated region for block: B:73:0x02a0 */
|
|
/* JADX WARNING: Removed duplicated region for block: B:74:0x02a2 */
|
|
private final void setupPermissionsSettings(Model model) {
|
|
long j;
|
|
for (CheckedSetting checkedSetting : n.listOf((Object[]) new CheckedSetting[]{getBinding().e, getBinding().f, getBinding().g, getBinding().h, getBinding().k, getBinding().n, getBinding().p, getBinding().q, getBinding().f1776s, getBinding().w, getBinding().t, getBinding().r, getBinding().u, getBinding().v, getBinding().f1777x, getBinding().f1778y, getBinding().B, getBinding().C, getBinding().E, getBinding().J, getBinding().I, getBinding().F, getBinding().G, getBinding().H, getBinding().d, getBinding().K, getBinding().M, getBinding().Q, getBinding().S, getBinding().P, getBinding().N, getBinding().O, getBinding().R, getBinding().A, getBinding().L, getBinding().D})) {
|
|
m.checkNotNullExpressionValue(checkedSetting, "setting");
|
|
switch (checkedSetting.getId()) {
|
|
case 2131364547:
|
|
j = 64;
|
|
break;
|
|
case 2131364548:
|
|
j = 8;
|
|
break;
|
|
case 2131364549:
|
|
j = 32768;
|
|
break;
|
|
case 2131364550:
|
|
j = 4;
|
|
break;
|
|
case 2131364551:
|
|
j = 67108864;
|
|
break;
|
|
case 2131364552:
|
|
case 2131364553:
|
|
case 2131364555:
|
|
case 2131364556:
|
|
case 2131364558:
|
|
case 2131364569:
|
|
case 2131364570:
|
|
default:
|
|
j = 0;
|
|
break;
|
|
case 2131364554:
|
|
j = 1;
|
|
break;
|
|
case 2131364557:
|
|
j = 16384;
|
|
break;
|
|
case 2131364559:
|
|
j = 2;
|
|
break;
|
|
case 2131364560:
|
|
j = 16;
|
|
break;
|
|
case 2131364561:
|
|
j = 1073741824;
|
|
break;
|
|
case 2131364562:
|
|
j = 8192;
|
|
break;
|
|
case 2131364563:
|
|
j = 134217728;
|
|
break;
|
|
case 2131364564:
|
|
j = 268435456;
|
|
break;
|
|
case 2131364565:
|
|
j = 32;
|
|
break;
|
|
case 2131364566:
|
|
j = 17179869184L;
|
|
break;
|
|
case 2131364567:
|
|
j = 536870912;
|
|
break;
|
|
case 2131364568:
|
|
j = 131072;
|
|
break;
|
|
case 2131364571:
|
|
j = 256;
|
|
break;
|
|
case 2131364572:
|
|
j = 65536;
|
|
break;
|
|
case 2131364573:
|
|
j = 1024;
|
|
break;
|
|
case 2131364574:
|
|
j = 4294967296L;
|
|
break;
|
|
case 2131364575:
|
|
j = 2048;
|
|
break;
|
|
case 2131364576:
|
|
j = 4096;
|
|
break;
|
|
case 2131364577:
|
|
j = 2147483648L;
|
|
break;
|
|
case 2131364578:
|
|
j = 262144;
|
|
break;
|
|
case 2131364579:
|
|
j = 68719476736L;
|
|
break;
|
|
case 2131364580:
|
|
j = 34359738368L;
|
|
break;
|
|
case 2131364581:
|
|
j = 128;
|
|
break;
|
|
case 2131364582:
|
|
j = 524288;
|
|
break;
|
|
case 2131364583:
|
|
j = 1048576;
|
|
break;
|
|
case 2131364584:
|
|
j = 8388608;
|
|
break;
|
|
case 2131364585:
|
|
j = 16777216;
|
|
break;
|
|
case 2131364586:
|
|
j = 4194304;
|
|
break;
|
|
case 2131364587:
|
|
j = 2097152;
|
|
break;
|
|
case 2131364588:
|
|
j = 33554432;
|
|
break;
|
|
case 2131364589:
|
|
j = 512;
|
|
break;
|
|
}
|
|
boolean can = PermissionUtils.can(j, Long.valueOf(model.getRole().g()));
|
|
checkedSetting.setChecked(can);
|
|
boolean can2 = PermissionUtils.can(j, model.getMyPermissions());
|
|
Model.ManageStatus manageStatus = model.getManageStatus();
|
|
if (manageStatus != null) {
|
|
int ordinal = manageStatus.ordinal();
|
|
if (ordinal != 4) {
|
|
if (ordinal == 5) {
|
|
if (model.getOwner() || j != 8 || !model.isSingular(j)) {
|
|
enableSetting(checkedSetting, model, j);
|
|
} else {
|
|
checkedSetting.b(2131890230);
|
|
}
|
|
}
|
|
} else if (can2 && !(model.isSingular(j) && can)) {
|
|
enableSetting(checkedSetting, model, j);
|
|
} else if (!can2) {
|
|
checkedSetting.b(2131890226);
|
|
} else {
|
|
checkedSetting.b(2131890230);
|
|
}
|
|
checkedSetting.setVisibility(!((j != 524288 && !model.isCommunityServer()) ^ true) ? 0 : 8);
|
|
}
|
|
checkedSetting.c(getLockMessage(model, false));
|
|
checkedSetting.setVisibility(!((j != 524288 && !model.isCommunityServer()) ^ true) ? 0 : 8);
|
|
}
|
|
}
|
|
|
|
private final void setupRoleName(Model model) {
|
|
TextInputLayout textInputLayout = getBinding().b;
|
|
m.checkNotNullExpressionValue(textInputLayout, "binding.editRoleName");
|
|
StatefulViews statefulViews = this.state;
|
|
TextInputLayout textInputLayout2 = getBinding().b;
|
|
m.checkNotNullExpressionValue(textInputLayout2, "binding.editRoleName");
|
|
ViewExtensions.setText(textInputLayout, (CharSequence) statefulViews.get(textInputLayout2.getId(), model.getRole().f()));
|
|
if (!model.canManage() || model.isEveryoneRole()) {
|
|
View view = getBinding().m;
|
|
m.checkNotNullExpressionValue(view, "binding.roleSettingsEditNameDisabledOverlay");
|
|
view.setVisibility(0);
|
|
getBinding().m.setOnClickListener(new WidgetServerSettingsEditRole$setupRoleName$1(this, model));
|
|
return;
|
|
}
|
|
View view2 = getBinding().m;
|
|
m.checkNotNullExpressionValue(view2, "binding.roleSettingsEditNameDisabledOverlay");
|
|
view2.setVisibility(8);
|
|
getBinding().m.setOnClickListener(null);
|
|
}
|
|
|
|
@Override // com.discord.app.AppFragment
|
|
public void onViewBound(View view) {
|
|
m.checkNotNullParameter(view, "view");
|
|
super.onViewBound(view);
|
|
setRetainInstance(true);
|
|
this.state.setupUnsavedChangesConfirmation(this);
|
|
StatefulViews statefulViews = this.state;
|
|
FloatingActionButton floatingActionButton = getBinding().f1775c;
|
|
TextInputLayout textInputLayout = getBinding().b;
|
|
m.checkNotNullExpressionValue(textInputLayout, "binding.editRoleName");
|
|
statefulViews.setupTextWatcherWithSaveAction(this, floatingActionButton, textInputLayout);
|
|
FloatingActionButton floatingActionButton2 = getBinding().f1775c;
|
|
m.checkNotNullExpressionValue(floatingActionButton2, "binding.editRoleSave");
|
|
floatingActionButton2.setVisibility(8);
|
|
}
|
|
|
|
@Override // com.discord.app.AppFragment
|
|
public void onViewBoundOrOnResume() {
|
|
super.onViewBoundOrOnResume();
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(ObservableExtensionsKt.computationLatest(Model.Companion.get(getMostRecentIntent().getLongExtra("INTENT_EXTRA_GUILD_ID", -1), getMostRecentIntent().getLongExtra("INTENT_EXTRA_ROLE_ID", -1))), this, null, 2, null), WidgetServerSettingsEditRole.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetServerSettingsEditRole$onViewBoundOrOnResume$1(this), 62, (Object) null);
|
|
FragmentManager parentFragmentManager = getParentFragmentManager();
|
|
m.checkNotNullExpressionValue(parentFragmentManager, "parentFragmentManager");
|
|
Fragment findFragmentByTag = parentFragmentManager.findFragmentByTag("DIALOG_TAG_COLOR_PICKER");
|
|
if (findFragmentByTag != null) {
|
|
parentFragmentManager.beginTransaction().remove(findFragmentByTag).commit();
|
|
}
|
|
}
|
|
}
|