package com.discord.utilities.uri; import android.content.ActivityNotFoundException; import android.content.Context; import android.content.Intent; import android.net.Uri; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.LinearLayout; import android.widget.TextView; import androidx.appcompat.app.AlertDialog; import androidx.browser.customtabs.CustomTabColorSchemeParams; import androidx.browser.customtabs.CustomTabsIntent; import c.a.a.f.a; import com.discord.app.AppTransitionActivity; import com.discord.databinding.LayoutUnhandledUriBinding; import com.discord.stores.StoreNotices; import com.discord.stores.StoreStream; import com.discord.utilities.analytics.AnalyticsTracker; import com.discord.utilities.color.ColorCompat; import com.discord.widgets.chat.pins.WidgetChannelPinnedMessages; import com.discord.widgets.home.WidgetHome; import com.discord.widgets.media.WidgetMedia; import com.discord.widgets.search.WidgetSearch; import com.discord.widgets.stage.discovery.WidgetDiscovery; import com.discord.widgets.user.WidgetUserMentions; import com.google.android.material.button.MaterialButton; import d0.e0.c; import d0.t.n; import d0.z.d.a0; import d0.z.d.m; import java.util.Objects; import kotlin.Unit; import kotlin.jvm.functions.Function0; /* compiled from: UriHandler.kt */ public final class UriHandler { private static final String APP_PACKAGE = "com.discord"; public static final UriHandler INSTANCE = new UriHandler(); private static final String URL_PLAY_STORE_ALT = "https://play.google.com/store/apps/details"; private static final String URL_PLAY_STORE_DIRECT = "market://details"; private UriHandler() { } public static final /* synthetic */ void access$openUrlExternally(UriHandler uriHandler, Context context, Uri uri, String str, Function0 function0) { uriHandler.openUrlExternally(context, uri, str, function0); } public static final void directToPlayStore(Context context) { directToPlayStore$default(context, null, null, 6, null); } public static final void directToPlayStore(Context context, String str) { directToPlayStore$default(context, str, null, 4, null); } public static final void directToPlayStore(Context context, String str, String str2) { m.checkNotNullParameter(context, "context"); m.checkNotNullParameter(str, "packageName"); m.checkNotNullParameter(str2, "source"); UriHandler$directToPlayStore$1 uriHandler$directToPlayStore$1 = new UriHandler$directToPlayStore$1(str, str2); INSTANCE.handle(context, uriHandler$directToPlayStore$1.invoke("market://details"), new UriHandler$directToPlayStore$2(context, uriHandler$directToPlayStore$1)); } public static /* synthetic */ void directToPlayStore$default(Context context, String str, String str2, int i, Object obj) { if ((i & 2) != 0) { str = "com.discord"; } if ((i & 4) != 0) { str2 = "discord"; } directToPlayStore(context, str, str2); } /* JADX DEBUG: Multi-variable search result rejected for r0v0, resolved type: com.discord.utilities.uri.UriHandler */ /* JADX WARN: Multi-variable type inference failed */ public static /* synthetic */ void handle$default(UriHandler uriHandler, Context context, String str, Function0 function0, int i, Object obj) { if ((i & 4) != 0) { function0 = null; } uriHandler.handle(context, str, function0); } public static final void handleOrUntrusted(Context context, String str, String str2) { m.checkNotNullParameter(context, "context"); m.checkNotNullParameter(str, "url"); StoreStream.Companion companion = StoreStream.Companion; if (companion.getMaskedLinks().isTrustedDomain(str, str2)) { handle$default(INSTANCE, context, str, null, 4, null); return; } Objects.requireNonNull(a.j); companion.getNotices().requestToShow(new StoreNotices.Notice("WIDGET_SPOOPY_LINKS_DIALOG", null, 0, 0, false, n.listOf((Object[]) new c[]{a0.getOrCreateKotlinClass(WidgetHome.class), a0.getOrCreateKotlinClass(WidgetUserMentions.class), a0.getOrCreateKotlinClass(WidgetSearch.class), a0.getOrCreateKotlinClass(WidgetDiscovery.class), a0.getOrCreateKotlinClass(WidgetChannelPinnedMessages.class), a0.getOrCreateKotlinClass(WidgetMedia.class)}), 0, false, 0, new UriHandler$handleOrUntrusted$notice$1(str), 134, null)); } public static /* synthetic */ void handleOrUntrusted$default(Context context, String str, String str2, int i, Object obj) { if ((i & 4) != 0) { str2 = null; } handleOrUntrusted(context, str, str2); } private final void openUrlExternally(Context context, Uri uri, String str, Function0 function0) { try { context.startActivity(new Intent("android.intent.action.VIEW", uri)); } catch (ActivityNotFoundException unused) { if ((function0 == null || function0.mo1invoke() == null) && str != null) { INSTANCE.showUnhandledUrlDialog(context, str); } } } /* JADX DEBUG: Multi-variable search result rejected for r1v0, resolved type: com.discord.utilities.uri.UriHandler */ /* JADX WARN: Multi-variable type inference failed */ public static /* synthetic */ void openUrlExternally$default(UriHandler uriHandler, Context context, Uri uri, String str, Function0 function0, int i, Object obj) { if ((i & 4) != 0) { str = null; } if ((i & 8) != 0) { function0 = null; } uriHandler.openUrlExternally(context, uri, str, function0); } private final void showUnhandledUrlDialog(Context context, String str) { AnalyticsTracker.INSTANCE.unhandledUrl(str); View inflate = LayoutInflater.from(context).inflate(2131558547, (ViewGroup) null, false); int i = 2131365478; TextView textView = (TextView) inflate.findViewById(2131365478); if (textView != null) { i = 2131365479; MaterialButton materialButton = (MaterialButton) inflate.findViewById(2131365479); if (materialButton != null) { LinearLayout linearLayout = (LinearLayout) inflate; LayoutUnhandledUriBinding layoutUnhandledUriBinding = new LayoutUnhandledUriBinding(linearLayout, textView, materialButton); m.checkNotNullExpressionValue(layoutUnhandledUriBinding, "LayoutUnhandledUriBindin…utInflater.from(context))"); AlertDialog create = new AlertDialog.Builder(context).setView(linearLayout).create(); m.checkNotNullExpressionValue(textView, "binding.unhandledUriDisplay"); textView.setText(str); textView.setOnClickListener(new UriHandler$showUnhandledUrlDialog$$inlined$apply$lambda$1(layoutUnhandledUriBinding, str)); materialButton.setOnClickListener(new UriHandler$showUnhandledUrlDialog$1$2(create)); create.show(); return; } } throw new NullPointerException("Missing required view with ID: ".concat(inflate.getResources().getResourceName(i))); } public final void handle(Context context, String str, Function0 function0) { Uri uri; m.checkNotNullParameter(context, "context"); if (str != null) { try { uri = Uri.parse(str); } catch (Exception unused) { uri = null; } if (uri == null) { return; } if (StoreStream.Companion.getUserSettings().getIsChromeCustomTabsEnabled()) { AppTransitionActivity.i = true; int themedColor = ColorCompat.getThemedColor(context, 2130968957); UriHandler$handle$1 uriHandler$handle$1 = new UriHandler$handle$1(context, uri, str, function0); m.checkNotNullParameter(context, "context"); m.checkNotNullParameter(uri, "uri"); m.checkNotNullParameter(uriHandler$handle$1, "onFailure"); if (c.a.h.a.a(context) != null) { CustomTabColorSchemeParams build = new CustomTabColorSchemeParams.Builder().setNavigationBarColor(themedColor).setToolbarColor(themedColor).setSecondaryToolbarColor(themedColor).build(); m.checkNotNullExpressionValue(build, "CustomTabColorSchemePara…lor)\n .build()"); CustomTabsIntent build2 = new CustomTabsIntent.Builder().setDefaultColorSchemeParams(build).setShowTitle(false).setStartAnimations(context, 2130771990, 2130771991).setExitAnimations(context, 2130771988, 2130771989).build(); m.checkNotNullExpressionValue(build2, "CustomTabsIntent.Builder…sId)\n .build()"); try { Intent intent = build2.intent; m.checkNotNullExpressionValue(intent, "customTabsIntent.intent"); intent.setData(uri); build2.launchUrl(context, uri); } catch (ActivityNotFoundException unused2) { uriHandler$handle$1.mo1invoke(); } } else { uriHandler$handle$1.mo1invoke(); } } else { openUrlExternally(context, uri, str, function0); } } } }