Merge "Rename awaitFrameNanos to withFrameNanos" into androidx-master-dev
diff --git a/androidx-plugin/build.gradle b/androidx-plugin/build.gradle
index 2ea079f..37cece5 100644
--- a/androidx-plugin/build.gradle
+++ b/androidx-plugin/build.gradle
@@ -1,3 +1,5 @@
+import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
+
buildscript {
apply from: '../buildSrc/build_dependencies.gradle'
@@ -41,4 +43,15 @@
}
}
}
+ tasks.withType(KotlinCompile).configureEach {
+ kotlinOptions {
+ jvmTarget = "1.8"
+ freeCompilerArgs += [
+ "-Werror",
+ "-Xskip-runtime-version-check",
+ // Allow `@OptIn` and `@UseExperimental`
+ "-Xopt-in=kotlin.RequiresOptIn"
+ ]
+ }
+ }
}
diff --git a/camera/camera-view/src/main/java/androidx/camera/view/CameraView.java b/camera/camera-view/src/main/java/androidx/camera/view/CameraView.java
index 4059cc1..d91141b 100644
--- a/camera/camera-view/src/main/java/androidx/camera/view/CameraView.java
+++ b/camera/camera-view/src/main/java/androidx/camera/view/CameraView.java
@@ -60,6 +60,7 @@
import androidx.camera.core.impl.utils.futures.FutureCallback;
import androidx.camera.core.impl.utils.futures.Futures;
import androidx.lifecycle.LifecycleOwner;
+import androidx.lifecycle.LiveData;
import com.google.common.util.concurrent.ListenableFuture;
@@ -294,6 +295,21 @@
dpyMgr.unregisterDisplayListener(mDisplayListener);
}
+ /**
+ * Gets the {@link LiveData} of the underlying {@link PreviewView}'s
+ * {@link PreviewView.StreamState}.
+ *
+ * @return A {@link LiveData} containing the {@link PreviewView.StreamState}. Apps can either
+ * get current value by {@link LiveData#getValue()} or register a observer by
+ * {@link LiveData#observe}.
+ * @see PreviewView#getPreviewStreamState()
+ */
+ @NonNull
+ public LiveData<PreviewView.StreamState> getPreviewStreamState() {
+ return mPreviewView.getPreviewStreamState();
+ }
+
+ @NonNull
PreviewView getPreviewView() {
return mPreviewView;
}
diff --git a/camera/integration-tests/viewtestapp/build.gradle b/camera/integration-tests/viewtestapp/build.gradle
index 6d13fe4..fe3e510 100644
--- a/camera/integration-tests/viewtestapp/build.gradle
+++ b/camera/integration-tests/viewtestapp/build.gradle
@@ -20,6 +20,7 @@
plugins {
id("AndroidXPlugin")
id("com.android.application")
+ id("kotlin-android")
}
android {
@@ -56,7 +57,7 @@
implementation(GUAVA_ANDROID)
// Lifecycle and LiveData
- implementation("androidx.lifecycle:lifecycle-livedata:2.1.0")
+ implementation("androidx.lifecycle:lifecycle-livedata:2.2.0")
// Android Support Library
implementation("androidx.appcompat:appcompat:1.1.0")
@@ -69,6 +70,7 @@
androidTestImplementation(ANDROIDX_TEST_UIAUTOMATOR)
androidTestImplementation(ESPRESSO_CORE)
androidTestImplementation(project(":camera:camera-testing"))
+ androidTestImplementation("androidx.lifecycle:lifecycle-livedata-ktx:2.2.0")
androidTestImplementation(TRUTH)
debugImplementation(ANDROIDX_TEST_CORE)
debugImplementation("androidx.fragment:fragment-testing:1.2.3")
diff --git a/camera/integration-tests/viewtestapp/src/androidTest/java/androidx/camera/integration/view/CameraViewFragmentTest.kt b/camera/integration-tests/viewtestapp/src/androidTest/java/androidx/camera/integration/view/CameraViewFragmentTest.kt
new file mode 100644
index 0000000..fc367c0
--- /dev/null
+++ b/camera/integration-tests/viewtestapp/src/androidTest/java/androidx/camera/integration/view/CameraViewFragmentTest.kt
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package androidx.camera.integration.view
+
+import androidx.camera.testing.CameraUtil
+import androidx.camera.testing.CoreAppTestUtil
+import androidx.camera.view.CameraView
+import androidx.camera.view.PreviewView
+import androidx.fragment.app.Fragment
+import androidx.fragment.app.testing.FragmentScenario
+import androidx.fragment.app.testing.launchFragmentInContainer
+import androidx.lifecycle.asFlow
+import androidx.test.ext.junit.runners.AndroidJUnit4
+import androidx.test.filters.LargeTest
+import androidx.test.platform.app.InstrumentationRegistry
+import androidx.test.rule.GrantPermissionRule
+import com.google.common.truth.Truth.assertThat
+import kotlinx.coroutines.flow.first
+import kotlinx.coroutines.runBlocking
+import org.junit.Assume
+import org.junit.Before
+import org.junit.Rule
+import org.junit.Test
+import org.junit.runner.RunWith
+
+@LargeTest
+@RunWith(AndroidJUnit4::class)
+class CameraViewFragmentTest {
+
+ @get:Rule
+ val permissionRule: GrantPermissionRule =
+ GrantPermissionRule.grant(android.Manifest.permission.CAMERA,
+ android.Manifest.permission.WRITE_EXTERNAL_STORAGE,
+ android.Manifest.permission.RECORD_AUDIO)
+
+ @Before
+ fun setup() {
+ Assume.assumeTrue(CameraUtil.deviceHasCamera())
+ CoreAppTestUtil.assumeCompatibleDevice()
+ CoreAppTestUtil.clearDeviceUI(InstrumentationRegistry.getInstrumentation())
+ }
+
+ @Test
+ fun cameraView_canStream() = runBlocking {
+ with(launchFragmentInContainer<CameraViewFragment>()) {
+ val streamState = withFragment {
+ (view?.findViewById<CameraView>(R.id.camera)?.previewStreamState)!!
+ }.asFlow().first {
+ it == PreviewView.StreamState.STREAMING
+ }
+
+ assertThat(streamState).isEqualTo(PreviewView.StreamState.STREAMING)
+ }
+ }
+}
+
+// Adapted from ActivityScenario.withActivity extension function
+private inline fun <reified F : Fragment, T : Any> FragmentScenario<F>.withFragment(
+ crossinline block: F.() -> T
+): T {
+ lateinit var value: T
+ var err: Throwable? = null
+ onFragment { fragment ->
+ try {
+ value = block(fragment)
+ } catch (t: Throwable) {
+ err = t
+ }
+ }
+ err?.let { throw it }
+ return value
+}
\ No newline at end of file
diff --git a/compose/compose-compiler-hosted/integration-tests/src/test/java/androidx/compose/plugins/kotlin/AbstractCodegenSignatureTest.kt b/compose/compose-compiler-hosted/integration-tests/src/test/java/androidx/compose/plugins/kotlin/AbstractCodegenSignatureTest.kt
index b88e636..da5b3a2 100644
--- a/compose/compose-compiler-hosted/integration-tests/src/test/java/androidx/compose/plugins/kotlin/AbstractCodegenSignatureTest.kt
+++ b/compose/compose-compiler-hosted/integration-tests/src/test/java/androidx/compose/plugins/kotlin/AbstractCodegenSignatureTest.kt
@@ -110,6 +110,13 @@
val fileName = "$className.kt"
val loader = classLoader("""
+ @file:OptIn(
+ ExperimentalComposeApi::class,
+ InternalComposeApi::class,
+ ComposeCompilerApi::class
+ )
+ package test
+
import androidx.compose.*
$src
diff --git a/compose/compose-compiler-hosted/integration-tests/src/test/java/androidx/compose/plugins/kotlin/AbstractCodegenTest.kt b/compose/compose-compiler-hosted/integration-tests/src/test/java/androidx/compose/plugins/kotlin/AbstractCodegenTest.kt
index f2c15f0c..7e7f8ff 100644
--- a/compose/compose-compiler-hosted/integration-tests/src/test/java/androidx/compose/plugins/kotlin/AbstractCodegenTest.kt
+++ b/compose/compose-compiler-hosted/integration-tests/src/test/java/androidx/compose/plugins/kotlin/AbstractCodegenTest.kt
@@ -118,6 +118,16 @@
protected fun testCompileEmittable(source: String, dumpClasses: Boolean = false) = testCompile(
"""
+ @file:OptIn(
+ ExperimentalComposeApi::class,
+ InternalComposeApi::class,
+ ComposeCompilerApi::class
+ )
+ package text
+
+ import androidx.compose.ExperimentalComposeApi
+ import androidx.compose.InternalComposeApi
+ import androidx.compose.ComposeCompilerApi
import androidx.compose.Applier
import androidx.compose.ApplyAdapter
import androidx.compose.Composer
diff --git a/compose/compose-compiler-hosted/integration-tests/src/test/java/androidx/compose/plugins/kotlin/ComposerParamSignatureTests.kt b/compose/compose-compiler-hosted/integration-tests/src/test/java/androidx/compose/plugins/kotlin/ComposerParamSignatureTests.kt
index b4f6822..11f797e 100644
--- a/compose/compose-compiler-hosted/integration-tests/src/test/java/androidx/compose/plugins/kotlin/ComposerParamSignatureTests.kt
+++ b/compose/compose-compiler-hosted/integration-tests/src/test/java/androidx/compose/plugins/kotlin/ComposerParamSignatureTests.kt
@@ -152,7 +152,7 @@
@Composable fun Foo(a: Bar?) {}
"""
) {
- val testClass = it.split("public final class ").single { it.startsWith("TestKt") }
+ val testClass = it.split("public final class ").single { it.startsWith("test/TestKt") }
assert(!testClass.contains(
"INVOKEVIRTUAL Bar.unbox-impl ()I"
))
@@ -174,7 +174,7 @@
}
"""
) {
- assert(it.contains("public final static Foo-T150t4E(ILandroidx/compose/Composer;III)V"))
+ assert(it.contains("public final static Foo-RDdOdTo(ILandroidx/compose/Composer;III)V"))
}
@Test
diff --git a/compose/compose-compiler-hosted/integration-tests/src/test/java/androidx/compose/plugins/kotlin/ComposerParamTransformTests.kt b/compose/compose-compiler-hosted/integration-tests/src/test/java/androidx/compose/plugins/kotlin/ComposerParamTransformTests.kt
index 73ab333..2e2062f 100644
--- a/compose/compose-compiler-hosted/integration-tests/src/test/java/androidx/compose/plugins/kotlin/ComposerParamTransformTests.kt
+++ b/compose/compose-compiler-hosted/integration-tests/src/test/java/androidx/compose/plugins/kotlin/ComposerParamTransformTests.kt
@@ -25,6 +25,16 @@
dumpTree: Boolean = false
) = verifyComposeIrTransform(
"""
+ @file:OptIn(
+ ExperimentalComposeApi::class,
+ InternalComposeApi::class,
+ ComposeCompilerApi::class
+ )
+ package test
+
+ import androidx.compose.ExperimentalComposeApi
+ import androidx.compose.InternalComposeApi
+ import androidx.compose.ComposeCompilerApi
import androidx.compose.Composable
import androidx.compose.ComposableContract
@@ -286,7 +296,7 @@
{ it: TextView ->
}
}, %composer, <>, 0)
- %composer.emit(-1248659174, { context: @[ParameterName(name = 'context')] Context ->
+ %composer.emit(-1248659431, { context: @[ParameterName(name = 'context')] Context ->
TextView(context)
}
) {
diff --git a/compose/compose-compiler-hosted/integration-tests/src/test/java/androidx/compose/plugins/kotlin/FunctionBodySkippingTransformTests.kt b/compose/compose-compiler-hosted/integration-tests/src/test/java/androidx/compose/plugins/kotlin/FunctionBodySkippingTransformTests.kt
index 2563d9d..f6e496d 100644
--- a/compose/compose-compiler-hosted/integration-tests/src/test/java/androidx/compose/plugins/kotlin/FunctionBodySkippingTransformTests.kt
+++ b/compose/compose-compiler-hosted/integration-tests/src/test/java/androidx/compose/plugins/kotlin/FunctionBodySkippingTransformTests.kt
@@ -113,9 +113,11 @@
""",
"""
import androidx.compose.Untracked
+ import androidx.compose.ExperimentalComposeApi
@Composable
fun Test(x: Int = 0, y: Int = 0) {
+ @OptIn(ExperimentalComposeApi::class)
Wrap @Untracked {
A(x)
}
@@ -2153,6 +2155,7 @@
""",
"""
import androidx.compose.currentComposer
+ import androidx.compose.ExperimentalComposeApi
open class Foo {
@ComposableContract(readonly = true)
diff --git a/compose/compose-compiler-hosted/integration-tests/src/test/java/androidx/compose/plugins/kotlin/LambdaMemoizationTests.kt b/compose/compose-compiler-hosted/integration-tests/src/test/java/androidx/compose/plugins/kotlin/LambdaMemoizationTests.kt
index c334929..749ca47 100644
--- a/compose/compose-compiler-hosted/integration-tests/src/test/java/androidx/compose/plugins/kotlin/LambdaMemoizationTests.kt
+++ b/compose/compose-compiler-hosted/integration-tests/src/test/java/androidx/compose/plugins/kotlin/LambdaMemoizationTests.kt
@@ -664,6 +664,7 @@
@Composable
fun Example(model: String) {
workToBeRepeated()
+ @OptIn(androidx.compose.ExperimentalComposeApi::class)
Wrapper @Untracked {
workToBeAvoided()
ValidateModel(model)
diff --git a/compose/compose-compiler-hosted/integration-tests/src/test/java/androidx/compose/plugins/kotlin/analysis/UnionCheckerTests.kt b/compose/compose-compiler-hosted/integration-tests/src/test/java/androidx/compose/plugins/kotlin/analysis/UnionCheckerTests.kt
index 4a03459..11cd514 100644
--- a/compose/compose-compiler-hosted/integration-tests/src/test/java/androidx/compose/plugins/kotlin/analysis/UnionCheckerTests.kt
+++ b/compose/compose-compiler-hosted/integration-tests/src/test/java/androidx/compose/plugins/kotlin/analysis/UnionCheckerTests.kt
@@ -25,6 +25,8 @@
"""
import androidx.compose.*;
+ @Suppress("EXPERIMENTAL_IS_NOT_ENABLED")
+ @OptIn(androidx.compose.ExperimentalComposeApi::class)
@Composable fun foo(value: @UnionType(Int::class, String::class) Any) {
System.out.println(value)
}
@@ -43,10 +45,14 @@
"""
import androidx.compose.*;
+ @Suppress("EXPERIMENTAL_IS_NOT_ENABLED")
+ @OptIn(androidx.compose.ExperimentalComposeApi::class)
@Composable fun foo(value: @UnionType(Int::class, String::class) Any) {
System.out.println(value)
}
+ @Suppress("EXPERIMENTAL_IS_NOT_ENABLED")
+ @OptIn(androidx.compose.ExperimentalComposeApi::class)
@Composable
fun bar(value: @UnionType(Int::class, String::class) Any) {
foo(value)
@@ -59,10 +65,14 @@
"""
import androidx.compose.*;
+ @Suppress("EXPERIMENTAL_IS_NOT_ENABLED")
+ @OptIn(androidx.compose.ExperimentalComposeApi::class)
@Composable fun foo(value: @UnionType(Int::class, String::class, Float::class) Any) {
System.out.println(value)
}
+ @Suppress("EXPERIMENTAL_IS_NOT_ENABLED")
+ @OptIn(androidx.compose.ExperimentalComposeApi::class)
@Composable
fun bar(value: @UnionType(Int::class, String::class) Any) {
foo(value)
@@ -75,10 +85,14 @@
"""
import androidx.compose.*;
+ @Suppress("EXPERIMENTAL_IS_NOT_ENABLED")
+ @OptIn(androidx.compose.ExperimentalComposeApi::class)
@Composable fun foo(value: @UnionType(Int::class, String::class) Any) {
System.out.println(value)
}
+ @Suppress("EXPERIMENTAL_IS_NOT_ENABLED")
+ @OptIn(androidx.compose.ExperimentalComposeApi::class)
@Composable
fun bar(value: @UnionType(Int::class, String::class, Float::class) Any) {
foo(<!ILLEGAL_ASSIGN_TO_UNIONTYPE!>value<!>)
diff --git a/compose/compose-compiler-hosted/src/main/java/androidx/compose/plugins/kotlin/compiler/lower/IrSourcePrinter.kt b/compose/compose-compiler-hosted/src/main/java/androidx/compose/plugins/kotlin/compiler/lower/IrSourcePrinter.kt
index 81d9aa1..f8248af 100644
--- a/compose/compose-compiler-hosted/src/main/java/androidx/compose/plugins/kotlin/compiler/lower/IrSourcePrinter.kt
+++ b/compose/compose-compiler-hosted/src/main/java/androidx/compose/plugins/kotlin/compiler/lower/IrSourcePrinter.kt
@@ -46,6 +46,7 @@
import org.jetbrains.kotlin.ir.expressions.IrBreakContinue
import org.jetbrains.kotlin.ir.expressions.IrCall
import org.jetbrains.kotlin.ir.expressions.IrCatch
+import org.jetbrains.kotlin.ir.expressions.IrClassReference
import org.jetbrains.kotlin.ir.expressions.IrComposite
import org.jetbrains.kotlin.ir.expressions.IrConst
import org.jetbrains.kotlin.ir.expressions.IrConstKind
@@ -1059,6 +1060,11 @@
expression.value.print()
}
+ override fun visitClassReference(expression: IrClassReference) {
+ print(expression.classType.renderSrc())
+ print("::class")
+ }
+
override fun visitFunctionAccess(expression: IrFunctionAccessExpression) {
super.visitFunctionAccess(expression)
}
diff --git a/compose/compose-runtime/api/0.1.0-dev14.txt b/compose/compose-runtime/api/0.1.0-dev14.txt
index 6bf9d77..8026f0c 100644
--- a/compose/compose-runtime/api/0.1.0-dev14.txt
+++ b/compose/compose-runtime/api/0.1.0-dev14.txt
@@ -18,7 +18,7 @@
method public static <T> androidx.compose.ProvidableAmbient<T> staticAmbientOf(kotlin.jvm.functions.Function0<? extends T>? defaultFactory = null);
}
- public final class Anchor {
+ @androidx.compose.InternalComposeApi public final class Anchor {
ctor public Anchor(internal int loc);
method public boolean getValid();
method public int location(androidx.compose.SlotTable slots);
@@ -46,7 +46,7 @@
property public final androidx.compose.AndroidUiDispatcher Main;
}
- public final class Applier<N> {
+ @androidx.compose.ExperimentalComposeApi public final class Applier<N> {
ctor public Applier(N! root, androidx.compose.ApplyAdapter<N> adapter);
method public void down(N? node);
method public N! getCurrent();
@@ -58,7 +58,7 @@
property public final N! current;
}
- public interface ApplyAdapter<N> {
+ @androidx.compose.ExperimentalComposeApi public interface ApplyAdapter<N> {
method public void end(N?, N? instance, N? parent);
method public void insertAt(N?, int index, N? instance);
method public void move(N?, int from, int to, int count);
@@ -96,6 +96,9 @@
method public abstract boolean restartable() default true;
}
+ @kotlin.RequiresOptIn(level=RequiresOptIn.Level.WARNING, message="This API is intended to be targeted by the Compose Compiler Plugin and not called " + "directly.") @kotlin.annotation.Target(allowedTargets={AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY, AnnotationTarget.TYPEALIAS}) public @interface ComposeCompilerApi {
+ }
+
public final class ComposeKt {
method @androidx.compose.Stable public static kotlin.jvm.functions.Function0<kotlin.Unit> emptyContent();
method public static inline kotlin.jvm.functions.Function0<kotlin.Unit> orEmpty(kotlin.jvm.functions.Function0<kotlin.Unit>?);
@@ -103,55 +106,44 @@
public class Composer<N> {
ctor public Composer(androidx.compose.SlotTable slotTable, androidx.compose.Applier<N> applier, androidx.compose.Recomposer recomposer);
- method public final void abortRoot();
- method public final <V, T> void apply(V? value, kotlin.jvm.functions.Function2<? super T,? super V,kotlin.Unit> block);
- method public final void applyChanges();
- method public final androidx.compose.CompositionReference buildReference();
+ method @androidx.compose.InternalComposeApi public final void applyChanges();
method @Deprecated public final inline void call(Object key, kotlin.jvm.functions.Function1<? super androidx.compose.ComposerValidator,java.lang.Boolean> invalid, kotlin.jvm.functions.Function0<kotlin.Unit> block);
- method public final boolean changed(Object? value);
- method public final boolean changed(char value);
- method public final boolean changed(byte value);
- method public final boolean changed(short value);
- method public final boolean changed(boolean value);
- method public final boolean changed(float value);
- method public final boolean changed(long value);
- method public final boolean changed(double value);
- method public final boolean changed(int value);
- method public final void collectKeySourceInformation();
+ method @androidx.compose.ComposeCompilerApi public final boolean changed(Object? value);
+ method @androidx.compose.ComposeCompilerApi public final boolean changed(char value);
+ method @androidx.compose.ComposeCompilerApi public final boolean changed(byte value);
+ method @androidx.compose.ComposeCompilerApi public final boolean changed(short value);
+ method @androidx.compose.ComposeCompilerApi public final boolean changed(boolean value);
+ method @androidx.compose.ComposeCompilerApi public final boolean changed(float value);
+ method @androidx.compose.ComposeCompilerApi public final boolean changed(long value);
+ method @androidx.compose.ComposeCompilerApi public final boolean changed(double value);
+ method @androidx.compose.ComposeCompilerApi public final boolean changed(int value);
+ method @androidx.compose.InternalComposeApi public final void collectKeySourceInformation();
method protected final void composeRoot(kotlin.jvm.functions.Function0<kotlin.Unit> block);
- method public final <T extends N> void createNode(kotlin.jvm.functions.Function0<? extends T> factory);
- method public final <T extends N> void emitNode(kotlin.jvm.functions.Function0<? extends T> factory);
- method public final void emitNode(N? node);
- method public final void endDefaults();
- method public final void endGroup();
- method public final void endMovableGroup();
- method public final void endNode();
- method public final void endReplaceableGroup();
- method public final androidx.compose.ScopeUpdateScope? endRestartGroup();
- method public final void endRoot();
- method public final int getChangeCount();
+ method @androidx.compose.ComposeCompilerApi public final <T extends N> void createNode(kotlin.jvm.functions.Function0<? extends T> factory);
+ method @androidx.compose.ComposeCompilerApi public final <T extends N> void emitNode(kotlin.jvm.functions.Function0<? extends T> factory);
+ method @androidx.compose.ComposeCompilerApi public final void emitNode(N? node);
+ method @androidx.compose.ComposeCompilerApi public final void endDefaults();
+ method @androidx.compose.ComposeCompilerApi public final void endMovableGroup();
+ method @androidx.compose.ComposeCompilerApi public final void endNode();
+ method @androidx.compose.ComposeCompilerApi public final void endReplaceableGroup();
+ method @androidx.compose.ComposeCompilerApi public final androidx.compose.ScopeUpdateScope? endRestartGroup();
method public final int getCurrentCompoundKeyHash();
method public final boolean getDefaultsInvalid();
method public final boolean getInserting();
method public final androidx.compose.Recomposer getRecomposer();
method public final boolean getSkipping();
method public final androidx.compose.SlotTable getSlotTable();
- method public final Object joinKey(Object? left, Object? right);
- method public final Object? nextSlot();
- method public final boolean recompose();
- method public final void skipCurrentGroup();
- method public final void skipToGroupEnd();
- method public final void startDefaults();
- method public final void startGroup(int key);
- method public final void startGroup(int key, Object? dataKey);
- method public final void startMovableGroup(int key, Object? dataKey);
- method public final void startNode(Object key);
- method public final void startReplaceableGroup(int key);
- method public final void startRestartGroup(int key);
- method public final void startRoot();
- method public final void updateValue(Object? value);
- method public final N! useNode();
- property public final int changeCount;
+ method @androidx.compose.ComposeCompilerApi public final Object joinKey(Object? left, Object? right);
+ method @androidx.compose.ComposeCompilerApi public final Object? nextSlot();
+ method @androidx.compose.InternalComposeApi public final boolean recompose();
+ method @androidx.compose.ComposeCompilerApi public final void skipCurrentGroup();
+ method @androidx.compose.ComposeCompilerApi public final void skipToGroupEnd();
+ method @androidx.compose.ComposeCompilerApi public final void startDefaults();
+ method @androidx.compose.ComposeCompilerApi public final void startMovableGroup(int key, Object? dataKey);
+ method @androidx.compose.ComposeCompilerApi public final void startNode(Object key);
+ method @androidx.compose.ComposeCompilerApi public final void startReplaceableGroup(int key);
+ method @androidx.compose.ComposeCompilerApi public final void startRestartGroup(int key);
+ method @androidx.compose.ComposeCompilerApi public final N! useNode();
property public final int currentCompoundKeyHash;
property public final boolean defaultsInvalid;
property public final boolean inserting;
@@ -159,7 +151,6 @@
}
public final class ComposerKt {
- method public static inline <N, T> T! cache(androidx.compose.Composer<N>, boolean valid = true, kotlin.jvm.functions.Function0<? extends T> block);
method public static inline <T> T! escapeCompose(kotlin.jvm.functions.Function1<? super androidx.compose.NullCompilationScope,? extends T> block);
method public static androidx.compose.Composer<?> getCurrentComposer();
}
@@ -174,9 +165,9 @@
method public inline <reified V> void update(V? value, kotlin.jvm.functions.Function2<? super T,? super V,? extends kotlin.Unit> block);
}
- public interface ComposerValidator {
- method public boolean changed(int value);
- method public <T> boolean changed(T? value);
+ @Deprecated public interface ComposerValidator {
+ method @Deprecated public boolean changed(int value);
+ method @Deprecated public <T> boolean changed(T? value);
}
public interface Composition {
@@ -241,6 +232,9 @@
public final class ExpectKt {
}
+ @kotlin.RequiresOptIn(level=RequiresOptIn.Level.ERROR, message="This is an experimental API for Compose and is likely to change before becoming " + "stable.") @kotlin.annotation.Target(allowedTargets={AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY}) public @interface ExperimentalComposeApi {
+ }
+
public final class FlowAdapterKt {
method @androidx.compose.Composable @kotlinx.coroutines.ExperimentalCoroutinesApi public static inline <T> androidx.compose.State<T> collectAsState(kotlinx.coroutines.flow.StateFlow<? extends T>, kotlin.coroutines.CoroutineContext context = Dispatchers.Main);
method @Deprecated @androidx.compose.Composable public static inline <T> androidx.compose.State<T> collectAsState(kotlinx.coroutines.flow.Flow<? extends T>, kotlin.coroutines.CoroutineContext context = Dispatchers.Main);
@@ -263,12 +257,12 @@
}
public final class JoinedKeyKt {
- method public static boolean isJoinedKey(Object? key);
- method public static Object? joinedKeyLeft(Object? key);
- method public static Object? joinedKeyRight(Object? key);
+ method @androidx.compose.InternalComposeApi public static boolean isJoinedKey(Object? key);
+ method @androidx.compose.InternalComposeApi public static Object? joinedKeyLeft(Object? key);
+ method @androidx.compose.InternalComposeApi public static Object? joinedKeyRight(Object? key);
}
- public final class KeyInfo {
+ @androidx.compose.InternalComposeApi public final class KeyInfo {
method public Object? getDataKey();
method public int getIndex();
method public int getKey();
@@ -281,7 +275,7 @@
}
public final class KeySourceInfoKt {
- method public static String? keySourceInfoOf(Object key);
+ method @androidx.compose.InternalComposeApi public static String? keySourceInfoOf(Object key);
}
@androidx.compose.Stable public interface MutableState<T> extends androidx.compose.State<T> {
@@ -368,11 +362,11 @@
method @androidx.compose.Composable public static inline <V> V! remember(Object![]? inputs, kotlin.jvm.functions.Function0<? extends V> block);
}
- public interface ScopeUpdateScope {
+ @androidx.compose.ComposeCompilerApi public interface ScopeUpdateScope {
method public void updateScope(kotlin.jvm.functions.Function3<? super androidx.compose.Composer<?>,? super java.lang.Integer,? super java.lang.Integer,kotlin.Unit> block);
}
- public final class SlotReader {
+ @androidx.compose.InternalComposeApi public final class SlotReader {
ctor public SlotReader(androidx.compose.SlotTable table);
method public void beginEmpty();
method public void close();
@@ -434,17 +428,17 @@
ctor public SlotTable(internal Object![] slots);
ctor public SlotTable();
method public int getSize();
- method public java.util.List<java.lang.Integer> groupPathTo(int location);
- method public androidx.compose.SlotReader openReader();
- method public androidx.compose.SlotWriter openWriter();
- method public <T> T! read(kotlin.jvm.functions.Function1<? super androidx.compose.SlotReader,? extends T> block);
- method @org.jetbrains.annotations.TestOnly public void verifyWellFormed();
- method public <T> T! write(kotlin.jvm.functions.Function1<? super androidx.compose.SlotWriter,? extends T> block);
+ method @androidx.compose.InternalComposeApi public java.util.List<java.lang.Integer> groupPathTo(int location);
+ method @androidx.compose.InternalComposeApi public androidx.compose.SlotReader openReader();
+ method @androidx.compose.InternalComposeApi public androidx.compose.SlotWriter openWriter();
+ method @androidx.compose.InternalComposeApi public <T> T! read(kotlin.jvm.functions.Function1<? super androidx.compose.SlotReader,? extends T> block);
+ method @androidx.compose.InternalComposeApi @org.jetbrains.annotations.TestOnly public void verifyWellFormed();
+ method @androidx.compose.InternalComposeApi public <T> T! write(kotlin.jvm.functions.Function1<? super androidx.compose.SlotWriter,? extends T> block);
property public final int size;
field public static final androidx.compose.SlotTable.Companion! Companion;
}
- public static final class SlotTable.Companion {
+ @androidx.compose.InternalComposeApi public static final class SlotTable.Companion {
method public Object getEMPTY();
property public final Object EMPTY;
}
@@ -452,7 +446,7 @@
public final class SlotTableKt {
}
- public final class SlotWriter {
+ @androidx.compose.InternalComposeApi public final class SlotWriter {
method public androidx.compose.Anchor anchor(int index = current);
method public void beginInsert();
method public void close();
@@ -529,11 +523,11 @@
public final class TraceKt {
}
- @kotlin.annotation.MustBeDocumented @kotlin.annotation.Retention(AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets={AnnotationTarget.TYPE, AnnotationTarget.TYPE_PARAMETER}) public @interface UnionType {
+ @androidx.compose.ExperimentalComposeApi @kotlin.annotation.MustBeDocumented @kotlin.annotation.Retention(AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets={AnnotationTarget.TYPE, AnnotationTarget.TYPE_PARAMETER}) public @interface UnionType {
method public abstract Class<?>[] types();
}
- @kotlin.annotation.MustBeDocumented @kotlin.annotation.Retention(AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=AnnotationTarget.FUNCTION) public @interface Untracked {
+ @androidx.compose.ExperimentalComposeApi @kotlin.annotation.MustBeDocumented @kotlin.annotation.Retention(AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=AnnotationTarget.FUNCTION) public @interface Untracked {
}
}
@@ -672,7 +666,7 @@
package androidx.compose.internal {
- @androidx.compose.Stable public final class RestartableFunction<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17, P18, R> implements kotlin.jvm.functions.Function10<P1,P2,P3,P4,P5,P6,P7,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function11<P1,P2,P3,P4,P5,P6,P7,P8,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function12<P1,P2,P3,P4,P5,P6,P7,P8,P9,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function13<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function14<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function15<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function16<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function17<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13,P14,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function18<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13,P14,P15,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function20<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13,P14,P15,P16,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function21<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13,P14,P15,P16,P17,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function22<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13,P14,P15,P16,P17,P18,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function3<androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function4<P1,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function5<P1,P2,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function6<P1,P2,P3,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function7<P1,P2,P3,P4,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function8<P1,P2,P3,P4,P5,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function9<P1,P2,P3,P4,P5,P6,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> {
+ @androidx.compose.ComposeCompilerApi @androidx.compose.Stable public final class RestartableFunction<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17, P18, R> implements kotlin.jvm.functions.Function10<P1,P2,P3,P4,P5,P6,P7,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function11<P1,P2,P3,P4,P5,P6,P7,P8,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function12<P1,P2,P3,P4,P5,P6,P7,P8,P9,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function13<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function14<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function15<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function16<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function17<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13,P14,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function18<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13,P14,P15,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function20<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13,P14,P15,P16,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function21<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13,P14,P15,P16,P17,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function22<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13,P14,P15,P16,P17,P18,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function3<androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function4<P1,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function5<P1,P2,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function6<P1,P2,P3,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function7<P1,P2,P3,P4,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function8<P1,P2,P3,P4,P5,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function9<P1,P2,P3,P4,P5,P6,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> {
ctor public RestartableFunction(int key, boolean tracked);
method public int getKey();
method public operator R! invoke(androidx.compose.Composer<?> c, int k, int changed);
@@ -698,11 +692,11 @@
}
public final class RestartableFunctionKt {
- method public static androidx.compose.internal.RestartableFunction<java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object> restartableFunction(androidx.compose.Composer<?> composer, int key, boolean tracked, Object block);
- method public static androidx.compose.internal.RestartableFunction<java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object> restartableFunctionInstance(int key, boolean tracked, Object block);
+ method @androidx.compose.ComposeCompilerApi public static androidx.compose.internal.RestartableFunction<java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object> restartableFunction(androidx.compose.Composer<?> composer, int key, boolean tracked, Object block);
+ method @androidx.compose.ComposeCompilerApi public static androidx.compose.internal.RestartableFunction<java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object> restartableFunctionInstance(int key, boolean tracked, Object block);
}
- @androidx.compose.Stable public final class RestartableFunctionN<R> implements kotlin.jvm.functions.FunctionN<R> {
+ @androidx.compose.ComposeCompilerApi @androidx.compose.Stable public final class RestartableFunctionN<R> implements kotlin.jvm.functions.FunctionN<R> {
ctor public RestartableFunctionN(int key, boolean tracked, int arity);
method public int getArity();
method public int getKey();
@@ -711,8 +705,8 @@
}
public final class RestartableFunctionNKt {
- method public static androidx.compose.internal.RestartableFunctionN<?> restartableFunctionN(androidx.compose.Composer<?> composer, int key, boolean tracked, int arity, Object block);
- method public static androidx.compose.internal.RestartableFunctionN<?> restartableFunctionNInstance(int key, boolean tracked, int arity, Object block);
+ method @androidx.compose.ComposeCompilerApi public static androidx.compose.internal.RestartableFunctionN<?> restartableFunctionN(androidx.compose.Composer<?> composer, int key, boolean tracked, int arity, Object block);
+ method @androidx.compose.ComposeCompilerApi public static androidx.compose.internal.RestartableFunctionN<?> restartableFunctionNInstance(int key, boolean tracked, int arity, Object block);
}
}
diff --git a/compose/compose-runtime/api/current.txt b/compose/compose-runtime/api/current.txt
index 6bf9d77..8026f0c 100644
--- a/compose/compose-runtime/api/current.txt
+++ b/compose/compose-runtime/api/current.txt
@@ -18,7 +18,7 @@
method public static <T> androidx.compose.ProvidableAmbient<T> staticAmbientOf(kotlin.jvm.functions.Function0<? extends T>? defaultFactory = null);
}
- public final class Anchor {
+ @androidx.compose.InternalComposeApi public final class Anchor {
ctor public Anchor(internal int loc);
method public boolean getValid();
method public int location(androidx.compose.SlotTable slots);
@@ -46,7 +46,7 @@
property public final androidx.compose.AndroidUiDispatcher Main;
}
- public final class Applier<N> {
+ @androidx.compose.ExperimentalComposeApi public final class Applier<N> {
ctor public Applier(N! root, androidx.compose.ApplyAdapter<N> adapter);
method public void down(N? node);
method public N! getCurrent();
@@ -58,7 +58,7 @@
property public final N! current;
}
- public interface ApplyAdapter<N> {
+ @androidx.compose.ExperimentalComposeApi public interface ApplyAdapter<N> {
method public void end(N?, N? instance, N? parent);
method public void insertAt(N?, int index, N? instance);
method public void move(N?, int from, int to, int count);
@@ -96,6 +96,9 @@
method public abstract boolean restartable() default true;
}
+ @kotlin.RequiresOptIn(level=RequiresOptIn.Level.WARNING, message="This API is intended to be targeted by the Compose Compiler Plugin and not called " + "directly.") @kotlin.annotation.Target(allowedTargets={AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY, AnnotationTarget.TYPEALIAS}) public @interface ComposeCompilerApi {
+ }
+
public final class ComposeKt {
method @androidx.compose.Stable public static kotlin.jvm.functions.Function0<kotlin.Unit> emptyContent();
method public static inline kotlin.jvm.functions.Function0<kotlin.Unit> orEmpty(kotlin.jvm.functions.Function0<kotlin.Unit>?);
@@ -103,55 +106,44 @@
public class Composer<N> {
ctor public Composer(androidx.compose.SlotTable slotTable, androidx.compose.Applier<N> applier, androidx.compose.Recomposer recomposer);
- method public final void abortRoot();
- method public final <V, T> void apply(V? value, kotlin.jvm.functions.Function2<? super T,? super V,kotlin.Unit> block);
- method public final void applyChanges();
- method public final androidx.compose.CompositionReference buildReference();
+ method @androidx.compose.InternalComposeApi public final void applyChanges();
method @Deprecated public final inline void call(Object key, kotlin.jvm.functions.Function1<? super androidx.compose.ComposerValidator,java.lang.Boolean> invalid, kotlin.jvm.functions.Function0<kotlin.Unit> block);
- method public final boolean changed(Object? value);
- method public final boolean changed(char value);
- method public final boolean changed(byte value);
- method public final boolean changed(short value);
- method public final boolean changed(boolean value);
- method public final boolean changed(float value);
- method public final boolean changed(long value);
- method public final boolean changed(double value);
- method public final boolean changed(int value);
- method public final void collectKeySourceInformation();
+ method @androidx.compose.ComposeCompilerApi public final boolean changed(Object? value);
+ method @androidx.compose.ComposeCompilerApi public final boolean changed(char value);
+ method @androidx.compose.ComposeCompilerApi public final boolean changed(byte value);
+ method @androidx.compose.ComposeCompilerApi public final boolean changed(short value);
+ method @androidx.compose.ComposeCompilerApi public final boolean changed(boolean value);
+ method @androidx.compose.ComposeCompilerApi public final boolean changed(float value);
+ method @androidx.compose.ComposeCompilerApi public final boolean changed(long value);
+ method @androidx.compose.ComposeCompilerApi public final boolean changed(double value);
+ method @androidx.compose.ComposeCompilerApi public final boolean changed(int value);
+ method @androidx.compose.InternalComposeApi public final void collectKeySourceInformation();
method protected final void composeRoot(kotlin.jvm.functions.Function0<kotlin.Unit> block);
- method public final <T extends N> void createNode(kotlin.jvm.functions.Function0<? extends T> factory);
- method public final <T extends N> void emitNode(kotlin.jvm.functions.Function0<? extends T> factory);
- method public final void emitNode(N? node);
- method public final void endDefaults();
- method public final void endGroup();
- method public final void endMovableGroup();
- method public final void endNode();
- method public final void endReplaceableGroup();
- method public final androidx.compose.ScopeUpdateScope? endRestartGroup();
- method public final void endRoot();
- method public final int getChangeCount();
+ method @androidx.compose.ComposeCompilerApi public final <T extends N> void createNode(kotlin.jvm.functions.Function0<? extends T> factory);
+ method @androidx.compose.ComposeCompilerApi public final <T extends N> void emitNode(kotlin.jvm.functions.Function0<? extends T> factory);
+ method @androidx.compose.ComposeCompilerApi public final void emitNode(N? node);
+ method @androidx.compose.ComposeCompilerApi public final void endDefaults();
+ method @androidx.compose.ComposeCompilerApi public final void endMovableGroup();
+ method @androidx.compose.ComposeCompilerApi public final void endNode();
+ method @androidx.compose.ComposeCompilerApi public final void endReplaceableGroup();
+ method @androidx.compose.ComposeCompilerApi public final androidx.compose.ScopeUpdateScope? endRestartGroup();
method public final int getCurrentCompoundKeyHash();
method public final boolean getDefaultsInvalid();
method public final boolean getInserting();
method public final androidx.compose.Recomposer getRecomposer();
method public final boolean getSkipping();
method public final androidx.compose.SlotTable getSlotTable();
- method public final Object joinKey(Object? left, Object? right);
- method public final Object? nextSlot();
- method public final boolean recompose();
- method public final void skipCurrentGroup();
- method public final void skipToGroupEnd();
- method public final void startDefaults();
- method public final void startGroup(int key);
- method public final void startGroup(int key, Object? dataKey);
- method public final void startMovableGroup(int key, Object? dataKey);
- method public final void startNode(Object key);
- method public final void startReplaceableGroup(int key);
- method public final void startRestartGroup(int key);
- method public final void startRoot();
- method public final void updateValue(Object? value);
- method public final N! useNode();
- property public final int changeCount;
+ method @androidx.compose.ComposeCompilerApi public final Object joinKey(Object? left, Object? right);
+ method @androidx.compose.ComposeCompilerApi public final Object? nextSlot();
+ method @androidx.compose.InternalComposeApi public final boolean recompose();
+ method @androidx.compose.ComposeCompilerApi public final void skipCurrentGroup();
+ method @androidx.compose.ComposeCompilerApi public final void skipToGroupEnd();
+ method @androidx.compose.ComposeCompilerApi public final void startDefaults();
+ method @androidx.compose.ComposeCompilerApi public final void startMovableGroup(int key, Object? dataKey);
+ method @androidx.compose.ComposeCompilerApi public final void startNode(Object key);
+ method @androidx.compose.ComposeCompilerApi public final void startReplaceableGroup(int key);
+ method @androidx.compose.ComposeCompilerApi public final void startRestartGroup(int key);
+ method @androidx.compose.ComposeCompilerApi public final N! useNode();
property public final int currentCompoundKeyHash;
property public final boolean defaultsInvalid;
property public final boolean inserting;
@@ -159,7 +151,6 @@
}
public final class ComposerKt {
- method public static inline <N, T> T! cache(androidx.compose.Composer<N>, boolean valid = true, kotlin.jvm.functions.Function0<? extends T> block);
method public static inline <T> T! escapeCompose(kotlin.jvm.functions.Function1<? super androidx.compose.NullCompilationScope,? extends T> block);
method public static androidx.compose.Composer<?> getCurrentComposer();
}
@@ -174,9 +165,9 @@
method public inline <reified V> void update(V? value, kotlin.jvm.functions.Function2<? super T,? super V,? extends kotlin.Unit> block);
}
- public interface ComposerValidator {
- method public boolean changed(int value);
- method public <T> boolean changed(T? value);
+ @Deprecated public interface ComposerValidator {
+ method @Deprecated public boolean changed(int value);
+ method @Deprecated public <T> boolean changed(T? value);
}
public interface Composition {
@@ -241,6 +232,9 @@
public final class ExpectKt {
}
+ @kotlin.RequiresOptIn(level=RequiresOptIn.Level.ERROR, message="This is an experimental API for Compose and is likely to change before becoming " + "stable.") @kotlin.annotation.Target(allowedTargets={AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY}) public @interface ExperimentalComposeApi {
+ }
+
public final class FlowAdapterKt {
method @androidx.compose.Composable @kotlinx.coroutines.ExperimentalCoroutinesApi public static inline <T> androidx.compose.State<T> collectAsState(kotlinx.coroutines.flow.StateFlow<? extends T>, kotlin.coroutines.CoroutineContext context = Dispatchers.Main);
method @Deprecated @androidx.compose.Composable public static inline <T> androidx.compose.State<T> collectAsState(kotlinx.coroutines.flow.Flow<? extends T>, kotlin.coroutines.CoroutineContext context = Dispatchers.Main);
@@ -263,12 +257,12 @@
}
public final class JoinedKeyKt {
- method public static boolean isJoinedKey(Object? key);
- method public static Object? joinedKeyLeft(Object? key);
- method public static Object? joinedKeyRight(Object? key);
+ method @androidx.compose.InternalComposeApi public static boolean isJoinedKey(Object? key);
+ method @androidx.compose.InternalComposeApi public static Object? joinedKeyLeft(Object? key);
+ method @androidx.compose.InternalComposeApi public static Object? joinedKeyRight(Object? key);
}
- public final class KeyInfo {
+ @androidx.compose.InternalComposeApi public final class KeyInfo {
method public Object? getDataKey();
method public int getIndex();
method public int getKey();
@@ -281,7 +275,7 @@
}
public final class KeySourceInfoKt {
- method public static String? keySourceInfoOf(Object key);
+ method @androidx.compose.InternalComposeApi public static String? keySourceInfoOf(Object key);
}
@androidx.compose.Stable public interface MutableState<T> extends androidx.compose.State<T> {
@@ -368,11 +362,11 @@
method @androidx.compose.Composable public static inline <V> V! remember(Object![]? inputs, kotlin.jvm.functions.Function0<? extends V> block);
}
- public interface ScopeUpdateScope {
+ @androidx.compose.ComposeCompilerApi public interface ScopeUpdateScope {
method public void updateScope(kotlin.jvm.functions.Function3<? super androidx.compose.Composer<?>,? super java.lang.Integer,? super java.lang.Integer,kotlin.Unit> block);
}
- public final class SlotReader {
+ @androidx.compose.InternalComposeApi public final class SlotReader {
ctor public SlotReader(androidx.compose.SlotTable table);
method public void beginEmpty();
method public void close();
@@ -434,17 +428,17 @@
ctor public SlotTable(internal Object![] slots);
ctor public SlotTable();
method public int getSize();
- method public java.util.List<java.lang.Integer> groupPathTo(int location);
- method public androidx.compose.SlotReader openReader();
- method public androidx.compose.SlotWriter openWriter();
- method public <T> T! read(kotlin.jvm.functions.Function1<? super androidx.compose.SlotReader,? extends T> block);
- method @org.jetbrains.annotations.TestOnly public void verifyWellFormed();
- method public <T> T! write(kotlin.jvm.functions.Function1<? super androidx.compose.SlotWriter,? extends T> block);
+ method @androidx.compose.InternalComposeApi public java.util.List<java.lang.Integer> groupPathTo(int location);
+ method @androidx.compose.InternalComposeApi public androidx.compose.SlotReader openReader();
+ method @androidx.compose.InternalComposeApi public androidx.compose.SlotWriter openWriter();
+ method @androidx.compose.InternalComposeApi public <T> T! read(kotlin.jvm.functions.Function1<? super androidx.compose.SlotReader,? extends T> block);
+ method @androidx.compose.InternalComposeApi @org.jetbrains.annotations.TestOnly public void verifyWellFormed();
+ method @androidx.compose.InternalComposeApi public <T> T! write(kotlin.jvm.functions.Function1<? super androidx.compose.SlotWriter,? extends T> block);
property public final int size;
field public static final androidx.compose.SlotTable.Companion! Companion;
}
- public static final class SlotTable.Companion {
+ @androidx.compose.InternalComposeApi public static final class SlotTable.Companion {
method public Object getEMPTY();
property public final Object EMPTY;
}
@@ -452,7 +446,7 @@
public final class SlotTableKt {
}
- public final class SlotWriter {
+ @androidx.compose.InternalComposeApi public final class SlotWriter {
method public androidx.compose.Anchor anchor(int index = current);
method public void beginInsert();
method public void close();
@@ -529,11 +523,11 @@
public final class TraceKt {
}
- @kotlin.annotation.MustBeDocumented @kotlin.annotation.Retention(AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets={AnnotationTarget.TYPE, AnnotationTarget.TYPE_PARAMETER}) public @interface UnionType {
+ @androidx.compose.ExperimentalComposeApi @kotlin.annotation.MustBeDocumented @kotlin.annotation.Retention(AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets={AnnotationTarget.TYPE, AnnotationTarget.TYPE_PARAMETER}) public @interface UnionType {
method public abstract Class<?>[] types();
}
- @kotlin.annotation.MustBeDocumented @kotlin.annotation.Retention(AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=AnnotationTarget.FUNCTION) public @interface Untracked {
+ @androidx.compose.ExperimentalComposeApi @kotlin.annotation.MustBeDocumented @kotlin.annotation.Retention(AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=AnnotationTarget.FUNCTION) public @interface Untracked {
}
}
@@ -672,7 +666,7 @@
package androidx.compose.internal {
- @androidx.compose.Stable public final class RestartableFunction<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17, P18, R> implements kotlin.jvm.functions.Function10<P1,P2,P3,P4,P5,P6,P7,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function11<P1,P2,P3,P4,P5,P6,P7,P8,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function12<P1,P2,P3,P4,P5,P6,P7,P8,P9,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function13<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function14<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function15<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function16<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function17<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13,P14,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function18<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13,P14,P15,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function20<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13,P14,P15,P16,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function21<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13,P14,P15,P16,P17,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function22<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13,P14,P15,P16,P17,P18,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function3<androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function4<P1,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function5<P1,P2,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function6<P1,P2,P3,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function7<P1,P2,P3,P4,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function8<P1,P2,P3,P4,P5,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function9<P1,P2,P3,P4,P5,P6,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> {
+ @androidx.compose.ComposeCompilerApi @androidx.compose.Stable public final class RestartableFunction<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17, P18, R> implements kotlin.jvm.functions.Function10<P1,P2,P3,P4,P5,P6,P7,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function11<P1,P2,P3,P4,P5,P6,P7,P8,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function12<P1,P2,P3,P4,P5,P6,P7,P8,P9,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function13<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function14<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function15<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function16<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function17<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13,P14,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function18<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13,P14,P15,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function20<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13,P14,P15,P16,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function21<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13,P14,P15,P16,P17,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function22<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13,P14,P15,P16,P17,P18,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function3<androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function4<P1,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function5<P1,P2,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function6<P1,P2,P3,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function7<P1,P2,P3,P4,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function8<P1,P2,P3,P4,P5,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function9<P1,P2,P3,P4,P5,P6,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> {
ctor public RestartableFunction(int key, boolean tracked);
method public int getKey();
method public operator R! invoke(androidx.compose.Composer<?> c, int k, int changed);
@@ -698,11 +692,11 @@
}
public final class RestartableFunctionKt {
- method public static androidx.compose.internal.RestartableFunction<java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object> restartableFunction(androidx.compose.Composer<?> composer, int key, boolean tracked, Object block);
- method public static androidx.compose.internal.RestartableFunction<java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object> restartableFunctionInstance(int key, boolean tracked, Object block);
+ method @androidx.compose.ComposeCompilerApi public static androidx.compose.internal.RestartableFunction<java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object> restartableFunction(androidx.compose.Composer<?> composer, int key, boolean tracked, Object block);
+ method @androidx.compose.ComposeCompilerApi public static androidx.compose.internal.RestartableFunction<java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object> restartableFunctionInstance(int key, boolean tracked, Object block);
}
- @androidx.compose.Stable public final class RestartableFunctionN<R> implements kotlin.jvm.functions.FunctionN<R> {
+ @androidx.compose.ComposeCompilerApi @androidx.compose.Stable public final class RestartableFunctionN<R> implements kotlin.jvm.functions.FunctionN<R> {
ctor public RestartableFunctionN(int key, boolean tracked, int arity);
method public int getArity();
method public int getKey();
@@ -711,8 +705,8 @@
}
public final class RestartableFunctionNKt {
- method public static androidx.compose.internal.RestartableFunctionN<?> restartableFunctionN(androidx.compose.Composer<?> composer, int key, boolean tracked, int arity, Object block);
- method public static androidx.compose.internal.RestartableFunctionN<?> restartableFunctionNInstance(int key, boolean tracked, int arity, Object block);
+ method @androidx.compose.ComposeCompilerApi public static androidx.compose.internal.RestartableFunctionN<?> restartableFunctionN(androidx.compose.Composer<?> composer, int key, boolean tracked, int arity, Object block);
+ method @androidx.compose.ComposeCompilerApi public static androidx.compose.internal.RestartableFunctionN<?> restartableFunctionNInstance(int key, boolean tracked, int arity, Object block);
}
}
diff --git a/compose/compose-runtime/api/public_plus_experimental_0.1.0-dev14.txt b/compose/compose-runtime/api/public_plus_experimental_0.1.0-dev14.txt
index 6bf9d77..8026f0c 100644
--- a/compose/compose-runtime/api/public_plus_experimental_0.1.0-dev14.txt
+++ b/compose/compose-runtime/api/public_plus_experimental_0.1.0-dev14.txt
@@ -18,7 +18,7 @@
method public static <T> androidx.compose.ProvidableAmbient<T> staticAmbientOf(kotlin.jvm.functions.Function0<? extends T>? defaultFactory = null);
}
- public final class Anchor {
+ @androidx.compose.InternalComposeApi public final class Anchor {
ctor public Anchor(internal int loc);
method public boolean getValid();
method public int location(androidx.compose.SlotTable slots);
@@ -46,7 +46,7 @@
property public final androidx.compose.AndroidUiDispatcher Main;
}
- public final class Applier<N> {
+ @androidx.compose.ExperimentalComposeApi public final class Applier<N> {
ctor public Applier(N! root, androidx.compose.ApplyAdapter<N> adapter);
method public void down(N? node);
method public N! getCurrent();
@@ -58,7 +58,7 @@
property public final N! current;
}
- public interface ApplyAdapter<N> {
+ @androidx.compose.ExperimentalComposeApi public interface ApplyAdapter<N> {
method public void end(N?, N? instance, N? parent);
method public void insertAt(N?, int index, N? instance);
method public void move(N?, int from, int to, int count);
@@ -96,6 +96,9 @@
method public abstract boolean restartable() default true;
}
+ @kotlin.RequiresOptIn(level=RequiresOptIn.Level.WARNING, message="This API is intended to be targeted by the Compose Compiler Plugin and not called " + "directly.") @kotlin.annotation.Target(allowedTargets={AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY, AnnotationTarget.TYPEALIAS}) public @interface ComposeCompilerApi {
+ }
+
public final class ComposeKt {
method @androidx.compose.Stable public static kotlin.jvm.functions.Function0<kotlin.Unit> emptyContent();
method public static inline kotlin.jvm.functions.Function0<kotlin.Unit> orEmpty(kotlin.jvm.functions.Function0<kotlin.Unit>?);
@@ -103,55 +106,44 @@
public class Composer<N> {
ctor public Composer(androidx.compose.SlotTable slotTable, androidx.compose.Applier<N> applier, androidx.compose.Recomposer recomposer);
- method public final void abortRoot();
- method public final <V, T> void apply(V? value, kotlin.jvm.functions.Function2<? super T,? super V,kotlin.Unit> block);
- method public final void applyChanges();
- method public final androidx.compose.CompositionReference buildReference();
+ method @androidx.compose.InternalComposeApi public final void applyChanges();
method @Deprecated public final inline void call(Object key, kotlin.jvm.functions.Function1<? super androidx.compose.ComposerValidator,java.lang.Boolean> invalid, kotlin.jvm.functions.Function0<kotlin.Unit> block);
- method public final boolean changed(Object? value);
- method public final boolean changed(char value);
- method public final boolean changed(byte value);
- method public final boolean changed(short value);
- method public final boolean changed(boolean value);
- method public final boolean changed(float value);
- method public final boolean changed(long value);
- method public final boolean changed(double value);
- method public final boolean changed(int value);
- method public final void collectKeySourceInformation();
+ method @androidx.compose.ComposeCompilerApi public final boolean changed(Object? value);
+ method @androidx.compose.ComposeCompilerApi public final boolean changed(char value);
+ method @androidx.compose.ComposeCompilerApi public final boolean changed(byte value);
+ method @androidx.compose.ComposeCompilerApi public final boolean changed(short value);
+ method @androidx.compose.ComposeCompilerApi public final boolean changed(boolean value);
+ method @androidx.compose.ComposeCompilerApi public final boolean changed(float value);
+ method @androidx.compose.ComposeCompilerApi public final boolean changed(long value);
+ method @androidx.compose.ComposeCompilerApi public final boolean changed(double value);
+ method @androidx.compose.ComposeCompilerApi public final boolean changed(int value);
+ method @androidx.compose.InternalComposeApi public final void collectKeySourceInformation();
method protected final void composeRoot(kotlin.jvm.functions.Function0<kotlin.Unit> block);
- method public final <T extends N> void createNode(kotlin.jvm.functions.Function0<? extends T> factory);
- method public final <T extends N> void emitNode(kotlin.jvm.functions.Function0<? extends T> factory);
- method public final void emitNode(N? node);
- method public final void endDefaults();
- method public final void endGroup();
- method public final void endMovableGroup();
- method public final void endNode();
- method public final void endReplaceableGroup();
- method public final androidx.compose.ScopeUpdateScope? endRestartGroup();
- method public final void endRoot();
- method public final int getChangeCount();
+ method @androidx.compose.ComposeCompilerApi public final <T extends N> void createNode(kotlin.jvm.functions.Function0<? extends T> factory);
+ method @androidx.compose.ComposeCompilerApi public final <T extends N> void emitNode(kotlin.jvm.functions.Function0<? extends T> factory);
+ method @androidx.compose.ComposeCompilerApi public final void emitNode(N? node);
+ method @androidx.compose.ComposeCompilerApi public final void endDefaults();
+ method @androidx.compose.ComposeCompilerApi public final void endMovableGroup();
+ method @androidx.compose.ComposeCompilerApi public final void endNode();
+ method @androidx.compose.ComposeCompilerApi public final void endReplaceableGroup();
+ method @androidx.compose.ComposeCompilerApi public final androidx.compose.ScopeUpdateScope? endRestartGroup();
method public final int getCurrentCompoundKeyHash();
method public final boolean getDefaultsInvalid();
method public final boolean getInserting();
method public final androidx.compose.Recomposer getRecomposer();
method public final boolean getSkipping();
method public final androidx.compose.SlotTable getSlotTable();
- method public final Object joinKey(Object? left, Object? right);
- method public final Object? nextSlot();
- method public final boolean recompose();
- method public final void skipCurrentGroup();
- method public final void skipToGroupEnd();
- method public final void startDefaults();
- method public final void startGroup(int key);
- method public final void startGroup(int key, Object? dataKey);
- method public final void startMovableGroup(int key, Object? dataKey);
- method public final void startNode(Object key);
- method public final void startReplaceableGroup(int key);
- method public final void startRestartGroup(int key);
- method public final void startRoot();
- method public final void updateValue(Object? value);
- method public final N! useNode();
- property public final int changeCount;
+ method @androidx.compose.ComposeCompilerApi public final Object joinKey(Object? left, Object? right);
+ method @androidx.compose.ComposeCompilerApi public final Object? nextSlot();
+ method @androidx.compose.InternalComposeApi public final boolean recompose();
+ method @androidx.compose.ComposeCompilerApi public final void skipCurrentGroup();
+ method @androidx.compose.ComposeCompilerApi public final void skipToGroupEnd();
+ method @androidx.compose.ComposeCompilerApi public final void startDefaults();
+ method @androidx.compose.ComposeCompilerApi public final void startMovableGroup(int key, Object? dataKey);
+ method @androidx.compose.ComposeCompilerApi public final void startNode(Object key);
+ method @androidx.compose.ComposeCompilerApi public final void startReplaceableGroup(int key);
+ method @androidx.compose.ComposeCompilerApi public final void startRestartGroup(int key);
+ method @androidx.compose.ComposeCompilerApi public final N! useNode();
property public final int currentCompoundKeyHash;
property public final boolean defaultsInvalid;
property public final boolean inserting;
@@ -159,7 +151,6 @@
}
public final class ComposerKt {
- method public static inline <N, T> T! cache(androidx.compose.Composer<N>, boolean valid = true, kotlin.jvm.functions.Function0<? extends T> block);
method public static inline <T> T! escapeCompose(kotlin.jvm.functions.Function1<? super androidx.compose.NullCompilationScope,? extends T> block);
method public static androidx.compose.Composer<?> getCurrentComposer();
}
@@ -174,9 +165,9 @@
method public inline <reified V> void update(V? value, kotlin.jvm.functions.Function2<? super T,? super V,? extends kotlin.Unit> block);
}
- public interface ComposerValidator {
- method public boolean changed(int value);
- method public <T> boolean changed(T? value);
+ @Deprecated public interface ComposerValidator {
+ method @Deprecated public boolean changed(int value);
+ method @Deprecated public <T> boolean changed(T? value);
}
public interface Composition {
@@ -241,6 +232,9 @@
public final class ExpectKt {
}
+ @kotlin.RequiresOptIn(level=RequiresOptIn.Level.ERROR, message="This is an experimental API for Compose and is likely to change before becoming " + "stable.") @kotlin.annotation.Target(allowedTargets={AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY}) public @interface ExperimentalComposeApi {
+ }
+
public final class FlowAdapterKt {
method @androidx.compose.Composable @kotlinx.coroutines.ExperimentalCoroutinesApi public static inline <T> androidx.compose.State<T> collectAsState(kotlinx.coroutines.flow.StateFlow<? extends T>, kotlin.coroutines.CoroutineContext context = Dispatchers.Main);
method @Deprecated @androidx.compose.Composable public static inline <T> androidx.compose.State<T> collectAsState(kotlinx.coroutines.flow.Flow<? extends T>, kotlin.coroutines.CoroutineContext context = Dispatchers.Main);
@@ -263,12 +257,12 @@
}
public final class JoinedKeyKt {
- method public static boolean isJoinedKey(Object? key);
- method public static Object? joinedKeyLeft(Object? key);
- method public static Object? joinedKeyRight(Object? key);
+ method @androidx.compose.InternalComposeApi public static boolean isJoinedKey(Object? key);
+ method @androidx.compose.InternalComposeApi public static Object? joinedKeyLeft(Object? key);
+ method @androidx.compose.InternalComposeApi public static Object? joinedKeyRight(Object? key);
}
- public final class KeyInfo {
+ @androidx.compose.InternalComposeApi public final class KeyInfo {
method public Object? getDataKey();
method public int getIndex();
method public int getKey();
@@ -281,7 +275,7 @@
}
public final class KeySourceInfoKt {
- method public static String? keySourceInfoOf(Object key);
+ method @androidx.compose.InternalComposeApi public static String? keySourceInfoOf(Object key);
}
@androidx.compose.Stable public interface MutableState<T> extends androidx.compose.State<T> {
@@ -368,11 +362,11 @@
method @androidx.compose.Composable public static inline <V> V! remember(Object![]? inputs, kotlin.jvm.functions.Function0<? extends V> block);
}
- public interface ScopeUpdateScope {
+ @androidx.compose.ComposeCompilerApi public interface ScopeUpdateScope {
method public void updateScope(kotlin.jvm.functions.Function3<? super androidx.compose.Composer<?>,? super java.lang.Integer,? super java.lang.Integer,kotlin.Unit> block);
}
- public final class SlotReader {
+ @androidx.compose.InternalComposeApi public final class SlotReader {
ctor public SlotReader(androidx.compose.SlotTable table);
method public void beginEmpty();
method public void close();
@@ -434,17 +428,17 @@
ctor public SlotTable(internal Object![] slots);
ctor public SlotTable();
method public int getSize();
- method public java.util.List<java.lang.Integer> groupPathTo(int location);
- method public androidx.compose.SlotReader openReader();
- method public androidx.compose.SlotWriter openWriter();
- method public <T> T! read(kotlin.jvm.functions.Function1<? super androidx.compose.SlotReader,? extends T> block);
- method @org.jetbrains.annotations.TestOnly public void verifyWellFormed();
- method public <T> T! write(kotlin.jvm.functions.Function1<? super androidx.compose.SlotWriter,? extends T> block);
+ method @androidx.compose.InternalComposeApi public java.util.List<java.lang.Integer> groupPathTo(int location);
+ method @androidx.compose.InternalComposeApi public androidx.compose.SlotReader openReader();
+ method @androidx.compose.InternalComposeApi public androidx.compose.SlotWriter openWriter();
+ method @androidx.compose.InternalComposeApi public <T> T! read(kotlin.jvm.functions.Function1<? super androidx.compose.SlotReader,? extends T> block);
+ method @androidx.compose.InternalComposeApi @org.jetbrains.annotations.TestOnly public void verifyWellFormed();
+ method @androidx.compose.InternalComposeApi public <T> T! write(kotlin.jvm.functions.Function1<? super androidx.compose.SlotWriter,? extends T> block);
property public final int size;
field public static final androidx.compose.SlotTable.Companion! Companion;
}
- public static final class SlotTable.Companion {
+ @androidx.compose.InternalComposeApi public static final class SlotTable.Companion {
method public Object getEMPTY();
property public final Object EMPTY;
}
@@ -452,7 +446,7 @@
public final class SlotTableKt {
}
- public final class SlotWriter {
+ @androidx.compose.InternalComposeApi public final class SlotWriter {
method public androidx.compose.Anchor anchor(int index = current);
method public void beginInsert();
method public void close();
@@ -529,11 +523,11 @@
public final class TraceKt {
}
- @kotlin.annotation.MustBeDocumented @kotlin.annotation.Retention(AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets={AnnotationTarget.TYPE, AnnotationTarget.TYPE_PARAMETER}) public @interface UnionType {
+ @androidx.compose.ExperimentalComposeApi @kotlin.annotation.MustBeDocumented @kotlin.annotation.Retention(AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets={AnnotationTarget.TYPE, AnnotationTarget.TYPE_PARAMETER}) public @interface UnionType {
method public abstract Class<?>[] types();
}
- @kotlin.annotation.MustBeDocumented @kotlin.annotation.Retention(AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=AnnotationTarget.FUNCTION) public @interface Untracked {
+ @androidx.compose.ExperimentalComposeApi @kotlin.annotation.MustBeDocumented @kotlin.annotation.Retention(AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=AnnotationTarget.FUNCTION) public @interface Untracked {
}
}
@@ -672,7 +666,7 @@
package androidx.compose.internal {
- @androidx.compose.Stable public final class RestartableFunction<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17, P18, R> implements kotlin.jvm.functions.Function10<P1,P2,P3,P4,P5,P6,P7,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function11<P1,P2,P3,P4,P5,P6,P7,P8,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function12<P1,P2,P3,P4,P5,P6,P7,P8,P9,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function13<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function14<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function15<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function16<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function17<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13,P14,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function18<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13,P14,P15,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function20<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13,P14,P15,P16,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function21<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13,P14,P15,P16,P17,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function22<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13,P14,P15,P16,P17,P18,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function3<androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function4<P1,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function5<P1,P2,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function6<P1,P2,P3,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function7<P1,P2,P3,P4,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function8<P1,P2,P3,P4,P5,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function9<P1,P2,P3,P4,P5,P6,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> {
+ @androidx.compose.ComposeCompilerApi @androidx.compose.Stable public final class RestartableFunction<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17, P18, R> implements kotlin.jvm.functions.Function10<P1,P2,P3,P4,P5,P6,P7,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function11<P1,P2,P3,P4,P5,P6,P7,P8,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function12<P1,P2,P3,P4,P5,P6,P7,P8,P9,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function13<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function14<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function15<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function16<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function17<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13,P14,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function18<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13,P14,P15,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function20<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13,P14,P15,P16,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function21<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13,P14,P15,P16,P17,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function22<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13,P14,P15,P16,P17,P18,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function3<androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function4<P1,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function5<P1,P2,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function6<P1,P2,P3,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function7<P1,P2,P3,P4,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function8<P1,P2,P3,P4,P5,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function9<P1,P2,P3,P4,P5,P6,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> {
ctor public RestartableFunction(int key, boolean tracked);
method public int getKey();
method public operator R! invoke(androidx.compose.Composer<?> c, int k, int changed);
@@ -698,11 +692,11 @@
}
public final class RestartableFunctionKt {
- method public static androidx.compose.internal.RestartableFunction<java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object> restartableFunction(androidx.compose.Composer<?> composer, int key, boolean tracked, Object block);
- method public static androidx.compose.internal.RestartableFunction<java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object> restartableFunctionInstance(int key, boolean tracked, Object block);
+ method @androidx.compose.ComposeCompilerApi public static androidx.compose.internal.RestartableFunction<java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object> restartableFunction(androidx.compose.Composer<?> composer, int key, boolean tracked, Object block);
+ method @androidx.compose.ComposeCompilerApi public static androidx.compose.internal.RestartableFunction<java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object> restartableFunctionInstance(int key, boolean tracked, Object block);
}
- @androidx.compose.Stable public final class RestartableFunctionN<R> implements kotlin.jvm.functions.FunctionN<R> {
+ @androidx.compose.ComposeCompilerApi @androidx.compose.Stable public final class RestartableFunctionN<R> implements kotlin.jvm.functions.FunctionN<R> {
ctor public RestartableFunctionN(int key, boolean tracked, int arity);
method public int getArity();
method public int getKey();
@@ -711,8 +705,8 @@
}
public final class RestartableFunctionNKt {
- method public static androidx.compose.internal.RestartableFunctionN<?> restartableFunctionN(androidx.compose.Composer<?> composer, int key, boolean tracked, int arity, Object block);
- method public static androidx.compose.internal.RestartableFunctionN<?> restartableFunctionNInstance(int key, boolean tracked, int arity, Object block);
+ method @androidx.compose.ComposeCompilerApi public static androidx.compose.internal.RestartableFunctionN<?> restartableFunctionN(androidx.compose.Composer<?> composer, int key, boolean tracked, int arity, Object block);
+ method @androidx.compose.ComposeCompilerApi public static androidx.compose.internal.RestartableFunctionN<?> restartableFunctionNInstance(int key, boolean tracked, int arity, Object block);
}
}
diff --git a/compose/compose-runtime/api/public_plus_experimental_current.txt b/compose/compose-runtime/api/public_plus_experimental_current.txt
index 6bf9d77..8026f0c 100644
--- a/compose/compose-runtime/api/public_plus_experimental_current.txt
+++ b/compose/compose-runtime/api/public_plus_experimental_current.txt
@@ -18,7 +18,7 @@
method public static <T> androidx.compose.ProvidableAmbient<T> staticAmbientOf(kotlin.jvm.functions.Function0<? extends T>? defaultFactory = null);
}
- public final class Anchor {
+ @androidx.compose.InternalComposeApi public final class Anchor {
ctor public Anchor(internal int loc);
method public boolean getValid();
method public int location(androidx.compose.SlotTable slots);
@@ -46,7 +46,7 @@
property public final androidx.compose.AndroidUiDispatcher Main;
}
- public final class Applier<N> {
+ @androidx.compose.ExperimentalComposeApi public final class Applier<N> {
ctor public Applier(N! root, androidx.compose.ApplyAdapter<N> adapter);
method public void down(N? node);
method public N! getCurrent();
@@ -58,7 +58,7 @@
property public final N! current;
}
- public interface ApplyAdapter<N> {
+ @androidx.compose.ExperimentalComposeApi public interface ApplyAdapter<N> {
method public void end(N?, N? instance, N? parent);
method public void insertAt(N?, int index, N? instance);
method public void move(N?, int from, int to, int count);
@@ -96,6 +96,9 @@
method public abstract boolean restartable() default true;
}
+ @kotlin.RequiresOptIn(level=RequiresOptIn.Level.WARNING, message="This API is intended to be targeted by the Compose Compiler Plugin and not called " + "directly.") @kotlin.annotation.Target(allowedTargets={AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY, AnnotationTarget.TYPEALIAS}) public @interface ComposeCompilerApi {
+ }
+
public final class ComposeKt {
method @androidx.compose.Stable public static kotlin.jvm.functions.Function0<kotlin.Unit> emptyContent();
method public static inline kotlin.jvm.functions.Function0<kotlin.Unit> orEmpty(kotlin.jvm.functions.Function0<kotlin.Unit>?);
@@ -103,55 +106,44 @@
public class Composer<N> {
ctor public Composer(androidx.compose.SlotTable slotTable, androidx.compose.Applier<N> applier, androidx.compose.Recomposer recomposer);
- method public final void abortRoot();
- method public final <V, T> void apply(V? value, kotlin.jvm.functions.Function2<? super T,? super V,kotlin.Unit> block);
- method public final void applyChanges();
- method public final androidx.compose.CompositionReference buildReference();
+ method @androidx.compose.InternalComposeApi public final void applyChanges();
method @Deprecated public final inline void call(Object key, kotlin.jvm.functions.Function1<? super androidx.compose.ComposerValidator,java.lang.Boolean> invalid, kotlin.jvm.functions.Function0<kotlin.Unit> block);
- method public final boolean changed(Object? value);
- method public final boolean changed(char value);
- method public final boolean changed(byte value);
- method public final boolean changed(short value);
- method public final boolean changed(boolean value);
- method public final boolean changed(float value);
- method public final boolean changed(long value);
- method public final boolean changed(double value);
- method public final boolean changed(int value);
- method public final void collectKeySourceInformation();
+ method @androidx.compose.ComposeCompilerApi public final boolean changed(Object? value);
+ method @androidx.compose.ComposeCompilerApi public final boolean changed(char value);
+ method @androidx.compose.ComposeCompilerApi public final boolean changed(byte value);
+ method @androidx.compose.ComposeCompilerApi public final boolean changed(short value);
+ method @androidx.compose.ComposeCompilerApi public final boolean changed(boolean value);
+ method @androidx.compose.ComposeCompilerApi public final boolean changed(float value);
+ method @androidx.compose.ComposeCompilerApi public final boolean changed(long value);
+ method @androidx.compose.ComposeCompilerApi public final boolean changed(double value);
+ method @androidx.compose.ComposeCompilerApi public final boolean changed(int value);
+ method @androidx.compose.InternalComposeApi public final void collectKeySourceInformation();
method protected final void composeRoot(kotlin.jvm.functions.Function0<kotlin.Unit> block);
- method public final <T extends N> void createNode(kotlin.jvm.functions.Function0<? extends T> factory);
- method public final <T extends N> void emitNode(kotlin.jvm.functions.Function0<? extends T> factory);
- method public final void emitNode(N? node);
- method public final void endDefaults();
- method public final void endGroup();
- method public final void endMovableGroup();
- method public final void endNode();
- method public final void endReplaceableGroup();
- method public final androidx.compose.ScopeUpdateScope? endRestartGroup();
- method public final void endRoot();
- method public final int getChangeCount();
+ method @androidx.compose.ComposeCompilerApi public final <T extends N> void createNode(kotlin.jvm.functions.Function0<? extends T> factory);
+ method @androidx.compose.ComposeCompilerApi public final <T extends N> void emitNode(kotlin.jvm.functions.Function0<? extends T> factory);
+ method @androidx.compose.ComposeCompilerApi public final void emitNode(N? node);
+ method @androidx.compose.ComposeCompilerApi public final void endDefaults();
+ method @androidx.compose.ComposeCompilerApi public final void endMovableGroup();
+ method @androidx.compose.ComposeCompilerApi public final void endNode();
+ method @androidx.compose.ComposeCompilerApi public final void endReplaceableGroup();
+ method @androidx.compose.ComposeCompilerApi public final androidx.compose.ScopeUpdateScope? endRestartGroup();
method public final int getCurrentCompoundKeyHash();
method public final boolean getDefaultsInvalid();
method public final boolean getInserting();
method public final androidx.compose.Recomposer getRecomposer();
method public final boolean getSkipping();
method public final androidx.compose.SlotTable getSlotTable();
- method public final Object joinKey(Object? left, Object? right);
- method public final Object? nextSlot();
- method public final boolean recompose();
- method public final void skipCurrentGroup();
- method public final void skipToGroupEnd();
- method public final void startDefaults();
- method public final void startGroup(int key);
- method public final void startGroup(int key, Object? dataKey);
- method public final void startMovableGroup(int key, Object? dataKey);
- method public final void startNode(Object key);
- method public final void startReplaceableGroup(int key);
- method public final void startRestartGroup(int key);
- method public final void startRoot();
- method public final void updateValue(Object? value);
- method public final N! useNode();
- property public final int changeCount;
+ method @androidx.compose.ComposeCompilerApi public final Object joinKey(Object? left, Object? right);
+ method @androidx.compose.ComposeCompilerApi public final Object? nextSlot();
+ method @androidx.compose.InternalComposeApi public final boolean recompose();
+ method @androidx.compose.ComposeCompilerApi public final void skipCurrentGroup();
+ method @androidx.compose.ComposeCompilerApi public final void skipToGroupEnd();
+ method @androidx.compose.ComposeCompilerApi public final void startDefaults();
+ method @androidx.compose.ComposeCompilerApi public final void startMovableGroup(int key, Object? dataKey);
+ method @androidx.compose.ComposeCompilerApi public final void startNode(Object key);
+ method @androidx.compose.ComposeCompilerApi public final void startReplaceableGroup(int key);
+ method @androidx.compose.ComposeCompilerApi public final void startRestartGroup(int key);
+ method @androidx.compose.ComposeCompilerApi public final N! useNode();
property public final int currentCompoundKeyHash;
property public final boolean defaultsInvalid;
property public final boolean inserting;
@@ -159,7 +151,6 @@
}
public final class ComposerKt {
- method public static inline <N, T> T! cache(androidx.compose.Composer<N>, boolean valid = true, kotlin.jvm.functions.Function0<? extends T> block);
method public static inline <T> T! escapeCompose(kotlin.jvm.functions.Function1<? super androidx.compose.NullCompilationScope,? extends T> block);
method public static androidx.compose.Composer<?> getCurrentComposer();
}
@@ -174,9 +165,9 @@
method public inline <reified V> void update(V? value, kotlin.jvm.functions.Function2<? super T,? super V,? extends kotlin.Unit> block);
}
- public interface ComposerValidator {
- method public boolean changed(int value);
- method public <T> boolean changed(T? value);
+ @Deprecated public interface ComposerValidator {
+ method @Deprecated public boolean changed(int value);
+ method @Deprecated public <T> boolean changed(T? value);
}
public interface Composition {
@@ -241,6 +232,9 @@
public final class ExpectKt {
}
+ @kotlin.RequiresOptIn(level=RequiresOptIn.Level.ERROR, message="This is an experimental API for Compose and is likely to change before becoming " + "stable.") @kotlin.annotation.Target(allowedTargets={AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY}) public @interface ExperimentalComposeApi {
+ }
+
public final class FlowAdapterKt {
method @androidx.compose.Composable @kotlinx.coroutines.ExperimentalCoroutinesApi public static inline <T> androidx.compose.State<T> collectAsState(kotlinx.coroutines.flow.StateFlow<? extends T>, kotlin.coroutines.CoroutineContext context = Dispatchers.Main);
method @Deprecated @androidx.compose.Composable public static inline <T> androidx.compose.State<T> collectAsState(kotlinx.coroutines.flow.Flow<? extends T>, kotlin.coroutines.CoroutineContext context = Dispatchers.Main);
@@ -263,12 +257,12 @@
}
public final class JoinedKeyKt {
- method public static boolean isJoinedKey(Object? key);
- method public static Object? joinedKeyLeft(Object? key);
- method public static Object? joinedKeyRight(Object? key);
+ method @androidx.compose.InternalComposeApi public static boolean isJoinedKey(Object? key);
+ method @androidx.compose.InternalComposeApi public static Object? joinedKeyLeft(Object? key);
+ method @androidx.compose.InternalComposeApi public static Object? joinedKeyRight(Object? key);
}
- public final class KeyInfo {
+ @androidx.compose.InternalComposeApi public final class KeyInfo {
method public Object? getDataKey();
method public int getIndex();
method public int getKey();
@@ -281,7 +275,7 @@
}
public final class KeySourceInfoKt {
- method public static String? keySourceInfoOf(Object key);
+ method @androidx.compose.InternalComposeApi public static String? keySourceInfoOf(Object key);
}
@androidx.compose.Stable public interface MutableState<T> extends androidx.compose.State<T> {
@@ -368,11 +362,11 @@
method @androidx.compose.Composable public static inline <V> V! remember(Object![]? inputs, kotlin.jvm.functions.Function0<? extends V> block);
}
- public interface ScopeUpdateScope {
+ @androidx.compose.ComposeCompilerApi public interface ScopeUpdateScope {
method public void updateScope(kotlin.jvm.functions.Function3<? super androidx.compose.Composer<?>,? super java.lang.Integer,? super java.lang.Integer,kotlin.Unit> block);
}
- public final class SlotReader {
+ @androidx.compose.InternalComposeApi public final class SlotReader {
ctor public SlotReader(androidx.compose.SlotTable table);
method public void beginEmpty();
method public void close();
@@ -434,17 +428,17 @@
ctor public SlotTable(internal Object![] slots);
ctor public SlotTable();
method public int getSize();
- method public java.util.List<java.lang.Integer> groupPathTo(int location);
- method public androidx.compose.SlotReader openReader();
- method public androidx.compose.SlotWriter openWriter();
- method public <T> T! read(kotlin.jvm.functions.Function1<? super androidx.compose.SlotReader,? extends T> block);
- method @org.jetbrains.annotations.TestOnly public void verifyWellFormed();
- method public <T> T! write(kotlin.jvm.functions.Function1<? super androidx.compose.SlotWriter,? extends T> block);
+ method @androidx.compose.InternalComposeApi public java.util.List<java.lang.Integer> groupPathTo(int location);
+ method @androidx.compose.InternalComposeApi public androidx.compose.SlotReader openReader();
+ method @androidx.compose.InternalComposeApi public androidx.compose.SlotWriter openWriter();
+ method @androidx.compose.InternalComposeApi public <T> T! read(kotlin.jvm.functions.Function1<? super androidx.compose.SlotReader,? extends T> block);
+ method @androidx.compose.InternalComposeApi @org.jetbrains.annotations.TestOnly public void verifyWellFormed();
+ method @androidx.compose.InternalComposeApi public <T> T! write(kotlin.jvm.functions.Function1<? super androidx.compose.SlotWriter,? extends T> block);
property public final int size;
field public static final androidx.compose.SlotTable.Companion! Companion;
}
- public static final class SlotTable.Companion {
+ @androidx.compose.InternalComposeApi public static final class SlotTable.Companion {
method public Object getEMPTY();
property public final Object EMPTY;
}
@@ -452,7 +446,7 @@
public final class SlotTableKt {
}
- public final class SlotWriter {
+ @androidx.compose.InternalComposeApi public final class SlotWriter {
method public androidx.compose.Anchor anchor(int index = current);
method public void beginInsert();
method public void close();
@@ -529,11 +523,11 @@
public final class TraceKt {
}
- @kotlin.annotation.MustBeDocumented @kotlin.annotation.Retention(AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets={AnnotationTarget.TYPE, AnnotationTarget.TYPE_PARAMETER}) public @interface UnionType {
+ @androidx.compose.ExperimentalComposeApi @kotlin.annotation.MustBeDocumented @kotlin.annotation.Retention(AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets={AnnotationTarget.TYPE, AnnotationTarget.TYPE_PARAMETER}) public @interface UnionType {
method public abstract Class<?>[] types();
}
- @kotlin.annotation.MustBeDocumented @kotlin.annotation.Retention(AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=AnnotationTarget.FUNCTION) public @interface Untracked {
+ @androidx.compose.ExperimentalComposeApi @kotlin.annotation.MustBeDocumented @kotlin.annotation.Retention(AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=AnnotationTarget.FUNCTION) public @interface Untracked {
}
}
@@ -672,7 +666,7 @@
package androidx.compose.internal {
- @androidx.compose.Stable public final class RestartableFunction<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17, P18, R> implements kotlin.jvm.functions.Function10<P1,P2,P3,P4,P5,P6,P7,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function11<P1,P2,P3,P4,P5,P6,P7,P8,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function12<P1,P2,P3,P4,P5,P6,P7,P8,P9,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function13<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function14<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function15<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function16<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function17<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13,P14,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function18<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13,P14,P15,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function20<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13,P14,P15,P16,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function21<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13,P14,P15,P16,P17,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function22<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13,P14,P15,P16,P17,P18,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function3<androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function4<P1,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function5<P1,P2,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function6<P1,P2,P3,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function7<P1,P2,P3,P4,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function8<P1,P2,P3,P4,P5,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function9<P1,P2,P3,P4,P5,P6,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> {
+ @androidx.compose.ComposeCompilerApi @androidx.compose.Stable public final class RestartableFunction<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17, P18, R> implements kotlin.jvm.functions.Function10<P1,P2,P3,P4,P5,P6,P7,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function11<P1,P2,P3,P4,P5,P6,P7,P8,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function12<P1,P2,P3,P4,P5,P6,P7,P8,P9,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function13<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function14<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function15<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function16<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function17<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13,P14,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function18<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13,P14,P15,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function20<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13,P14,P15,P16,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function21<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13,P14,P15,P16,P17,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function22<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13,P14,P15,P16,P17,P18,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function3<androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function4<P1,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function5<P1,P2,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function6<P1,P2,P3,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function7<P1,P2,P3,P4,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function8<P1,P2,P3,P4,P5,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function9<P1,P2,P3,P4,P5,P6,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> {
ctor public RestartableFunction(int key, boolean tracked);
method public int getKey();
method public operator R! invoke(androidx.compose.Composer<?> c, int k, int changed);
@@ -698,11 +692,11 @@
}
public final class RestartableFunctionKt {
- method public static androidx.compose.internal.RestartableFunction<java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object> restartableFunction(androidx.compose.Composer<?> composer, int key, boolean tracked, Object block);
- method public static androidx.compose.internal.RestartableFunction<java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object> restartableFunctionInstance(int key, boolean tracked, Object block);
+ method @androidx.compose.ComposeCompilerApi public static androidx.compose.internal.RestartableFunction<java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object> restartableFunction(androidx.compose.Composer<?> composer, int key, boolean tracked, Object block);
+ method @androidx.compose.ComposeCompilerApi public static androidx.compose.internal.RestartableFunction<java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object> restartableFunctionInstance(int key, boolean tracked, Object block);
}
- @androidx.compose.Stable public final class RestartableFunctionN<R> implements kotlin.jvm.functions.FunctionN<R> {
+ @androidx.compose.ComposeCompilerApi @androidx.compose.Stable public final class RestartableFunctionN<R> implements kotlin.jvm.functions.FunctionN<R> {
ctor public RestartableFunctionN(int key, boolean tracked, int arity);
method public int getArity();
method public int getKey();
@@ -711,8 +705,8 @@
}
public final class RestartableFunctionNKt {
- method public static androidx.compose.internal.RestartableFunctionN<?> restartableFunctionN(androidx.compose.Composer<?> composer, int key, boolean tracked, int arity, Object block);
- method public static androidx.compose.internal.RestartableFunctionN<?> restartableFunctionNInstance(int key, boolean tracked, int arity, Object block);
+ method @androidx.compose.ComposeCompilerApi public static androidx.compose.internal.RestartableFunctionN<?> restartableFunctionN(androidx.compose.Composer<?> composer, int key, boolean tracked, int arity, Object block);
+ method @androidx.compose.ComposeCompilerApi public static androidx.compose.internal.RestartableFunctionN<?> restartableFunctionNInstance(int key, boolean tracked, int arity, Object block);
}
}
diff --git a/compose/compose-runtime/api/restricted_0.1.0-dev14.txt b/compose/compose-runtime/api/restricted_0.1.0-dev14.txt
index be79aa1..cb54f3a 100644
--- a/compose/compose-runtime/api/restricted_0.1.0-dev14.txt
+++ b/compose/compose-runtime/api/restricted_0.1.0-dev14.txt
@@ -18,7 +18,7 @@
method public static <T> androidx.compose.ProvidableAmbient<T> staticAmbientOf(kotlin.jvm.functions.Function0<? extends T>? defaultFactory = null);
}
- public final class Anchor {
+ @androidx.compose.InternalComposeApi public final class Anchor {
ctor public Anchor(internal int loc);
method public boolean getValid();
method public int location(androidx.compose.SlotTable slots);
@@ -46,7 +46,7 @@
property public final androidx.compose.AndroidUiDispatcher Main;
}
- public final class Applier<N> {
+ @androidx.compose.ExperimentalComposeApi public final class Applier<N> {
ctor public Applier(N! root, androidx.compose.ApplyAdapter<N> adapter);
method public void down(N? node);
method public N! getCurrent();
@@ -58,7 +58,7 @@
property public final N! current;
}
- public interface ApplyAdapter<N> {
+ @androidx.compose.ExperimentalComposeApi public interface ApplyAdapter<N> {
method public void end(N?, N? instance, N? parent);
method public void insertAt(N?, int index, N? instance);
method public void move(N?, int from, int to, int count);
@@ -96,6 +96,9 @@
method public abstract boolean restartable() default true;
}
+ @kotlin.RequiresOptIn(level=RequiresOptIn.Level.WARNING, message="This API is intended to be targeted by the Compose Compiler Plugin and not called " + "directly.") @kotlin.annotation.Target(allowedTargets={AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY, AnnotationTarget.TYPEALIAS}) public @interface ComposeCompilerApi {
+ }
+
public final class ComposeKt {
method @androidx.compose.Stable public static kotlin.jvm.functions.Function0<kotlin.Unit> emptyContent();
method public static inline kotlin.jvm.functions.Function0<kotlin.Unit> orEmpty(kotlin.jvm.functions.Function0<kotlin.Unit>?);
@@ -103,56 +106,46 @@
public class Composer<N> {
ctor public Composer(androidx.compose.SlotTable slotTable, androidx.compose.Applier<N> applier, androidx.compose.Recomposer recomposer);
- method public final void abortRoot();
- method public final <V, T> void apply(V? value, kotlin.jvm.functions.Function2<? super T,? super V,kotlin.Unit> block);
- method public final void applyChanges();
- method public final androidx.compose.CompositionReference buildReference();
+ method @androidx.compose.InternalComposeApi public final void applyChanges();
method @Deprecated public final inline void call(Object key, kotlin.jvm.functions.Function1<? super androidx.compose.ComposerValidator,java.lang.Boolean> invalid, kotlin.jvm.functions.Function0<kotlin.Unit> block);
- method public final boolean changed(Object? value);
- method public final boolean changed(char value);
- method public final boolean changed(byte value);
- method public final boolean changed(short value);
- method public final boolean changed(boolean value);
- method public final boolean changed(float value);
- method public final boolean changed(long value);
- method public final boolean changed(double value);
- method public final boolean changed(int value);
- method public final void collectKeySourceInformation();
+ method @androidx.compose.ComposeCompilerApi public final boolean changed(Object? value);
+ method @androidx.compose.ComposeCompilerApi public final boolean changed(char value);
+ method @androidx.compose.ComposeCompilerApi public final boolean changed(byte value);
+ method @androidx.compose.ComposeCompilerApi public final boolean changed(short value);
+ method @androidx.compose.ComposeCompilerApi public final boolean changed(boolean value);
+ method @androidx.compose.ComposeCompilerApi public final boolean changed(float value);
+ method @androidx.compose.ComposeCompilerApi public final boolean changed(long value);
+ method @androidx.compose.ComposeCompilerApi public final boolean changed(double value);
+ method @androidx.compose.ComposeCompilerApi public final boolean changed(int value);
+ method @androidx.compose.InternalComposeApi public final void collectKeySourceInformation();
method protected final void composeRoot(kotlin.jvm.functions.Function0<kotlin.Unit> block);
method @kotlin.PublishedApi internal final <T> T! consume(androidx.compose.Ambient<T> key);
- method public final <T extends N> void createNode(kotlin.jvm.functions.Function0<? extends T> factory);
- method public final <T extends N> void emitNode(kotlin.jvm.functions.Function0<? extends T> factory);
- method public final void emitNode(N? node);
- method public final void endDefaults();
- method public final void endGroup();
- method public final void endMovableGroup();
- method public final void endNode();
- method public final void endReplaceableGroup();
- method public final androidx.compose.ScopeUpdateScope? endRestartGroup();
- method public final void endRoot();
- method public final int getChangeCount();
+ method @androidx.compose.ComposeCompilerApi public final <T extends N> void createNode(kotlin.jvm.functions.Function0<? extends T> factory);
+ method @androidx.compose.ComposeCompilerApi public final <T extends N> void emitNode(kotlin.jvm.functions.Function0<? extends T> factory);
+ method @androidx.compose.ComposeCompilerApi public final void emitNode(N? node);
+ method @androidx.compose.ComposeCompilerApi public final void endDefaults();
+ method @androidx.compose.ComposeCompilerApi public final void endMovableGroup();
+ method @androidx.compose.ComposeCompilerApi public final void endNode();
+ method @androidx.compose.ComposeCompilerApi public final void endReplaceableGroup();
+ method @androidx.compose.ComposeCompilerApi public final androidx.compose.ScopeUpdateScope? endRestartGroup();
method public final int getCurrentCompoundKeyHash();
method public final boolean getDefaultsInvalid();
method public final boolean getInserting();
method public final androidx.compose.Recomposer getRecomposer();
method public final boolean getSkipping();
method public final androidx.compose.SlotTable getSlotTable();
- method public final Object joinKey(Object? left, Object? right);
- method public final Object? nextSlot();
- method public final boolean recompose();
- method public final void skipCurrentGroup();
- method public final void skipToGroupEnd();
- method public final void startDefaults();
- method public final void startGroup(int key);
- method public final void startGroup(int key, Object? dataKey);
- method public final void startMovableGroup(int key, Object? dataKey);
- method public final void startNode(Object key);
- method public final void startReplaceableGroup(int key);
- method public final void startRestartGroup(int key);
- method public final void startRoot();
- method public final void updateValue(Object? value);
- method public final N! useNode();
- property public final int changeCount;
+ method @androidx.compose.ComposeCompilerApi public final Object joinKey(Object? left, Object? right);
+ method @androidx.compose.ComposeCompilerApi public final Object? nextSlot();
+ method @androidx.compose.InternalComposeApi public final boolean recompose();
+ method @androidx.compose.ComposeCompilerApi public final void skipCurrentGroup();
+ method @androidx.compose.ComposeCompilerApi public final void skipToGroupEnd();
+ method @androidx.compose.ComposeCompilerApi public final void startDefaults();
+ method @androidx.compose.ComposeCompilerApi public final void startMovableGroup(int key, Object? dataKey);
+ method @androidx.compose.ComposeCompilerApi public final void startNode(Object key);
+ method @androidx.compose.ComposeCompilerApi public final void startReplaceableGroup(int key);
+ method @androidx.compose.ComposeCompilerApi public final void startRestartGroup(int key);
+ method @kotlin.PublishedApi internal final void updateValue(Object? value);
+ method @androidx.compose.ComposeCompilerApi public final N! useNode();
property public final int currentCompoundKeyHash;
property public final boolean defaultsInvalid;
property public final boolean inserting;
@@ -160,7 +153,7 @@
}
public final class ComposerKt {
- method public static inline <N, T> T! cache(androidx.compose.Composer<N>, boolean valid = true, kotlin.jvm.functions.Function0<? extends T> block);
+ method @kotlin.PublishedApi internal static inline <N, T> T! cache(androidx.compose.Composer<N>, boolean valid = true, kotlin.jvm.functions.Function0<? extends T> block);
method public static inline <T> T! escapeCompose(kotlin.jvm.functions.Function1<? super androidx.compose.NullCompilationScope,? extends T> block);
method public static androidx.compose.Composer<?> getCurrentComposer();
field @kotlin.PublishedApi internal static final androidx.compose.OpaqueKey ambientMap;
@@ -187,9 +180,9 @@
method public inline <reified V> void update(V? value, kotlin.jvm.functions.Function2<? super T,? super V,? extends kotlin.Unit> block);
}
- public interface ComposerValidator {
- method public boolean changed(int value);
- method public <T> boolean changed(T? value);
+ @Deprecated public interface ComposerValidator {
+ method @Deprecated public boolean changed(int value);
+ method @Deprecated public <T> boolean changed(T? value);
}
public interface Composition {
@@ -254,6 +247,9 @@
public final class ExpectKt {
}
+ @kotlin.RequiresOptIn(level=RequiresOptIn.Level.ERROR, message="This is an experimental API for Compose and is likely to change before becoming " + "stable.") @kotlin.annotation.Target(allowedTargets={AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY}) public @interface ExperimentalComposeApi {
+ }
+
public final class FlowAdapterKt {
method @androidx.compose.Composable @kotlinx.coroutines.ExperimentalCoroutinesApi public static inline <T> androidx.compose.State<T> collectAsState(kotlinx.coroutines.flow.StateFlow<? extends T>, kotlin.coroutines.CoroutineContext context = Dispatchers.Main);
method @Deprecated @androidx.compose.Composable public static inline <T> androidx.compose.State<T> collectAsState(kotlinx.coroutines.flow.Flow<? extends T>, kotlin.coroutines.CoroutineContext context = Dispatchers.Main);
@@ -276,12 +272,12 @@
}
public final class JoinedKeyKt {
- method public static boolean isJoinedKey(Object? key);
- method public static Object? joinedKeyLeft(Object? key);
- method public static Object? joinedKeyRight(Object? key);
+ method @androidx.compose.InternalComposeApi public static boolean isJoinedKey(Object? key);
+ method @androidx.compose.InternalComposeApi public static Object? joinedKeyLeft(Object? key);
+ method @androidx.compose.InternalComposeApi public static Object? joinedKeyRight(Object? key);
}
- public final class KeyInfo {
+ @androidx.compose.InternalComposeApi public final class KeyInfo {
method public Object? getDataKey();
method public int getIndex();
method public int getKey();
@@ -294,7 +290,7 @@
}
public final class KeySourceInfoKt {
- method public static String? keySourceInfoOf(Object key);
+ method @androidx.compose.InternalComposeApi public static String? keySourceInfoOf(Object key);
}
@androidx.compose.Stable public interface MutableState<T> extends androidx.compose.State<T> {
@@ -396,11 +392,11 @@
method @androidx.compose.Composable public static inline <V> V! remember(Object![]? inputs, kotlin.jvm.functions.Function0<? extends V> block);
}
- public interface ScopeUpdateScope {
+ @androidx.compose.ComposeCompilerApi public interface ScopeUpdateScope {
method public void updateScope(kotlin.jvm.functions.Function3<? super androidx.compose.Composer<?>,? super java.lang.Integer,? super java.lang.Integer,kotlin.Unit> block);
}
- public final class SlotReader {
+ @androidx.compose.InternalComposeApi public final class SlotReader {
ctor public SlotReader(androidx.compose.SlotTable table);
method public void beginEmpty();
method public void close();
@@ -462,17 +458,17 @@
ctor public SlotTable(internal Object![] slots);
ctor public SlotTable();
method public int getSize();
- method public java.util.List<java.lang.Integer> groupPathTo(int location);
- method public androidx.compose.SlotReader openReader();
- method public androidx.compose.SlotWriter openWriter();
- method public <T> T! read(kotlin.jvm.functions.Function1<? super androidx.compose.SlotReader,? extends T> block);
- method @org.jetbrains.annotations.TestOnly public void verifyWellFormed();
- method public <T> T! write(kotlin.jvm.functions.Function1<? super androidx.compose.SlotWriter,? extends T> block);
+ method @androidx.compose.InternalComposeApi public java.util.List<java.lang.Integer> groupPathTo(int location);
+ method @androidx.compose.InternalComposeApi public androidx.compose.SlotReader openReader();
+ method @androidx.compose.InternalComposeApi public androidx.compose.SlotWriter openWriter();
+ method @androidx.compose.InternalComposeApi public <T> T! read(kotlin.jvm.functions.Function1<? super androidx.compose.SlotReader,? extends T> block);
+ method @androidx.compose.InternalComposeApi @org.jetbrains.annotations.TestOnly public void verifyWellFormed();
+ method @androidx.compose.InternalComposeApi public <T> T! write(kotlin.jvm.functions.Function1<? super androidx.compose.SlotWriter,? extends T> block);
property public final int size;
field public static final androidx.compose.SlotTable.Companion! Companion;
}
- public static final class SlotTable.Companion {
+ @androidx.compose.InternalComposeApi public static final class SlotTable.Companion {
method public Object getEMPTY();
property public final Object EMPTY;
}
@@ -481,7 +477,7 @@
field @kotlin.PublishedApi internal static final Object EMPTY;
}
- public final class SlotWriter {
+ @androidx.compose.InternalComposeApi public final class SlotWriter {
method public androidx.compose.Anchor anchor(int index = current);
method public void beginInsert();
method public void close();
@@ -558,11 +554,11 @@
public final class TraceKt {
}
- @kotlin.annotation.MustBeDocumented @kotlin.annotation.Retention(AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets={AnnotationTarget.TYPE, AnnotationTarget.TYPE_PARAMETER}) public @interface UnionType {
+ @androidx.compose.ExperimentalComposeApi @kotlin.annotation.MustBeDocumented @kotlin.annotation.Retention(AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets={AnnotationTarget.TYPE, AnnotationTarget.TYPE_PARAMETER}) public @interface UnionType {
method public abstract Class<?>[] types();
}
- @kotlin.annotation.MustBeDocumented @kotlin.annotation.Retention(AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=AnnotationTarget.FUNCTION) public @interface Untracked {
+ @androidx.compose.ExperimentalComposeApi @kotlin.annotation.MustBeDocumented @kotlin.annotation.Retention(AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=AnnotationTarget.FUNCTION) public @interface Untracked {
}
}
@@ -702,7 +698,7 @@
package androidx.compose.internal {
- @androidx.compose.Stable public final class RestartableFunction<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17, P18, R> implements kotlin.jvm.functions.Function10<P1,P2,P3,P4,P5,P6,P7,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function11<P1,P2,P3,P4,P5,P6,P7,P8,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function12<P1,P2,P3,P4,P5,P6,P7,P8,P9,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function13<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function14<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function15<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function16<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function17<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13,P14,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function18<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13,P14,P15,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function20<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13,P14,P15,P16,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function21<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13,P14,P15,P16,P17,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function22<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13,P14,P15,P16,P17,P18,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function3<androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function4<P1,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function5<P1,P2,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function6<P1,P2,P3,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function7<P1,P2,P3,P4,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function8<P1,P2,P3,P4,P5,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function9<P1,P2,P3,P4,P5,P6,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> {
+ @androidx.compose.ComposeCompilerApi @androidx.compose.Stable public final class RestartableFunction<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17, P18, R> implements kotlin.jvm.functions.Function10<P1,P2,P3,P4,P5,P6,P7,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function11<P1,P2,P3,P4,P5,P6,P7,P8,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function12<P1,P2,P3,P4,P5,P6,P7,P8,P9,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function13<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function14<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function15<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function16<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function17<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13,P14,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function18<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13,P14,P15,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function20<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13,P14,P15,P16,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function21<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13,P14,P15,P16,P17,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function22<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13,P14,P15,P16,P17,P18,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function3<androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function4<P1,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function5<P1,P2,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function6<P1,P2,P3,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function7<P1,P2,P3,P4,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function8<P1,P2,P3,P4,P5,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function9<P1,P2,P3,P4,P5,P6,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> {
ctor public RestartableFunction(int key, boolean tracked);
method public int getKey();
method public operator R! invoke(androidx.compose.Composer<?> c, int k, int changed);
@@ -728,11 +724,11 @@
}
public final class RestartableFunctionKt {
- method public static androidx.compose.internal.RestartableFunction<java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object> restartableFunction(androidx.compose.Composer<?> composer, int key, boolean tracked, Object block);
- method public static androidx.compose.internal.RestartableFunction<java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object> restartableFunctionInstance(int key, boolean tracked, Object block);
+ method @androidx.compose.ComposeCompilerApi public static androidx.compose.internal.RestartableFunction<java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object> restartableFunction(androidx.compose.Composer<?> composer, int key, boolean tracked, Object block);
+ method @androidx.compose.ComposeCompilerApi public static androidx.compose.internal.RestartableFunction<java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object> restartableFunctionInstance(int key, boolean tracked, Object block);
}
- @androidx.compose.Stable public final class RestartableFunctionN<R> implements kotlin.jvm.functions.FunctionN<R> {
+ @androidx.compose.ComposeCompilerApi @androidx.compose.Stable public final class RestartableFunctionN<R> implements kotlin.jvm.functions.FunctionN<R> {
ctor public RestartableFunctionN(int key, boolean tracked, int arity);
method public int getArity();
method public int getKey();
@@ -741,8 +737,8 @@
}
public final class RestartableFunctionNKt {
- method public static androidx.compose.internal.RestartableFunctionN<?> restartableFunctionN(androidx.compose.Composer<?> composer, int key, boolean tracked, int arity, Object block);
- method public static androidx.compose.internal.RestartableFunctionN<?> restartableFunctionNInstance(int key, boolean tracked, int arity, Object block);
+ method @androidx.compose.ComposeCompilerApi public static androidx.compose.internal.RestartableFunctionN<?> restartableFunctionN(androidx.compose.Composer<?> composer, int key, boolean tracked, int arity, Object block);
+ method @androidx.compose.ComposeCompilerApi public static androidx.compose.internal.RestartableFunctionN<?> restartableFunctionNInstance(int key, boolean tracked, int arity, Object block);
}
}
diff --git a/compose/compose-runtime/api/restricted_current.txt b/compose/compose-runtime/api/restricted_current.txt
index be79aa1..cb54f3a 100644
--- a/compose/compose-runtime/api/restricted_current.txt
+++ b/compose/compose-runtime/api/restricted_current.txt
@@ -18,7 +18,7 @@
method public static <T> androidx.compose.ProvidableAmbient<T> staticAmbientOf(kotlin.jvm.functions.Function0<? extends T>? defaultFactory = null);
}
- public final class Anchor {
+ @androidx.compose.InternalComposeApi public final class Anchor {
ctor public Anchor(internal int loc);
method public boolean getValid();
method public int location(androidx.compose.SlotTable slots);
@@ -46,7 +46,7 @@
property public final androidx.compose.AndroidUiDispatcher Main;
}
- public final class Applier<N> {
+ @androidx.compose.ExperimentalComposeApi public final class Applier<N> {
ctor public Applier(N! root, androidx.compose.ApplyAdapter<N> adapter);
method public void down(N? node);
method public N! getCurrent();
@@ -58,7 +58,7 @@
property public final N! current;
}
- public interface ApplyAdapter<N> {
+ @androidx.compose.ExperimentalComposeApi public interface ApplyAdapter<N> {
method public void end(N?, N? instance, N? parent);
method public void insertAt(N?, int index, N? instance);
method public void move(N?, int from, int to, int count);
@@ -96,6 +96,9 @@
method public abstract boolean restartable() default true;
}
+ @kotlin.RequiresOptIn(level=RequiresOptIn.Level.WARNING, message="This API is intended to be targeted by the Compose Compiler Plugin and not called " + "directly.") @kotlin.annotation.Target(allowedTargets={AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY, AnnotationTarget.TYPEALIAS}) public @interface ComposeCompilerApi {
+ }
+
public final class ComposeKt {
method @androidx.compose.Stable public static kotlin.jvm.functions.Function0<kotlin.Unit> emptyContent();
method public static inline kotlin.jvm.functions.Function0<kotlin.Unit> orEmpty(kotlin.jvm.functions.Function0<kotlin.Unit>?);
@@ -103,56 +106,46 @@
public class Composer<N> {
ctor public Composer(androidx.compose.SlotTable slotTable, androidx.compose.Applier<N> applier, androidx.compose.Recomposer recomposer);
- method public final void abortRoot();
- method public final <V, T> void apply(V? value, kotlin.jvm.functions.Function2<? super T,? super V,kotlin.Unit> block);
- method public final void applyChanges();
- method public final androidx.compose.CompositionReference buildReference();
+ method @androidx.compose.InternalComposeApi public final void applyChanges();
method @Deprecated public final inline void call(Object key, kotlin.jvm.functions.Function1<? super androidx.compose.ComposerValidator,java.lang.Boolean> invalid, kotlin.jvm.functions.Function0<kotlin.Unit> block);
- method public final boolean changed(Object? value);
- method public final boolean changed(char value);
- method public final boolean changed(byte value);
- method public final boolean changed(short value);
- method public final boolean changed(boolean value);
- method public final boolean changed(float value);
- method public final boolean changed(long value);
- method public final boolean changed(double value);
- method public final boolean changed(int value);
- method public final void collectKeySourceInformation();
+ method @androidx.compose.ComposeCompilerApi public final boolean changed(Object? value);
+ method @androidx.compose.ComposeCompilerApi public final boolean changed(char value);
+ method @androidx.compose.ComposeCompilerApi public final boolean changed(byte value);
+ method @androidx.compose.ComposeCompilerApi public final boolean changed(short value);
+ method @androidx.compose.ComposeCompilerApi public final boolean changed(boolean value);
+ method @androidx.compose.ComposeCompilerApi public final boolean changed(float value);
+ method @androidx.compose.ComposeCompilerApi public final boolean changed(long value);
+ method @androidx.compose.ComposeCompilerApi public final boolean changed(double value);
+ method @androidx.compose.ComposeCompilerApi public final boolean changed(int value);
+ method @androidx.compose.InternalComposeApi public final void collectKeySourceInformation();
method protected final void composeRoot(kotlin.jvm.functions.Function0<kotlin.Unit> block);
method @kotlin.PublishedApi internal final <T> T! consume(androidx.compose.Ambient<T> key);
- method public final <T extends N> void createNode(kotlin.jvm.functions.Function0<? extends T> factory);
- method public final <T extends N> void emitNode(kotlin.jvm.functions.Function0<? extends T> factory);
- method public final void emitNode(N? node);
- method public final void endDefaults();
- method public final void endGroup();
- method public final void endMovableGroup();
- method public final void endNode();
- method public final void endReplaceableGroup();
- method public final androidx.compose.ScopeUpdateScope? endRestartGroup();
- method public final void endRoot();
- method public final int getChangeCount();
+ method @androidx.compose.ComposeCompilerApi public final <T extends N> void createNode(kotlin.jvm.functions.Function0<? extends T> factory);
+ method @androidx.compose.ComposeCompilerApi public final <T extends N> void emitNode(kotlin.jvm.functions.Function0<? extends T> factory);
+ method @androidx.compose.ComposeCompilerApi public final void emitNode(N? node);
+ method @androidx.compose.ComposeCompilerApi public final void endDefaults();
+ method @androidx.compose.ComposeCompilerApi public final void endMovableGroup();
+ method @androidx.compose.ComposeCompilerApi public final void endNode();
+ method @androidx.compose.ComposeCompilerApi public final void endReplaceableGroup();
+ method @androidx.compose.ComposeCompilerApi public final androidx.compose.ScopeUpdateScope? endRestartGroup();
method public final int getCurrentCompoundKeyHash();
method public final boolean getDefaultsInvalid();
method public final boolean getInserting();
method public final androidx.compose.Recomposer getRecomposer();
method public final boolean getSkipping();
method public final androidx.compose.SlotTable getSlotTable();
- method public final Object joinKey(Object? left, Object? right);
- method public final Object? nextSlot();
- method public final boolean recompose();
- method public final void skipCurrentGroup();
- method public final void skipToGroupEnd();
- method public final void startDefaults();
- method public final void startGroup(int key);
- method public final void startGroup(int key, Object? dataKey);
- method public final void startMovableGroup(int key, Object? dataKey);
- method public final void startNode(Object key);
- method public final void startReplaceableGroup(int key);
- method public final void startRestartGroup(int key);
- method public final void startRoot();
- method public final void updateValue(Object? value);
- method public final N! useNode();
- property public final int changeCount;
+ method @androidx.compose.ComposeCompilerApi public final Object joinKey(Object? left, Object? right);
+ method @androidx.compose.ComposeCompilerApi public final Object? nextSlot();
+ method @androidx.compose.InternalComposeApi public final boolean recompose();
+ method @androidx.compose.ComposeCompilerApi public final void skipCurrentGroup();
+ method @androidx.compose.ComposeCompilerApi public final void skipToGroupEnd();
+ method @androidx.compose.ComposeCompilerApi public final void startDefaults();
+ method @androidx.compose.ComposeCompilerApi public final void startMovableGroup(int key, Object? dataKey);
+ method @androidx.compose.ComposeCompilerApi public final void startNode(Object key);
+ method @androidx.compose.ComposeCompilerApi public final void startReplaceableGroup(int key);
+ method @androidx.compose.ComposeCompilerApi public final void startRestartGroup(int key);
+ method @kotlin.PublishedApi internal final void updateValue(Object? value);
+ method @androidx.compose.ComposeCompilerApi public final N! useNode();
property public final int currentCompoundKeyHash;
property public final boolean defaultsInvalid;
property public final boolean inserting;
@@ -160,7 +153,7 @@
}
public final class ComposerKt {
- method public static inline <N, T> T! cache(androidx.compose.Composer<N>, boolean valid = true, kotlin.jvm.functions.Function0<? extends T> block);
+ method @kotlin.PublishedApi internal static inline <N, T> T! cache(androidx.compose.Composer<N>, boolean valid = true, kotlin.jvm.functions.Function0<? extends T> block);
method public static inline <T> T! escapeCompose(kotlin.jvm.functions.Function1<? super androidx.compose.NullCompilationScope,? extends T> block);
method public static androidx.compose.Composer<?> getCurrentComposer();
field @kotlin.PublishedApi internal static final androidx.compose.OpaqueKey ambientMap;
@@ -187,9 +180,9 @@
method public inline <reified V> void update(V? value, kotlin.jvm.functions.Function2<? super T,? super V,? extends kotlin.Unit> block);
}
- public interface ComposerValidator {
- method public boolean changed(int value);
- method public <T> boolean changed(T? value);
+ @Deprecated public interface ComposerValidator {
+ method @Deprecated public boolean changed(int value);
+ method @Deprecated public <T> boolean changed(T? value);
}
public interface Composition {
@@ -254,6 +247,9 @@
public final class ExpectKt {
}
+ @kotlin.RequiresOptIn(level=RequiresOptIn.Level.ERROR, message="This is an experimental API for Compose and is likely to change before becoming " + "stable.") @kotlin.annotation.Target(allowedTargets={AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY}) public @interface ExperimentalComposeApi {
+ }
+
public final class FlowAdapterKt {
method @androidx.compose.Composable @kotlinx.coroutines.ExperimentalCoroutinesApi public static inline <T> androidx.compose.State<T> collectAsState(kotlinx.coroutines.flow.StateFlow<? extends T>, kotlin.coroutines.CoroutineContext context = Dispatchers.Main);
method @Deprecated @androidx.compose.Composable public static inline <T> androidx.compose.State<T> collectAsState(kotlinx.coroutines.flow.Flow<? extends T>, kotlin.coroutines.CoroutineContext context = Dispatchers.Main);
@@ -276,12 +272,12 @@
}
public final class JoinedKeyKt {
- method public static boolean isJoinedKey(Object? key);
- method public static Object? joinedKeyLeft(Object? key);
- method public static Object? joinedKeyRight(Object? key);
+ method @androidx.compose.InternalComposeApi public static boolean isJoinedKey(Object? key);
+ method @androidx.compose.InternalComposeApi public static Object? joinedKeyLeft(Object? key);
+ method @androidx.compose.InternalComposeApi public static Object? joinedKeyRight(Object? key);
}
- public final class KeyInfo {
+ @androidx.compose.InternalComposeApi public final class KeyInfo {
method public Object? getDataKey();
method public int getIndex();
method public int getKey();
@@ -294,7 +290,7 @@
}
public final class KeySourceInfoKt {
- method public static String? keySourceInfoOf(Object key);
+ method @androidx.compose.InternalComposeApi public static String? keySourceInfoOf(Object key);
}
@androidx.compose.Stable public interface MutableState<T> extends androidx.compose.State<T> {
@@ -396,11 +392,11 @@
method @androidx.compose.Composable public static inline <V> V! remember(Object![]? inputs, kotlin.jvm.functions.Function0<? extends V> block);
}
- public interface ScopeUpdateScope {
+ @androidx.compose.ComposeCompilerApi public interface ScopeUpdateScope {
method public void updateScope(kotlin.jvm.functions.Function3<? super androidx.compose.Composer<?>,? super java.lang.Integer,? super java.lang.Integer,kotlin.Unit> block);
}
- public final class SlotReader {
+ @androidx.compose.InternalComposeApi public final class SlotReader {
ctor public SlotReader(androidx.compose.SlotTable table);
method public void beginEmpty();
method public void close();
@@ -462,17 +458,17 @@
ctor public SlotTable(internal Object![] slots);
ctor public SlotTable();
method public int getSize();
- method public java.util.List<java.lang.Integer> groupPathTo(int location);
- method public androidx.compose.SlotReader openReader();
- method public androidx.compose.SlotWriter openWriter();
- method public <T> T! read(kotlin.jvm.functions.Function1<? super androidx.compose.SlotReader,? extends T> block);
- method @org.jetbrains.annotations.TestOnly public void verifyWellFormed();
- method public <T> T! write(kotlin.jvm.functions.Function1<? super androidx.compose.SlotWriter,? extends T> block);
+ method @androidx.compose.InternalComposeApi public java.util.List<java.lang.Integer> groupPathTo(int location);
+ method @androidx.compose.InternalComposeApi public androidx.compose.SlotReader openReader();
+ method @androidx.compose.InternalComposeApi public androidx.compose.SlotWriter openWriter();
+ method @androidx.compose.InternalComposeApi public <T> T! read(kotlin.jvm.functions.Function1<? super androidx.compose.SlotReader,? extends T> block);
+ method @androidx.compose.InternalComposeApi @org.jetbrains.annotations.TestOnly public void verifyWellFormed();
+ method @androidx.compose.InternalComposeApi public <T> T! write(kotlin.jvm.functions.Function1<? super androidx.compose.SlotWriter,? extends T> block);
property public final int size;
field public static final androidx.compose.SlotTable.Companion! Companion;
}
- public static final class SlotTable.Companion {
+ @androidx.compose.InternalComposeApi public static final class SlotTable.Companion {
method public Object getEMPTY();
property public final Object EMPTY;
}
@@ -481,7 +477,7 @@
field @kotlin.PublishedApi internal static final Object EMPTY;
}
- public final class SlotWriter {
+ @androidx.compose.InternalComposeApi public final class SlotWriter {
method public androidx.compose.Anchor anchor(int index = current);
method public void beginInsert();
method public void close();
@@ -558,11 +554,11 @@
public final class TraceKt {
}
- @kotlin.annotation.MustBeDocumented @kotlin.annotation.Retention(AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets={AnnotationTarget.TYPE, AnnotationTarget.TYPE_PARAMETER}) public @interface UnionType {
+ @androidx.compose.ExperimentalComposeApi @kotlin.annotation.MustBeDocumented @kotlin.annotation.Retention(AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets={AnnotationTarget.TYPE, AnnotationTarget.TYPE_PARAMETER}) public @interface UnionType {
method public abstract Class<?>[] types();
}
- @kotlin.annotation.MustBeDocumented @kotlin.annotation.Retention(AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=AnnotationTarget.FUNCTION) public @interface Untracked {
+ @androidx.compose.ExperimentalComposeApi @kotlin.annotation.MustBeDocumented @kotlin.annotation.Retention(AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=AnnotationTarget.FUNCTION) public @interface Untracked {
}
}
@@ -702,7 +698,7 @@
package androidx.compose.internal {
- @androidx.compose.Stable public final class RestartableFunction<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17, P18, R> implements kotlin.jvm.functions.Function10<P1,P2,P3,P4,P5,P6,P7,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function11<P1,P2,P3,P4,P5,P6,P7,P8,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function12<P1,P2,P3,P4,P5,P6,P7,P8,P9,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function13<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function14<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function15<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function16<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function17<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13,P14,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function18<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13,P14,P15,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function20<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13,P14,P15,P16,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function21<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13,P14,P15,P16,P17,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function22<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13,P14,P15,P16,P17,P18,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function3<androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function4<P1,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function5<P1,P2,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function6<P1,P2,P3,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function7<P1,P2,P3,P4,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function8<P1,P2,P3,P4,P5,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function9<P1,P2,P3,P4,P5,P6,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> {
+ @androidx.compose.ComposeCompilerApi @androidx.compose.Stable public final class RestartableFunction<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17, P18, R> implements kotlin.jvm.functions.Function10<P1,P2,P3,P4,P5,P6,P7,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function11<P1,P2,P3,P4,P5,P6,P7,P8,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function12<P1,P2,P3,P4,P5,P6,P7,P8,P9,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function13<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function14<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function15<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function16<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function17<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13,P14,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function18<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13,P14,P15,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function20<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13,P14,P15,P16,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function21<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13,P14,P15,P16,P17,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function22<P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13,P14,P15,P16,P17,P18,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function3<androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function4<P1,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function5<P1,P2,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function6<P1,P2,P3,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function7<P1,P2,P3,P4,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function8<P1,P2,P3,P4,P5,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> kotlin.jvm.functions.Function9<P1,P2,P3,P4,P5,P6,androidx.compose.Composer<?>,java.lang.Integer,java.lang.Integer,R> {
ctor public RestartableFunction(int key, boolean tracked);
method public int getKey();
method public operator R! invoke(androidx.compose.Composer<?> c, int k, int changed);
@@ -728,11 +724,11 @@
}
public final class RestartableFunctionKt {
- method public static androidx.compose.internal.RestartableFunction<java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object> restartableFunction(androidx.compose.Composer<?> composer, int key, boolean tracked, Object block);
- method public static androidx.compose.internal.RestartableFunction<java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object> restartableFunctionInstance(int key, boolean tracked, Object block);
+ method @androidx.compose.ComposeCompilerApi public static androidx.compose.internal.RestartableFunction<java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object> restartableFunction(androidx.compose.Composer<?> composer, int key, boolean tracked, Object block);
+ method @androidx.compose.ComposeCompilerApi public static androidx.compose.internal.RestartableFunction<java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object> restartableFunctionInstance(int key, boolean tracked, Object block);
}
- @androidx.compose.Stable public final class RestartableFunctionN<R> implements kotlin.jvm.functions.FunctionN<R> {
+ @androidx.compose.ComposeCompilerApi @androidx.compose.Stable public final class RestartableFunctionN<R> implements kotlin.jvm.functions.FunctionN<R> {
ctor public RestartableFunctionN(int key, boolean tracked, int arity);
method public int getArity();
method public int getKey();
@@ -741,8 +737,8 @@
}
public final class RestartableFunctionNKt {
- method public static androidx.compose.internal.RestartableFunctionN<?> restartableFunctionN(androidx.compose.Composer<?> composer, int key, boolean tracked, int arity, Object block);
- method public static androidx.compose.internal.RestartableFunctionN<?> restartableFunctionNInstance(int key, boolean tracked, int arity, Object block);
+ method @androidx.compose.ComposeCompilerApi public static androidx.compose.internal.RestartableFunctionN<?> restartableFunctionN(androidx.compose.Composer<?> composer, int key, boolean tracked, int arity, Object block);
+ method @androidx.compose.ComposeCompilerApi public static androidx.compose.internal.RestartableFunctionN<?> restartableFunctionNInstance(int key, boolean tracked, int arity, Object block);
}
}
diff --git a/compose/compose-runtime/compose-runtime-benchmark/src/androidTest/java/androidx/compose/benchmark/ComposeBenchmarkBase.kt b/compose/compose-runtime/compose-runtime-benchmark/src/androidTest/java/androidx/compose/benchmark/ComposeBenchmarkBase.kt
index 01abcb6..81f4e07 100644
--- a/compose/compose-runtime/compose-runtime-benchmark/src/androidTest/java/androidx/compose/benchmark/ComposeBenchmarkBase.kt
+++ b/compose/compose-runtime/compose-runtime-benchmark/src/androidTest/java/androidx/compose/benchmark/ComposeBenchmarkBase.kt
@@ -26,6 +26,7 @@
import androidx.compose.Composer
import androidx.compose.Composition
import androidx.compose.FrameManager
+import androidx.compose.InternalComposeApi
import androidx.compose.Recomposer
import androidx.compose.currentComposer
import androidx.ui.core.AndroidOwner
@@ -83,6 +84,7 @@
}
val didSomething = activeComposer?.let { composer ->
+ @OptIn(InternalComposeApi::class)
composer.recompose().also { composer.applyChanges() }
} ?: false
assertTrue(didSomething)
diff --git a/compose/compose-runtime/src/androidAndroidTest/kotlin/androidx/compose/test/AmbientTests.kt b/compose/compose-runtime/src/androidAndroidTest/kotlin/androidx/compose/test/AmbientTests.kt
index b12eec2..d870aa60 100644
--- a/compose/compose-runtime/src/androidAndroidTest/kotlin/androidx/compose/test/AmbientTests.kt
+++ b/compose/compose-runtime/src/androidAndroidTest/kotlin/androidx/compose/test/AmbientTests.kt
@@ -20,6 +20,7 @@
import androidx.compose.Ambient
import androidx.compose.Composable
import androidx.compose.CompositionReference
+import androidx.compose.ExperimentalComposeApi
import androidx.compose.Providers
import androidx.compose.Recomposer
import androidx.compose.StructurallyEqual
@@ -496,8 +497,8 @@
@After
fun ensureNoSubcomposePending() {
activityRule.activity.uiThread {
- val hadPendingChanges = Recomposer.current().hasPendingChanges()
- assertTrue(!hadPendingChanges, "Pending changes detected after test completed")
+ val hasPendingChanges = Recomposer.current().hasPendingChanges()
+ assertTrue(!hasPendingChanges, "Pending changes detected after test completed")
}
}
@@ -514,6 +515,7 @@
val ref = Ref<CompositionReference>()
narrowInvalidateForReference(ref = ref)
return {
+ @OptIn(ExperimentalComposeApi::class)
// TODO(b/150390669): Review use of @Untracked
subcomposeInto(
activityRule.activity,
diff --git a/compose/compose-runtime/src/androidAndroidTest/kotlin/androidx/compose/test/BaseComposeTest.kt b/compose/compose-runtime/src/androidAndroidTest/kotlin/androidx/compose/test/BaseComposeTest.kt
index b061a67..1a1235e 100644
--- a/compose/compose-runtime/src/androidAndroidTest/kotlin/androidx/compose/test/BaseComposeTest.kt
+++ b/compose/compose-runtime/src/androidAndroidTest/kotlin/androidx/compose/test/BaseComposeTest.kt
@@ -28,6 +28,7 @@
import androidx.compose.ChoreographerFrameCallback
import androidx.compose.Composable
import androidx.compose.Composition
+import androidx.compose.ExperimentalComposeApi
import androidx.compose.FrameManager
import androidx.compose.Looper
import androidx.compose.Recomposer
@@ -133,6 +134,7 @@
remember { escapeCompose { LayoutNode() } }
val reference = compositionReference()
// TODO(b/150390669): Review use of @Untracked
+ @OptIn(ExperimentalComposeApi::class)
subcomposeInto(
activityRule.activity,
container,
diff --git a/compose/compose-runtime/src/androidAndroidTest/kotlin/androidx/compose/test/CompoundHashKeyTests.kt b/compose/compose-runtime/src/androidAndroidTest/kotlin/androidx/compose/test/CompoundHashKeyTests.kt
index f29c4bdb..263b85d 100644
--- a/compose/compose-runtime/src/androidAndroidTest/kotlin/androidx/compose/test/CompoundHashKeyTests.kt
+++ b/compose/compose-runtime/src/androidAndroidTest/kotlin/androidx/compose/test/CompoundHashKeyTests.kt
@@ -14,9 +14,11 @@
* limitations under the License.
*/
+@file:OptIn(ExperimentalComposeApi::class)
package androidx.compose.test
import androidx.compose.Composable
+import androidx.compose.ExperimentalComposeApi
import androidx.compose.currentComposer
import androidx.compose.invalidate
import androidx.compose.key
diff --git a/compose/compose-runtime/src/androidAndroidTest/kotlin/androidx/compose/test/EmittableComposer.kt b/compose/compose-runtime/src/androidAndroidTest/kotlin/androidx/compose/test/EmittableComposer.kt
index 3aeab66..f814f7e 100644
--- a/compose/compose-runtime/src/androidAndroidTest/kotlin/androidx/compose/test/EmittableComposer.kt
+++ b/compose/compose-runtime/src/androidAndroidTest/kotlin/androidx/compose/test/EmittableComposer.kt
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
+@file:OptIn(ComposeCompilerApi::class, ExperimentalComposeApi::class)
package androidx.compose.test
import android.app.Activity
@@ -23,9 +23,11 @@
import androidx.compose.Applier
import androidx.compose.ApplyAdapter
import androidx.compose.Composable
+import androidx.compose.ComposeCompilerApi
import androidx.compose.Composer
import androidx.compose.ComposerUpdater
import androidx.compose.Composition
+import androidx.compose.ExperimentalComposeApi
import androidx.compose.FrameManager
import androidx.compose.Recomposer
import androidx.compose.SlotTable
diff --git a/compose/compose-runtime/src/androidMain/kotlin/androidx/compose/KeySourceInfo.kt b/compose/compose-runtime/src/androidMain/kotlin/androidx/compose/KeySourceInfo.kt
index ad9124f..a48741a 100644
--- a/compose/compose-runtime/src/androidMain/kotlin/androidx/compose/KeySourceInfo.kt
+++ b/compose/compose-runtime/src/androidMain/kotlin/androidx/compose/KeySourceInfo.kt
@@ -59,4 +59,5 @@
}
}
+@InternalComposeApi
actual fun keySourceInfoOf(key: Any): String? = keyInfo[key]
diff --git a/compose/compose-runtime/src/commonMain/kotlin/androidx/compose/Applier.kt b/compose/compose-runtime/src/commonMain/kotlin/androidx/compose/Applier.kt
index 59787e0..8bd88c9 100644
--- a/compose/compose-runtime/src/commonMain/kotlin/androidx/compose/Applier.kt
+++ b/compose/compose-runtime/src/commonMain/kotlin/androidx/compose/Applier.kt
@@ -19,6 +19,7 @@
/**
* An adapter that performs tree based operations on some tree startNode N without requiring a specific base type for N
*/
+@ExperimentalComposeApi
interface ApplyAdapter<N> {
fun N.start(instance: N)
fun N.insertAt(index: Int, instance: N)
@@ -30,6 +31,7 @@
/**
* A helper class to apply changes to a tree with startNode types N given an apply adapter for type N
*/
+@ExperimentalComposeApi
class Applier<N>(root: N, private val adapter: ApplyAdapter<N>) {
private val stack = Stack<N>()
private var _current: N = root
diff --git a/compose/compose-runtime/src/commonMain/kotlin/androidx/compose/BitwiseOperators.kt b/compose/compose-runtime/src/commonMain/kotlin/androidx/compose/BitwiseOperators.kt
index ec31452..98ce237 100644
--- a/compose/compose-runtime/src/commonMain/kotlin/androidx/compose/BitwiseOperators.kt
+++ b/compose/compose-runtime/src/commonMain/kotlin/androidx/compose/BitwiseOperators.kt
@@ -15,7 +15,6 @@
*/
@file:Suppress("NOTHING_TO_INLINE")
-
package androidx.compose
@OptIn(ExperimentalStdlibApi::class)
diff --git a/compose/compose-runtime/src/commonMain/kotlin/androidx/compose/ComposeCompilerApi.kt b/compose/compose-runtime/src/commonMain/kotlin/androidx/compose/ComposeCompilerApi.kt
new file mode 100644
index 0000000..e7be2ad
--- /dev/null
+++ b/compose/compose-runtime/src/commonMain/kotlin/androidx/compose/ComposeCompilerApi.kt
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package androidx.compose
+
+@RequiresOptIn(
+ level = RequiresOptIn.Level.WARNING,
+ message = "This API is intended to be targeted by the Compose Compiler Plugin and not called " +
+ "directly."
+)
+@Target(
+ AnnotationTarget.CLASS,
+ AnnotationTarget.FUNCTION,
+ AnnotationTarget.PROPERTY,
+ AnnotationTarget.TYPEALIAS
+)
+annotation class ComposeCompilerApi
\ No newline at end of file
diff --git a/compose/compose-runtime/src/commonMain/kotlin/androidx/compose/Composer.kt b/compose/compose-runtime/src/commonMain/kotlin/androidx/compose/Composer.kt
index 140161a..5d085e8 100644
--- a/compose/compose-runtime/src/commonMain/kotlin/androidx/compose/Composer.kt
+++ b/compose/compose-runtime/src/commonMain/kotlin/androidx/compose/Composer.kt
@@ -14,6 +14,11 @@
* limitations under the License.
*/
+@file:OptIn(
+ InternalComposeApi::class,
+ ExperimentalComposeApi::class,
+ ComposeCompilerApi::class
+)
package androidx.compose
import androidx.compose.SlotTable.Companion.EMPTY
@@ -187,6 +192,7 @@
var location: Int
)
+@ComposeCompilerApi
interface ScopeUpdateScope {
fun updateScope(block: (Composer<*>, Int, Int) -> Unit)
}
@@ -316,6 +322,9 @@
}
}
+@Deprecated(
+ "This interfce is only left here for backwards compatibility with the Compose IDE Plugin"
+)
interface ComposerValidator {
fun changed(value: Int): Boolean
fun <T> changed(value: T): Boolean
@@ -339,6 +348,7 @@
/**
* Manager for scheduling recompositions.
*/
+ @ExperimentalComposeApi
val recomposer: Recomposer
) {
private val changes = mutableListOf<Change<N>>()
@@ -422,6 +432,7 @@
* @see [startMovableGroup]
* @see [startRestartGroup]
*/
+ @ComposeCompilerApi
fun startReplaceableGroup(key: Int) = start(key, null, false, null)
/**
@@ -436,6 +447,7 @@
*
* @see [startReplaceableGroup]
*/
+ @ComposeCompilerApi
fun endReplaceableGroup() = endGroup()
/**
@@ -444,6 +456,7 @@
* directly from source code. Call this API at your own risk.
*
*/
+ @ComposeCompilerApi
fun startDefaults() = start(0, null, false, null)
/**
@@ -453,6 +466,7 @@
*
* @see [startReplaceableGroup]
*/
+ @ComposeCompilerApi
fun endDefaults() {
endGroup()
val scope = currentRecomposeScope
@@ -461,6 +475,7 @@
}
}
+ @ComposeCompilerApi
val defaultsInvalid: Boolean
get() {
return providersInvalid || currentRecomposeScope?.defaultsInvalid == true
@@ -493,6 +508,7 @@
* @see [startReplaceableGroup]
* @see [startRestartGroup]
*/
+ @ComposeCompilerApi
fun startMovableGroup(key: Int, dataKey: Any?) = start(key, dataKey, false, null)
/**
@@ -510,9 +526,10 @@
*
* @see [startMovableGroup]
*/
+ @ComposeCompilerApi
fun endMovableGroup() = endGroup()
- @Suppress("UNUSED_PARAMETER", "DeprecatedCallableAddReplaceWith")
+ @Suppress("UNUSED_PARAMETER", "DeprecatedCallableAddReplaceWith", "DEPRECATION")
@Deprecated(
"This method is only left here for backwards compatibility with the Compose IDE Plugin"
)
@@ -531,7 +548,7 @@
* Start the composition. This should be called, and only be called, as the first group in
* the composition.
*/
- fun startRoot() {
+ internal fun startRoot() {
reader = slotTable.openReader()
startGroup(rootKey)
parentReference?.let { parentRef ->
@@ -546,7 +563,7 @@
* End the composition. This should be called, and only be called, to end the first group in
* the composition.
*/
- fun endRoot() {
+ internal fun endRoot() {
if (parentReference != null) {
endGroup()
}
@@ -559,7 +576,7 @@
/**
* Discard a pending composition because an error was encountered during composition
*/
- fun abortRoot() {
+ internal fun abortRoot() {
cleanUpCompose()
pendingStack.clear()
nodeIndexStack.clear()
@@ -577,12 +594,14 @@
* first composition this is always true. During recomposition this is true when new nodes
* are being scheduled to be added to the tree.
*/
+ @ComposeCompilerApi
var inserting: Boolean = false
private set
/**
* True if the composition should be checking if the composable functions can be skipped.
*/
+ @ComposeCompilerApi
val skipping: Boolean get() {
return !inserting &&
!providersInvalid &&
@@ -593,6 +612,7 @@
* Returns the hash of the compound key calculated as a combination of the keys of all the
* currently started groups via [startGroup].
*/
+ @ExperimentalComposeApi
var currentCompoundKeyHash: Int = 0
private set
@@ -600,6 +620,7 @@
* Start collecting key source information. This enables enables the tool API to be able to
* determine the source location of where groups and nodes are created.
*/
+ @InternalComposeApi
fun collectKeySourceInformation() {
collectKeySources = true
}
@@ -607,6 +628,7 @@
/**
* Apply the changes to the tree that were collected during the last composition.
*/
+ @InternalComposeApi
fun applyChanges() {
trace("Compose:applyChanges") {
invalidateStack.clear()
@@ -685,14 +707,14 @@
*
* @param key The key for the group
*/
- fun startGroup(key: Int) = start(key, null, false, null)
+ internal fun startGroup(key: Int) = start(key, null, false, null)
- fun startGroup(key: Int, dataKey: Any?) = start(key, dataKey, false, null)
+ internal fun startGroup(key: Int, dataKey: Any?) = start(key, dataKey, false, null)
/**
* End the current group.
*/
- fun endGroup() = end(false)
+ internal fun endGroup() = end(false)
private fun skipGroup() {
groupNodeCount += reader.skipGroup()
@@ -707,12 +729,14 @@
*
* @param key the key for the node.
*/
+ @ComposeCompilerApi
fun startNode(key: Any) {
start(nodeKey, key, true, null)
nodeExpected = true
}
// Deprecated
+ @ComposeCompilerApi
fun <T : N> emitNode(factory: () -> T) {
validateNodeExpected()
if (inserting) {
@@ -736,6 +760,7 @@
* call when the composer is inserting.
*/
@Suppress("UNUSED")
+ @ComposeCompilerApi
fun <T : N> createNode(factory: () -> T) {
validateNodeExpected()
require(inserting) { "createNode() can only be called when inserting" }
@@ -756,6 +781,7 @@
* Schedule the given node to be inserted. This is only valid to call when the composer is
* inserting.
*/
+ @ComposeCompilerApi
fun emitNode(node: N) {
validateNodeExpected()
require(inserting) { "emitNode() called when not inserting" }
@@ -774,6 +800,7 @@
* valid to call when the composition is not inserting. This must be called at the same
* location as [emitNode] or [createNode] as called even if the value is unused.
*/
+ @ComposeCompilerApi
fun useNode(): N {
validateNodeExpected()
require(!inserting) { "useNode() called while inserting" }
@@ -785,6 +812,7 @@
/**
* Called to end the node group.
*/
+ @ComposeCompilerApi
fun endNode() = end(true)
/**
@@ -792,7 +820,7 @@
* node that is the current node in the tree which was either created by [createNode],
* emitted by [emitNode] or returned by [useNode].
*/
- fun <V, T> apply(value: V, block: T.(V) -> Unit) {
+ internal fun <V, T> apply(value: V, block: T.(V) -> Unit) {
recordApplierOperation { applier, _, _ ->
@Suppress("UNCHECKED_CAST")
(applier.current as T).block(value)
@@ -803,12 +831,14 @@
* Create a composed key that can be used in calls to [startGroup] or [startNode]. This will
* use the key stored at the current location in the slot table to avoid allocating a new key.
*/
+ @ComposeCompilerApi
fun joinKey(left: Any?, right: Any?): Any =
getKey(reader.groupDataKey, left, right) ?: JoinedKey(left, right)
/**
* Return the next value in the slot table and advance the current location.
*/
+ @ComposeCompilerApi
fun nextSlot(): Any? = if (inserting) {
validateNodeNotExpected()
EMPTY
@@ -822,6 +852,7 @@
*
* @param value the value to be compared.
*/
+ @ComposeCompilerApi
fun changed(value: Any?): Boolean {
return if (nextSlot() != value) {
updateValue(value)
@@ -831,6 +862,7 @@
}
}
+ @ComposeCompilerApi
fun changed(value: Char): Boolean {
val next = nextSlot()
if (next is Char) {
@@ -841,6 +873,7 @@
return true
}
+ @ComposeCompilerApi
fun changed(value: Byte): Boolean {
val next = nextSlot()
if (next is Byte) {
@@ -851,6 +884,7 @@
return true
}
+ @ComposeCompilerApi
fun changed(value: Short): Boolean {
val next = nextSlot()
if (next is Short) {
@@ -861,6 +895,7 @@
return true
}
+ @ComposeCompilerApi
fun changed(value: Boolean): Boolean {
val next = nextSlot()
if (next is Boolean) {
@@ -871,6 +906,7 @@
return true
}
+ @ComposeCompilerApi
fun changed(value: Float): Boolean {
val next = nextSlot()
if (next is Float) {
@@ -881,6 +917,7 @@
return true
}
+ @ComposeCompilerApi
fun changed(value: Long): Boolean {
val next = nextSlot()
if (next is Long) {
@@ -891,6 +928,7 @@
return true
}
+ @ComposeCompilerApi
fun changed(value: Double): Boolean {
val next = nextSlot()
if (next is Double) {
@@ -901,6 +939,7 @@
return true
}
+ @ComposeCompilerApi
fun changed(value: Int): Boolean {
val next = nextSlot()
if (next is Int) {
@@ -916,7 +955,8 @@
*
* @param value the value to schedule to be written to the slot table.
*/
- fun updateValue(value: Any?) {
+ @PublishedApi
+ internal fun updateValue(value: Any?) {
if (inserting) {
writer.update(value)
if (value is CompositionLifecycleObserver) {
@@ -1071,7 +1111,7 @@
/**
* Create or use a memoized `CompositionReference` instance at this position in the slot table.
*/
- fun buildReference(): CompositionReference {
+ internal fun buildReference(): CompositionReference {
startGroup(referenceKey, reference)
var ref = nextSlot() as? CompositionReference
@@ -1109,7 +1149,7 @@
* Slot table movement (skipping groups and nodes) will be coalesced so this number is
* possibly less than the total changes detected.
*/
- val changeCount get() = changes.size
+ internal val changeCount get() = changes.size
internal val currentRecomposeScope: RecomposeScope?
get() =
@@ -1647,6 +1687,7 @@
* Skip a group. Skips the group at the current location. This is only valid to call if the
* composition is not inserting.
*/
+ @ComposeCompilerApi
fun skipCurrentGroup() {
if (invalidations.isEmpty()) {
skipGroup()
@@ -1670,6 +1711,7 @@
/**
* Skip to the end of the group opened by [startGroup].
*/
+ @ComposeCompilerApi
fun skipToGroupEnd() {
require(groupNodeCount == 0) { "No nodes can be emitted before calling skipAndEndGroup" }
if (invalidations.isEmpty()) {
@@ -1685,6 +1727,7 @@
* will be recomposed. A recompose scope can be invalidated by calling the lambda returned by
* [androidx.compose.invalidate].
*/
+ @ComposeCompilerApi
fun startRestartGroup(key: Int) {
start(key, null, false, null)
if (inserting) {
@@ -1705,6 +1748,7 @@
* composition as was produced by this group (including calling [startRestartGroup] and
* [endRestartGroup]).
*/
+ @ComposeCompilerApi
fun endRestartGroup(): ScopeUpdateScope? {
// This allows for the invalidate stack to be out of sync since this might be called during exception stack
// unwinding that might have not called the doneJoin/endRestartGroup in the wrong order.
@@ -1731,6 +1775,7 @@
* Synchronously recompose all invalidated groups. This collects the changes which must be
* applied by [applyChanges] to have an effect.
*/
+ @InternalComposeApi
fun recompose(): Boolean {
if (invalidations.isNotEmpty()) {
trace("Compose:recompose") {
@@ -2227,7 +2272,8 @@
* value is obtained from the slot table and [block] is not invoked. If [valid] is false a new
* value is produced by calling [block] and the slot table is updated to contain the new value.
*/
-inline fun <N, T> Composer<N>.cache(valid: Boolean = true, block: () -> T): T {
+@PublishedApi
+internal inline fun <N, T> Composer<N>.cache(valid: Boolean = true, block: () -> T): T {
var result = nextSlot()
if (result === EMPTY || !valid) {
val value = block()
diff --git a/compose/compose-runtime/src/commonMain/kotlin/androidx/compose/Composition.kt b/compose/compose-runtime/src/commonMain/kotlin/androidx/compose/Composition.kt
index 7971347..bccf965 100644
--- a/compose/compose-runtime/src/commonMain/kotlin/androidx/compose/Composition.kt
+++ b/compose/compose-runtime/src/commonMain/kotlin/androidx/compose/Composition.kt
@@ -14,6 +14,7 @@
* limitations under the License.
*/
+@file:OptIn(InternalComposeApi::class)
package androidx.compose
/**
diff --git a/compose/compose-runtime/src/commonMain/kotlin/androidx/compose/CompositionFrameClock.kt b/compose/compose-runtime/src/commonMain/kotlin/androidx/compose/CompositionFrameClock.kt
index 4ad0f1d..6a2e1c8 100644
--- a/compose/compose-runtime/src/commonMain/kotlin/androidx/compose/CompositionFrameClock.kt
+++ b/compose/compose-runtime/src/commonMain/kotlin/androidx/compose/CompositionFrameClock.kt
@@ -14,6 +14,7 @@
* limitations under the License.
*/
+// TODO(b/158105080): make part of ComposeRuntime
package androidx.compose
/**
diff --git a/compose/compose-runtime/src/commonMain/kotlin/androidx/compose/Effects.kt b/compose/compose-runtime/src/commonMain/kotlin/androidx/compose/Effects.kt
index f586ef5..bee80c6 100644
--- a/compose/compose-runtime/src/commonMain/kotlin/androidx/compose/Effects.kt
+++ b/compose/compose-runtime/src/commonMain/kotlin/androidx/compose/Effects.kt
@@ -15,7 +15,6 @@
*/
@file:Suppress("unused")
-
package androidx.compose
/**
@@ -144,6 +143,7 @@
* @see [onActive]
*/
@Suppress("NOTHING_TO_INLINE")
+@OptIn(ComposeCompilerApi::class)
@Composable
inline fun onCommit(noinline callback: CommitScope.() -> Unit) {
currentComposer.changed(PostCommitScopeImpl(callback))
@@ -228,6 +228,7 @@
* @see [onActive]
*/
@Suppress("NOTHING_TO_INLINE")
+@OptIn(ComposeCompilerApi::class)
@Composable
inline fun onPreCommit(noinline callback: CommitScope.() -> Unit) {
currentComposer.changed(PreCommitScopeImpl(callback))
diff --git a/compose/compose-runtime/src/commonMain/kotlin/androidx/compose/ExperimentalComposeApi.kt b/compose/compose-runtime/src/commonMain/kotlin/androidx/compose/ExperimentalComposeApi.kt
new file mode 100644
index 0000000..dddbe3a
--- /dev/null
+++ b/compose/compose-runtime/src/commonMain/kotlin/androidx/compose/ExperimentalComposeApi.kt
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package androidx.compose
+
+@RequiresOptIn(
+ level = RequiresOptIn.Level.ERROR,
+ message = "This is an experimental API for Compose and is likely to change before becoming " +
+ "stable."
+)
+@Target(
+ AnnotationTarget.CLASS,
+ AnnotationTarget.FUNCTION,
+ AnnotationTarget.PROPERTY
+)
+annotation class ExperimentalComposeApi
\ No newline at end of file
diff --git a/compose/compose-runtime/src/commonMain/kotlin/androidx/compose/FrameManager.kt b/compose/compose-runtime/src/commonMain/kotlin/androidx/compose/FrameManager.kt
index 3a07159..0f88642 100644
--- a/compose/compose-runtime/src/commonMain/kotlin/androidx/compose/FrameManager.kt
+++ b/compose/compose-runtime/src/commonMain/kotlin/androidx/compose/FrameManager.kt
@@ -14,6 +14,7 @@
* limitations under the License.
*/
+@file:OptIn(InternalComposeApi::class)
package androidx.compose
import androidx.compose.frames.Frame
diff --git a/compose/compose-runtime/src/commonMain/kotlin/androidx/compose/JoinedKey.kt b/compose/compose-runtime/src/commonMain/kotlin/androidx/compose/JoinedKey.kt
index 30fc771..ab28f60 100644
--- a/compose/compose-runtime/src/commonMain/kotlin/androidx/compose/JoinedKey.kt
+++ b/compose/compose-runtime/src/commonMain/kotlin/androidx/compose/JoinedKey.kt
@@ -21,12 +21,15 @@
val right: Any?
)
+@InternalComposeApi
fun isJoinedKey(key: Any?) = key is JoinedKey
+@InternalComposeApi
fun joinedKeyLeft(key: Any?): Any? = when (key) {
is JoinedKey -> key.left
else -> null
}
+@InternalComposeApi
fun joinedKeyRight(key: Any?): Any? = when (key) {
is JoinedKey -> key.right
else -> null
diff --git a/compose/compose-runtime/src/commonMain/kotlin/androidx/compose/KeySourceInfo.kt b/compose/compose-runtime/src/commonMain/kotlin/androidx/compose/KeySourceInfo.kt
index d428fe6..fd5fe81 100644
--- a/compose/compose-runtime/src/commonMain/kotlin/androidx/compose/KeySourceInfo.kt
+++ b/compose/compose-runtime/src/commonMain/kotlin/androidx/compose/KeySourceInfo.kt
@@ -18,4 +18,5 @@
internal expect fun recordSourceKeyInfo(key: Any)
+@InternalComposeApi
expect fun keySourceInfoOf(key: Any): String?
\ No newline at end of file
diff --git a/compose/compose-runtime/src/commonMain/kotlin/androidx/compose/Recomposer.kt b/compose/compose-runtime/src/commonMain/kotlin/androidx/compose/Recomposer.kt
index bc325f4..c77569f 100644
--- a/compose/compose-runtime/src/commonMain/kotlin/androidx/compose/Recomposer.kt
+++ b/compose/compose-runtime/src/commonMain/kotlin/androidx/compose/Recomposer.kt
@@ -14,6 +14,7 @@
* limitations under the License.
*/
+@file:OptIn(InternalComposeApi::class)
package androidx.compose
import kotlinx.coroutines.CoroutineScope
@@ -61,7 +62,7 @@
/**
* Track if any outstanding invalidated composers are awaiting recomposition.
* This latch is closed any time we resume invalidComposersAwaiter and opened
- * by [recomposeAndApplyChanges] when it suspends for no further work to do.
+ * by [recomposeAndApplyChanges] when it suspends when it has no further work to do.
*/
private val idlingLatch = Latch()
diff --git a/compose/compose-runtime/src/commonMain/kotlin/androidx/compose/Remember.kt b/compose/compose-runtime/src/commonMain/kotlin/androidx/compose/Remember.kt
index c9ed0f2f..87d7621e 100644
--- a/compose/compose-runtime/src/commonMain/kotlin/androidx/compose/Remember.kt
+++ b/compose/compose-runtime/src/commonMain/kotlin/androidx/compose/Remember.kt
@@ -20,7 +20,6 @@
* Remember the value produced by [calculation]. [calculation] will only be evaluated during the composition.
* Recomposition will always return the value produced by composition.
*/
-
@Composable
inline fun <T> remember(calculation: () -> T): T =
currentComposer.cache(true, calculation)
@@ -29,6 +28,7 @@
* Remember the value returned by [calculation] if [v1] is equal to the previous composition, otherwise
* produce and remember a new value by calling [calculation].
*/
+@OptIn(ComposeCompilerApi::class)
@Composable
inline fun <T, /*reified*/ V1> remember(v1: V1, calculation: () -> T): T {
return currentComposer.cache(!currentComposer.changed(v1), calculation)
@@ -38,6 +38,7 @@
* Remember the value returned by [calculation] if [v1] and [v2] are equal to the previous composition,
* otherwise produce and remember a new value by calling [calculation].
*/
+@OptIn(ComposeCompilerApi::class)
@Composable
inline fun <T, /*reified*/ V1, /*reified*/ V2> remember(
v1: V1,
@@ -53,6 +54,7 @@
* Remember the value returned by [calculation] if [v1], [v2] and [v3] are equal to the previous
* composition, otherwise produce and remember a new value by calling [calculation].
*/
+@OptIn(ComposeCompilerApi::class)
@Composable
inline fun <T, /*reified*/ V1, /*reified*/ V2, /*reified*/ V3> remember(
v1: V1,
@@ -70,6 +72,7 @@
* Remember the value returned by [block] if all values of [inputs] are equal to the previous
* composition, otherwise produce and remember a new value by calling [block].
*/
+@OptIn(ComposeCompilerApi::class)
@Composable
inline fun <V> remember(vararg inputs: Any?, block: () -> V): V {
var valid = true
diff --git a/compose/compose-runtime/src/commonMain/kotlin/androidx/compose/SlotTable.kt b/compose/compose-runtime/src/commonMain/kotlin/androidx/compose/SlotTable.kt
index f42db92..d666468 100644
--- a/compose/compose-runtime/src/commonMain/kotlin/androidx/compose/SlotTable.kt
+++ b/compose/compose-runtime/src/commonMain/kotlin/androidx/compose/SlotTable.kt
@@ -14,8 +14,10 @@
* limitations under the License.
*/
+@file:OptIn(InternalComposeApi::class)
package androidx.compose
+@InternalComposeApi
class SlotReader(val table: SlotTable) {
var current = 0
private set
@@ -301,6 +303,7 @@
@PublishedApi
internal val EMPTY = SlotTable.EMPTY
+@InternalComposeApi
class SlotWriter internal constructor(val table: SlotTable) {
var current = 0
@@ -1088,6 +1091,7 @@
*
* @see SlotReader
*/
+ @InternalComposeApi
fun <T> read(block: (reader: SlotReader) -> T): T = openReader().let { reader ->
try {
block(reader)
@@ -1103,6 +1107,7 @@
*
* @see SlotWriter
*/
+ @InternalComposeApi
fun <T> write(block: (writer: SlotWriter) -> T): T = openWriter().let { writer ->
try {
block(writer)
@@ -1117,6 +1122,7 @@
* [groupPathTo] creates a reader so it cannot be called when the slot table is being written
* to.
*/
+ @InternalComposeApi
fun groupPathTo(location: Int): List<Int> {
require(location < size)
val path = mutableListOf<Int>()
@@ -1145,6 +1151,7 @@
*
* @see SlotReader
*/
+ @InternalComposeApi
fun openReader(): SlotReader {
if (writer) error("Cannot read while a writer is pending")
readers++
@@ -1157,6 +1164,7 @@
*
* @see SlotWriter
*/
+ @InternalComposeApi
fun openWriter(): SlotWriter {
if (writer) error("Cannot start a writer when another writer is pending")
if (readers > 0) error("Cannot start a writer when a reader is pending")
@@ -1172,6 +1180,7 @@
* well-formed.
*/
@TestOnly
+ @InternalComposeApi
fun verifyWellFormed() {
var current = 0
@@ -1222,6 +1231,7 @@
* The number of active slots in the slot table. The current capacity of the slot table is at
* lease [size].
*/
+ @InternalComposeApi
val size: Int get() = slots.size - gapLen
internal fun close(reader: SlotReader) {
@@ -1349,7 +1359,9 @@
return anchors[location] === anchor
}
+ @InternalComposeApi
companion object {
+ @InternalComposeApi
val EMPTY = object : Any() {
override fun toString(): String {
return "EMPTY"
@@ -1365,6 +1377,7 @@
/**
* Information about groups and their keys.
*/
+@InternalComposeApi
class KeyInfo internal constructor(
/**
* The group key.
@@ -1397,6 +1410,7 @@
internal val group: Group
)
+@InternalComposeApi
class Anchor(internal var loc: Int) {
val valid get() = loc >= 0
fun location(slots: SlotTable) = slots.anchorLocation(this)
diff --git a/compose/compose-runtime/src/commonMain/kotlin/androidx/compose/SuspendingEffects.kt b/compose/compose-runtime/src/commonMain/kotlin/androidx/compose/SuspendingEffects.kt
index 8167ab4..24fdd18 100644
--- a/compose/compose-runtime/src/commonMain/kotlin/androidx/compose/SuspendingEffects.kt
+++ b/compose/compose-runtime/src/commonMain/kotlin/androidx/compose/SuspendingEffects.kt
@@ -14,6 +14,8 @@
* limitations under the License.
*/
+// TODO(b/158105080): make part of ComposeRuntime
+@file:OptIn(InternalComposeApi::class)
package androidx.compose
import kotlinx.coroutines.CoroutineScope
@@ -75,11 +77,16 @@
* Launch a suspending side effect when this composition is committed and cancel it
* when [launchInComposition] leaves the composition. [block] will run in the **apply** scope of the
* composition's [Recomposer], which is usually your UI's main thread.
+ *
+ * [block] will be launched **once** when this call enters the composition; recomposition will not
+ * cause [block] to launch again. To re-launch a suspend function when inputs change, see the
+ * other overloads of [launchInComposition] that accept input value parameters.
*/
@Composable
fun launchInComposition(
block: suspend CompositionCoroutineScope.() -> Unit
) {
+ @OptIn(ExperimentalComposeApi::class)
val recomposer = currentComposer.recomposer
remember { SuspendingEffect(recomposer, block) }
}
@@ -95,6 +102,7 @@
v1: Any?,
block: suspend CompositionCoroutineScope.() -> Unit
) {
+ @OptIn(ExperimentalComposeApi::class)
val recomposer = currentComposer.recomposer
remember(v1) { SuspendingEffect(recomposer, block) }
}
@@ -112,6 +120,7 @@
v2: Any?,
block: suspend CompositionCoroutineScope.() -> Unit
) {
+ @OptIn(ExperimentalComposeApi::class)
val recomposer = currentComposer.recomposer
remember(v1, v2) { SuspendingEffect(recomposer, block) }
}
@@ -130,6 +139,7 @@
v3: Any?,
block: suspend CompositionCoroutineScope.() -> Unit
) {
+ @OptIn(ExperimentalComposeApi::class)
val recomposer = currentComposer.recomposer
remember(v1, v2, v3) { SuspendingEffect(recomposer, block) }
}
@@ -146,6 +156,7 @@
vararg keys: Any?,
block: suspend CompositionCoroutineScope.() -> Unit
) {
+ @OptIn(ExperimentalComposeApi::class)
val recomposer = currentComposer.recomposer
remember(*keys) { SuspendingEffect(recomposer, block) }
}
\ No newline at end of file
diff --git a/compose/compose-runtime/src/commonMain/kotlin/androidx/compose/UnionType.kt b/compose/compose-runtime/src/commonMain/kotlin/androidx/compose/UnionType.kt
index 6da5d7a..101f3e4 100644
--- a/compose/compose-runtime/src/commonMain/kotlin/androidx/compose/UnionType.kt
+++ b/compose/compose-runtime/src/commonMain/kotlin/androidx/compose/UnionType.kt
@@ -30,4 +30,5 @@
@MustBeDocumented
@Retention(AnnotationRetention.BINARY)
@Target(AnnotationTarget.TYPE, AnnotationTarget.TYPE_PARAMETER)
+@ExperimentalComposeApi
annotation class UnionType(vararg val types: KClass<*>)
diff --git a/compose/compose-runtime/src/commonMain/kotlin/androidx/compose/Untracked.kt b/compose/compose-runtime/src/commonMain/kotlin/androidx/compose/Untracked.kt
index 1d2d945..9fe14cf 100644
--- a/compose/compose-runtime/src/commonMain/kotlin/androidx/compose/Untracked.kt
+++ b/compose/compose-runtime/src/commonMain/kotlin/androidx/compose/Untracked.kt
@@ -26,4 +26,5 @@
@Target(
AnnotationTarget.FUNCTION
)
+@ExperimentalComposeApi
annotation class Untracked
\ No newline at end of file
diff --git a/compose/compose-runtime/src/commonMain/kotlin/androidx/compose/internal/RestartableFunction.kt b/compose/compose-runtime/src/commonMain/kotlin/androidx/compose/internal/RestartableFunction.kt
index 9d7ab12..234c85a 100644
--- a/compose/compose-runtime/src/commonMain/kotlin/androidx/compose/internal/RestartableFunction.kt
+++ b/compose/compose-runtime/src/commonMain/kotlin/androidx/compose/internal/RestartableFunction.kt
@@ -15,10 +15,12 @@
*/
@file:Suppress("UNCHECKED_CAST")
-
+@file:OptIn(InternalComposeApi::class)
package androidx.compose.internal
+import androidx.compose.ComposeCompilerApi
import androidx.compose.Composer
+import androidx.compose.InternalComposeApi
import androidx.compose.RecomposeScope
import androidx.compose.SlotTable
import androidx.compose.Stable
@@ -41,6 +43,7 @@
* multiple levels of composable functions.
*/
@Stable
+@ComposeCompilerApi
class RestartableFunction<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16,
P17, P18, R>(
val key: Int,
@@ -1136,10 +1139,12 @@
private fun RecomposeScope?.replacableWith(other: RecomposeScope) =
this == null || !this.valid || this == other || this.anchor == other.anchor
+@ComposeCompilerApi
private typealias RFunction = RestartableFunction<Any, Any, Any, Any, Any, Any, Any, Any, Any, Any,
Any, Any, Any, Any, Any, Any, Any, Any, Any>
@Suppress("unused")
+@ComposeCompilerApi
fun restartableFunction(composer: Composer<*>, key: Int, tracked: Boolean, block: Any): RFunction {
composer.startReplaceableGroup(key)
val slot = composer.nextSlot()
@@ -1156,5 +1161,6 @@
}
@Suppress("unused")
+@ComposeCompilerApi
fun restartableFunctionInstance(key: Int, tracked: Boolean, block: Any) =
RFunction(key, tracked).apply { update(block) }
diff --git a/compose/compose-runtime/src/desktopMain/kotlin/androidx/compose/ActualDesktop.kt b/compose/compose-runtime/src/desktopMain/kotlin/androidx/compose/ActualDesktop.kt
index 681e25a..541b42e 100644
--- a/compose/compose-runtime/src/desktopMain/kotlin/androidx/compose/ActualDesktop.kt
+++ b/compose/compose-runtime/src/desktopMain/kotlin/androidx/compose/ActualDesktop.kt
@@ -124,6 +124,7 @@
}
}
+@InternalComposeApi
actual fun keySourceInfoOf(key: Any): String? = keyInfo[key]
private object MainCompositionFrameClock : CompositionFrameClock {
diff --git a/compose/compose-runtime/src/jvmMain/kotlin/androidx/compose/internal/RestartableFunctionN.kt b/compose/compose-runtime/src/jvmMain/kotlin/androidx/compose/internal/RestartableFunctionN.kt
index c011ada..f1396ed 100644
--- a/compose/compose-runtime/src/jvmMain/kotlin/androidx/compose/internal/RestartableFunctionN.kt
+++ b/compose/compose-runtime/src/jvmMain/kotlin/androidx/compose/internal/RestartableFunctionN.kt
@@ -14,10 +14,13 @@
* limitations under the License.
*/
+@file:OptIn(InternalComposeApi::class)
package androidx.compose.internal
+import androidx.compose.ComposeCompilerApi
import androidx.compose.Composer
import androidx.compose.FrameManager
+import androidx.compose.InternalComposeApi
import androidx.compose.SlotTable
import androidx.compose.Stable
import kotlin.jvm.functions.FunctionN
@@ -25,6 +28,7 @@
private const val SLOTS_PER_INT = 15
@Stable
+@ComposeCompilerApi
class RestartableFunctionN<R>(
val key: Int,
private val tracked: Boolean,
@@ -88,6 +92,7 @@
}
@Suppress("unused")
+@ComposeCompilerApi
fun restartableFunctionN(
composer: Composer<*>,
key: Int,
@@ -111,6 +116,7 @@
}
@Suppress("unused")
+@ComposeCompilerApi
fun restartableFunctionNInstance(
key: Int,
tracked: Boolean,
diff --git a/compose/compose-runtime/src/unitTest/kotlin/androidx/compose/CompositionTests.kt b/compose/compose-runtime/src/unitTest/kotlin/androidx/compose/CompositionTests.kt
index c400824..3fd352b 100644
--- a/compose/compose-runtime/src/unitTest/kotlin/androidx/compose/CompositionTests.kt
+++ b/compose/compose-runtime/src/unitTest/kotlin/androidx/compose/CompositionTests.kt
@@ -13,6 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
+@file:OptIn(ExperimentalComposeApi::class, InternalComposeApi::class)
package androidx.compose
import androidx.compose.mock.Contact
diff --git a/compose/compose-runtime/src/unitTest/kotlin/androidx/compose/SlotTableTests.kt b/compose/compose-runtime/src/unitTest/kotlin/androidx/compose/SlotTableTests.kt
index 2fa59e0..50cbfba 100644
--- a/compose/compose-runtime/src/unitTest/kotlin/androidx/compose/SlotTableTests.kt
+++ b/compose/compose-runtime/src/unitTest/kotlin/androidx/compose/SlotTableTests.kt
@@ -14,6 +14,7 @@
* limitations under the License.
*/
+@file:OptIn(InternalComposeApi::class)
package androidx.compose
import java.util.Random
diff --git a/compose/compose-runtime/src/unitTest/kotlin/androidx/compose/mock/ViewComposer.kt b/compose/compose-runtime/src/unitTest/kotlin/androidx/compose/mock/ViewComposer.kt
index 3012c05..a5e5a30 100644
--- a/compose/compose-runtime/src/unitTest/kotlin/androidx/compose/mock/ViewComposer.kt
+++ b/compose/compose-runtime/src/unitTest/kotlin/androidx/compose/mock/ViewComposer.kt
@@ -19,8 +19,11 @@
import androidx.compose.Applier
import androidx.compose.ApplyAdapter
import androidx.compose.Composable
+import androidx.compose.ComposeCompilerApi
import androidx.compose.Composer
import androidx.compose.ComposerUpdater
+import androidx.compose.ExperimentalComposeApi
+import androidx.compose.InternalComposeApi
import androidx.compose.Recomposer
import androidx.compose.SlotTable
import androidx.compose.Stable
@@ -28,6 +31,7 @@
import androidx.compose.invokeComposable
@Suppress("EXTENSION_SHADOWED_BY_MEMBER")
+@OptIn(ExperimentalComposeApi::class)
object ViewApplierAdapter :
ApplyAdapter<View> {
override fun View.start(instance: View) {}
@@ -44,6 +48,7 @@
val composer: MockViewComposer
}
+@OptIn(InternalComposeApi::class, ExperimentalComposeApi::class, ComposeCompilerApi::class)
class MockViewComposer(
val root: View,
recomposer: Recomposer
@@ -90,6 +95,7 @@
}
@Suppress("UNCHECKED_CAST")
+@OptIn(ComposeCompilerApi::class)
@Composable
fun <P1> MockComposeScope.memoize(
key: Int,
diff --git a/mediarouter/mediarouter/src/main/java/androidx/mediarouter/media/RegisteredMediaRouteProvider.java b/mediarouter/mediarouter/src/main/java/androidx/mediarouter/media/RegisteredMediaRouteProvider.java
index 6456958..dd1f48d 100644
--- a/mediarouter/mediarouter/src/main/java/androidx/mediarouter/media/RegisteredMediaRouteProvider.java
+++ b/mediarouter/mediarouter/src/main/java/androidx/mediarouter/media/RegisteredMediaRouteProvider.java
@@ -67,6 +67,7 @@
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
+import android.os.Build;
import android.os.Bundle;
import android.os.DeadObjectException;
import android.os.Handler;
@@ -255,7 +256,11 @@
Intent service = new Intent(MediaRouteProviderProtocol.SERVICE_INTERFACE);
service.setComponent(mComponentName);
try {
- mBound = getContext().bindService(service, this, Context.BIND_AUTO_CREATE);
+ int flags = Context.BIND_AUTO_CREATE;
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
+ flags |= Context.BIND_INCLUDE_CAPABILITIES;
+ }
+ mBound = getContext().bindService(service, this, flags);
if (!mBound && DEBUG) {
Log.d(TAG, this + ": Bind failed");
}
diff --git a/ui/integration-tests/benchmark/src/androidTest/java/androidx/ui/benchmark/test/autofill/AndroidAutofillBenchmark.kt b/ui/integration-tests/benchmark/src/androidTest/java/androidx/ui/benchmark/test/autofill/AndroidAutofillBenchmark.kt
index 3062b73..1417f3d 100644
--- a/ui/integration-tests/benchmark/src/androidTest/java/androidx/ui/benchmark/test/autofill/AndroidAutofillBenchmark.kt
+++ b/ui/integration-tests/benchmark/src/androidTest/java/androidx/ui/benchmark/test/autofill/AndroidAutofillBenchmark.kt
@@ -18,7 +18,7 @@
import android.graphics.Rect
import android.util.SparseArray
-import android.view.ViewGroup
+import android.view.View
import android.view.autofill.AutofillValue
import androidx.benchmark.junit4.BenchmarkRule
import androidx.benchmark.junit4.measureRepeated
@@ -26,9 +26,10 @@
import androidx.test.filters.LargeTest
import androidx.ui.autofill.AutofillNode
import androidx.test.filters.SdkSuppress
+import androidx.ui.autofill.AutofillTree
import androidx.ui.autofill.AutofillType
-import androidx.ui.core.Owner
-import androidx.ui.core.OwnerAmbient
+import androidx.ui.core.AutofillTreeAmbient
+import androidx.ui.core.ViewAmbient
import androidx.ui.test.createComposeRule
import org.junit.Before
import org.junit.Rule
@@ -46,15 +47,14 @@
@get:Rule
val benchmarkRule = BenchmarkRule()
- private lateinit var owner: Owner
- private lateinit var composeView: ViewGroup
+ private lateinit var autofillTree: AutofillTree
+ private lateinit var composeView: View
@Before
fun setup() {
composeTestRule.setContent {
- @Suppress("DEPRECATION") // Owner Ambient will be removed by b/139866476.
- owner = OwnerAmbient.current
- composeView = owner as ViewGroup
+ autofillTree = AutofillTreeAmbient.current
+ composeView = ViewAmbient.current
}
}
@@ -72,7 +72,7 @@
val autofillValues = SparseArray<AutofillValue>().apply {
append(autofillNode.id, AutofillValue.forText("Name"))
}
- owner.autofillTree += autofillNode
+ autofillTree += autofillNode
// Assess.
benchmarkRule.measureRepeated {
diff --git a/ui/ui-android-view/integration-tests/android-view-demos/src/main/java/androidx/ui/androidview/demos/AndroidViewDemos.kt b/ui/ui-android-view/integration-tests/android-view-demos/src/main/java/androidx/ui/androidview/demos/AndroidViewDemos.kt
index 8d539c6..86c9bf6 100644
--- a/ui/ui-android-view/integration-tests/android-view-demos/src/main/java/androidx/ui/androidview/demos/AndroidViewDemos.kt
+++ b/ui/ui-android-view/integration-tests/android-view-demos/src/main/java/androidx/ui/androidview/demos/AndroidViewDemos.kt
@@ -22,5 +22,6 @@
val AndroidViewDemos = DemoCategory("AndroidView", listOf(
ComposeInAndroidDemos,
AndroidInComposeDemos,
+ ComplexTouchInterop,
ActivityDemo("WebComponent", WebComponentActivity::class)
))
diff --git a/ui/ui-android-view/integration-tests/android-view-demos/src/main/java/androidx/ui/androidview/demos/ComplexInteractions.kt b/ui/ui-android-view/integration-tests/android-view-demos/src/main/java/androidx/ui/androidview/demos/ComplexInteractions.kt
new file mode 100644
index 0000000..9b7fac4
--- /dev/null
+++ b/ui/ui-android-view/integration-tests/android-view-demos/src/main/java/androidx/ui/androidview/demos/ComplexInteractions.kt
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package androidx.ui.androidview.demos
+
+import android.content.Context
+import android.widget.FrameLayout
+import androidx.compose.Composable
+import androidx.compose.Recomposer
+import androidx.compose.escapeCompose
+import androidx.ui.core.ContextAmbient
+import androidx.ui.core.setContent
+import androidx.ui.demos.common.ComposableDemo
+import androidx.ui.demos.common.DemoCategory
+import androidx.ui.foundation.Text
+import androidx.ui.layout.Column
+import androidx.ui.material.Button
+import androidx.ui.viewinterop.AndroidView
+
+val ComplexTouchInterop = DemoCategory("Complex Touch Interop", listOf(
+ ComposableDemo("ReproOffsetIssue") { ComposeInAndroidInComposeEtcTargetingDemo() }
+))
+
+@Composable
+fun ComposeInAndroidInComposeEtcTargetingDemo() {
+ val context = ContextAmbient.current
+ Column {
+ Text("In this demo, there is a compose button inside Android, which is inside Compose, " +
+ "which inside Android... and on so on for a few times. The conversions of " +
+ "pointer input events at every level still work.")
+ AndroidWithCompose(context) {
+ AndroidWithCompose(context) {
+ AndroidWithCompose(context) {
+ Button( }) {
+ Text("Click me")
+ }
+ }
+ }
+ }
+ }
+}
+
+@Composable
+fun AndroidWithCompose(context: Context, children: @Composable () -> Unit) {
+ val anotherLayout =
+ escapeCompose { FrameLayout(context) }.also { view ->
+ view.setContent(Recomposer.current()) {
+ children()
+ }
+ view.setPadding(50, 50, 50, 50)
+ }
+ AndroidView(anotherLayout)
+}
\ No newline at end of file
diff --git a/ui/ui-core/api/0.1.0-dev14.txt b/ui/ui-core/api/0.1.0-dev14.txt
index 175813a..73e8834 100644
--- a/ui/ui-core/api/0.1.0-dev14.txt
+++ b/ui/ui-core/api/0.1.0-dev14.txt
@@ -188,6 +188,7 @@
method public static androidx.compose.ProvidableAmbient<android.content.res.Configuration> getConfigurationAmbient();
method public static androidx.compose.ProvidableAmbient<android.content.Context> getContextAmbient();
method public static androidx.compose.ProvidableAmbient<androidx.lifecycle.LifecycleOwner> getLifecycleOwnerAmbient();
+ method public static androidx.compose.ProvidableAmbient<android.view.View> getViewAmbient();
}
public final class AndroidComposeViewKt {
@@ -198,14 +199,19 @@
public interface AndroidOwner extends androidx.ui.core.Owner {
method public void addAndroidView(android.view.View view, androidx.ui.core.LayoutNode layoutNode);
method public kotlin.jvm.functions.Function0<kotlin.Unit> getConfigurationChangeObserver();
- method public androidx.lifecycle.LifecycleOwner? getLifecycleOwner();
method public android.view.View getView();
+ method public androidx.ui.core.AndroidOwner.ViewTreeOwners? getViewTreeOwners();
method public void removeAndroidView(android.view.View view);
method public void setConfigurationChangeObserver(kotlin.jvm.functions.Function0<kotlin.Unit> p);
- method public void setOnLifecycleOwnerAvailable(kotlin.jvm.functions.Function1<? super androidx.lifecycle.LifecycleOwner,kotlin.Unit> callback);
+ method public void setOnViewTreeOwnersAvailable(kotlin.jvm.functions.Function1<? super androidx.ui.core.AndroidOwner.ViewTreeOwners,kotlin.Unit> callback);
property public abstract kotlin.jvm.functions.Function0<kotlin.Unit> configurationChangeObserver;
- property public abstract androidx.lifecycle.LifecycleOwner? lifecycleOwner;
property public abstract android.view.View view;
+ property public abstract androidx.ui.core.AndroidOwner.ViewTreeOwners? viewTreeOwners;
+ }
+
+ public static final class AndroidOwner.ViewTreeOwners {
+ ctor public AndroidOwner.ViewTreeOwners(androidx.lifecycle.LifecycleOwner lifecycleOwner);
+ method public androidx.lifecycle.LifecycleOwner getLifecycleOwner();
}
public final class ClipKt {
diff --git a/ui/ui-core/api/current.txt b/ui/ui-core/api/current.txt
index 175813a..73e8834 100644
--- a/ui/ui-core/api/current.txt
+++ b/ui/ui-core/api/current.txt
@@ -188,6 +188,7 @@
method public static androidx.compose.ProvidableAmbient<android.content.res.Configuration> getConfigurationAmbient();
method public static androidx.compose.ProvidableAmbient<android.content.Context> getContextAmbient();
method public static androidx.compose.ProvidableAmbient<androidx.lifecycle.LifecycleOwner> getLifecycleOwnerAmbient();
+ method public static androidx.compose.ProvidableAmbient<android.view.View> getViewAmbient();
}
public final class AndroidComposeViewKt {
@@ -198,14 +199,19 @@
public interface AndroidOwner extends androidx.ui.core.Owner {
method public void addAndroidView(android.view.View view, androidx.ui.core.LayoutNode layoutNode);
method public kotlin.jvm.functions.Function0<kotlin.Unit> getConfigurationChangeObserver();
- method public androidx.lifecycle.LifecycleOwner? getLifecycleOwner();
method public android.view.View getView();
+ method public androidx.ui.core.AndroidOwner.ViewTreeOwners? getViewTreeOwners();
method public void removeAndroidView(android.view.View view);
method public void setConfigurationChangeObserver(kotlin.jvm.functions.Function0<kotlin.Unit> p);
- method public void setOnLifecycleOwnerAvailable(kotlin.jvm.functions.Function1<? super androidx.lifecycle.LifecycleOwner,kotlin.Unit> callback);
+ method public void setOnViewTreeOwnersAvailable(kotlin.jvm.functions.Function1<? super androidx.ui.core.AndroidOwner.ViewTreeOwners,kotlin.Unit> callback);
property public abstract kotlin.jvm.functions.Function0<kotlin.Unit> configurationChangeObserver;
- property public abstract androidx.lifecycle.LifecycleOwner? lifecycleOwner;
property public abstract android.view.View view;
+ property public abstract androidx.ui.core.AndroidOwner.ViewTreeOwners? viewTreeOwners;
+ }
+
+ public static final class AndroidOwner.ViewTreeOwners {
+ ctor public AndroidOwner.ViewTreeOwners(androidx.lifecycle.LifecycleOwner lifecycleOwner);
+ method public androidx.lifecycle.LifecycleOwner getLifecycleOwner();
}
public final class ClipKt {
diff --git a/ui/ui-core/api/public_plus_experimental_0.1.0-dev14.txt b/ui/ui-core/api/public_plus_experimental_0.1.0-dev14.txt
index 8073ed8..b34e963 100644
--- a/ui/ui-core/api/public_plus_experimental_0.1.0-dev14.txt
+++ b/ui/ui-core/api/public_plus_experimental_0.1.0-dev14.txt
@@ -188,6 +188,7 @@
method public static androidx.compose.ProvidableAmbient<android.content.res.Configuration> getConfigurationAmbient();
method public static androidx.compose.ProvidableAmbient<android.content.Context> getContextAmbient();
method public static androidx.compose.ProvidableAmbient<androidx.lifecycle.LifecycleOwner> getLifecycleOwnerAmbient();
+ method public static androidx.compose.ProvidableAmbient<android.view.View> getViewAmbient();
}
public final class AndroidComposeViewKt {
@@ -198,14 +199,19 @@
public interface AndroidOwner extends androidx.ui.core.Owner {
method public void addAndroidView(android.view.View view, androidx.ui.core.LayoutNode layoutNode);
method public kotlin.jvm.functions.Function0<kotlin.Unit> getConfigurationChangeObserver();
- method public androidx.lifecycle.LifecycleOwner? getLifecycleOwner();
method public android.view.View getView();
+ method public androidx.ui.core.AndroidOwner.ViewTreeOwners? getViewTreeOwners();
method public void removeAndroidView(android.view.View view);
method public void setConfigurationChangeObserver(kotlin.jvm.functions.Function0<kotlin.Unit> p);
- method public void setOnLifecycleOwnerAvailable(kotlin.jvm.functions.Function1<? super androidx.lifecycle.LifecycleOwner,kotlin.Unit> callback);
+ method public void setOnViewTreeOwnersAvailable(kotlin.jvm.functions.Function1<? super androidx.ui.core.AndroidOwner.ViewTreeOwners,kotlin.Unit> callback);
property public abstract kotlin.jvm.functions.Function0<kotlin.Unit> configurationChangeObserver;
- property public abstract androidx.lifecycle.LifecycleOwner? lifecycleOwner;
property public abstract android.view.View view;
+ property public abstract androidx.ui.core.AndroidOwner.ViewTreeOwners? viewTreeOwners;
+ }
+
+ public static final class AndroidOwner.ViewTreeOwners {
+ ctor public AndroidOwner.ViewTreeOwners(androidx.lifecycle.LifecycleOwner lifecycleOwner);
+ method public androidx.lifecycle.LifecycleOwner getLifecycleOwner();
}
public final class ClipKt {
diff --git a/ui/ui-core/api/public_plus_experimental_current.txt b/ui/ui-core/api/public_plus_experimental_current.txt
index 8073ed8..b34e963 100644
--- a/ui/ui-core/api/public_plus_experimental_current.txt
+++ b/ui/ui-core/api/public_plus_experimental_current.txt
@@ -188,6 +188,7 @@
method public static androidx.compose.ProvidableAmbient<android.content.res.Configuration> getConfigurationAmbient();
method public static androidx.compose.ProvidableAmbient<android.content.Context> getContextAmbient();
method public static androidx.compose.ProvidableAmbient<androidx.lifecycle.LifecycleOwner> getLifecycleOwnerAmbient();
+ method public static androidx.compose.ProvidableAmbient<android.view.View> getViewAmbient();
}
public final class AndroidComposeViewKt {
@@ -198,14 +199,19 @@
public interface AndroidOwner extends androidx.ui.core.Owner {
method public void addAndroidView(android.view.View view, androidx.ui.core.LayoutNode layoutNode);
method public kotlin.jvm.functions.Function0<kotlin.Unit> getConfigurationChangeObserver();
- method public androidx.lifecycle.LifecycleOwner? getLifecycleOwner();
method public android.view.View getView();
+ method public androidx.ui.core.AndroidOwner.ViewTreeOwners? getViewTreeOwners();
method public void removeAndroidView(android.view.View view);
method public void setConfigurationChangeObserver(kotlin.jvm.functions.Function0<kotlin.Unit> p);
- method public void setOnLifecycleOwnerAvailable(kotlin.jvm.functions.Function1<? super androidx.lifecycle.LifecycleOwner,kotlin.Unit> callback);
+ method public void setOnViewTreeOwnersAvailable(kotlin.jvm.functions.Function1<? super androidx.ui.core.AndroidOwner.ViewTreeOwners,kotlin.Unit> callback);
property public abstract kotlin.jvm.functions.Function0<kotlin.Unit> configurationChangeObserver;
- property public abstract androidx.lifecycle.LifecycleOwner? lifecycleOwner;
property public abstract android.view.View view;
+ property public abstract androidx.ui.core.AndroidOwner.ViewTreeOwners? viewTreeOwners;
+ }
+
+ public static final class AndroidOwner.ViewTreeOwners {
+ ctor public AndroidOwner.ViewTreeOwners(androidx.lifecycle.LifecycleOwner lifecycleOwner);
+ method public androidx.lifecycle.LifecycleOwner getLifecycleOwner();
}
public final class ClipKt {
diff --git a/ui/ui-core/api/restricted_0.1.0-dev14.txt b/ui/ui-core/api/restricted_0.1.0-dev14.txt
index 8309f7e..67da9f9 100644
--- a/ui/ui-core/api/restricted_0.1.0-dev14.txt
+++ b/ui/ui-core/api/restricted_0.1.0-dev14.txt
@@ -188,6 +188,7 @@
method public static androidx.compose.ProvidableAmbient<android.content.res.Configuration> getConfigurationAmbient();
method public static androidx.compose.ProvidableAmbient<android.content.Context> getContextAmbient();
method public static androidx.compose.ProvidableAmbient<androidx.lifecycle.LifecycleOwner> getLifecycleOwnerAmbient();
+ method public static androidx.compose.ProvidableAmbient<android.view.View> getViewAmbient();
}
public final class AndroidComposeViewKt {
@@ -198,14 +199,14 @@
public interface AndroidOwner extends androidx.ui.core.Owner {
method public void addAndroidView(android.view.View view, androidx.ui.core.LayoutNode layoutNode);
method public kotlin.jvm.functions.Function0<kotlin.Unit> getConfigurationChangeObserver();
- method public androidx.lifecycle.LifecycleOwner? getLifecycleOwner();
method public android.view.View getView();
+ method public androidx.ui.core.AndroidOwner.ViewTreeOwners? getViewTreeOwners();
method public void removeAndroidView(android.view.View view);
method public void setConfigurationChangeObserver(kotlin.jvm.functions.Function0<kotlin.Unit> p);
- method public void setOnLifecycleOwnerAvailable(kotlin.jvm.functions.Function1<? super androidx.lifecycle.LifecycleOwner,kotlin.Unit> callback);
+ method public void setOnViewTreeOwnersAvailable(kotlin.jvm.functions.Function1<? super androidx.ui.core.AndroidOwner.ViewTreeOwners,kotlin.Unit> callback);
property public abstract kotlin.jvm.functions.Function0<kotlin.Unit> configurationChangeObserver;
- property public abstract androidx.lifecycle.LifecycleOwner? lifecycleOwner;
property public abstract android.view.View view;
+ property public abstract androidx.ui.core.AndroidOwner.ViewTreeOwners? viewTreeOwners;
}
@RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP) public static final class AndroidOwner.Companion {
@@ -214,6 +215,11 @@
property public final kotlin.jvm.functions.Function1<androidx.ui.core.AndroidOwner,kotlin.Unit>? onAndroidOwnerCreatedCallback;
}
+ public static final class AndroidOwner.ViewTreeOwners {
+ ctor public AndroidOwner.ViewTreeOwners(androidx.lifecycle.LifecycleOwner lifecycleOwner);
+ method public androidx.lifecycle.LifecycleOwner getLifecycleOwner();
+ }
+
public final class ClipKt {
method @androidx.compose.Stable public static androidx.ui.core.Modifier clip(androidx.ui.core.Modifier, androidx.ui.graphics.Shape shape);
method @androidx.compose.Stable public static androidx.ui.core.Modifier clipToBounds(androidx.ui.core.Modifier);
diff --git a/ui/ui-core/api/restricted_current.txt b/ui/ui-core/api/restricted_current.txt
index 8309f7e..67da9f9 100644
--- a/ui/ui-core/api/restricted_current.txt
+++ b/ui/ui-core/api/restricted_current.txt
@@ -188,6 +188,7 @@
method public static androidx.compose.ProvidableAmbient<android.content.res.Configuration> getConfigurationAmbient();
method public static androidx.compose.ProvidableAmbient<android.content.Context> getContextAmbient();
method public static androidx.compose.ProvidableAmbient<androidx.lifecycle.LifecycleOwner> getLifecycleOwnerAmbient();
+ method public static androidx.compose.ProvidableAmbient<android.view.View> getViewAmbient();
}
public final class AndroidComposeViewKt {
@@ -198,14 +199,14 @@
public interface AndroidOwner extends androidx.ui.core.Owner {
method public void addAndroidView(android.view.View view, androidx.ui.core.LayoutNode layoutNode);
method public kotlin.jvm.functions.Function0<kotlin.Unit> getConfigurationChangeObserver();
- method public androidx.lifecycle.LifecycleOwner? getLifecycleOwner();
method public android.view.View getView();
+ method public androidx.ui.core.AndroidOwner.ViewTreeOwners? getViewTreeOwners();
method public void removeAndroidView(android.view.View view);
method public void setConfigurationChangeObserver(kotlin.jvm.functions.Function0<kotlin.Unit> p);
- method public void setOnLifecycleOwnerAvailable(kotlin.jvm.functions.Function1<? super androidx.lifecycle.LifecycleOwner,kotlin.Unit> callback);
+ method public void setOnViewTreeOwnersAvailable(kotlin.jvm.functions.Function1<? super androidx.ui.core.AndroidOwner.ViewTreeOwners,kotlin.Unit> callback);
property public abstract kotlin.jvm.functions.Function0<kotlin.Unit> configurationChangeObserver;
- property public abstract androidx.lifecycle.LifecycleOwner? lifecycleOwner;
property public abstract android.view.View view;
+ property public abstract androidx.ui.core.AndroidOwner.ViewTreeOwners? viewTreeOwners;
}
@RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP) public static final class AndroidOwner.Companion {
@@ -214,6 +215,11 @@
property public final kotlin.jvm.functions.Function1<androidx.ui.core.AndroidOwner,kotlin.Unit>? onAndroidOwnerCreatedCallback;
}
+ public static final class AndroidOwner.ViewTreeOwners {
+ ctor public AndroidOwner.ViewTreeOwners(androidx.lifecycle.LifecycleOwner lifecycleOwner);
+ method public androidx.lifecycle.LifecycleOwner getLifecycleOwner();
+ }
+
public final class ClipKt {
method @androidx.compose.Stable public static androidx.ui.core.Modifier clip(androidx.ui.core.Modifier, androidx.ui.graphics.Shape shape);
method @androidx.compose.Stable public static androidx.ui.core.Modifier clipToBounds(androidx.ui.core.Modifier);
diff --git a/ui/ui-core/build.gradle b/ui/ui-core/build.gradle
index c073121..5187b77 100644
--- a/ui/ui-core/build.gradle
+++ b/ui/ui-core/build.gradle
@@ -34,19 +34,27 @@
implementation(KOTLIN_COROUTINES_ANDROID)
api "androidx.annotation:annotation:1.1.0"
- api "androidx.activity:activity:1.2.0-alpha02"
+ api "androidx.activity:activity:1.2.0-alpha05"
+
api project(":ui:ui-unit")
api project(":ui:ui-graphics")
api project(":ui:ui-text-core")
api project(":ui:ui-vector")
api project(":ui:ui-animation-core")
+ api project(":ui:ui-saved-instance-state")
implementation project(":ui:ui-util")
implementation project(":compose:compose-runtime")
- implementation "androidx.lifecycle:lifecycle-runtime:2.3.0-alpha01"
- implementation project(":ui:ui-saved-instance-state")
implementation "androidx.autofill:autofill:1.0.0"
+ // we don't use these dependencies but we need to ensure at least these versions are used if
+ // the user adds these dependencies as otherwise AppCompatActivity and Fragment will not
+ // propagate ViewTree*Owners we are relying on and we will crash.
+ implementation "androidx.fragment:fragment:1.3.0-alpha05"
+ // due to b/152023266 we can't add these dependency right now
+ // to be fixed as part of b/158301343
+ // implementation "androidx.appcompat:appcompat:1.3.0-alpha01"
+
testImplementation(ANDROIDX_TEST_RULES)
testImplementation(ANDROIDX_TEST_RUNNER)
testImplementation(JUNIT)
@@ -73,6 +81,8 @@
androidTestImplementation project(":ui:ui-test-font")
androidTestImplementation project(":ui:ui-layout")
androidTestImplementation project(":ui:ui-foundation")
+ androidTestImplementation "androidx.fragment:fragment:1.2.4"
+ androidTestImplementation "androidx.appcompat:appcompat:1.1.0"
}
androidx {
diff --git a/ui/ui-core/src/androidTest/AndroidManifest.xml b/ui/ui-core/src/androidTest/AndroidManifest.xml
index 4704cda..935a68e 100644
--- a/ui/ui-core/src/androidTest/AndroidManifest.xml
+++ b/ui/ui-core/src/androidTest/AndroidManifest.xml
@@ -19,7 +19,9 @@
<activity
android:name="androidx.ui.framework.test.TestActivity"
android:theme="@android:style/Theme.Material.NoActionBar.Fullscreen" />
- <activity android:name="androidx.activity.ComponentActivity" />
<activity android:name="androidx.ui.core.AndroidPointerInputTestActivity" />
+ <activity android:name="androidx.appcompat.app.AppCompatActivity"
+ android:theme="@style/Theme.AppCompat"/>
+ <activity android:name="androidx.fragment.app.FragmentActivity"/>
</application>
</manifest>
diff --git a/ui/ui-core/src/androidTest/java/androidx/ui/core/AndroidAutoFillTest.kt b/ui/ui-core/src/androidTest/java/androidx/ui/core/AndroidAutoFillTest.kt
index 0c7bbba..a000527 100644
--- a/ui/ui-core/src/androidTest/java/androidx/ui/core/AndroidAutoFillTest.kt
+++ b/ui/ui-core/src/androidTest/java/androidx/ui/core/AndroidAutoFillTest.kt
@@ -19,7 +19,6 @@
import android.graphics.Rect
import android.util.SparseArray
import android.view.View
-import android.view.ViewGroup
import android.view.ViewStructure
import android.view.autofill.AutofillValue
import androidx.autofill.HintConstants.AUTOFILL_HINT_PERSON_NAME
@@ -47,13 +46,12 @@
private var autofill: Autofill? = null
private lateinit var autofillTree: AutofillTree
- private lateinit var ownerView: ViewGroup
+ private lateinit var ownerView: View
@Before
fun setup() {
composeTestRule.setContent {
- @Suppress("DEPRECATION")
- ownerView = OwnerAmbient.current as ViewGroup
+ ownerView = ViewAmbient.current
autofill = AutofillAmbient.current
autofillTree = AutofillTreeAmbient.current
}
diff --git a/ui/ui-core/src/androidTest/java/androidx/ui/core/AndroidPointerInputTest.kt b/ui/ui-core/src/androidTest/java/androidx/ui/core/AndroidPointerInputTest.kt
index be4e9b5..8f3abf4 100644
--- a/ui/ui-core/src/androidTest/java/androidx/ui/core/AndroidPointerInputTest.kt
+++ b/ui/ui-core/src/androidTest/java/androidx/ui/core/AndroidPointerInputTest.kt
@@ -16,14 +16,16 @@
package androidx.ui.core
-import android.app.Activity
+import android.content.Context
import android.view.MotionEvent
import android.view.ViewGroup
import android.widget.FrameLayout
+import androidx.activity.ComponentActivity
import androidx.compose.Composable
import androidx.compose.FrameManager
import androidx.compose.Recomposer
import androidx.compose.emptyContent
+import androidx.compose.escapeCompose
import androidx.compose.getValue
import androidx.compose.mutableStateOf
import androidx.compose.remember
@@ -31,15 +33,19 @@
import androidx.test.filters.SmallTest
import androidx.ui.core.pointerinput.PointerInputFilter
import androidx.ui.core.pointerinput.PointerInputModifier
+import androidx.ui.testutils.down
import androidx.ui.unit.IntPxSize
import androidx.ui.geometry.Offset
import androidx.ui.unit.ipx
+import androidx.ui.unit.milliseconds
+import androidx.ui.viewinterop.AndroidView
import com.google.common.truth.Truth.assertThat
import com.nhaarman.mockitokotlin2.any
import com.nhaarman.mockitokotlin2.never
import com.nhaarman.mockitokotlin2.spy
import com.nhaarman.mockitokotlin2.verify
import org.junit.Before
+import org.junit.Ignore
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
@@ -214,6 +220,75 @@
}
}
+ // Currently ignored because it fails when run via command line. Runs successfully in Android
+ // Studio.
+ @Test
+ // TODO(b/158099918): For some reason, this test fails when run from command line but passes
+ // when run from Android Studio. This seems to be caused by b/158099918. Once that is
+ // fixed, @Ignore can be removed.
+ @Ignore
+ fun dispatchTouchEvent_throughLayersOfAndroidAndCompose_hitsChildPointerInputFilter() {
+
+ // Arrange
+
+ val context = rule.activity
+
+ val log = mutableListOf<List<PointerInputChange>>()
+
+ countDown { latch ->
+ rule.runOnUiThread {
+ container.setContent(Recomposer.current()) {
+ AndroidWithCompose(context, 1) {
+ AndroidWithCompose(context, 10) {
+ AndroidWithCompose(context, 100) {
+ Layout(
+ {},
+ Modifier
+ .logEventsGestureFilter(log)
+ .onPositioned {
+ latch.countDown()
+ }
+ ) { _, _, _ ->
+ layout(5.ipx, 5.ipx) {}
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ rule.runOnUiThread {
+
+ androidComposeView = container.getChildAt(0) as AndroidComposeView
+
+ val locationInWindow = IntArray(2).also {
+ androidComposeView.getLocationInWindow(it)
+ }
+
+ val motionEvent = MotionEvent(
+ 0,
+ MotionEvent.ACTION_DOWN,
+ 1,
+ 0,
+ arrayOf(PointerProperties(0)),
+ arrayOf(
+ PointerCoords(
+ locationInWindow[0].toFloat() + 1 + 10 + 100,
+ locationInWindow[1].toFloat() + 1 + 10 + 100
+ )
+ )
+ )
+
+ // Act
+ androidComposeView.dispatchTouchEvent(motionEvent)
+
+ // Assert
+ assertThat(log).hasSize(1)
+ assertThat(log[0]).isEqualTo(listOf(down(0, 0.milliseconds, 0f, 0f)))
+ }
+ }
+
private fun dispatchTouchEvent_movementConsumptionInCompose(
consumeMovement: Boolean,
callsRequestDisallowInterceptTouchEvent: Boolean
@@ -272,6 +347,18 @@
}
}
+@Composable
+fun AndroidWithCompose(context: Context, androidPadding: Int, children: @Composable () -> Unit) {
+ val anotherLayout =
+ escapeCompose { FrameLayout(context) }.also { view ->
+ view.setContent(Recomposer.current()) {
+ children()
+ }
+ view.setPadding(androidPadding, androidPadding, androidPadding, androidPadding)
+ }
+ AndroidView(anotherLayout)
+}
+
fun Modifier.consumeMovementGestureFilter(consumeMovement: Boolean = false): Modifier = composed {
val filter = remember(consumeMovement) { ConsumeMovementGestureFilter(consumeMovement) }
PointerInputModifierImpl(filter)
@@ -283,6 +370,12 @@
this + PointerInputModifierImpl(filter)
}
+fun Modifier.logEventsGestureFilter(log: MutableList<List<PointerInputChange>>): Modifier =
+ composed {
+ val filter = remember { LogEventsGestureFilter(log) }
+ this + PointerInputModifierImpl(filter)
+ }
+
private class PointerInputModifierImpl(override val pointerInputFilter: PointerInputFilter) :
PointerInputModifier
@@ -322,6 +415,23 @@
override fun onCancel() {}
}
+private class LogEventsGestureFilter(val log: MutableList<List<PointerInputChange>>) :
+ PointerInputFilter() {
+
+ override fun onPointerInput(
+ changes: List<PointerInputChange>,
+ pass: PointerEventPass,
+ bounds: IntPxSize
+ ): List<PointerInputChange> {
+ if (pass == PointerEventPass.InitialDown) {
+ log.add(changes.map { it.copy() })
+ }
+ return changes
+ }
+
+ override fun onCancel() {}
+}
+
@Composable
fun FillLayout(modifier: Modifier = Modifier) {
Layout(emptyContent(), modifier) { _, constraints, _ ->
@@ -335,4 +445,4 @@
assertThat(countDownLatch.await(1, TimeUnit.SECONDS)).isTrue()
}
-class AndroidPointerInputTestActivity : Activity()
+class AndroidPointerInputTestActivity : ComponentActivity()
diff --git a/ui/ui-core/src/androidTest/java/androidx/ui/core/PopupTest.kt b/ui/ui-core/src/androidTest/java/androidx/ui/core/PopupTest.kt
index b2714d1..6c604df 100644
--- a/ui/ui-core/src/androidTest/java/androidx/ui/core/PopupTest.kt
+++ b/ui/ui-core/src/androidTest/java/androidx/ui/core/PopupTest.kt
@@ -79,8 +79,7 @@
composeTestRule.setContent {
// Get the compose view position on screen
- @Suppress("DEPRECATION")
- val composeView = OwnerAmbient.current as View
+ val composeView = ViewAmbient.current
val positionArray = IntArray(2)
composeView.getLocationOnScreen(positionArray)
composeViewAbsolutePosition = IntPxPosition(
diff --git a/ui/ui-core/src/androidTest/java/androidx/ui/core/focus/OwnerFocusTest.kt b/ui/ui-core/src/androidTest/java/androidx/ui/core/focus/OwnerFocusTest.kt
index d4bce6f..04e736d 100644
--- a/ui/ui-core/src/androidTest/java/androidx/ui/core/focus/OwnerFocusTest.kt
+++ b/ui/ui-core/src/androidTest/java/androidx/ui/core/focus/OwnerFocusTest.kt
@@ -16,12 +16,12 @@
package androidx.ui.core.focus
-import android.view.ViewGroup
+import android.view.View
import androidx.compose.Composable
import androidx.test.filters.SmallTest
import androidx.ui.core.focus.FocusDetailedState.Active
import androidx.ui.core.focus.FocusDetailedState.Inactive
-import androidx.ui.core.OwnerAmbient
+import androidx.ui.core.ViewAmbient
import androidx.ui.foundation.Box
import androidx.ui.test.createComposeRule
import androidx.ui.test.runOnIdleCompose
@@ -41,7 +41,7 @@
@Test
fun requestFocus_bringsViewInFocus() {
// Arrange.
- lateinit var ownerView: ViewGroup
+ lateinit var ownerView: View
val modifier = FocusModifierImpl(Inactive)
composeTestRule.setFocusableContent {
ownerView = getOwner()
@@ -63,7 +63,7 @@
@Test
fun whenOwnerGainsFocus_focusModifiersAreUpdated() {
// Arrange.
- lateinit var ownerView: ViewGroup
+ lateinit var ownerView: View
val modifier = FocusModifierImpl(Inactive)
composeTestRule.setFocusableContent {
ownerView = getOwner()
@@ -85,7 +85,7 @@
@Test
fun whenWindowGainsFocus_focusModifiersAreUpdated() {
// Arrange.
- lateinit var ownerView: ViewGroup
+ lateinit var ownerView: View
val modifier = FocusModifierImpl(Inactive)
composeTestRule.setFocusableContent {
ownerView = getOwner()
@@ -106,7 +106,7 @@
@Test
fun whenOwnerLosesFocus_focusModifiersAreUpdated() {
// Arrange.
- lateinit var ownerView: ViewGroup
+ lateinit var ownerView: View
val modifier = FocusModifierImpl(Inactive)
composeTestRule.setFocusableContent {
ownerView = getOwner()
@@ -130,7 +130,7 @@
@Test
fun whenWindowLosesFocus_focusStateIsUnchanged() {
// Arrange.
- lateinit var ownerView: ViewGroup
+ lateinit var ownerView: View
lateinit var modifier: FocusModifier
composeTestRule.setFocusableContent {
ownerView = getOwner()
@@ -152,7 +152,6 @@
}
}
- @Suppress("DEPRECATION")
@Composable
- private fun getOwner() = OwnerAmbient.current as ViewGroup
+ private fun getOwner() = ViewAmbient.current
}
diff --git a/ui/ui-core/src/androidTest/java/androidx/ui/core/lifecycleowner/LifecycleOwnerInAppCompatActivityTest.kt b/ui/ui-core/src/androidTest/java/androidx/ui/core/lifecycleowner/LifecycleOwnerInAppCompatActivityTest.kt
new file mode 100644
index 0000000..c61effc
--- /dev/null
+++ b/ui/ui-core/src/androidTest/java/androidx/ui/core/lifecycleowner/LifecycleOwnerInAppCompatActivityTest.kt
@@ -0,0 +1,87 @@
+/*
+ * Copyright 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package androidx.ui.core.lifecycleowner
+
+import android.widget.FrameLayout
+import androidx.appcompat.app.AppCompatActivity
+import androidx.compose.Recomposer
+import androidx.lifecycle.LifecycleOwner
+import androidx.test.filters.SmallTest
+import androidx.ui.core.LifecycleOwnerAmbient
+import androidx.ui.core.setContent
+import org.junit.Assert.assertEquals
+import org.junit.Assert.assertTrue
+import org.junit.Before
+import org.junit.Ignore
+import org.junit.Rule
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.junit.runners.JUnit4
+import java.util.concurrent.CountDownLatch
+import java.util.concurrent.TimeUnit
+
+@SmallTest
+@RunWith(JUnit4::class)
+class LifecycleOwnerInAppCompatActivityTest {
+ @Suppress("DEPRECATION")
+ @get:Rule
+ val activityTestRule = androidx.test.rule.ActivityTestRule<AppCompatActivity>(
+ AppCompatActivity::class.java
+ )
+ private lateinit var activity: AppCompatActivity
+
+ @Before
+ fun setup() {
+ activity = activityTestRule.activity
+ }
+
+ @Ignore("Disabled due to b/158301343")
+ @Test
+ fun lifecycleOwnerIsAvailable() {
+ val latch = CountDownLatch(1)
+ var owner: LifecycleOwner? = null
+
+ activityTestRule.runOnUiThread {
+ activity.setContent {
+ owner = LifecycleOwnerAmbient.current
+ latch.countDown()
+ }
+ }
+
+ assertTrue(latch.await(1, TimeUnit.SECONDS))
+ assertEquals(activity, owner)
+ }
+
+ @Ignore("Disabled due to b/158301343")
+ @Test
+ fun lifecycleOwnerIsAvailableWhenComposedIntoViewGroup() {
+ val latch = CountDownLatch(1)
+ var owner: LifecycleOwner? = null
+
+ activityTestRule.runOnUiThread {
+ val view = FrameLayout(activity)
+ activity.setContentView(view)
+ view.setContent(Recomposer.current()) {
+ owner = LifecycleOwnerAmbient.current
+ latch.countDown()
+ }
+ }
+
+ assertTrue(latch.await(1, TimeUnit.SECONDS))
+ assertEquals(activity, owner)
+ }
+}
diff --git a/ui/ui-core/src/androidTest/java/androidx/ui/core/lifecycleowner/LifecycleOwnerInComponentActivityTest.kt b/ui/ui-core/src/androidTest/java/androidx/ui/core/lifecycleowner/LifecycleOwnerInComponentActivityTest.kt
new file mode 100644
index 0000000..dfb2bab
--- /dev/null
+++ b/ui/ui-core/src/androidTest/java/androidx/ui/core/lifecycleowner/LifecycleOwnerInComponentActivityTest.kt
@@ -0,0 +1,84 @@
+/*
+ * Copyright 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package androidx.ui.core.lifecycleowner
+
+import android.widget.FrameLayout
+import androidx.activity.ComponentActivity
+import androidx.compose.Recomposer
+import androidx.lifecycle.LifecycleOwner
+import androidx.test.filters.SmallTest
+import androidx.ui.core.LifecycleOwnerAmbient
+import androidx.ui.core.setContent
+import org.junit.Assert.assertEquals
+import org.junit.Assert.assertTrue
+import org.junit.Before
+import org.junit.Rule
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.junit.runners.JUnit4
+import java.util.concurrent.CountDownLatch
+import java.util.concurrent.TimeUnit
+
+@SmallTest
+@RunWith(JUnit4::class)
+class LifecycleOwnerInComponentActivityTest {
+ @Suppress("DEPRECATION")
+ @get:Rule
+ val activityTestRule = androidx.test.rule.ActivityTestRule<ComponentActivity>(
+ ComponentActivity::class.java
+ )
+ private lateinit var activity: ComponentActivity
+
+ @Before
+ fun setup() {
+ activity = activityTestRule.activity
+ }
+
+ @Test
+ fun lifecycleOwnerIsAvailable() {
+ val latch = CountDownLatch(1)
+ var owner: LifecycleOwner? = null
+
+ activityTestRule.runOnUiThread {
+ activity.setContent {
+ owner = LifecycleOwnerAmbient.current
+ latch.countDown()
+ }
+ }
+
+ assertTrue(latch.await(1, TimeUnit.SECONDS))
+ assertEquals(activity, owner)
+ }
+
+ @Test
+ fun lifecycleOwnerIsAvailableWhenComposedIntoViewGroup() {
+ val latch = CountDownLatch(1)
+ var owner: LifecycleOwner? = null
+
+ activityTestRule.runOnUiThread {
+ val view = FrameLayout(activity)
+ activity.setContentView(view)
+ view.setContent(Recomposer.current()) {
+ owner = LifecycleOwnerAmbient.current
+ latch.countDown()
+ }
+ }
+
+ assertTrue(latch.await(1, TimeUnit.SECONDS))
+ assertEquals(activity, owner)
+ }
+}
diff --git a/ui/ui-core/src/androidTest/java/androidx/ui/core/lifecycleowner/LifecycleOwnerInFragmentTest.kt b/ui/ui-core/src/androidTest/java/androidx/ui/core/lifecycleowner/LifecycleOwnerInFragmentTest.kt
new file mode 100644
index 0000000..426f808
--- /dev/null
+++ b/ui/ui-core/src/androidTest/java/androidx/ui/core/lifecycleowner/LifecycleOwnerInFragmentTest.kt
@@ -0,0 +1,89 @@
+/*
+ * Copyright 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package androidx.ui.core.lifecycleowner
+
+import android.os.Bundle
+import android.view.LayoutInflater
+import android.view.ViewGroup
+import android.widget.FrameLayout
+import androidx.compose.Recomposer
+import androidx.fragment.app.Fragment
+import androidx.fragment.app.FragmentActivity
+import androidx.fragment.app.FragmentContainerView
+import androidx.lifecycle.LifecycleOwner
+import androidx.test.filters.SmallTest
+import androidx.ui.core.LifecycleOwnerAmbient
+import androidx.ui.core.setContent
+import org.junit.Assert.assertEquals
+import org.junit.Assert.assertTrue
+import org.junit.Before
+import org.junit.Rule
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.junit.runners.JUnit4
+import java.util.concurrent.CountDownLatch
+import java.util.concurrent.TimeUnit
+
+@SmallTest
+@RunWith(JUnit4::class)
+class LifecycleOwnerInFragment {
+ @Suppress("DEPRECATION")
+ @get:Rule
+ val activityTestRule = androidx.test.rule.ActivityTestRule<FragmentActivity>(
+ FragmentActivity::class.java
+ )
+ private lateinit var activity: FragmentActivity
+
+ @Before
+ fun setup() {
+ activity = activityTestRule.activity
+ }
+
+ @Test
+ fun lifecycleOwnerIsAvailable() {
+ val fragment = TestFragment()
+
+ activityTestRule.runOnUiThread {
+ val view = FragmentContainerView(activity)
+ view.id = 100
+ activity.setContentView(view)
+ activity.supportFragmentManager.beginTransaction()
+ .replace(100, fragment)
+ .commit()
+ }
+
+ assertTrue(fragment.latch.await(1, TimeUnit.SECONDS))
+ assertEquals(fragment.viewLifecycleOwner, fragment.owner)
+ }
+}
+
+class TestFragment : Fragment() {
+
+ var owner: LifecycleOwner? = null
+ val latch = CountDownLatch(1)
+
+ override fun onCreateView(
+ inflater: LayoutInflater,
+ container: ViewGroup?,
+ savedInstanceState: Bundle?
+ ) = FrameLayout(container?.context ?: requireContext()).apply {
+ setContent(Recomposer.current()) {
+ owner = LifecycleOwnerAmbient.current
+ latch.countDown()
+ }
+ }
+}
diff --git a/ui/ui-core/src/androidTest/java/androidx/ui/core/test/WrapperTest.kt b/ui/ui-core/src/androidTest/java/androidx/ui/core/test/WrapperTest.kt
index 8325f0d..1245d3d 100644
--- a/ui/ui-core/src/androidTest/java/androidx/ui/core/test/WrapperTest.kt
+++ b/ui/ui-core/src/androidTest/java/androidx/ui/core/test/WrapperTest.kt
@@ -28,11 +28,9 @@
import androidx.lifecycle.LifecycleRegistry
import androidx.lifecycle.ViewTreeLifecycleOwner
import androidx.test.filters.SmallTest
-import androidx.ui.core.LifecycleOwnerAmbient
import androidx.ui.core.setContent
import androidx.ui.framework.test.TestActivity
import org.junit.Assert.assertEquals
-import org.junit.Assert.assertNotNull
import org.junit.Assert.assertTrue
import org.junit.Before
import org.junit.Rule
@@ -84,40 +82,6 @@
}
@Test
- fun lifecycleOwnerIsAvailableInComponentActivity() {
- val latch = CountDownLatch(1)
- var owner: LifecycleOwner? = null
-
- activityTestRule.runOnUiThread {
- activity.setContent {
- owner = LifecycleOwnerAmbient.current
- latch.countDown()
- }
- }
-
- assertTrue(latch.await(1, TimeUnit.SECONDS))
- assertNotNull(owner)
- }
-
- @Test
- fun lifecycleOwnerIsAvailableWhenComposedIntoViewGroup() {
- val latch = CountDownLatch(1)
- var owner: LifecycleOwner? = null
-
- activityTestRule.runOnUiThread {
- val view = FrameLayout(activity)
- activity.setContentView(view)
- view.setContent(Recomposer.current()) {
- owner = LifecycleOwnerAmbient.current
- latch.countDown()
- }
- }
-
- assertTrue(latch.await(1, TimeUnit.SECONDS))
- assertNotNull(owner)
- }
-
- @Test
fun disposedWhenActivityDestroyed() {
val composedLatch = CountDownLatch(1)
val disposeLatch = CountDownLatch(1)
diff --git a/ui/ui-core/src/androidTest/java/androidx/ui/node/PointerInteropUtilsTest.kt b/ui/ui-core/src/androidTest/java/androidx/ui/node/PointerInteropUtilsTest.kt
index b5b4da43..b041f80 100644
--- a/ui/ui-core/src/androidTest/java/androidx/ui/node/PointerInteropUtilsTest.kt
+++ b/ui/ui-core/src/androidTest/java/androidx/ui/node/PointerInteropUtilsTest.kt
@@ -17,11 +17,14 @@
package androidx.ui.node
import android.view.MotionEvent
+import android.view.View
import androidx.test.filters.SmallTest
import androidx.ui.core.PointerInputChange
import androidx.ui.testutils.down
import androidx.ui.testutils.moveTo
import androidx.ui.testutils.up
+import androidx.ui.unit.IntPxPosition
+import androidx.ui.unit.ipx
import androidx.ui.unit.milliseconds
import com.google.common.truth.Truth
import org.junit.Test
@@ -35,7 +38,7 @@
@Test(expected = IllegalStateException::class)
fun toMotionEventScope_emptyList_throws() {
val list = listOf<PointerInputChange>()
- list.toMotionEventScope {}
+ list.toMotionEventScope(IntPxPosition.Origin) {}
}
@Test
@@ -52,7 +55,7 @@
)
lateinit var actual: MotionEvent
- list.toMotionEventScope {
+ list.toMotionEventScope(IntPxPosition.Origin) {
actual = it
}
@@ -73,7 +76,7 @@
)
lateinit var actual: MotionEvent
- list.toMotionEventScope {
+ list.toMotionEventScope(IntPxPosition.Origin) {
actual = it
}
@@ -97,7 +100,7 @@
)
lateinit var actual: MotionEvent
- list.toMotionEventScope {
+ list.toMotionEventScope(IntPxPosition.Origin) {
actual = it
}
@@ -121,7 +124,7 @@
)
lateinit var actual: MotionEvent
- list.toMotionEventScope {
+ list.toMotionEventScope(IntPxPosition.Origin) {
actual = it
}
@@ -145,7 +148,7 @@
)
lateinit var actual: MotionEvent
- list.toMotionEventScope {
+ list.toMotionEventScope(IntPxPosition.Origin) {
actual = it
}
@@ -169,7 +172,7 @@
)
lateinit var actual: MotionEvent
- list.toMotionEventScope {
+ list.toMotionEventScope(IntPxPosition.Origin) {
actual = it
}
@@ -192,7 +195,7 @@
)
lateinit var actual: MotionEvent
- list.toMotionEventScope {
+ list.toMotionEventScope(IntPxPosition.Origin) {
actual = it
}
@@ -216,7 +219,54 @@
)
lateinit var actual: MotionEvent
- list.toMotionEventScope {
+ list.toMotionEventScope(IntPxPosition.Origin) {
+ actual = it
+ }
+
+ assertEquals(actual, expected)
+ }
+
+ @Test
+ fun toMotionEventScope_globalOffsetsSet1Pointer_motionEventIsCorrect() {
+ val pointer1 = down(1, 2.milliseconds, 3f, 4f)
+
+ val list = listOf(pointer1)
+ val expected =
+ MotionEvent(
+ 2,
+ MotionEvent.ACTION_DOWN,
+ 1,
+ 0,
+ arrayOf(PointerProperties(1)),
+ arrayOf(PointerCoords(13f, 104f))
+ ).apply { offsetLocation(-10f, -100f) }
+ lateinit var actual: MotionEvent
+
+ list.toMotionEventScope(IntPxPosition(10.ipx, 100.ipx)) {
+ actual = it
+ }
+
+ assertEquals(actual, expected)
+ }
+
+ @Test
+ fun toMotionEventScope_globalOffsetsSet2Pointers_motionEventIsCorrect() {
+ val pointer1 = down(1, 2.milliseconds, 3f, 4f).moveTo(7.milliseconds, 3f, 4f)
+ val pointer2 = down(8, 7.milliseconds, 10f, 11f)
+
+ val list = listOf(pointer2, pointer1)
+ val expected =
+ MotionEvent(
+ 7,
+ MotionEvent.ACTION_POINTER_DOWN,
+ 2,
+ 0,
+ arrayOf(PointerProperties(8), PointerProperties(1)),
+ arrayOf(PointerCoords(110f, 1011f), PointerCoords(103f, 1004f))
+ ).apply { offsetLocation(-100f, -1000f) }
+ lateinit var actual: MotionEvent
+
+ list.toMotionEventScope(IntPxPosition(100.ipx, 1000.ipx)) {
actual = it
}
@@ -226,7 +276,7 @@
@Test(expected = IllegalStateException::class)
fun toCancelMotionEventScope_emptyList_throws() {
val list = listOf<PointerInputChange>()
- list.toCancelMotionEventScope {}
+ list.toCancelMotionEventScope(IntPxPosition.Origin) {}
}
@Test
@@ -245,7 +295,7 @@
)
lateinit var actual: MotionEvent
- list.toCancelMotionEventScope {
+ list.toCancelMotionEventScope(IntPxPosition.Origin) {
actual = it
}
@@ -269,7 +319,7 @@
)
lateinit var actual: MotionEvent
- list.toCancelMotionEventScope {
+ list.toCancelMotionEventScope(IntPxPosition.Origin) {
actual = it
}
@@ -293,7 +343,54 @@
)
lateinit var actual: MotionEvent
- list.toCancelMotionEventScope {
+ list.toCancelMotionEventScope(IntPxPosition.Origin) {
+ actual = it
+ }
+
+ assertEquals(actual, expected)
+ }
+
+ @Test
+ fun toCancelMotionEventScope_globalOffsetsSet1Pointer_motionEventIsCorrect() {
+ val pointer1 = down(1, 2.milliseconds, 3f, 4f)
+
+ val list = listOf(pointer1)
+ val expected =
+ MotionEvent(
+ 2,
+ MotionEvent.ACTION_CANCEL,
+ 1,
+ 0,
+ arrayOf(PointerProperties(1)),
+ arrayOf(PointerCoords(13f, 104f))
+ ).apply { offsetLocation(-10f, -100f) }
+ lateinit var actual: MotionEvent
+
+ list.toCancelMotionEventScope(IntPxPosition(10.ipx, 100.ipx)) {
+ actual = it
+ }
+
+ assertEquals(actual, expected)
+ }
+
+ @Test
+ fun toCancelMotionEventScope_globalOffsetsSet2Pointers_motionEventIsCorrect() {
+ val pointer1 = down(1, 2.milliseconds, 3f, 4f).moveTo(7.milliseconds, 3f, 4f)
+ val pointer2 = down(8, 7.milliseconds, 10f, 11f)
+
+ val list = listOf(pointer2, pointer1)
+ val expected =
+ MotionEvent(
+ 7,
+ MotionEvent.ACTION_CANCEL,
+ 2,
+ 0,
+ arrayOf(PointerProperties(8), PointerProperties(1)),
+ arrayOf(PointerCoords(110f, 1011f), PointerCoords(103f, 1004f))
+ ).apply { offsetLocation(-100f, -1000f) }
+ lateinit var actual: MotionEvent
+
+ list.toCancelMotionEventScope(IntPxPosition(100.ipx, 1000.ipx)) {
actual = it
}
@@ -374,6 +471,20 @@
Truth.assertThat(actualPointerProperties).isEqualTo(expectedPointerProperties)
}
+ // Equal pointer coords relative to local region.
+ assertEqualPointerCoords(actual, expected)
+
+ // Equal pointer coords relative to screen.
+ assertEqualPointerCoords(
+ actual.asOffsetToScreen(),
+ expected.asOffsetToScreen()
+ )
+}
+
+/**
+ * Asserts that 2 [MotionEvent]s' [PointerCoords] are the same.
+ */
+private fun assertEqualPointerCoords(actual: MotionEvent, expected: MotionEvent) {
val actualPointerCoords = MotionEvent.PointerCoords()
val expectedPointerCoords = MotionEvent.PointerCoords()
repeat(expected.pointerCount) { index ->
@@ -383,3 +494,12 @@
Truth.assertThat(actualPointerCoords.y).isEqualTo(expectedPointerCoords.y)
}
}
+
+/**
+ * Creates a new [MotionEvent] that is offset to the screen instead of the [View] it was
+ * dispatched to.
+ */
+private fun MotionEvent.asOffsetToScreen() =
+ MotionEvent.obtain(this).also { motionEvent ->
+ motionEvent.offsetLocation(rawX - x, rawY - y)
+ }
diff --git a/ui/ui-core/src/main/java/androidx/ui/core/AndroidAmbients.kt b/ui/ui-core/src/main/java/androidx/ui/core/AndroidAmbients.kt
index e594e2f..31c5385 100644
--- a/ui/ui-core/src/main/java/androidx/ui/core/AndroidAmbients.kt
+++ b/ui/ui-core/src/main/java/androidx/ui/core/AndroidAmbients.kt
@@ -18,6 +18,7 @@
import android.content.Context
import android.content.res.Configuration
+import android.view.View
import androidx.compose.Composable
import androidx.compose.NeverEqual
import androidx.compose.Providers
@@ -48,12 +49,9 @@
val LifecycleOwnerAmbient = staticAmbientOf<LifecycleOwner>()
/**
- * Don't use this
- * @suppress
+ * The ambient containing the current Compose [View].
*/
-// TODO(b/139866476): The Owner should not be exposed via ambient
-@Deprecated(message = "This will be removed as of b/139866476")
-val OwnerAmbient = staticAmbientOf<Owner>()
+val ViewAmbient = staticAmbientOf<View>()
@Composable
internal fun ProvideAndroidAmbients(owner: AndroidOwner, content: @Composable () -> Unit) {
@@ -71,13 +69,15 @@
}
val uriHandler = remember { AndroidUriHandler(context) }
+ val viewTreeOwners = owner.viewTreeOwners ?: throw IllegalStateException(
+ "Called when the ViewTreeOwnersAvailability is not yet in Available state"
+ )
Providers(
ConfigurationAmbient provides configuration,
ContextAmbient provides context,
- LifecycleOwnerAmbient provides requireNotNull(owner.lifecycleOwner),
- @Suppress("DEPRECATION")
- OwnerAmbient provides owner
+ LifecycleOwnerAmbient provides viewTreeOwners.lifecycleOwner,
+ ViewAmbient provides owner.view
) {
ProvideCommonAmbients(
owner = owner,
diff --git a/ui/ui-core/src/main/java/androidx/ui/core/AndroidComposeView.kt b/ui/ui-core/src/main/java/androidx/ui/core/AndroidComposeView.kt
index 7442d21..538db54 100644
--- a/ui/ui-core/src/main/java/androidx/ui/core/AndroidComposeView.kt
+++ b/ui/ui-core/src/main/java/androidx/ui/core/AndroidComposeView.kt
@@ -39,9 +39,7 @@
import androidx.core.os.HandlerCompat
import androidx.core.view.ViewCompat
import androidx.core.view.accessibility.AccessibilityNodeProviderCompat
-import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleOwner
-import androidx.lifecycle.LifecycleRegistry
import androidx.lifecycle.ViewTreeLifecycleOwner
import androidx.ui.autofill.AndroidAutofill
import androidx.ui.autofill.Autofill
@@ -50,6 +48,7 @@
import androidx.ui.autofill.populateViewStructure
import androidx.ui.autofill.registerCallback
import androidx.ui.autofill.unregisterCallback
+import androidx.ui.core.AndroidOwner.ViewTreeOwners
import androidx.ui.core.clipboard.AndroidClipboardManager
import androidx.ui.core.clipboard.ClipboardManager
import androidx.ui.core.focus.FOCUS_TAG
@@ -107,7 +106,7 @@
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
internal class AndroidComposeView constructor(
context: Context,
- lifecycleOwner: LifecycleOwner?
+ initialLifecycleOwner: LifecycleOwner?
) : ViewGroup(context), AndroidOwner {
override val view: View = this
@@ -527,24 +526,24 @@
}
}
- override var lifecycleOwner: LifecycleOwner? = lifecycleOwner
+ override var viewTreeOwners: ViewTreeOwners? =
+ if (initialLifecycleOwner != null) {
+ ViewTreeOwners(initialLifecycleOwner)
+ } else {
+ null
+ }
private set
- private var onLifecycleAvailable: ((LifecycleOwner) -> Unit)? = null
-
- override fun setOnLifecycleOwnerAvailable(callback: (LifecycleOwner) -> Unit) {
- require(lifecycleOwner == null) { "LifecycleOwner is already available" }
- >
+ override fun setOnViewTreeOwnersAvailable(callback: (ViewTreeOwners) -> Unit) {
+ val viewTreeOwners = viewTreeOwners
+ if (viewTreeOwners != null) {
+ callback(viewTreeOwners)
+ } else {
+ >
+ }
}
- // Workaround for the cases when we don't have a real LifecycleOwner, this happens when
- // ViewTreeLifecycleOwner.get(this) returned null:
- // 1) we are in AppCompatActivity and there is a bug for(should be fixed soon)
- // 2) we are in a regular Activity. once we fix bug in AppCompatActivity we stop support it.
- private val viewLifecycleOwner = object : LifecycleOwner {
- val lifecycleRegistry = LifecycleRegistry(this)
- override fun getLifecycle() = lifecycleRegistry
- }
+ private var onViewTreeOwnersAvailable: ((ViewTreeOwners) -> Unit)? = null
override fun onAttachedToWindow() {
super.onAttachedToWindow()
@@ -552,12 +551,17 @@
modelObserver.enableModelUpdatesObserving(true)
ifDebug { if (autofillSupported()) _autofill?.registerCallback() }
root.attach(this)
- if (lifecycleOwner == null) {
- lifecycleOwner = ViewTreeLifecycleOwner.get(this) ?: viewLifecycleOwner
+
+ if (viewTreeOwners == null) {
+ val lifecycleOwner = ViewTreeLifecycleOwner.get(this) ?: throw IllegalStateException(
+ "Composed into the View which doesn't propagate ViewTreeLifecycleOwner!"
+ )
+ val viewTreeOwners = ViewTreeOwners(
+ lifecycleOwner = lifecycleOwner
+ )
+ this.viewTreeOwners = viewTreeOwners
+ onViewTreeOwnersAvailable?.invoke(viewTreeOwners)
}
- onLifecycleAvailable?.invoke(lifecycleOwner!!)
- >
- viewLifecycleOwner.lifecycleRegistry.currentState = Lifecycle.State.RESUMED
}
override fun onDetachedFromWindow() {
@@ -565,7 +569,6 @@
modelObserver.enableModelUpdatesObserving(false)
ifDebug { if (autofillSupported()) _autofill?.unregisterCallback() }
root.detach()
- viewLifecycleOwner.lifecycleRegistry.currentState = Lifecycle.State.CREATED
}
override fun onProvideAutofillVirtualStructure(structure: ViewStructure?, flags: Int) {
diff --git a/ui/ui-core/src/main/java/androidx/ui/core/AndroidOwner.kt b/ui/ui-core/src/main/java/androidx/ui/core/AndroidOwner.kt
index 6494bb9..cd01ac6 100644
--- a/ui/ui-core/src/main/java/androidx/ui/core/AndroidOwner.kt
+++ b/ui/ui-core/src/main/java/androidx/ui/core/AndroidOwner.kt
@@ -50,15 +50,16 @@
var configurationChangeObserver: () -> Unit
/**
- * The [LifecycleOwner] associated with this owner. If it's null you can wait for it to became
- * available using [setOnLifecycleOwnerAvailable].
+ * Current [ViewTreeOwners]. Use [setOnViewTreeOwnersAvailable] if you want to
+ * execute your code when the object will be created.
*/
- val lifecycleOwner: LifecycleOwner?
+ val viewTreeOwners: ViewTreeOwners?
/**
- * Allows other components to be notified when the [lifecycleOwner] became available.
+ * The callback to be executed when [viewTreeOwners] is created and not-null anymore.
+ * Note that this callback will be fired inline when it is already available
*/
- fun setOnLifecycleOwnerAvailable(callback: (LifecycleOwner) -> Unit)
+ fun setOnViewTreeOwnersAvailable(callback: (ViewTreeOwners) -> Unit)
/** @suppress */
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
@@ -72,4 +73,17 @@
@TestOnly
set
}
+
+ /**
+ * Combines objects populated via ViewTree*Owner
+ */
+ class ViewTreeOwners(
+ /**
+ * The [LifecycleOwner] associated with this owner.
+ */
+ val lifecycleOwner: LifecycleOwner
+ // TODO: Add these two items here as well
+ // val savedStateRegistry: UiSavedStateRegistry,
+ // val viewModelStoreOwner: ViewTreeViewModelStoreOwner
+ )
}
diff --git a/ui/ui-core/src/main/java/androidx/ui/core/ComposedModifier.kt b/ui/ui-core/src/main/java/androidx/ui/core/ComposedModifier.kt
index 1e269e4..2f8161e 100644
--- a/ui/ui-core/src/main/java/androidx/ui/core/ComposedModifier.kt
+++ b/ui/ui-core/src/main/java/androidx/ui/core/ComposedModifier.kt
@@ -17,6 +17,7 @@
package androidx.ui.core
import androidx.compose.Composable
+import androidx.compose.ComposeCompilerApi
import androidx.compose.Composer
/**
@@ -41,6 +42,7 @@
* Call right before setting the returned modifier on an emitted node.
* You almost certainly do not need to call this function directly.
*/
+@OptIn(ComposeCompilerApi::class)
fun Composer<*>.materialize(modifier: Modifier): Modifier {
if (modifier.all { it !is ComposedModifier }) return modifier
diff --git a/ui/ui-core/src/main/java/androidx/ui/core/Layout.kt b/ui/ui-core/src/main/java/androidx/ui/core/Layout.kt
index d48084e..531a865 100644
--- a/ui/ui-core/src/main/java/androidx/ui/core/Layout.kt
+++ b/ui/ui-core/src/main/java/androidx/ui/core/Layout.kt
@@ -20,6 +20,7 @@
import androidx.compose.Composable
import androidx.compose.Composition
import androidx.compose.CompositionReference
+import androidx.compose.ExperimentalComposeApi
import androidx.compose.FrameManager
import androidx.compose.Recomposer
import androidx.compose.Stable
@@ -466,6 +467,8 @@
val state = remember { WithConstrainsState() }
state.children = children
state.context = ContextAmbient.current
+ // TODO(lmr): refactor these APIs so that recomposer isn't necessary
+ @OptIn(ExperimentalComposeApi::class)
state.recomposer = currentComposer.recomposer
state.compositionRef = compositionReference()
// if this code was executed subcomposition must be triggered as well
@@ -588,6 +591,7 @@
}
}
+ @OptIn(ExperimentalComposeApi::class)
fun subcompose() {
// TODO(b/150390669): Review use of @Untracked
composition =
diff --git a/ui/ui-core/src/main/java/androidx/ui/core/Popup.kt b/ui/ui-core/src/main/java/androidx/ui/core/Popup.kt
index cfc2401..1f03a51 100644
--- a/ui/ui-core/src/main/java/androidx/ui/core/Popup.kt
+++ b/ui/ui-core/src/main/java/androidx/ui/core/Popup.kt
@@ -26,6 +26,7 @@
import android.widget.FrameLayout
import androidx.compose.Composable
import androidx.compose.Composition
+import androidx.compose.ExperimentalComposeApi
import androidx.compose.Immutable
import androidx.compose.Providers
import androidx.compose.ambientOf
@@ -156,18 +157,14 @@
onDismissRequest: (() -> Unit)? = null,
children: @Composable () -> Unit
) {
- val context = ContextAmbient.current
- // TODO(b/139866476): Decide if we want to expose the AndroidComposeView
- @Suppress("DEPRECATION")
- val owner = OwnerAmbient.current
+ val view = ViewAmbient.current
val providedTestTag = PopupTestTagAmbient.current
val popupPositionProperties = remember { PopupPositionProperties() }
val popupLayout = remember(isFocusable) {
escapeCompose {
PopupLayout(
- context = context,
- composeView = owner as View,
+ composeView = view,
popupIsFocusable = isFocusable,
>
popupPositionProperties = popupPositionProperties,
@@ -199,6 +196,8 @@
layout(0.ipx, 0.ipx) {}
}
+ // TODO(lmr): refactor these APIs so that recomposer isn't necessary
+ @OptIn(ExperimentalComposeApi::class)
val recomposer = currentComposer.recomposer
onCommit {
composition = popupLayout.setContent(recomposer) {
@@ -258,7 +257,6 @@
/**
* The layout the popup uses to display its content.
*
- * @param context The application context.
* @param composeView The parent view of the popup which is the AndroidComposeView.
* @param popupIsFocusable Indicates if the popup can grab the focus.
* @param onDismissRequest Executed when the popup tries to dismiss itself.
@@ -266,21 +264,22 @@
*/
@SuppressLint("ViewConstructor")
private class PopupLayout(
- context: Context,
val composeView: View,
val popupIsFocusable: Boolean,
val onDismissRequest: (() -> Unit)? = null,
var popupPositionProperties: PopupPositionProperties,
var popupPositionProvider: PopupPositionProvider,
var testTag: String
-) : FrameLayout(context) {
- val windowManager = context.getSystemService(Context.WINDOW_SERVICE) as WindowManager
+) : FrameLayout(composeView.context) {
+ val windowManager =
+ composeView.context.getSystemService(Context.WINDOW_SERVICE) as WindowManager
val params = createLayoutParams()
var viewAdded: Boolean = false
init {
id = android.R.id.content
updateLayoutParams()
+ ViewTreeLifecycleOwner.set(this, ViewTreeLifecycleOwner.get(composeView))
}
/**
@@ -300,7 +299,6 @@
if (!viewAdded) {
windowManager.addView(this, params)
- ViewTreeLifecycleOwner.set(this, ViewTreeLifecycleOwner.get(composeView))
viewAdded = true
} else {
windowManager.updateViewLayout(this, params)
diff --git a/ui/ui-core/src/main/java/androidx/ui/core/Wrapper.kt b/ui/ui-core/src/main/java/androidx/ui/core/Wrapper.kt
index 4c86db0..e7f07d0 100644
--- a/ui/ui-core/src/main/java/androidx/ui/core/Wrapper.kt
+++ b/ui/ui-core/src/main/java/androidx/ui/core/Wrapper.kt
@@ -27,6 +27,7 @@
import androidx.compose.Composition
import androidx.compose.CompositionReference
import androidx.compose.FrameManager
+import androidx.compose.InternalComposeApi
import androidx.compose.Recomposer
import androidx.compose.SlotTable
import androidx.compose.compositionFor
@@ -218,37 +219,38 @@
private var addedToLifecycle: Lifecycle? = null
override fun setContent(content: @Composable () -> Unit) {
- val lifecycle = owner.lifecycleOwner?.lifecycle
- if (lifecycle != null) {
- if (addedToLifecycle == null) {
- addedToLifecycle = lifecycle
- lifecycle.addObserver(this)
- }
- if (owner.savedStateRegistry != null) {
- original.setContent {
- @Suppress("UNCHECKED_CAST")
- (owner.view.getTag(R.id.inspection_slot_table_set) as? MutableSet<SlotTable>)
+ owner.setOnViewTreeOwnersAvailable {
+ if (!disposed) {
+ if (addedToLifecycle == null) {
+ val lifecycle = it.lifecycleOwner.lifecycle
+ lifecycle.addObserver(this)
+ addedToLifecycle = lifecycle
+ }
+ if (owner.savedStateRegistry != null) {
+ original.setContent {
+ @Suppress("UNCHECKED_CAST")
+ (owner.view.getTag(R.id.inspection_slot_table_set) as?
+ MutableSet<SlotTable>)
?.let {
val composer = currentComposer
+ @OptIn(InternalComposeApi::class)
composer.collectKeySourceInformation()
it.add(composer.slotTable)
}
- ProvideAndroidAmbients(owner) {
- WrapWithSelectionContainer(content)
+ ProvideAndroidAmbients(owner) {
+ WrapWithSelectionContainer(content)
+ }
+ }
+ } else {
+ // TODO(Andrey) unify setOnSavedStateRegistryAvailable and
+ // whenViewTreeOwnersAvailable so we will postpone until we have everything.
+ // we should migrate to androidx SavedStateRegistry first
+ // we will postpone the composition until composeView restores the state.
+ owner.setOnSavedStateRegistryAvailable {
+ if (!disposed) setContent(content)
}
}
- } else {
- // TODO(Andrey) unify setOnSavedStateRegistryAvailable and
- // setOnLifecycleOwnerAvailable so we will postpone until we have everything.
- // we should migrate to androidx SavedStateRegistry first
- // we will postpone the composition until composeView restores the state.
- owner.setOnSavedStateRegistryAvailable {
- if (!disposed) setContent(content)
- }
}
- } else {
- // we will postpone the composition until we got the lifecycle owner
- owner.setOnLifecycleOwnerAvailable { if (!disposed) setContent(content) }
}
}
diff --git a/ui/ui-core/src/main/java/androidx/ui/graphics/vector/VectorPainter.kt b/ui/ui-core/src/main/java/androidx/ui/graphics/vector/VectorPainter.kt
index 7204d8e..fe285c6 100644
--- a/ui/ui-core/src/main/java/androidx/ui/graphics/vector/VectorPainter.kt
+++ b/ui/ui-core/src/main/java/androidx/ui/graphics/vector/VectorPainter.kt
@@ -17,6 +17,7 @@
package androidx.ui.graphics.vector
import androidx.compose.Composable
+import androidx.compose.ExperimentalComposeApi
import androidx.compose.compositionReference
import androidx.compose.currentComposer
import androidx.compose.onPreCommit
@@ -144,6 +145,8 @@
val composition = composeVector(
vector,
+ // TODO(lmr): refactor these APIs so that recomposer isn't necessary
+ @OptIn(ExperimentalComposeApi::class)
currentComposer.recomposer,
compositionReference(),
children
diff --git a/ui/ui-core/src/main/java/androidx/ui/node/PointerInteropFilter.kt b/ui/ui-core/src/main/java/androidx/ui/node/PointerInteropFilter.kt
index df4faa1b..3d2fb23 100644
--- a/ui/ui-core/src/main/java/androidx/ui/node/PointerInteropFilter.kt
+++ b/ui/ui-core/src/main/java/androidx/ui/node/PointerInteropFilter.kt
@@ -26,7 +26,9 @@
import androidx.ui.core.consumeAllChanges
import androidx.ui.core.pointerinput.PointerInputFilter
import androidx.ui.core.pointerinput.PointerInputModifier
+import androidx.ui.unit.IntPxPosition
import androidx.ui.unit.IntPxSize
+import androidx.ui.unit.ipx
import androidx.ui.unit.milliseconds
import androidx.ui.util.fastAny
import androidx.ui.viewinterop.AndroidViewHolder
@@ -78,6 +80,9 @@
val view: AndroidViewHolder
) : PointerInputModifier {
+ // Reusable to avoid extra allocations.
+ private val reusableLocationInWindow by lazy { IntArray(2) }
+
/**
* The 3 possible states
*/
@@ -186,18 +191,28 @@
@Suppress("NAME_SHADOWING")
var changes = changes
+ // TODO(b/158034713): This should likely not be the view's location in window, but
+ // instead should take the global position of this PointerInteropFilter.
+ // Depending on future work, this may or may not be the case.
+ val globalToLocalOffset =
+ reusableLocationInWindow.run {
+ view.getLocationInWindow(this)
+ IntPxPosition(this[0].ipx, this[1].ipx)
+ }
+
if (changes.fastAny { it.anyChangeConsumed() }) {
// We should no longer dispatch to the Android View.
if (state === DispatchToViewState.Dispatching) {
// If we were dipatching, send ACTION_CANCEL.
- changes.toCancelMotionEventScope { motionEvent ->
+ changes.toCancelMotionEventScope(globalToLocalOffset) { motionEvent ->
view.dispatchTouchEvent(motionEvent)
}
}
state = DispatchToViewState.NotDispatching
} else {
// Dispatch and update our state with the result.
- changes.toMotionEventScope { motionEvent ->
+
+ changes.toMotionEventScope(globalToLocalOffset) { motionEvent ->
state = if (view.dispatchTouchEvent(motionEvent)) {
DispatchToViewState.Dispatching
} else {
diff --git a/ui/ui-core/src/main/java/androidx/ui/node/PointerInteropUtils.kt b/ui/ui-core/src/main/java/androidx/ui/node/PointerInteropUtils.kt
index 8d23589..3d96492 100644
--- a/ui/ui-core/src/main/java/androidx/ui/node/PointerInteropUtils.kt
+++ b/ui/ui-core/src/main/java/androidx/ui/node/PointerInteropUtils.kt
@@ -23,143 +23,157 @@
import androidx.ui.core.changedToDownIgnoreConsumed
import androidx.ui.core.changedToUpIgnoreConsumed
import androidx.ui.unit.Duration
+import androidx.ui.unit.IntPxPosition
import androidx.ui.unit.NanosecondsPerMillisecond
import androidx.ui.unit.milliseconds
// TODO(shepshapard): Refactor in order to remove the need for current.uptime!!
-internal fun List<PointerInputChange>.toMotionEventScope(block: (MotionEvent) -> Unit) {
- check(isNotEmpty())
-
- val eventTime =
- (first().current.uptime!!.nanoseconds / NanosecondsPerMillisecond)
- val numPointers = size
-
- val (action, actionIndex) =
- if (all { it.changedToDownIgnoreConsumed() }) {
- MotionEvent.ACTION_DOWN to 0
- } else if (all { it.changedToUpIgnoreConsumed() }) {
- MotionEvent.ACTION_UP to 0
- } else {
- val downIndex = indexOfFirst { it.changedToDownIgnoreConsumed() }
- if (downIndex != -1) {
- MotionEvent.ACTION_POINTER_DOWN to downIndex
- } else {
- val upIndex = indexOfFirst { it.changedToUpIgnoreConsumed() }
- if (upIndex != -1) {
- MotionEvent.ACTION_POINTER_UP to upIndex
- } else {
- MotionEvent.ACTION_MOVE to 0
- }
- }
- }
-
- // TODO(b/154136736): "(it.id.value % 32).toInt()" is very fishy.
- val pointerProperties =
- map { PointerProperties((it.id.value % 32).toInt()) }
- .toTypedArray()
- val pointerCoords =
- map {
- if (it.changedToUpIgnoreConsumed()) {
- PointerCoords(it.previous.position!!.x, it.previous.position.y)
- } else {
- PointerCoords(it.current.position!!.x, it.current.position.y)
- }
- }.toTypedArray()
-
- // TODO(b/154136736): Downtime as 0 isn't right. Not sure it matters.
- val motionEvent =
- MotionEvent(
- eventTime,
- action,
- numPointers,
- actionIndex,
- pointerProperties,
- pointerCoords
- )
- block(motionEvent)
- motionEvent.recycle()
+/**
+ * Converts to a [MotionEvent], runs [block] with it, and recycles the [MotionEvent].
+ *
+ * @param regionToGlobalOffset The global offset of the region where this [MotionEvent] is being
+ * used. This will be added to each [PointerInputChange]'s position in order set raw coordinates
+ * correctly, and will be subtracted via [MotionEvent.offsetLocation] so the [MotionEvent]
+ * is still offset to be relative to the region.
+ * @param block The block to be executed with the created [MotionEvent].
+ */
+internal fun List<PointerInputChange>.toMotionEventScope(
+ regionToGlobalOffset: IntPxPosition,
+ block: (MotionEvent) -> Unit
+) {
+ toMotionEventScope(regionToGlobalOffset, block, false)
}
+/**
+ * Converts to an [MotionEvent.ACTION_CANCEL] [MotionEvent], runs [block] with it, and recycles the
+ * [MotionEvent].
+ *
+ * @param regionToGlobalOffset The global offset of the region where this [MotionEvent] is being
+ * used. This will be added to each [PointerInputChange]'s position in order set raw coordinates
+ * correctly, and will be subtracted via [MotionEvent.offsetLocation] so the [MotionEvent]
+ * is still offset to be relative to the region.
+ * @param block The block to be executed with the created [MotionEvent].
+ */
// TODO(shepshapard): Refactor in order to remove the need for current.uptime!!
-internal fun List<PointerInputChange>.toCancelMotionEventScope(block: (MotionEvent) -> Unit) {
- check(isNotEmpty())
-
- val eventTime =
- (first().current.uptime!!.nanoseconds / NanosecondsPerMillisecond)
- val numPointers = size
-
- // TODO(shepshapard): toInt() is clearly not right.
- val pointerProperties =
- map { PointerProperties(it.id.value.toInt()) }
- .toTypedArray()
- val pointerCoords =
- map {
- if (it.changedToUpIgnoreConsumed()) {
- PointerCoords(it.previous.position!!.x, it.previous.position.y)
- } else {
- PointerCoords(it.current.position!!.x, it.current.position.y)
- }
- }.toTypedArray()
-
- // TODO(b/154136736): Downtime as 0 isn't right. Not sure it matters.
- val motionEvent =
- MotionEvent(
- eventTime,
- MotionEvent.ACTION_CANCEL,
- numPointers,
- 0,
- pointerProperties,
- pointerCoords
- )
- block(motionEvent)
- motionEvent.recycle()
+internal fun List<PointerInputChange>.toCancelMotionEventScope(
+ regionToGlobalOffset: IntPxPosition,
+ block: (MotionEvent) -> Unit
+) {
+ toMotionEventScope(regionToGlobalOffset, block, true)
}
internal fun emptyCancelMotionEventScope(
now: Duration = SystemClock.uptimeMillis().milliseconds,
block: (MotionEvent) -> Unit
) {
- // Mimics what ViewGroup does when it needs to send a minimal ACTION_CANCEL event.
+ // Does what ViewGroup does when it needs to send a minimal ACTION_CANCEL event.
val nowMillis = now.nanoseconds / NanosecondsPerMillisecond
- val motionEvent = MotionEvent.obtain(nowMillis, nowMillis,
- MotionEvent.ACTION_CANCEL, 0.0f, 0.0f, 0)
+ val motionEvent =
+ MotionEvent.obtain(nowMillis, nowMillis, MotionEvent.ACTION_CANCEL, 0.0f, 0.0f, 0)
motionEvent.source = InputDevice.SOURCE_TOUCHSCREEN
block(motionEvent)
motionEvent.recycle()
}
-private fun PointerProperties(id: Int = 0, toolType: Int = MotionEvent.TOOL_TYPE_UNKNOWN) =
- MotionEvent.PointerProperties().apply {
- this.id = id
- this.toolType = toolType
+private fun List<PointerInputChange>.toMotionEventScope(
+ regionToGlobalOffset: IntPxPosition,
+ block: (MotionEvent) -> Unit,
+ cancel: Boolean
+) {
+ // We need to make sure this is not empty
+ check(isNotEmpty())
+
+ // We derive the values of each aspect of MotionEvent...
+
+ val eventTime =
+ first().current.uptime!!.nanoseconds / NanosecondsPerMillisecond
+
+ val action = if (cancel) {
+ MotionEvent.ACTION_CANCEL
+ } else {
+ if (all { it.changedToDownIgnoreConsumed() }) {
+ createAction(MotionEvent.ACTION_DOWN, 0)
+ } else if (all { it.changedToUpIgnoreConsumed() }) {
+ createAction(MotionEvent.ACTION_UP, 0)
+ } else {
+ val downIndex = indexOfFirst { it.changedToDownIgnoreConsumed() }
+ if (downIndex != -1) {
+ createAction(MotionEvent.ACTION_POINTER_DOWN, downIndex)
+ } else {
+ val upIndex = indexOfFirst { it.changedToUpIgnoreConsumed() }
+ if (upIndex != -1) {
+ createAction(MotionEvent.ACTION_POINTER_UP, upIndex)
+ } else {
+ createAction(MotionEvent.ACTION_MOVE, 0)
+ }
+ }
+ }
}
-private fun PointerCoords(x: Float = 0f, y: Float = 0f) =
- MotionEvent.PointerCoords().apply {
- this.x = x
- this.y = y
- }
+ val numPointers = size
-private fun MotionEvent(
- eventTime: Long,
- action: Int,
- numPointers: Int,
- actionIndex: Int,
- pointerProperties: Array<MotionEvent.PointerProperties>,
- pointerCoords: Array<MotionEvent.PointerCoords>
-) = MotionEvent.obtain(
- 0,
- eventTime,
- action + (actionIndex shl MotionEvent.ACTION_POINTER_INDEX_SHIFT),
- numPointers,
- pointerProperties,
- pointerCoords,
- 0,
- 0,
- 0f,
- 0f,
- 0,
- 0,
- 0,
- 0
-)
\ No newline at end of file
+ // TODO(b/154136736): "(it.id.value % 32).toInt()" is very fishy, but android never expects
+ // the id to be larger than 31.
+ val pointerProperties =
+ map {
+ MotionEvent.PointerProperties().apply {
+ id = (it.id.value % 32).toInt()
+ toolType = MotionEvent.TOOL_TYPE_UNKNOWN
+ }
+ }.toTypedArray()
+
+ val pointerCoords =
+ map {
+ val offsetX =
+ if (it.changedToUpIgnoreConsumed()) {
+ it.previous.position!!.x
+ } else {
+ it.current.position!!.x
+ }
+ val offsetY =
+ if (it.changedToUpIgnoreConsumed()) {
+ it.previous.position!!.y
+ } else {
+ it.current.position!!.y
+ }
+ // We add the regionToGlobalOffset so that the raw coordinates are correct.
+ val rawX = offsetX + regionToGlobalOffset.x.value
+ val rawY = offsetY + regionToGlobalOffset.y.value
+
+ MotionEvent.PointerCoords().apply {
+ this.x = rawX
+ this.y = rawY
+ }
+ }.toTypedArray()
+
+ // ... Then we create the MotionEvent, dispatch it to block, and recycle it.
+
+ // TODO(b/154136736): Downtime as 0 isn't right. Not sure it matters.
+ MotionEvent.obtain(
+ 0,
+ eventTime,
+ action,
+ numPointers,
+ pointerProperties,
+ pointerCoords,
+ 0,
+ 0,
+ 0f,
+ 0f,
+ 0,
+ 0,
+ 0,
+ 0
+ ).apply {
+ // We subtract the regionToGlobalOffset so the local coordinates are correct.
+ offsetLocation(
+ -regionToGlobalOffset.x.value.toFloat(),
+ -regionToGlobalOffset.y.value.toFloat()
+ )
+ block(this)
+ recycle()
+ }
+}
+
+private fun createAction(actionType: Int, actionIndex: Int) =
+ actionType + (actionIndex shl MotionEvent.ACTION_POINTER_INDEX_SHIFT)
diff --git a/ui/ui-core/src/main/java/androidx/ui/node/UiComposer.kt b/ui/ui-core/src/main/java/androidx/ui/node/UiComposer.kt
index 79b6ec2..a0686f6 100644
--- a/ui/ui-core/src/main/java/androidx/ui/node/UiComposer.kt
+++ b/ui/ui-core/src/main/java/androidx/ui/node/UiComposer.kt
@@ -14,6 +14,7 @@
* limitations under the License.
*/
+@file:OptIn(ExperimentalComposeApi::class, ComposeCompilerApi::class)
package androidx.ui.node
import android.content.Context
@@ -21,8 +22,10 @@
import android.view.ViewGroup
import androidx.compose.Applier
import androidx.compose.ApplyAdapter
+import androidx.compose.ComposeCompilerApi
import androidx.compose.Composer
import androidx.compose.ComposerUpdater
+import androidx.compose.ExperimentalComposeApi
import androidx.compose.FrameManager
import androidx.compose.Recomposer
import androidx.compose.SlotTable
diff --git a/ui/ui-core/src/test/java/androidx/ui/core/ComposedModifierTest.kt b/ui/ui-core/src/test/java/androidx/ui/core/ComposedModifierTest.kt
index 3647c18..2d3b191 100644
--- a/ui/ui-core/src/test/java/androidx/ui/core/ComposedModifierTest.kt
+++ b/ui/ui-core/src/test/java/androidx/ui/core/ComposedModifierTest.kt
@@ -21,6 +21,8 @@
import androidx.compose.Composable
import androidx.compose.Composer
import androidx.compose.CompositionFrameClock
+import androidx.compose.ExperimentalComposeApi
+import androidx.compose.InternalComposeApi
import androidx.compose.Recomposer
import androidx.compose.SlotTable
import androidx.compose.currentComposer
@@ -44,6 +46,7 @@
if (element is TestTagModifier<*> && element.name == name) element.value as T else acc
}
+@OptIn(InternalComposeApi::class)
class ComposedModifierTest {
private val composer: Composer<*> get() = error("should not be called")
@@ -198,6 +201,7 @@
}
}
+@OptIn(InternalComposeApi::class)
private fun compose(
recomposer: Recomposer,
block: @Composable () -> Unit
@@ -210,6 +214,7 @@
/**
* This ApplyAdapter does nothing. These tests only confirm modifier materialization.
*/
+@OptIn(ExperimentalComposeApi::class)
private object UnitApplierAdapter : ApplyAdapter<Unit> {
override fun Unit.start(instance: Unit) {}
override fun Unit.insertAt(index: Int, instance: Unit) {}
@@ -229,6 +234,7 @@
override suspend fun <R> withFrameNanos(onFrame: (Long) -> R): R = onFrame(frameCh.receive())
}
+@OptIn(ExperimentalComposeApi::class)
private class UnitComposer(recomposer: Recomposer) : Composer<Unit>(
SlotTable(),
Applier(Unit, UnitApplierAdapter),
diff --git a/ui/ui-desktop/android-emu/src/desktopMain/kotlin/android/os/Handler.kt b/ui/ui-desktop/android-emu/src/desktopMain/kotlin/android/os/Handler.kt
index 28999e2..25a05ac 100644
--- a/ui/ui-desktop/android-emu/src/desktopMain/kotlin/android/os/Handler.kt
+++ b/ui/ui-desktop/android-emu/src/desktopMain/kotlin/android/os/Handler.kt
@@ -31,4 +31,8 @@
SwingUtilities.invokeLater(runnable)
return true
}
+
+ fun removeMessages(what: Int) {}
+
+ fun sendEmptyMessage(what: Int): Boolean = true
}
\ No newline at end of file
diff --git a/ui/ui-desktop/android-emu/src/desktopMain/kotlin/android/view/View.kt b/ui/ui-desktop/android-emu/src/desktopMain/kotlin/android/view/View.kt
index 2bcf8df..b82bc72 100644
--- a/ui/ui-desktop/android-emu/src/desktopMain/kotlin/android/view/View.kt
+++ b/ui/ui-desktop/android-emu/src/desktopMain/kotlin/android/view/View.kt
@@ -17,6 +17,7 @@
package android.view
import android.content.Context
+import android.content.res.Resources
import android.graphics.Canvas
import android.graphics.Matrix
import android.graphics.Rect
@@ -165,4 +166,7 @@
}
return true
}
+
+ private val resources = Resources()
+ fun getResources(): Resources = resources
}
diff --git a/ui/ui-desktop/android-emu/src/desktopMain/kotlin/android/view/ViewConfiguration.kt b/ui/ui-desktop/android-emu/src/desktopMain/kotlin/android/view/ViewConfiguration.kt
new file mode 100644
index 0000000..37b854d
--- /dev/null
+++ b/ui/ui-desktop/android-emu/src/desktopMain/kotlin/android/view/ViewConfiguration.kt
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.view
+
+class ViewConfiguration {
+ companion object {
+ @JvmStatic
+ fun getScrollFriction(): Float = 0.015f
+ }
+}
\ No newline at end of file
diff --git a/ui/ui-desktop/samples/src/jvmMain/kotlin/androidx/ui/desktop/examples/example2/Main.kt b/ui/ui-desktop/samples/src/jvmMain/kotlin/androidx/ui/desktop/examples/example2/Main.kt
index 904d29e..64b13cd 100644
--- a/ui/ui-desktop/samples/src/jvmMain/kotlin/androidx/ui/desktop/examples/example2/Main.kt
+++ b/ui/ui-desktop/samples/src/jvmMain/kotlin/androidx/ui/desktop/examples/example2/Main.kt
@@ -37,7 +37,7 @@
drawRect(Color.Magenta)
inset(10.0f) {
drawLine(
- p1 = Offset.zero,
+ p1 = Offset.Zero,
p2 = Offset(size.width, size.height),
stroke = Stroke(width = 5.0f),
color = Color.Red
diff --git a/ui/ui-desktop/src/jvmMain/kotlin/androidx/ui/desktop/DesktopPlatformInput.kt b/ui/ui-desktop/src/jvmMain/kotlin/androidx/ui/desktop/DesktopPlatformInput.kt
index 46e45b8..cccd208 100644
--- a/ui/ui-desktop/src/jvmMain/kotlin/androidx/ui/desktop/DesktopPlatformInput.kt
+++ b/ui/ui-desktop/src/jvmMain/kotlin/androidx/ui/desktop/DesktopPlatformInput.kt
@@ -59,6 +59,7 @@
override fun notifyFocusedRect(rect: Rect) {}
+ @Suppress("UNUSED_PARAMETER")
fun onKeyPressed(keyCode: Int, char: Char) {
onEditCommand?.let {
when (keyCode) {
@@ -82,6 +83,7 @@
}
}
+ @Suppress("UNUSED_PARAMETER")
fun onKeyReleased(keyCode: Int, char: Char) {
}
diff --git a/ui/ui-desktop/src/jvmMain/kotlin/androidx/ui/desktop/Wrapper.kt b/ui/ui-desktop/src/jvmMain/kotlin/androidx/ui/desktop/Wrapper.kt
index 7573dae..e7f3247 100644
--- a/ui/ui-desktop/src/jvmMain/kotlin/androidx/ui/desktop/Wrapper.kt
+++ b/ui/ui-desktop/src/jvmMain/kotlin/androidx/ui/desktop/Wrapper.kt
@@ -96,22 +96,18 @@
override fun onMouseClicked(x: Int, y: Int, modifiers: Int) {}
- override fun onMousePressed(x: Int, y: Int, awtModifiers: Int) {
+ override fun onMousePressed(x: Int, y: Int, modifiers: Int) {
view.dispatchTouchEvent(
- MotionEvent(x, y, MotionEvent.ACTION_DOWN or modifiers(awtModifiers)))
+ MotionEvent(x, y, MotionEvent.ACTION_DOWN))
}
- override fun onMouseReleased(x: Int, y: Int, awtModifiers: Int) {
- view.dispatchTouchEvent(MotionEvent(x, y, MotionEvent.ACTION_UP or modifiers(awtModifiers)))
+ override fun onMouseReleased(x: Int, y: Int, modifiers: Int) {
+ view.dispatchTouchEvent(MotionEvent(x, y, MotionEvent.ACTION_UP))
}
- override fun onMouseDragged(x: Int, y: Int, awtModifiers: Int) {
+ override fun onMouseDragged(x: Int, y: Int, modifiers: Int) {
view.dispatchTouchEvent(MotionEvent(x, y,
- MotionEvent.ACTION_MOVE or modifiers(awtModifiers)))
- }
-
- private fun modifiers(awtModifiers: Int): Int {
- return 0
+ MotionEvent.ACTION_MOVE))
}
override fun onKeyPressed(code: Int, char: Char) {
diff --git a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/ClickableTest.kt b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/ClickableTest.kt
index 9d9962d..bbc906e 100644
--- a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/ClickableTest.kt
+++ b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/ClickableTest.kt
@@ -27,14 +27,18 @@
import androidx.ui.test.assertHasNoClickAction
import androidx.ui.test.assertIsEnabled
import androidx.ui.test.assertIsNotEnabled
+import androidx.ui.test.center
import androidx.ui.test.createComposeRule
import androidx.ui.test.doClick
import androidx.ui.test.doGesture
+import androidx.ui.test.doPartialGesture
import androidx.ui.test.findByTag
import androidx.ui.test.runOnIdleCompose
import androidx.ui.test.sendClick
import androidx.ui.test.sendDoubleClick
+import androidx.ui.test.sendDown
import androidx.ui.test.sendLongClick
+import androidx.ui.test.sendUp
import com.google.common.truth.Truth.assertThat
import org.junit.Rule
import org.junit.Test
@@ -333,19 +337,15 @@
assertThat(interactionState.value).doesNotContain(Interaction.Pressed)
}
- // TODO: b/154498119 simulate press event, replace with gesture injection when supported
- runOnIdleCompose {
- interactionState.addInteraction(Interaction.Pressed)
- }
+ findByTag("myClickable")
+ .doPartialGesture { sendDown(center) }
runOnIdleCompose {
assertThat(interactionState.value).contains(Interaction.Pressed)
}
- // TODO: b/154498119 simulate press event, replace with gesture injection when supported
- runOnIdleCompose {
- interactionState.removeInteraction(Interaction.Pressed)
- }
+ findByTag("myClickable")
+ .doPartialGesture { sendUp() }
runOnIdleCompose {
assertThat(interactionState.value).doesNotContain(Interaction.Pressed)
@@ -374,10 +374,8 @@
assertThat(interactionState.value).doesNotContain(Interaction.Pressed)
}
- // TODO: b/154498119 simulate press event, replace with gesture injection when supported
- runOnIdleCompose {
- interactionState.addInteraction(Interaction.Pressed)
- }
+ findByTag("myClickable")
+ .doPartialGesture { sendDown(center) }
runOnIdleCompose {
assertThat(interactionState.value).contains(Interaction.Pressed)
diff --git a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/DraggableTest.kt b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/DraggableTest.kt
index 4d9fff49..f1a5e9a3 100644
--- a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/DraggableTest.kt
+++ b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/DraggableTest.kt
@@ -30,10 +30,15 @@
import androidx.ui.test.center
import androidx.ui.test.createComposeRule
import androidx.ui.test.doGesture
+import androidx.ui.test.doPartialGesture
import androidx.ui.test.findByTag
import androidx.ui.test.runOnIdleCompose
+import androidx.ui.test.sendDown
+import androidx.ui.test.sendMoveBy
import androidx.ui.test.sendSwipe
import androidx.ui.test.sendSwipeWithVelocity
+import androidx.ui.test.sendUp
+import androidx.ui.test.size
import androidx.ui.geometry.Offset
import androidx.ui.unit.dp
import androidx.ui.unit.milliseconds
@@ -349,26 +354,30 @@
val interactionState = InteractionState()
setDraggableContent {
- Modifier.draggable(DragDirection.Horizontal, interactionState = interactionState) { 0f }
+ Modifier.draggable(
+ DragDirection.Horizontal,
+ interactionState = interactionState
+ ) { 0f }
}
runOnIdleCompose {
assertThat(interactionState.value).doesNotContain(Interaction.Dragged)
}
- // TODO: b/154498119 simulate drag event, replace with gesture injection when supported
- runOnIdleCompose {
- interactionState.addInteraction(Interaction.Dragged)
- }
+ findByTag(draggableBoxTag)
+ .doPartialGesture {
+ sendDown(Offset(size.width.value / 4f, size.height.value / 2f))
+ sendMoveBy(Offset(size.width.value / 2f, 0f))
+ }
runOnIdleCompose {
assertThat(interactionState.value).contains(Interaction.Dragged)
}
- // TODO: b/154498119 simulate drag event, replace with gesture injection when supported
- runOnIdleCompose {
- interactionState.removeInteraction(Interaction.Dragged)
- }
+ findByTag(draggableBoxTag)
+ .doPartialGesture {
+ sendUp()
+ }
runOnIdleCompose {
assertThat(interactionState.value).doesNotContain(Interaction.Dragged)
@@ -399,10 +408,11 @@
assertThat(interactionState.value).doesNotContain(Interaction.Dragged)
}
- // TODO: b/154498119 simulate drag event, replace with gesture injection when supported
- runOnIdleCompose {
- interactionState.addInteraction(Interaction.Dragged)
- }
+ findByTag(draggableBoxTag)
+ .doPartialGesture {
+ sendDown(Offset(size.width.value / 4f, size.height.value / 2f))
+ sendMoveBy(Offset(size.width.value / 2f, 0f))
+ }
runOnIdleCompose {
assertThat(interactionState.value).contains(Interaction.Dragged)
diff --git a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/SelectableTest.kt b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/SelectableTest.kt
index 0eb86b4..4d851fc 100644
--- a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/SelectableTest.kt
+++ b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/SelectableTest.kt
@@ -16,20 +16,31 @@
package androidx.ui.foundation
+import androidx.compose.getValue
+import androidx.compose.mutableStateOf
+import androidx.compose.setValue
import androidx.compose.state
import androidx.test.filters.MediumTest
import androidx.ui.core.Modifier
import androidx.ui.foundation.selection.selectable
+import androidx.ui.layout.Stack
import androidx.ui.test.assertCountEquals
import androidx.ui.test.assertIsInMutuallyExclusiveGroup
import androidx.ui.test.assertIsSelected
import androidx.ui.test.assertIsUnselected
+import androidx.ui.test.center
import androidx.ui.test.createComposeRule
import androidx.ui.test.doClick
+import androidx.ui.test.doPartialGesture
import androidx.ui.test.find
import androidx.ui.test.findAll
+import androidx.ui.test.findByText
import androidx.ui.test.first
import androidx.ui.test.isInMutuallyExclusiveGroup
+import androidx.ui.test.runOnIdleCompose
+import androidx.ui.test.sendDown
+import androidx.ui.test.sendUp
+import com.google.common.truth.Truth
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
@@ -96,4 +107,79 @@
.doClick()
.assertIsUnselected()
}
+
+ @Test
+ fun selectableTest_interactionState() {
+ val interactionState = InteractionState()
+
+ composeTestRule.setContent {
+ Stack {
+ Box(Modifier.selectable(
+ selected = true,
+ interactionState = interactionState,
+ >
+ )) {
+ Text("SelectableText")
+ }
+ }
+ }
+
+ runOnIdleCompose {
+ Truth.assertThat(interactionState.value).doesNotContain(Interaction.Pressed)
+ }
+
+ findByText("SelectableText")
+ .doPartialGesture { sendDown(center) }
+
+ runOnIdleCompose {
+ Truth.assertThat(interactionState.value).contains(Interaction.Pressed)
+ }
+
+ findByText("SelectableText")
+ .doPartialGesture { sendUp() }
+
+ runOnIdleCompose {
+ Truth.assertThat(interactionState.value).doesNotContain(Interaction.Pressed)
+ }
+ }
+
+ @Test
+ fun selectableTest_interactionState_resetWhenDisposed() {
+ val interactionState = InteractionState()
+ var emitSelectableText by mutableStateOf(true)
+
+ composeTestRule.setContent {
+ Stack {
+ if (emitSelectableText) {
+ Box(Modifier.selectable(
+ selected = true,
+ interactionState = interactionState,
+ >
+ )) {
+ Text("SelectableText")
+ }
+ }
+ }
+ }
+
+ runOnIdleCompose {
+ Truth.assertThat(interactionState.value).doesNotContain(Interaction.Pressed)
+ }
+
+ findByText("SelectableText")
+ .doPartialGesture { sendDown(center) }
+
+ runOnIdleCompose {
+ Truth.assertThat(interactionState.value).contains(Interaction.Pressed)
+ }
+
+ // Dispose selectable
+ runOnIdleCompose {
+ emitSelectableText = false
+ }
+
+ runOnIdleCompose {
+ Truth.assertThat(interactionState.value).doesNotContain(Interaction.Pressed)
+ }
+ }
}
\ No newline at end of file
diff --git a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/ToggleableTest.kt b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/ToggleableTest.kt
index 3df8d81..6c7334c 100644
--- a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/ToggleableTest.kt
+++ b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/ToggleableTest.kt
@@ -16,6 +16,9 @@
package androidx.ui.foundation
+import androidx.compose.getValue
+import androidx.compose.mutableStateOf
+import androidx.compose.setValue
import androidx.test.filters.MediumTest
import androidx.ui.core.Modifier
import androidx.ui.core.testTag
@@ -33,12 +36,17 @@
import androidx.ui.test.assertIsNotEnabled
import androidx.ui.test.assertIsOff
import androidx.ui.test.assertIsOn
+import androidx.ui.test.center
import androidx.ui.test.createComposeRule
import androidx.ui.test.doClick
+import androidx.ui.test.doPartialGesture
import androidx.ui.test.find
import androidx.ui.test.findByTag
+import androidx.ui.test.findByText
import androidx.ui.test.isToggleable
import androidx.ui.test.runOnIdleCompose
+import androidx.ui.test.sendDown
+import androidx.ui.test.sendUp
import com.google.common.truth.Truth.assertThat
import org.junit.Rule
import org.junit.Test
@@ -167,4 +175,79 @@
assertThat(checked).isEqualTo(false)
}
}
-}
\ No newline at end of file
+
+ @Test
+ fun toggleableTest_interactionState() {
+ val interactionState = InteractionState()
+
+ composeTestRule.setContent {
+ Stack {
+ Box(Modifier.toggleable(
+ value = true,
+ interactionState = interactionState,
+ >
+ )) {
+ Text("ToggleableText")
+ }
+ }
+ }
+
+ runOnIdleCompose {
+ assertThat(interactionState.value).doesNotContain(Interaction.Pressed)
+ }
+
+ findByText("ToggleableText")
+ .doPartialGesture { sendDown(center) }
+
+ runOnIdleCompose {
+ assertThat(interactionState.value).contains(Interaction.Pressed)
+ }
+
+ findByText("ToggleableText")
+ .doPartialGesture { sendUp() }
+
+ runOnIdleCompose {
+ assertThat(interactionState.value).doesNotContain(Interaction.Pressed)
+ }
+ }
+
+ @Test
+ fun toggleableTest_interactionState_resetWhenDisposed() {
+ val interactionState = InteractionState()
+ var emitToggleableText by mutableStateOf(true)
+
+ composeTestRule.setContent {
+ Stack {
+ if (emitToggleableText) {
+ Box(Modifier.toggleable(
+ value = true,
+ interactionState = interactionState,
+ >
+ )) {
+ Text("ToggleableText")
+ }
+ }
+ }
+ }
+
+ runOnIdleCompose {
+ assertThat(interactionState.value).doesNotContain(Interaction.Pressed)
+ }
+
+ findByText("ToggleableText")
+ .doPartialGesture { sendDown(center) }
+
+ runOnIdleCompose {
+ assertThat(interactionState.value).contains(Interaction.Pressed)
+ }
+
+ // Dispose toggleable
+ runOnIdleCompose {
+ emitToggleableText = false
+ }
+
+ runOnIdleCompose {
+ assertThat(interactionState.value).doesNotContain(Interaction.Pressed)
+ }
+ }
+}
diff --git a/ui/ui-foundation/src/main/java/androidx/ui/foundation/AdapterList.kt b/ui/ui-foundation/src/main/java/androidx/ui/foundation/AdapterList.kt
index cee692b..0a17492 100644
--- a/ui/ui-foundation/src/main/java/androidx/ui/foundation/AdapterList.kt
+++ b/ui/ui-foundation/src/main/java/androidx/ui/foundation/AdapterList.kt
@@ -20,6 +20,7 @@
import androidx.compose.Composable
import androidx.compose.Composition
import androidx.compose.CompositionReference
+import androidx.compose.ExperimentalComposeApi
import androidx.compose.FrameManager
import androidx.compose.Recomposer
import androidx.compose.Untracked
@@ -475,6 +476,7 @@
node = rootNode.children[layoutIndex.value]
}
// TODO(b/150390669): Review use of @Untracked
+ @OptIn(ExperimentalComposeApi::class)
val composition = subcomposeInto(context!!, node, recomposer, compositionRef) @Untracked {
itemCallback(data[dataIndex.value])
}
@@ -523,6 +525,7 @@
itemCallback: @Composable (T) -> Unit
) {
val state = remember { ListState<T>() }
+ @OptIn(ExperimentalComposeApi::class)
state.recomposer = currentComposer.recomposer
state.itemCallback = itemCallback
state.data = data
diff --git a/ui/ui-foundation/src/main/java/androidx/ui/foundation/Dialog.kt b/ui/ui-foundation/src/main/java/androidx/ui/foundation/Dialog.kt
index 06a1553..e7c105e 100644
--- a/ui/ui-foundation/src/main/java/androidx/ui/foundation/Dialog.kt
+++ b/ui/ui-foundation/src/main/java/androidx/ui/foundation/Dialog.kt
@@ -17,18 +17,20 @@
package androidx.ui.foundation
import android.app.Dialog
-import android.content.Context
import android.view.MotionEvent
+import android.view.View
import android.view.Window
import android.widget.FrameLayout
import androidx.compose.Composable
import androidx.compose.Composition
+import androidx.compose.ExperimentalComposeApi
import androidx.compose.Recomposer
import androidx.compose.currentComposer
import androidx.compose.onActive
import androidx.compose.onCommit
import androidx.compose.remember
-import androidx.ui.core.ContextAmbient
+import androidx.lifecycle.ViewTreeLifecycleOwner
+import androidx.ui.core.ViewAmbient
import androidx.ui.core.setContent
import androidx.ui.foundation.semantics.dialog
import androidx.ui.semantics.Semantics
@@ -49,11 +51,12 @@
*/
@Composable
fun Dialog(onCloseRequest: () -> Unit, children: @Composable () -> Unit) {
- val context = ContextAmbient.current
+ val view = ViewAmbient.current
+ @OptIn(ExperimentalComposeApi::class)
val recomposer = currentComposer.recomposer
// The recomposer can't change.
- val dialog = remember(context) { DialogWrapper(context, recomposer) }
+ val dialog = remember(view) { DialogWrapper(view, recomposer) }
dialog.>
onActive {
@@ -73,9 +76,9 @@
}
private class DialogWrapper(
- context: Context,
+ composeView: View,
private val recomposer: Recomposer
-) : Dialog(context) {
+) : Dialog(composeView.context) {
lateinit var onCloseRequest: () -> Unit
private val frameLayout = FrameLayout(context)
@@ -85,6 +88,7 @@
window!!.requestFeature(Window.FEATURE_NO_TITLE)
window!!.setBackgroundDrawableResource(android.R.color.transparent)
setContentView(frameLayout)
+ ViewTreeLifecycleOwner.set(frameLayout, ViewTreeLifecycleOwner.get(composeView))
}
fun setContent(children: @Composable () -> Unit) {
diff --git a/ui/ui-saved-instance-state/build.gradle b/ui/ui-saved-instance-state/build.gradle
index 243cad5..283cd4d 100644
--- a/ui/ui-saved-instance-state/build.gradle
+++ b/ui/ui-saved-instance-state/build.gradle
@@ -25,35 +25,51 @@
id("AndroidXPlugin")
id("com.android.library")
id("AndroidXUiPlugin")
- id("org.jetbrains.kotlin.android")
+ id("kotlin-multiplatform")
}
dependencies {
kotlinPlugin project(path: ":compose:compose-compiler")
+}
- implementation(KOTLIN_STDLIB)
+kotlin {
+ android()
+ sourceSets {
+ commonMain.dependencies {
+ implementation(KOTLIN_STDLIB_COMMON)
- api "androidx.annotation:annotation:1.1.0"
+ api project(":compose:compose-runtime")
+ implementation project(":ui:ui-util")
- api project(":compose:compose-runtime")
- implementation project(":ui:ui-util")
+ }
- testImplementation(ANDROIDX_TEST_RULES)
- testImplementation(ANDROIDX_TEST_RUNNER)
- testImplementation(JUNIT)
- testImplementation(TRUTH)
+ androidMain.dependencies {
+ implementation(KOTLIN_STDLIB)
+ api "androidx.annotation:annotation:1.1.0"
+ }
- androidTestImplementation project(':ui:ui-test')
- androidTestImplementation project(':ui:ui-core')
- androidTestImplementation(ANDROIDX_TEST_UIAUTOMATOR)
- androidTestImplementation(ANDROIDX_TEST_CORE)
- androidTestImplementation(ANDROIDX_TEST_RULES)
- androidTestImplementation(ANDROIDX_TEST_RUNNER)
- androidTestImplementation(ESPRESSO_CORE)
- androidTestImplementation(JUNIT)
- androidTestImplementation(TRUTH)
- androidTestImplementation(DEXMAKER_MOCKITO, libs.exclude_bytebuddy) // DexMaker has it"s own MockMaker
- androidTestImplementation(MOCKITO_CORE, libs.exclude_bytebuddy) // DexMaker has it"s own MockMaker
+
+ androidTest.dependencies {
+ implementation(ANDROIDX_TEST_RULES)
+ implementation(ANDROIDX_TEST_RUNNER)
+ implementation(JUNIT)
+ implementation(TRUTH)
+ }
+
+ androidAndroidTest.dependencies {
+ implementation project(':ui:ui-test')
+ implementation project(':ui:ui-core')
+ implementation(ANDROIDX_TEST_UIAUTOMATOR)
+ implementation(ANDROIDX_TEST_CORE)
+ implementation(ANDROIDX_TEST_RULES)
+ implementation(ANDROIDX_TEST_RUNNER)
+ implementation(ESPRESSO_CORE)
+ implementation(JUNIT)
+ implementation(TRUTH)
+ implementation(DEXMAKER_MOCKITO, libs.exclude_bytebuddy) // DexMaker has it"s own MockMaker
+ implementation(MOCKITO_CORE, libs.exclude_bytebuddy) // DexMaker has it"s own MockMaker
+ }
+ }
}
androidx {
diff --git a/ui/ui-saved-instance-state/src/androidTest/AndroidManifest.xml b/ui/ui-saved-instance-state/src/androidAndroidTest/AndroidManifest.xml
similarity index 100%
rename from ui/ui-saved-instance-state/src/androidTest/AndroidManifest.xml
rename to ui/ui-saved-instance-state/src/androidAndroidTest/AndroidManifest.xml
diff --git a/ui/ui-saved-instance-state/src/androidTest/java/androidx/ui/savedinstancestate/ActivityRecreationTest.kt b/ui/ui-saved-instance-state/src/androidAndroidTest/kotlin/androidx/ui/savedinstancestate/ActivityRecreationTest.kt
similarity index 100%
rename from ui/ui-saved-instance-state/src/androidTest/java/androidx/ui/savedinstancestate/ActivityRecreationTest.kt
rename to ui/ui-saved-instance-state/src/androidAndroidTest/kotlin/androidx/ui/savedinstancestate/ActivityRecreationTest.kt
diff --git a/ui/ui-saved-instance-state/src/androidTest/java/androidx/ui/savedinstancestate/Holder.kt b/ui/ui-saved-instance-state/src/androidAndroidTest/kotlin/androidx/ui/savedinstancestate/Holder.kt
similarity index 100%
rename from ui/ui-saved-instance-state/src/androidTest/java/androidx/ui/savedinstancestate/Holder.kt
rename to ui/ui-saved-instance-state/src/androidAndroidTest/kotlin/androidx/ui/savedinstancestate/Holder.kt
diff --git a/ui/ui-saved-instance-state/src/androidTest/java/androidx/ui/savedinstancestate/RememberSavedInstanceStateTest.kt b/ui/ui-saved-instance-state/src/androidAndroidTest/kotlin/androidx/ui/savedinstancestate/RememberSavedInstanceStateTest.kt
similarity index 100%
rename from ui/ui-saved-instance-state/src/androidTest/java/androidx/ui/savedinstancestate/RememberSavedInstanceStateTest.kt
rename to ui/ui-saved-instance-state/src/androidAndroidTest/kotlin/androidx/ui/savedinstancestate/RememberSavedInstanceStateTest.kt
diff --git a/ui/ui-saved-instance-state/src/androidTest/java/androidx/ui/savedinstancestate/SavedInstanceStateTest.kt b/ui/ui-saved-instance-state/src/androidAndroidTest/kotlin/androidx/ui/savedinstancestate/SavedInstanceStateTest.kt
similarity index 100%
rename from ui/ui-saved-instance-state/src/androidTest/java/androidx/ui/savedinstancestate/SavedInstanceStateTest.kt
rename to ui/ui-saved-instance-state/src/androidAndroidTest/kotlin/androidx/ui/savedinstancestate/SavedInstanceStateTest.kt
diff --git a/ui/ui-saved-instance-state/src/main/AndroidManifest.xml b/ui/ui-saved-instance-state/src/androidMain/AndroidManifest.xml
similarity index 100%
rename from ui/ui-saved-instance-state/src/main/AndroidManifest.xml
rename to ui/ui-saved-instance-state/src/androidMain/AndroidManifest.xml
diff --git a/ui/ui-saved-instance-state/src/main/java/androidx/ui/savedinstancestate/ListSaver.kt b/ui/ui-saved-instance-state/src/commonMain/kotlin/androidx/ui/savedinstancestate/ListSaver.kt
similarity index 100%
rename from ui/ui-saved-instance-state/src/main/java/androidx/ui/savedinstancestate/ListSaver.kt
rename to ui/ui-saved-instance-state/src/commonMain/kotlin/androidx/ui/savedinstancestate/ListSaver.kt
diff --git a/ui/ui-saved-instance-state/src/main/java/androidx/ui/savedinstancestate/MapSaver.kt b/ui/ui-saved-instance-state/src/commonMain/kotlin/androidx/ui/savedinstancestate/MapSaver.kt
similarity index 100%
rename from ui/ui-saved-instance-state/src/main/java/androidx/ui/savedinstancestate/MapSaver.kt
rename to ui/ui-saved-instance-state/src/commonMain/kotlin/androidx/ui/savedinstancestate/MapSaver.kt
diff --git a/ui/ui-saved-instance-state/src/main/java/androidx/ui/savedinstancestate/RememberSavedInstanceState.kt b/ui/ui-saved-instance-state/src/commonMain/kotlin/androidx/ui/savedinstancestate/RememberSavedInstanceState.kt
similarity index 97%
rename from ui/ui-saved-instance-state/src/main/java/androidx/ui/savedinstancestate/RememberSavedInstanceState.kt
rename to ui/ui-saved-instance-state/src/commonMain/kotlin/androidx/ui/savedinstancestate/RememberSavedInstanceState.kt
index 1d3e0af..bc7b944 100644
--- a/ui/ui-saved-instance-state/src/main/java/androidx/ui/savedinstancestate/RememberSavedInstanceState.kt
+++ b/ui/ui-saved-instance-state/src/commonMain/kotlin/androidx/ui/savedinstancestate/RememberSavedInstanceState.kt
@@ -18,6 +18,7 @@
import androidx.compose.Composable
import androidx.compose.CompositionLifecycleObserver
+import androidx.compose.ExperimentalComposeApi
import androidx.compose.MutableState
import androidx.compose.currentComposer
import androidx.compose.remember
@@ -49,6 +50,7 @@
* in the composition tree
* @param init A factory function to create the initial value of this state
*/
+@OptIn(ExperimentalComposeApi::class)
@Composable
fun <T : Any> rememberSavedInstanceState(
vararg inputs: Any?,
diff --git a/ui/ui-saved-instance-state/src/main/java/androidx/ui/savedinstancestate/SavedInstanceState.kt b/ui/ui-saved-instance-state/src/commonMain/kotlin/androidx/ui/savedinstancestate/SavedInstanceState.kt
similarity index 100%
rename from ui/ui-saved-instance-state/src/main/java/androidx/ui/savedinstancestate/SavedInstanceState.kt
rename to ui/ui-saved-instance-state/src/commonMain/kotlin/androidx/ui/savedinstancestate/SavedInstanceState.kt
diff --git a/ui/ui-saved-instance-state/src/main/java/androidx/ui/savedinstancestate/Saver.kt b/ui/ui-saved-instance-state/src/commonMain/kotlin/androidx/ui/savedinstancestate/Saver.kt
similarity index 100%
rename from ui/ui-saved-instance-state/src/main/java/androidx/ui/savedinstancestate/Saver.kt
rename to ui/ui-saved-instance-state/src/commonMain/kotlin/androidx/ui/savedinstancestate/Saver.kt
diff --git a/ui/ui-saved-instance-state/src/main/java/androidx/ui/savedinstancestate/UiSavedStateRegistry.kt b/ui/ui-saved-instance-state/src/commonMain/kotlin/androidx/ui/savedinstancestate/UiSavedStateRegistry.kt
similarity index 100%
rename from ui/ui-saved-instance-state/src/main/java/androidx/ui/savedinstancestate/UiSavedStateRegistry.kt
rename to ui/ui-saved-instance-state/src/commonMain/kotlin/androidx/ui/savedinstancestate/UiSavedStateRegistry.kt
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/IsDisplayedTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/IsDisplayedTest.kt
index 870defa..d4cb20c 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/IsDisplayedTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/IsDisplayedTest.kt
@@ -55,14 +55,28 @@
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
-import org.junit.runners.JUnit4
+import org.junit.runners.Parameterized
@MediumTest
-@RunWith(JUnit4::class)
-class IsDisplayedTest {
+@RunWith(Parameterized::class)
+class IsDisplayedTest(val config: BitmapCapturingTest.TestConfig) {
+ data class TestConfig(
+ val activityClass: Class<out ComponentActivity>
+ )
+ companion object {
+ @JvmStatic
+ @Parameterized.Parameters(name = "{0}")
+ fun createTestSet(): List<BitmapCapturingTest.TestConfig> = listOf(
+ BitmapCapturingTest.TestConfig(ComponentActivity::class.java),
+ BitmapCapturingTest.TestConfig(ActivityWithActionBar::class.java)
+ )
+ }
+
+ @Suppress("DEPRECATION")
@get:Rule
- val composeTestRule = AndroidComposeTestRule<ComponentActivity>(disableTransitions = true)
+ val composeTestRule = AndroidComposeTestRule(
+ androidx.test.rule.ActivityTestRule(config.activityClass))
private val colors = listOf(Color.Red, Color.Green, Color.Blue)
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/TestAnimationClockTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/TestAnimationClockTest.kt
index 85a06a0..433b068 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/TestAnimationClockTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/TestAnimationClockTest.kt
@@ -20,6 +20,7 @@
import androidx.animation.LinearEasing
import androidx.animation.transitionDefinition
import androidx.compose.Composable
+import androidx.compose.ExperimentalComposeApi
import androidx.compose.FrameManager
import androidx.compose.Recomposer
import androidx.compose.State
@@ -122,6 +123,7 @@
val animationState = mutableStateOf(AnimationStates.From)
lateinit var recomposer: Recomposer
composeTestRule.setContent {
+ @OptIn(ExperimentalComposeApi::class)
recomposer = currentComposer.recomposer
Ui(animationState)
}
diff --git a/ui/ui-test/src/main/java/androidx/ui/test/Assertions.kt b/ui/ui-test/src/main/java/androidx/ui/test/Assertions.kt
index 6cf6c0e..e9919c1 100644
--- a/ui/ui-test/src/main/java/androidx/ui/test/Assertions.kt
+++ b/ui/ui-test/src/main/java/androidx/ui/test/Assertions.kt
@@ -21,10 +21,12 @@
import androidx.ui.core.LayoutNode
import androidx.ui.core.findClosestParentNode
import androidx.ui.core.semantics.SemanticsNode
+import androidx.ui.geometry.Offset
+import androidx.ui.geometry.Rect
import androidx.ui.semantics.AccessibilityRangeInfo
import androidx.ui.semantics.SemanticsProperties
-import androidx.ui.unit.PxBounds
import androidx.ui.unit.height
+import androidx.ui.unit.toRect
import androidx.ui.unit.width
/**
@@ -315,22 +317,32 @@
return (globalRect.width > 0f && globalRect.height > 0f)
}
+private fun SemanticsNode.nodeBoundsInWindow(): Rect {
+ val composeView = (componentNode.owner as AndroidOwner).view
+ val rootLocationInWindow = intArrayOf(0, 0).let {
+ composeView.getLocationInWindow(it)
+ Offset(it[0].toFloat(), it[1].toFloat())
+ }
+ return boundsInRoot.toRect().shift(rootLocationInWindow)
+}
+
private fun SemanticsNode.isInScreenBounds(): Boolean {
- val nodeBounds = globalBounds
- if (nodeBounds.width == 0f && nodeBounds.height == 0f) {
+ val composeView = (componentNode.owner as AndroidOwner).view
+
+ // Window relative bounds of our node
+ val nodeBoundsInWindow = nodeBoundsInWindow()
+ if (nodeBoundsInWindow.width == 0f || nodeBoundsInWindow.height == 0f) {
return false
}
- val displayMetrics = (componentNode.owner as AndroidOwner).view.resources.displayMetrics
- val screenBounds = PxBounds(
- left = 0f,
- top = 0f,
- right = displayMetrics.widthPixels.toFloat(),
- bottom = displayMetrics.heightPixels.toFloat()
- )
+ // Window relative bounds of our compose root view that are visible on the screen
+ val globalRootRect = android.graphics.Rect()
+ if (!composeView.getGlobalVisibleRect(globalRootRect)) {
+ return false
+ }
- return nodeBounds.top >= screenBounds.top &&
- nodeBounds.left >= screenBounds.left &&
- nodeBounds.right <= screenBounds.right &&
- nodeBounds.bottom <= screenBounds.bottom
+ return nodeBoundsInWindow.top >= globalRootRect.top &&
+ nodeBoundsInWindow.left >= globalRootRect.left &&
+ nodeBoundsInWindow.right <= globalRootRect.right &&
+ nodeBoundsInWindow.bottom <= globalRootRect.bottom
}
diff --git a/ui/ui-test/src/main/java/androidx/ui/test/android/AndroidOwnerRegistry.kt b/ui/ui-test/src/main/java/androidx/ui/test/android/AndroidOwnerRegistry.kt
index f39b500..1bb4b4d 100644
--- a/ui/ui-test/src/main/java/androidx/ui/test/android/AndroidOwnerRegistry.kt
+++ b/ui/ui-test/src/main/java/androidx/ui/test/android/AndroidOwnerRegistry.kt
@@ -68,11 +68,7 @@
*/
fun getOwners(): Set<AndroidOwner> {
return owners.filterTo(mutableSetOf()) {
- // lifecycleOwner can only be null if it.view is not yet attached, and since owners
- // are only in the registry when they're attached we don't care about the
- // lifecycleOwner being null.
- val lifecycleOwner = it.lifecycleOwner ?: return@filterTo false
- lifecycleOwner.lifecycle.currentState == Lifecycle.State.RESUMED
+ it.viewTreeOwners?.lifecycleOwner?.lifecycle?.currentState == Lifecycle.State.RESUMED
}
}
diff --git a/ui/ui-test/src/main/java/androidx/ui/test/android/FirstDrawRegistry.kt b/ui/ui-test/src/main/java/androidx/ui/test/android/FirstDrawRegistry.kt
index c69a7eb..8893f4d 100644
--- a/ui/ui-test/src/main/java/androidx/ui/test/android/FirstDrawRegistry.kt
+++ b/ui/ui-test/src/main/java/androidx/ui/test/android/FirstDrawRegistry.kt
@@ -59,8 +59,9 @@
*/
fun haveAllDrawn(): Boolean {
return notYetDrawn.all {
- val lifecycleOwner = it.lifecycleOwner ?: return false
- lifecycleOwner.lifecycle.currentState != Lifecycle.State.RESUMED
+ val viewTreeOwners = it.viewTreeOwners
+ viewTreeOwners == null ||
+ viewTreeOwners.lifecycleOwner.lifecycle.currentState != Lifecycle.State.RESUMED
}
}
diff --git a/ui/ui-tooling/src/androidTest/java/androidx/ui/tooling/ComposeViewAdapterTest.kt b/ui/ui-tooling/src/androidTest/java/androidx/ui/tooling/ComposeViewAdapterTest.kt
index fa94958..cf0dea08 100644
--- a/ui/ui-tooling/src/androidTest/java/androidx/ui/tooling/ComposeViewAdapterTest.kt
+++ b/ui/ui-tooling/src/androidTest/java/androidx/ui/tooling/ComposeViewAdapterTest.kt
@@ -16,8 +16,8 @@
package androidx.ui.tooling
+import android.app.Activity
import android.os.Bundle
-import androidx.activity.ComponentActivity
import androidx.ui.tooling.preview.ComposeViewAdapter
import androidx.ui.tooling.preview.ViewInfo
import androidx.ui.tooling.test.R
@@ -168,8 +168,16 @@
)
}
+ @Test
+ fun lifecycleUsedInsidePreview() {
+ assertRendersCorrectly(
+ "androidx.ui.tooling.SimpleComposablePreviewKt",
+ "LifecyclePreview"
+ )
+ }
+
companion object {
- class TestActivity : ComponentActivity() {
+ class TestActivity : Activity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.compose_adapter_test)
diff --git a/ui/ui-tooling/src/androidTest/java/androidx/ui/tooling/SimpleComposablePreview.kt b/ui/ui-tooling/src/androidTest/java/androidx/ui/tooling/SimpleComposablePreview.kt
index 839959e..2a404f9 100644
--- a/ui/ui-tooling/src/androidTest/java/androidx/ui/tooling/SimpleComposablePreview.kt
+++ b/ui/ui-tooling/src/androidTest/java/androidx/ui/tooling/SimpleComposablePreview.kt
@@ -17,6 +17,8 @@
package androidx.ui.tooling
import androidx.compose.Composable
+import androidx.lifecycle.Lifecycle
+import androidx.ui.core.LifecycleOwnerAmbient
import androidx.ui.foundation.Text
import androidx.ui.graphics.Color
import androidx.ui.material.Surface
@@ -64,6 +66,16 @@
Text("Default parameter ${a()} $b ${c.name}")
}
+@Preview
+@Composable
+private fun LifecyclePreview() {
+ val lifecycleState = LifecycleOwnerAmbient.current.lifecycle.currentState
+ if (lifecycleState != Lifecycle.State.RESUMED) throw IllegalArgumentException(
+ "Lifecycle state is not resumed. $lifecycleState"
+ )
+ Text("Lifecycle is $lifecycleState")
+}
+
class TestGroup {
@Preview
@Composable
diff --git a/ui/ui-tooling/src/main/java/androidx/ui/tooling/Inspectable.kt b/ui/ui-tooling/src/main/java/androidx/ui/tooling/Inspectable.kt
index 32ed1ee..3c037d1 100644
--- a/ui/ui-tooling/src/main/java/androidx/ui/tooling/Inspectable.kt
+++ b/ui/ui-tooling/src/main/java/androidx/ui/tooling/Inspectable.kt
@@ -17,6 +17,7 @@
package androidx.ui.tooling
import androidx.compose.Composable
+import androidx.compose.InternalComposeApi
import androidx.compose.Providers
import androidx.compose.SlotTable
import androidx.compose.currentComposer
@@ -52,6 +53,7 @@
slotTableRecord: SlotTableRecord,
children: @Composable () -> Unit
) {
+ @OptIn(InternalComposeApi::class)
currentComposer.collectKeySourceInformation()
(slotTableRecord as SlotTableRecordImpl).store.add(currentComposer.slotTable)
Providers(InspectionMode provides true, children = children)
diff --git a/ui/ui-tooling/src/main/java/androidx/ui/tooling/SlotTree.kt b/ui/ui-tooling/src/main/java/androidx/ui/tooling/SlotTree.kt
index a2fedcb..7dcddde 100644
--- a/ui/ui-tooling/src/main/java/androidx/ui/tooling/SlotTree.kt
+++ b/ui/ui-tooling/src/main/java/androidx/ui/tooling/SlotTree.kt
@@ -14,8 +14,10 @@
* limitations under the License.
*/
+@file:OptIn(InternalComposeApi::class)
package androidx.ui.tooling
+import androidx.compose.InternalComposeApi
import androidx.compose.SlotReader
import androidx.compose.SlotTable
import androidx.compose.isJoinedKey
diff --git a/ui/ui-tooling/src/main/java/androidx/ui/tooling/preview/ComposeViewAdapter.kt b/ui/ui-tooling/src/main/java/androidx/ui/tooling/preview/ComposeViewAdapter.kt
index 68b02f1..b39b929 100644
--- a/ui/ui-tooling/src/main/java/androidx/ui/tooling/preview/ComposeViewAdapter.kt
+++ b/ui/ui-tooling/src/main/java/androidx/ui/tooling/preview/ComposeViewAdapter.kt
@@ -29,6 +29,10 @@
import androidx.compose.Providers
import androidx.compose.Recomposer
import androidx.compose.currentComposer
+import androidx.lifecycle.Lifecycle
+import androidx.lifecycle.LifecycleOwner
+import androidx.lifecycle.LifecycleRegistry
+import androidx.lifecycle.ViewTreeLifecycleOwner
import androidx.ui.core.AnimationClockAmbient
import androidx.ui.core.FontLoaderAmbient
import androidx.ui.core.setContent
@@ -269,6 +273,7 @@
debugViewInfos: Boolean = false,
animationClockStartTime: Long = -1
) {
+ ViewTreeLifecycleOwner.set(this, FakeLifecycleOwner)
this.debugPaintBounds = debugPaintBounds
this.debugViewInfos = debugViewInfos
@@ -361,4 +366,12 @@
animationClockStartTime = animationClockStartTime
)
}
+
+ private val FakeLifecycleOwner = object : LifecycleOwner {
+ val lifecycleRegistry = LifecycleRegistry(this).apply {
+ currentState = Lifecycle.State.RESUMED
+ }
+
+ override fun getLifecycle() = lifecycleRegistry
+ }
}
diff --git a/ui/ui-vector/src/commonMain/kotlin/androidx/ui/graphics/vector/VectorComposeNonIR.kt b/ui/ui-vector/src/commonMain/kotlin/androidx/ui/graphics/vector/VectorComposeNonIR.kt
index d22fed2..dd63fc3a 100644
--- a/ui/ui-vector/src/commonMain/kotlin/androidx/ui/graphics/vector/VectorComposeNonIR.kt
+++ b/ui/ui-vector/src/commonMain/kotlin/androidx/ui/graphics/vector/VectorComposeNonIR.kt
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
+@file:OptIn(ExperimentalComposeApi::class)
package androidx.ui.graphics.vector
import androidx.compose.Applier
@@ -23,6 +23,8 @@
import androidx.compose.ComposerUpdater
import androidx.compose.CompositionReference
import androidx.compose.Composition
+import androidx.compose.ExperimentalComposeApi
+import androidx.compose.ComposeCompilerApi
import androidx.compose.Recomposer
import androidx.compose.SlotTable
import androidx.compose.compositionFor
@@ -62,6 +64,7 @@
composable: @Composable VectorScope.(viewportWidth: Float, viewportHeight: Float) -> Unit
): Composition = composeVector(container, Recomposer.current(), parent, composable)
+@OptIn(ComposeCompilerApi::class)
class VectorComposer(
val root: VNode,
slotTable: SlotTable,
diff --git a/wear/wear/src/main/java/androidx/wear/widget/BoxInsetLayout.java b/wear/wear/src/main/java/androidx/wear/widget/BoxInsetLayout.java
index e43e2bf..e68a72d 100644
--- a/wear/wear/src/main/java/androidx/wear/widget/BoxInsetLayout.java
+++ b/wear/wear/src/main/java/androidx/wear/widget/BoxInsetLayout.java
@@ -428,7 +428,11 @@
super(context, attrs);
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.BoxInsetLayout_Layout,
0, 0);
- boxedEdges = a.getInt(R.styleable.BoxInsetLayout_Layout_boxedEdges, BOX_NONE);
+ int boxedEdgesResourceKey = R.styleable.BoxInsetLayout_Layout_layout_boxedEdges;
+ if (!a.hasValueOrEmpty(R.styleable.BoxInsetLayout_Layout_layout_boxedEdges)){
+ boxedEdgesResourceKey = R.styleable.BoxInsetLayout_Layout_boxedEdges;
+ }
+ boxedEdges = a.getInt(boxedEdgesResourceKey, BOX_NONE);
a.recycle();
}
diff --git a/wear/wear/src/main/res/values/attrs.xml b/wear/wear/src/main/res/values/attrs.xml
index 12d4de6..4044dbc 100644
--- a/wear/wear/src/main/res/values/attrs.xml
+++ b/wear/wear/src/main/res/values/attrs.xml
@@ -28,11 +28,26 @@
<p>The values defined here correspond to the base layout attribute
class {@landroidx.wearwear.widget.BoxInsetLayout.LayoutParams}. -->
<declare-styleable name="BoxInsetLayout_Layout">
+ <!-- Deprecated. Use {@link #layout_boxedEdges} instead. -->
+ <attr name="boxedEdges">
+ <!-- Default boxing setting. There are no insets forced on the child views. -->
+ <flag name="none" value="0x00" />
+ <!-- The view will force an inset on the left edge of the children. -->
+ <flag name="left" value="0x01" />
+ <!-- The view will force an inset on the top edge of the children. -->
+ <flag name="top" value="0x02" />
+ <!-- The view will force an inset on the right edge of the children. -->
+ <flag name="right" value="0x04" />
+ <!-- The view will force an inset on the bottom edge of the children. -->
+ <flag name="bottom" value="0x08" />
+ <!-- The view will force an inset on all of the edges of the children. -->
+ <flag name="all" value="0x0F" />
+ </attr>
<!-- The types of insets this view can force on its children. The view will respect the
defined values of other child attributes such as ones provided by
{@link android.view.ViewGroup.MarginLayoutParams}, but it will add an additional inset
as requested -->
- <attr name="boxedEdges">
+ <attr name="layout_boxedEdges">
<!-- Default boxing setting. There are no insets forced on the child views. -->
<flag name="none" value="0x00" />
<!-- The view will force an inset on the left edge of the children. -->