374 lines
18 KiB
Java
374 lines
18 KiB
Java
package com.discord.widgets.settings;
|
|
|
|
import android.content.Context;
|
|
import android.content.res.ColorStateList;
|
|
import android.view.View;
|
|
import android.widget.LinearLayout;
|
|
import android.widget.TextView;
|
|
import androidx.core.content.ContextCompat;
|
|
import androidx.fragment.app.Fragment;
|
|
import androidx.fragment.app.FragmentManager;
|
|
import androidx.fragment.app.FragmentViewModelLazyKt;
|
|
import c.a.d.h0;
|
|
import c.a.d.j0;
|
|
import c.d.b.a.a;
|
|
import com.discord.app.AppFragment;
|
|
import com.discord.databinding.WidgetSettingsBinding;
|
|
import com.discord.models.presence.Presence;
|
|
import com.discord.models.user.MeUser;
|
|
import com.discord.stores.StoreStream;
|
|
import com.discord.utilities.accessibility.AccessibilityUtils;
|
|
import com.discord.utilities.presence.PresenceUtils;
|
|
import com.discord.utilities.rx.ObservableExtensionsKt;
|
|
import com.discord.utilities.user.UserUtils;
|
|
import com.discord.utilities.viewbinding.FragmentViewBindingDelegate;
|
|
import com.discord.utilities.viewbinding.FragmentViewBindingDelegateKt;
|
|
import com.discord.widgets.notice.WidgetNoticeDialog;
|
|
import com.discord.widgets.tabs.NavigationTab;
|
|
import com.discord.widgets.tabs.OnTabSelectedListener;
|
|
import com.discord.widgets.tabs.WidgetTabsHost;
|
|
import com.discord.widgets.user.Badge;
|
|
import com.discord.widgets.user.profile.UserProfileHeaderView;
|
|
import com.discord.widgets.user.profile.UserProfileHeaderViewModel;
|
|
import com.google.android.material.shape.MaterialShapeDrawable;
|
|
import com.google.android.material.shape.ShapeAppearanceModel;
|
|
import d0.t.n;
|
|
import d0.z.d.a0;
|
|
import d0.z.d.m;
|
|
import kotlin.Lazy;
|
|
import kotlin.jvm.functions.Function0;
|
|
import kotlin.jvm.functions.Function1;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
import kotlin.reflect.KProperty;
|
|
import rx.Observable;
|
|
import rx.functions.Func5;
|
|
/* compiled from: WidgetSettings.kt */
|
|
public final class WidgetSettings extends AppFragment implements OnTabSelectedListener {
|
|
public static final /* synthetic */ KProperty[] $$delegatedProperties = {a.W(WidgetSettings.class, "binding", "getBinding()Lcom/discord/databinding/WidgetSettingsBinding;", 0)};
|
|
private final FragmentViewBindingDelegate binding$delegate = FragmentViewBindingDelegateKt.viewBinding$default(this, WidgetSettings$binding$2.INSTANCE, null, 2, null);
|
|
private final Lazy viewModelUserProfileHeader$delegate;
|
|
|
|
/* compiled from: WidgetSettings.kt */
|
|
public static final class Model {
|
|
public static final Companion Companion = new Companion(null);
|
|
private final boolean isCustomProfilesEditingEnabled;
|
|
private final boolean isStaffOrAlpha;
|
|
private final MeUser meUser;
|
|
private final Presence presence;
|
|
private final int promoCount;
|
|
|
|
/* compiled from: WidgetSettings.kt */
|
|
public static final class Companion {
|
|
private Companion() {
|
|
}
|
|
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
/* JADX DEBUG: Type inference failed for r6v0. Raw type applied. Possible types: rx.Observable<R>, rx.Observable */
|
|
/* JADX WARNING: Unknown variable types count: 1 */
|
|
public final Observable<Model> get() {
|
|
StoreStream.Companion companion = StoreStream.Companion;
|
|
Observable<MeUser> observeMe = companion.getUsers().observeMe(true);
|
|
Observable<Boolean> experimentalAlpha = companion.getExperiments().getExperimentalAlpha();
|
|
Observable<Presence> observeLocalPresence = companion.getPresences().observeLocalPresence();
|
|
Observable F = companion.getOutboundPromotions().observeState().F(WidgetSettings$Model$Companion$get$1.INSTANCE);
|
|
Observable<Boolean> observeIsEnabled = CustomProfilesEditingFeatureFlag.Companion.getINSTANCE().observeIsEnabled();
|
|
WidgetSettings$Model$Companion$get$2 widgetSettings$Model$Companion$get$2 = WidgetSettings$Model$Companion$get$2.INSTANCE;
|
|
if (widgetSettings$Model$Companion$get$2 != null) {
|
|
widgetSettings$Model$Companion$get$2 = new WidgetSettings$sam$rx_functions_Func5$0(widgetSettings$Model$Companion$get$2);
|
|
}
|
|
Observable<Model> g = Observable.g(observeMe, experimentalAlpha, observeLocalPresence, F, observeIsEnabled, (Func5) widgetSettings$Model$Companion$get$2);
|
|
m.checkNotNullExpressionValue(g, "Observable\n .… ::Model\n )");
|
|
return g;
|
|
}
|
|
}
|
|
|
|
public Model(MeUser meUser, boolean z2, Presence presence, int i, boolean z3) {
|
|
m.checkNotNullParameter(meUser, "meUser");
|
|
m.checkNotNullParameter(presence, "presence");
|
|
this.meUser = meUser;
|
|
this.isStaffOrAlpha = z2;
|
|
this.presence = presence;
|
|
this.promoCount = i;
|
|
this.isCustomProfilesEditingEnabled = z3;
|
|
}
|
|
|
|
public static /* synthetic */ Model copy$default(Model model, MeUser meUser, boolean z2, Presence presence, int i, boolean z3, int i2, Object obj) {
|
|
if ((i2 & 1) != 0) {
|
|
meUser = model.meUser;
|
|
}
|
|
if ((i2 & 2) != 0) {
|
|
z2 = model.isStaffOrAlpha;
|
|
}
|
|
if ((i2 & 4) != 0) {
|
|
presence = model.presence;
|
|
}
|
|
if ((i2 & 8) != 0) {
|
|
i = model.promoCount;
|
|
}
|
|
if ((i2 & 16) != 0) {
|
|
z3 = model.isCustomProfilesEditingEnabled;
|
|
}
|
|
return model.copy(meUser, z2, presence, i, z3);
|
|
}
|
|
|
|
public final MeUser component1() {
|
|
return this.meUser;
|
|
}
|
|
|
|
public final boolean component2() {
|
|
return this.isStaffOrAlpha;
|
|
}
|
|
|
|
public final Presence component3() {
|
|
return this.presence;
|
|
}
|
|
|
|
public final int component4() {
|
|
return this.promoCount;
|
|
}
|
|
|
|
public final boolean component5() {
|
|
return this.isCustomProfilesEditingEnabled;
|
|
}
|
|
|
|
public final Model copy(MeUser meUser, boolean z2, Presence presence, int i, boolean z3) {
|
|
m.checkNotNullParameter(meUser, "meUser");
|
|
m.checkNotNullParameter(presence, "presence");
|
|
return new Model(meUser, z2, presence, i, z3);
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (this == obj) {
|
|
return true;
|
|
}
|
|
if (!(obj instanceof Model)) {
|
|
return false;
|
|
}
|
|
Model model = (Model) obj;
|
|
return m.areEqual(this.meUser, model.meUser) && this.isStaffOrAlpha == model.isStaffOrAlpha && m.areEqual(this.presence, model.presence) && this.promoCount == model.promoCount && this.isCustomProfilesEditingEnabled == model.isCustomProfilesEditingEnabled;
|
|
}
|
|
|
|
public final MeUser getMeUser() {
|
|
return this.meUser;
|
|
}
|
|
|
|
public final Presence getPresence() {
|
|
return this.presence;
|
|
}
|
|
|
|
public final int getPromoCount() {
|
|
return this.promoCount;
|
|
}
|
|
|
|
public int hashCode() {
|
|
MeUser meUser = this.meUser;
|
|
int i = 0;
|
|
int hashCode = (meUser != null ? meUser.hashCode() : 0) * 31;
|
|
boolean z2 = this.isStaffOrAlpha;
|
|
int i2 = 1;
|
|
if (z2) {
|
|
z2 = true;
|
|
}
|
|
int i3 = z2 ? 1 : 0;
|
|
int i4 = z2 ? 1 : 0;
|
|
int i5 = z2 ? 1 : 0;
|
|
int i6 = (hashCode + i3) * 31;
|
|
Presence presence = this.presence;
|
|
if (presence != null) {
|
|
i = presence.hashCode();
|
|
}
|
|
int i7 = (((i6 + i) * 31) + this.promoCount) * 31;
|
|
boolean z3 = this.isCustomProfilesEditingEnabled;
|
|
if (!z3) {
|
|
i2 = z3 ? 1 : 0;
|
|
}
|
|
return i7 + i2;
|
|
}
|
|
|
|
public final boolean isCustomProfilesEditingEnabled() {
|
|
return this.isCustomProfilesEditingEnabled;
|
|
}
|
|
|
|
public final boolean isStaffOrAlpha() {
|
|
return this.isStaffOrAlpha;
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuilder L = a.L("Model(meUser=");
|
|
L.append(this.meUser);
|
|
L.append(", isStaffOrAlpha=");
|
|
L.append(this.isStaffOrAlpha);
|
|
L.append(", presence=");
|
|
L.append(this.presence);
|
|
L.append(", promoCount=");
|
|
L.append(this.promoCount);
|
|
L.append(", isCustomProfilesEditingEnabled=");
|
|
return a.G(L, this.isCustomProfilesEditingEnabled, ")");
|
|
}
|
|
}
|
|
|
|
public WidgetSettings() {
|
|
super(2131559187);
|
|
WidgetSettings$viewModelUserProfileHeader$2 widgetSettings$viewModelUserProfileHeader$2 = WidgetSettings$viewModelUserProfileHeader$2.INSTANCE;
|
|
h0 h0Var = new h0(this);
|
|
this.viewModelUserProfileHeader$delegate = FragmentViewModelLazyKt.createViewModelLazy(this, a0.getOrCreateKotlinClass(UserProfileHeaderViewModel.class), new WidgetSettings$appViewModels$$inlined$viewModels$1(h0Var), new j0(widgetSettings$viewModelUserProfileHeader$2));
|
|
}
|
|
|
|
public static final /* synthetic */ void access$configureUI(WidgetSettings widgetSettings, Model model) {
|
|
widgetSettings.configureUI(model);
|
|
}
|
|
|
|
public static final /* synthetic */ void access$showLogoutDialog(WidgetSettings widgetSettings, Context context) {
|
|
widgetSettings.showLogoutDialog(context);
|
|
}
|
|
|
|
private final void configureToolbar() {
|
|
bindToolbar();
|
|
setActionBarTitle(2131894357);
|
|
setActionBarTitleLayoutMinimumTappableArea();
|
|
AppFragment.setActionBarOptionsMenu$default(this, 2131623962, new WidgetSettings$configureToolbar$1(this), null, 4, null);
|
|
}
|
|
|
|
private final void configureUI(Model model) {
|
|
MeUser meUser = model.getMeUser();
|
|
UserUtils userUtils = UserUtils.INSTANCE;
|
|
int i = 0;
|
|
boolean z2 = userUtils.isStaff(meUser);
|
|
boolean isVerified = meUser.isVerified();
|
|
boolean hasSubscription = userUtils.getHasSubscription(meUser);
|
|
WidgetSettingsBinding binding = getBinding();
|
|
View view = binding.n;
|
|
m.checkNotNullExpressionValue(view, "developerOptionsDivider");
|
|
view.setVisibility(z2 ? 0 : 8);
|
|
TextView textView = binding.o;
|
|
m.checkNotNullExpressionValue(textView, "developerOptionsHeader");
|
|
textView.setVisibility(z2 ? 0 : 8);
|
|
TextView textView2 = binding.m;
|
|
m.checkNotNullExpressionValue(textView2, "developerOptions");
|
|
textView2.setVisibility(z2 ? 0 : 8);
|
|
binding.m.setOnClickListener(WidgetSettings$configureUI$1$1.INSTANCE);
|
|
LinearLayout linearLayout = binding.u;
|
|
m.checkNotNullExpressionValue(linearLayout, "nitroSettingsContainer");
|
|
linearLayout.setVisibility(isVerified ? 0 : 8);
|
|
TextView textView3 = binding.A;
|
|
m.checkNotNullExpressionValue(textView3, "settingsNitro");
|
|
textView3.setText(getString(hasSubscription ? 2131886914 : 2131892328));
|
|
TextView textView4 = binding.q;
|
|
m.checkNotNullExpressionValue(textView4, "nitroBoosting");
|
|
textView4.setText(getString(hasSubscription ? 2131892101 : 2131892322));
|
|
Presence presence = model.getPresence();
|
|
binding.C.setPresence(presence);
|
|
TextView textView5 = binding.B;
|
|
m.checkNotNullExpressionValue(textView5, "settingsPresenceText");
|
|
textView5.setText(getString(PresenceUtils.INSTANCE.getStatusStringResForPresence(presence)));
|
|
if (model.getPromoCount() > 0) {
|
|
TextView textView6 = binding.r;
|
|
m.checkNotNullExpressionValue(textView6, "nitroGiftingBadge");
|
|
textView6.setText(String.valueOf(model.getPromoCount()));
|
|
TextView textView7 = binding.r;
|
|
m.checkNotNullExpressionValue(textView7, "nitroGiftingBadge");
|
|
MaterialShapeDrawable materialShapeDrawable = new MaterialShapeDrawable(new ShapeAppearanceModel.Builder().setAllCornerSizes(ShapeAppearanceModel.PILL).build());
|
|
materialShapeDrawable.setFillColor(ColorStateList.valueOf(ContextCompat.getColor(requireContext(), 2131100324)));
|
|
textView7.setBackground(materialShapeDrawable);
|
|
TextView textView8 = binding.r;
|
|
m.checkNotNullExpressionValue(textView8, "nitroGiftingBadge");
|
|
textView8.setVisibility(0);
|
|
} else {
|
|
TextView textView9 = binding.r;
|
|
m.checkNotNullExpressionValue(textView9, "nitroGiftingBadge");
|
|
textView9.setVisibility(8);
|
|
}
|
|
TextView textView10 = getBinding().f1920x;
|
|
m.checkNotNullExpressionValue(textView10, "binding.profile");
|
|
if (!model.isCustomProfilesEditingEnabled()) {
|
|
i = 8;
|
|
}
|
|
textView10.setVisibility(i);
|
|
}
|
|
|
|
private final WidgetSettingsBinding getBinding() {
|
|
return (WidgetSettingsBinding) this.binding$delegate.getValue((Fragment) this, $$delegatedProperties[0]);
|
|
}
|
|
|
|
private final UserProfileHeaderViewModel getViewModelUserProfileHeader() {
|
|
return (UserProfileHeaderViewModel) this.viewModelUserProfileHeader$delegate.getValue();
|
|
}
|
|
|
|
private final void showLogoutDialog(Context context) {
|
|
FragmentManager parentFragmentManager = getParentFragmentManager();
|
|
m.checkNotNullExpressionValue(parentFragmentManager, "parentFragmentManager");
|
|
WidgetNoticeDialog.Builder.setNegativeButton$default(new WidgetNoticeDialog.Builder(context).setTitle(2131890957).setMessage(2131894410).setDialogAttrTheme(2130969788).setPositiveButton(2131890957, WidgetSettings$showLogoutDialog$1.INSTANCE), 2131887178, (Function1) null, 2, (Object) null).show(parentFragmentManager);
|
|
}
|
|
|
|
@Override // com.discord.widgets.tabs.OnTabSelectedListener
|
|
public void onTabSelected() {
|
|
configureToolbar();
|
|
setActionBarTitleAccessibilityViewFocused();
|
|
}
|
|
|
|
@Override // com.discord.app.AppFragment
|
|
public void onViewBound(View view) {
|
|
m.checkNotNullParameter(view, "view");
|
|
super.onViewBound(view);
|
|
Fragment parentFragment = getParentFragment();
|
|
if (!(parentFragment instanceof WidgetTabsHost)) {
|
|
parentFragment = null;
|
|
}
|
|
WidgetTabsHost widgetTabsHost = (WidgetTabsHost) parentFragment;
|
|
if (widgetTabsHost != null) {
|
|
widgetTabsHost.registerTabSelectionListener(NavigationTab.SETTINGS, this);
|
|
}
|
|
WidgetSettingsBinding binding = getBinding();
|
|
binding.f1922z.setOnClickListener(new WidgetSettings$onViewBound$$inlined$with$lambda$1(this));
|
|
UserProfileHeaderView userProfileHeaderView = binding.H;
|
|
Badge.Companion companion = Badge.Companion;
|
|
FragmentManager parentFragmentManager = getParentFragmentManager();
|
|
m.checkNotNullExpressionValue(parentFragmentManager, "parentFragmentManager");
|
|
userProfileHeaderView.setOnBadgeClick(companion.onBadgeClick(parentFragmentManager, requireContext()));
|
|
TextView textView = binding.f;
|
|
m.checkNotNullExpressionValue(textView, "appInfoHeader");
|
|
String string = getString(2131886360);
|
|
textView.setText(string + " - 82.11 - Beta (82111)");
|
|
binding.f1921y.setOnClickListener(new WidgetSettings$onViewBound$$inlined$with$lambda$2(this));
|
|
binding.u.setOnClickListener(WidgetSettings$onViewBound$1$4.INSTANCE);
|
|
binding.q.setOnClickListener(WidgetSettings$onViewBound$1$5.INSTANCE);
|
|
binding.f1919s.setOnClickListener(WidgetSettings$onViewBound$1$6.INSTANCE);
|
|
binding.f1918c.setOnClickListener(WidgetSettings$onViewBound$1$7.INSTANCE);
|
|
binding.f1920x.setOnClickListener(WidgetSettings$onViewBound$1$8.INSTANCE);
|
|
binding.i.setOnClickListener(WidgetSettings$onViewBound$1$9.INSTANCE);
|
|
binding.w.setOnClickListener(WidgetSettings$onViewBound$1$10.INSTANCE);
|
|
binding.l.setOnClickListener(WidgetSettings$onViewBound$1$11.INSTANCE);
|
|
binding.h.setOnClickListener(WidgetSettings$onViewBound$1$12.INSTANCE);
|
|
binding.b.setOnClickListener(WidgetSettings$onViewBound$1$13.INSTANCE);
|
|
binding.j.setOnClickListener(WidgetSettings$onViewBound$1$14.INSTANCE);
|
|
binding.p.setOnClickListener(WidgetSettings$onViewBound$1$15.INSTANCE);
|
|
binding.e.setOnClickListener(WidgetSettings$onViewBound$1$16.INSTANCE);
|
|
binding.v.setOnClickListener(new WidgetSettings$onViewBound$$inlined$with$lambda$3(this));
|
|
binding.E.setOnClickListener(WidgetSettings$onViewBound$1$18.INSTANCE);
|
|
binding.I.setOnClickListener(WidgetSettings$onViewBound$1$19.INSTANCE);
|
|
binding.D.setOnClickListener(WidgetSettings$onViewBound$1$20.INSTANCE);
|
|
binding.F.setOnClickListener(new WidgetSettings$onViewBound$$inlined$with$lambda$4(binding, this));
|
|
binding.d.setOnClickListener(WidgetSettings$onViewBound$1$22.INSTANCE);
|
|
binding.k.setOnClickListener(WidgetSettings$onViewBound$1$23.INSTANCE);
|
|
for (TextView textView2 : n.listOf((Object[]) new TextView[]{binding.G, binding.t, binding.g, binding.o, binding.f})) {
|
|
AccessibilityUtils accessibilityUtils = AccessibilityUtils.INSTANCE;
|
|
m.checkNotNullExpressionValue(textView2, "header");
|
|
accessibilityUtils.setViewIsHeading(textView2);
|
|
}
|
|
}
|
|
|
|
@Override // com.discord.app.AppFragment
|
|
public void onViewBoundOrOnResume() {
|
|
super.onViewBoundOrOnResume();
|
|
UserProfileHeaderView.Companion companion = UserProfileHeaderView.Companion;
|
|
UserProfileHeaderView userProfileHeaderView = getBinding().H;
|
|
m.checkNotNullExpressionValue(userProfileHeaderView, "binding.userSettingsProfileHeaderView");
|
|
companion.bind(userProfileHeaderView, this, getViewModelUserProfileHeader().observeViewState());
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(ObservableExtensionsKt.computationLatest(Model.Companion.get()), this, null, 2, null), WidgetSettings.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetSettings$onViewBoundOrOnResume$1(this), 62, (Object) null);
|
|
}
|
|
}
|