Rabbit-R1/switch port/java/sources/androidx/compose/foundation/AbstractClickableNode.java
2024-05-21 17:08:36 -04:00

184 lines
14 KiB
Java

package androidx.compose.foundation;
import android.view.KeyEvent;
import androidx.compose.foundation.interaction.MutableInteractionSource;
import androidx.compose.foundation.interaction.PressInteraction;
import androidx.compose.ui.geometry.Offset;
import androidx.compose.ui.input.key.Key;
import androidx.compose.ui.input.key.KeyEvent_androidKt;
import androidx.compose.ui.input.key.KeyInputModifierNode;
import androidx.compose.ui.input.pointer.PointerEvent;
import androidx.compose.ui.input.pointer.PointerEventPass;
import androidx.compose.ui.node.DelegatingNode;
import androidx.compose.ui.node.PointerInputModifierNode;
import androidx.compose.ui.semantics.Role;
import androidx.core.app.NotificationCompat;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
import kotlin.Metadata;
import kotlin.Unit;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.Intrinsics;
import kotlinx.coroutines.BuildersKt__Builders_commonKt;
/* compiled from: Clickable.kt */
@Metadata(d1 = {"\u0000t\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000b\n\u0000\n\u0002\u0010\u000e\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\u0010\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0007\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0007\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\b2\u0018\u00002\u00020\u00012\u00020\u00022\u00020\u0003:\u00011B<\b\u0004\u0012\u0006\u0010\u0004\u001a\u00020\u0005\u0012\u0006\u0010\u0006\u001a\u00020\u0007\u0012\b\u0010\b\u001a\u0004\u0018\u00010\t\u0012\b\u0010\n\u001a\u0004\u0018\u00010\u000b\u0012\f\u0010\f\u001a\b\u0012\u0004\u0012\u00020\u000e0\\u0001\u0000¢\u0006\u0002\u0010\u000fJ\b\u0010\u001c\u001a\u00020\u000eH\u0004J\b\u0010\u001d\u001a\u00020\u000eH\u0016J\b\u0010\u001e\u001a\u00020\u000eH\u0016J\u001d\u0010\u001f\u001a\u00020\u00072\u0006\u0010 \u001a\u00020!H\u0016ø\u0001\u0001ø\u0001\u0000¢\u0006\u0004\b\"\u0010#J-\u0010$\u001a\u00020\u000e2\u0006\u0010%\u001a\u00020&2\u0006\u0010'\u001a\u00020(2\u0006\u0010)\u001a\u00020*H\u0016ø\u0001\u0001ø\u0001\u0000¢\u0006\u0004\b+\u0010,J\u001d\u0010-\u001a\u00020\u00072\u0006\u0010 \u001a\u00020!H\u0016ø\u0001\u0001ø\u0001\u0000¢\u0006\u0004\b.\u0010#JG\u0010/\u001a\u00020\u000e2\u0006\u0010\u0004\u001a\u00020\u00052\u0006\u0010\u0006\u001a\u00020\u00072\b\u0010\b\u001a\u0004\u0018\u00010\t2\n\b\u0002\u0010\n\u001a\u0004\u0018\u00010\u000b2\f\u0010\f\u001a\b\u0012\u0004\u0012\u00020\u000e0\rH\u0004ø\u0001\u0001ø\u0001\u0000¢\u0006\u0002\b0R\u0012\u0010\u0010\u001a\u00020\u0011X¦\u0004¢\u0006\u0006\u001a\u0004\b\u0012\u0010\u0013R\u0012\u0010\u0014\u001a\u00020\u0015X¦\u0004¢\u0006\u0006\u001a\u0004\b\u0016\u0010\u0017R\u000e\u0010\u0006\u001a\u00020\u0007X\u0082\u000e¢\u0006\u0002\n\u0000R\u0014\u0010\u0018\u001a\u00020\u0019X\u0084\u0004¢\u0006\b\n\u0000\u001a\u0004\b\u001a\u0010\u001bR\u000e\u0010\u0004\u001a\u00020\u0005X\u0082\u000e¢\u0006\u0002\n\u0000R\u0014\u0010\f\u001a\b\u0012\u0004\u0012\u00020\u000e0\rX\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010\b\u001a\u0004\u0018\u00010\tX\u0082\u000e¢\u0006\u0002\n\u0000R\u0019\u0010\n\u001a\u0004\u0018\u00010\u000bX\u0082\u000eø\u0001\u0000ø\u0001\u0001ø\u0001\u0002¢\u0006\u0002\n\u0000\u0082\u0001\u000223\u0082\u0002\u000f\n\u0002\b\u0019\n\u0005\\u001e0\u0001\n\u0002\b!¨\u00064"}, d2 = {"Landroidx/compose/foundation/AbstractClickableNode;", "Landroidx/compose/ui/node/DelegatingNode;", "Landroidx/compose/ui/node/PointerInputModifierNode;", "Landroidx/compose/ui/input/key/KeyInputModifierNode;", "interactionSource", "Landroidx/compose/foundation/interaction/MutableInteractionSource;", "enabled", "", "onClickLabel", "", "role", "Landroidx/compose/ui/semantics/Role;", "onClick", "Lkotlin/Function0;", "", "(Landroidx/compose/foundation/interaction/MutableInteractionSource;ZLjava/lang/String;Landroidx/compose/ui/semantics/Role;Lkotlin/jvm/functions/Function0;)V", "clickablePointerInputNode", "Landroidx/compose/foundation/AbstractClickablePointerInputNode;", "getClickablePointerInputNode", "()Landroidx/compose/foundation/AbstractClickablePointerInputNode;", "clickableSemanticsNode", "Landroidx/compose/foundation/ClickableSemanticsNode;", "getClickableSemanticsNode", "()Landroidx/compose/foundation/ClickableSemanticsNode;", "interactionData", "Landroidx/compose/foundation/AbstractClickableNode$InteractionData;", "getInteractionData", "()Landroidx/compose/foundation/AbstractClickableNode$InteractionData;", "disposeInteractionSource", "onCancelPointerInput", "onDetach", "onKeyEvent", NotificationCompat.CATEGORY_EVENT, "Landroidx/compose/ui/input/key/KeyEvent;", "onKeyEvent-ZmokQxo", "(Landroid/view/KeyEvent;)Z", "onPointerEvent", "pointerEvent", "Landroidx/compose/ui/input/pointer/PointerEvent;", "pass", "Landroidx/compose/ui/input/pointer/PointerEventPass;", "bounds", "Landroidx/compose/ui/unit/IntSize;", "onPointerEvent-H0pRuoY", "(Landroidx/compose/ui/input/pointer/PointerEvent;Landroidx/compose/ui/input/pointer/PointerEventPass;J)V", "onPreKeyEvent", "onPreKeyEvent-ZmokQxo", "updateCommon", "updateCommon-XHw0xAI", "InteractionData", "Landroidx/compose/foundation/ClickableNode;", "Landroidx/compose/foundation/CombinedClickableNode;", "foundation_release"}, k = 1, mv = {1, 8, 0}, xi = 48)
/* loaded from: classes.dex */
abstract class AbstractClickableNode extends DelegatingNode implements PointerInputModifierNode, KeyInputModifierNode {
private boolean enabled;
private final InteractionData interactionData;
private MutableInteractionSource interactionSource;
private Function0<Unit> onClick;
private String onClickLabel;
private Role role;
/* compiled from: Clickable.kt */
@Metadata(d1 = {"\u0000$\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0006\n\u0002\u0010%\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\b\b\u0007\u0018\u00002\u00020\u0001B\u0005¢\u0006\u0002\u0010\u0002R%\u0010\u0003\u001a\u00020\u0004X\u0086\u000eø\u0001\u0000ø\u0001\u0001ø\u0001\u0002¢\u0006\u0010\n\u0002\u0010\t\u001a\u0004\b\u0005\u0010\u0006\"\u0004\b\u0007\u0010\bR \u0010\n\u001a\u000e\u0012\u0004\u0012\u00020\f\u0012\u0004\u0012\u00020\r0\u000bø\u0001\u0000¢\u0006\b\n\u0000\u001a\u0004\b\u000e\u0010\u000fR\u001c\u0010\u0010\u001a\u0004\u0018\u00010\rX\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\u0011\u0010\u0012\"\u0004\b\u0013\u0010\u0014\u0082\u0002\u000f\n\u0002\b\u0019\n\u0005\\u001e0\u0001\n\u0002\b!¨\u0006\u0015"}, d2 = {"Landroidx/compose/foundation/AbstractClickableNode$InteractionData;", "", "()V", "centreOffset", "Landroidx/compose/ui/geometry/Offset;", "getCentreOffset-F1C5BW0", "()J", "setCentreOffset-k-4lQ0M", "(J)V", "J", "currentKeyPressInteractions", "", "Landroidx/compose/ui/input/key/Key;", "Landroidx/compose/foundation/interaction/PressInteraction$Press;", "getCurrentKeyPressInteractions", "()Ljava/util/Map;", "pressInteraction", "getPressInteraction", "()Landroidx/compose/foundation/interaction/PressInteraction$Press;", "setPressInteraction", "(Landroidx/compose/foundation/interaction/PressInteraction$Press;)V", "foundation_release"}, k = 1, mv = {1, 8, 0}, xi = 48)
/* loaded from: classes.dex */
public static final class InteractionData {
public static final int $stable = 8;
private PressInteraction.Press pressInteraction;
private final Map<Key, PressInteraction.Press> currentKeyPressInteractions = new LinkedHashMap();
private long centreOffset = Offset.INSTANCE.m2416getZeroF1C5BW0();
/* renamed from: getCentreOffset-F1C5BW0, reason: not valid java name and from getter */
public final long getCentreOffset() {
return this.centreOffset;
}
public final Map<Key, PressInteraction.Press> getCurrentKeyPressInteractions() {
return this.currentKeyPressInteractions;
}
public final PressInteraction.Press getPressInteraction() {
return this.pressInteraction;
}
/* renamed from: setCentreOffset-k-4lQ0M, reason: not valid java name */
public final void m156setCentreOffsetk4lQ0M(long j) {
this.centreOffset = j;
}
public final void setPressInteraction(PressInteraction.Press press) {
this.pressInteraction = press;
}
}
public /* synthetic */ AbstractClickableNode(MutableInteractionSource mutableInteractionSource, boolean z, String str, Role role, Function0 function0, DefaultConstructorMarker defaultConstructorMarker) {
this(mutableInteractionSource, z, str, role, function0);
}
public abstract AbstractClickablePointerInputNode getClickablePointerInputNode();
public abstract ClickableSemanticsNode getClickableSemanticsNode();
/* JADX INFO: Access modifiers changed from: protected */
public final InteractionData getInteractionData() {
return this.interactionData;
}
@Override // androidx.compose.ui.input.key.KeyInputModifierNode
/* renamed from: onPreKeyEvent-ZmokQxo, reason: not valid java name */
public boolean mo153onPreKeyEventZmokQxo(KeyEvent event) {
Intrinsics.checkNotNullParameter(event, "event");
return false;
}
private AbstractClickableNode(MutableInteractionSource interactionSource, boolean z, String str, Role role, Function0<Unit> onClick) {
Intrinsics.checkNotNullParameter(interactionSource, "interactionSource");
Intrinsics.checkNotNullParameter(onClick, "onClick");
this.interactionSource = interactionSource;
this.enabled = z;
this.onClickLabel = str;
this.role = role;
this.onClick = onClick;
this.interactionData = new InteractionData();
}
/* renamed from: updateCommon-XHw0xAI$default, reason: not valid java name */
public static /* synthetic */ void m150updateCommonXHw0xAI$default(AbstractClickableNode abstractClickableNode, MutableInteractionSource mutableInteractionSource, boolean z, String str, Role role, Function0 function0, int i, Object obj) {
if (obj != null) {
throw new UnsupportedOperationException("Super calls with default arguments not supported in this target, function: updateCommon-XHw0xAI");
}
if ((i & 8) != 0) {
role = null;
}
abstractClickableNode.m154updateCommonXHw0xAI(mutableInteractionSource, z, str, role, function0);
}
/* JADX INFO: Access modifiers changed from: protected */
/* renamed from: updateCommon-XHw0xAI, reason: not valid java name */
public final void m154updateCommonXHw0xAI(MutableInteractionSource interactionSource, boolean enabled, String onClickLabel, Role role, Function0<Unit> onClick) {
Intrinsics.checkNotNullParameter(interactionSource, "interactionSource");
Intrinsics.checkNotNullParameter(onClick, "onClick");
if (!Intrinsics.areEqual(this.interactionSource, interactionSource)) {
disposeInteractionSource();
this.interactionSource = interactionSource;
}
if (this.enabled != enabled) {
if (!enabled) {
disposeInteractionSource();
}
this.enabled = enabled;
}
this.onClickLabel = onClickLabel;
this.role = role;
this.onClick = onClick;
}
@Override // androidx.compose.ui.Modifier.Node
public void onDetach() {
disposeInteractionSource();
}
/* JADX INFO: Access modifiers changed from: protected */
public final void disposeInteractionSource() {
PressInteraction.Press pressInteraction = this.interactionData.getPressInteraction();
if (pressInteraction != null) {
this.interactionSource.tryEmit(new PressInteraction.Cancel(pressInteraction));
}
Iterator<T> it = this.interactionData.getCurrentKeyPressInteractions().values().iterator();
while (it.hasNext()) {
this.interactionSource.tryEmit(new PressInteraction.Cancel((PressInteraction.Press) it.next()));
}
this.interactionData.setPressInteraction(null);
this.interactionData.getCurrentKeyPressInteractions().clear();
}
@Override // androidx.compose.ui.node.PointerInputModifierNode
/* renamed from: onPointerEvent-H0pRuoY, reason: not valid java name */
public void mo152onPointerEventH0pRuoY(PointerEvent pointerEvent, PointerEventPass pass, long bounds) {
Intrinsics.checkNotNullParameter(pointerEvent, "pointerEvent");
Intrinsics.checkNotNullParameter(pass, "pass");
getClickablePointerInputNode().mo152onPointerEventH0pRuoY(pointerEvent, pass, bounds);
}
@Override // androidx.compose.ui.node.PointerInputModifierNode
public void onCancelPointerInput() {
getClickablePointerInputNode().onCancelPointerInput();
}
@Override // androidx.compose.ui.input.key.KeyInputModifierNode
/* renamed from: onKeyEvent-ZmokQxo, reason: not valid java name */
public boolean mo151onKeyEventZmokQxo(KeyEvent event) {
Intrinsics.checkNotNullParameter(event, "event");
if (this.enabled && Clickable_androidKt.m217isPressZmokQxo(event)) {
if (!this.interactionData.getCurrentKeyPressInteractions().containsKey(Key.m3314boximpl(KeyEvent_androidKt.m3625getKeyZmokQxo(event)))) {
PressInteraction.Press press = new PressInteraction.Press(this.interactionData.getCentreOffset(), null);
this.interactionData.getCurrentKeyPressInteractions().put(Key.m3314boximpl(KeyEvent_androidKt.m3625getKeyZmokQxo(event)), press);
BuildersKt__Builders_commonKt.launch$default(getCoroutineScope(), null, null, new AbstractClickableNode$onKeyEvent$1(this, press, null), 3, null);
return true;
}
} else if (this.enabled && Clickable_androidKt.m215isClickZmokQxo(event)) {
PressInteraction.Press remove = this.interactionData.getCurrentKeyPressInteractions().remove(Key.m3314boximpl(KeyEvent_androidKt.m3625getKeyZmokQxo(event)));
if (remove != null) {
BuildersKt__Builders_commonKt.launch$default(getCoroutineScope(), null, null, new AbstractClickableNode$onKeyEvent$2$1(this, remove, null), 3, null);
}
this.onClick.invoke();
return true;
}
return false;
}
}