794 lines
39 KiB
Java
794 lines
39 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 android.widget.RelativeLayout;
|
|
import android.widget.TextView;
|
|
import androidx.appcompat.widget.Toolbar;
|
|
import androidx.core.content.ContextCompat;
|
|
import androidx.fragment.app.Fragment;
|
|
import androidx.fragment.app.FragmentManager;
|
|
import c.a.d.j;
|
|
import c.a.d.o;
|
|
import c.d.b.a.a;
|
|
import com.discord.R;
|
|
import com.discord.api.permission.Permission;
|
|
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.colors.ColorPickerUtils;
|
|
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 com.jaredrummler.android.colorpicker.ColorPickerDialog;
|
|
import d0.t.n;
|
|
import d0.z.d.m;
|
|
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.b0(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(R.id.edit_role_name);
|
|
|
|
/* 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(WidgetServerSettingsEditRole.INTENT_EXTRA_ROLE_ID, j2);
|
|
j.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 hasEventsFeature;
|
|
private final boolean isCommunityServer;
|
|
private final ManageStatus manageStatus;
|
|
private final Long myPermissions;
|
|
private final long myPermissionsFromOtherRoles;
|
|
private final boolean owner;
|
|
private final GuildRole role;
|
|
private final boolean useNewThreadPermissions;
|
|
|
|
/* 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(Permission.MANAGE_ROLES, 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.h() | 0 | guildRole.h();
|
|
}
|
|
for (Number number : collection) {
|
|
long longValue = number.longValue();
|
|
GuildRole guildRole2 = map.get(Long.valueOf(longValue));
|
|
if (!(guildRole2 == null || longValue == j)) {
|
|
j3 = guildRole2.h() | j3;
|
|
}
|
|
}
|
|
return j3;
|
|
}
|
|
|
|
public final Observable<Model> get(long j, long j2) {
|
|
Observable<Model> q = StoreUser.observeMe$default(StoreStream.Companion.getUsers(), false, 1, null).Y(new WidgetServerSettingsEditRole$Model$Companion$get$1(j, j2)).q();
|
|
m.checkNotNullExpressionValue(q, "getUsers()\n .… .distinctUntilChanged()");
|
|
return q;
|
|
}
|
|
}
|
|
|
|
/* 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, boolean z4, boolean z5) {
|
|
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;
|
|
this.useNewThreadPermissions = z4;
|
|
this.hasEventsFeature = z5;
|
|
}
|
|
|
|
public static /* synthetic */ Model copy$default(Model model, boolean z2, long j, GuildRole guildRole, ManageStatus manageStatus, Long l, long j2, boolean z3, boolean z4, boolean z5, 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, (i & 128) != 0 ? model.useNewThreadPermissions : z4, (i & 256) != 0 ? model.hasEventsFeature : z5);
|
|
}
|
|
|
|
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 boolean component8() {
|
|
return this.useNewThreadPermissions;
|
|
}
|
|
|
|
public final boolean component9() {
|
|
return this.hasEventsFeature;
|
|
}
|
|
|
|
public final Model copy(boolean z2, long j, GuildRole guildRole, ManageStatus manageStatus, Long l, long j2, boolean z3, boolean z4, boolean z5) {
|
|
m.checkNotNullParameter(guildRole, "role");
|
|
return new Model(z2, j, guildRole, manageStatus, l, j2, z3, z4, z5);
|
|
}
|
|
|
|
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 && this.useNewThreadPermissions == model.useNewThreadPermissions && this.hasEventsFeature == model.hasEventsFeature;
|
|
}
|
|
|
|
public final long getGuildId() {
|
|
return this.guildId;
|
|
}
|
|
|
|
public final boolean getHasEventsFeature() {
|
|
return this.hasEventsFeature;
|
|
}
|
|
|
|
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 final boolean getUseNewThreadPermissions() {
|
|
return this.useNewThreadPermissions;
|
|
}
|
|
|
|
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) {
|
|
z3 = true;
|
|
}
|
|
int i6 = z3 ? 1 : 0;
|
|
int i7 = z3 ? 1 : 0;
|
|
int i8 = z3 ? 1 : 0;
|
|
int i9 = (a2 + i6) * 31;
|
|
boolean z4 = this.useNewThreadPermissions;
|
|
if (z4) {
|
|
z4 = true;
|
|
}
|
|
int i10 = z4 ? 1 : 0;
|
|
int i11 = z4 ? 1 : 0;
|
|
int i12 = z4 ? 1 : 0;
|
|
int i13 = (i9 + i10) * 31;
|
|
boolean z5 = this.hasEventsFeature;
|
|
if (!z5) {
|
|
i = z5 ? 1 : 0;
|
|
}
|
|
return i13 + 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 R = a.R("Model(owner=");
|
|
R.append(this.owner);
|
|
R.append(", guildId=");
|
|
R.append(this.guildId);
|
|
R.append(", role=");
|
|
R.append(this.role);
|
|
R.append(", manageStatus=");
|
|
R.append(this.manageStatus);
|
|
R.append(", myPermissions=");
|
|
R.append(this.myPermissions);
|
|
R.append(", myPermissionsFromOtherRoles=");
|
|
R.append(this.myPermissionsFromOtherRoles);
|
|
R.append(", isCommunityServer=");
|
|
R.append(this.isCommunityServer);
|
|
R.append(", useNewThreadPermissions=");
|
|
R.append(this.useNewThreadPermissions);
|
|
R.append(", hasEventsFeature=");
|
|
return a.L(R, this.hasEventsFeature, ")");
|
|
}
|
|
}
|
|
|
|
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(R.layout.widget_edit_role);
|
|
}
|
|
|
|
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);
|
|
setRoleIcon(model);
|
|
this.state.configureSaveActionView(getBinding().f1854c);
|
|
getBinding().f1854c.setOnClickListener(new WidgetServerSettingsEditRole$configureUI$1(this, model));
|
|
if (!model.getUseNewThreadPermissions()) {
|
|
CheckedSetting.i(getBinding().N, getString(R.string.role_permissions_send_messages_description), false, 2);
|
|
getBinding().O.setText(getString(R.string.interim_send_messages_in_threads));
|
|
getBinding().O.h(c.a.k.b.k(this, R.string.interim_role_permissions_send_messages_in_threads_description, new Object[0], null, 4), true);
|
|
getBinding().o.setText(getString(R.string.interim_create_public_threads));
|
|
getBinding().o.h(c.a.k.b.k(this, R.string.interim_role_permissions_create_public_threads_description, new Object[0], null, 4), true);
|
|
getBinding().n.setText(getString(R.string.interim_create_private_threads));
|
|
getBinding().n.h(c.a.k.b.k(this, R.string.interim_role_permissions_create_private_threads_description, new Object[0], null, 4), true);
|
|
}
|
|
}
|
|
|
|
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]);
|
|
}
|
|
|
|
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(R.string.help_missing_manage_roles_permission);
|
|
} else if (ordinal == 1) {
|
|
str = getString(R.string.help_role_locked);
|
|
} else if (ordinal == 2) {
|
|
str = getString(R.string.help_role_locked_mine);
|
|
} else if (ordinal == 3) {
|
|
str = getString(R.string.two_fa_guild_mfa_warning_ios);
|
|
}
|
|
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(R.string.form_label_disabled_for_everyone);
|
|
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) {
|
|
ColorPickerDialog buildColorPickerDialog = ColorPickerUtils.INSTANCE.buildColorPickerDialog(requireContext(), R.string.role_color, RoleUtils.getRoleColor$default(model.getRole(), requireContext(), null, 2, null));
|
|
buildColorPickerDialog.j = new WidgetServerSettingsEditRole$launchColorPicker$1(this, model);
|
|
AppFragment.hideKeyboard$default(this, null, 1, null);
|
|
buildColorPickerDialog.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(o.j(WidgetServerSettingsEditRole$patchRole$1.INSTANCE, getContext(), null, 4));
|
|
}
|
|
|
|
private final void setRoleIcon(Model model) {
|
|
if (model.getRole().d() != null) {
|
|
String d = model.getRole().d();
|
|
m.checkNotNull(d);
|
|
if (d.length() > 0) {
|
|
getBinding().K.setRole(model.getRole(), Long.valueOf(model.getGuildId()));
|
|
TextView textView = getBinding().M;
|
|
m.checkNotNullExpressionValue(textView, "binding.roleSettingsRoleIconHeader");
|
|
textView.setVisibility(0);
|
|
View view = getBinding().L;
|
|
m.checkNotNullExpressionValue(view, "binding.roleSettingsRoleIconDivider");
|
|
view.setVisibility(0);
|
|
RelativeLayout relativeLayout = getBinding().t;
|
|
m.checkNotNullExpressionValue(relativeLayout, "binding.roleSettingsIconContainer");
|
|
relativeLayout.setVisibility(0);
|
|
return;
|
|
}
|
|
}
|
|
TextView textView2 = getBinding().M;
|
|
m.checkNotNullExpressionValue(textView2, "binding.roleSettingsRoleIconHeader");
|
|
textView2.setVisibility(8);
|
|
View view2 = getBinding().L;
|
|
m.checkNotNullExpressionValue(view2, "binding.roleSettingsRoleIconDivider");
|
|
view2.setVisibility(8);
|
|
RelativeLayout relativeLayout2 = getBinding().t;
|
|
m.checkNotNullExpressionValue(relativeLayout2, "binding.roleSettingsIconContainer");
|
|
relativeLayout2.setVisibility(8);
|
|
}
|
|
|
|
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(), (int) R.attr.color_brand)));
|
|
if (RoleUtils.isDefaultColor(model.getRole())) {
|
|
i = ColorCompat.getThemedColor(this, (int) R.attr.color_brand_460);
|
|
} 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 ? R.color.primary_100 : R.color.primary_500);
|
|
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(R.string.form_label_role_settings);
|
|
m.checkNotNullExpressionValue(string, "getString(R.string.form_label_role_settings)");
|
|
setActionBarTitle(widgetServerSettingsEditRole$setupActionBar$1.invoke(string, color));
|
|
setActionBarSubtitle(widgetServerSettingsEditRole$setupActionBar$1.invoke(model.getRole().g(), 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().p;
|
|
m.checkNotNullExpressionValue(view, "binding.roleSettingsCurrentColorDisplay");
|
|
Drawable drawable = ContextCompat.getDrawable(view.getContext(), R.drawable.drawable_circle_white_1);
|
|
if (drawable != null) {
|
|
drawable.setColorFilter(new PorterDuffColorFilter(RoleUtils.getRoleColor$default(model.getRole(), requireContext(), null, 2, null), PorterDuff.Mode.SRC_ATOP));
|
|
View view2 = getBinding().p;
|
|
m.checkNotNullExpressionValue(view2, "binding.roleSettingsCurrentColorDisplay");
|
|
view2.setBackground(drawable);
|
|
}
|
|
if (!model.canManage() || model.isEveryoneRole()) {
|
|
View view3 = getBinding().k;
|
|
m.checkNotNullExpressionValue(view3, "binding.roleSettingsColorDisabledOverlay");
|
|
view3.setVisibility(0);
|
|
getBinding().k.setOnClickListener(new WidgetServerSettingsEditRole$setupColorSetting$2(this, model));
|
|
return;
|
|
}
|
|
getBinding().l.setOnClickListener(new WidgetServerSettingsEditRole$setupColorSetting$1(this, model));
|
|
View view4 = getBinding().k;
|
|
m.checkNotNullExpressionValue(view4, "binding.roleSettingsColorDisabledOverlay");
|
|
view4.setVisibility(8);
|
|
getBinding().k.setOnClickListener(null);
|
|
}
|
|
|
|
private final void setupHoistAndMentionSettings(Model model) {
|
|
CheckedSetting checkedSetting = getBinding().f1855s;
|
|
m.checkNotNullExpressionValue(checkedSetting, "binding.roleSettingsHoistCheckedsetting");
|
|
checkedSetting.setChecked(model.getRole().c());
|
|
CheckedSetting checkedSetting2 = getBinding().F;
|
|
m.checkNotNullExpressionValue(checkedSetting2, "binding.roleSettingsMentionableCheckedsetting");
|
|
checkedSetting2.setChecked(model.getRole().f());
|
|
if (!model.canManage() || model.isEveryoneRole()) {
|
|
String lockMessage = getLockMessage(model, true);
|
|
getBinding().f1855s.c(lockMessage);
|
|
getBinding().F.c(lockMessage);
|
|
return;
|
|
}
|
|
getBinding().f1855s.e(new WidgetServerSettingsEditRole$setupHoistAndMentionSettings$1(this, model));
|
|
getBinding().F.e(new WidgetServerSettingsEditRole$setupHoistAndMentionSettings$2(this, model));
|
|
}
|
|
|
|
private final void setupMenu(Model model) {
|
|
if (!model.canManage() || model.isEveryoneRole() || model.getRole().e()) {
|
|
AppFragment.setActionBarOptionsMenu$default(this, R.menu.menu_empty, null, null, 4, null);
|
|
} else {
|
|
AppFragment.setActionBarOptionsMenu$default(this, R.menu.menu_edit_role, new WidgetServerSettingsEditRole$setupMenu$1(this, model), null, 4, null);
|
|
}
|
|
}
|
|
|
|
/* JADX WARNING: Removed duplicated region for block: B:76:0x02d4 */
|
|
/* JADX WARNING: Removed duplicated region for block: B:77:0x02d6 */
|
|
private final void setupPermissionsSettings(Model model) {
|
|
long j;
|
|
int i = 0;
|
|
for (CheckedSetting checkedSetting : n.listOf((Object[]) new CheckedSetting[]{getBinding().g, getBinding().h, getBinding().i, getBinding().j, getBinding().m, getBinding().r, getBinding().u, getBinding().v, getBinding().f1857y, getBinding().C, getBinding().f1858z, getBinding().w, getBinding().A, getBinding().B, getBinding().D, getBinding().E, getBinding().H, getBinding().I, getBinding().N, getBinding().O, getBinding().o, getBinding().n, getBinding().P, getBinding().Q, getBinding().R, getBinding().S, getBinding().f, getBinding().T, getBinding().V, getBinding().Z, getBinding().f1853b0, getBinding().Y, getBinding().W, getBinding().X, getBinding().f1852a0, getBinding().G, getBinding().U, getBinding().J, getBinding().f1856x})) {
|
|
m.checkNotNullExpressionValue(checkedSetting, "setting");
|
|
switch (checkedSetting.getId()) {
|
|
case R.id.role_settings_add_reactions /* 2131364823 */:
|
|
j = 64;
|
|
break;
|
|
case R.id.role_settings_administrator /* 2131364824 */:
|
|
j = 8;
|
|
break;
|
|
case R.id.role_settings_attach_files /* 2131364825 */:
|
|
j = Permission.ATTACH_FILES;
|
|
break;
|
|
case R.id.role_settings_ban_members /* 2131364826 */:
|
|
j = 4;
|
|
break;
|
|
case R.id.role_settings_change_nickname /* 2131364827 */:
|
|
j = Permission.CHANGE_NICKNAME;
|
|
break;
|
|
case R.id.role_settings_color_disabled_overlay /* 2131364828 */:
|
|
case R.id.role_settings_color_selector_container /* 2131364829 */:
|
|
case R.id.role_settings_current_color_display /* 2131364833 */:
|
|
case R.id.role_settings_edit_name_disabled_overlay /* 2131364834 */:
|
|
case R.id.role_settings_hoist_checkedsetting /* 2131364836 */:
|
|
case R.id.role_settings_icon_container /* 2131364837 */:
|
|
case R.id.role_settings_mentionable_checkedsetting /* 2131364849 */:
|
|
case R.id.role_settings_overview_scroll /* 2131364850 */:
|
|
case R.id.role_settings_role_icon /* 2131364855 */:
|
|
case R.id.role_settings_role_icon_divider /* 2131364856 */:
|
|
case R.id.role_settings_role_icon_header /* 2131364857 */:
|
|
default:
|
|
j = 0;
|
|
break;
|
|
case R.id.role_settings_create_instant_invite /* 2131364830 */:
|
|
j = 1;
|
|
break;
|
|
case R.id.role_settings_create_private_threads /* 2131364831 */:
|
|
j = Permission.CREATE_PRIVATE_THREADS;
|
|
break;
|
|
case R.id.role_settings_create_public_threads /* 2131364832 */:
|
|
j = Permission.CREATE_PUBLIC_THREADS;
|
|
break;
|
|
case R.id.role_settings_embed_links /* 2131364835 */:
|
|
j = Permission.EMBED_LINKS;
|
|
break;
|
|
case R.id.role_settings_kick_members /* 2131364838 */:
|
|
j = 2;
|
|
break;
|
|
case R.id.role_settings_manage_channels /* 2131364839 */:
|
|
j = 16;
|
|
break;
|
|
case R.id.role_settings_manage_emojis_and_stickers /* 2131364840 */:
|
|
j = Permission.MANAGE_EMOJIS_AND_STICKERS;
|
|
break;
|
|
case R.id.role_settings_manage_events /* 2131364841 */:
|
|
j = Permission.MANAGE_EVENTS;
|
|
break;
|
|
case R.id.role_settings_manage_messages /* 2131364842 */:
|
|
j = Permission.MANAGE_MESSAGES;
|
|
break;
|
|
case R.id.role_settings_manage_nicknames /* 2131364843 */:
|
|
j = Permission.MANAGE_NICKNAMES;
|
|
break;
|
|
case R.id.role_settings_manage_roles /* 2131364844 */:
|
|
j = Permission.MANAGE_ROLES;
|
|
break;
|
|
case R.id.role_settings_manage_server /* 2131364845 */:
|
|
j = 32;
|
|
break;
|
|
case R.id.role_settings_manage_threads /* 2131364846 */:
|
|
j = Permission.MANAGE_THREADS;
|
|
break;
|
|
case R.id.role_settings_manage_webhooks /* 2131364847 */:
|
|
j = Permission.MANAGE_WEBHOOKS;
|
|
break;
|
|
case R.id.role_settings_mention_everyone /* 2131364848 */:
|
|
j = Permission.MENTION_EVERYONE;
|
|
break;
|
|
case R.id.role_settings_priority_speaker /* 2131364851 */:
|
|
j = 256;
|
|
break;
|
|
case R.id.role_settings_read_message_history /* 2131364852 */:
|
|
j = Permission.READ_MESSAGE_HISTORY;
|
|
break;
|
|
case R.id.role_settings_read_messages /* 2131364853 */:
|
|
j = Permission.VIEW_CHANNEL;
|
|
break;
|
|
case R.id.role_settings_request_to_speak /* 2131364854 */:
|
|
j = Permission.REQUEST_TO_SPEAK;
|
|
break;
|
|
case R.id.role_settings_send_messages /* 2131364858 */:
|
|
j = Permission.SEND_MESSAGES;
|
|
break;
|
|
case R.id.role_settings_send_messages_in_threads /* 2131364859 */:
|
|
j = Permission.SEND_MESSAGES_IN_THREADS;
|
|
break;
|
|
case R.id.role_settings_send_tts_messages /* 2131364860 */:
|
|
j = Permission.SEND_TTS_MESSAGES;
|
|
break;
|
|
case R.id.role_settings_use_application_commands /* 2131364861 */:
|
|
j = Permission.USE_APPLICATION_COMMANDS;
|
|
break;
|
|
case R.id.role_settings_use_external_emojis /* 2131364862 */:
|
|
j = Permission.USE_EXTERNAL_EMOJIS;
|
|
break;
|
|
case R.id.role_settings_use_external_stickers /* 2131364863 */:
|
|
j = Permission.USE_EXTERNAL_STICKERS;
|
|
break;
|
|
case R.id.role_settings_view_audit_log /* 2131364864 */:
|
|
j = 128;
|
|
break;
|
|
case R.id.role_settings_view_guild_analytics /* 2131364865 */:
|
|
j = Permission.VIEW_GUILD_ANALYTICS;
|
|
break;
|
|
case R.id.role_settings_voice_connect /* 2131364866 */:
|
|
j = Permission.CONNECT;
|
|
break;
|
|
case R.id.role_settings_voice_deafen_members /* 2131364867 */:
|
|
j = Permission.DEAFEN_MEMBERS;
|
|
break;
|
|
case R.id.role_settings_voice_move_members /* 2131364868 */:
|
|
j = Permission.MOVE_MEMBERS;
|
|
break;
|
|
case R.id.role_settings_voice_mute_members /* 2131364869 */:
|
|
j = Permission.MUTE_MEMBERS;
|
|
break;
|
|
case R.id.role_settings_voice_speak /* 2131364870 */:
|
|
j = Permission.SPEAK;
|
|
break;
|
|
case R.id.role_settings_voice_use_voice_activity /* 2131364871 */:
|
|
j = Permission.USE_VAD;
|
|
break;
|
|
case R.id.role_settings_voice_video /* 2131364872 */:
|
|
j = 512;
|
|
break;
|
|
}
|
|
boolean can = PermissionUtils.can(j, Long.valueOf(model.getRole().h()));
|
|
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(R.string.help_singular_permission);
|
|
}
|
|
}
|
|
} else if (can2 && !(model.isSingular(j) && can)) {
|
|
enableSetting(checkedSetting, model, j);
|
|
} else if (!can2) {
|
|
checkedSetting.b(R.string.help_missing_permission);
|
|
} else {
|
|
checkedSetting.b(R.string.help_singular_permission);
|
|
}
|
|
checkedSetting.setVisibility(!((j != Permission.VIEW_GUILD_ANALYTICS && !model.isCommunityServer()) ^ true) ? 0 : 8);
|
|
}
|
|
checkedSetting.c(getLockMessage(model, false));
|
|
checkedSetting.setVisibility(!((j != Permission.VIEW_GUILD_ANALYTICS && !model.isCommunityServer()) ^ true) ? 0 : 8);
|
|
}
|
|
View view = getBinding().d;
|
|
m.checkNotNullExpressionValue(view, "binding.eventPermissionsDivider");
|
|
view.setVisibility(model.getHasEventsFeature() ? 0 : 8);
|
|
TextView textView = getBinding().e;
|
|
m.checkNotNullExpressionValue(textView, "binding.eventPermissionsTitle");
|
|
textView.setVisibility(model.getHasEventsFeature() ? 0 : 8);
|
|
CheckedSetting checkedSetting2 = getBinding().f1856x;
|
|
m.checkNotNullExpressionValue(checkedSetting2, "binding.roleSettingsManageEvents");
|
|
if (!model.getHasEventsFeature()) {
|
|
i = 8;
|
|
}
|
|
checkedSetting2.setVisibility(i);
|
|
}
|
|
|
|
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().g()));
|
|
if (!model.canManage() || model.isEveryoneRole()) {
|
|
View view = getBinding().q;
|
|
m.checkNotNullExpressionValue(view, "binding.roleSettingsEditNameDisabledOverlay");
|
|
view.setVisibility(0);
|
|
getBinding().q.setOnClickListener(new WidgetServerSettingsEditRole$setupRoleName$1(this, model));
|
|
return;
|
|
}
|
|
View view2 = getBinding().q;
|
|
m.checkNotNullExpressionValue(view2, "binding.roleSettingsEditNameDisabledOverlay");
|
|
view2.setVisibility(8);
|
|
getBinding().q.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().f1854c;
|
|
TextInputLayout textInputLayout = getBinding().b;
|
|
m.checkNotNullExpressionValue(textInputLayout, "binding.editRoleName");
|
|
statefulViews.setupTextWatcherWithSaveAction(this, floatingActionButton, textInputLayout);
|
|
FloatingActionButton floatingActionButton2 = getBinding().f1854c;
|
|
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();
|
|
}
|
|
}
|
|
}
|