discord-jadx/app/src/main/java/com/discord/widgets/settings/profile/WidgetEditProfileBannerShee...

299 lines
16 KiB
Java

package com.discord.widgets.settings.profile;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import androidx.annotation.ColorInt;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentViewModelLazyKt;
import c.a.a.e.c;
import c.a.d.h0;
import c.a.d.j0;
import c.a.k.b;
import c.d.b.a.a;
import c.k.a.a.e;
import com.discord.app.AppBottomSheet;
import com.discord.app.AppLog;
import com.discord.databinding.WidgetEditProfileBannerSheetBinding;
import com.discord.utilities.KotlinExtensionsKt;
import com.discord.utilities.analytics.AnalyticsTracker;
import com.discord.utilities.analytics.Traits;
import com.discord.utilities.color.ColorCompat;
import com.discord.utilities.color.ColorCompatKt;
import com.discord.utilities.font.FontUtils;
import com.discord.utilities.logging.Logger;
import com.discord.utilities.rx.ObservableExtensionsKt;
import com.discord.utilities.viewbinding.FragmentViewBindingDelegate;
import com.discord.utilities.viewbinding.FragmentViewBindingDelegateKt;
import com.discord.widgets.settings.profile.EditProfileBannerSheetViewModel;
import com.google.android.material.button.MaterialButton;
import com.google.android.material.textview.MaterialTextView;
import d0.z.d.a0;
import d0.z.d.m;
import java.util.Objects;
import kotlin.Lazy;
import kotlin.Unit;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.Ref$ObjectRef;
import kotlin.reflect.KProperty;
/* compiled from: WidgetEditProfileBannerSheet.kt */
public final class WidgetEditProfileBannerSheet extends AppBottomSheet {
public static final /* synthetic */ KProperty[] $$delegatedProperties = {a.V(WidgetEditProfileBannerSheet.class, "binding", "getBinding()Lcom/discord/databinding/WidgetEditProfileBannerSheetBinding;", 0)};
private static final String ARG_DEFAULT_BANNER_COLOR_HEX = "ARG_DEFAULT_BANNER_COLOR_HEX";
private static final String ARG_INITIAL_COLOR_PREVIEW_HEX = "ARG_INITIAL_COLOR_PREVIEW_HEX";
public static final Companion Companion = new Companion(null);
private static final String DIALOG_TAG_COLOR_PICKER = "DIALOG_TAG_COLOR_PICKER";
private final FragmentViewBindingDelegate binding$delegate = FragmentViewBindingDelegateKt.viewBinding$default(this, WidgetEditProfileBannerSheet$binding$2.INSTANCE, null, 2, null);
private int defaultBannerColor;
private Function0<Unit> onChangeProfileBannerImage = WidgetEditProfileBannerSheet$onChangeProfileBannerImage$1.INSTANCE;
private Function1<? super Integer, Unit> onColorSelected = WidgetEditProfileBannerSheet$onColorSelected$1.INSTANCE;
private Function0<Unit> onRemoveProfileBannerImage = WidgetEditProfileBannerSheet$onRemoveProfileBannerImage$1.INSTANCE;
private final Lazy viewModel$delegate;
/* compiled from: WidgetEditProfileBannerSheet.kt */
public static final class Companion {
private Companion() {
}
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
/* JADX DEBUG: Multi-variable search result rejected for r7v0, resolved type: com.discord.widgets.settings.profile.WidgetEditProfileBannerSheet$Companion */
/* JADX WARN: Multi-variable type inference failed */
public static /* synthetic */ void show$default(Companion companion, String str, String str2, FragmentManager fragmentManager, Function0 function0, Function0 function02, Function1 function1, int i, Object obj) {
if ((i & 8) != 0) {
function0 = WidgetEditProfileBannerSheet$Companion$show$1.INSTANCE;
}
if ((i & 16) != 0) {
function02 = WidgetEditProfileBannerSheet$Companion$show$2.INSTANCE;
}
if ((i & 32) != 0) {
function1 = WidgetEditProfileBannerSheet$Companion$show$3.INSTANCE;
}
companion.show(str, str2, fragmentManager, function0, function02, function1);
}
public final void show(String str, String str2, FragmentManager fragmentManager, Function0<Unit> function0, Function0<Unit> function02, Function1<? super Integer, Unit> function1) {
m.checkNotNullParameter(str, "defaultBannerColorHex");
m.checkNotNullParameter(fragmentManager, "fragmentManager");
m.checkNotNullParameter(function0, "onChangeProfileBannerImage");
m.checkNotNullParameter(function02, "onRemoveProfileBannerImage");
m.checkNotNullParameter(function1, "onColorSelected");
WidgetEditProfileBannerSheet widgetEditProfileBannerSheet = new WidgetEditProfileBannerSheet();
Bundle bundle = new Bundle();
bundle.putString("ARG_DEFAULT_BANNER_COLOR_HEX", str);
bundle.putString("ARG_INITIAL_COLOR_PREVIEW_HEX", str2);
widgetEditProfileBannerSheet.setArguments(bundle);
widgetEditProfileBannerSheet.setOnChangeProfileBannerImage(function0);
widgetEditProfileBannerSheet.setOnRemoveProfileBannerImage(function02);
widgetEditProfileBannerSheet.setOnColorSelected(function1);
widgetEditProfileBannerSheet.show(fragmentManager, WidgetEditProfileBannerSheet.class.getName());
}
}
public WidgetEditProfileBannerSheet() {
super(false, 1, null);
WidgetEditProfileBannerSheet$viewModel$2 widgetEditProfileBannerSheet$viewModel$2 = new WidgetEditProfileBannerSheet$viewModel$2(this);
h0 h0Var = new h0(this);
this.viewModel$delegate = FragmentViewModelLazyKt.createViewModelLazy(this, a0.getOrCreateKotlinClass(EditProfileBannerSheetViewModel.class), new WidgetEditProfileBannerSheet$appViewModels$$inlined$viewModels$1(h0Var), new j0(widgetEditProfileBannerSheet$viewModel$2));
}
public static final /* synthetic */ void access$configureUi(WidgetEditProfileBannerSheet widgetEditProfileBannerSheet, EditProfileBannerSheetViewModel.ViewState viewState) {
widgetEditProfileBannerSheet.configureUi(viewState);
}
public static final /* synthetic */ Bundle access$getArgumentsOrDefault$p(WidgetEditProfileBannerSheet widgetEditProfileBannerSheet) {
return widgetEditProfileBannerSheet.getArgumentsOrDefault();
}
public static final /* synthetic */ int access$getDefaultBannerColor$p(WidgetEditProfileBannerSheet widgetEditProfileBannerSheet) {
return widgetEditProfileBannerSheet.defaultBannerColor;
}
public static final /* synthetic */ EditProfileBannerSheetViewModel access$getViewModel$p(WidgetEditProfileBannerSheet widgetEditProfileBannerSheet) {
return widgetEditProfileBannerSheet.getViewModel();
}
public static final /* synthetic */ void access$launchColorPicker(WidgetEditProfileBannerSheet widgetEditProfileBannerSheet, int i) {
widgetEditProfileBannerSheet.launchColorPicker(i);
}
public static final /* synthetic */ void access$navigateToUpsellModal(WidgetEditProfileBannerSheet widgetEditProfileBannerSheet) {
widgetEditProfileBannerSheet.navigateToUpsellModal();
}
public static final /* synthetic */ void access$setDefaultBannerColor$p(WidgetEditProfileBannerSheet widgetEditProfileBannerSheet, int i) {
widgetEditProfileBannerSheet.defaultBannerColor = i;
}
/* JADX WARNING: Unknown variable types count: 1 */
private final void configureUi(EditProfileBannerSheetViewModel.ViewState viewState) {
CharSequence charSequence;
if (viewState instanceof EditProfileBannerSheetViewModel.ViewState) {
String bannerColorHex = viewState.getBannerColorHex();
Ref$ObjectRef ref$ObjectRef = new Ref$ObjectRef();
ref$ObjectRef.element = null;
if (bannerColorHex != null) {
try {
ref$ObjectRef.element = Integer.valueOf(Color.parseColor(bannerColorHex));
} catch (IllegalArgumentException e) {
Logger.e$default(AppLog.g, a.s("failed to parse banner color string: ", bannerColorHex), e, null, 4, null);
}
}
if (ref$ObjectRef.element != null) {
ImageView imageView = getBinding().e;
m.checkNotNullExpressionValue(imageView, "binding.bannerColorPreview");
ColorCompatKt.tintWithColor(imageView, ref$ObjectRef.element.intValue());
}
ImageView imageView2 = getBinding().e;
m.checkNotNullExpressionValue(imageView2, "binding.bannerColorPreview");
int i = 0;
imageView2.setVisibility(ref$ObjectRef.element == null ? 4 : 0);
getBinding().d.setOnClickListener(new WidgetEditProfileBannerSheet$configureUi$1(this, ref$ObjectRef));
boolean hasBannerImage = viewState.getHasBannerImage();
MaterialTextView materialTextView = getBinding().f1778c;
m.checkNotNullExpressionValue(materialTextView, "binding.bannerChangeImageItemTitle");
if (hasBannerImage) {
Resources resources = getResources();
m.checkNotNullExpressionValue(resources, "resources");
charSequence = b.h(resources, 2131894540, new Object[0], null, 4);
} else {
Resources resources2 = getResources();
m.checkNotNullExpressionValue(resources2, "resources");
charSequence = b.h(resources2, 2131894632, new Object[0], null, 4);
}
materialTextView.setText(charSequence);
MaterialButton materialButton = getBinding().g;
m.checkNotNullExpressionValue(materialButton, "binding.premiumUpsellButton");
materialButton.setVisibility(viewState.getShowPremiumUpsell() ? 0 : 8);
MaterialTextView materialTextView2 = getBinding().f;
m.checkNotNullExpressionValue(materialTextView2, "binding.bannerRemoveImageItem");
if (!hasBannerImage) {
i = 8;
}
materialTextView2.setVisibility(i);
getBinding().b.setOnClickListener(new WidgetEditProfileBannerSheet$configureUi$2(this, viewState));
}
KotlinExtensionsKt.getExhaustive(Unit.a);
}
private final WidgetEditProfileBannerSheetBinding getBinding() {
return (WidgetEditProfileBannerSheetBinding) this.binding$delegate.getValue((Fragment) this, $$delegatedProperties[0]);
}
private final EditProfileBannerSheetViewModel getViewModel() {
return (EditProfileBannerSheetViewModel) this.viewModel$delegate.getValue();
}
private final void launchColorPicker(@ColorInt int i) {
e.k kVar = new e.k();
kVar.h = i;
kVar.f1460s = ColorCompat.getThemedColor(getContext(), 2130968904);
kVar.i = false;
kVar.j = false;
kVar.f = 0;
kVar.a = 2131894529;
kVar.r = ColorCompat.getThemedColor(getContext(), 2130968932);
FontUtils fontUtils = FontUtils.INSTANCE;
kVar.f1461x = fontUtils.getThemedFontResId(getContext(), 2130969320);
kVar.l = true;
kVar.e = 2131887424;
kVar.p = ColorCompat.getThemedColor(getContext(), 2130968994);
kVar.d = 2131893310;
kVar.w = ColorCompat.getColor(getContext(), 2131100428);
kVar.f1462y = fontUtils.getThemedFontResId(getContext(), 2130969326);
kVar.t = ColorCompat.getThemedColor(getContext(), 2130968988);
kVar.u = 2131231108;
kVar.f1463z = fontUtils.getThemedFontResId(getContext(), 2130969325);
e a = kVar.a();
a.j = new WidgetEditProfileBannerSheet$launchColorPicker$1(this);
AppBottomSheet.hideKeyboard$default(this, null, 1, null);
a.show(getParentFragmentManager(), "DIALOG_TAG_COLOR_PICKER");
}
private final void navigateToUpsellModal() {
c.b bVar = c.j;
FragmentManager parentFragmentManager = getParentFragmentManager();
m.checkNotNullExpressionValue(parentFragmentManager, "parentFragmentManager");
AnalyticsTracker.PremiumUpsellType premiumUpsellType = AnalyticsTracker.PremiumUpsellType.CustomProfileUpsellModal;
Resources resources = getResources();
m.checkNotNullExpressionValue(resources, "resources");
String obj = b.h(resources, 2131892389, new Object[0], null, 4).toString();
Resources resources2 = getResources();
m.checkNotNullExpressionValue(resources2, "resources");
String obj2 = b.h(resources2, 2131892387, new Object[0], null, 4).toString();
Objects.requireNonNull(bVar);
m.checkNotNullParameter(parentFragmentManager, "fragmentManager");
m.checkNotNullParameter(premiumUpsellType, "premiumUpsellType");
c cVar = new c();
Bundle bundle = new Bundle();
bundle.putInt("extra_image_drawable_res", 2131232253);
bundle.putString("extra_header_text", obj);
bundle.putString("extra_body_text", obj2);
bundle.putString("extra_section_name", "Profile Customization");
cVar.setArguments(bundle);
cVar.show(parentFragmentManager, c.class.getName());
AnalyticsTracker.premiumUpsellViewed$default(AnalyticsTracker.INSTANCE, premiumUpsellType, new Traits.Location("User Settings", "Profile Customization", "Edit Profile Banner", null, null, 24, null), null, 4, null);
}
@Override // com.discord.app.AppBottomSheet
public int getContentViewResId() {
return 2131559011;
}
public final Function0<Unit> getOnChangeProfileBannerImage() {
return this.onChangeProfileBannerImage;
}
/* JADX DEBUG: Type inference failed for r0v0. Raw type applied. Possible types: kotlin.jvm.functions.Function1<? super java.lang.Integer, kotlin.Unit>, kotlin.jvm.functions.Function1<java.lang.Integer, kotlin.Unit> */
public final Function1<Integer, Unit> getOnColorSelected() {
return this.onColorSelected;
}
public final Function0<Unit> getOnRemoveProfileBannerImage() {
return this.onRemoveProfileBannerImage;
}
@Override // com.discord.app.AppBottomSheet, androidx.fragment.app.Fragment
public void onPause() {
super.onPause();
dismiss();
}
@Override // com.discord.app.AppBottomSheet, androidx.fragment.app.Fragment
public void onResume() {
super.onResume();
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.bindToComponentLifecycle(getViewModel().observeViewState(), this), WidgetEditProfileBannerSheet.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetEditProfileBannerSheet$onResume$1(this), 62, (Object) null);
}
@Override // com.discord.app.AppBottomSheet, androidx.fragment.app.Fragment
public void onViewCreated(View view, Bundle bundle) {
m.checkNotNullParameter(view, "view");
super.onViewCreated(view, bundle);
getBinding().g.setOnClickListener(new WidgetEditProfileBannerSheet$onViewCreated$1(this));
getBinding().f.setOnClickListener(new WidgetEditProfileBannerSheet$onViewCreated$2(this));
}
public final void setOnChangeProfileBannerImage(Function0<Unit> function0) {
m.checkNotNullParameter(function0, "<set-?>");
this.onChangeProfileBannerImage = function0;
}
public final void setOnColorSelected(Function1<? super Integer, Unit> function1) {
m.checkNotNullParameter(function1, "<set-?>");
this.onColorSelected = function1;
}
public final void setOnRemoveProfileBannerImage(Function0<Unit> function0) {
m.checkNotNullParameter(function0, "<set-?>");
this.onRemoveProfileBannerImage = function0;
}
}