372 lines
18 KiB
Java
372 lines
18 KiB
Java
package com.discord.widgets.settings;
|
|
|
|
import android.content.Context;
|
|
import android.content.SharedPreferences;
|
|
import android.content.res.ColorStateList;
|
|
import android.view.View;
|
|
import android.widget.LinearLayout;
|
|
import android.widget.TextView;
|
|
import androidx.core.app.NotificationManagerCompat;
|
|
import androidx.core.content.ContextCompat;
|
|
import androidx.fragment.app.Fragment;
|
|
import androidx.fragment.app.FragmentManager;
|
|
import androidx.fragment.app.FragmentViewModelLazyKt;
|
|
import c.a.d.f0;
|
|
import c.a.d.h0;
|
|
import c.d.b.a.a;
|
|
import com.discord.R;
|
|
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.cache.SharedPreferencesProvider;
|
|
import com.discord.utilities.features.GrowthTeamFeatures;
|
|
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.settings.profile.WidgetSettingsUserProfile;
|
|
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.Func4;
|
|
/* compiled from: WidgetSettings.kt */
|
|
public final class WidgetSettings extends AppFragment implements OnTabSelectedListener {
|
|
public static final /* synthetic */ KProperty[] $$delegatedProperties = {a.a0(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 SharedPreferences sharedPreferences;
|
|
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 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 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<Integer> observeUnseenCount = companion.getOutboundPromotions().observeUnseenCount();
|
|
WidgetSettings$Model$Companion$get$1 widgetSettings$Model$Companion$get$1 = WidgetSettings$Model$Companion$get$1.INSTANCE;
|
|
if (widgetSettings$Model$Companion$get$1 != null) {
|
|
widgetSettings$Model$Companion$get$1 = new WidgetSettings$sam$rx_functions_Func4$0(widgetSettings$Model$Companion$get$1);
|
|
}
|
|
Observable<Model> h = Observable.h(observeMe, experimentalAlpha, observeLocalPresence, observeUnseenCount, (Func4) widgetSettings$Model$Companion$get$1);
|
|
m.checkNotNullExpressionValue(h, "Observable\n .… ::Model\n )");
|
|
return h;
|
|
}
|
|
}
|
|
|
|
public Model(MeUser meUser, boolean z2, Presence presence, int i) {
|
|
m.checkNotNullParameter(meUser, "meUser");
|
|
m.checkNotNullParameter(presence, "presence");
|
|
this.meUser = meUser;
|
|
this.isStaffOrAlpha = z2;
|
|
this.presence = presence;
|
|
this.promoCount = i;
|
|
}
|
|
|
|
public static /* synthetic */ Model copy$default(Model model, MeUser meUser, boolean z2, Presence presence, int i, 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;
|
|
}
|
|
return model.copy(meUser, z2, presence, i);
|
|
}
|
|
|
|
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 Model copy(MeUser meUser, boolean z2, Presence presence, int i) {
|
|
m.checkNotNullParameter(meUser, "meUser");
|
|
m.checkNotNullParameter(presence, "presence");
|
|
return new Model(meUser, z2, presence, i);
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
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;
|
|
if (z2) {
|
|
z2 = true;
|
|
}
|
|
int i2 = z2 ? 1 : 0;
|
|
int i3 = z2 ? 1 : 0;
|
|
int i4 = z2 ? 1 : 0;
|
|
int i5 = (hashCode + i2) * 31;
|
|
Presence presence = this.presence;
|
|
if (presence != null) {
|
|
i = presence.hashCode();
|
|
}
|
|
return ((i5 + i) * 31) + this.promoCount;
|
|
}
|
|
|
|
public final boolean isStaffOrAlpha() {
|
|
return this.isStaffOrAlpha;
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuilder P = a.P("Model(meUser=");
|
|
P.append(this.meUser);
|
|
P.append(", isStaffOrAlpha=");
|
|
P.append(this.isStaffOrAlpha);
|
|
P.append(", presence=");
|
|
P.append(this.presence);
|
|
P.append(", promoCount=");
|
|
return a.z(P, this.promoCount, ")");
|
|
}
|
|
}
|
|
|
|
public WidgetSettings() {
|
|
super(R.layout.widget_settings);
|
|
WidgetSettings$viewModelUserProfileHeader$2 widgetSettings$viewModelUserProfileHeader$2 = WidgetSettings$viewModelUserProfileHeader$2.INSTANCE;
|
|
f0 f0Var = new f0(this);
|
|
this.viewModelUserProfileHeader$delegate = FragmentViewModelLazyKt.createViewModelLazy(this, a0.getOrCreateKotlinClass(UserProfileHeaderViewModel.class), new WidgetSettings$appViewModels$$inlined$viewModels$1(f0Var), new h0(widgetSettings$viewModelUserProfileHeader$2));
|
|
this.sharedPreferences = SharedPreferencesProvider.INSTANCE.get();
|
|
}
|
|
|
|
public static final /* synthetic */ void access$configureUI(WidgetSettings widgetSettings, Model model) {
|
|
widgetSettings.configureUI(model);
|
|
}
|
|
|
|
public static final /* synthetic */ UserProfileHeaderViewModel access$getViewModelUserProfileHeader$p(WidgetSettings widgetSettings) {
|
|
return widgetSettings.getViewModelUserProfileHeader();
|
|
}
|
|
|
|
public static final /* synthetic */ void access$showLogoutDialog(WidgetSettings widgetSettings, Context context) {
|
|
widgetSettings.showLogoutDialog(context);
|
|
}
|
|
|
|
private final void configureToolbar() {
|
|
AppFragment.bindToolbar$default(this, null, 1, null);
|
|
setActionBarTitle(R.string.user_settings);
|
|
setActionBarTitleLayoutMinimumTappableArea();
|
|
AppFragment.setActionBarOptionsMenu$default(this, R.menu.menu_settings, 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.D;
|
|
m.checkNotNullExpressionValue(textView3, "settingsNitro");
|
|
textView3.setText(getString(hasSubscription ? R.string.billing_manage_subscription : R.string.premium_settings_subscribe_today));
|
|
TextView textView4 = binding.q;
|
|
m.checkNotNullExpressionValue(textView4, "nitroBoosting");
|
|
textView4.setText(getString(hasSubscription ? R.string.premium_guild_perks_modal_manage_your_subscriptions : R.string.premium_settings_premium_guild_subscriptions));
|
|
Presence presence = model.getPresence();
|
|
binding.F.setPresence(presence);
|
|
TextView textView5 = binding.E;
|
|
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(), R.color.status_red_500)));
|
|
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);
|
|
}
|
|
boolean z3 = this.sharedPreferences.getBoolean(WidgetSettingsUserProfile.USER_PROFILE_SETTINGS_VIEWED_CACHE_KEY, false);
|
|
TextView textView10 = getBinding().A;
|
|
m.checkNotNullExpressionValue(textView10, "binding.profileNewBadge");
|
|
if (!(!z3)) {
|
|
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(R.string.logout).setMessage(R.string.user_settings_confirm_logout).setDialogAttrTheme(R.attr.notice_theme_positive_red).setPositiveButton(R.string.logout, WidgetSettings$showLogoutDialog$1.INSTANCE), (int) R.string.cancel, (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.C.setOnClickListener(new WidgetSettings$onViewBound$$inlined$with$lambda$1(this));
|
|
UserProfileHeaderView userProfileHeaderView = binding.K;
|
|
Badge.Companion companion = Badge.Companion;
|
|
FragmentManager parentFragmentManager = getParentFragmentManager();
|
|
m.checkNotNullExpressionValue(parentFragmentManager, "parentFragmentManager");
|
|
userProfileHeaderView.setOnBadgeClick(companion.onBadgeClick(parentFragmentManager, requireContext()));
|
|
binding.K.setOnBannerPress(new WidgetSettings$onViewBound$$inlined$with$lambda$2(this));
|
|
TextView textView = binding.f;
|
|
m.checkNotNullExpressionValue(textView, "appInfoHeader");
|
|
String string = getString(R.string.app_information);
|
|
textView.setText(string + " - 92.5 - Alpha (92205)");
|
|
binding.B.setOnClickListener(new WidgetSettings$onViewBound$$inlined$with$lambda$3(this));
|
|
binding.u.setOnClickListener(WidgetSettings$onViewBound$1$5.INSTANCE);
|
|
binding.q.setOnClickListener(WidgetSettings$onViewBound$1$6.INSTANCE);
|
|
binding.f1997s.setOnClickListener(WidgetSettings$onViewBound$1$7.INSTANCE);
|
|
binding.f1996c.setOnClickListener(WidgetSettings$onViewBound$1$8.INSTANCE);
|
|
binding.f2000z.setOnClickListener(WidgetSettings$onViewBound$1$9.INSTANCE);
|
|
binding.i.setOnClickListener(WidgetSettings$onViewBound$1$10.INSTANCE);
|
|
binding.f1999y.setOnClickListener(WidgetSettings$onViewBound$1$11.INSTANCE);
|
|
binding.l.setOnClickListener(WidgetSettings$onViewBound$1$12.INSTANCE);
|
|
binding.h.setOnClickListener(WidgetSettings$onViewBound$1$13.INSTANCE);
|
|
binding.b.setOnClickListener(WidgetSettings$onViewBound$1$14.INSTANCE);
|
|
binding.j.setOnClickListener(WidgetSettings$onViewBound$1$15.INSTANCE);
|
|
binding.p.setOnClickListener(WidgetSettings$onViewBound$1$16.INSTANCE);
|
|
binding.e.setOnClickListener(WidgetSettings$onViewBound$1$17.INSTANCE);
|
|
binding.f1998x.setOnClickListener(new WidgetSettings$onViewBound$$inlined$with$lambda$4(this));
|
|
binding.H.setOnClickListener(WidgetSettings$onViewBound$1$19.INSTANCE);
|
|
binding.L.setOnClickListener(WidgetSettings$onViewBound$1$20.INSTANCE);
|
|
binding.G.setOnClickListener(WidgetSettings$onViewBound$1$21.INSTANCE);
|
|
binding.I.setOnClickListener(new WidgetSettings$onViewBound$$inlined$with$lambda$5(binding, this));
|
|
binding.d.setOnClickListener(WidgetSettings$onViewBound$1$23.INSTANCE);
|
|
binding.k.setOnClickListener(WidgetSettings$onViewBound$1$24.INSTANCE);
|
|
binding.w.setOnClickListener(WidgetSettings$onViewBound$1$25.INSTANCE);
|
|
for (TextView textView2 : n.listOf((Object[]) new TextView[]{binding.J, 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().K;
|
|
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);
|
|
LinearLayout linearLayout = getBinding().v;
|
|
m.checkNotNullExpressionValue(linearLayout, "binding.notificationUpsell");
|
|
int i = 0;
|
|
if (!(!NotificationManagerCompat.from(requireContext()).areNotificationsEnabled() && GrowthTeamFeatures.INSTANCE.isNotificationUpsellEnabled())) {
|
|
i = 8;
|
|
}
|
|
linearLayout.setVisibility(i);
|
|
}
|
|
}
|