Rabbit-R1/android (non root)/java/sources/androidx/navigation/NavDeepLinkBuilder.java
2024-05-21 17:08:36 -04:00

324 lines
18 KiB
Java

package androidx.navigation;
import android.app.Activity;
import android.app.PendingIntent;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Parcelable;
import androidx.core.app.TaskStackBuilder;
import androidx.exifinterface.media.ExifInterface;
import androidx.navigation.Navigator;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import kotlin.Metadata;
import kotlin.collections.ArrayDeque;
import kotlin.collections.CollectionsKt;
import kotlin.jvm.internal.Intrinsics;
/* compiled from: NavDeepLinkBuilder.kt */
@Metadata(d1 = {"\u0000r\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010!\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\b\n\u0002\b\u0002\n\u0002\u0010\u000e\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\t\u0018\u00002\u00020\u0001:\u0002,-B\u000f\b\u0010\u0012\u0006\u0010\u0002\u001a\u00020\u0003¢\u0006\u0002\u0010\u0004B\r\u0012\u0006\u0010\u0005\u001a\u00020\u0006¢\u0006\u0002\u0010\u0007J\u001e\u0010\u0011\u001a\u00020\u00002\b\b\u0001\u0010\u0012\u001a\u00020\u00132\n\b\u0002\u0010\u0014\u001a\u0004\u0018\u00010\fH\u0007J\u001c\u0010\u0011\u001a\u00020\u00002\u0006\u0010\u0015\u001a\u00020\u00162\n\b\u0002\u0010\u0014\u001a\u0004\u0018\u00010\fH\u0007J\u0006\u0010\u0017\u001a\u00020\u0018J\u0006\u0010\u0019\u001a\u00020\u001aJ\b\u0010\u001b\u001a\u00020\u001cH\u0002J\u0014\u0010\u001d\u001a\u0004\u0018\u00010\u001e2\b\b\u0001\u0010\u0012\u001a\u00020\u0013H\u0002J\u0010\u0010\u001f\u001a\u00020\u00002\b\u0010\u0014\u001a\u0004\u0018\u00010\fJ\u000e\u0010 \u001a\u00020\u00002\u0006\u0010!\u001a\u00020\"J\u0018\u0010 \u001a\u00020\u00002\u0010\u0010#\u001a\f\u0012\b\b\u0001\u0012\u0004\u0018\u00010%0$J\u001e\u0010&\u001a\u00020\u00002\b\b\u0001\u0010\u0012\u001a\u00020\u00132\n\b\u0002\u0010\u0014\u001a\u0004\u0018\u00010\fH\u0007J\u001c\u0010&\u001a\u00020\u00002\u0006\u0010'\u001a\u00020\u00162\n\b\u0002\u0010\u0014\u001a\u0004\u0018\u00010\fH\u0007J\u000e\u0010(\u001a\u00020\u00002\u0006\u0010)\u001a\u00020\u000eJ\u0010\u0010(\u001a\u00020\u00002\b\b\u0001\u0010*\u001a\u00020\u0013J\b\u0010+\u001a\u00020\u001cH\u0002R\u000e\u0010\u0005\u001a\u00020\u0006X\u0082\u0004¢\u0006\u0002\n\u0000R\u0014\u0010\b\u001a\b\u0012\u0004\u0012\u00020\n0\tX\u0082\u0004¢\u0006\u0002\n\u0000R\u0010\u0010\u000b\u001a\u0004\u0018\u00010\fX\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010\r\u001a\u0004\u0018\u00010\u000eX\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u000f\u001a\u00020\u0010X\u0082\u0004¢\u0006\u0002\n\u0000¨\u0006."}, d2 = {"Landroidx/navigation/NavDeepLinkBuilder;", "", "navController", "Landroidx/navigation/NavController;", "(Landroidx/navigation/NavController;)V", "context", "Landroid/content/Context;", "(Landroid/content/Context;)V", "destinations", "", "Landroidx/navigation/NavDeepLinkBuilder$DeepLinkDestination;", "globalArgs", "Landroid/os/Bundle;", "graph", "Landroidx/navigation/NavGraph;", "intent", "Landroid/content/Intent;", "addDestination", "destId", "", "args", "route", "", "createPendingIntent", "Landroid/app/PendingIntent;", "createTaskStackBuilder", "Landroidx/core/app/TaskStackBuilder;", "fillInIntent", "", "findDestination", "Landroidx/navigation/NavDestination;", "setArguments", "setComponentName", "componentName", "Landroid/content/ComponentName;", "activityClass", "Ljava/lang/Class;", "Landroid/app/Activity;", "setDestination", "destRoute", "setGraph", "navGraph", "navGraphId", "verifyAllDestinations", "DeepLinkDestination", "PermissiveNavigatorProvider", "navigation-runtime_release"}, k = 1, mv = {1, 8, 0}, xi = 48)
/* loaded from: classes2.dex */
public final class NavDeepLinkBuilder {
private final Context context;
private final List<DeepLinkDestination> destinations;
private Bundle globalArgs;
private NavGraph graph;
private final Intent intent;
public final NavDeepLinkBuilder addDestination(int i) {
return addDestination$default(this, i, (Bundle) null, 2, (Object) null);
}
public final NavDeepLinkBuilder addDestination(String route) {
Intrinsics.checkNotNullParameter(route, "route");
return addDestination$default(this, route, (Bundle) null, 2, (Object) null);
}
public final NavDeepLinkBuilder setDestination(int i) {
return setDestination$default(this, i, (Bundle) null, 2, (Object) null);
}
public final NavDeepLinkBuilder setDestination(String destRoute) {
Intrinsics.checkNotNullParameter(destRoute, "destRoute");
return setDestination$default(this, destRoute, (Bundle) null, 2, (Object) null);
}
/* compiled from: NavDeepLinkBuilder.kt */
@Metadata(d1 = {"\u0000\u0018\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\n\u0002\u0010\b\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0006\b\u0002\u0018\u00002\u00020\u0001B\u0017\u0012\u0006\u0010\u0002\u001a\u00020\u0003\u0012\b\u0010\u0004\u001a\u0004\u0018\u00010\u0005¢\u0006\u0002\u0010\u0006R\u0013\u0010\u0004\u001a\u0004\u0018\u00010\u0005¢\u0006\b\n\u0000\u001a\u0004\b\u0007\u0010\bR\u0011\u0010\u0002\u001a\u00020\u0003¢\u0006\b\n\u0000\u001a\u0004\b\t\u0010\\u0006\u000b"}, d2 = {"Landroidx/navigation/NavDeepLinkBuilder$DeepLinkDestination;", "", "destinationId", "", "arguments", "Landroid/os/Bundle;", "(ILandroid/os/Bundle;)V", "getArguments", "()Landroid/os/Bundle;", "getDestinationId", "()I", "navigation-runtime_release"}, k = 1, mv = {1, 8, 0}, xi = 48)
/* loaded from: classes2.dex */
public static final class DeepLinkDestination {
private final Bundle arguments;
private final int destinationId;
public final Bundle getArguments() {
return this.arguments;
}
public final int getDestinationId() {
return this.destinationId;
}
public DeepLinkDestination(int i, Bundle bundle) {
this.destinationId = i;
this.arguments = bundle;
}
}
public NavDeepLinkBuilder(Context context) {
Intent launchIntentForPackage;
Intrinsics.checkNotNullParameter(context, "context");
this.context = context;
if (context instanceof Activity) {
launchIntentForPackage = new Intent(context, context.getClass());
} else {
launchIntentForPackage = context.getPackageManager().getLaunchIntentForPackage(context.getPackageName());
if (launchIntentForPackage == null) {
launchIntentForPackage = new Intent();
}
}
launchIntentForPackage.addFlags(268468224);
this.intent = launchIntentForPackage;
this.destinations = new ArrayList();
}
/* JADX WARN: 'this' call moved to the top of the method (can break code semantics) */
public NavDeepLinkBuilder(NavController navController) {
this(navController.getContext());
Intrinsics.checkNotNullParameter(navController, "navController");
this.graph = navController.getGraph();
}
public final NavDeepLinkBuilder setComponentName(Class<? extends Activity> activityClass) {
Intrinsics.checkNotNullParameter(activityClass, "activityClass");
return setComponentName(new ComponentName(this.context, activityClass));
}
public final NavDeepLinkBuilder setComponentName(ComponentName componentName) {
Intrinsics.checkNotNullParameter(componentName, "componentName");
this.intent.setComponent(componentName);
return this;
}
public final NavDeepLinkBuilder setGraph(int navGraphId) {
return setGraph(new NavInflater(this.context, new PermissiveNavigatorProvider()).inflate(navGraphId));
}
public final NavDeepLinkBuilder setGraph(NavGraph navGraph) {
Intrinsics.checkNotNullParameter(navGraph, "navGraph");
this.graph = navGraph;
verifyAllDestinations();
return this;
}
public static /* synthetic */ NavDeepLinkBuilder setDestination$default(NavDeepLinkBuilder navDeepLinkBuilder, int i, Bundle bundle, int i2, Object obj) {
if ((i2 & 2) != 0) {
bundle = null;
}
return navDeepLinkBuilder.setDestination(i, bundle);
}
public final NavDeepLinkBuilder setDestination(int destId, Bundle args) {
this.destinations.clear();
this.destinations.add(new DeepLinkDestination(destId, args));
if (this.graph != null) {
verifyAllDestinations();
}
return this;
}
public static /* synthetic */ NavDeepLinkBuilder setDestination$default(NavDeepLinkBuilder navDeepLinkBuilder, String str, Bundle bundle, int i, Object obj) {
if ((i & 2) != 0) {
bundle = null;
}
return navDeepLinkBuilder.setDestination(str, bundle);
}
public final NavDeepLinkBuilder setDestination(String destRoute, Bundle args) {
Intrinsics.checkNotNullParameter(destRoute, "destRoute");
this.destinations.clear();
this.destinations.add(new DeepLinkDestination(NavDestination.INSTANCE.createRoute(destRoute).hashCode(), args));
if (this.graph != null) {
verifyAllDestinations();
}
return this;
}
public static /* synthetic */ NavDeepLinkBuilder addDestination$default(NavDeepLinkBuilder navDeepLinkBuilder, int i, Bundle bundle, int i2, Object obj) {
if ((i2 & 2) != 0) {
bundle = null;
}
return navDeepLinkBuilder.addDestination(i, bundle);
}
public final NavDeepLinkBuilder addDestination(int destId, Bundle args) {
this.destinations.add(new DeepLinkDestination(destId, args));
if (this.graph != null) {
verifyAllDestinations();
}
return this;
}
public static /* synthetic */ NavDeepLinkBuilder addDestination$default(NavDeepLinkBuilder navDeepLinkBuilder, String str, Bundle bundle, int i, Object obj) {
if ((i & 2) != 0) {
bundle = null;
}
return navDeepLinkBuilder.addDestination(str, bundle);
}
public final NavDeepLinkBuilder addDestination(String route, Bundle args) {
Intrinsics.checkNotNullParameter(route, "route");
this.destinations.add(new DeepLinkDestination(NavDestination.INSTANCE.createRoute(route).hashCode(), args));
if (this.graph != null) {
verifyAllDestinations();
}
return this;
}
private final NavDestination findDestination(int destId) {
ArrayDeque arrayDeque = new ArrayDeque();
NavGraph navGraph = this.graph;
Intrinsics.checkNotNull(navGraph);
arrayDeque.add(navGraph);
while (!arrayDeque.isEmpty()) {
NavDestination navDestination = (NavDestination) arrayDeque.removeFirst();
if (navDestination.getId() == destId) {
return navDestination;
}
if (navDestination instanceof NavGraph) {
Iterator<NavDestination> it = ((NavGraph) navDestination).iterator();
while (it.hasNext()) {
arrayDeque.add(it.next());
}
}
}
return null;
}
private final void verifyAllDestinations() {
Iterator<DeepLinkDestination> it = this.destinations.iterator();
while (it.hasNext()) {
int destinationId = it.next().getDestinationId();
if (findDestination(destinationId) == null) {
throw new IllegalArgumentException("Navigation destination " + NavDestination.INSTANCE.getDisplayName(this.context, destinationId) + " cannot be found in the navigation graph " + this.graph);
}
}
}
private final void fillInIntent() {
ArrayList arrayList = new ArrayList();
ArrayList<? extends Parcelable> arrayList2 = new ArrayList<>();
NavDestination navDestination = null;
for (DeepLinkDestination deepLinkDestination : this.destinations) {
int destinationId = deepLinkDestination.getDestinationId();
Bundle arguments = deepLinkDestination.getArguments();
NavDestination findDestination = findDestination(destinationId);
if (findDestination == null) {
throw new IllegalArgumentException("Navigation destination " + NavDestination.INSTANCE.getDisplayName(this.context, destinationId) + " cannot be found in the navigation graph " + this.graph);
}
for (int i : findDestination.buildDeepLinkIds(navDestination)) {
arrayList.add(Integer.valueOf(i));
arrayList2.add(arguments);
}
navDestination = findDestination;
}
this.intent.putExtra(NavController.KEY_DEEP_LINK_IDS, CollectionsKt.toIntArray(arrayList));
this.intent.putParcelableArrayListExtra(NavController.KEY_DEEP_LINK_ARGS, arrayList2);
}
public final NavDeepLinkBuilder setArguments(Bundle args) {
this.globalArgs = args;
this.intent.putExtra(NavController.KEY_DEEP_LINK_EXTRAS, args);
return this;
}
public final TaskStackBuilder createTaskStackBuilder() {
if (this.graph == null) {
throw new IllegalStateException("You must call setGraph() before constructing the deep link".toString());
}
if (!(!this.destinations.isEmpty())) {
throw new IllegalStateException("You must call setDestination() or addDestination() before constructing the deep link".toString());
}
fillInIntent();
TaskStackBuilder addNextIntentWithParentStack = TaskStackBuilder.create(this.context).addNextIntentWithParentStack(new Intent(this.intent));
Intrinsics.checkNotNullExpressionValue(addNextIntentWithParentStack, "create(context)\n …rentStack(Intent(intent))");
int intentCount = addNextIntentWithParentStack.getIntentCount();
for (int i = 0; i < intentCount; i++) {
Intent editIntentAt = addNextIntentWithParentStack.editIntentAt(i);
if (editIntentAt != null) {
editIntentAt.putExtra(NavController.KEY_DEEP_LINK_INTENT, this.intent);
}
}
return addNextIntentWithParentStack;
}
public final PendingIntent createPendingIntent() {
int i;
Bundle bundle = this.globalArgs;
if (bundle != null) {
Iterator<String> it = bundle.keySet().iterator();
i = 0;
while (it.hasNext()) {
Object obj = bundle.get(it.next());
i = (i * 31) + (obj != null ? obj.hashCode() : 0);
}
} else {
i = 0;
}
for (DeepLinkDestination deepLinkDestination : this.destinations) {
i = (i * 31) + deepLinkDestination.getDestinationId();
Bundle arguments = deepLinkDestination.getArguments();
if (arguments != null) {
Iterator<String> it2 = arguments.keySet().iterator();
while (it2.hasNext()) {
Object obj2 = arguments.get(it2.next());
i = (i * 31) + (obj2 != null ? obj2.hashCode() : 0);
}
}
}
PendingIntent pendingIntent = createTaskStackBuilder().getPendingIntent(i, 201326592);
Intrinsics.checkNotNull(pendingIntent);
return pendingIntent;
}
/* compiled from: NavDeepLinkBuilder.kt */
@Metadata(d1 = {"\u0000 \n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\u000e\n\u0002\b\u0002\b\u0002\u0018\u00002\u00020\u0001B\u0005¢\u0006\u0002\u0010\u0002J'\u0010\u0006\u001a\u0002H\u0007\"\u0010\b\u0000\u0010\u0007*\n\u0012\u0006\b\u0001\u0012\u00020\u00050\u00042\u0006\u0010\b\u001a\u00020\tH\u0016¢\u0006\u0002\u0010\nR\u0014\u0010\u0003\u001a\b\u0012\u0004\u0012\u00020\u00050\u0004X\u0082\u0004¢\u0006\u0002\n\u0000¨\u0006\u000b"}, d2 = {"Landroidx/navigation/NavDeepLinkBuilder$PermissiveNavigatorProvider;", "Landroidx/navigation/NavigatorProvider;", "()V", "mDestNavigator", "Landroidx/navigation/Navigator;", "Landroidx/navigation/NavDestination;", "getNavigator", ExifInterface.GPS_DIRECTION_TRUE, "name", "", "(Ljava/lang/String;)Landroidx/navigation/Navigator;", "navigation-runtime_release"}, k = 1, mv = {1, 8, 0}, xi = 48)
/* loaded from: classes2.dex */
private static final class PermissiveNavigatorProvider extends NavigatorProvider {
private final Navigator<NavDestination> mDestNavigator = new Navigator<NavDestination>() { // from class: androidx.navigation.NavDeepLinkBuilder$PermissiveNavigatorProvider$mDestNavigator$1
@Override // androidx.navigation.Navigator
public NavDestination createDestination() {
return new NavDestination("permissive");
}
@Override // androidx.navigation.Navigator
public NavDestination navigate(NavDestination destination, Bundle args, NavOptions navOptions, Navigator.Extras navigatorExtras) {
Intrinsics.checkNotNullParameter(destination, "destination");
throw new IllegalStateException("navigate is not supported");
}
@Override // androidx.navigation.Navigator
public boolean popBackStack() {
throw new IllegalStateException("popBackStack is not supported");
}
};
public PermissiveNavigatorProvider() {
addNavigator(new NavGraphNavigator(this));
}
@Override // androidx.navigation.NavigatorProvider
public <T extends Navigator<? extends NavDestination>> T getNavigator(String name) {
Intrinsics.checkNotNullParameter(name, "name");
try {
return (T) super.getNavigator(name);
} catch (IllegalStateException unused) {
Navigator<NavDestination> navigator = this.mDestNavigator;
Intrinsics.checkNotNull(navigator, "null cannot be cast to non-null type T of androidx.navigation.NavDeepLinkBuilder.PermissiveNavigatorProvider.getNavigator");
return navigator;
}
}
}
}