package com.discord.widgets.changelog; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.text.format.DateFormat; import android.text.method.LinkMovementMethod; import android.view.View; import android.view.ViewGroup; import android.widget.ImageButton; import android.widget.LinearLayout; import android.widget.TextView; import android.widget.VideoView; import androidx.cardview.widget.CardView; import androidx.fragment.app.Fragment; import c.a.d.j; import c.d.b.a.a; import c.f.g.a.a.b; import c.f.g.a.a.d; import com.discord.R; import com.discord.app.AppFragment; import com.discord.databinding.WidgetChangeLogSpecialBinding; import com.discord.stores.StoreStream; import com.discord.utilities.analytics.AnalyticsTracker; import com.discord.utilities.dimen.DimenUtils; import com.discord.utilities.time.ClockFactory; import com.discord.utilities.time.TimeUtils; import com.discord.utilities.view.extensions.ViewExtensions; import com.discord.utilities.view.text.LinkifiedTextView; import com.discord.utilities.viewbinding.FragmentViewBindingDelegate; import com.discord.utilities.viewbinding.FragmentViewBindingDelegateKt; import com.facebook.drawee.controller.AbstractDraweeController; import com.facebook.drawee.view.SimpleDraweeView; import d0.g0.t; import d0.t.h0; import d0.z.d.m; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.HashMap; import java.util.Map; import java.util.Objects; import kotlin.jvm.internal.DefaultConstructorMarker; import kotlin.reflect.KProperty; import org.webrtc.MediaStreamTrack; /* compiled from: WidgetChangeLogSpecial.kt */ public final class WidgetChangeLogSpecial extends AppFragment { public static final /* synthetic */ KProperty[] $$delegatedProperties = {a.Y(WidgetChangeLogSpecial.class, "binding", "getBinding()Lcom/discord/databinding/WidgetChangeLogSpecialBinding;", 0)}; public static final Companion Companion = new Companion(null); private static final String INTENT_EXTRA_BODY = "INTENT_EXTRA_BODY"; private static final String INTENT_EXTRA_EXIT_STYLE = "INTENT_EXTRA_EXIT_STYLE"; private static final String INTENT_EXTRA_HIDE_VIDEO = "INTENT_EXTRA_HIDE_VIDEO"; private static final String INTENT_EXTRA_REVISION = "INTENT_EXTRA_REVISION"; private static final String INTENT_EXTRA_VERSION = "INTENT_EXTRA_VERSION"; private static final String INTENT_EXTRA_VIDEO = "INTENT_EXTRA_VIDEO"; private final FragmentViewBindingDelegate binding$delegate = FragmentViewBindingDelegateKt.viewBinding(this, WidgetChangeLogSpecial$binding$2.INSTANCE, new WidgetChangeLogSpecial$binding$3(this)); private int maxScrolledPercent; private long openedTimestamp; private final WidgetChangeLogSpecial$thumbnailControllerListener$1 thumbnailControllerListener = new WidgetChangeLogSpecial$thumbnailControllerListener$1(this); private AbstractDraweeController thumbnailDraweeController; /* compiled from: WidgetChangeLogSpecial.kt */ public static final class Companion { /* compiled from: WidgetChangeLogSpecial.kt */ public enum ExitStyle { BACK, CLOSE } private Companion() { } public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) { this(); } public static /* synthetic */ void launch$default(Companion companion, Context context, String str, String str2, String str3, String str4, ExitStyle exitStyle, boolean z2, int i, Object obj) { companion.launch(context, str, str2, str3, str4, (i & 32) != 0 ? ExitStyle.CLOSE : exitStyle, (i & 64) != 0 ? false : z2); } public final void launch(Context context, String str, String str2, String str3, String str4, ExitStyle exitStyle, boolean z2) { m.checkNotNullParameter(context, "context"); m.checkNotNullParameter(str, "version"); m.checkNotNullParameter(str2, "revision"); m.checkNotNullParameter(str3, MediaStreamTrack.VIDEO_TRACK_KIND); m.checkNotNullParameter(str4, "body"); m.checkNotNullParameter(exitStyle, "exitStyle"); Bundle bundle = new Bundle(); bundle.putSerializable(WidgetChangeLogSpecial.INTENT_EXTRA_EXIT_STYLE, exitStyle); bundle.putString(WidgetChangeLogSpecial.INTENT_EXTRA_VERSION, str); bundle.putString(WidgetChangeLogSpecial.INTENT_EXTRA_REVISION, str2); bundle.putString(WidgetChangeLogSpecial.INTENT_EXTRA_VIDEO, str3); bundle.putString(WidgetChangeLogSpecial.INTENT_EXTRA_BODY, str4); bundle.putBoolean(WidgetChangeLogSpecial.INTENT_EXTRA_HIDE_VIDEO, z2); j.d(context, WidgetChangeLogSpecial.class, new Intent().putExtras(bundle)); } } public WidgetChangeLogSpecial() { super(R.layout.widget_change_log_special); } public static final /* synthetic */ WidgetChangeLogSpecialBinding access$getBinding$p(WidgetChangeLogSpecial widgetChangeLogSpecial) { return widgetChangeLogSpecial.getBinding(); } public static final /* synthetic */ int access$getMaxScrolledPercent$p(WidgetChangeLogSpecial widgetChangeLogSpecial) { return widgetChangeLogSpecial.maxScrolledPercent; } public static final /* synthetic */ void access$hideVideoOverlay(WidgetChangeLogSpecial widgetChangeLogSpecial) { widgetChangeLogSpecial.hideVideoOverlay(); } public static final /* synthetic */ void access$onViewBindingDestroy(WidgetChangeLogSpecial widgetChangeLogSpecial, WidgetChangeLogSpecialBinding widgetChangeLogSpecialBinding) { widgetChangeLogSpecial.onViewBindingDestroy(widgetChangeLogSpecialBinding); } public static final /* synthetic */ void access$setMaxScrolledPercent$p(WidgetChangeLogSpecial widgetChangeLogSpecial, int i) { widgetChangeLogSpecial.maxScrolledPercent = i; } public static final /* synthetic */ void access$showVideoOverlay(WidgetChangeLogSpecial widgetChangeLogSpecial) { widgetChangeLogSpecial.showVideoOverlay(); } private final void configureMedia(String str) { boolean endsWith$default = t.endsWith$default(str, ".mp4", false, 2, null); VideoView videoView = getBinding().i; m.checkNotNullExpressionValue(videoView, "binding.changeLogVideo"); int i = 8; videoView.setVisibility(endsWith$default ? 0 : 8); SimpleDraweeView simpleDraweeView = getBinding().j; m.checkNotNullExpressionValue(simpleDraweeView, "binding.changeLogVideoOverlay"); if (endsWith$default) { i = 0; } simpleDraweeView.setVisibility(i); if (!endsWith$default) { SimpleDraweeView simpleDraweeView2 = getBinding().h; m.checkNotNullExpressionValue(simpleDraweeView2, "binding.changeLogThumbnail"); simpleDraweeView2.setVisibility(0); d a = b.a(); SimpleDraweeView simpleDraweeView3 = getBinding().h; m.checkNotNullExpressionValue(simpleDraweeView3, "binding.changeLogThumbnail"); a.n = simpleDraweeView3.getController(); d g = a.g(str); g.m = false; g.k = this.thumbnailControllerListener; this.thumbnailDraweeController = g.a(); SimpleDraweeView simpleDraweeView4 = getBinding().h; m.checkNotNullExpressionValue(simpleDraweeView4, "binding.changeLogThumbnail"); simpleDraweeView4.setController(this.thumbnailDraweeController); getBinding().h.requestLayout(); return; } getBinding().i.setVideoPath(str); getBinding().i.setOnCompletionListener(new WidgetChangeLogSpecial$configureMedia$1(this)); getBinding().i.setOnClickListener(new WidgetChangeLogSpecial$configureMedia$2(this)); getBinding().i.setOnPreparedListener(new WidgetChangeLogSpecial$configureMedia$3(this)); } private final WidgetChangeLogSpecialBinding getBinding() { return (WidgetChangeLogSpecialBinding) this.binding$delegate.getValue((Fragment) this, $$delegatedProperties[0]); } private final CharSequence getDateString(Context context) { String stringExtra = getMostRecentIntent().getStringExtra(INTENT_EXTRA_VERSION); if (stringExtra == null) { stringExtra = getString(R.string.change_log_md_date); } m.checkNotNullExpressionValue(stringExtra, "mostRecentIntent.getStri…tring.change_log_md_date)"); try { Date parse = new SimpleDateFormat(TimeUtils.UTCFormat.SHORT).parse(stringExtra); if (parse == null) { parse = new Date(); } return " " + DateFormat.getMediumDateFormat(context).format(parse) + " "; } catch (ParseException unused) { return stringExtra; } } private final void hideVideoOverlay() { ViewExtensions.fadeOut$default(getBinding().j, 200, WidgetChangeLogSpecial$hideVideoOverlay$1.INSTANCE, null, 4, null); } public static final void launch(Context context, String str, String str2, String str3, String str4, Companion.ExitStyle exitStyle, boolean z2) { Companion.launch(context, str, str2, str3, str4, exitStyle, z2); } private final void onViewBindingDestroy(WidgetChangeLogSpecialBinding widgetChangeLogSpecialBinding) { widgetChangeLogSpecialBinding.i.setOnPreparedListener(null); widgetChangeLogSpecialBinding.i.setOnCompletionListener(null); AbstractDraweeController abstractDraweeController = this.thumbnailDraweeController; if (abstractDraweeController != null) { abstractDraweeController.A(this.thumbnailControllerListener); } } private final void showVideoOverlay() { ViewExtensions.fadeIn$default(getBinding().j, 200, WidgetChangeLogSpecial$showVideoOverlay$1.INSTANCE, WidgetChangeLogSpecial$showVideoOverlay$2.INSTANCE, null, 8, null); } private final void track(String str, Map map, boolean z2) { String stringExtra = getMostRecentIntent().getStringExtra(INTENT_EXTRA_VERSION); if (stringExtra == null) { stringExtra = getString(R.string.change_log_md_date); } m.checkNotNullExpressionValue(stringExtra, "mostRecentIntent.getStri…tring.change_log_md_date)"); String stringExtra2 = getMostRecentIntent().getStringExtra(INTENT_EXTRA_REVISION); if (stringExtra2 == null) { stringExtra2 = getString(R.string.change_log_md_revision); } m.checkNotNullExpressionValue(stringExtra2, "mostRecentIntent.getStri…g.change_log_md_revision)"); HashMap hashMap = new HashMap(); if (z2) { hashMap.put("seconds_open", Long.valueOf((ClockFactory.get().currentTimeMillis() - this.openedTimestamp) / ((long) 1000))); hashMap.put("max_scrolled_percentage", Integer.valueOf(this.maxScrolledPercent)); } AnalyticsTracker.INSTANCE.changeLogEvent(str, stringExtra, stringExtra2, h0.plus(map, hashMap)); } /* JADX DEBUG: Multi-variable search result rejected for r0v0, resolved type: com.discord.widgets.changelog.WidgetChangeLogSpecial */ /* JADX WARN: Multi-variable type inference failed */ public static /* synthetic */ void track$default(WidgetChangeLogSpecial widgetChangeLogSpecial, String str, Map map, boolean z2, int i, Object obj) { if ((i & 2) != 0) { map = new HashMap(); } if ((i & 4) != 0) { z2 = true; } widgetChangeLogSpecial.track(str, map, z2); } @Override // androidx.fragment.app.Fragment public void onDestroy() { String stringExtra = getMostRecentIntent().getStringExtra(INTENT_EXTRA_VERSION); if (stringExtra == null) { stringExtra = getString(R.string.change_log_md_date); } m.checkNotNullExpressionValue(stringExtra, "mostRecentIntent.getStri…tring.change_log_md_date)"); StoreStream.Companion.getChangeLog().markSeen(stringExtra); track$default(this, "change_log_closed", null, false, 6, null); super.onDestroy(); } @Override // com.discord.app.AppFragment, androidx.fragment.app.Fragment public void onPause() { VideoView videoView = getBinding().i; m.checkNotNullExpressionValue(videoView, "binding.changeLogVideo"); if (videoView.isPlaying()) { getBinding().i.pause(); } super.onPause(); } @Override // com.discord.app.AppFragment public void onViewBound(View view) { m.checkNotNullParameter(view, "view"); super.onViewBound(view); this.openedTimestamp = ClockFactory.get().currentTimeMillis(); track$default(this, "change_log_opened", null, false, 2, null); setActionBarSubtitle(getDateString(requireContext())); String stringExtra = getMostRecentIntent().getStringExtra(INTENT_EXTRA_BODY); if (stringExtra == null) { stringExtra = getString(R.string.change_log_md_body); } m.checkNotNullExpressionValue(stringExtra, "mostRecentIntent.getStri…tring.change_log_md_body)"); if (getMostRecentIntent().getSerializableExtra(INTENT_EXTRA_EXIT_STYLE) == Companion.ExitStyle.BACK) { ImageButton imageButton = getBinding().e; m.checkNotNullExpressionValue(imageButton, "binding.changeLogSpecialClose"); imageButton.setVisibility(8); ImageButton imageButton2 = getBinding().f1718c; m.checkNotNullExpressionValue(imageButton2, "binding.changeLogSpecialBack"); imageButton2.setVisibility(0); } TextView textView = getBinding().f; m.checkNotNullExpressionValue(textView, "binding.changeLogSpecialDate"); textView.setText(getDateString(requireContext())); getBinding().b.setDraweeSpanStringBuilder(ChangeLogParser.INSTANCE.parse(requireContext(), stringExtra, true, new WidgetChangeLogSpecial$onViewBound$1(this))); String stringExtra2 = getMostRecentIntent().getStringExtra(INTENT_EXTRA_VIDEO); if (stringExtra2 == null) { stringExtra2 = getString(R.string.change_log_md_video); } m.checkNotNullExpressionValue(stringExtra2, "mostRecentIntent.getStri…ring.change_log_md_video)"); configureMedia(stringExtra2); getBinding().f1718c.setOnClickListener(new WidgetChangeLogSpecial$onViewBound$2(this)); getBinding().e.setOnClickListener(new WidgetChangeLogSpecial$onViewBound$3(this)); LinkifiedTextView linkifiedTextView = getBinding().b; m.checkNotNullExpressionValue(linkifiedTextView, "binding.changeLogBody"); c.a.k.b.n(linkifiedTextView, R.string.changelog_stickers_cta_body, new Object[0], null, 4); LinkifiedTextView linkifiedTextView2 = getBinding().b; m.checkNotNullExpressionValue(linkifiedTextView2, "binding.changeLogBody"); linkifiedTextView2.setMovementMethod(LinkMovementMethod.getInstance()); getBinding().d.setOnClickListener(new WidgetChangeLogSpecial$onViewBound$4(this)); if (getMostRecentIntent().getBooleanExtra(INTENT_EXTRA_HIDE_VIDEO, false)) { VideoView videoView = getBinding().i; m.checkNotNullExpressionValue(videoView, "binding.changeLogVideo"); videoView.setVisibility(8); CardView cardView = getBinding().k; m.checkNotNullExpressionValue(cardView, "binding.changelogSpecialHeaderContainer"); ViewGroup.LayoutParams layoutParams = cardView.getLayoutParams(); Objects.requireNonNull(layoutParams, "null cannot be cast to non-null type android.widget.LinearLayout.LayoutParams"); LinearLayout.LayoutParams layoutParams2 = (LinearLayout.LayoutParams) layoutParams; layoutParams2.setMargins(layoutParams2.leftMargin, layoutParams2.topMargin, layoutParams2.rightMargin, DimenUtils.dpToPixels(16)); } getBinding().g.setOnScrollChangeListener(new WidgetChangeLogSpecial$onViewBound$5(this)); } }