Merge "Handle @Transient annotation in KSP" into androidx-main
diff --git a/buildSrc/res/values/public.xml b/buildSrc/res/values/public.xml
new file mode 100644
index 0000000..7964639
--- /dev/null
+++ b/buildSrc/res/values/public.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright 2021 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.
+ -->
+
+<resources>
+ <!-- Empty public resource to ensure that AGP generates a public.txt file. -->
+ <public />
+</resources>
diff --git a/buildSrc/src/main/kotlin/androidx/build/AndroidXPlugin.kt b/buildSrc/src/main/kotlin/androidx/build/AndroidXPlugin.kt
index 63b4030..fb07963 100644
--- a/buildSrc/src/main/kotlin/androidx/build/AndroidXPlugin.kt
+++ b/buildSrc/src/main/kotlin/androidx/build/AndroidXPlugin.kt
@@ -32,6 +32,7 @@
import androidx.build.gradle.isRoot
import androidx.build.jacoco.Jacoco
import androidx.build.license.configureExternalDependencyLicenseCheck
+import androidx.build.resources.configurePublicResourcesStub
import androidx.build.studio.StudioTask
import androidx.build.testConfiguration.addAppApkToTestConfigGeneration
import androidx.build.testConfiguration.configureTestConfigGeneration
@@ -286,6 +287,7 @@
check(!excludes.contains("/META-INF/*.kotlin_module"))
}
+ project.configurePublicResourcesStub(libraryExtension)
project.configureSourceJarForAndroid(libraryExtension)
project.configureVersionFileWriter(libraryExtension, androidXExtension)
project.addCreateLibraryBuildInfoFileTask(androidXExtension)
diff --git a/buildSrc/src/main/kotlin/androidx/build/LibraryVersions.kt b/buildSrc/src/main/kotlin/androidx/build/LibraryVersions.kt
index 2956a4d..419c479 100644
--- a/buildSrc/src/main/kotlin/androidx/build/LibraryVersions.kt
+++ b/buildSrc/src/main/kotlin/androidx/build/LibraryVersions.kt
@@ -136,7 +136,7 @@
val WEAR_WATCHFACE_DATA = Version("1.0.0-alpha05")
val WEAR_WATCHFACE_EDITOR = Version("1.0.0-alpha05")
val WEAR_WATCHFACE_STYLE = Version("1.0.0-alpha05")
- val WEBKIT = Version("1.4.0-beta01")
+ val WEBKIT = Version("1.5.0-alpha01")
val WINDOW = Version("1.0.0-alpha02")
val WINDOW_EXTENSIONS = Version("1.0.0-alpha01")
val WINDOW_SIDECAR = Version("0.1.0-alpha01")
diff --git a/buildSrc/src/main/kotlin/androidx/build/dependencies/Dependencies.kt b/buildSrc/src/main/kotlin/androidx/build/dependencies/Dependencies.kt
index 4f725e8..e09d0d5 100644
--- a/buildSrc/src/main/kotlin/androidx/build/dependencies/Dependencies.kt
+++ b/buildSrc/src/main/kotlin/androidx/build/dependencies/Dependencies.kt
@@ -125,7 +125,7 @@
}
}
const val TRUTH = "com.google.truth:truth:1.0.1"
-const val XERIAL = "org.xerial:sqlite-jdbc:3.25.2"
+const val XERIAL = "org.xerial:sqlite-jdbc:3.34.0"
const val XPP3 = "xpp3:xpp3:1.1.4c"
const val XMLPULL = "xmlpull:xmlpull:1.1.3.1"
diff --git a/buildSrc/src/main/kotlin/androidx/build/resources/GenerateResourceApiTask.kt b/buildSrc/src/main/kotlin/androidx/build/resources/GenerateResourceApiTask.kt
index 5d9c895..8ee38d4 100644
--- a/buildSrc/src/main/kotlin/androidx/build/resources/GenerateResourceApiTask.kt
+++ b/buildSrc/src/main/kotlin/androidx/build/resources/GenerateResourceApiTask.kt
@@ -18,11 +18,14 @@
import androidx.build.checkapi.ApiLocation
import org.gradle.api.DefaultTask
+import org.gradle.api.GradleException
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.provider.Property
import org.gradle.api.tasks.InputFiles
import org.gradle.api.tasks.Internal
import org.gradle.api.tasks.OutputFile
+import org.gradle.api.tasks.PathSensitive
+import org.gradle.api.tasks.PathSensitivity
import org.gradle.api.tasks.TaskAction
import java.io.File
@@ -39,6 +42,10 @@
@get:InputFiles // InputFiles allows non-existent files, whereas InputFile does not.
abstract val builtApi: RegularFileProperty
+ /** Source files against which API signatures will be validated. */
+ @get:[InputFiles PathSensitive(PathSensitivity.RELATIVE)]
+ var sourcePaths: Collection<File> = emptyList()
+
/** Text file to which API signatures will be written. */
@get:Internal
abstract val apiLocation: Property<ApiLocation>
@@ -54,7 +61,15 @@
val sortedApiLines = if (builtApiFile.exists()) {
builtApiFile.readLines().toSortedSet()
} else {
- emptySet<String>()
+ val errorMessage = """No public resources defined
+
+At least one public resource must be defined to prevent all resources from
+appearing public by default.
+
+This exception should never occur for AndroidX projects, as a <public />
+resource is added by default to all library project. Please contact the
+AndroidX Core team for assistance."""
+ throw GradleException(errorMessage)
}
val outputApiFile = apiLocation.get().resourceFile
diff --git a/buildSrc/src/main/kotlin/androidx/build/resources/PublicResourcesStubHelper.kt b/buildSrc/src/main/kotlin/androidx/build/resources/PublicResourcesStubHelper.kt
new file mode 100644
index 0000000..1660ba5
--- /dev/null
+++ b/buildSrc/src/main/kotlin/androidx/build/resources/PublicResourcesStubHelper.kt
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2021 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.build.resources
+
+import com.android.build.gradle.LibraryExtension
+import org.gradle.api.Project
+import java.io.File
+
+fun Project.configurePublicResourcesStub(extension: LibraryExtension) {
+ extension.libraryVariants.all { variant ->
+ variant.registerGeneratedResFolders(
+ project.files(
+ File(project.rootDir, "/buildSrc/res")
+ )
+ )
+ }
+}
diff --git a/buildSrc/src/main/kotlin/androidx/build/testConfiguration/TestSuiteConfiguration.kt b/buildSrc/src/main/kotlin/androidx/build/testConfiguration/TestSuiteConfiguration.kt
index 764abcc..0e8cc90 100644
--- a/buildSrc/src/main/kotlin/androidx/build/testConfiguration/TestSuiteConfiguration.kt
+++ b/buildSrc/src/main/kotlin/androidx/build/testConfiguration/TestSuiteConfiguration.kt
@@ -34,13 +34,22 @@
import org.gradle.api.tasks.TaskProvider
import java.io.File
+/**
+ * Creates and configures the test config generation task for a project. Configuration includes
+ * populating the task with relevant data from the first 4 params, and setting whether the task
+ * is enabled.
+ *
+ * @param overrideProject Allows the config task for one project to get registered to an
+ * alternative project. Default is for the project to register the new config task to itself
+ */
fun Project.createTestConfigurationGenerationTask(
variantName: String,
artifacts: Artifacts,
minSdk: Int,
- testRunner: String
+ testRunner: String,
+ overrideProject: Project = this
) {
- val generateTestConfigurationTask = this.tasks.register(
+ val generateTestConfigurationTask = overrideProject.tasks.register(
"${AndroidXPlugin.GENERATE_TEST_CONFIGURATION_TASK}$variantName",
GenerateTestConfigurationTask::class.java
) { task ->
@@ -73,13 +82,14 @@
.dependsOn(generateTestConfigurationTask)
}
-fun Project.addAppApkToTestConfigGeneration() {
+fun Project.addAppApkToTestConfigGeneration(overrideProject: Project = this) {
extensions.getByType<ApplicationAndroidComponentsExtension>().apply {
onVariants(selector().withBuildType("debug")) { debugVariant ->
- tasks.withType(GenerateTestConfigurationTask::class.java).configureEach {
- it.appFolder.set(debugVariant.artifacts.get(ArtifactType.APK))
- it.appLoader.set(debugVariant.artifacts.getBuiltArtifactsLoader())
- }
+ overrideProject.tasks.withType(GenerateTestConfigurationTask::class.java)
+ .configureEach {
+ it.appFolder.set(debugVariant.artifacts.get(ArtifactType.APK))
+ it.appLoader.set(debugVariant.artifacts.getBuiltArtifactsLoader())
+ }
}
}
}
@@ -87,14 +97,15 @@
private fun getOrCreateMediaTestConfigTask(project: Project, isMedia2: Boolean):
TaskProvider<GenerateMediaTestConfigurationTask> {
val mediaPrefix = getMediaConfigTaskPrefix(isMedia2)
- if (!project.parent!!.tasks.withType(GenerateMediaTestConfigurationTask::class.java)
+ val parentProject = project.parent!!
+ if (!parentProject.tasks.withType(GenerateMediaTestConfigurationTask::class.java)
.names.contains(
"support-$mediaPrefix-test${
AndroidXPlugin.GENERATE_TEST_CONFIGURATION_TASK
}"
)
) {
- val task = project.parent!!.tasks.register(
+ val task = parentProject.tasks.register(
"support-$mediaPrefix-test${AndroidXPlugin.GENERATE_TEST_CONFIGURATION_TASK}",
GenerateMediaTestConfigurationTask::class.java
) { task ->
@@ -109,7 +120,7 @@
.dependsOn(task)
return task
} else {
- return project.parent!!.tasks.withType(GenerateMediaTestConfigurationTask::class.java)
+ return parentProject.tasks.withType(GenerateMediaTestConfigurationTask::class.java)
.named(
"support-$mediaPrefix-test${
AndroidXPlugin.GENERATE_TEST_CONFIGURATION_TASK
@@ -178,6 +189,66 @@
}
}
+private fun Project.getOrCreateMacrobenchmarkConfigTask(variantName: String):
+ TaskProvider<GenerateTestConfigurationTask> {
+ val parentProject = this.parent!!
+ return if (
+ parentProject.tasks.withType(GenerateTestConfigurationTask::class.java).isEmpty()
+ ) {
+ parentProject.tasks.register(
+ "${AndroidXPlugin.GENERATE_TEST_CONFIGURATION_TASK}$variantName",
+ GenerateTestConfigurationTask::class.java
+ )
+ } else {
+ parentProject.tasks.withType(GenerateTestConfigurationTask::class.java)
+ .named("${AndroidXPlugin.GENERATE_TEST_CONFIGURATION_TASK}$variantName")
+ }
+ }
+
+private fun Project.configureMacrobenchmarkConfigTask(
+ variantName: String,
+ artifacts: Artifacts,
+ minSdk: Int,
+ testRunner: String
+) {
+ val configTask = getOrCreateMacrobenchmarkConfigTask(variantName)
+ if (path.endsWith("macrobenchmark")) {
+ configTask.configure { task ->
+ task.testFolder.set(artifacts.get(ArtifactType.APK))
+ task.testLoader.set(artifacts.getBuiltArtifactsLoader())
+ task.outputXml.fileValue(
+ File(
+ this.getTestConfigDirectory(),
+ "${this.path.asFilenamePrefix()}$variantName.xml"
+ )
+ )
+ task.minSdk.set(minSdk)
+ task.hasBenchmarkPlugin.set(this.hasBenchmarkPlugin())
+ task.testRunner.set(testRunner)
+ task.projectPath.set(this.path)
+ task.affectedModuleDetectorSubset.set(
+ project.provider {
+ AffectedModuleDetector.getProjectSubset(project)
+ }
+ )
+ AffectedModuleDetector.configureTaskGuard(task)
+ }
+ // Disable xml generation for projects that have no test sources
+ this.afterEvaluate {
+ configTask.configure {
+ it.enabled = this.hasAndroidTestSourceCode()
+ }
+ }
+ this.rootProject.tasks.findByName(AndroidXPlugin.ZIP_TEST_CONFIGS_WITH_APKS_TASK)!!
+ .dependsOn(configTask)
+ } else if (path.endsWith("macrobenchmark-target")) {
+ configTask.configure { task ->
+ task.appFolder.set(artifacts.get(ArtifactType.APK))
+ task.appLoader.set(artifacts.getBuiltArtifactsLoader())
+ }
+ }
+}
+
fun Project.configureTestConfigGeneration(testedExtension: TestedExtension) {
extensions.getByType<AndroidComponentsExtension<*, *>>().apply {
androidTest(selector().all()) { androidTest ->
@@ -200,6 +271,15 @@
isMedia2 = false
)
}
+ path.endsWith("macrobenchmark") ||
+ path.endsWith("macrobenchmark-target") -> {
+ configureMacrobenchmarkConfigTask(
+ androidTest.name,
+ androidTest.artifacts,
+ testedExtension.defaultConfig.minSdk!!,
+ testedExtension.defaultConfig.testInstrumentationRunner!!
+ )
+ }
else -> {
createTestConfigurationGenerationTask(
androidTest.name,
diff --git a/camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/compat/quirk/SamsungPreviewTargetAspectRatioQuirk.java b/camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/compat/quirk/SamsungPreviewTargetAspectRatioQuirk.java
index 5e97281..c5637ee 100644
--- a/camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/compat/quirk/SamsungPreviewTargetAspectRatioQuirk.java
+++ b/camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/compat/quirk/SamsungPreviewTargetAspectRatioQuirk.java
@@ -27,21 +27,17 @@
import java.util.List;
/**
- * Quirk that produces stretched or incorrect FOV preview on certain Samsung devices.
+ * Quirk that produces stretched preview on certain Samsung devices.
*
* <p> On certain Samsung devices, the HAL provides 16:9 preview even when the Surface size is
* set to 4:3, which causes the preview to be stretched in PreviewView.
- *
- * <p> On certain Samsung devices, the HAL crops the preview images from the cropped 16:9 area but
- * not the full active array area, which causes the preview FOV incorrect when using non-16:9 sizes.
*/
public class SamsungPreviewTargetAspectRatioQuirk implements Quirk {
// List of devices with the issue.
private static final List<String> DEVICE_MODELS = Arrays.asList(
"SM-J710MN", // b/170762209
- "SM-T580", // b/169471824
- "SM-J327U" // b/176474000
+ "SM-T580" // b/169471824
);
static boolean load() {
diff --git a/camera/camera-camera2/src/main/res/values/public.xml b/camera/camera-camera2/src/main/res/values/public.xml
index 91112ca..73009f1 100644
--- a/camera/camera-camera2/src/main/res/values/public.xml
+++ b/camera/camera-camera2/src/main/res/values/public.xml
@@ -16,5 +16,4 @@
-->
<resources>
- <public />
</resources>
diff --git a/camera/camera-camera2/src/test/java/androidx/camera/camera2/internal/compat/workaround/TargetAspectRatioTest.java b/camera/camera-camera2/src/test/java/androidx/camera/camera2/internal/compat/workaround/TargetAspectRatioTest.java
index 9d98353..8049c3b 100644
--- a/camera/camera-camera2/src/test/java/androidx/camera/camera2/internal/compat/workaround/TargetAspectRatioTest.java
+++ b/camera/camera-camera2/src/test/java/androidx/camera/camera2/internal/compat/workaround/TargetAspectRatioTest.java
@@ -84,15 +84,6 @@
data.add(new Object[]{new Config("Samsung", "SM-T580", false,
INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED, RATIO_16_9, RATIO_ORIGINAL,
ALL_API_LEVELS)});
- data.add(new Object[]{new Config("Samsung", "SM-J327U", true,
- INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED, RATIO_4_3, RATIO_16_9, ALL_API_LEVELS)});
- data.add(new Object[]{new Config("Samsung", "SM-J327U", true,
- INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED, RATIO_16_9, RATIO_16_9, ALL_API_LEVELS)});
- data.add(new Object[]{new Config("Samsung", "SM-J327U", false,
- INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED, RATIO_4_3, RATIO_ORIGINAL, ALL_API_LEVELS)});
- data.add(new Object[]{new Config("Samsung", "SM-J327U", false,
- INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED, RATIO_16_9, RATIO_ORIGINAL,
- ALL_API_LEVELS)});
data.add(new Object[]{new Config("Google", "Nexus 4", true,
INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY, RATIO_4_3, RATIO_MAX_JPEG,
new Range<>(21, 22))});
diff --git a/camera/camera-core/src/main/res/values/public.xml b/camera/camera-core/src/main/res/values/public.xml
index 91112ca..73009f1 100644
--- a/camera/camera-core/src/main/res/values/public.xml
+++ b/camera/camera-core/src/main/res/values/public.xml
@@ -16,5 +16,4 @@
-->
<resources>
- <public />
</resources>
diff --git a/car/app/app/api/current.txt b/car/app/app/api/current.txt
index d68f9c6..86127ba 100644
--- a/car/app/app/api/current.txt
+++ b/car/app/app/api/current.txt
@@ -255,17 +255,21 @@
method public androidx.car.app.model.CarIcon.Builder setTint(androidx.car.app.model.CarColor?);
}
- public class CarIconSpan extends android.text.style.CharacterStyle {
+ public class CarIconSpan extends androidx.car.app.model.CarSpan {
method public static androidx.car.app.model.CarIconSpan create(androidx.car.app.model.CarIcon);
method public static androidx.car.app.model.CarIconSpan create(androidx.car.app.model.CarIcon, int);
method public int getAlignment();
method public androidx.car.app.model.CarIcon getIcon();
- method public void updateDrawState(android.text.TextPaint?);
field public static final int ALIGN_BASELINE = 1; // 0x1
field public static final int ALIGN_BOTTOM = 0; // 0x0
field public static final int ALIGN_CENTER = 2; // 0x2
}
+ @Keep public class CarSpan extends android.text.style.CharacterStyle {
+ ctor public CarSpan();
+ method public void updateDrawState(android.text.TextPaint);
+ }
+
public class CarText {
method public static androidx.car.app.model.CarText create(CharSequence);
method public java.util.List<androidx.car.app.model.CarText.SpanWrapper!> getSpans();
@@ -276,10 +280,14 @@
}
public static class CarText.SpanWrapper {
- field @Keep public final int end;
- field @Keep public final int flags;
- field @Keep public final Object? span;
- field @Keep public final int start;
+ method public androidx.car.app.model.CarSpan getCarSpan();
+ method public int getEnd();
+ method public int getFlags();
+ method public int getStart();
+ field @Deprecated @Keep public final int end;
+ field @Deprecated @Keep public final int flags;
+ field @Deprecated @Keep public final Object! span;
+ field @Deprecated @Keep public final int start;
}
public class DateTimeWithZone {
@@ -304,23 +312,20 @@
field public static final int UNIT_YARDS = 7; // 0x7
}
- public class DistanceSpan extends android.text.style.CharacterStyle {
+ public class DistanceSpan extends androidx.car.app.model.CarSpan {
method public static androidx.car.app.model.DistanceSpan create(androidx.car.app.model.Distance);
method public androidx.car.app.model.Distance getDistance();
- method public void updateDrawState(android.text.TextPaint?);
}
- public class DurationSpan extends android.text.style.CharacterStyle {
+ public class DurationSpan extends androidx.car.app.model.CarSpan {
method public static androidx.car.app.model.DurationSpan create(long);
method @RequiresApi(26) public static androidx.car.app.model.DurationSpan create(java.time.Duration);
method public long getDurationSeconds();
- method public void updateDrawState(android.text.TextPaint?);
}
- public class ForegroundCarColorSpan extends android.text.style.CharacterStyle {
+ public class ForegroundCarColorSpan extends androidx.car.app.model.CarSpan {
method public static androidx.car.app.model.ForegroundCarColorSpan create(androidx.car.app.model.CarColor);
method public androidx.car.app.model.CarColor getColor();
- method public void updateDrawState(android.text.TextPaint);
}
public class GridItem implements androidx.car.app.model.Item {
@@ -428,7 +433,8 @@
public final class MessageTemplate implements androidx.car.app.model.Template {
method public static androidx.car.app.model.MessageTemplate.Builder builder(CharSequence);
- method public androidx.car.app.model.ActionList? getActions();
+ method public java.util.List<androidx.car.app.model.Action!> getActionList();
+ method @Deprecated public androidx.car.app.model.ActionList? getActions();
method public androidx.car.app.model.CarText? getDebugMessage();
method public androidx.car.app.model.Action? getHeaderAction();
method public androidx.car.app.model.CarIcon? getIcon();
@@ -439,7 +445,8 @@
public static final class MessageTemplate.Builder {
ctor public MessageTemplate.Builder(CharSequence);
method public androidx.car.app.model.MessageTemplate build();
- method public androidx.car.app.model.MessageTemplate.Builder setActions(java.util.List<androidx.car.app.model.Action!>);
+ method public androidx.car.app.model.MessageTemplate.Builder setActionList(java.util.List<androidx.car.app.model.Action!>);
+ method @Deprecated public androidx.car.app.model.MessageTemplate.Builder setActions(java.util.List<androidx.car.app.model.Action!>);
method public androidx.car.app.model.MessageTemplate.Builder setDebugCause(Throwable?);
method public androidx.car.app.model.MessageTemplate.Builder setDebugMessage(String?);
method public androidx.car.app.model.MessageTemplate.Builder setHeaderAction(androidx.car.app.model.Action?);
@@ -485,7 +492,8 @@
public final class Pane {
method public static androidx.car.app.model.Pane.Builder builder();
- method public androidx.car.app.model.ActionList? getActions();
+ method public java.util.List<androidx.car.app.model.Action!> getActionList();
+ method @Deprecated public androidx.car.app.model.ActionList? getActions();
method public java.util.List<java.lang.Object!> getRows();
method public boolean isLoading();
}
@@ -494,7 +502,8 @@
ctor public Pane.Builder();
method public androidx.car.app.model.Pane.Builder addRow(androidx.car.app.model.Row);
method public androidx.car.app.model.Pane build();
- method public androidx.car.app.model.Pane.Builder setActions(java.util.List<androidx.car.app.model.Action!>);
+ method public androidx.car.app.model.Pane.Builder setActionList(java.util.List<androidx.car.app.model.Action!>);
+ method @Deprecated public androidx.car.app.model.Pane.Builder setActions(java.util.List<androidx.car.app.model.Action!>);
method public androidx.car.app.model.Pane.Builder setLoading(boolean);
}
@@ -648,7 +657,6 @@
}
public interface Template {
- method public default void checkPermissions(android.content.Context);
}
public final class TemplateInfo {
@@ -971,10 +979,12 @@
public static final class Trip.Builder {
ctor public Trip.Builder();
- method public androidx.car.app.navigation.model.Trip.Builder addDestination(androidx.car.app.navigation.model.Destination);
- method public androidx.car.app.navigation.model.Trip.Builder addDestinationTravelEstimate(androidx.car.app.navigation.model.TravelEstimate);
- method public androidx.car.app.navigation.model.Trip.Builder addStep(androidx.car.app.navigation.model.Step?);
- method public androidx.car.app.navigation.model.Trip.Builder addStepTravelEstimate(androidx.car.app.navigation.model.TravelEstimate);
+ method public androidx.car.app.navigation.model.Trip.Builder addDestination(androidx.car.app.navigation.model.Destination, androidx.car.app.navigation.model.TravelEstimate);
+ method @Deprecated public androidx.car.app.navigation.model.Trip.Builder addDestination(androidx.car.app.navigation.model.Destination);
+ method @Deprecated public androidx.car.app.navigation.model.Trip.Builder addDestinationTravelEstimate(androidx.car.app.navigation.model.TravelEstimate);
+ method public androidx.car.app.navigation.model.Trip.Builder addStep(androidx.car.app.navigation.model.Step?, androidx.car.app.navigation.model.TravelEstimate);
+ method @Deprecated public androidx.car.app.navigation.model.Trip.Builder addStep(androidx.car.app.navigation.model.Step?);
+ method @Deprecated public androidx.car.app.navigation.model.Trip.Builder addStepTravelEstimate(androidx.car.app.navigation.model.TravelEstimate);
method public androidx.car.app.navigation.model.Trip build();
method public androidx.car.app.navigation.model.Trip.Builder clearDestinationTravelEstimates();
method public androidx.car.app.navigation.model.Trip.Builder clearDestinations();
diff --git a/car/app/app/api/public_plus_experimental_current.txt b/car/app/app/api/public_plus_experimental_current.txt
index d68f9c6..86127ba 100644
--- a/car/app/app/api/public_plus_experimental_current.txt
+++ b/car/app/app/api/public_plus_experimental_current.txt
@@ -255,17 +255,21 @@
method public androidx.car.app.model.CarIcon.Builder setTint(androidx.car.app.model.CarColor?);
}
- public class CarIconSpan extends android.text.style.CharacterStyle {
+ public class CarIconSpan extends androidx.car.app.model.CarSpan {
method public static androidx.car.app.model.CarIconSpan create(androidx.car.app.model.CarIcon);
method public static androidx.car.app.model.CarIconSpan create(androidx.car.app.model.CarIcon, int);
method public int getAlignment();
method public androidx.car.app.model.CarIcon getIcon();
- method public void updateDrawState(android.text.TextPaint?);
field public static final int ALIGN_BASELINE = 1; // 0x1
field public static final int ALIGN_BOTTOM = 0; // 0x0
field public static final int ALIGN_CENTER = 2; // 0x2
}
+ @Keep public class CarSpan extends android.text.style.CharacterStyle {
+ ctor public CarSpan();
+ method public void updateDrawState(android.text.TextPaint);
+ }
+
public class CarText {
method public static androidx.car.app.model.CarText create(CharSequence);
method public java.util.List<androidx.car.app.model.CarText.SpanWrapper!> getSpans();
@@ -276,10 +280,14 @@
}
public static class CarText.SpanWrapper {
- field @Keep public final int end;
- field @Keep public final int flags;
- field @Keep public final Object? span;
- field @Keep public final int start;
+ method public androidx.car.app.model.CarSpan getCarSpan();
+ method public int getEnd();
+ method public int getFlags();
+ method public int getStart();
+ field @Deprecated @Keep public final int end;
+ field @Deprecated @Keep public final int flags;
+ field @Deprecated @Keep public final Object! span;
+ field @Deprecated @Keep public final int start;
}
public class DateTimeWithZone {
@@ -304,23 +312,20 @@
field public static final int UNIT_YARDS = 7; // 0x7
}
- public class DistanceSpan extends android.text.style.CharacterStyle {
+ public class DistanceSpan extends androidx.car.app.model.CarSpan {
method public static androidx.car.app.model.DistanceSpan create(androidx.car.app.model.Distance);
method public androidx.car.app.model.Distance getDistance();
- method public void updateDrawState(android.text.TextPaint?);
}
- public class DurationSpan extends android.text.style.CharacterStyle {
+ public class DurationSpan extends androidx.car.app.model.CarSpan {
method public static androidx.car.app.model.DurationSpan create(long);
method @RequiresApi(26) public static androidx.car.app.model.DurationSpan create(java.time.Duration);
method public long getDurationSeconds();
- method public void updateDrawState(android.text.TextPaint?);
}
- public class ForegroundCarColorSpan extends android.text.style.CharacterStyle {
+ public class ForegroundCarColorSpan extends androidx.car.app.model.CarSpan {
method public static androidx.car.app.model.ForegroundCarColorSpan create(androidx.car.app.model.CarColor);
method public androidx.car.app.model.CarColor getColor();
- method public void updateDrawState(android.text.TextPaint);
}
public class GridItem implements androidx.car.app.model.Item {
@@ -428,7 +433,8 @@
public final class MessageTemplate implements androidx.car.app.model.Template {
method public static androidx.car.app.model.MessageTemplate.Builder builder(CharSequence);
- method public androidx.car.app.model.ActionList? getActions();
+ method public java.util.List<androidx.car.app.model.Action!> getActionList();
+ method @Deprecated public androidx.car.app.model.ActionList? getActions();
method public androidx.car.app.model.CarText? getDebugMessage();
method public androidx.car.app.model.Action? getHeaderAction();
method public androidx.car.app.model.CarIcon? getIcon();
@@ -439,7 +445,8 @@
public static final class MessageTemplate.Builder {
ctor public MessageTemplate.Builder(CharSequence);
method public androidx.car.app.model.MessageTemplate build();
- method public androidx.car.app.model.MessageTemplate.Builder setActions(java.util.List<androidx.car.app.model.Action!>);
+ method public androidx.car.app.model.MessageTemplate.Builder setActionList(java.util.List<androidx.car.app.model.Action!>);
+ method @Deprecated public androidx.car.app.model.MessageTemplate.Builder setActions(java.util.List<androidx.car.app.model.Action!>);
method public androidx.car.app.model.MessageTemplate.Builder setDebugCause(Throwable?);
method public androidx.car.app.model.MessageTemplate.Builder setDebugMessage(String?);
method public androidx.car.app.model.MessageTemplate.Builder setHeaderAction(androidx.car.app.model.Action?);
@@ -485,7 +492,8 @@
public final class Pane {
method public static androidx.car.app.model.Pane.Builder builder();
- method public androidx.car.app.model.ActionList? getActions();
+ method public java.util.List<androidx.car.app.model.Action!> getActionList();
+ method @Deprecated public androidx.car.app.model.ActionList? getActions();
method public java.util.List<java.lang.Object!> getRows();
method public boolean isLoading();
}
@@ -494,7 +502,8 @@
ctor public Pane.Builder();
method public androidx.car.app.model.Pane.Builder addRow(androidx.car.app.model.Row);
method public androidx.car.app.model.Pane build();
- method public androidx.car.app.model.Pane.Builder setActions(java.util.List<androidx.car.app.model.Action!>);
+ method public androidx.car.app.model.Pane.Builder setActionList(java.util.List<androidx.car.app.model.Action!>);
+ method @Deprecated public androidx.car.app.model.Pane.Builder setActions(java.util.List<androidx.car.app.model.Action!>);
method public androidx.car.app.model.Pane.Builder setLoading(boolean);
}
@@ -648,7 +657,6 @@
}
public interface Template {
- method public default void checkPermissions(android.content.Context);
}
public final class TemplateInfo {
@@ -971,10 +979,12 @@
public static final class Trip.Builder {
ctor public Trip.Builder();
- method public androidx.car.app.navigation.model.Trip.Builder addDestination(androidx.car.app.navigation.model.Destination);
- method public androidx.car.app.navigation.model.Trip.Builder addDestinationTravelEstimate(androidx.car.app.navigation.model.TravelEstimate);
- method public androidx.car.app.navigation.model.Trip.Builder addStep(androidx.car.app.navigation.model.Step?);
- method public androidx.car.app.navigation.model.Trip.Builder addStepTravelEstimate(androidx.car.app.navigation.model.TravelEstimate);
+ method public androidx.car.app.navigation.model.Trip.Builder addDestination(androidx.car.app.navigation.model.Destination, androidx.car.app.navigation.model.TravelEstimate);
+ method @Deprecated public androidx.car.app.navigation.model.Trip.Builder addDestination(androidx.car.app.navigation.model.Destination);
+ method @Deprecated public androidx.car.app.navigation.model.Trip.Builder addDestinationTravelEstimate(androidx.car.app.navigation.model.TravelEstimate);
+ method public androidx.car.app.navigation.model.Trip.Builder addStep(androidx.car.app.navigation.model.Step?, androidx.car.app.navigation.model.TravelEstimate);
+ method @Deprecated public androidx.car.app.navigation.model.Trip.Builder addStep(androidx.car.app.navigation.model.Step?);
+ method @Deprecated public androidx.car.app.navigation.model.Trip.Builder addStepTravelEstimate(androidx.car.app.navigation.model.TravelEstimate);
method public androidx.car.app.navigation.model.Trip build();
method public androidx.car.app.navigation.model.Trip.Builder clearDestinationTravelEstimates();
method public androidx.car.app.navigation.model.Trip.Builder clearDestinations();
diff --git a/car/app/app/api/restricted_current.txt b/car/app/app/api/restricted_current.txt
index d68f9c6..86127ba 100644
--- a/car/app/app/api/restricted_current.txt
+++ b/car/app/app/api/restricted_current.txt
@@ -255,17 +255,21 @@
method public androidx.car.app.model.CarIcon.Builder setTint(androidx.car.app.model.CarColor?);
}
- public class CarIconSpan extends android.text.style.CharacterStyle {
+ public class CarIconSpan extends androidx.car.app.model.CarSpan {
method public static androidx.car.app.model.CarIconSpan create(androidx.car.app.model.CarIcon);
method public static androidx.car.app.model.CarIconSpan create(androidx.car.app.model.CarIcon, int);
method public int getAlignment();
method public androidx.car.app.model.CarIcon getIcon();
- method public void updateDrawState(android.text.TextPaint?);
field public static final int ALIGN_BASELINE = 1; // 0x1
field public static final int ALIGN_BOTTOM = 0; // 0x0
field public static final int ALIGN_CENTER = 2; // 0x2
}
+ @Keep public class CarSpan extends android.text.style.CharacterStyle {
+ ctor public CarSpan();
+ method public void updateDrawState(android.text.TextPaint);
+ }
+
public class CarText {
method public static androidx.car.app.model.CarText create(CharSequence);
method public java.util.List<androidx.car.app.model.CarText.SpanWrapper!> getSpans();
@@ -276,10 +280,14 @@
}
public static class CarText.SpanWrapper {
- field @Keep public final int end;
- field @Keep public final int flags;
- field @Keep public final Object? span;
- field @Keep public final int start;
+ method public androidx.car.app.model.CarSpan getCarSpan();
+ method public int getEnd();
+ method public int getFlags();
+ method public int getStart();
+ field @Deprecated @Keep public final int end;
+ field @Deprecated @Keep public final int flags;
+ field @Deprecated @Keep public final Object! span;
+ field @Deprecated @Keep public final int start;
}
public class DateTimeWithZone {
@@ -304,23 +312,20 @@
field public static final int UNIT_YARDS = 7; // 0x7
}
- public class DistanceSpan extends android.text.style.CharacterStyle {
+ public class DistanceSpan extends androidx.car.app.model.CarSpan {
method public static androidx.car.app.model.DistanceSpan create(androidx.car.app.model.Distance);
method public androidx.car.app.model.Distance getDistance();
- method public void updateDrawState(android.text.TextPaint?);
}
- public class DurationSpan extends android.text.style.CharacterStyle {
+ public class DurationSpan extends androidx.car.app.model.CarSpan {
method public static androidx.car.app.model.DurationSpan create(long);
method @RequiresApi(26) public static androidx.car.app.model.DurationSpan create(java.time.Duration);
method public long getDurationSeconds();
- method public void updateDrawState(android.text.TextPaint?);
}
- public class ForegroundCarColorSpan extends android.text.style.CharacterStyle {
+ public class ForegroundCarColorSpan extends androidx.car.app.model.CarSpan {
method public static androidx.car.app.model.ForegroundCarColorSpan create(androidx.car.app.model.CarColor);
method public androidx.car.app.model.CarColor getColor();
- method public void updateDrawState(android.text.TextPaint);
}
public class GridItem implements androidx.car.app.model.Item {
@@ -428,7 +433,8 @@
public final class MessageTemplate implements androidx.car.app.model.Template {
method public static androidx.car.app.model.MessageTemplate.Builder builder(CharSequence);
- method public androidx.car.app.model.ActionList? getActions();
+ method public java.util.List<androidx.car.app.model.Action!> getActionList();
+ method @Deprecated public androidx.car.app.model.ActionList? getActions();
method public androidx.car.app.model.CarText? getDebugMessage();
method public androidx.car.app.model.Action? getHeaderAction();
method public androidx.car.app.model.CarIcon? getIcon();
@@ -439,7 +445,8 @@
public static final class MessageTemplate.Builder {
ctor public MessageTemplate.Builder(CharSequence);
method public androidx.car.app.model.MessageTemplate build();
- method public androidx.car.app.model.MessageTemplate.Builder setActions(java.util.List<androidx.car.app.model.Action!>);
+ method public androidx.car.app.model.MessageTemplate.Builder setActionList(java.util.List<androidx.car.app.model.Action!>);
+ method @Deprecated public androidx.car.app.model.MessageTemplate.Builder setActions(java.util.List<androidx.car.app.model.Action!>);
method public androidx.car.app.model.MessageTemplate.Builder setDebugCause(Throwable?);
method public androidx.car.app.model.MessageTemplate.Builder setDebugMessage(String?);
method public androidx.car.app.model.MessageTemplate.Builder setHeaderAction(androidx.car.app.model.Action?);
@@ -485,7 +492,8 @@
public final class Pane {
method public static androidx.car.app.model.Pane.Builder builder();
- method public androidx.car.app.model.ActionList? getActions();
+ method public java.util.List<androidx.car.app.model.Action!> getActionList();
+ method @Deprecated public androidx.car.app.model.ActionList? getActions();
method public java.util.List<java.lang.Object!> getRows();
method public boolean isLoading();
}
@@ -494,7 +502,8 @@
ctor public Pane.Builder();
method public androidx.car.app.model.Pane.Builder addRow(androidx.car.app.model.Row);
method public androidx.car.app.model.Pane build();
- method public androidx.car.app.model.Pane.Builder setActions(java.util.List<androidx.car.app.model.Action!>);
+ method public androidx.car.app.model.Pane.Builder setActionList(java.util.List<androidx.car.app.model.Action!>);
+ method @Deprecated public androidx.car.app.model.Pane.Builder setActions(java.util.List<androidx.car.app.model.Action!>);
method public androidx.car.app.model.Pane.Builder setLoading(boolean);
}
@@ -648,7 +657,6 @@
}
public interface Template {
- method public default void checkPermissions(android.content.Context);
}
public final class TemplateInfo {
@@ -971,10 +979,12 @@
public static final class Trip.Builder {
ctor public Trip.Builder();
- method public androidx.car.app.navigation.model.Trip.Builder addDestination(androidx.car.app.navigation.model.Destination);
- method public androidx.car.app.navigation.model.Trip.Builder addDestinationTravelEstimate(androidx.car.app.navigation.model.TravelEstimate);
- method public androidx.car.app.navigation.model.Trip.Builder addStep(androidx.car.app.navigation.model.Step?);
- method public androidx.car.app.navigation.model.Trip.Builder addStepTravelEstimate(androidx.car.app.navigation.model.TravelEstimate);
+ method public androidx.car.app.navigation.model.Trip.Builder addDestination(androidx.car.app.navigation.model.Destination, androidx.car.app.navigation.model.TravelEstimate);
+ method @Deprecated public androidx.car.app.navigation.model.Trip.Builder addDestination(androidx.car.app.navigation.model.Destination);
+ method @Deprecated public androidx.car.app.navigation.model.Trip.Builder addDestinationTravelEstimate(androidx.car.app.navigation.model.TravelEstimate);
+ method public androidx.car.app.navigation.model.Trip.Builder addStep(androidx.car.app.navigation.model.Step?, androidx.car.app.navigation.model.TravelEstimate);
+ method @Deprecated public androidx.car.app.navigation.model.Trip.Builder addStep(androidx.car.app.navigation.model.Step?);
+ method @Deprecated public androidx.car.app.navigation.model.Trip.Builder addStepTravelEstimate(androidx.car.app.navigation.model.TravelEstimate);
method public androidx.car.app.navigation.model.Trip build();
method public androidx.car.app.navigation.model.Trip.Builder clearDestinationTravelEstimates();
method public androidx.car.app.navigation.model.Trip.Builder clearDestinations();
diff --git a/car/app/app/src/main/java/androidx/car/app/model/CarIconSpan.java b/car/app/app/src/main/java/androidx/car/app/model/CarIconSpan.java
index 2fb1bf1..96ee074 100644
--- a/car/app/app/src/main/java/androidx/car/app/model/CarIconSpan.java
+++ b/car/app/app/src/main/java/androidx/car/app/model/CarIconSpan.java
@@ -20,9 +20,6 @@
import static java.util.Objects.requireNonNull;
-import android.text.TextPaint;
-import android.text.style.CharacterStyle;
-
import androidx.annotation.IntDef;
import androidx.annotation.Keep;
import androidx.annotation.NonNull;
@@ -61,7 +58,7 @@
*
* @see CarIcon
*/
-public class CarIconSpan extends CharacterStyle {
+public class CarIconSpan extends CarSpan {
/**
* Indicates how to align a car icon span with its surrounding text.
*
@@ -165,11 +162,6 @@
}
@Override
- public void updateDrawState(@Nullable TextPaint paint) {
- // Not relevant.
- }
-
- @Override
@NonNull
public String toString() {
return "[icon: " + mIcon + ", alignment: " + alignmentToString(mAlignment) + "]";
diff --git a/car/app/app/src/main/java/androidx/car/app/model/CarSpan.java b/car/app/app/src/main/java/androidx/car/app/model/CarSpan.java
new file mode 100644
index 0000000..c4d46498
--- /dev/null
+++ b/car/app/app/src/main/java/androidx/car/app/model/CarSpan.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2021 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.car.app.model;
+
+import android.text.TextPaint;
+import android.text.style.CharacterStyle;
+
+import androidx.annotation.Keep;
+import androidx.annotation.NonNull;
+
+/** Base class for all span types allowed for a car app. */
+@Keep
+public class CarSpan extends CharacterStyle {
+ @Override
+ public void updateDrawState(@NonNull TextPaint tp) {
+ // Do nothing
+ }
+}
diff --git a/car/app/app/src/main/java/androidx/car/app/model/CarText.java b/car/app/app/src/main/java/androidx/car/app/model/CarText.java
index 60dac52..a924c82 100644
--- a/car/app/app/src/main/java/androidx/car/app/model/CarText.java
+++ b/car/app/app/src/main/java/androidx/car/app/model/CarText.java
@@ -46,9 +46,10 @@
}
/**
- * Returns a {@link CarText} instance for the given {@link CharSequence}, by sanitizing the car
- * sequence (dropping unsupported {@link Spanned} objects, and wrapping the remaining supported
- * {@link Spanned} objects into data that can be sent across to the host in a bundle.
+ * Returns a {@link CarText} instance for the given {@link CharSequence}.
+ *
+ * <p>Only {@link CarSpan} type spans are allowed in a {@link CarText}, other spans will be
+ * removed from the provided {@link CharSequence}.
*/
@NonNull
public static CarText create(@NonNull CharSequence text) {
@@ -90,7 +91,7 @@
}
private CarText(CharSequence text) {
- this.mText = text.toString().trim();
+ this.mText = text.toString();
mSpans = new ArrayList<>();
@@ -98,11 +99,8 @@
Spanned spanned = (Spanned) text;
for (Object span : spanned.getSpans(0, text.length(), Object.class)) {
- if (span instanceof ForegroundCarColorSpan
- || span instanceof CarIconSpan
- || span instanceof DurationSpan
- || span instanceof DistanceSpan) {
- mSpans.add(SpanWrapper.wrap(spanned, span));
+ if (span instanceof CarSpan) {
+ mSpans.add(new SpanWrapper(spanned, (CarSpan) span));
}
}
}
@@ -129,32 +127,72 @@
* Wraps a span to send it to the host.
*/
public static class SpanWrapper {
- @Keep
+ /**
+ * @deprecated Removing in a follow up commit.
+ */
+ @Keep @Deprecated
public final int start;
- @Keep
+ /**
+ * @deprecated Removing in a follow up commit.
+ */
+ @Keep @Deprecated
public final int end;
- @Keep
+ /**
+ * @deprecated Removing in a follow up commit.
+ */
+ @Keep @Deprecated
public final int flags;
- @Keep
- @Nullable
+ /**
+ * @deprecated Removing in a follow up commit.
+ */
+ @Keep @Deprecated
public final Object span;
+ @Keep
+ private final int mStart;
+ @Keep
+ private final int mEnd;
+ @Keep
+ private final int mFlags;
+ @Keep @NonNull
+ private final CarSpan mCarSpan;
- static SpanWrapper wrap(Spanned spanned, Object span) {
- return new SpanWrapper(spanned, span);
- }
-
- SpanWrapper(Spanned spanned, Object span) {
- this.start = spanned.getSpanStart(span);
- this.end = spanned.getSpanEnd(span);
- this.flags = spanned.getSpanFlags(span);
- this.span = span;
+ SpanWrapper(@NonNull Spanned spanned, @NonNull CarSpan carSpan) {
+ mStart = spanned.getSpanStart(carSpan);
+ mEnd = spanned.getSpanEnd(carSpan);
+ mFlags = spanned.getSpanFlags(carSpan);
+ mCarSpan = carSpan;
+ this.start = mStart;
+ this.end = mEnd;
+ this.flags = mFlags;
+ this.span = mCarSpan;
}
SpanWrapper() {
- start = 0;
- end = 0;
- flags = 0;
- span = null;
+ mStart = 0;
+ mEnd = 0;
+ mFlags = 0;
+ mCarSpan = new CarSpan();
+ this.start = mStart;
+ this.end = mEnd;
+ this.flags = mFlags;
+ this.span = mCarSpan;
+ }
+
+ public int getStart() {
+ return mStart;
+ }
+
+ public int getEnd() {
+ return mEnd;
+ }
+
+ public int getFlags() {
+ return mFlags;
+ }
+
+ @NonNull
+ public CarSpan getCarSpan() {
+ return mCarSpan;
}
@Override
@@ -177,6 +215,7 @@
return Objects.hash(start, end, flags, span);
}
+ @NonNull
@Override
public String toString() {
return "[" + span + ": " + start + ", " + end + ", flags: " + flags + "]";
diff --git a/car/app/app/src/main/java/androidx/car/app/model/DistanceSpan.java b/car/app/app/src/main/java/androidx/car/app/model/DistanceSpan.java
index 3ae6a5f..be73daf 100644
--- a/car/app/app/src/main/java/androidx/car/app/model/DistanceSpan.java
+++ b/car/app/app/src/main/java/androidx/car/app/model/DistanceSpan.java
@@ -18,9 +18,6 @@
import static java.util.Objects.requireNonNull;
-import android.text.TextPaint;
-import android.text.style.CharacterStyle;
-
import androidx.annotation.Keep;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@@ -60,7 +57,7 @@
* string.setSpan(ForegroundCarColorSpan.create(CarColor.BLUE), 0, 1, SPAN_EXCLUSIVE_EXCLUSIVE);
* }</pre>
*/
-public class DistanceSpan extends CharacterStyle {
+public class DistanceSpan extends CarSpan {
@Nullable
@Keep
private final Distance mDistance;
@@ -84,11 +81,7 @@
return requireNonNull(mDistance);
}
- @Override
- public void updateDrawState(@Nullable TextPaint paint) {
- // Not relevant.
- }
-
+ @NonNull
@Override
public String toString() {
return "[distance: " + mDistance + "]";
diff --git a/car/app/app/src/main/java/androidx/car/app/model/DurationSpan.java b/car/app/app/src/main/java/androidx/car/app/model/DurationSpan.java
index ac05662..d1b1765 100644
--- a/car/app/app/src/main/java/androidx/car/app/model/DurationSpan.java
+++ b/car/app/app/src/main/java/androidx/car/app/model/DurationSpan.java
@@ -19,8 +19,6 @@
import static java.util.Objects.requireNonNull;
import android.annotation.SuppressLint;
-import android.text.TextPaint;
-import android.text.style.CharacterStyle;
import androidx.annotation.Keep;
import androidx.annotation.NonNull;
@@ -54,7 +52,7 @@
* string.setSpan(ForegroundCarColorSpan.create(CarColor.BLUE), 0, 1, SPAN_EXCLUSIVE_EXCLUSIVE);
* }</pre>
*/
-public class DurationSpan extends CharacterStyle {
+public class DurationSpan extends CarSpan {
@Keep
private final long mDurationSeconds;
@@ -87,11 +85,6 @@
}
@Override
- public void updateDrawState(@Nullable TextPaint paint) {
- // Not relevant.
- }
-
- @Override
@NonNull
public String toString() {
return "[seconds: " + mDurationSeconds + "]";
diff --git a/car/app/app/src/main/java/androidx/car/app/model/ForegroundCarColorSpan.java b/car/app/app/src/main/java/androidx/car/app/model/ForegroundCarColorSpan.java
index 8691c2b..587fa6e 100644
--- a/car/app/app/src/main/java/androidx/car/app/model/ForegroundCarColorSpan.java
+++ b/car/app/app/src/main/java/androidx/car/app/model/ForegroundCarColorSpan.java
@@ -18,8 +18,6 @@
import static java.util.Objects.requireNonNull;
-import android.text.TextPaint;
-import android.text.style.CharacterStyle;
import android.text.style.ForegroundColorSpan;
import androidx.annotation.Keep;
@@ -48,7 +46,7 @@
* @see CarColor
* @see ForegroundColorSpan
*/
-public class ForegroundCarColorSpan extends CharacterStyle {
+public class ForegroundCarColorSpan extends CarSpan {
@Keep
private final CarColor mCarColor;
@@ -72,11 +70,6 @@
}
@Override
- public void updateDrawState(@NonNull TextPaint paint) {
- // Not relevant.
- }
-
- @Override
@NonNull
public String toString() {
return "[color: " + mCarColor + "]";
diff --git a/car/app/app/src/main/java/androidx/car/app/model/MessageTemplate.java b/car/app/app/src/main/java/androidx/car/app/model/MessageTemplate.java
index ff11c19..c899dd7 100644
--- a/car/app/app/src/main/java/androidx/car/app/model/MessageTemplate.java
+++ b/car/app/app/src/main/java/androidx/car/app/model/MessageTemplate.java
@@ -28,6 +28,7 @@
import androidx.annotation.Nullable;
import androidx.car.app.model.constraints.CarIconConstraints;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
@@ -58,8 +59,7 @@
@Nullable
private final Action mHeaderAction;
@Keep
- @Nullable
- private final ActionList mActionList;
+ private final List<Action> mActionList;
/** Constructs a new builder of {@link MessageTemplate}. */
// TODO(b/175827428): remove once host is changed to use new public ctor.
@@ -93,8 +93,18 @@
return mIcon;
}
+ /**
+ * @deprecated use {@link #getActionList()} instead.
+ */
+ // TODO(jayyoo): remove once {@link #getActionList()} is used in the host.
+ @Deprecated
@Nullable
public ActionList getActions() {
+ return mActionList.isEmpty() ? null : ActionList.create(mActionList);
+ }
+
+ @NonNull
+ public List<Action> getActionList() {
return mActionList;
}
@@ -133,7 +143,7 @@
mDebugMessage = builder.mDebugMessage;
mIcon = builder.mIcon;
mHeaderAction = builder.mHeaderAction;
- mActionList = builder.mActionList;
+ mActionList = new ArrayList<>(builder.mActionList);
}
/** Constructs an empty instance, used by serialization code. */
@@ -143,7 +153,7 @@
mDebugMessage = null;
mIcon = null;
mHeaderAction = null;
- mActionList = null;
+ mActionList = Collections.emptyList();
}
/** A builder of {@link MessageTemplate}. */
@@ -157,8 +167,7 @@
CarIcon mIcon;
@Nullable
Action mHeaderAction;
- @Nullable
- ActionList mActionList;
+ List<Action> mActionList = new ArrayList<>();
@Nullable
Throwable mDebugCause;
@Nullable
@@ -272,10 +281,32 @@
* <p>Any actions above the maximum limit of 2 will be ignored.
*
* @throws NullPointerException if {@code actions} is {@code null}.
+ * @deprecated use {@link #setActionList(List)} instead.
*/
+ // TODO(jayyoo): remove once {@link #setActionList(List)} is used in the host.
+ @Deprecated
@NonNull
public Builder setActions(@NonNull List<Action> actions) {
- mActionList = ActionList.create(requireNonNull(actions));
+ return setActionList(actions);
+ }
+
+ /**
+ * Sets a list of {@link Action}s to display along with the message.
+ *
+ * <p>Any actions above the maximum limit of 2 will be ignored.
+ *
+ * @throws NullPointerException if {@code actions} is {@code null}.
+ */
+ @NonNull
+ public Builder setActionList(@NonNull List<Action> actions) {
+ requireNonNull(actions);
+ for (Action action : actions) {
+ if (action == null) {
+ throw new IllegalArgumentException(
+ "Disallowed null action found in action list");
+ }
+ mActionList.add(action);
+ }
return this;
}
diff --git a/car/app/app/src/main/java/androidx/car/app/model/ModelUtils.java b/car/app/app/src/main/java/androidx/car/app/model/ModelUtils.java
index 240e097..0a5e10c 100644
--- a/car/app/app/src/main/java/androidx/car/app/model/ModelUtils.java
+++ b/car/app/app/src/main/java/androidx/car/app/model/ModelUtils.java
@@ -152,11 +152,10 @@
List<SpanWrapper> spans = carText.getSpans();
for (int i = 0; i < spans.size(); i++) {
SpanWrapper wrapper = spans.get(i);
- Object spanObj = wrapper.span;
- if (spanType.isInstance(spanObj)
- && wrapper.start >= 0
- && wrapper.start != wrapper.end
- && wrapper.start < text.length()) {
+ if (spanType.isInstance(wrapper.getCarSpan())
+ && wrapper.getStart() >= 0
+ && wrapper.getStart() != wrapper.getEnd()
+ && wrapper.getStart() < text.length()) {
return true;
}
}
diff --git a/car/app/app/src/main/java/androidx/car/app/model/Pane.java b/car/app/app/src/main/java/androidx/car/app/model/Pane.java
index f211121..4d68b35 100644
--- a/car/app/app/src/main/java/androidx/car/app/model/Pane.java
+++ b/car/app/app/src/main/java/androidx/car/app/model/Pane.java
@@ -33,8 +33,7 @@
*/
public final class Pane {
@Keep
- @Nullable
- private final ActionList mActionList;
+ private final List<Action> mActionList;
@Keep
private final List<Object> mRows;
@Keep
@@ -49,9 +48,21 @@
/**
* Returns the list of {@link Action}s displayed alongside the {@link Row}s in this pane.
+ *
+ * @deprecated use {@link #getActionList()} instead.
*/
+ // TODO(jayyoo): remove once {@link #getActionList()} is used in the host.
+ @Deprecated
@Nullable
public ActionList getActions() {
+ return mActionList.isEmpty() ? null : ActionList.create(mActionList);
+ }
+
+ /**
+ * Returns the list of {@link Action}s displayed alongside the {@link Row}s in this pane.
+ */
+ @NonNull
+ public List<Action> getActionList() {
return mActionList;
}
@@ -102,22 +113,21 @@
Pane(Builder builder) {
mRows = new ArrayList<>(builder.mRows);
- mActionList = builder.mActionList;
+ mActionList = new ArrayList<>(builder.mActionList);
mIsLoading = builder.mIsLoading;
}
/** Constructs an empty instance, used by serialization code. */
private Pane() {
mRows = Collections.emptyList();
- mActionList = null;
+ mActionList = Collections.emptyList();
mIsLoading = false;
}
/** A builder of {@link Pane}. */
public static final class Builder {
final List<Object> mRows = new ArrayList<>();
- @Nullable
- ActionList mActionList;
+ List<Action> mActionList = new ArrayList<>();
boolean mIsLoading;
/**
@@ -154,10 +164,32 @@
* <p>By default, no actions are displayed.
*
* @throws NullPointerException if {@code actions} is {@code null}.
+ * @deprecated use {@link #setActionList(List)} instead.
*/
+ // TODO(jayyoo): remove once {@link #setActionList(List)} is used in the host.
+ @Deprecated
@NonNull
public Builder setActions(@NonNull List<Action> actions) {
- mActionList = ActionList.create(requireNonNull(actions));
+ return setActionList(actions);
+ }
+
+ /**
+ * Sets multiple {@link Action}s to display alongside the rows in the pane.
+ *
+ * <p>By default, no actions are displayed.
+ *
+ * @throws NullPointerException if {@code actions} is {@code null}.
+ */
+ @NonNull
+ public Builder setActionList(@NonNull List<Action> actions) {
+ requireNonNull(actions);
+ for (Action action : actions) {
+ if (action == null) {
+ throw new IllegalArgumentException(
+ "Disallowed null action found in action list");
+ }
+ mActionList.add(action);
+ }
return this;
}
diff --git a/car/app/app/src/main/java/androidx/car/app/model/PlaceListMapTemplate.java b/car/app/app/src/main/java/androidx/car/app/model/PlaceListMapTemplate.java
index 5fe1060..460103b 100644
--- a/car/app/app/src/main/java/androidx/car/app/model/PlaceListMapTemplate.java
+++ b/car/app/app/src/main/java/androidx/car/app/model/PlaceListMapTemplate.java
@@ -20,13 +20,9 @@
import static androidx.car.app.model.constraints.ActionsConstraints.ACTIONS_CONSTRAINTS_SIMPLE;
import static androidx.car.app.model.constraints.RowListConstraints.ROW_LIST_CONSTRAINTS_SIMPLE;
-import android.Manifest.permission;
-import android.content.Context;
-
import androidx.annotation.Keep;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
-import androidx.car.app.CarAppPermission;
import java.util.Collections;
import java.util.List;
@@ -112,13 +108,6 @@
return mAnchor;
}
- @Override
- public void checkPermissions(@NonNull Context context) {
- if (isCurrentLocationEnabled()) {
- CarAppPermission.checkHasPermission(context, permission.ACCESS_FINE_LOCATION);
- }
- }
-
@NonNull
@Override
public String toString() {
diff --git a/car/app/app/src/main/java/androidx/car/app/model/Template.java b/car/app/app/src/main/java/androidx/car/app/model/Template.java
index 20a8881..6f8a861 100644
--- a/car/app/app/src/main/java/androidx/car/app/model/Template.java
+++ b/car/app/app/src/main/java/androidx/car/app/model/Template.java
@@ -16,17 +16,6 @@
package androidx.car.app.model;
-import android.content.Context;
-
-import androidx.annotation.NonNull;
-
/** An interface used to denote a model that can act as a root for a tree of other models. */
public interface Template {
- /**
- * Checks that the application has the required permissions for this template.
- *
- * @throws SecurityException if the application is missing any required permission.
- */
- default void checkPermissions(@NonNull Context context) {
- }
}
diff --git a/car/app/app/src/main/java/androidx/car/app/model/constraints/RowListConstraints.java b/car/app/app/src/main/java/androidx/car/app/model/constraints/RowListConstraints.java
index 932cc4b..d0b1464 100644
--- a/car/app/app/src/main/java/androidx/car/app/model/constraints/RowListConstraints.java
+++ b/car/app/app/src/main/java/androidx/car/app/model/constraints/RowListConstraints.java
@@ -23,7 +23,7 @@
import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
-import androidx.car.app.model.ActionList;
+import androidx.car.app.model.Action;
import androidx.car.app.model.ItemList;
import androidx.car.app.model.Pane;
import androidx.car.app.model.SectionedItemList;
@@ -157,8 +157,8 @@
* @throws IllegalArgumentException if the constraints are not met.
*/
public void validateOrThrow(@NonNull Pane pane) {
- ActionList actions = pane.getActions();
- if (actions != null && actions.getList().size() > mMaxActions) {
+ List<Action> actions = pane.getActionList();
+ if (actions != null && actions.size() > mMaxActions) {
throw new IllegalArgumentException(
"The number of actions on the pane exceeded the supported max of "
+ mMaxActions);
diff --git a/car/app/app/src/main/java/androidx/car/app/navigation/model/NavigationTemplate.java b/car/app/app/src/main/java/androidx/car/app/navigation/model/NavigationTemplate.java
index 6e3e587..1204e73 100644
--- a/car/app/app/src/main/java/androidx/car/app/navigation/model/NavigationTemplate.java
+++ b/car/app/app/src/main/java/androidx/car/app/navigation/model/NavigationTemplate.java
@@ -21,12 +21,9 @@
import static java.util.Objects.requireNonNull;
-import android.content.Context;
-
import androidx.annotation.Keep;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
-import androidx.car.app.CarAppPermission;
import androidx.car.app.Screen;
import androidx.car.app.SurfaceCallback;
import androidx.car.app.model.Action;
@@ -162,11 +159,6 @@
&& Objects.equals(mActionStrip, otherTemplate.mActionStrip);
}
- @Override
- public void checkPermissions(@NonNull Context context) {
- CarAppPermission.checkHasLibraryPermission(context, CarAppPermission.NAVIGATION_TEMPLATES);
- }
-
NavigationTemplate(Builder builder) {
mNavigationInfo = builder.mNavigationInfo;
mBackgroundColor = builder.mBackgroundColor;
diff --git a/car/app/app/src/main/java/androidx/car/app/navigation/model/PlaceListNavigationTemplate.java b/car/app/app/src/main/java/androidx/car/app/navigation/model/PlaceListNavigationTemplate.java
index cf9f9a7..56325a4 100644
--- a/car/app/app/src/main/java/androidx/car/app/navigation/model/PlaceListNavigationTemplate.java
+++ b/car/app/app/src/main/java/androidx/car/app/navigation/model/PlaceListNavigationTemplate.java
@@ -20,12 +20,9 @@
import static androidx.car.app.model.constraints.ActionsConstraints.ACTIONS_CONSTRAINTS_SIMPLE;
import static androidx.car.app.model.constraints.RowListConstraints.ROW_LIST_CONSTRAINTS_SIMPLE;
-import android.content.Context;
-
import androidx.annotation.Keep;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
-import androidx.car.app.CarAppPermission;
import androidx.car.app.Screen;
import androidx.car.app.SurfaceCallback;
import androidx.car.app.model.Action;
@@ -112,11 +109,6 @@
return mActionStrip;
}
- @Override
- public void checkPermissions(@NonNull Context context) {
- CarAppPermission.checkHasLibraryPermission(context, CarAppPermission.NAVIGATION_TEMPLATES);
- }
-
@NonNull
@Override
public String toString() {
diff --git a/car/app/app/src/main/java/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.java b/car/app/app/src/main/java/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.java
index 3540038..62e1af1 100644
--- a/car/app/app/src/main/java/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.java
+++ b/car/app/app/src/main/java/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.java
@@ -22,12 +22,9 @@
import static java.util.Objects.requireNonNull;
-import android.content.Context;
-
import androidx.annotation.Keep;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
-import androidx.car.app.CarAppPermission;
import androidx.car.app.Screen;
import androidx.car.app.SurfaceCallback;
import androidx.car.app.model.Action;
@@ -133,11 +130,6 @@
return mActionStrip;
}
- @Override
- public void checkPermissions(@NonNull Context context) {
- CarAppPermission.checkHasLibraryPermission(context, CarAppPermission.NAVIGATION_TEMPLATES);
- }
-
@NonNull
@Override
public String toString() {
diff --git a/car/app/app/src/main/java/androidx/car/app/navigation/model/Trip.java b/car/app/app/src/main/java/androidx/car/app/navigation/model/Trip.java
index be3069f..90d46c1 100644
--- a/car/app/app/src/main/java/androidx/car/app/navigation/model/Trip.java
+++ b/car/app/app/src/main/java/androidx/car/app/navigation/model/Trip.java
@@ -165,10 +165,33 @@
* surfaces may or may not use the destination and if multiple destinations are added the
* display may only show information about the first destination.
*
+ * <p>For every destination added, a corresponding {@link TravelEstimate} must be
+ * provided. Display surfaces may or may not use the destination travel estimate and if
+ * multiple destination travel estimates are added the display may only show information
+ * about the first destination travel estimate.
+ */
+ @NonNull
+ public Builder addDestination(@NonNull Destination destination,
+ @NonNull TravelEstimate destinationTravelEstimate) {
+ mDestinations.add(requireNonNull(destination));
+ mDestinationTravelEstimates.add(requireNonNull(destinationTravelEstimate));
+ return this;
+ }
+
+ /**
+ * Adds a destination to the trip.
+ *
+ * <p>Destinations must be added in order of arrival. A destination is not required. Display
+ * surfaces may or may not use the destination and if multiple destinations are added the
+ * display may only show information about the first destination.
+ *
* <p>For every destination added, a corresponding {@link TravelEstimate} must be added via
* {@link #addDestinationTravelEstimate}.They are added separately so that travel
* estimates can be updated frequently based on location.
+ *
+ * @deprecated Use {@link #addDestination(Destination, TravelEstimate)}.
*/
+ @Deprecated
@NonNull
public Builder addDestination(@NonNull Destination destination) {
mDestinations.add(requireNonNull(destination));
@@ -189,10 +212,32 @@
* may or may not use the step and if multiple steps are added the display may only show
* information about the first step.
*
+ * <p>For every step added, a corresponding {@link TravelEstimate} must be provided.
+ * Display surfaces may or may not use the step travel estimate and if multiple
+ * step travel estimates are added the display may only show information about the first
+ * step travel estimate.
+ */
+ @NonNull
+ public Builder addStep(@Nullable Step step, @NonNull TravelEstimate stepTravelEstimate) {
+ mSteps.add(requireNonNull(step));
+ mStepTravelEstimates.add(requireNonNull(stepTravelEstimate));
+ return this;
+ }
+
+ /**
+ * Adds a step to the trip.
+ *
+ * <p>Steps must be added in order of arrival. A step is not required. Display surfaces
+ * may or may not use the step and if multiple steps are added the display may only show
+ * information about the first step.
+ *
* <p>For every step added, a corresponding {@link TravelEstimate} must be added via {@link
* #addStepTravelEstimate}. They are added separately so that travel estimates can be
* updated frequently based on location.
+ *
+ * @deprecated Use {@link #addStep(Step, TravelEstimate)}.
*/
+ @Deprecated
@NonNull
public Builder addStep(@Nullable Step step) {
mSteps.add(requireNonNull(step));
@@ -217,7 +262,10 @@
* <p>For every destination travel estimate added, a corresponding destination must also be
* added. They are added separately so that travel estimates can be updated frequently
* based on location.
+ *
+ * @deprecated User {@link #addDestination(Destination, TravelEstimate)}.
*/
+ @Deprecated
@NonNull
public Builder addDestinationTravelEstimate(
@NonNull TravelEstimate destinationTravelEstimate) {
@@ -241,7 +289,10 @@
* step travel estimate.
*
* <p>For every step travel estimate added, a corresponding step must also be added.
+ *
+ * @deprecated Use {@link #addStep(Step, TravelEstimate)}.
*/
+ @Deprecated
@NonNull
public Builder addStepTravelEstimate(@NonNull TravelEstimate stepTravelEstimate) {
mStepTravelEstimates.add(requireNonNull(stepTravelEstimate));
diff --git a/car/app/app/src/test/java/androidx/car/app/TestUtils.java b/car/app/app/src/test/java/androidx/car/app/TestUtils.java
index a0c2418..d64e13e 100644
--- a/car/app/app/src/test/java/androidx/car/app/TestUtils.java
+++ b/car/app/app/src/test/java/androidx/car/app/TestUtils.java
@@ -20,18 +20,11 @@
import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
import android.content.Context;
-import android.content.pm.PackageManager;
import android.graphics.drawable.Drawable;
import android.text.SpannableString;
import androidx.annotation.DrawableRes;
-import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.car.app.model.Action;
@@ -148,7 +141,7 @@
for (int i = 0; i < actionCount; i++) {
actions.add(createAction("action " + i, null));
}
- builder.setActions(actions);
+ builder.setActionList(actions);
return builder.build();
}
@@ -188,13 +181,4 @@
assertThat(dateTimeWithZone.getTimeSinceEpochMillis())
.isEqualTo(dateTimeWithZone.getTimeSinceEpochMillis());
}
-
- public static Context getMockContextWithPermission(@NonNull String permission) {
- Context mockContext = mock(Context.class);
- PackageManager packageManager = mock(PackageManager.class);
- when(mockContext.getPackageManager()).thenReturn(packageManager);
- when(packageManager.checkPermission(eq(permission), any())).thenReturn(
- PackageManager.PERMISSION_GRANTED);
- return mockContext;
- }
}
diff --git a/car/app/app/src/test/java/androidx/car/app/model/MessageTemplateTest.java b/car/app/app/src/test/java/androidx/car/app/model/MessageTemplateTest.java
index 0a90e2c..9909aec 100644
--- a/car/app/app/src/test/java/androidx/car/app/model/MessageTemplateTest.java
+++ b/car/app/app/src/test/java/androidx/car/app/model/MessageTemplateTest.java
@@ -83,7 +83,7 @@
assertThat(template.getTitle().getText()).isEqualTo("header");
assertThat(template.getIcon()).isNull();
assertThat(template.getHeaderAction()).isNull();
- assertThat(template.getActions()).isNull();
+ assertThat(template.getActionList()).isEmpty();
assertThat(template.getDebugMessage()).isNull();
}
@@ -113,16 +113,16 @@
.setHeaderAction(Action.BACK)
.setDebugCause(exception)
.setIcon(icon)
- .setActions(ImmutableList.of(action))
+ .setActionList(ImmutableList.of(action))
.build();
assertThat(template.getMessage().toString()).isEqualTo(mMessage);
assertThat(template.getTitle().toString()).isEqualTo(mTitle);
assertThat(template.getDebugMessage().toString()).isEqualTo(
- Log.getStackTraceString(exception).trim());
+ Log.getStackTraceString(exception));
assertThat(template.getIcon()).isEqualTo(icon);
assertThat(template.getHeaderAction()).isEqualTo(Action.BACK);
- assertThat(template.getActions().getList()).containsExactly(action);
+ assertThat(template.getActionList()).containsExactly(action);
}
@Test
@@ -133,7 +133,7 @@
.setDebugMessage(mDebugMessage)
.setDebugCause(mCause)
.setHeaderAction(Action.BACK)
- .setActions(ImmutableList.of(mAction))
+ .setActionList(ImmutableList.of(mAction))
.setIcon(mIcon)
.build();
MessageTemplate template2 =
@@ -142,7 +142,7 @@
.setDebugMessage(mDebugMessage)
.setDebugCause(mCause)
.setHeaderAction(Action.BACK)
- .setActions(ImmutableList.of(mAction))
+ .setActionList(ImmutableList.of(mAction))
.setIcon(mIcon)
.build();
@@ -156,7 +156,7 @@
.setTitle(mTitle)
.setDebugMessage(mDebugMessage)
.setDebugCause(mCause)
- .setActions(ImmutableList.of(mAction))
+ .setActionList(ImmutableList.of(mAction))
.setIcon(mIcon)
.build();
MessageTemplate template2 =
@@ -164,7 +164,7 @@
.setTitle(mTitle)
.setDebugMessage("yo")
.setDebugCause(mCause)
- .setActions(ImmutableList.of(mAction))
+ .setActionList(ImmutableList.of(mAction))
.setIcon(mIcon)
.build();
@@ -178,7 +178,7 @@
.setTitle(mTitle)
.setDebugMessage(mDebugMessage)
.setDebugCause(mCause)
- .setActions(ImmutableList.of(mAction))
+ .setActionList(ImmutableList.of(mAction))
.setIcon(mIcon)
.build();
MessageTemplate template2 =
@@ -186,7 +186,7 @@
.setTitle(mTitle)
.setDebugMessage(mDebugMessage)
.setDebugCause(new IllegalStateException("something else bad"))
- .setActions(ImmutableList.of(mAction))
+ .setActionList(ImmutableList.of(mAction))
.setIcon(mIcon)
.build();
@@ -201,7 +201,7 @@
.setDebugMessage(mDebugMessage)
.setDebugCause(mCause)
.setMessage(mMessage)
- .setActions(ImmutableList.of(mAction))
+ .setActionList(ImmutableList.of(mAction))
.setIcon(mIcon)
.build();
MessageTemplate template2 =
@@ -209,7 +209,7 @@
.setTitle(mTitle)
.setDebugMessage(mDebugMessage)
.setDebugCause(mCause)
- .setActions(ImmutableList.of(mAction))
+ .setActionList(ImmutableList.of(mAction))
.setIcon(mIcon)
.build();
@@ -224,7 +224,7 @@
.setDebugMessage(mDebugMessage)
.setDebugCause(mCause)
.setHeaderAction(Action.BACK)
- .setActions(ImmutableList.of(mAction))
+ .setActionList(ImmutableList.of(mAction))
.setIcon(mIcon)
.build();
MessageTemplate template2 =
@@ -233,7 +233,7 @@
.setDebugMessage(mDebugMessage)
.setDebugCause(mCause)
.setHeaderAction(Action.APP_ICON)
- .setActions(ImmutableList.of(mAction))
+ .setActionList(ImmutableList.of(mAction))
.setIcon(mIcon)
.build();
@@ -247,7 +247,7 @@
.setTitle(mTitle)
.setDebugMessage(mDebugMessage)
.setDebugCause(mCause)
- .setActions(ImmutableList.of(mAction))
+ .setActionList(ImmutableList.of(mAction))
.setIcon(mIcon)
.build();
MessageTemplate template2 =
@@ -255,7 +255,7 @@
.setTitle(mTitle)
.setDebugMessage(mDebugMessage)
.setDebugCause(mCause)
- .setActions(ImmutableList.of(mAction, mAction))
+ .setActionList(ImmutableList.of(mAction, mAction))
.setIcon(mIcon)
.build();
@@ -269,7 +269,7 @@
.setTitle(mTitle)
.setDebugMessage(mDebugMessage)
.setDebugCause(mCause)
- .setActions(ImmutableList.of(mAction))
+ .setActionList(ImmutableList.of(mAction))
.setIcon(mIcon)
.build();
MessageTemplate template2 =
@@ -277,7 +277,7 @@
.setTitle(mTitle)
.setDebugMessage(mDebugMessage)
.setDebugCause(mCause)
- .setActions(ImmutableList.of(mAction))
+ .setActionList(ImmutableList.of(mAction))
.setIcon(CarIcon.ERROR)
.build();
@@ -291,7 +291,7 @@
.setTitle(mTitle)
.setDebugMessage(mDebugMessage)
.setDebugCause(mCause)
- .setActions(ImmutableList.of(mAction))
+ .setActionList(ImmutableList.of(mAction))
.setIcon(mIcon)
.build();
MessageTemplate template2 =
@@ -299,7 +299,7 @@
.setTitle("Header2")
.setDebugMessage(mDebugMessage)
.setDebugCause(mCause)
- .setActions(ImmutableList.of(mAction))
+ .setActionList(ImmutableList.of(mAction))
.setIcon(mIcon)
.build();
diff --git a/car/app/app/src/test/java/androidx/car/app/model/PaneTest.java b/car/app/app/src/test/java/androidx/car/app/model/PaneTest.java
index a6228fc..f7a91ae 100644
--- a/car/app/app/src/test/java/androidx/car/app/model/PaneTest.java
+++ b/car/app/app/src/test/java/androidx/car/app/model/PaneTest.java
@@ -70,14 +70,15 @@
}
@Test
- public void setActions() {
+ public void setActionList() {
Action action1 = createAction(1);
Action action2 = createAction(2);
List<Action> actions = Arrays.asList(action1, action2);
Pane pane =
- new Pane.Builder().addRow(new Row.Builder().setTitle("Title").build()).setActions(
+ new Pane.Builder().addRow(
+ new Row.Builder().setTitle("Title").build()).setActionList(
actions).build();
- assertActions(pane.getActions(), actions);
+ assertThat(pane.getActionList()).containsExactlyElementsIn(actions);
}
@Test
@@ -85,7 +86,7 @@
Action action1 = createAction(1);
assertThrows(
IllegalArgumentException.class,
- () -> new Pane.Builder().setActions(Arrays.asList(action1, null)).build());
+ () -> new Pane.Builder().setActionList(Arrays.asList(action1, null)).build());
}
@Test
@@ -93,7 +94,7 @@
Pane pane =
new Pane.Builder()
.setLoading(false)
- .setActions(ImmutableList.of(Action.APP_ICON, Action.BACK))
+ .setActionList(ImmutableList.of(Action.APP_ICON, Action.BACK))
.addRow(new Row.Builder().setTitle("Title").build())
.build();
@@ -101,7 +102,7 @@
.isEqualTo(
new Pane.Builder()
.setLoading(false)
- .setActions(ImmutableList.of(Action.APP_ICON, Action.BACK))
+ .setActionList(ImmutableList.of(Action.APP_ICON, Action.BACK))
.addRow(new Row.Builder().setTitle("Title").build())
.build());
}
@@ -121,12 +122,12 @@
Pane pane =
new Pane.Builder()
.addRow(row)
- .setActions(ImmutableList.of(Action.APP_ICON, Action.BACK))
+ .setActionList(ImmutableList.of(Action.APP_ICON, Action.BACK))
.build();
assertThat(pane)
.isNotEqualTo(
- new Pane.Builder().addRow(row).setActions(
+ new Pane.Builder().addRow(row).setActionList(
ImmutableList.of(Action.APP_ICON)).build());
}
@@ -152,9 +153,4 @@
return new Action.Builder().setTitle("Action " + suffix).setOnClickListener(() -> {
}).build();
}
-
- private static void assertActions(Object obj, List<Action> expectedActions) {
- ActionList actionList = (ActionList) obj;
- assertThat(actionList.getList()).containsExactlyElementsIn(expectedActions);
- }
}
diff --git a/car/app/app/src/test/java/androidx/car/app/model/PlaceListMapTemplateTest.java b/car/app/app/src/test/java/androidx/car/app/model/PlaceListMapTemplateTest.java
index d8e1bce..d936368 100644
--- a/car/app/app/src/test/java/androidx/car/app/model/PlaceListMapTemplateTest.java
+++ b/car/app/app/src/test/java/androidx/car/app/model/PlaceListMapTemplateTest.java
@@ -444,62 +444,4 @@
.setCurrentLocationEnabled(false)
.build());
}
-
-// TODO(shiufai): the following shadow is resulting in a ClasscastException.
-// Further investigation is needed.
-// @Test
-// public void checkPermissions_hasPermissions() {
-// PlaceListMapTemplate template =
-// new PlaceListMapTemplate.Builder()
-// .setTitle("Title")
-// .setItemList(
-// TestUtils.createItemListWithDistanceSpan(6, false, mDistanceSpan))
-// .setCurrentLocationEnabled(true)
-// .build();
-//
-// PackageManager packageManager = mContext.getPackageManager();
-// PackageInfo pi = new PackageInfo();
-// pi.packageName = mContext.getPackageName();
-// pi.versionCode = 1;
-// pi.requestedPermissions = new String[]{permission.ACCESS_FINE_LOCATION};
-//
-// shadowOf(packageManager).installPackage(pi);
-//
-// // Expect that it does not throw
-// template.checkPermissions(context);
-// }
-
-// TODO(shiufai): the following shadow is resulting in a ClasscastException.
-// Further investigation is needed.
-// @Test
-// public void checkPermissions_doesNotHaveFineLocationPermission() {
-// PlaceListMapTemplate template =
-// new PlaceListMapTemplate.Builder()
-// .setTitle("Title")
-// .setItemList(
-// TestUtils.createItemListWithDistanceSpan(6, false, mDistanceSpan))
-// .setCurrentLocationEnabled(true)
-// .build();
-//
-// PackageManager packageManager = mContext.getPackageManager();
-// PackageInfo pi = new PackageInfo();
-// pi.packageName = mContext.getPackageName();
-// pi.versionCode = 1;
-//
-// shadowOf(packageManager).installPackage(pi);
-// assertThrows(SecurityException.class, () -> template.checkPermissions(context));
-// }
-
- @Test
- public void checkPermissions_doesNotHavePermissions() {
- PlaceListMapTemplate template =
- new PlaceListMapTemplate.Builder()
- .setTitle("Title")
- .setItemList(
- TestUtils.createItemListWithDistanceSpan(6, false, mDistanceSpan))
- .setCurrentLocationEnabled(true)
- .build();
-
- assertThrows(SecurityException.class, () -> template.checkPermissions(mContext));
- }
}
diff --git a/car/app/app/src/test/java/androidx/car/app/navigation/NavigationManagerTest.java b/car/app/app/src/test/java/androidx/car/app/navigation/NavigationManagerTest.java
index c20fb92..fbcb1de 100644
--- a/car/app/app/src/test/java/androidx/car/app/navigation/NavigationManagerTest.java
+++ b/car/app/app/src/test/java/androidx/car/app/navigation/NavigationManagerTest.java
@@ -67,8 +67,8 @@
private NavigationManager mNavigationManager;
private final Destination mDestination =
- new Destination.Builder().setName("Home").setAddress("123 State Street").build();
- private final Step mStep = new Step.Builder("Straight Ahead").build();
+ Destination.builder().setName("Home").setAddress("123 State Street").build();
+ private final Step mStep = Step.builder("Straight Ahead").build();
private final TravelEstimate mStepTravelEstimate =
TravelEstimate.create(
Distance.create(/* displayDistance= */ 10, Distance.UNIT_KILOMETERS),
@@ -81,11 +81,9 @@
createDateTimeWithZone("2020-04-14T16:57:00", "US/Pacific"));
private static final String CURRENT_ROAD = "State St.";
private final Trip mTrip =
- new Trip.Builder()
- .addDestination(mDestination)
- .addStep(mStep)
- .addDestinationTravelEstimate(mDestinationTravelEstimate)
- .addStepTravelEstimate(mStepTravelEstimate)
+ Trip.builder()
+ .addDestination(mDestination, mDestinationTravelEstimate)
+ .addStep(mStep, mStepTravelEstimate)
.setCurrentRoad(CURRENT_ROAD)
.build();
@@ -212,4 +210,4 @@
}
}
-}
+}
\ No newline at end of file
diff --git a/car/app/app/src/test/java/androidx/car/app/navigation/model/NavigationTemplateTest.java b/car/app/app/src/test/java/androidx/car/app/navigation/model/NavigationTemplateTest.java
index 6b57e47..6b273ea 100644
--- a/car/app/app/src/test/java/androidx/car/app/navigation/model/NavigationTemplateTest.java
+++ b/car/app/app/src/test/java/androidx/car/app/navigation/model/NavigationTemplateTest.java
@@ -22,13 +22,11 @@
import static org.junit.Assert.assertThrows;
-import androidx.car.app.CarAppPermission;
import androidx.car.app.TestUtils;
import androidx.car.app.model.ActionStrip;
import androidx.car.app.model.CarColor;
import androidx.car.app.model.CarIcon;
import androidx.car.app.model.Distance;
-import androidx.test.core.app.ApplicationProvider;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -360,30 +358,4 @@
.setBackgroundColor(CarColor.GREEN)
.build());
}
-
- @Test
- public void checkPermissions_hasPermissions() {
- NavigationTemplate template =
- NavigationTemplate.builder()
- .setActionStrip(mActionStrip)
- .setBackgroundColor(CarColor.BLUE)
- .build();
-
- // Expect that it does not throw
- template.checkPermissions(
- TestUtils.getMockContextWithPermission(CarAppPermission.NAVIGATION_TEMPLATES));
- }
-
- @Test
- public void checkPermissions_doesNotHavePermissions() {
- NavigationTemplate template =
- NavigationTemplate.builder()
- .setActionStrip(mActionStrip)
- .setBackgroundColor(CarColor.BLUE)
- .build();
-
- assertThrows(
- SecurityException.class,
- () -> template.checkPermissions(ApplicationProvider.getApplicationContext()));
- }
}
diff --git a/car/app/app/src/test/java/androidx/car/app/navigation/model/PlaceListNavigationTemplateTest.java b/car/app/app/src/test/java/androidx/car/app/navigation/model/PlaceListNavigationTemplateTest.java
index eb09a46..612c13b 100644
--- a/car/app/app/src/test/java/androidx/car/app/navigation/model/PlaceListNavigationTemplateTest.java
+++ b/car/app/app/src/test/java/androidx/car/app/navigation/model/PlaceListNavigationTemplateTest.java
@@ -23,7 +23,6 @@
import android.content.Context;
import android.text.SpannableString;
-import androidx.car.app.CarAppPermission;
import androidx.car.app.TestUtils;
import androidx.car.app.model.Action;
import androidx.car.app.model.ActionStrip;
@@ -378,30 +377,4 @@
.setTitle("other")
.build());
}
-
- @Test
- public void checkPermissions_hasPermissions() {
- PlaceListNavigationTemplate template =
- new PlaceListNavigationTemplate.Builder()
- .setItemList(
- TestUtils.createItemListWithDistanceSpan(6, false, mDistanceSpan))
- .setTitle("title")
- .build();
-
- // Expect that it does not throw
- template.checkPermissions(
- TestUtils.getMockContextWithPermission(CarAppPermission.NAVIGATION_TEMPLATES));
- }
-
- @Test
- public void checkPermissions_doesNotHavePermissions() {
- PlaceListNavigationTemplate template =
- new PlaceListNavigationTemplate.Builder()
- .setItemList(
- TestUtils.createItemListWithDistanceSpan(6, false, mDistanceSpan))
- .setTitle("title")
- .build();
-
- assertThrows(SecurityException.class, () -> template.checkPermissions(mContext));
- }
}
diff --git a/car/app/app/src/test/java/androidx/car/app/navigation/model/RoutePreviewNavigationTemplateTest.java b/car/app/app/src/test/java/androidx/car/app/navigation/model/RoutePreviewNavigationTemplateTest.java
index cd0dcea..7da3e0b 100644
--- a/car/app/app/src/test/java/androidx/car/app/navigation/model/RoutePreviewNavigationTemplateTest.java
+++ b/car/app/app/src/test/java/androidx/car/app/navigation/model/RoutePreviewNavigationTemplateTest.java
@@ -25,7 +25,6 @@
import android.content.Context;
import android.text.SpannableString;
-import androidx.car.app.CarAppPermission;
import androidx.car.app.OnDoneCallback;
import androidx.car.app.TestUtils;
import androidx.car.app.model.Action;
@@ -47,10 +46,10 @@
@RunWith(RobolectricTestRunner.class)
@DoNotInstrument
public class RoutePreviewNavigationTemplateTest {
- private final Context mContext = ApplicationProvider.getApplicationContext();
private static final DistanceSpan DISTANCE =
DistanceSpan.create(
Distance.create(/* displayDistance= */ 1, Distance.UNIT_KILOMETERS_P1));
+ private final Context mContext = ApplicationProvider.getApplicationContext();
@Test
public void createInstance_emptyList_notLoading_Throws() {
@@ -452,34 +451,4 @@
}).build())
.build());
}
-
- @Test
- public void checkPermissions_hasPermissions() {
- RoutePreviewNavigationTemplate template =
- new RoutePreviewNavigationTemplate.Builder()
- .setTitle("Title")
- .setItemList(TestUtils.createItemListWithDistanceSpan(2, true, DISTANCE))
- .setNavigateAction(
- new Action.Builder().setTitle("drive").setOnClickListener(() -> {
- }).build())
- .build();
-
- // Expect that it does not throw
- template.checkPermissions(
- TestUtils.getMockContextWithPermission(CarAppPermission.NAVIGATION_TEMPLATES));
- }
-
- @Test
- public void checkPermissions_doesNotHavePermissions() {
- RoutePreviewNavigationTemplate template =
- new RoutePreviewNavigationTemplate.Builder()
- .setTitle("Title")
- .setItemList(TestUtils.createItemListWithDistanceSpan(2, true, DISTANCE))
- .setNavigateAction(
- new Action.Builder().setTitle("drive").setOnClickListener(() -> {
- }).build())
- .build();
-
- assertThrows(SecurityException.class, () -> template.checkPermissions(mContext));
- }
}
diff --git a/car/app/app/src/test/java/androidx/car/app/navigation/model/TripTest.java b/car/app/app/src/test/java/androidx/car/app/navigation/model/TripTest.java
index e370874..e0b055b 100644
--- a/car/app/app/src/test/java/androidx/car/app/navigation/model/TripTest.java
+++ b/car/app/app/src/test/java/androidx/car/app/navigation/model/TripTest.java
@@ -40,16 +40,16 @@
public class TripTest {
private final Step mStep =
- new Step.Builder("Take the second exit of the roundabout.")
- .addLane(new Lane.Builder().addDirection(
+ Step.builder("Take the second exit of the roundabout.")
+ .addLane(Lane.builder().addDirection(
LaneDirection.create(SHAPE_SHARP_LEFT, true)).build())
- .setManeuver(new Maneuver.Builder(TYPE_ROUNDABOUT_ENTER_AND_EXIT_CCW)
+ .setManeuver(Maneuver.builder(TYPE_ROUNDABOUT_ENTER_AND_EXIT_CCW)
.setRoundaboutExitNumber(/*roundaboutExitNumber=*/ 2)
.setIcon(CarIcon.APP_ICON)
.build())
.build();
private final Destination mDestination =
- new Destination.Builder().setName("Google BVE").setAddress("1120 112th Ave NE").build();
+ Destination.builder().setName("Google BVE").setAddress("1120 112th Ave NE").build();
private final TravelEstimate mStepTravelEstimate =
TravelEstimate.create(
Distance.create(/* displayDistance= */ 10, Distance.UNIT_KILOMETERS),
@@ -65,11 +65,9 @@
@Test
public void createInstance() {
Trip trip =
- new Trip.Builder()
- .addDestination(mDestination)
- .addStep(mStep)
- .addDestinationTravelEstimate(mDestinationTravelEstimate)
- .addStepTravelEstimate(mStepTravelEstimate)
+ Trip.builder()
+ .addDestination(mDestination, mDestinationTravelEstimate)
+ .addStep(mStep, mStepTravelEstimate)
.setCurrentRoad(ROAD)
.setLoading(false)
.build();
@@ -87,31 +85,10 @@
}
@Test
- public void getDestinationWithEstimates_mismatch_count() {
- assertThrows(
- IllegalArgumentException.class,
- () -> new Trip.Builder().addDestination(mDestination).build());
- assertThrows(
- IllegalArgumentException.class,
- () -> new Trip.Builder().addDestinationTravelEstimate(
- mDestinationTravelEstimate).build());
- }
-
- @Test
- public void getStepWithEstimates_mismatch_count() {
- assertThrows(IllegalArgumentException.class,
- () -> new Trip.Builder().addStep(mStep).build());
- assertThrows(
- IllegalArgumentException.class,
- () -> new Trip.Builder().addStepTravelEstimate(mStepTravelEstimate).build());
- }
-
- @Test
public void createInstance_loading_no_steps() {
Trip trip =
- new Trip.Builder()
- .addDestination(mDestination)
- .addDestinationTravelEstimate(mDestinationTravelEstimate)
+ Trip.builder()
+ .addDestination(mDestination, mDestinationTravelEstimate)
.setCurrentRoad(ROAD)
.setLoading(true)
.build();
@@ -128,19 +105,12 @@
@Test
public void createInstance_loading_with_steps() {
+
assertThrows(
IllegalArgumentException.class,
- () -> new Trip.Builder().addStep(mStep).setLoading(true).build());
- assertThrows(
- IllegalArgumentException.class,
- () -> new Trip.Builder().addStepTravelEstimate(mStepTravelEstimate).setLoading(
- true).build());
- assertThrows(
- IllegalArgumentException.class,
- () -> new Trip.Builder()
- .addStep(mStep)
- .addStepTravelEstimate(mStepTravelEstimate)
+ () -> Trip.builder()
+ .addStep(mStep, mStepTravelEstimate)
.setLoading(true)
.build());
}
-}
+}
\ No newline at end of file
diff --git a/compose/foundation/foundation/api/current.txt b/compose/foundation/foundation/api/current.txt
index e787c7c..0e039b4 100644
--- a/compose/foundation/foundation/api/current.txt
+++ b/compose/foundation/foundation/api/current.txt
@@ -533,9 +533,6 @@
@androidx.compose.runtime.Immutable public final class InlineTextContent {
ctor public InlineTextContent(androidx.compose.ui.text.Placeholder placeholder, kotlin.jvm.functions.Function1<? super java.lang.String,kotlin.Unit> children);
- method public androidx.compose.ui.text.Placeholder component1();
- method public kotlin.jvm.functions.Function1<java.lang.String,kotlin.Unit> component2();
- method @androidx.compose.runtime.Immutable public androidx.compose.foundation.text.InlineTextContent copy(androidx.compose.ui.text.Placeholder placeholder, kotlin.jvm.functions.Function1<? super java.lang.String,kotlin.Unit> children);
method public kotlin.jvm.functions.Function1<java.lang.String,kotlin.Unit> getChildren();
method public androidx.compose.ui.text.Placeholder getPlaceholder();
property public final kotlin.jvm.functions.Function1<java.lang.String,kotlin.Unit> children;
diff --git a/compose/foundation/foundation/api/public_plus_experimental_current.txt b/compose/foundation/foundation/api/public_plus_experimental_current.txt
index e787c7c..0e039b4 100644
--- a/compose/foundation/foundation/api/public_plus_experimental_current.txt
+++ b/compose/foundation/foundation/api/public_plus_experimental_current.txt
@@ -533,9 +533,6 @@
@androidx.compose.runtime.Immutable public final class InlineTextContent {
ctor public InlineTextContent(androidx.compose.ui.text.Placeholder placeholder, kotlin.jvm.functions.Function1<? super java.lang.String,kotlin.Unit> children);
- method public androidx.compose.ui.text.Placeholder component1();
- method public kotlin.jvm.functions.Function1<java.lang.String,kotlin.Unit> component2();
- method @androidx.compose.runtime.Immutable public androidx.compose.foundation.text.InlineTextContent copy(androidx.compose.ui.text.Placeholder placeholder, kotlin.jvm.functions.Function1<? super java.lang.String,kotlin.Unit> children);
method public kotlin.jvm.functions.Function1<java.lang.String,kotlin.Unit> getChildren();
method public androidx.compose.ui.text.Placeholder getPlaceholder();
property public final kotlin.jvm.functions.Function1<java.lang.String,kotlin.Unit> children;
diff --git a/compose/foundation/foundation/api/restricted_current.txt b/compose/foundation/foundation/api/restricted_current.txt
index e787c7c..0e039b4 100644
--- a/compose/foundation/foundation/api/restricted_current.txt
+++ b/compose/foundation/foundation/api/restricted_current.txt
@@ -533,9 +533,6 @@
@androidx.compose.runtime.Immutable public final class InlineTextContent {
ctor public InlineTextContent(androidx.compose.ui.text.Placeholder placeholder, kotlin.jvm.functions.Function1<? super java.lang.String,kotlin.Unit> children);
- method public androidx.compose.ui.text.Placeholder component1();
- method public kotlin.jvm.functions.Function1<java.lang.String,kotlin.Unit> component2();
- method @androidx.compose.runtime.Immutable public androidx.compose.foundation.text.InlineTextContent copy(androidx.compose.ui.text.Placeholder placeholder, kotlin.jvm.functions.Function1<? super java.lang.String,kotlin.Unit> children);
method public kotlin.jvm.functions.Function1<java.lang.String,kotlin.Unit> getChildren();
method public androidx.compose.ui.text.Placeholder getPlaceholder();
property public final kotlin.jvm.functions.Function1<java.lang.String,kotlin.Unit> children;
diff --git a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/ScrollableTest.kt b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/ScrollableTest.kt
index 0e77bcd..79a9310 100644
--- a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/ScrollableTest.kt
+++ b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/ScrollableTest.kt
@@ -471,13 +471,13 @@
}
}
launch {
- controller.smoothScrollBy(300f)
+ (controller as Scrollable).smoothScrollBy(300f)
}
advanceClockWhileAwaitersExist(clock)
assertThat(total).isEqualTo(300f)
launch {
- controller.smoothScrollBy(200f)
+ (controller as Scrollable).smoothScrollBy(200f)
}
// don't advance clocks yet, toggle disposed value
disposed.value = true
diff --git a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/text/CoreTextFieldSoftKeyboardTest.kt b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/text/CoreTextFieldSoftKeyboardTest.kt
index f02d251..029a4f3 100644
--- a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/text/CoreTextFieldSoftKeyboardTest.kt
+++ b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/text/CoreTextFieldSoftKeyboardTest.kt
@@ -30,7 +30,7 @@
import androidx.compose.ui.platform.AmbientFocusManager
import androidx.compose.ui.platform.AmbientView
import androidx.compose.ui.platform.testTag
-import androidx.compose.ui.test.junit4.createComposeRuleLegacy
+import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.performClick
import androidx.compose.ui.text.InternalTextApi
@@ -38,21 +38,17 @@
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.LargeTest
import androidx.test.filters.SdkSuppress
-import com.google.common.truth.Truth.assertThat
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
-import java.util.concurrent.CountDownLatch
-import java.util.concurrent.TimeUnit
@LargeTest
@RunWith(AndroidJUnit4::class)
@OptIn(InternalTextApi::class)
class CoreTextFieldSoftKeyboardTest {
- @Suppress("DEPRECATION")
@get:Rule
- val rule = createComposeRuleLegacy()
+ val rule = createComposeRule()
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.R)
@Test
@@ -70,12 +66,9 @@
view.ensureKeyboardIsHidden()
// Act.
- val isSoftKeyboardShown = view.runAndWaitUntil({ view.isSoftwareKeyboardShown() }) {
+ view.runAndWaitUntil({ view.isSoftwareKeyboardShown() }) {
rule.onNodeWithTag("TextField1").performClick()
}
-
- // Assert.
- assertThat(isSoftKeyboardShown).isTrue()
}
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.R)
@@ -95,12 +88,9 @@
view.ensureKeyboardIsHidden()
// Act.
- val isSoftKeyboardShown = view.runAndWaitUntil({ view.isSoftwareKeyboardShown() }) {
+ view.runAndWaitUntil({ view.isSoftwareKeyboardShown() }) {
rule.runOnIdle { focusRequester.requestFocus() }
}
-
- // Assert.
- assertThat(isSoftKeyboardShown).isTrue()
}
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.R)
@@ -126,12 +116,9 @@
}
// Act.
- val isSoftKeyboardHidden = view.runAndWaitUntil({ !view.isSoftwareKeyboardShown() }) {
+ view.runAndWaitUntil({ !view.isSoftwareKeyboardShown() }) {
rule.runOnIdle { focusManager.clearFocus() }
}
-
- // Assert.
- assertThat(isSoftKeyboardHidden).isTrue()
}
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.R)
@@ -156,12 +143,9 @@
}
// Act.
- val isSoftKeyboardVisible = view.runAndWaitUntil({ view.isSoftwareKeyboardShown() }) {
+ view.runAndWaitUntil({ view.isSoftwareKeyboardShown() }) {
rule.onNodeWithTag("TextField1").performClick()
}
-
- // Assert.
- assertThat(isSoftKeyboardVisible).isTrue()
}
@OptIn(ExperimentalComposeUiApi::class)
@@ -192,28 +176,24 @@
}
// Act.
- val wasKeyboardHidden = view.runAndWaitUntil({ !view.isSoftwareKeyboardShown() }) {
+ view.runAndWaitUntil({ !view.isSoftwareKeyboardShown() }) {
rule.runOnIdle { focusRequester2.requestFocus() }
}
-
- // Assert.
- assertThat(wasKeyboardHidden).isFalse()
}
@RequiresApi(Build.VERSION_CODES.R)
- private fun View.runAndWaitUntil(condition: () -> Boolean, block: () -> Unit): Boolean {
- val latch = CountDownLatch(1)
+ private fun View.runAndWaitUntil(condition: () -> Boolean, block: () -> Unit) {
+ var conditionPassed = false
rule.runOnIdle {
rootView.setWindowInsetsAnimationCallback(
InsetAnimationCallback {
- if (condition()) { latch.countDown() }
+ if (condition()) { conditionPassed = true }
}
)
}
rule.waitForIdle()
block()
- rule.waitForIdle()
- return latch.await(15L, TimeUnit.SECONDS)
+ rule.waitUntil(15_000) { conditionPassed }
}
// We experienced some flakiness in tests if the keyboard was visible at the start of the test.
@@ -247,8 +227,7 @@
@RequiresApi(Build.VERSION_CODES.R)
private fun View.isSoftwareKeyboardShown(): Boolean {
- checkNotNull(rootWindowInsets)
- return rootWindowInsets.isVisible(WindowInsets.Type.ime())
+ return rootWindowInsets != null && rootWindowInsets.isVisible(WindowInsets.Type.ime())
}
@RequiresApi(Build.VERSION_CODES.R)
diff --git a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/Indication.kt b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/Indication.kt
index 6b94200..e540e8f 100644
--- a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/Indication.kt
+++ b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/Indication.kt
@@ -17,7 +17,7 @@
package androidx.compose.foundation
import androidx.compose.runtime.Composable
-import androidx.compose.runtime.CompositionLifecycleObserver
+import androidx.compose.runtime.RememberObserver
import androidx.compose.runtime.Stable
import androidx.compose.runtime.remember
import androidx.compose.runtime.staticAmbientOf
@@ -145,7 +145,7 @@
private class IndicationModifier(
val interactionState: InteractionState,
val indicationInstance: IndicationInstance
-) : CompositionLifecycleObserver, DrawModifier {
+) : RememberObserver, DrawModifier {
override fun ContentDrawScope.draw() {
with(indicationInstance) {
@@ -153,9 +153,13 @@
}
}
- override fun onEnter() {}
+ override fun onRemembered() { }
- override fun onLeave() {
+ override fun onForgotten() {
+ indicationInstance.onDispose()
+ }
+
+ override fun onAbandoned() {
indicationInstance.onDispose()
}
}
\ No newline at end of file
diff --git a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/CoreTextField.kt b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/CoreTextField.kt
index 2786da4..a7c06ad 100644
--- a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/CoreTextField.kt
+++ b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/CoreTextField.kt
@@ -163,12 +163,16 @@
val selectionBackgroundColor = AmbientTextSelectionColors.current.backgroundColor
// State
- val (visualText, offsetMapping) = remember(value, visualTransformation) {
+ val transformedText = remember(value, visualTransformation) {
val transformed = visualTransformation.filter(AnnotatedString(value.text))
value.composition?.let {
TextFieldDelegate.applyCompositionDecoration(it, transformed)
} ?: transformed
}
+
+ val visualText = transformedText.text
+ val offsetMapping = transformedText.offsetMapping
+
val state = remember {
TextFieldState(
TextDelegate(
diff --git a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/InactiveTextField.kt b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/InactiveTextField.kt
index fe4b034..da04daa 100644
--- a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/InactiveTextField.kt
+++ b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/InactiveTextField.kt
@@ -48,7 +48,7 @@
) {
val transformedText = remember(value, visualTransformation) {
visualTransformation.filter(AnnotatedString(value.text))
- }.transformedText
+ }.text
val text: @Composable (Modifier) -> Unit = @Composable { textModifier ->
BasicText(
diff --git a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/InlineTextContent.kt b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/InlineTextContent.kt
index 3f7e142..cc6c7fa7 100644
--- a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/InlineTextContent.kt
+++ b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/InlineTextContent.kt
@@ -61,7 +61,7 @@
* @see Placeholder
*/
@Immutable
-data class InlineTextContent(
+class InlineTextContent(
/**
* The setting object that defines the size and vertical alignment of this composable in the
* text line. This is different from the measure of Layout
diff --git a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/TextFieldDelegate.kt b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/TextFieldDelegate.kt
index a028be9..79f0ea9 100644
--- a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/TextFieldDelegate.kt
+++ b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/TextFieldDelegate.kt
@@ -302,7 +302,7 @@
transformed: TransformedText
): TransformedText =
TransformedText(
- AnnotatedString.Builder(transformed.transformedText).apply {
+ AnnotatedString.Builder(transformed.text).apply {
addStyle(
SpanStyle(textDecoration = TextDecoration.Underline),
transformed.offsetMapping.originalToTransformed(compositionRange.start),
diff --git a/compose/foundation/foundation/src/test/kotlin/androidx/compose/foundation/text/TextFieldDelegateTest.kt b/compose/foundation/foundation/src/test/kotlin/androidx/compose/foundation/text/TextFieldDelegateTest.kt
index 884eb28..a93f802e 100644
--- a/compose/foundation/foundation/src/test/kotlin/androidx/compose/foundation/text/TextFieldDelegateTest.kt
+++ b/compose/foundation/foundation/src/test/kotlin/androidx/compose/foundation/text/TextFieldDelegateTest.kt
@@ -312,8 +312,11 @@
@Test
fun use_identity_mapping_if_none_visual_transformation() {
- val (visualText, offsetMapping) =
- VisualTransformation.None.filter(AnnotatedString(text = "Hello, World"))
+ val transformedText = VisualTransformation.None.filter(
+ AnnotatedString(text = "Hello, World")
+ )
+ val visualText = transformedText.text
+ val offsetMapping = transformedText.offsetMapping
assertEquals("Hello, World", visualText.text)
for (i in 0..visualText.text.length) {
@@ -331,7 +334,7 @@
}
val input = TransformedText(
- transformedText = AnnotatedString.Builder().apply {
+ text = AnnotatedString.Builder().apply {
pushStyle(SpanStyle(color = Color.Red))
append("Hello, World")
}.toAnnotatedString(),
@@ -343,9 +346,9 @@
transformed = input
)
- assertThat(result.transformedText.text).isEqualTo(input.transformedText.text)
- assertThat(result.transformedText.spanStyles.size).isEqualTo(2)
- assertThat(result.transformedText.spanStyles).contains(
+ assertThat(result.text.text).isEqualTo(input.text.text)
+ assertThat(result.text.spanStyles.size).isEqualTo(2)
+ assertThat(result.text.spanStyles).contains(
AnnotatedString.Range(SpanStyle(textDecoration = TextDecoration.Underline), 3, 6)
)
}
@@ -359,7 +362,7 @@
}
val input = TransformedText(
- transformedText = AnnotatedString.Builder().apply {
+ text = AnnotatedString.Builder().apply {
append(" ".repeat(offsetAmount))
append("Hello World")
}.toAnnotatedString(),
@@ -372,8 +375,8 @@
transformed = input
)
- assertThat(result.transformedText.spanStyles.size).isEqualTo(1)
- assertThat(result.transformedText.spanStyles).contains(
+ assertThat(result.text.spanStyles.size).isEqualTo(1)
+ assertThat(result.text.spanStyles).contains(
AnnotatedString.Range(
SpanStyle(textDecoration = TextDecoration.Underline),
range.start + offsetAmount,
diff --git a/compose/integration-tests/demos/src/androidTest/java/androidx/compose/integration/demos/test/DemoTest.kt b/compose/integration-tests/demos/src/androidTest/java/androidx/compose/integration/demos/test/DemoTest.kt
index e50f942..51e3f5f 100644
--- a/compose/integration-tests/demos/src/androidTest/java/androidx/compose/integration/demos/test/DemoTest.kt
+++ b/compose/integration-tests/demos/src/androidTest/java/androidx/compose/integration/demos/test/DemoTest.kt
@@ -32,7 +32,7 @@
import androidx.compose.ui.test.hasClickAction
import androidx.compose.ui.test.hasText
import androidx.compose.ui.test.isDialog
-import androidx.compose.ui.test.junit4.createAndroidComposeRuleLegacy
+import androidx.compose.ui.test.junit4.createAndroidComposeRule
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performClick
@@ -51,6 +51,7 @@
private val ignoredDemos = listOf(
// TODO(b/168695905, fresen): We don't have a way to pause suspend animations yet.
"Animation > Suspend Animation Demos > Infinitely Animating",
+ "Animation > State Transition Demos > Infinite transition",
)
@LargeTest
@@ -58,9 +59,8 @@
@OptIn(ExperimentalTestApi::class)
class DemoTest {
// We need to provide the recompose factory first to use new clock.
- @Suppress("DEPRECATION")
@get:Rule
- val rule = createAndroidComposeRuleLegacy<DemoActivity>()
+ val rule = createAndroidComposeRule<DemoActivity>()
@Test
fun testFiltering() {
@@ -116,8 +116,7 @@
@Test
fun navigateThroughAllDemos_withInfiniteAnimations() {
// Pause the clock in these tests and forward it manually
- @Suppress("DEPRECATION")
- rule.clockTestRule.pauseClock()
+ rule.mainClock.autoAdvance = false
navigateThroughAllDemos(AllDemosWithInfiniteAnimations, fastForwardClock = true)
}
@@ -204,13 +203,17 @@
rule.waitForIdle()
Espresso.pressBack()
+ if (fastForwardClock) {
+ // Pump press back
+ fastForwardClock(2000)
+ }
+
assertAppBarHasTitle(navigationTitle)
}
- private fun fastForwardClock() {
+ private fun fastForwardClock(millis: Long = 5000) {
rule.waitForIdle()
- @Suppress("DEPRECATION")
- rule.clockTestRule.advanceClock(5000)
+ rule.mainClock.advanceTimeBy(millis)
}
/**
diff --git a/compose/integration-tests/demos/src/main/java/androidx/compose/integration/demos/DemoActivity.kt b/compose/integration-tests/demos/src/main/java/androidx/compose/integration/demos/DemoActivity.kt
index 392d4bc..9a1ea7de1 100644
--- a/compose/integration-tests/demos/src/main/java/androidx/compose/integration/demos/DemoActivity.kt
+++ b/compose/integration-tests/demos/src/main/java/androidx/compose/integration/demos/DemoActivity.kt
@@ -34,7 +34,6 @@
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleEventObserver
import androidx.preference.PreferenceManager
-import androidx.compose.ui.platform.setContent
import androidx.compose.integration.demos.common.ActivityDemo
import androidx.compose.integration.demos.common.Demo
import androidx.compose.integration.demos.common.DemoCategory
@@ -47,6 +46,7 @@
import androidx.compose.runtime.savedinstancestate.listSaver
import androidx.compose.runtime.savedinstancestate.rememberSavedInstanceState
import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.platform.ComposeView
/**
* Main [Activity] containing all Compose related demos.
@@ -55,7 +55,10 @@
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
- setContent {
+
+ ComposeView(this).also {
+ setContentView(it)
+ }.setContent {
val activityStarter = fun(demo: ActivityDemo<*>) {
startActivity(Intent(this, demo.activityClass.java))
}
diff --git a/compose/integration-tests/docs-snippets/src/main/java/androidx/compose/integration/docs/kotlin/Kotlin.kt b/compose/integration-tests/docs-snippets/src/main/java/androidx/compose/integration/docs/kotlin/Kotlin.kt
index 4785fe9..faccf4d 100644
--- a/compose/integration-tests/docs-snippets/src/main/java/androidx/compose/integration/docs/kotlin/Kotlin.kt
+++ b/compose/integration-tests/docs-snippets/src/main/java/androidx/compose/integration/docs/kotlin/Kotlin.kt
@@ -71,7 +71,8 @@
@Composable private fun KotlinSnippet4() {
Column(
- modifier = Modifier.padding(16.dp), content = {
+ modifier = Modifier.padding(16.dp),
+ content = {
Text("Some text")
Text("Some more text")
Text("Last text")
@@ -114,7 +115,7 @@
// This method accepts a lambda of type DrawScope.() -> Unit
// therefore in this lambda we can access properties and functions
// available from DrawScope, such as the `drawRectangle` function.
- drawRect( /*...*/)
+ drawRect(/*...*/)
}
)
}
diff --git a/compose/integration-tests/docs-snippets/src/main/java/androidx/compose/integration/docs/layout/Layout.kt b/compose/integration-tests/docs-snippets/src/main/java/androidx/compose/integration/docs/layout/Layout.kt
index 867d057..7380d00 100644
--- a/compose/integration-tests/docs-snippets/src/main/java/androidx/compose/integration/docs/layout/Layout.kt
+++ b/compose/integration-tests/docs-snippets/src/main/java/androidx/compose/integration/docs/layout/Layout.kt
@@ -25,21 +25,24 @@
import androidx.compose.foundation.layout.ConstraintLayout
import androidx.compose.foundation.layout.ConstraintSet
import androidx.compose.foundation.layout.Row
+import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.layout.preferredSize
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
+import androidx.compose.integration.docs.layout.LayoutSnippet12.firstBaselineToTop
import androidx.compose.material.Button
+import androidx.compose.material.Card
import androidx.compose.material.Scaffold
import androidx.compose.material.Surface
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
-import androidx.compose.integration.docs.layout.LayoutSnippet12.firstBaselineToTop
import androidx.compose.ui.layout.AlignmentLine
import androidx.compose.ui.layout.FirstBaseline
import androidx.compose.ui.layout.Layout
@@ -79,7 +82,7 @@
@Composable
fun ArtistCard(artist: Artist) {
Row(verticalAlignment = Alignment.CenterVertically) {
- Image( /*...*/)
+ Image(/*...*/)
Column {
Text(artist.name)
Text(artist.lastSeenOnline)
@@ -88,6 +91,26 @@
}
}
+private object LayoutSnippet3bis {
+ @Composable
+ fun ArtistCard(
+ artist: Artist,
+ onClick: () -> Unit
+ ) {
+ val padding = 16.dp
+ Column(
+ Modifier
+ .clickable(onClick = onClick)
+ .padding(padding)
+ .fillMaxWidth()
+ ) {
+ Row(verticalAlignment = Alignment.CenterVertically) { /*...*/ }
+ Spacer(Modifier.preferredSize(padding))
+ Card(elevation = 4.dp) { /*...*/ }
+ }
+ }
+}
+
private object LayoutSnippet4 {
@Composable
fun ArtistCard(/*...*/) {
@@ -105,7 +128,7 @@
private object LayoutSnippet5 {
@Composable
- fun ArtistCard( /* ... */) {
+ fun ArtistCard(/*...*/) {
val padding = 16.dp
Column(
Modifier
@@ -150,7 +173,7 @@
private object LayoutSnippet8 {
@Composable
- fun HomeScreen( /*...*/) {
+ fun HomeScreen(/*...*/) {
Scaffold(
drawerContent = { /*...*/ },
topBar = { /*...*/ },
@@ -228,11 +251,12 @@
}
}
}
+
private object LayoutSnippet11 {
/* Can't be compiled without returning layout() from Modifier.layout. See next snippet for
possible changes.
- fun Modifier.customLayoutModifier( /*...*/ ) =
+ fun Modifier.customLayoutModifier(/*...*/) =
Modifier.layout { measurable, constraints ->
// ...
}
diff --git a/compose/integration-tests/docs-snippets/src/main/java/androidx/compose/integration/docs/mentalmodel/MentalModel.kt b/compose/integration-tests/docs-snippets/src/main/java/androidx/compose/integration/docs/mentalmodel/MentalModel.kt
index 8f16fb4..bff05e5 100644
--- a/compose/integration-tests/docs-snippets/src/main/java/androidx/compose/integration/docs/mentalmodel/MentalModel.kt
+++ b/compose/integration-tests/docs-snippets/src/main/java/androidx/compose/integration/docs/mentalmodel/MentalModel.kt
@@ -95,8 +95,7 @@
Column {
for (item in myList) {
Text("Item: $item")
- items++ // this is a side-effect of the Column recomposing
- // and should be avoided
+ items++ // Avoid! Side-effect of the column recomposing.
}
}
Text("Count: $items")
diff --git a/compose/integration-tests/docs-snippets/src/main/java/androidx/compose/integration/docs/state/State.kt b/compose/integration-tests/docs-snippets/src/main/java/androidx/compose/integration/docs/state/State.kt
index 2dd4e4e..dd6f636 100644
--- a/compose/integration-tests/docs-snippets/src/main/java/androidx/compose/integration/docs/state/State.kt
+++ b/compose/integration-tests/docs-snippets/src/main/java/androidx/compose/integration/docs/state/State.kt
@@ -209,10 +209,10 @@
override var value: T
}
*/
- interface DummyState<T> : State<T> {
+ interface FakeState<T> : State<T> {
override var value: T
}
- interface DummMutableState<T> : MutableState<String>
+ interface FakeMutableState<T> : MutableState<String>
}
private object StateSnippet11 {
@@ -250,7 +250,7 @@
private object StateSnippet12 {
// this stateful composable is only responsible for holding internal state
-// and defers the UI to the stateless composable
+ // and defers the UI to the stateless composable
@Composable
fun ExpandingCard(title: String, body: String) {
var expanded by remember { mutableStateOf(false) }
@@ -264,7 +264,7 @@
}
// this stateless composable is responsible for describing the UI based on the state
-// passed to it and firing events in response to the buttons being pressed
+ // passed to it and firing events in response to the buttons being pressed
@Composable
fun ExpandingCard(
title: String,
diff --git a/compose/integration-tests/docs-snippets/src/main/java/androidx/compose/integration/docs/testing/Testing.kt b/compose/integration-tests/docs-snippets/src/main/java/androidx/compose/integration/docs/testing/Testing.kt
index 2695c57..5338e1b 100644
--- a/compose/integration-tests/docs-snippets/src/main/java/androidx/compose/integration/docs/testing/Testing.kt
+++ b/compose/integration-tests/docs-snippets/src/main/java/androidx/compose/integration/docs/testing/Testing.kt
@@ -136,8 +136,7 @@
@Composable private fun TestingSnippets7() {
// Single matcher:
- composeTestRule.onNode(matcher).assert(hasText("Button")) // hasText is a
- // SemanticsMatcher
+ composeTestRule.onNode(matcher).assert(hasText("Button")) // hasText is a SemanticsMatcher
// Multiple matchers can use and / or
composeTestRule.onNode(matcher).assert(hasText("Button") or hasText("Button2"))
}
diff --git a/compose/integration-tests/docs-snippets/src/main/java/androidx/compose/integration/docs/tutorial/Tutorial.kt b/compose/integration-tests/docs-snippets/src/main/java/androidx/compose/integration/docs/tutorial/Tutorial.kt
index 9d5504d..18a6b75 100644
--- a/compose/integration-tests/docs-snippets/src/main/java/androidx/compose/integration/docs/tutorial/Tutorial.kt
+++ b/compose/integration-tests/docs-snippets/src/main/java/androidx/compose/integration/docs/tutorial/Tutorial.kt
@@ -43,6 +43,8 @@
* https://developer.android.com/jetpack/compose/tutorial
*
* No action required if it's modified.
+ *
+ * Tech writers: on DAC, these snippets contain html formatting that is omitted here.
*/
private object TutorialSnippet1 {
@@ -177,7 +179,8 @@
.preferredHeight(180.dp)
.fillMaxWidth()
- Image(image, modifier = imageModifier,
+ Image(image,
+ modifier = imageModifier,
contentScale = ContentScale.Crop)
Text("A day in Shark Fin Cove")
@@ -202,7 +205,8 @@
.fillMaxWidth()
.clip(shape = RoundedCornerShape(4.dp))
- Image(image, modifier = imageModifier,
+ Image(image,
+ modifier = imageModifier,
contentScale = ContentScale.Crop)
Spacer(Modifier.preferredHeight(16.dp))
@@ -226,7 +230,8 @@
.fillMaxWidth()
.clip(shape = RoundedCornerShape(4.dp))
- Image(image, modifier = imageModifier,
+ Image(image,
+ modifier = imageModifier,
contentScale = ContentScale.Crop)
Spacer(Modifier.preferredHeight(16.dp))
@@ -252,7 +257,8 @@
.fillMaxWidth()
.clip(shape = RoundedCornerShape(4.dp))
- Image(image, modifier = imageModifier,
+ Image(image,
+ modifier = imageModifier,
contentScale = ContentScale.Crop)
Spacer(Modifier.preferredHeight(16.dp))
@@ -281,7 +287,8 @@
.fillMaxWidth()
.clip(shape = RoundedCornerShape(4.dp))
- Image(image, modifier = imageModifier,
+ Image(image,
+ modifier = imageModifier,
contentScale = ContentScale.Crop)
Spacer(Modifier.preferredHeight(16.dp))
@@ -314,7 +321,8 @@
.fillMaxWidth()
.clip(shape = RoundedCornerShape(4.dp))
- Image(image, modifier = imageModifier,
+ Image(image,
+ modifier = imageModifier,
contentScale = ContentScale.Crop)
Spacer(Modifier.preferredHeight(16.dp))
diff --git a/compose/integration-tests/src/androidTest/java/androidx/ui/integration/test/CheckboxesInRowsTest.kt b/compose/integration-tests/src/androidTest/java/androidx/ui/integration/test/CheckboxesInRowsTest.kt
deleted file mode 100644
index c138681..0000000
--- a/compose/integration-tests/src/androidTest/java/androidx/ui/integration/test/CheckboxesInRowsTest.kt
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright 2019 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.integration.test
-
-import androidx.activity.ComponentActivity
-import androidx.compose.testutils.assertMeasureSizeIsPositive
-import androidx.compose.testutils.assertNoPendingChanges
-import androidx.compose.testutils.forGivenTestCase
-import androidx.compose.ui.test.ExperimentalTestApi
-import androidx.compose.ui.test.junit4.createAndroidComposeRuleLegacy
-import androidx.test.filters.MediumTest
-import androidx.ui.integration.test.material.CheckboxesInRowsTestCase
-import org.junit.Rule
-import org.junit.Test
-import org.junit.runner.RunWith
-import org.junit.runners.Parameterized
-
-/**
- * Ensure correctness of [CheckboxesInRowsTestCase].
- */
-@MediumTest
-@RunWith(Parameterized::class)
-@OptIn(ExperimentalTestApi::class)
-class CheckboxesInRowsTest(private val numberOfCheckboxes: Int) {
-
- companion object {
- @JvmStatic
- @Parameterized.Parameters
- fun initParameters(): Array<Any> = arrayOf(1, 10)
- }
-
- @Suppress("DEPRECATION")
- @get:Rule
- val composeTestRule = createAndroidComposeRuleLegacy<ComponentActivity>()
-
- @Test
- fun toggleRectangleColor_compose() {
- val testCase = CheckboxesInRowsTestCase(numberOfCheckboxes)
- composeTestRule
- .forGivenTestCase(testCase)
- .performTestWithEventsControl {
- doFrame()
- assertNoPendingChanges()
- assertMeasureSizeIsPositive()
- testCase.toggleState()
- doFrame()
- assertNoPendingChanges()
- }
- }
-}
\ No newline at end of file
diff --git a/compose/material/material-icons-extended/src/androidAndroidTest/kotlin/androidx/compose/material/icons/IconComparisonTest.kt b/compose/material/material-icons-extended/src/androidAndroidTest/kotlin/androidx/compose/material/icons/IconComparisonTest.kt
index 19ffeac..611a8b0 100644
--- a/compose/material/material-icons-extended/src/androidAndroidTest/kotlin/androidx/compose/material/icons/IconComparisonTest.kt
+++ b/compose/material/material-icons-extended/src/androidAndroidTest/kotlin/androidx/compose/material/icons/IconComparisonTest.kt
@@ -31,6 +31,8 @@
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.graphics.asAndroidBitmap
import androidx.compose.ui.graphics.vector.ImageVector
+import androidx.compose.ui.graphics.vector.VectorGroup
+import androidx.compose.ui.graphics.vector.VectorPath
import androidx.compose.ui.graphics.vector.rememberVectorPainter
import androidx.compose.ui.platform.AmbientContext
import androidx.compose.ui.platform.AmbientDensity
@@ -137,6 +139,71 @@
}
/**
+ * Helper method to copy the existing [ImageVector] modifying the name
+ * for use in equality checks.
+ */
+private fun ImageVector.copy(name: String): ImageVector {
+ val builder = ImageVector.Builder(
+ name, defaultWidth, defaultHeight, viewportWidth, viewportHeight, tintColor, tintBlendMode
+ )
+ val root = this.root
+ // Stack of vector groups and current child index being traversed
+ val stack = ArrayList<Pair<Int, VectorGroup>>()
+ stack.add(Pair(0, root))
+
+ while (!stack.isEmpty()) {
+ val current = stack[stack.size - 1]
+ var currentIndex = current.first
+ var currentGroup = current.second
+ while (currentIndex < currentGroup.size) {
+ val vectorNode = currentGroup[currentIndex]
+ when (vectorNode) {
+ is VectorGroup -> {
+ // keep track of the current index to continue parsing groups
+ // when we eventually "pop" the stack of groups
+ stack.add(Pair(currentIndex + 1, currentGroup))
+ builder.addGroup(
+ name = vectorNode.name,
+ rotate = vectorNode.rotation,
+ pivotX = vectorNode.pivotX,
+ pivotY = vectorNode.pivotY,
+ scaleX = vectorNode.scaleX,
+ scaleY = vectorNode.scaleY,
+ translationX = vectorNode.translationX,
+ translationY = vectorNode.translationY,
+ clipPathData = vectorNode.clipPathData
+ )
+ currentGroup = vectorNode
+ currentIndex = 0
+ }
+ is VectorPath -> {
+ builder.addPath(
+ name = vectorNode.name,
+ pathData = vectorNode.pathData,
+ pathFillType = vectorNode.pathFillType,
+ fill = vectorNode.fill,
+ fillAlpha = vectorNode.fillAlpha,
+ stroke = vectorNode.stroke,
+ strokeAlpha = vectorNode.strokeAlpha,
+ strokeLineWidth = vectorNode.strokeLineWidth,
+ strokeLineCap = vectorNode.strokeLineCap,
+ strokeLineJoin = vectorNode.strokeLineJoin,
+ strokeLineMiter = vectorNode.strokeLineMiter,
+ trimPathStart = vectorNode.trimPathStart,
+ trimPathEnd = vectorNode.trimPathEnd,
+ trimPathOffset = vectorNode.trimPathOffset
+ )
+ }
+ }
+ currentIndex++
+ }
+ // "pop" the most recent group after we have examined each of the children
+ stack.removeAt(stack.size - 1)
+ }
+ return builder.build()
+}
+
+/**
* @return the [ImageVector] matching the drawable with [this] name.
*/
@Composable
diff --git a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/BottomNavigationScreenshotTest.kt b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/BottomNavigationScreenshotTest.kt
index afa40ad..b32d261 100644
--- a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/BottomNavigationScreenshotTest.kt
+++ b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/BottomNavigationScreenshotTest.kt
@@ -31,7 +31,7 @@
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.test.ExperimentalTestApi
import androidx.compose.ui.test.captureToImage
-import androidx.compose.ui.test.junit4.createComposeRuleLegacy
+import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithTag
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.LargeTest
@@ -47,9 +47,8 @@
@OptIn(ExperimentalMaterialApi::class, ExperimentalTestApi::class)
class BottomNavigationScreenshotTest {
- @Suppress("DEPRECATION")
@get:Rule
- val composeTestRule = createComposeRuleLegacy()
+ val composeTestRule = createComposeRule()
@get:Rule
val screenshotRule = AndroidXScreenshotTestRule(GOLDEN_MATERIAL)
@@ -274,13 +273,12 @@
* @param interaction the [Interaction] to assert for, or `null` if no [Interaction].
* @param goldenIdentifier the identifier for the corresponding screenshot
*/
- @Suppress("DEPRECATION") // Due to clockTestRule
private fun assertBottomNavigationMatches(
interactionState: InteractionState,
interaction: Interaction? = null,
goldenIdentifier: String
) {
- composeTestRule.clockTestRule.pauseClock()
+ composeTestRule.mainClock.autoAdvance = false
if (interaction != null) {
// Start ripple
@@ -294,7 +292,7 @@
// Advance to somewhere in the middle of the animation for the ripple
composeTestRule.waitForIdle()
- composeTestRule.clockTestRule.advanceClock(50)
+ composeTestRule.mainClock.advanceTimeBy(milliseconds = 80)
}
// Capture and compare screenshots
diff --git a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/ButtonScreenshotTest.kt b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/ButtonScreenshotTest.kt
index 0e60ee3..432b33d 100644
--- a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/ButtonScreenshotTest.kt
+++ b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/ButtonScreenshotTest.kt
@@ -26,7 +26,7 @@
import androidx.compose.ui.test.center
import androidx.compose.ui.test.down
import androidx.compose.ui.test.hasClickAction
-import androidx.compose.ui.test.junit4.createComposeRuleLegacy
+import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.onRoot
import androidx.compose.ui.test.performGesture
@@ -45,9 +45,8 @@
@OptIn(ExperimentalTestApi::class)
class ButtonScreenshotTest {
- @Suppress("DEPRECATION")
@get:Rule
- val rule = createComposeRuleLegacy()
+ val rule = createComposeRule()
@get:Rule
val screenshotRule = AndroidXScreenshotTestRule(GOLDEN_MATERIAL)
@@ -79,7 +78,6 @@
}
@Test
- @Suppress("DEPRECATION") // Due to clockTestRule
fun ripple() {
rule.setMaterialContent {
Box(Modifier.size(200.dp, 100.dp).wrapContentSize()) {
@@ -87,7 +85,7 @@
}
}
- rule.clockTestRule.pauseClock()
+ rule.mainClock.autoAdvance = false
// Start ripple
rule.onNode(hasClickAction())
@@ -95,7 +93,7 @@
// Let ripple propagate
rule.waitForIdle()
- rule.clockTestRule.advanceClock(50)
+ rule.mainClock.advanceTimeBy(milliseconds = 50)
rule.onRoot()
.captureToImage()
diff --git a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/CheckboxScreenshotTest.kt b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/CheckboxScreenshotTest.kt
index 470ee01..33005c0 100644
--- a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/CheckboxScreenshotTest.kt
+++ b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/CheckboxScreenshotTest.kt
@@ -30,7 +30,7 @@
import androidx.compose.ui.test.center
import androidx.compose.ui.test.down
import androidx.compose.ui.test.isToggleable
-import androidx.compose.ui.test.junit4.createComposeRuleLegacy
+import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.move
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.performGesture
@@ -49,9 +49,8 @@
@OptIn(ExperimentalTestApi::class)
class CheckboxScreenshotTest {
- @Suppress("DEPRECATION")
@get:Rule
- val rule = createComposeRuleLegacy()
+ val rule = createComposeRule()
@get:Rule
val screenshotRule = AndroidXScreenshotTestRule(GOLDEN_MATERIAL)
@@ -145,7 +144,6 @@
}
@Test
- @Suppress("DEPRECATION") // Due to clockTestRule
fun checkBoxTest_unchecked_animateToChecked() {
rule.setMaterialContent {
val isChecked = remember { mutableStateOf(false) }
@@ -158,22 +156,21 @@
}
}
- rule.clockTestRule.pauseClock()
+ rule.mainClock.autoAdvance = false
rule.onNode(isToggleable())
// split click into (down) and (move, up) to enforce a composition in between
.performGesture { down(center) }
.performGesture { move(); up() }
- rule.waitForIdle()
-
- rule.clockTestRule.advanceClock(60)
+ rule.mainClock.advanceTimeByFrame()
+ rule.waitForIdle() // Wait for measure
+ rule.mainClock.advanceTimeBy(milliseconds = 80)
assertToggeableAgainstGolden("checkbox_animateToChecked")
}
@Test
- @Suppress("DEPRECATION") // Due to clockTestRule
fun checkBoxTest_checked_animateToUnchecked() {
rule.setMaterialContent {
val isChecked = remember { mutableStateOf(true) }
@@ -186,16 +183,16 @@
}
}
- rule.clockTestRule.pauseClock()
+ rule.mainClock.autoAdvance = false
rule.onNode(isToggleable())
// split click into (down) and (move, up) to enforce a composition in between
.performGesture { down(center) }
.performGesture { move(); up() }
- rule.waitForIdle()
-
- rule.clockTestRule.advanceClock(60)
+ rule.mainClock.advanceTimeByFrame()
+ rule.waitForIdle() // Wait for measure
+ rule.mainClock.advanceTimeBy(milliseconds = 80)
assertToggeableAgainstGolden("checkbox_animateToUnchecked")
}
diff --git a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/MaterialRippleThemeTest.kt b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/MaterialRippleThemeTest.kt
index b914986..44923cd 100644
--- a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/MaterialRippleThemeTest.kt
+++ b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/MaterialRippleThemeTest.kt
@@ -49,7 +49,7 @@
import androidx.compose.ui.test.ExperimentalTestApi
import androidx.compose.ui.test.captureToImage
import androidx.compose.ui.test.junit4.ComposeTestRule
-import androidx.compose.ui.test.junit4.createComposeRuleLegacy
+import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.unit.dp
import androidx.test.ext.junit.runners.AndroidJUnit4
@@ -71,9 +71,8 @@
@OptIn(ExperimentalMaterialApi::class, ExperimentalTestApi::class, ExperimentalRippleApi::class)
class MaterialRippleThemeTest {
- @Suppress("DEPRECATION")
@get:Rule
- val rule = createComposeRuleLegacy()
+ val rule = createComposeRule()
@get:Rule
val screenshotRule = AndroidXScreenshotTestRule(GOLDEN_MATERIAL)
@@ -571,14 +570,13 @@
* @param expectedCenterPixelColor the expected color for the pixel at the center of the
* [RippleBox]
*/
- @Suppress("DEPRECATION") // Due to clockTestRule
private fun assertRippleMatches(
interactionState: InteractionState,
interaction: Interaction,
goldenIdentifier: String,
expectedCenterPixelColor: Color
) {
- rule.clockTestRule.pauseClock()
+ rule.mainClock.autoAdvance = false
// Start ripple
rule.runOnUiThread {
@@ -592,7 +590,7 @@
// Advance to somewhere in the middle of the animation for a ripple, or at the end of a
// state layer transition
rule.waitForIdle()
- rule.clockTestRule.advanceClock(50)
+ rule.mainClock.advanceTimeBy(milliseconds = 50)
// Capture and compare screenshots
rule.onNodeWithTag(Tag)
@@ -601,8 +599,7 @@
// Advance until after the end of the ripple animation, so we have a stable final opacity
rule.waitForIdle()
- rule.clockTestRule.advanceClock(50)
- rule.waitForIdle()
+ rule.mainClock.advanceTimeBy(milliseconds = 50)
// Compare expected and actual pixel color
val centerPixel = rule.onNodeWithTag(Tag)
diff --git a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/MaterialTextSelectionColorsScreenshotTest.kt b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/MaterialTextSelectionColorsScreenshotTest.kt
index c6c506b..6cbca52 100644
--- a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/MaterialTextSelectionColorsScreenshotTest.kt
+++ b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/MaterialTextSelectionColorsScreenshotTest.kt
@@ -28,7 +28,7 @@
import androidx.compose.ui.test.captureToImage
import androidx.compose.ui.test.click
import androidx.compose.ui.test.height
-import androidx.compose.ui.test.junit4.createComposeRuleLegacy
+import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.longClick
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.onNodeWithText
@@ -55,9 +55,8 @@
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.O)
class MaterialTextSelectionColorsScreenshotTest {
- @Suppress("DEPRECATION")
@get:Rule
- val rule = createComposeRuleLegacy()
+ val rule = createComposeRule()
@get:Rule
val screenshotRule = AndroidXScreenshotTestRule(GOLDEN_MATERIAL)
diff --git a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/RadioButtonScreenshotTest.kt b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/RadioButtonScreenshotTest.kt
index 03897529..2ee0ce4 100644
--- a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/RadioButtonScreenshotTest.kt
+++ b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/RadioButtonScreenshotTest.kt
@@ -30,7 +30,7 @@
import androidx.compose.ui.test.center
import androidx.compose.ui.test.down
import androidx.compose.ui.test.isSelectable
-import androidx.compose.ui.test.junit4.createComposeRuleLegacy
+import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.move
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.performGesture
@@ -49,9 +49,8 @@
@OptIn(ExperimentalTestApi::class)
class RadioButtonScreenshotTest {
- @Suppress("DEPRECATION")
@get:Rule
- val rule = createComposeRuleLegacy()
+ val rule = createComposeRule()
@get:Rule
val screenshotRule = AndroidXScreenshotTestRule(GOLDEN_MATERIAL)
@@ -116,7 +115,6 @@
}
@Test
- @Suppress("DEPRECATION") // Due to clockTestRule
fun radioButton_notSelected_animateToSelected() {
rule.setMaterialContent {
val isSelected = remember { mutableStateOf(false) }
@@ -128,22 +126,21 @@
}
}
- rule.clockTestRule.pauseClock()
+ rule.mainClock.autoAdvance = false
rule.onNode(isSelectable())
// split click into (down) and (move, up) to enforce a composition in between
.performGesture { down(center) }
.performGesture { move(); up() }
- rule.waitForIdle()
-
- rule.clockTestRule.advanceClock(60)
+ rule.mainClock.advanceTimeByFrame()
+ rule.waitForIdle() // Wait for measure
+ rule.mainClock.advanceTimeBy(milliseconds = 80)
assertSelectableAgainstGolden("radioButton_animateToSelected")
}
@Test
- @Suppress("DEPRECATION") // Due to clockTestRule
fun radioButton_selected_animateToNotSelected() {
rule.setMaterialContent {
val isSelected = remember { mutableStateOf(true) }
@@ -155,16 +152,16 @@
}
}
- rule.clockTestRule.pauseClock()
+ rule.mainClock.autoAdvance = false
rule.onNode(isSelectable())
// split click into (down) and (move, up) to enforce a composition in between
.performGesture { down(center) }
.performGesture { move(); up() }
- rule.waitForIdle()
-
- rule.clockTestRule.advanceClock(60)
+ rule.mainClock.advanceTimeByFrame()
+ rule.waitForIdle() // Wait for measure
+ rule.mainClock.advanceTimeBy(milliseconds = 80)
assertSelectableAgainstGolden("radioButton_animateToNotSelected")
}
diff --git a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/ScaffoldScreenshotTest.kt b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/ScaffoldScreenshotTest.kt
index b97b2d0..0deb853 100644
--- a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/ScaffoldScreenshotTest.kt
+++ b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/ScaffoldScreenshotTest.kt
@@ -34,7 +34,7 @@
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.test.captureToImage
-import androidx.compose.ui.test.junit4.createComposeRuleLegacy
+import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.unit.LayoutDirection
import androidx.test.ext.junit.runners.AndroidJUnit4
@@ -51,9 +51,8 @@
@OptIn(ExperimentalMaterialApi::class)
class ScaffoldScreenshotTest {
- @Suppress("DEPRECATION")
@get:Rule
- val composeTestRule = createComposeRuleLegacy()
+ val composeTestRule = createComposeRule()
@get:Rule
val screenshotRule = AndroidXScreenshotTestRule(GOLDEN_MATERIAL)
diff --git a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/SliderScreenshotTest.kt b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/SliderScreenshotTest.kt
index 8b3393f..9bc7687 100644
--- a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/SliderScreenshotTest.kt
+++ b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/SliderScreenshotTest.kt
@@ -30,7 +30,7 @@
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.test.captureToImage
-import androidx.compose.ui.test.junit4.createComposeRuleLegacy
+import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.unit.dp
import androidx.test.ext.junit.runners.AndroidJUnit4
@@ -46,9 +46,8 @@
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.O)
class SliderScreenshotTest {
- @Suppress("DEPRECATION")
@get:Rule
- val rule = createComposeRuleLegacy()
+ val rule = createComposeRule()
@get:Rule
val screenshotRule = AndroidXScreenshotTestRule(GOLDEN_MATERIAL)
diff --git a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/SnackbarHostTest.kt b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/SnackbarHostTest.kt
index 6bff44b..87ef7af 100644
--- a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/SnackbarHostTest.kt
+++ b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/SnackbarHostTest.kt
@@ -19,7 +19,7 @@
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.rememberCoroutineScope
-import androidx.compose.ui.test.junit4.createComposeRuleLegacy
+import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performClick
import androidx.test.ext.junit.runners.AndroidJUnit4
@@ -30,7 +30,6 @@
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
-import kotlinx.coroutines.runBlocking
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
@@ -41,9 +40,8 @@
@OptIn(ExperimentalMaterialApi::class)
class SnackbarHostTest {
- @Suppress("DEPRECATION")
@get:Rule
- val rule = createComposeRuleLegacy()
+ val rule = createComposeRule()
@Test
fun snackbarHost_observePushedData() {
@@ -67,9 +65,8 @@
hostState.showSnackbar("3")
Truth.assertThat(resultedInvocation).isEqualTo("123")
}
- runBlocking {
- job.join()
- }
+
+ rule.waitUntil { job.isCompleted }
}
@Test
@@ -96,9 +93,8 @@
hostState.showSnackbar(it.toString())
}
}
- runBlocking {
- parent.children.forEach { it.join() }
- }
+
+ rule.waitUntil { parent.children.all { it.isCompleted } }
Truth.assertThat(resultedInvocation).isEqualTo("0123456789")
}
@@ -119,9 +115,9 @@
}
rule.onNodeWithText("press")
.performClick()
- runBlocking {
- job1.join()
- }
+
+ rule.waitUntil { job1.isCompleted }
+
val job2 = scope.launch {
val result = hostState.showSnackbar(
message = "1",
@@ -129,9 +125,8 @@
)
Truth.assertThat(result).isEqualTo(SnackbarResult.Dismissed)
}
- runBlocking {
- job2.join()
- }
+
+ rule.waitUntil(timeoutMillis = 5_000) { job2.isCompleted }
}
@Test
@@ -155,9 +150,7 @@
delay(10)
switchState.value = false
}
- runBlocking {
- job2.join()
- job1.join()
- }
+
+ rule.waitUntil { job1.isCompleted && job2.isCompleted }
}
}
\ No newline at end of file
diff --git a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/SwitchScreenshotTest.kt b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/SwitchScreenshotTest.kt
index 482751f..a4cf2ab 100644
--- a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/SwitchScreenshotTest.kt
+++ b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/SwitchScreenshotTest.kt
@@ -34,7 +34,7 @@
import androidx.compose.ui.test.center
import androidx.compose.ui.test.down
import androidx.compose.ui.test.isToggleable
-import androidx.compose.ui.test.junit4.createComposeRuleLegacy
+import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.move
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.performGesture
@@ -55,9 +55,8 @@
@OptIn(ExperimentalTestApi::class)
class SwitchScreenshotTest {
- @Suppress("DEPRECATION")
@get:Rule
- val rule = createComposeRuleLegacy()
+ val rule = createComposeRule()
@get:Rule
val screenshotRule = AndroidXScreenshotTestRule(GOLDEN_MATERIAL)
@@ -173,7 +172,6 @@
}
@Test
- @Suppress("DEPRECATION") // Due to clockTestRule
fun switchTest_unchecked_animateToChecked() {
rule.setMaterialContent {
val isChecked = remember { mutableStateOf(false) }
@@ -185,7 +183,7 @@
}
}
- rule.clockTestRule.pauseClock()
+ rule.mainClock.autoAdvance = false
rule.onNode(isToggleable())
// split click into (down) and (move, up) to enforce a composition in between
@@ -193,8 +191,7 @@
.performGesture { move(); up() }
rule.waitForIdle()
-
- rule.clockTestRule.advanceClock(60)
+ rule.mainClock.advanceTimeBy(milliseconds = 96)
assertToggeableAgainstGolden("switch_animateToChecked")
}
@@ -212,7 +209,7 @@
}
}
- rule.clockTestRule.pauseClock()
+ rule.mainClock.autoAdvance = false
rule.onNode(isToggleable())
// split click into (down) and (move, up) to enforce a composition in between
@@ -220,8 +217,7 @@
.performGesture { move(); up() }
rule.waitForIdle()
-
- rule.clockTestRule.advanceClock(60)
+ rule.mainClock.advanceTimeBy(milliseconds = 96)
assertToggeableAgainstGolden("switch_animateToUnchecked")
}
diff --git a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/TabScreenshotTest.kt b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/TabScreenshotTest.kt
index 3e9f5b5..778b0ba 100644
--- a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/TabScreenshotTest.kt
+++ b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/TabScreenshotTest.kt
@@ -29,7 +29,7 @@
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.test.ExperimentalTestApi
import androidx.compose.ui.test.captureToImage
-import androidx.compose.ui.test.junit4.createComposeRuleLegacy
+import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithTag
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.LargeTest
@@ -45,9 +45,8 @@
@OptIn(ExperimentalMaterialApi::class, ExperimentalTestApi::class)
class TabScreenshotTest {
- @Suppress("DEPRECATION")
@get:Rule
- val composeTestRule = createComposeRuleLegacy()
+ val composeTestRule = createComposeRule()
@get:Rule
val screenshotRule = AndroidXScreenshotTestRule(GOLDEN_MATERIAL)
@@ -272,13 +271,12 @@
* @param interaction the [Interaction] to assert for, or `null` if no [Interaction].
* @param goldenIdentifier the identifier for the corresponding screenshot
*/
- @Suppress("DEPRECATION") // Due to clockTestRule
private fun assertTabsMatch(
interactionState: InteractionState,
interaction: Interaction? = null,
goldenIdentifier: String
) {
- composeTestRule.clockTestRule.pauseClock()
+ composeTestRule.mainClock.autoAdvance = false
if (interaction != null) {
// Start ripple
@@ -292,7 +290,7 @@
// Advance to somewhere in the middle of the animation for the ripple
composeTestRule.waitForIdle()
- composeTestRule.clockTestRule.advanceClock(50)
+ composeTestRule.mainClock.advanceTimeBy(milliseconds = 50)
}
// Capture and compare screenshots
diff --git a/compose/runtime/runtime/api/current.txt b/compose/runtime/runtime/api/current.txt
index d190676..8bba67c 100644
--- a/compose/runtime/runtime/api/current.txt
+++ b/compose/runtime/runtime/api/current.txt
@@ -156,9 +156,9 @@
method @androidx.compose.runtime.ExperimentalComposeApi public static androidx.compose.runtime.Composition compositionFor(Object key, androidx.compose.runtime.Applier<?> applier, androidx.compose.runtime.CompositionReference parent, optional kotlin.jvm.functions.Function0<kotlin.Unit> onCreated);
}
- public interface CompositionLifecycleObserver {
- method public default void onEnter();
- method public default void onLeave();
+ @Deprecated public interface CompositionLifecycleObserver {
+ method @Deprecated public default void onEnter();
+ method @Deprecated public default void onLeave();
}
public abstract class CompositionReference {
@@ -347,6 +347,12 @@
method @androidx.compose.runtime.Composable public static inline <T> androidx.compose.runtime.State<T> rememberUpdatedState(T? newValue);
}
+ public interface RememberObserver {
+ method public void onAbandoned();
+ method public void onForgotten();
+ method public void onRemembered();
+ }
+
@androidx.compose.runtime.ComposeCompilerApi public interface ScopeUpdateScope {
method public void updateScope(kotlin.jvm.functions.Function2<? super androidx.compose.runtime.Composer<?>,? super java.lang.Integer,kotlin.Unit> block);
}
diff --git a/compose/runtime/runtime/api/public_plus_experimental_current.txt b/compose/runtime/runtime/api/public_plus_experimental_current.txt
index d190676..8bba67c 100644
--- a/compose/runtime/runtime/api/public_plus_experimental_current.txt
+++ b/compose/runtime/runtime/api/public_plus_experimental_current.txt
@@ -156,9 +156,9 @@
method @androidx.compose.runtime.ExperimentalComposeApi public static androidx.compose.runtime.Composition compositionFor(Object key, androidx.compose.runtime.Applier<?> applier, androidx.compose.runtime.CompositionReference parent, optional kotlin.jvm.functions.Function0<kotlin.Unit> onCreated);
}
- public interface CompositionLifecycleObserver {
- method public default void onEnter();
- method public default void onLeave();
+ @Deprecated public interface CompositionLifecycleObserver {
+ method @Deprecated public default void onEnter();
+ method @Deprecated public default void onLeave();
}
public abstract class CompositionReference {
@@ -347,6 +347,12 @@
method @androidx.compose.runtime.Composable public static inline <T> androidx.compose.runtime.State<T> rememberUpdatedState(T? newValue);
}
+ public interface RememberObserver {
+ method public void onAbandoned();
+ method public void onForgotten();
+ method public void onRemembered();
+ }
+
@androidx.compose.runtime.ComposeCompilerApi public interface ScopeUpdateScope {
method public void updateScope(kotlin.jvm.functions.Function2<? super androidx.compose.runtime.Composer<?>,? super java.lang.Integer,kotlin.Unit> block);
}
diff --git a/compose/runtime/runtime/api/restricted_current.txt b/compose/runtime/runtime/api/restricted_current.txt
index 1314909..f427065 100644
--- a/compose/runtime/runtime/api/restricted_current.txt
+++ b/compose/runtime/runtime/api/restricted_current.txt
@@ -122,6 +122,7 @@
method @androidx.compose.runtime.ComposeCompilerApi public void startReplaceableGroup(int key, String? sourceInformation);
method @androidx.compose.runtime.ComposeCompilerApi public void startRestartGroup(int key);
method @androidx.compose.runtime.ComposeCompilerApi public void startRestartGroup(int key, String? sourceInformation);
+ method @kotlin.PublishedApi internal void updateCachedValue(Object? value);
method @kotlin.PublishedApi internal void updateValue(Object? value);
method @kotlin.PublishedApi internal void useNode();
method @androidx.compose.runtime.InternalComposeApi public void verifyConsistent();
@@ -177,9 +178,9 @@
method @androidx.compose.runtime.ExperimentalComposeApi public static androidx.compose.runtime.Composition compositionFor(Object key, androidx.compose.runtime.Applier<?> applier, androidx.compose.runtime.CompositionReference parent, optional kotlin.jvm.functions.Function0<kotlin.Unit> onCreated);
}
- public interface CompositionLifecycleObserver {
- method public default void onEnter();
- method public default void onLeave();
+ @Deprecated public interface CompositionLifecycleObserver {
+ method @Deprecated public default void onEnter();
+ method @Deprecated public default void onLeave();
}
public abstract class CompositionReference {
@@ -188,9 +189,12 @@
public final class CompositionReferenceKt {
}
- @kotlin.PublishedApi internal final class CompositionScopedCoroutineScopeCanceller implements androidx.compose.runtime.CompositionLifecycleObserver {
+ @kotlin.PublishedApi internal final class CompositionScopedCoroutineScopeCanceller implements androidx.compose.runtime.RememberObserver {
ctor public CompositionScopedCoroutineScopeCanceller(kotlinx.coroutines.CoroutineScope coroutineScope);
method public kotlinx.coroutines.CoroutineScope getCoroutineScope();
+ method public void onAbandoned();
+ method public void onForgotten();
+ method public void onRemembered();
property public final kotlinx.coroutines.CoroutineScope coroutineScope;
}
@@ -309,9 +313,12 @@
property public final boolean isPaused;
}
- @kotlin.PublishedApi internal final class PreCommitScopeImpl implements androidx.compose.runtime.CommitScope androidx.compose.runtime.CompositionLifecycleObserver {
+ @kotlin.PublishedApi internal final class PreCommitScopeImpl implements androidx.compose.runtime.CommitScope androidx.compose.runtime.RememberObserver {
ctor public PreCommitScopeImpl(kotlin.jvm.functions.Function1<? super androidx.compose.runtime.CommitScope,kotlin.Unit> onCommit);
+ method public void onAbandoned();
method public void onDispose(kotlin.jvm.functions.Function0<kotlin.Unit> callback);
+ method public void onForgotten();
+ method public void onRemembered();
}
public final class ProduceStateKt {
@@ -380,6 +387,12 @@
method @androidx.compose.runtime.Composable public static inline <T> androidx.compose.runtime.State<T> rememberUpdatedState(T? newValue);
}
+ public interface RememberObserver {
+ method public void onAbandoned();
+ method public void onForgotten();
+ method public void onRemembered();
+ }
+
@androidx.compose.runtime.ComposeCompilerApi public interface ScopeUpdateScope {
method public void updateScope(kotlin.jvm.functions.Function2<? super androidx.compose.runtime.Composer<?>,? super java.lang.Integer,kotlin.Unit> block);
}
diff --git a/compose/runtime/runtime/integration-tests/src/androidAndroidTest/kotlin/androidx/compose/runtime/FlowAdapterTest.kt b/compose/runtime/runtime/integration-tests/src/androidAndroidTest/kotlin/androidx/compose/runtime/FlowAdapterTest.kt
index 7dbfdd0..579ca44 100644
--- a/compose/runtime/runtime/integration-tests/src/androidAndroidTest/kotlin/androidx/compose/runtime/FlowAdapterTest.kt
+++ b/compose/runtime/runtime/integration-tests/src/androidAndroidTest/kotlin/androidx/compose/runtime/FlowAdapterTest.kt
@@ -30,8 +30,6 @@
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
-import java.util.concurrent.CountDownLatch
-import java.util.concurrent.TimeUnit
import kotlin.coroutines.CoroutineContext
@LargeTest
@@ -214,25 +212,18 @@
@Test
fun observingOnCustomContext() {
val stream = FlowChannel<String>()
- val latch = CountDownLatch(1)
var realValue: String? = null
rule.setContent {
realValue = stream.flow.collectAsState(null, Dispatchers.Default).value
- if (realValue != null) {
- latch.countDown()
- }
}
- rule.runOnIdle {
+ rule.runOnUiThread {
stream.channel.offer("value")
}
- assertThat(latch.await(5, TimeUnit.SECONDS)).isTrue()
-
- rule.runOnIdle {
- assertThat(realValue).isEqualTo("value")
- }
+ rule.waitUntil { realValue != null }
+ assertThat(realValue).isEqualTo("value")
}
@Test
diff --git a/compose/runtime/runtime/integration-tests/src/androidAndroidTest/kotlin/androidx/compose/runtime/SideEffectTests.kt b/compose/runtime/runtime/integration-tests/src/androidAndroidTest/kotlin/androidx/compose/runtime/SideEffectTests.kt
index bac8cd7..b76cf87 100644
--- a/compose/runtime/runtime/integration-tests/src/androidAndroidTest/kotlin/androidx/compose/runtime/SideEffectTests.kt
+++ b/compose/runtime/runtime/integration-tests/src/androidAndroidTest/kotlin/androidx/compose/runtime/SideEffectTests.kt
@@ -32,6 +32,7 @@
import kotlin.test.assertNotNull
import kotlin.test.assertSame
import kotlin.test.assertTrue
+import kotlin.test.fail
@Suppress("UNUSED_VARIABLE")
@MediumTest
@@ -77,17 +78,21 @@
*/
@Test
fun testSideEffectsRunAfterLifecycleObservers() {
- class MyObserver : CompositionLifecycleObserver {
+ class MyObserver : RememberObserver {
var isPresent: Boolean = false
private set
- override fun onEnter() {
+ override fun onRemembered() {
isPresent = true
}
- override fun onLeave() {
+ override fun onForgotten() {
isPresent = false
}
+
+ override fun onAbandoned() {
+ fail("Unexpected call to onAbandoned")
+ }
}
val myObserverOne = MyObserver()
diff --git a/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/Composer.kt b/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/Composer.kt
index f4e409d..cb55e3c 100644
--- a/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/Composer.kt
+++ b/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/Composer.kt
@@ -29,7 +29,7 @@
internal typealias Change<N> = (
applier: Applier<N>,
slots: SlotWriter,
- lifecycleManager: LifecycleManager
+ rememberManager: RememberManager
) -> Unit
private class GroupInfo(
@@ -50,9 +50,11 @@
var nodeCount: Int
)
-internal interface LifecycleManager {
- fun entering(instance: CompositionLifecycleObserver)
- fun leaving(instance: CompositionLifecycleObserver)
+internal interface RememberManager {
+ fun entering(@Suppress("DEPRECATION") instance: CompositionLifecycleObserver)
+ fun leaving(@Suppress("DEPRECATION") instance: CompositionLifecycleObserver)
+ fun remembering(instance: RememberObserver)
+ fun forgetting(instance: RememberObserver)
fun sideEffect(effect: () -> Unit)
}
@@ -366,6 +368,7 @@
CompositionLifecycleObserverHolder,
CompositionLifecycleObserverHolder
>()
+ private val abandonSet = HashSet<RememberObserver>()
private val pendingStack = Stack<Pending?>()
private var pending: Pending? = null
private var nodeIndex: Int = 0
@@ -725,21 +728,23 @@
}
/**
- * Helper for collecting lifecycle enter and leave events for later strictly ordered dispatch.
- * [lifecycleObservers] should be the long-lived set of observers tracked over time; brand new
- * additions or leaves from this set will be tracked by the [LifecycleManager] callback methods.
- * Call [dispatchLifecycleObservers] to invoke the observers in LIFO order - last in,
- * first out.
+ * Helper for collecting remember observers for later strictly ordered dispatch.
+ *
+ * This includes support for the deprecated [CompositionLifecycleObserver] which should be
+ * removed with it.
*/
- private class LifecycleEventDispatcher(
+ private class RememberEventDispatcher(
private val lifecycleObservers: MutableMap<CompositionLifecycleObserverHolder,
- CompositionLifecycleObserverHolder>
- ) : LifecycleManager {
+ CompositionLifecycleObserverHolder>,
+ private val abandoning: MutableSet<RememberObserver>
+ ) : RememberManager {
private val enters = mutableSetOf<CompositionLifecycleObserverHolder>()
private val leaves = mutableSetOf<CompositionLifecycleObserverHolder>()
+ private val remembering = mutableListOf<RememberObserver>()
+ private val forgetting = mutableListOf<RememberObserver>()
private val sideEffects = mutableListOf<() -> Unit>()
- override fun entering(instance: CompositionLifecycleObserver) {
+ override fun entering(@Suppress("DEPRECATION") instance: CompositionLifecycleObserver) {
val holder = CompositionLifecycleObserverHolder(instance)
lifecycleObservers.getOrPut(holder) {
enters.add(holder)
@@ -747,7 +752,7 @@
}.apply { count++ }
}
- override fun leaving(instance: CompositionLifecycleObserver) {
+ override fun leaving(@Suppress("DEPRECATION") instance: CompositionLifecycleObserver) {
val holder = CompositionLifecycleObserverHolder(instance)
val left = lifecycleObservers[holder]?.let {
if (--it.count == 0) {
@@ -758,6 +763,28 @@
if (left != null) lifecycleObservers.remove(left)
}
+ override fun remembering(instance: RememberObserver) {
+ forgetting.lastIndexOf(instance).let { index ->
+ if (index >= 0) {
+ forgetting.removeAt(index)
+ abandoning.remove(instance)
+ } else {
+ remembering.add(instance)
+ }
+ }
+ }
+
+ override fun forgetting(instance: RememberObserver) {
+ remembering.lastIndexOf(instance).let { index ->
+ if (index >= 0) {
+ remembering.removeAt(index)
+ abandoning.remove(instance)
+ } else {
+ forgetting.add(instance)
+ }
+ }
+ }
+
override fun sideEffect(effect: () -> Unit) {
sideEffects += effect
}
@@ -776,12 +803,28 @@
}
}
+ // Send forgets
+ if (forgetting.isNotEmpty()) {
+ for (instance in forgetting.reversed()) {
+ if (instance !in abandoning)
+ instance.onForgotten()
+ }
+ }
+
// Send lifecycle enters
if (enters.isNotEmpty()) {
for (holder in enters) {
holder.instance.onEnter()
}
}
+
+ // Send remembers
+ if (remembering.isNotEmpty()) {
+ for (instance in remembering) {
+ abandoning.remove(instance)
+ instance.onRemembered()
+ }
+ }
}
fun dispatchSideEffects() {
@@ -792,6 +835,17 @@
sideEffects.clear()
}
}
+
+ fun dispatchAbandons() {
+ if (abandoning.isNotEmpty()) {
+ val iterator = abandoning.iterator()
+ while (iterator.hasNext()) {
+ val instance = iterator.next()
+ iterator.remove()
+ instance.onAbandoned()
+ }
+ }
+ }
}
/**
@@ -806,42 +860,45 @@
invalidations.map { reader.anchor(it.location) to it }
}
- val manager = LifecycleEventDispatcher(lifecycleObservers)
+ val manager = RememberEventDispatcher(lifecycleObservers, abandonSet)
+ try {
+ applier.onBeginChanges()
- applier.onBeginChanges()
-
- // Apply all changes
- slotTable.write { slots ->
- val applier = applier
- changes.forEach { change ->
- change(applier, slots, manager)
+ // Apply all changes
+ slotTable.write { slots ->
+ val applier = applier
+ changes.forEach { change ->
+ change(applier, slots, manager)
+ }
+ changes.clear()
}
- changes.clear()
- }
- applier.onEndChanges()
+ applier.onEndChanges()
- providerUpdates.clear()
+ providerUpdates.clear()
- @Suppress("ReplaceManualRangeWithIndicesCalls") // Avoids allocation of an iterator
- for (index in 0 until invalidationAnchors.size) {
- val (anchor, invalidation) = invalidationAnchors[index]
- if (anchor.valid) {
- invalidation.location = anchor.toIndexFor(slotTable)
- } else {
- invalidations.remove(invalidation)
+ @Suppress("ReplaceManualRangeWithIndicesCalls") // Avoids allocation of an iterator
+ for (index in 0 until invalidationAnchors.size) {
+ val (anchor, invalidation) = invalidationAnchors[index]
+ if (anchor.valid) {
+ invalidation.location = anchor.toIndexFor(slotTable)
+ } else {
+ invalidations.remove(invalidation)
+ }
}
- }
- // Side effects run after lifecycle observers so that any remembered objects
- // that implement CompositionLifecycleObserver receive onEnter before a side effect
- // that captured it and operates on it can run.
- manager.dispatchLifecycleObservers()
- manager.dispatchSideEffects()
+ // Side effects run after lifecycle observers so that any remembered objects
+ // that implement CompositionLifecycleObserver receive onEnter before a side effect
+ // that captured it and operates on it can run.
+ manager.dispatchLifecycleObservers()
+ manager.dispatchSideEffects()
- if (pendingInvalidScopes) {
- pendingInvalidScopes = false
- observations.removeValueIf { _, scope -> !scope.valid }
+ if (pendingInvalidScopes) {
+ pendingInvalidScopes = false
+ observations.removeValueIf { _, scope -> !scope.valid }
+ }
+ } finally {
+ manager.dispatchAbandons()
}
}
}
@@ -856,7 +913,7 @@
changes.clear()
applier.clear()
if (slotTable.groupsSize > 0) {
- val manager = LifecycleEventDispatcher(lifecycleObservers)
+ val manager = RememberEventDispatcher(lifecycleObservers, abandonSet)
slotTable.write { writer ->
writer.removeCurrentGroup(manager)
}
@@ -1122,17 +1179,29 @@
internal fun updateValue(value: Any?) {
if (inserting) {
writer.update(value)
+ @Suppress("DEPRECATION")
if (value is CompositionLifecycleObserver) {
record { _, _, lifecycleManager -> lifecycleManager.entering(value) }
}
+ if (value is RememberObserver) {
+ record { _, _, rememberManager -> rememberManager.remembering(value) }
+ }
} else {
val groupSlotIndex = reader.groupSlotIndex - 1
- recordSlotTableOperation(forParent = true) { _, slots, lifecycleManager ->
+ recordSlotTableOperation(forParent = true) { _, slots, rememberManager ->
+ @Suppress("DEPRECATION")
if (value is CompositionLifecycleObserver)
- lifecycleManager.entering(value)
+ rememberManager.entering(value)
+ if (value is RememberObserver) {
+ abandonSet.add(value)
+ rememberManager.remembering(value)
+ }
+ @Suppress("DEPRECATION")
when (val previous = slots.set(groupSlotIndex, value)) {
is CompositionLifecycleObserver ->
- lifecycleManager.leaving(previous)
+ rememberManager.leaving(previous)
+ is RememberObserver ->
+ rememberManager.forgetting(previous)
is RecomposeScope -> {
if (previous.composer != null) {
previous.composer = null
@@ -1144,6 +1213,20 @@
}
}
+ /**
+ * Schedule the current value in the slot table to be updated to [value].
+ *
+ * @param value the value to schedule to be written to the slot table.
+ */
+ @PublishedApi
+ @OptIn(InternalComposeApi::class)
+ internal fun updateCachedValue(value: Any?) {
+ if (inserting && value is RememberObserver) {
+ abandonSet.add(value)
+ }
+ updateValue(value)
+ }
+
@InternalComposeApi
val compositionData: CompositionData get() = slotTable
@@ -1151,7 +1234,7 @@
* Schedule a side effect to run when we apply composition changes.
*/
internal fun recordSideEffect(effect: () -> Unit) {
- record { _, _, lifecycleManager -> lifecycleManager.sideEffect(effect) }
+ record { _, _, rememberManager -> rememberManager.sideEffect(effect) }
}
/**
@@ -2245,10 +2328,10 @@
insertFixups.clear()
realizeUps()
realizeDowns()
- recordSlotEditingOperation { applier, slots, lifecycleManager ->
+ recordSlotEditingOperation { applier, slots, rememberManager ->
insertTable.write { writer ->
for (fixup in fixups) {
- fixup(applier, writer, lifecycleManager)
+ fixup(applier, writer, rememberManager)
}
}
slots.beginInsert()
@@ -2403,7 +2486,7 @@
* that will not have its reference made visible to user code.
*/
// This warning becomes an error if its advice is followed since Composer needs its type param
- @Suppress("RemoveRedundantQualifierName")
+ @Suppress("RemoveRedundantQualifierName", "DEPRECATION")
private class CompositionReferenceHolder<T>(
val ref: Composer<T>.CompositionReferenceImpl
) : CompositionLifecycleObserver {
@@ -2662,7 +2745,7 @@
}
}
-private fun SlotWriter.removeCurrentGroup(lifecycleManager: LifecycleManager) {
+private fun SlotWriter.removeCurrentGroup(rememberManager: RememberManager) {
// Notify the lifecycle manager of any observers leaving the slot table
// The notification order should ensure that listeners are notified of leaving
// in opposite order that they are notified of entering.
@@ -2671,9 +2754,13 @@
// of the group tree, and then call `leaves` in the inverse order.
for (slot in groupSlots()) {
+ @Suppress("DEPRECATION")
when (slot) {
is CompositionLifecycleObserver -> {
- lifecycleManager.leaving(slot)
+ rememberManager.leaving(slot)
+ }
+ is RememberObserver -> {
+ rememberManager.forgetting(slot)
}
is RecomposeScope -> {
val composer = slot.composer
@@ -2953,8 +3040,8 @@
return currentA
}
-private val removeCurrentGroupInstance: Change<*> = { _, slots, lifecycleManager ->
- slots.removeCurrentGroup(lifecycleManager)
+private val removeCurrentGroupInstance: Change<*> = { _, slots, rememberManager ->
+ slots.removeCurrentGroup(rememberManager)
}
private val endGroupInstance: Change<*> = { _, slots, _ -> slots.endGroup() }
diff --git a/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/CompositionLifecycleObserver.kt b/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/CompositionLifecycleObserver.kt
index 56dc3de..130c438 100644
--- a/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/CompositionLifecycleObserver.kt
+++ b/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/CompositionLifecycleObserver.kt
@@ -34,6 +34,10 @@
* multiple threads. Implementations intending to support this use case should implement atomic
* reference counting or a similar strategy to correctly manage resources.
*/
+@Deprecated(
+ message = "CompositionLifecycleObserver is deprecated. Use RememberObserver instead",
+ replaceWith = ReplaceWith("RememberObserver")
+)
interface CompositionLifecycleObserver {
/**
* Called when this object successfully enters a composition.
@@ -54,7 +58,9 @@
*
* The holder can be used as a key for the identity of the instance.
*/
-internal class CompositionLifecycleObserverHolder(val instance: CompositionLifecycleObserver) {
+internal class CompositionLifecycleObserverHolder(
+ @Suppress("DEPRECATION") val instance: CompositionLifecycleObserver
+) {
var count: Int = 0
override fun equals(other: Any?): Boolean =
other is CompositionLifecycleObserverHolder && instance === other.instance
diff --git a/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/Effects.kt b/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/Effects.kt
index 5f2a2b37..59cd4d7 100644
--- a/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/Effects.kt
+++ b/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/Effects.kt
@@ -41,7 +41,7 @@
@PublishedApi
internal class PreCommitScopeImpl(
internal val onCommit: CommitScope.() -> Unit
-) : CommitScope, CompositionLifecycleObserver {
+) : CommitScope, RememberObserver {
internal var disposeCallback = emptyDispose
override fun onDispose(callback: () -> Unit) {
@@ -51,11 +51,15 @@
disposeCallback = callback
}
- override fun onEnter() {
+ override fun onRemembered() {
onCommit(this)
}
- override fun onLeave() {
+ override fun onForgotten() {
+ disposeCallback()
+ }
+
+ override fun onAbandoned() {
disposeCallback()
}
}
diff --git a/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/RememberObserver.kt b/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/RememberObserver.kt
new file mode 100644
index 0000000..f18ff31
--- /dev/null
+++ b/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/RememberObserver.kt
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2021 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.runtime
+
+/**
+ * Objects implementing this interface are notified when they are initially used in a composition
+ * and when they are no longer being used.
+ *
+ * An object is [remembered][onRemembered] by the composition if it is [remember]ed in at least
+ * one place in a composition. Compose may implicitly [remember] an object if doing so is
+ * required to restart the composition later, such as for composable function parameters. An
+ * object is [forgotten][onForgotten] when it is no longer [remember]ed anywhere in that
+ * composition. If a single instance is [remember]ed in more than one location in
+ * the same composition, its [onRemembered] and [onForgotten] will be called for each location in
+ * the composition.
+ *
+ * When objects implementing this interface is remmembered and forgotten together,
+ * the order of [onForgotten] is guaranteed to be called in the opposite order of [onRemembered].
+ * For example, if two objects, A and B are [remember]ed together, A followed by B,
+ * [onRemembered] will be called first on A then on B. If they forgotten together then
+ * [onForgotten] will be called on B first then on A.
+ *
+ * Implementations of [RememberObserver] should generally not expose those object references
+ * outside of their immediate usage sites. A [RememberObserver] reference that is propagated to
+ * multiple parts of a composition might remain present in the composition for longer than
+ * expected if it is remembered (explicitly or implicitly) elsewhere, and a [RememberObserver]
+ * that appears more once can have its callback methods called multiple times in no meaningful
+ * order and on multiple threads.
+ *
+ * An object remembered in only one place in only one composition is guaranteed to,
+ *
+ * 1. have either [onRemembered] or [onAbandoned] called
+ * 2. if [onRemembered] is called, [onForgotten] will eventually be called
+ */
+@Suppress("CallbackName")
+interface RememberObserver {
+ /**
+ * Called when this object is successfully remembered by a composition. This method is called on
+ * the composition's **apply thread.**
+ */
+ fun onRemembered()
+
+ /**
+ * Called when this object is forgotten by a composition. This method is called on the
+ * composition's **apply thread.**
+ */
+ fun onForgotten()
+
+ /**
+ * Called when this object is returned by the callback to `remember` but is not successfully
+ * remembered by a composition.
+ */
+ fun onAbandoned()
+}
\ No newline at end of file
diff --git a/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/SideEffect.kt b/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/SideEffect.kt
index 24580b7..d2f9a7e 100644
--- a/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/SideEffect.kt
+++ b/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/SideEffect.kt
@@ -31,8 +31,8 @@
*
* [effect] will always be run on the composition's apply dispatcher and appliers are never run
* concurrent with themselves, one another, applying changes to the composition tree, or running
- * [CompositionLifecycleObserver] event callbacks. [SideEffect]s are always run after
- * [CompositionLifecycleObserver] event callbacks.
+ * [RememberObserver] event callbacks. [SideEffect]s are always run after [RememberObserver]
+ * event callbacks.
*
* A [SideEffect] runs after **every** recomposition. To launch an ongoing task spanning
* potentially many recompositions, see [LaunchedEffect]. To manage an event subscription or other
@@ -72,17 +72,21 @@
private class DisposableEffectImpl(
private val effect: DisposableEffectScope.() -> DisposableEffectDisposable
-) : CompositionLifecycleObserver {
+) : RememberObserver {
private var onDispose: DisposableEffectDisposable? = null
- override fun onEnter() {
+ override fun onRemembered() {
onDispose = InternalDisposableEffectScope.effect()
}
- override fun onLeave() {
+ override fun onForgotten() {
onDispose?.dispose()
onDispose = null
}
+
+ override fun onAbandoned() {
+ // Nothing to do as [onRemembered] was not called.
+ }
}
private const val DisposableEffectNoParamError =
@@ -129,8 +133,8 @@
* There is guaranteed to be one call to [dispose][DisposableEffectScope.onDispose] for every call
* to [effect]. Both [effect] and [dispose][DisposableEffectScope.onDispose] will always be run
* on the composition's apply dispatcher and appliers are never run concurrent with themselves,
- * one another, applying changes to the composition tree, or running [CompositionLifecycleObserver]
- * event callbacks.
+ * one another, applying changes to the composition tree, or running [RememberObserver] event
+ * callbacks.
*/
@Composable
@ComposableContract(restartable = false)
@@ -168,7 +172,7 @@
* There is guaranteed to be one call to [dispose][DisposableEffectScope.onDispose] for every call
* to [effect]. Both [effect] and [dispose][DisposableEffectScope.onDispose] will always be run
* on the composition's apply dispatcher and appliers are never run concurrent with themselves,
- * one another, applying changes to the composition tree, or running [CompositionLifecycleObserver]
+ * one another, applying changes to the composition tree, or running [RememberObserver]
* event callbacks.
*/
@Composable
@@ -208,8 +212,8 @@
* There is guaranteed to be one call to [dispose][DisposableEffectScope.onDispose] for every call
* to [effect]. Both [effect] and [dispose][DisposableEffectScope.onDispose] will always be run
* on the composition's apply dispatcher and appliers are never run concurrent with themselves,
- * one another, applying changes to the composition tree, or running [CompositionLifecycleObserver]
- * event callbacks.
+ * one another, applying changes to the composition tree, or running [RememberObserver] event
+ * callbacks.
*/
@Composable
@ComposableContract(restartable = false)
@@ -249,8 +253,8 @@
* There is guaranteed to be one call to [dispose][DisposableEffectScope.onDispose] for every call
* to [effect]. Both [effect] and [dispose][DisposableEffectScope.onDispose] will always be run
* on the composition's apply dispatcher and appliers are never run concurrent with themselves,
- * one another, applying changes to the composition tree, or running [CompositionLifecycleObserver]
- * event callbacks.
+ * one another, applying changes to the composition tree, or running [RememberObserver] event
+ * callbacks.
*/
@Composable
@ComposableContract(restartable = false)
@@ -265,17 +269,21 @@
internal class LaunchedEffectImpl(
parentCoroutineContext: CoroutineContext,
private val task: suspend CoroutineScope.() -> Unit
-) : CompositionLifecycleObserver {
-
+) : RememberObserver {
private val scope = CoroutineScope(parentCoroutineContext)
private var job: Job? = null
- override fun onEnter() {
+ override fun onRemembered() {
job?.cancel("Old job was still running!")
job = scope.launch(block = task)
}
- override fun onLeave() {
+ override fun onForgotten() {
+ job?.cancel()
+ job = null
+ }
+
+ override fun onAbandoned() {
job?.cancel()
job = null
}
diff --git a/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/SuspendingEffects.kt b/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/SuspendingEffects.kt
index 948fe16..8967245 100644
--- a/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/SuspendingEffects.kt
+++ b/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/SuspendingEffects.kt
@@ -27,8 +27,16 @@
@PublishedApi
internal class CompositionScopedCoroutineScopeCanceller(
val coroutineScope: CoroutineScope
-) : CompositionLifecycleObserver {
- override fun onLeave() {
+) : RememberObserver {
+ override fun onRemembered() {
+ // Nothing to do
+ }
+
+ override fun onForgotten() {
+ coroutineScope.cancel()
+ }
+
+ override fun onAbandoned() {
coroutineScope.cancel()
}
}
diff --git a/compose/runtime/runtime/src/test/kotlin/androidx/compose/runtime/CompositionTests.kt b/compose/runtime/runtime/src/test/kotlin/androidx/compose/runtime/CompositionTests.kt
index 2def755..65a9eda 100644
--- a/compose/runtime/runtime/src/test/kotlin/androidx/compose/runtime/CompositionTests.kt
+++ b/compose/runtime/runtime/src/test/kotlin/androidx/compose/runtime/CompositionTests.kt
@@ -1398,16 +1398,20 @@
}
@Test
- fun testLifecycle_Enter_Simple() = compositionTest {
- val lifecycleObject = object : CompositionLifecycleObserver {
+ fun testRememberObserver_Remember_Simple() = compositionTest {
+ val rememberedObject = object : RememberObserver {
var count = 0
- override fun onEnter() {
+ override fun onRemembered() {
count++
}
- override fun onLeave() {
+ override fun onForgotten() {
count--
}
+
+ override fun onAbandoned() {
+ assertEquals(0, count, "onRemember called on an abandon object")
+ }
}
var changed = { }
@@ -1416,7 +1420,7 @@
fun Composition() {
Linear {
changed = invalidate
- remember { lifecycleObject }
+ remember { rememberedObject }
Text("Some text")
}
}
@@ -1432,39 +1436,43 @@
}
validate { this.Composition() }
- assertEquals(1, lifecycleObject.count, "object should have been notified of an enter")
+ assertEquals(1, rememberedObject.count, "object should have been notified of a remember")
changed()
expectNoChanges()
validate { this.Composition() }
- assertEquals(1, lifecycleObject.count, "Object should have only been notified once")
+ assertEquals(1, rememberedObject.count, "Object should have only been notified once")
}
@Test
- fun testLifecycle_Enter_SingleNotification() = compositionTest {
- val lifecycleObject = object : CompositionLifecycleObserver {
+ fun testRememberObserver_Remember_SingleNotification() = compositionTest {
+ val rememberedObject = object : RememberObserver {
var count = 0
- override fun onEnter() {
+ override fun onRemembered() {
count++
}
- override fun onLeave() {
+ override fun onForgotten() {
count--
}
+
+ override fun onAbandoned() {
+ assertEquals(0, count, "onRemember called on an abandon object")
+ }
}
var value by mutableStateOf(0)
@Composable
fun Composition() {
Linear {
- val l = remember { lifecycleObject }
- assertEquals(lifecycleObject, l, "Lifecycle object should be returned")
+ val l = remember { rememberedObject }
+ assertEquals(rememberedObject, l, "remembered object should be returned")
Text("Some text $value")
}
Linear {
- val l = remember { lifecycleObject }
- assertEquals(lifecycleObject, l, "Lifecycle object should be returned")
+ val l = remember { rememberedObject }
+ assertEquals(rememberedObject, l, "remembered object should be returned")
Text("Some other text $value")
}
}
@@ -1483,44 +1491,48 @@
}
validate { this.Composition() }
- assertEquals(1, lifecycleObject.count, "object should have been notified of an enter")
+ assertEquals(2, rememberedObject.count, "object should have been notified remembered twice")
value++
expectChanges()
validate { this.Composition() }
- assertEquals(1, lifecycleObject.count, "Object should have only been notified once")
+ assertEquals(2, rememberedObject.count, "Object should have only been notified twice")
}
@Test
- fun testLifecycle_Leave_Simple() = compositionTest {
- val lifecycleObject = object : CompositionLifecycleObserver {
+ fun testRememberObserver_Forget_Simple() = compositionTest {
+ val rememberObject = object : RememberObserver {
var count = 0
- override fun onEnter() {
+ override fun onRemembered() {
count++
}
- override fun onLeave() {
+ override fun onForgotten() {
count--
}
+
+ override fun onAbandoned() {
+ assertEquals(0, count, "onRemember called on an abandon object")
+ }
}
@Composable
- fun Composition(includeLifecycleObject: Boolean) {
+ fun Composition(includeRememberObject: Boolean) {
Linear {
- if (includeLifecycleObject) {
+ if (includeRememberObject) {
Linear {
- val l = remember { lifecycleObject }
- assertEquals(lifecycleObject, l, "Lifecycle object should be returned")
+ val l = remember { rememberObject }
+ assertEquals(rememberObject, l, "Remember object should be returned")
Text("Some text")
}
}
}
}
- fun MockViewValidator.Composition(includeLifecycleObject: Boolean) {
+ fun MockViewValidator.Composition(includeRememberObject: Boolean) {
Linear {
- if (includeLifecycleObject) {
+ if (includeRememberObject) {
Linear {
Text("Some text")
}
@@ -1536,36 +1548,40 @@
}
validate { this.Composition(true) }
- assertEquals(1, lifecycleObject.count, "object should have been notified of an enter")
+ assertEquals(1, rememberObject.count, "object should have been notified of a remember")
changed()
expectNoChanges()
validate { this.Composition(true) }
- assertEquals(1, lifecycleObject.count, "Object should have only been notified once")
+ assertEquals(1, rememberObject.count, "Object should have only been notified once")
value = false
changed()
expectChanges()
validate { this.Composition(false) }
- assertEquals(0, lifecycleObject.count, "Object should have been notified of a leave")
+ assertEquals(0, rememberObject.count, "Object should have been notified of a forget")
}
@Test
- fun testLifecycle_Leave_NoLeaveOnReenter() = compositionTest {
- var expectedEnter = true
- var expectedLeave = true
- val lifecycleObject = object : CompositionLifecycleObserver {
+ fun testRemember_Forget_NoForgetOnRemember() = compositionTest {
+ var expectedRemember = true
+ var expectedForget = true
+ val rememberObject = object : RememberObserver {
var count = 0
- override fun onEnter() {
- count++
- assertTrue(expectedEnter, "No enter expected")
+ override fun onRemembered() {
+ val remembered = count++ == 0
+ assertTrue(remembered && expectedRemember, "No remember expected")
}
- override fun onLeave() {
- count--
- assertTrue(expectedLeave, "No leave expected")
+ override fun onForgotten() {
+ val forgotten = --count == 0
+ assertTrue(forgotten && expectedForget, "No forget expected")
+ }
+
+ override fun onAbandoned() {
+ assertEquals(0, count, "onAbandon called after onRemember")
}
}
@@ -1575,8 +1591,8 @@
if (a) {
key(1) {
Linear {
- val l = remember { lifecycleObject }
- assertEquals(lifecycleObject, l, "Lifecycle object should be returned")
+ val l = remember { rememberObject }
+ assertEquals(rememberObject, l, "Lifecycle object should be returned")
Text("a")
}
}
@@ -1584,8 +1600,8 @@
if (b) {
key(2) {
Linear {
- val l = remember { lifecycleObject }
- assertEquals(lifecycleObject, l, "Lifecycle object should be returned")
+ val l = remember { rememberObject }
+ assertEquals(rememberObject, l, "Lifecycle object should be returned")
Text("b")
}
}
@@ -1593,8 +1609,8 @@
if (c) {
key(3) {
Linear {
- val l = remember { lifecycleObject }
- assertEquals(lifecycleObject, l, "Lifecycle object should be returned")
+ val l = remember { rememberObject }
+ assertEquals(rememberObject, l, "Lifecycle object should be returned")
Text("c")
}
}
@@ -1622,8 +1638,8 @@
}
}
- expectedEnter = true
- expectedLeave = false
+ expectedRemember = true
+ expectedForget = false
var a = true
var b = false
@@ -1643,12 +1659,12 @@
assertEquals(
1,
- lifecycleObject.count,
+ rememberObject.count,
"object should have been notified of an enter"
)
- expectedEnter = false
- expectedLeave = false
+ expectedRemember = false
+ expectedForget = false
changed()
expectNoChanges()
validate {
@@ -1660,12 +1676,12 @@
}
assertEquals(
1,
- lifecycleObject.count,
+ rememberObject.count,
"Object should have only been notified once"
)
- expectedEnter = false
- expectedLeave = false
+ expectedRemember = false
+ expectedForget = false
a = false
b = true
c = false
@@ -1678,10 +1694,10 @@
c = false
)
}
- assertEquals(1, lifecycleObject.count, "No enter or leaves")
+ assertEquals(1, rememberObject.count, "No enter or leaves")
- expectedEnter = false
- expectedLeave = false
+ expectedRemember = false
+ expectedForget = false
a = false
b = false
c = true
@@ -1694,10 +1710,10 @@
c = true
)
}
- assertEquals(1, lifecycleObject.count, "No enter or leaves")
+ assertEquals(1, rememberObject.count, "No enter or leaves")
- expectedEnter = false
- expectedLeave = false
+ expectedRemember = false
+ expectedForget = false
a = true
b = false
c = false
@@ -1710,10 +1726,10 @@
c = false
)
}
- assertEquals(1, lifecycleObject.count, "No enter or leaves")
+ assertEquals(1, rememberObject.count, "No enter or leaves")
- expectedEnter = false
- expectedLeave = true
+ expectedRemember = false
+ expectedForget = true
a = false
b = false
c = false
@@ -1726,34 +1742,42 @@
c = false
)
}
- assertEquals(0, lifecycleObject.count, "A leave")
+ assertEquals(0, rememberObject.count, "A leave")
}
@Test
- fun testLifecycle_Leave_LeaveOnReplace() = compositionTest {
- val lifecycleObject1 = object : CompositionLifecycleObserver {
+ fun testRemember_Forget_ForgetOnReplace() = compositionTest {
+ val rememberObject1 = object : RememberObserver {
var count = 0
- override fun onEnter() {
+ override fun onRemembered() {
count++
}
- override fun onLeave() {
+ override fun onForgotten() {
count--
}
+
+ override fun onAbandoned() {
+ assertEquals(0, count, "onAbandon called after onRemember")
+ }
}
- val lifecycleObject2 = object : CompositionLifecycleObserver {
+ val rememberObject2 = object : RememberObserver {
var count = 0
- override fun onEnter() {
+ override fun onRemembered() {
count++
}
- override fun onLeave() {
+ override fun onForgotten() {
count--
}
+
+ override fun onAbandoned() {
+ assertEquals(0, count, "onAbandon called after onRemember")
+ }
}
- var lifecycleObject: Any = lifecycleObject1
+ var rememberObject: Any = rememberObject1
var changed = {}
@Composable
@@ -1778,59 +1802,63 @@
compose {
changed = invalidate
- Composition(obj = lifecycleObject)
+ Composition(obj = rememberObject)
}
validate { this.Composition() }
- assertEquals(1, lifecycleObject1.count, "first object should enter")
- assertEquals(0, lifecycleObject2.count, "second object should not have entered")
+ assertEquals(2, rememberObject1.count, "first object should enter")
+ assertEquals(0, rememberObject2.count, "second object should not have entered")
- lifecycleObject = lifecycleObject2
+ rememberObject = rememberObject2
changed()
expectChanges()
validate { Composition() }
- assertEquals(0, lifecycleObject1.count, "first object should have left")
- assertEquals(1, lifecycleObject2.count, "second object should have entered")
+ assertEquals(0, rememberObject1.count, "first object should have left")
+ assertEquals(2, rememberObject2.count, "second object should have entered")
- lifecycleObject = object {}
+ rememberObject = object {}
changed()
expectChanges()
validate { Composition() }
- assertEquals(0, lifecycleObject1.count, "first object should have left")
- assertEquals(0, lifecycleObject2.count, "second object should have left")
+ assertEquals(0, rememberObject1.count, "first object should have left")
+ assertEquals(0, rememberObject2.count, "second object should have left")
}
@Test
- fun testLifecycle_EnterLeaveOrder() = compositionTest {
+ fun testRemember_RememberForgetOrder() = compositionTest {
var order = 0
val objects = mutableListOf<Any>()
- val newLifecycleObject = { name: String ->
+ val newRememberObject = { name: String ->
object :
- CompositionLifecycleObserver,
+ RememberObserver,
Counted,
Ordered,
Named {
override var name = name
override var count = 0
- override var enterOrder = -1
- override var leaveOrder = -1
- override fun onEnter() {
- assertEquals(-1, enterOrder, "Only one call to onEnter expected")
- enterOrder = order++
+ override var rememberOrder = -1
+ override var forgetOrder = -1
+ override fun onRemembered() {
+ assertEquals(-1, rememberOrder, "Only one call to onRemembered expected")
+ rememberOrder = order++
count++
}
- override fun onLeave() {
- assertEquals(-1, leaveOrder, "Only one call to onLeave expected")
- leaveOrder = order++
+ override fun onForgotten() {
+ assertEquals(-1, forgetOrder, "Only one call to onForgotten expected")
+ forgetOrder = order++
count--
}
+
+ override fun onAbandoned() {
+ assertEquals(0, count, "onAbandoned called after onRemembered")
+ }
}.also { objects.add(it) }
}
@Composable
- fun LifecycleUser(name: String) {
+ fun RememberUser(name: String) {
Linear {
- remember(name) { newLifecycleObject(name) }
+ remember(name) { newRememberObject(name) }
Text(value = name)
}
}
@@ -1854,23 +1882,23 @@
@Composable
fun Tree() {
Linear {
- LifecycleUser("A")
+ RememberUser("A")
Linear {
- LifecycleUser("B")
+ RememberUser("B")
Linear {
- LifecycleUser("C")
- LifecycleUser("D")
+ RememberUser("C")
+ RememberUser("D")
}
- LifecycleUser("E")
- LifecycleUser("F")
+ RememberUser("E")
+ RememberUser("F")
Linear {
- LifecycleUser("G")
- LifecycleUser("H")
+ RememberUser("G")
+ RememberUser("H")
Linear {
- LifecycleUser("I")
+ RememberUser("I")
}
}
- LifecycleUser("J")
+ RememberUser("J")
}
}
}
@@ -1904,7 +1932,7 @@
assertArrayEquals(
"Expected enter order",
arrayOf("A", "B", "C", "D", "E", "F", "G", "H", "I", "J"),
- objects.mapNotNull { it as? Ordered }.sortedBy { it.enterOrder }.map {
+ objects.mapNotNull { it as? Ordered }.sortedBy { it.rememberOrder }.map {
(it as Named).name
}.toTypedArray()
)
@@ -1912,7 +1940,7 @@
assertArrayEquals(
"Expected leave order",
arrayOf("J", "I", "H", "G", "F", "E", "D", "C", "B", "A"),
- objects.mapNotNull { it as? Ordered }.sortedBy { it.leaveOrder }.map {
+ objects.mapNotNull { it as? Ordered }.sortedBy { it.forgetOrder }.map {
(it as Named).name
}.toTypedArray()
)
@@ -2473,9 +2501,9 @@
// as the last expression in a unit lambda (the argument to `compose {}`). The remember
// lambda is in turn interpreted as returning Unit, the object expression is dropped
// on the floor for the gc, and Unit is written into the slot table.
- remember<CompositionLifecycleObserver> {
- object : CompositionLifecycleObserver {
- override fun onEnter() {
+ remember<RememberObserver> {
+ object : RememberObserver {
+ override fun onRemembered() {
assertEquals(
1,
myApplier.onBeginChangesCalled,
@@ -2486,7 +2514,15 @@
myApplier.onEndChangesCalled,
"onEndChanges during lifecycle observer"
)
- checks += "CompositionLifecycleObserver"
+ checks += "RememberObserver"
+ }
+
+ override fun onForgotten() {
+ // Nothing to do
+ }
+
+ override fun onAbandoned() {
+ // Nothing to do
}
}
}
@@ -2494,7 +2530,7 @@
assertEquals(
listOf(
"composition",
- "CompositionLifecycleObserver",
+ "RememberObserver",
"SideEffect"
),
checks,
@@ -2713,7 +2749,7 @@
// Read the state here so that the emit removal will invalidate it
stateMutatedOnRemove.value
if (shouldEmitNode) {
- emit<Unit, MutateOnRemoveApplier>({ Unit }) {}
+ emit<Unit, MutateOnRemoveApplier>({ }) {}
}
}
// Initial composition should not contain the node we will remove. We want to test
@@ -2816,8 +2852,8 @@
}
private interface Ordered {
- val enterOrder: Int
- val leaveOrder: Int
+ val rememberOrder: Int
+ val forgetOrder: Int
}
private interface Named {
diff --git a/compose/ui/ui-test-junit4/src/androidMain/kotlin/androidx/compose/ui/test/junit4/AndroidComposeTestRule.kt b/compose/ui/ui-test-junit4/src/androidMain/kotlin/androidx/compose/ui/test/junit4/AndroidComposeTestRule.kt
index 1f46da3..4b54533 100644
--- a/compose/ui/ui-test-junit4/src/androidMain/kotlin/androidx/compose/ui/test/junit4/AndroidComposeTestRule.kt
+++ b/compose/ui/ui-test-junit4/src/androidMain/kotlin/androidx/compose/ui/test/junit4/AndroidComposeTestRule.kt
@@ -22,8 +22,11 @@
import androidx.compose.foundation.text.blinkingCursorEnabled
import androidx.compose.runtime.Composable
import androidx.compose.runtime.Recomposer
+import androidx.compose.ui.InternalComposeUiApi
import androidx.compose.ui.node.Owner
import androidx.compose.ui.platform.ViewRootForTest
+import androidx.compose.ui.platform.WindowRecomposerFactory
+import androidx.compose.ui.platform.WindowRecomposerPolicy
import androidx.compose.ui.platform.setContent
import androidx.compose.ui.test.ExperimentalTestApi
import androidx.compose.ui.test.IdlingResource
@@ -460,6 +463,12 @@
textInputServiceFactory = {
TextInputServiceForTests(it)
}
+ if (recomposer != null) {
+ @OptIn(InternalComposeUiApi::class)
+ WindowRecomposerPolicy.setWindowRecomposerFactory {
+ recomposer
+ }
+ }
base.evaluate()
} finally {
if (driveClockByMonotonicFrameClock) {
@@ -471,6 +480,13 @@
@OptIn(ExperimentalCoroutinesApi::class)
testCoroutineDispatcher?.cleanupTestCoroutines()
}
+ if (recomposer != null) {
+ @Suppress("DEPRECATION")
+ @OptIn(InternalComposeUiApi::class)
+ WindowRecomposerPolicy.setWindowRecomposerFactory(
+ WindowRecomposerFactory.Global
+ )
+ }
@Suppress("DEPRECATION_ERROR")
blinkingCursorEnabled = true
@Suppress("DEPRECATION_ERROR")
diff --git a/compose/ui/ui-test/src/androidAndroidTest/kotlin/androidx/compose/ui/test/gesturescope/SendClickTest.kt b/compose/ui/ui-test/src/androidAndroidTest/kotlin/androidx/compose/ui/test/gesturescope/SendClickTest.kt
index 7584d2e..19bb830 100644
--- a/compose/ui/ui-test/src/androidAndroidTest/kotlin/androidx/compose/ui/test/gesturescope/SendClickTest.kt
+++ b/compose/ui/ui-test/src/androidAndroidTest/kotlin/androidx/compose/ui/test/gesturescope/SendClickTest.kt
@@ -28,7 +28,7 @@
import androidx.test.filters.MediumTest
import androidx.compose.ui.test.junit4.ComposeTestRule
import androidx.compose.ui.test.click
-import androidx.compose.ui.test.junit4.createAndroidComposeRuleLegacy
+import androidx.compose.ui.test.junit4.createAndroidComposeRule
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.performGesture
import androidx.compose.ui.test.util.ClickableTestBox
@@ -85,9 +85,8 @@
}
}
- @Suppress("DEPRECATION") // Needed because this test is setting its own content.
@get:Rule
- val rule = createAndroidComposeRuleLegacy(config.activityClass)
+ val rule = createAndroidComposeRule(config.activityClass)
private val recordedClicks = mutableListOf<ClickData>()
private val expectedClickPosition =
diff --git a/compose/ui/ui-text/api/current.txt b/compose/ui/ui-text/api/current.txt
index 999786b..2d42bdb 100644
--- a/compose/ui/ui-text/api/current.txt
+++ b/compose/ui/ui-text/api/current.txt
@@ -718,6 +718,9 @@
method public void applyTo(androidx.compose.ui.text.input.EditingBuffer buffer);
}
+ public final class EditCommandKt {
+ }
+
public final class EditingBuffer {
field public static final int NOWHERE = -1; // 0xffffffff
}
@@ -889,14 +892,11 @@
}
public final class TransformedText {
- ctor public TransformedText(androidx.compose.ui.text.AnnotatedString transformedText, androidx.compose.ui.text.input.OffsetMapping offsetMapping);
- method public androidx.compose.ui.text.AnnotatedString component1();
- method public androidx.compose.ui.text.input.OffsetMapping component2();
- method public androidx.compose.ui.text.input.TransformedText copy(androidx.compose.ui.text.AnnotatedString transformedText, androidx.compose.ui.text.input.OffsetMapping offsetMapping);
+ ctor public TransformedText(androidx.compose.ui.text.AnnotatedString text, androidx.compose.ui.text.input.OffsetMapping offsetMapping);
method public androidx.compose.ui.text.input.OffsetMapping getOffsetMapping();
- method public androidx.compose.ui.text.AnnotatedString getTransformedText();
+ method public androidx.compose.ui.text.AnnotatedString getText();
property public final androidx.compose.ui.text.input.OffsetMapping offsetMapping;
- property public final androidx.compose.ui.text.AnnotatedString transformedText;
+ property public final androidx.compose.ui.text.AnnotatedString text;
}
@androidx.compose.runtime.Immutable public fun interface VisualTransformation {
@@ -937,10 +937,8 @@
ctor public LocaleList(java.util.List<androidx.compose.ui.text.intl.Locale> localeList);
ctor public LocaleList(String languageTags);
ctor public LocaleList(androidx.compose.ui.text.intl.Locale... locales);
- method public java.util.List<androidx.compose.ui.text.intl.Locale> component1();
method public operator boolean contains(androidx.compose.ui.text.intl.Locale element);
method public boolean containsAll(java.util.Collection<?> elements);
- method @androidx.compose.runtime.Immutable public androidx.compose.ui.text.intl.LocaleList copy(java.util.List<androidx.compose.ui.text.intl.Locale> localeList);
method public operator androidx.compose.ui.text.intl.Locale get(int i);
method public java.util.List<androidx.compose.ui.text.intl.Locale> getLocaleList();
method public int getSize();
diff --git a/compose/ui/ui-text/api/public_plus_experimental_current.txt b/compose/ui/ui-text/api/public_plus_experimental_current.txt
index 999786b..2d42bdb 100644
--- a/compose/ui/ui-text/api/public_plus_experimental_current.txt
+++ b/compose/ui/ui-text/api/public_plus_experimental_current.txt
@@ -718,6 +718,9 @@
method public void applyTo(androidx.compose.ui.text.input.EditingBuffer buffer);
}
+ public final class EditCommandKt {
+ }
+
public final class EditingBuffer {
field public static final int NOWHERE = -1; // 0xffffffff
}
@@ -889,14 +892,11 @@
}
public final class TransformedText {
- ctor public TransformedText(androidx.compose.ui.text.AnnotatedString transformedText, androidx.compose.ui.text.input.OffsetMapping offsetMapping);
- method public androidx.compose.ui.text.AnnotatedString component1();
- method public androidx.compose.ui.text.input.OffsetMapping component2();
- method public androidx.compose.ui.text.input.TransformedText copy(androidx.compose.ui.text.AnnotatedString transformedText, androidx.compose.ui.text.input.OffsetMapping offsetMapping);
+ ctor public TransformedText(androidx.compose.ui.text.AnnotatedString text, androidx.compose.ui.text.input.OffsetMapping offsetMapping);
method public androidx.compose.ui.text.input.OffsetMapping getOffsetMapping();
- method public androidx.compose.ui.text.AnnotatedString getTransformedText();
+ method public androidx.compose.ui.text.AnnotatedString getText();
property public final androidx.compose.ui.text.input.OffsetMapping offsetMapping;
- property public final androidx.compose.ui.text.AnnotatedString transformedText;
+ property public final androidx.compose.ui.text.AnnotatedString text;
}
@androidx.compose.runtime.Immutable public fun interface VisualTransformation {
@@ -937,10 +937,8 @@
ctor public LocaleList(java.util.List<androidx.compose.ui.text.intl.Locale> localeList);
ctor public LocaleList(String languageTags);
ctor public LocaleList(androidx.compose.ui.text.intl.Locale... locales);
- method public java.util.List<androidx.compose.ui.text.intl.Locale> component1();
method public operator boolean contains(androidx.compose.ui.text.intl.Locale element);
method public boolean containsAll(java.util.Collection<?> elements);
- method @androidx.compose.runtime.Immutable public androidx.compose.ui.text.intl.LocaleList copy(java.util.List<androidx.compose.ui.text.intl.Locale> localeList);
method public operator androidx.compose.ui.text.intl.Locale get(int i);
method public java.util.List<androidx.compose.ui.text.intl.Locale> getLocaleList();
method public int getSize();
diff --git a/compose/ui/ui-text/api/restricted_current.txt b/compose/ui/ui-text/api/restricted_current.txt
index 999786b..2d42bdb 100644
--- a/compose/ui/ui-text/api/restricted_current.txt
+++ b/compose/ui/ui-text/api/restricted_current.txt
@@ -718,6 +718,9 @@
method public void applyTo(androidx.compose.ui.text.input.EditingBuffer buffer);
}
+ public final class EditCommandKt {
+ }
+
public final class EditingBuffer {
field public static final int NOWHERE = -1; // 0xffffffff
}
@@ -889,14 +892,11 @@
}
public final class TransformedText {
- ctor public TransformedText(androidx.compose.ui.text.AnnotatedString transformedText, androidx.compose.ui.text.input.OffsetMapping offsetMapping);
- method public androidx.compose.ui.text.AnnotatedString component1();
- method public androidx.compose.ui.text.input.OffsetMapping component2();
- method public androidx.compose.ui.text.input.TransformedText copy(androidx.compose.ui.text.AnnotatedString transformedText, androidx.compose.ui.text.input.OffsetMapping offsetMapping);
+ ctor public TransformedText(androidx.compose.ui.text.AnnotatedString text, androidx.compose.ui.text.input.OffsetMapping offsetMapping);
method public androidx.compose.ui.text.input.OffsetMapping getOffsetMapping();
- method public androidx.compose.ui.text.AnnotatedString getTransformedText();
+ method public androidx.compose.ui.text.AnnotatedString getText();
property public final androidx.compose.ui.text.input.OffsetMapping offsetMapping;
- property public final androidx.compose.ui.text.AnnotatedString transformedText;
+ property public final androidx.compose.ui.text.AnnotatedString text;
}
@androidx.compose.runtime.Immutable public fun interface VisualTransformation {
@@ -937,10 +937,8 @@
ctor public LocaleList(java.util.List<androidx.compose.ui.text.intl.Locale> localeList);
ctor public LocaleList(String languageTags);
ctor public LocaleList(androidx.compose.ui.text.intl.Locale... locales);
- method public java.util.List<androidx.compose.ui.text.intl.Locale> component1();
method public operator boolean contains(androidx.compose.ui.text.intl.Locale element);
method public boolean containsAll(java.util.Collection<?> elements);
- method @androidx.compose.runtime.Immutable public androidx.compose.ui.text.intl.LocaleList copy(java.util.List<androidx.compose.ui.text.intl.Locale> localeList);
method public operator androidx.compose.ui.text.intl.Locale get(int i);
method public java.util.List<androidx.compose.ui.text.intl.Locale> getLocaleList();
method public int getSize();
diff --git a/compose/ui/ui-text/src/commonMain/kotlin/androidx/compose/ui/text/input/EditCommand.kt b/compose/ui/ui-text/src/commonMain/kotlin/androidx/compose/ui/text/input/EditCommand.kt
index 0ef2a5c..278e8ad 100644
--- a/compose/ui/ui-text/src/commonMain/kotlin/androidx/compose/ui/text/input/EditCommand.kt
+++ b/compose/ui/ui-text/src/commonMain/kotlin/androidx/compose/ui/text/input/EditCommand.kt
@@ -18,7 +18,6 @@
import androidx.compose.ui.util.findFollowingBreak
import androidx.compose.ui.util.findPrecedingBreak
-import androidx.compose.ui.util.isSurrogatePair
/**
* [EditCommand] is a command representation for the platform IME API function calls. The
@@ -531,4 +530,11 @@
override fun toString(): String {
return "DeleteAllCommand()"
}
-}
\ No newline at end of file
+}
+
+/**
+ * Helper function that returns true when [high] is a Unicode high-surrogate code unit and [low]
+ * is a Unicode low-surrogate code unit.
+ */
+private fun isSurrogatePair(high: Char, low: Char): Boolean =
+ high.isHighSurrogate() && low.isLowSurrogate()
diff --git a/compose/ui/ui-text/src/commonMain/kotlin/androidx/compose/ui/text/input/VisualTransformation.kt b/compose/ui/ui-text/src/commonMain/kotlin/androidx/compose/ui/text/input/VisualTransformation.kt
index 4049ed2..57358ba 100644
--- a/compose/ui/ui-text/src/commonMain/kotlin/androidx/compose/ui/text/input/VisualTransformation.kt
+++ b/compose/ui/ui-text/src/commonMain/kotlin/androidx/compose/ui/text/input/VisualTransformation.kt
@@ -23,17 +23,35 @@
/**
* The transformed text with offset offset mapping
*/
-data class TransformedText(
+class TransformedText(
/**
* The transformed text
*/
- val transformedText: AnnotatedString,
+ val text: AnnotatedString,
/**
* The map used for bidirectional offset mapping from original to transformed text.
*/
val offsetMapping: OffsetMapping
-)
+) {
+ override fun equals(other: Any?): Boolean {
+ if (this === other) return true
+ if (other !is TransformedText) return false
+ if (text != other.text) return false
+ if (offsetMapping != other.offsetMapping) return false
+ return true
+ }
+
+ override fun hashCode(): Int {
+ var result = text.hashCode()
+ result = 31 * result + offsetMapping.hashCode()
+ return result
+ }
+
+ override fun toString(): String {
+ return "TransformedText(text=$text, offsetMapping=$offsetMapping)"
+ }
+}
/**
* Interface used for changing visual output of the input field.
diff --git a/compose/ui/ui-text/src/commonMain/kotlin/androidx/compose/ui/text/intl/LocaleList.kt b/compose/ui/ui-text/src/commonMain/kotlin/androidx/compose/ui/text/intl/LocaleList.kt
index cba9ea3..e5d8d4a 100644
--- a/compose/ui/ui-text/src/commonMain/kotlin/androidx/compose/ui/text/intl/LocaleList.kt
+++ b/compose/ui/ui-text/src/commonMain/kotlin/androidx/compose/ui/text/intl/LocaleList.kt
@@ -27,7 +27,7 @@
* @see SpanStyle
*/
@Immutable
-data class LocaleList constructor(val localeList: List<Locale>) : Collection<Locale> {
+class LocaleList constructor(val localeList: List<Locale>) : Collection<Locale> {
companion object {
/**
* Returns Locale object which represents current locale
@@ -54,9 +54,28 @@
// Collection overrides for easy iterations.
override val size: Int = localeList.size
+
override operator fun contains(element: Locale): Boolean = localeList.contains(element)
+
override fun containsAll(elements: Collection<Locale>): Boolean =
localeList.containsAll(elements)
+
override fun isEmpty(): Boolean = localeList.isEmpty()
+
override fun iterator(): Iterator<Locale> = localeList.iterator()
+
+ override fun equals(other: Any?): Boolean {
+ if (this === other) return true
+ if (other !is LocaleList) return false
+ if (localeList != other.localeList) return false
+ return true
+ }
+
+ override fun hashCode(): Int {
+ return localeList.hashCode()
+ }
+
+ override fun toString(): String {
+ return "LocaleList(localeList=$localeList)"
+ }
}
diff --git a/compose/ui/ui-text/src/test/java/androidx/compose/ui/text/input/PasswordVisualTransformationTest.kt b/compose/ui/ui-text/src/test/java/androidx/compose/ui/text/input/PasswordVisualTransformationTest.kt
index 6f062f3..b3abc8c 100644
--- a/compose/ui/ui-text/src/test/java/androidx/compose/ui/text/input/PasswordVisualTransformationTest.kt
+++ b/compose/ui/ui-text/src/test/java/androidx/compose/ui/text/input/PasswordVisualTransformationTest.kt
@@ -28,12 +28,14 @@
fun check_visual_output_is_masked_with_asterisk() {
val transformation = PasswordVisualTransformation(mask = '*')
val text = AnnotatedString("12345")
- val (transformedText, map) = transformation.filter(text)
+ val transformedText = transformation.filter(text)
+ val visualText = transformedText.text
+ val offsetMapping = transformedText.offsetMapping
- assertEquals("*****", transformedText.text)
- for (i in 0..transformedText.text.length) {
- assertEquals(i, map.originalToTransformed(i))
- assertEquals(i, map.transformedToOriginal(i))
+ assertEquals("*****", visualText.text)
+ for (i in 0..visualText.text.length) {
+ assertEquals(i, offsetMapping.originalToTransformed(i))
+ assertEquals(i, offsetMapping.transformedToOriginal(i))
}
}
@@ -41,12 +43,14 @@
fun check_visual_output_is_masked_with_default() {
val filter = PasswordVisualTransformation()
val text = AnnotatedString("1234567890")
- val (filtered, map) = filter.filter(text)
+ val transformedText = filter.filter(text)
+ val visualText = transformedText.text
+ val offsetMapping = transformedText.offsetMapping
- assertEquals("\u2022".repeat(10), filtered.text)
- for (i in 0..filtered.text.length) {
- assertEquals(i, map.originalToTransformed(i))
- assertEquals(i, map.transformedToOriginal(i))
+ assertEquals("\u2022".repeat(10), visualText.text)
+ for (i in 0..visualText.text.length) {
+ assertEquals(i, offsetMapping.originalToTransformed(i))
+ assertEquals(i, offsetMapping.transformedToOriginal(i))
}
}
}
\ No newline at end of file
diff --git a/compose/ui/ui-tooling/src/androidTest/java/androidx/compose/ui/tooling/inspector/InlineClassConverterTest.kt b/compose/ui/ui-tooling/src/androidTest/java/androidx/compose/ui/tooling/inspector/InlineClassConverterTest.kt
index 6a035f6..06e692b 100644
--- a/compose/ui/ui-tooling/src/androidTest/java/androidx/compose/ui/tooling/inspector/InlineClassConverterTest.kt
+++ b/compose/ui/ui-tooling/src/androidTest/java/androidx/compose/ui/tooling/inspector/InlineClassConverterTest.kt
@@ -26,6 +26,7 @@
import androidx.compose.ui.tooling.asTree
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.TextUnit
+import androidx.compose.ui.unit.sp
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.MediumTest
import com.google.common.truth.Truth.assertThat
@@ -42,7 +43,7 @@
show {
Inspectable(slotTableRecord) {
Surface {
- Text(text = "OK", fontSize = TextUnit.Sp(12))
+ Text(text = "OK", fontSize = 12.sp)
}
}
}
diff --git a/compose/ui/ui-tooling/src/androidTest/java/androidx/compose/ui/tooling/inspector/OffsetData.kt b/compose/ui/ui-tooling/src/androidTest/java/androidx/compose/ui/tooling/inspector/OffsetData.kt
index 93a8266..8a356b2 100644
--- a/compose/ui/ui-tooling/src/androidTest/java/androidx/compose/ui/tooling/inspector/OffsetData.kt
+++ b/compose/ui/ui-tooling/src/androidTest/java/androidx/compose/ui/tooling/inspector/OffsetData.kt
@@ -32,8 +32,8 @@
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.tooling.preview.Preview
-import androidx.compose.ui.unit.TextUnit
import androidx.compose.ui.unit.dp
+import androidx.compose.ui.unit.sp
/**
* WARNING: Any modification of this *requires* a change to OffsetInformationTest
@@ -53,7 +53,7 @@
style = TextStyle(
color = Color.Magenta,
background = Color.White,
- fontSize = TextUnit.Sp(30)
+ fontSize = 30.sp
)
)
Greeting("Android")
diff --git a/compose/ui/ui-tooling/src/androidTest/java/androidx/compose/ui/tooling/inspector/OffsetInformationTest.kt b/compose/ui/ui-tooling/src/androidTest/java/androidx/compose/ui/tooling/inspector/OffsetInformationTest.kt
index 7c85542..59635c8 100644
--- a/compose/ui/ui-tooling/src/androidTest/java/androidx/compose/ui/tooling/inspector/OffsetInformationTest.kt
+++ b/compose/ui/ui-tooling/src/androidTest/java/androidx/compose/ui/tooling/inspector/OffsetInformationTest.kt
@@ -50,17 +50,17 @@
assertArrayEquals(
arrayListOf(
- "MyComposeTheme" to 1665,
- "Column" to 1690,
- "Text" to 1747,
- "Greeting" to 2000,
- "Text" to 2835,
- "Surface" to 2115,
- "Button" to 2160,
- "Text" to 2183,
- "Surface" to 2032,
- "TextButton" to 2349,
- "Row" to 2490
+ "MyComposeTheme" to 1659,
+ "Column" to 1684,
+ "Text" to 1741,
+ "Greeting" to 1984,
+ "Text" to 2819,
+ "Surface" to 2099,
+ "Button" to 2144,
+ "Text" to 2167,
+ "Surface" to 2016,
+ "TextButton" to 2333,
+ "Row" to 2474
),
offsets
)
diff --git a/compose/ui/ui-tooling/src/androidTest/java/androidx/compose/ui/tooling/inspector/ParameterFactoryTest.kt b/compose/ui/ui-tooling/src/androidTest/java/androidx/compose/ui/tooling/inspector/ParameterFactoryTest.kt
index 0d979b4..b89fcf6 100644
--- a/compose/ui/ui-tooling/src/androidTest/java/androidx/compose/ui/tooling/inspector/ParameterFactoryTest.kt
+++ b/compose/ui/ui-tooling/src/androidTest/java/androidx/compose/ui/tooling/inspector/ParameterFactoryTest.kt
@@ -617,12 +617,12 @@
assertThat(lookup(TextUnit.Unspecified)).isEqualTo(ParameterType.String to "Unspecified")
assertThat(lookup(12.0.sp)).isEqualTo(ParameterType.DimensionSp to 12.0f)
assertThat(lookup(2.0.em)).isEqualTo(ParameterType.DimensionEm to 2.0f)
- assertThat(lookup(TextUnit.Sp(9.0f))).isEqualTo(ParameterType.DimensionSp to 9.0f)
- assertThat(lookup(TextUnit.Sp(10))).isEqualTo(ParameterType.DimensionSp to 10.0f)
- assertThat(lookup(TextUnit.Sp(26.0))).isEqualTo(ParameterType.DimensionSp to 26.0f)
- assertThat(lookup(TextUnit.Em(2.0f))).isEqualTo(ParameterType.DimensionEm to 2.0f)
- assertThat(lookup(TextUnit.Em(1))).isEqualTo(ParameterType.DimensionEm to 1.0f)
- assertThat(lookup(TextUnit.Em(3.0))).isEqualTo(ParameterType.DimensionEm to 3.0f)
+ assertThat(lookup(9.0f.sp)).isEqualTo(ParameterType.DimensionSp to 9.0f)
+ assertThat(lookup(10.sp)).isEqualTo(ParameterType.DimensionSp to 10.0f)
+ assertThat(lookup(26.0.sp)).isEqualTo(ParameterType.DimensionSp to 26.0f)
+ assertThat(lookup(2.0f.em)).isEqualTo(ParameterType.DimensionEm to 2.0f)
+ assertThat(lookup(1.em)).isEqualTo(ParameterType.DimensionEm to 1.0f)
+ assertThat(lookup(3.0.em)).isEqualTo(ParameterType.DimensionEm to 3.0f)
}
@Test
diff --git a/compose/ui/ui-unit/api/current.txt b/compose/ui/ui-unit/api/current.txt
index 2321a9e..911e66d 100644
--- a/compose/ui/ui-unit/api/current.txt
+++ b/compose/ui/ui-unit/api/current.txt
@@ -321,7 +321,7 @@
ctor public TextUnit();
method public static inline operator int compareTo--R2X_6o(long $this, long other);
method public static long constructor-impl(long packedValue);
- method public static inline operator float div--R2X_6o(long $this, long other);
+ method @Deprecated public static inline operator float div--R2X_6o(long $this, long other);
method public static inline operator long div-XSAIIZE(long $this, float other);
method public static inline operator long div-XSAIIZE(long $this, double other);
method public static inline operator long div-XSAIIZE(long $this, int other);
@@ -333,8 +333,8 @@
method @androidx.compose.runtime.Immutable public static inline int hashCode-impl(long p);
method public static boolean isEm-impl(long $this);
method public static boolean isSp-impl(long $this);
- method public static inline operator long minus--R2X_6o(long $this, long other);
- method public static inline operator long plus--R2X_6o(long $this, long other);
+ method @Deprecated public static inline operator long minus--R2X_6o(long $this, long other);
+ method @Deprecated public static inline operator long plus--R2X_6o(long $this, long other);
method public static inline operator long times-XSAIIZE(long $this, float other);
method public static inline operator long times-XSAIIZE(long $this, double other);
method public static inline operator long times-XSAIIZE(long $this, int other);
@@ -345,20 +345,20 @@
}
public static final class TextUnit.Companion {
- method public long Em-XSAIIZE(int value);
- method public long Em-XSAIIZE(float value);
- method public long Em-XSAIIZE(double value);
- method public long Sp-XSAIIZE(int value);
- method public long Sp-XSAIIZE(float value);
- method public long Sp-XSAIIZE(double value);
+ method @Deprecated public long Em-XSAIIZE(int value);
+ method @Deprecated public long Em-XSAIIZE(float value);
+ method @Deprecated public long Em-XSAIIZE(double value);
+ method @Deprecated public long Sp-XSAIIZE(int value);
+ method @Deprecated public long Sp-XSAIIZE(float value);
+ method @Deprecated public long Sp-XSAIIZE(double value);
method public long getUnspecified-XSAIIZE();
property public final long Unspecified;
}
public final class TextUnitKt {
- method @androidx.compose.runtime.Stable public static inline long coerceAtLeast-8E83U4Q(long, long minimumValue);
- method @androidx.compose.runtime.Stable public static inline long coerceAtMost-8E83U4Q(long, long maximumValue);
- method @androidx.compose.runtime.Stable public static inline long coerceIn-HxQ2Pkc(long, long minimumValue, long maximumValue);
+ method @Deprecated @androidx.compose.runtime.Stable public static inline long coerceAtLeast-8E83U4Q(long, long minimumValue);
+ method @Deprecated @androidx.compose.runtime.Stable public static inline long coerceAtMost-8E83U4Q(long, long maximumValue);
+ method @Deprecated @androidx.compose.runtime.Stable public static inline long coerceIn-HxQ2Pkc(long, long minimumValue, long maximumValue);
method public static long getEm(float);
method public static long getEm(double);
method public static long getEm(int);
@@ -367,9 +367,9 @@
method public static long getSp(int);
method public static inline boolean isSpecified--R2X_6o(long);
method public static boolean isUnspecified--R2X_6o(long);
- method @androidx.compose.runtime.Stable public static long lerp-KeuwX78(long a, long b, float t);
- method @androidx.compose.runtime.Stable public static inline long max-8E83U4Q(long a, long b);
- method @androidx.compose.runtime.Stable public static inline long min-8E83U4Q(long a, long b);
+ method @androidx.compose.runtime.Stable public static long lerp-KeuwX78(long start, long stop, float fraction);
+ method @Deprecated @androidx.compose.runtime.Stable public static inline long max-8E83U4Q(long a, long b);
+ method @Deprecated @androidx.compose.runtime.Stable public static inline long min-8E83U4Q(long a, long b);
method public static inline long takeOrElse-bAewZlA(long, kotlin.jvm.functions.Function0<androidx.compose.ui.unit.TextUnit> block);
method @androidx.compose.runtime.Stable public static inline operator long times-0PRCd3Q(double, long other);
method @androidx.compose.runtime.Stable public static inline operator long times-Ew26DjI(float, long other);
diff --git a/compose/ui/ui-unit/api/public_plus_experimental_current.txt b/compose/ui/ui-unit/api/public_plus_experimental_current.txt
index 2321a9e..911e66d 100644
--- a/compose/ui/ui-unit/api/public_plus_experimental_current.txt
+++ b/compose/ui/ui-unit/api/public_plus_experimental_current.txt
@@ -321,7 +321,7 @@
ctor public TextUnit();
method public static inline operator int compareTo--R2X_6o(long $this, long other);
method public static long constructor-impl(long packedValue);
- method public static inline operator float div--R2X_6o(long $this, long other);
+ method @Deprecated public static inline operator float div--R2X_6o(long $this, long other);
method public static inline operator long div-XSAIIZE(long $this, float other);
method public static inline operator long div-XSAIIZE(long $this, double other);
method public static inline operator long div-XSAIIZE(long $this, int other);
@@ -333,8 +333,8 @@
method @androidx.compose.runtime.Immutable public static inline int hashCode-impl(long p);
method public static boolean isEm-impl(long $this);
method public static boolean isSp-impl(long $this);
- method public static inline operator long minus--R2X_6o(long $this, long other);
- method public static inline operator long plus--R2X_6o(long $this, long other);
+ method @Deprecated public static inline operator long minus--R2X_6o(long $this, long other);
+ method @Deprecated public static inline operator long plus--R2X_6o(long $this, long other);
method public static inline operator long times-XSAIIZE(long $this, float other);
method public static inline operator long times-XSAIIZE(long $this, double other);
method public static inline operator long times-XSAIIZE(long $this, int other);
@@ -345,20 +345,20 @@
}
public static final class TextUnit.Companion {
- method public long Em-XSAIIZE(int value);
- method public long Em-XSAIIZE(float value);
- method public long Em-XSAIIZE(double value);
- method public long Sp-XSAIIZE(int value);
- method public long Sp-XSAIIZE(float value);
- method public long Sp-XSAIIZE(double value);
+ method @Deprecated public long Em-XSAIIZE(int value);
+ method @Deprecated public long Em-XSAIIZE(float value);
+ method @Deprecated public long Em-XSAIIZE(double value);
+ method @Deprecated public long Sp-XSAIIZE(int value);
+ method @Deprecated public long Sp-XSAIIZE(float value);
+ method @Deprecated public long Sp-XSAIIZE(double value);
method public long getUnspecified-XSAIIZE();
property public final long Unspecified;
}
public final class TextUnitKt {
- method @androidx.compose.runtime.Stable public static inline long coerceAtLeast-8E83U4Q(long, long minimumValue);
- method @androidx.compose.runtime.Stable public static inline long coerceAtMost-8E83U4Q(long, long maximumValue);
- method @androidx.compose.runtime.Stable public static inline long coerceIn-HxQ2Pkc(long, long minimumValue, long maximumValue);
+ method @Deprecated @androidx.compose.runtime.Stable public static inline long coerceAtLeast-8E83U4Q(long, long minimumValue);
+ method @Deprecated @androidx.compose.runtime.Stable public static inline long coerceAtMost-8E83U4Q(long, long maximumValue);
+ method @Deprecated @androidx.compose.runtime.Stable public static inline long coerceIn-HxQ2Pkc(long, long minimumValue, long maximumValue);
method public static long getEm(float);
method public static long getEm(double);
method public static long getEm(int);
@@ -367,9 +367,9 @@
method public static long getSp(int);
method public static inline boolean isSpecified--R2X_6o(long);
method public static boolean isUnspecified--R2X_6o(long);
- method @androidx.compose.runtime.Stable public static long lerp-KeuwX78(long a, long b, float t);
- method @androidx.compose.runtime.Stable public static inline long max-8E83U4Q(long a, long b);
- method @androidx.compose.runtime.Stable public static inline long min-8E83U4Q(long a, long b);
+ method @androidx.compose.runtime.Stable public static long lerp-KeuwX78(long start, long stop, float fraction);
+ method @Deprecated @androidx.compose.runtime.Stable public static inline long max-8E83U4Q(long a, long b);
+ method @Deprecated @androidx.compose.runtime.Stable public static inline long min-8E83U4Q(long a, long b);
method public static inline long takeOrElse-bAewZlA(long, kotlin.jvm.functions.Function0<androidx.compose.ui.unit.TextUnit> block);
method @androidx.compose.runtime.Stable public static inline operator long times-0PRCd3Q(double, long other);
method @androidx.compose.runtime.Stable public static inline operator long times-Ew26DjI(float, long other);
diff --git a/compose/ui/ui-unit/api/restricted_current.txt b/compose/ui/ui-unit/api/restricted_current.txt
index e632849..cab5fe4 100644
--- a/compose/ui/ui-unit/api/restricted_current.txt
+++ b/compose/ui/ui-unit/api/restricted_current.txt
@@ -321,7 +321,7 @@
ctor public TextUnit();
method public static inline operator int compareTo--R2X_6o(long $this, long other);
method public static long constructor-impl(long packedValue);
- method public static inline operator float div--R2X_6o(long $this, long other);
+ method @Deprecated public static inline operator float div--R2X_6o(long $this, long other);
method public static inline operator long div-XSAIIZE(long $this, float other);
method public static inline operator long div-XSAIIZE(long $this, double other);
method public static inline operator long div-XSAIIZE(long $this, int other);
@@ -333,8 +333,8 @@
method @androidx.compose.runtime.Immutable public static inline int hashCode-impl(long p);
method public static boolean isEm-impl(long $this);
method public static boolean isSp-impl(long $this);
- method public static inline operator long minus--R2X_6o(long $this, long other);
- method public static inline operator long plus--R2X_6o(long $this, long other);
+ method @Deprecated public static inline operator long minus--R2X_6o(long $this, long other);
+ method @Deprecated public static inline operator long plus--R2X_6o(long $this, long other);
method public static inline operator long times-XSAIIZE(long $this, float other);
method public static inline operator long times-XSAIIZE(long $this, double other);
method public static inline operator long times-XSAIIZE(long $this, int other);
@@ -345,12 +345,12 @@
}
public static final class TextUnit.Companion {
- method public long Em-XSAIIZE(int value);
- method public long Em-XSAIIZE(float value);
- method public long Em-XSAIIZE(double value);
- method public long Sp-XSAIIZE(int value);
- method public long Sp-XSAIIZE(float value);
- method public long Sp-XSAIIZE(double value);
+ method @Deprecated public long Em-XSAIIZE(int value);
+ method @Deprecated public long Em-XSAIIZE(float value);
+ method @Deprecated public long Em-XSAIIZE(double value);
+ method @Deprecated public long Sp-XSAIIZE(int value);
+ method @Deprecated public long Sp-XSAIIZE(float value);
+ method @Deprecated public long Sp-XSAIIZE(double value);
method public long getUnspecified-XSAIIZE();
property public final long Unspecified;
}
@@ -359,9 +359,9 @@
method @kotlin.PublishedApi internal static void checkArithmetic--R2X_6o(long a);
method @kotlin.PublishedApi internal static void checkArithmetic-8E83U4Q(long a, long b);
method @kotlin.PublishedApi internal static void checkArithmetic-HxQ2Pkc(long a, long b, long c);
- method @androidx.compose.runtime.Stable public static inline long coerceAtLeast-8E83U4Q(long, long minimumValue);
- method @androidx.compose.runtime.Stable public static inline long coerceAtMost-8E83U4Q(long, long maximumValue);
- method @androidx.compose.runtime.Stable public static inline long coerceIn-HxQ2Pkc(long, long minimumValue, long maximumValue);
+ method @Deprecated @androidx.compose.runtime.Stable public static inline long coerceAtLeast-8E83U4Q(long, long minimumValue);
+ method @Deprecated @androidx.compose.runtime.Stable public static inline long coerceAtMost-8E83U4Q(long, long maximumValue);
+ method @Deprecated @androidx.compose.runtime.Stable public static inline long coerceIn-HxQ2Pkc(long, long minimumValue, long maximumValue);
method public static long getEm(float);
method public static long getEm(double);
method public static long getEm(int);
@@ -370,9 +370,9 @@
method public static long getSp(int);
method public static inline boolean isSpecified--R2X_6o(long);
method public static boolean isUnspecified--R2X_6o(long);
- method @androidx.compose.runtime.Stable public static long lerp-KeuwX78(long a, long b, float t);
- method @androidx.compose.runtime.Stable public static inline long max-8E83U4Q(long a, long b);
- method @androidx.compose.runtime.Stable public static inline long min-8E83U4Q(long a, long b);
+ method @androidx.compose.runtime.Stable public static long lerp-KeuwX78(long start, long stop, float fraction);
+ method @Deprecated @androidx.compose.runtime.Stable public static inline long max-8E83U4Q(long a, long b);
+ method @Deprecated @androidx.compose.runtime.Stable public static inline long min-8E83U4Q(long a, long b);
method @kotlin.PublishedApi internal static inline long pack(long unitType, float v);
method public static inline long takeOrElse-bAewZlA(long, kotlin.jvm.functions.Function0<androidx.compose.ui.unit.TextUnit> block);
method @androidx.compose.runtime.Stable public static inline operator long times-0PRCd3Q(double, long other);
diff --git a/compose/ui/ui-unit/src/commonMain/kotlin/androidx/compose/ui/unit/Density.kt b/compose/ui/ui-unit/src/commonMain/kotlin/androidx/compose/ui/unit/Density.kt
index 5f11ec4..2ba0d4a 100644
--- a/compose/ui/ui-unit/src/commonMain/kotlin/androidx/compose/ui/unit/Density.kt
+++ b/compose/ui/ui-unit/src/commonMain/kotlin/androidx/compose/ui/unit/Density.kt
@@ -75,7 +75,7 @@
* Convert [Dp] to Sp. Sp is used for font size, etc.
*/
@Stable
- fun Dp.toSp(): TextUnit = TextUnit.Sp(value / fontScale)
+ fun Dp.toSp(): TextUnit = (value / fontScale).sp
/**
* Convert Sp to pixels. Pixels are used to paint to Canvas.
diff --git a/compose/ui/ui-unit/src/commonMain/kotlin/androidx/compose/ui/unit/TextUnit.kt b/compose/ui/ui-unit/src/commonMain/kotlin/androidx/compose/ui/unit/TextUnit.kt
index 792b99f..8942598 100644
--- a/compose/ui/ui-unit/src/commonMain/kotlin/androidx/compose/ui/unit/TextUnit.kt
+++ b/compose/ui/ui-unit/src/commonMain/kotlin/androidx/compose/ui/unit/TextUnit.kt
@@ -51,8 +51,10 @@
/**
* The unit used for text related dimension value.
*
- * This unit can hold either scaled pixels (SP), relative font size (em) and special unit for
- * indicating inheriting from other style.
+ * This unit can hold either scaled pixels (SP), relative font size (EM) and special unit
+ * Unspecified for indicating inheriting from other style or using the default value. It can be
+ * created with [sp] or [em]. (e.g. 15.sp or 18.em) which can be applied to [Int], [Double],
+ * and [Float].
*
* Note that do not store this value in your persistent storage or send to another process since
* the internal representation may be changed in future.
@@ -60,24 +62,46 @@
@Suppress("EXPERIMENTAL_FEATURE_WARNING")
@Immutable
inline class TextUnit(val packedValue: Long) {
+ @Deprecated(
+ message = "This function will be removed. Please perform the arithmetic operations " +
+ "before creating the TextUnit.",
+ replaceWith = ReplaceWith(
+ "if(isSp) (value + other.value).sp else (value + other.value).em"
+ )
+ )
/**
* Add two [TextUnit]s together.
*
* This operation works only if all the operands are the same unit type and not they are not
* equal to [TextUnit.Unspecified].
* The result of this operation is the same unit type of the given one.
+ *
+ * @throws IllegalArgumentException if this [TextUnit] and the [other] has different
+ * [TextUnitType]s or either of the two has the [TextUnitType] equals to
+ * [TextUnitType.Unspecified].
*/
inline operator fun plus(other: TextUnit): TextUnit {
checkArithmetic(this, other)
return pack(rawType, value + other.value)
}
+ @Deprecated(
+ message = "This function will be removed. Please perform the arithmetic operations " +
+ "before creating the TextUnit.",
+ replaceWith = ReplaceWith(
+ "if(isSp) (value - other.value).sp else (value - other.value).em"
+ )
+ )
/**
* Subtract a [TextUnit] from another one.
* This operation works only if all the operands are the same unit type and not they are not
* equal to [TextUnit.Unspecified].
* The result of this operation is the same unit type of the given one.
+ *
+ * @throws IllegalArgumentException if this [TextUnit] and the [other] has different
+ * [TextUnitType]s or either of the two has the [TextUnitType] equals to
+ * [TextUnitType.Unspecified].
*/
inline operator fun minus(other: TextUnit): TextUnit {
checkArithmetic(this, other)
@@ -89,6 +113,8 @@
*
* This operation works only if the operand is not equal to [TextUnit.Unspecified].
* The result of this operation is the same unit type of the given one.
+ *
+ * @throws IllegalArgumentException if this [TextUnit]'s type is [TextUnitType.Unspecified].
*/
inline operator fun unaryMinus(): TextUnit {
checkArithmetic(this)
@@ -100,6 +126,8 @@
*
* This operation works only if the left operand is not equal to [TextUnit.Unspecified].
* The result of this operation is the same unit type of the given one.
+ *
+ * @throws IllegalArgumentException if this [TextUnit]'s type is [TextUnitType.Unspecified].
*/
inline operator fun div(other: Float): TextUnit {
checkArithmetic(this)
@@ -111,6 +139,8 @@
*
* This operation works only if the left operand is not equal to [TextUnit.Unspecified].
* The result of this operation is the same unit type of the given one.
+ *
+ * @throws IllegalArgumentException if this [TextUnit]'s type is [TextUnitType.Unspecified].
*/
inline operator fun div(other: Double): TextUnit {
checkArithmetic(this)
@@ -122,17 +152,30 @@
*
* This operation works only if the left operand is not equal to [TextUnit.Unspecified].
* The result of this operation is the same unit type of the given one.
+ *
+ * @throws IllegalArgumentException if this [TextUnit]'s type is [TextUnitType.Unspecified].
*/
inline operator fun div(other: Int): TextUnit {
checkArithmetic(this)
return pack(rawType, value / other)
}
+ @Deprecated(
+ message = "This function will be removed. Please perform the arithmetic operations " +
+ "before creating the TextUnit.",
+ replaceWith = ReplaceWith(
+ "value / other.value"
+ )
+ )
/**
* Divide by another [TextUnit] to get a scalar.
*
* This operation works only if all the operands are the same unit type and they are not
* equal to [TextUnit.Unspecified].
+ *
+ * @throws IllegalArgumentException if this [TextUnit] and the [other] has different
+ * [TextUnitType]s or either of the two has the [TextUnitType] equals to
+ * [TextUnitType.Unspecified].
*/
inline operator fun div(other: TextUnit): Float {
checkArithmetic(this, other)
@@ -144,6 +187,8 @@
*
* This operation works only if the left operand is not equal to [TextUnit.Unspecified].
* The result of this operation is the same unit type of the given one.
+ *
+ * @throws IllegalArgumentException if this [TextUnit]'s type is [TextUnitType.Unspecified].
*/
inline operator fun times(other: Float): TextUnit {
checkArithmetic(this)
@@ -155,6 +200,8 @@
*
* This operation works only if the left operand is not equal to [TextUnit.Unspecified].
* The result of this operation is the same unit type of the given one.
+ *
+ * @throws IllegalArgumentException if this [TextUnit]'s type is [TextUnitType.Unspecified].
*/
inline operator fun times(other: Double): TextUnit {
checkArithmetic(this)
@@ -166,6 +213,8 @@
*
* This operation works only if the left operand is not equal to [TextUnit.Unspecified].
* The result of this operation is the same unit type of the given one.
+ *
+ * @throws IllegalArgumentException if this [TextUnit]'s type is [TextUnitType.Unspecified].
*/
inline operator fun times(other: Int): TextUnit {
checkArithmetic(this)
@@ -174,13 +223,18 @@
/**
* Support comparing Dimensions with comparison operators.
+ *
+ * @return 0 if this [TextUnit] equals to the [other], a negative number if it's less than the
+ * [other], or a positive number if it's greater than the [other].
+ * @throws IllegalArgumentException if this [TextUnit] and the [other] has different
+ * [TextUnitType]s or either of the two has the [TextUnitType] equals to
+ * [TextUnitType.Unspecified].
*/
inline operator fun compareTo(other: TextUnit): Int {
checkArithmetic(this, other)
return value.compareTo(other.value)
}
- @Suppress("DEPRECATION")
override fun toString(): String {
return when (type) {
TextUnitType.Unspecified -> "Unspecified"
@@ -193,31 +247,73 @@
internal val TextUnitTypes =
arrayOf(TextUnitType.Unspecified, TextUnitType.Sp, TextUnitType.Em)
+ @Deprecated(
+ message = "This function will be removed. Please use Int.sp instead.",
+ replaceWith = ReplaceWith(
+ "value.sp",
+ "androidx.compose.ui.unit.sp"
+ )
+ )
/**
* Creates a SP unit [TextUnit].
*/
fun Sp(value: Int) = pack(UNIT_TYPE_SP, value.toFloat())
+ @Deprecated(
+ message = "This function will be removed. Please use Float.sp instead.",
+ replaceWith = ReplaceWith(
+ "value.sp",
+ "androidx.compose.ui.unit.sp"
+ )
+ )
/**
* Creates a SP unit [TextUnit].
*/
fun Sp(value: Float) = pack(UNIT_TYPE_SP, value)
+ @Deprecated(
+ message = "This function will be removed. Please use Double.sp instead.",
+ replaceWith = ReplaceWith(
+ "value.sp",
+ "androidx.compose.ui.unit.sp"
+ )
+ )
/**
* Creates a SP unit [TextUnit].
*/
fun Sp(value: Double) = pack(UNIT_TYPE_SP, value.toFloat())
+ @Deprecated(
+ message = "This function will be removed. Please use Int.em instead.",
+ replaceWith = ReplaceWith(
+ "value.em",
+ "androidx.compose.ui.unit.em"
+ )
+ )
/**
* Creates an EM unit [TextUnit].
*/
fun Em(value: Int) = pack(UNIT_TYPE_EM, value.toFloat())
+ @Deprecated(
+ message = "This function will be removed. Please use Float.em instead.",
+ replaceWith = ReplaceWith(
+ "value.em",
+ "androidx.compose.ui.unit.em"
+ )
+ )
/**
* Creates an EM unit [TextUnit].
*/
fun Em(value: Float) = pack(UNIT_TYPE_EM, value)
+ @Deprecated(
+ message = "This function will be removed. Please use Double.em instead.",
+ replaceWith = ReplaceWith(
+ "value.em",
+ "androidx.compose.ui.unit.em"
+ )
+ )
/**
* Creates an EM unit [TextUnit].
*/
@@ -225,6 +321,9 @@
/**
* A special [TextUnit] instance for representing inheriting from parent value.
+ *
+ * Notice that performing arithmetic operations on [Unspecified] may result in an
+ * [IllegalArgumentException].
*/
@Stable
val Unspecified = pack(UNIT_TYPE_UNSPECIFIED, Float.NaN)
@@ -240,8 +339,6 @@
/**
* A type information of this TextUnit.
- *
- * @throws RuntimeException if unknown unknown unit type is appeared.
*/
val type: TextUnitType get() = TextUnitTypes[(rawType ushr 32).toInt()]
@@ -256,7 +353,10 @@
val isEm get() = rawType == UNIT_TYPE_EM
/**
- * Returns the value
+ * Returns the value of this [TextUnit].
+ *
+ * For example, the value of 3.sp equals to 3, and value of 5.em equals to 5. The value of
+ * [TextUnit]s whose [TextUnitType] is [TextUnitType.Unspecified] is undefined.
*/
val value get() = Float.fromBits((packedValue and 0xFFFF_FFFFL).toInt())
}
@@ -354,6 +454,14 @@
return pack(other.rawType, this * other.value)
}
+@Deprecated(
+ message = "This function will be removed, please perform the arithmetic operations " +
+ "before creating the TextUnit.",
+ replaceWith = ReplaceWith(
+ "if (a.value < b.value) a else b",
+ "import kotlin.math.min"
+ )
+)
/**
* Returns the smaller value from the given values.
*
@@ -367,6 +475,14 @@
return if (a.value < b.value) a else b
}
+@Deprecated(
+ message = "This function will be removed, please perform the arithmetic operations " +
+ "before creating the TextUnit.",
+ replaceWith = ReplaceWith(
+ "if (a.value < b.value) b else a",
+ "import kotlin.math.min"
+ )
+)
/**
* Returns the smaller value from the given values.
*
@@ -380,6 +496,18 @@
return if (a.value < b.value) b else a
}
+@Deprecated(
+ message = "This function will be removed, please perform the arithmetic operations " +
+ "before creating the TextUnit.",
+ replaceWith = ReplaceWith(
+ "if(isSp) {\n" +
+ " value.coerceIn(minimumValue.value, maximumValue.value).sp\n" +
+ "} else {\n" +
+ " value.coerceIn(minimumValue.value, maximumValue.value).em\n" +
+ "}",
+ "import kotlin.ranges.coerceIn"
+ )
+)
/**
* Ensures that the value of [TextUnit] lies in the specified range [minimumValue]..[maximumValue].
*
@@ -390,6 +518,10 @@
*
* @return this value if it's in the range, or [minimumValue] if this value is less than
* [minimumValue], or [maximumValue] if this value is greater than [maximumValue].
+ *
+ * @throws IllegalArgumentException if this [TextUnit], [minimumValue] and [maximumValue] don't
+ * have the same [TextUnitType], or if any of this [TextUnit], [minimumValue] and [maximumValue]
+ * has its [TextUnitType] equal to [TextUnitType.Unspecified].
*/
@Stable
inline fun TextUnit.coerceIn(minimumValue: TextUnit, maximumValue: TextUnit): TextUnit {
@@ -397,11 +529,27 @@
return pack(rawType, value.coerceIn(minimumValue.value, maximumValue.value))
}
+@Deprecated(
+ message = "This function will be removed, please perform the arithmetic operations " +
+ "before creating the TextUnit.",
+ replaceWith = ReplaceWith(
+ "if(isSp) {\n" +
+ " value.coerceAtLeast(minimumValue.value).sp\n" +
+ "} else {\n" +
+ " value.coerceAtLeast(minimumValue.value).em\n" +
+ "}",
+ "import kotlin.ranges.coerceAtLeast"
+ )
+)
/**
* Ensures that the value of [TextUnit] is not less than the specified [minimumValue].
*
* @return this value if it's greater than or equal to the [minimumValue] or the
* [minimumValue] otherwise.
+ *
+ * @throws IllegalArgumentException if this [TextUnit] and [minimumValue] don't have the same
+ * [TextUnitType], or if either of the two has its [TextUnitType] equal to
+ * [TextUnitType.Unspecified].
*/
@Stable
inline fun TextUnit.coerceAtLeast(minimumValue: TextUnit): TextUnit {
@@ -409,11 +557,27 @@
return pack(rawType, value.coerceAtLeast(minimumValue.value))
}
+@Deprecated(
+ message = "This function will be removed, please perform the arithmetic operations " +
+ "before creating the TextUnit.",
+ replaceWith = ReplaceWith(
+ "if(isSp) {\n" +
+ " value.coerceAtMost(maximumValue.value).sp\n" +
+ "} else {\n" +
+ " value.coerceAtMost(maximumValue.value).em\n" +
+ "}",
+ "import kotlin.ranges.coerceAtMost"
+ )
+)
/**
* Ensures that the value of [TextUnit] is not greater than the specified [maximumValue].
*
* @return this value if it's less than or equal to the [maximumValue] or the
* [maximumValue] otherwise.
+ *
+ * @throws IllegalArgumentException if this [TextUnit] and [maximumValue] don't have the same
+ * [TextUnitType], or if either of the two has its [TextUnitType] equal to
+ * [TextUnitType.Unspecified].
*/
@Stable
inline fun TextUnit.coerceAtMost(maximumValue: TextUnit): TextUnit {
@@ -452,8 +616,22 @@
}
}
+/**
+ * Linearly interpolate between two [TextUnit]s.
+ *
+ * The [fraction] argument represents position on the timeline, with 0.0 meaning
+ * that the interpolation has not started, returning [start] (or something
+ * equivalent to [start]), 1.0 meaning that the interpolation has finished,
+ * returning [stop] (or something equivalent to [stop]), and values in between
+ * meaning that the interpolation is at the relevant point on the timeline
+ * between [start] and [stop]. The interpolation can be extrapolated beyond 0.0 and
+ * 1.0, so negative values and values greater than 1.0 are valid.
+ *
+ * @throws IllegalArgumentException if [start] and [stop] have different [TextUnitType]s, or
+ * either of the two has its [TextUnitType] equal to [TextUnitType.Unspecified].
+ */
@Stable
-fun lerp(a: TextUnit, b: TextUnit, t: Float): TextUnit {
- checkArithmetic(a, b)
- return pack(a.rawType, lerp(a.value, b.value, t))
+fun lerp(start: TextUnit, stop: TextUnit, fraction: Float): TextUnit {
+ checkArithmetic(start, stop)
+ return pack(start.rawType, lerp(start.value, stop.value, fraction))
}
diff --git a/compose/ui/ui-unit/src/test/kotlin/androidx/compose/ui/unit/TextUnitTest.kt b/compose/ui/ui-unit/src/test/kotlin/androidx/compose/ui/unit/TextUnitTest.kt
index 3546e6b..b53341a 100644
--- a/compose/ui/ui-unit/src/test/kotlin/androidx/compose/ui/unit/TextUnitTest.kt
+++ b/compose/ui/ui-unit/src/test/kotlin/androidx/compose/ui/unit/TextUnitTest.kt
@@ -22,11 +22,13 @@
import org.junit.runner.RunWith
import org.junit.runners.JUnit4
+@Suppress("Deprecation")
+
@RunWith(JUnit4::class)
class TextUnitTest {
@Test
fun construct_sp_from_float() {
- TextUnit.Sp(5f).also {
+ 5f.sp.also {
assertThat(it.isSp).isTrue()
assertThat(it.isUnspecified).isFalse()
assertThat(it.isEm).isFalse()
@@ -37,7 +39,7 @@
@Test
fun construct_sp_from_int() {
- TextUnit.Sp(5).also {
+ 5.sp.also {
assertThat(it.isSp).isTrue()
assertThat(it.isUnspecified).isFalse()
assertThat(it.isEm).isFalse()
@@ -48,7 +50,7 @@
@Test
fun construct_sp_from_double() {
- TextUnit.Sp(5.0).also {
+ 5.0.sp.also {
assertThat(it.isSp).isTrue()
assertThat(it.isUnspecified).isFalse()
assertThat(it.isEm).isFalse()
@@ -92,7 +94,7 @@
@Test
fun construct_em_from_float() {
- TextUnit.Em(5f).also {
+ 5f.em.also {
assertThat(it.isSp).isFalse()
assertThat(it.isUnspecified).isFalse()
assertThat(it.isEm).isTrue()
@@ -103,7 +105,7 @@
@Test
fun construct_em_from_int() {
- TextUnit.Em(5).also {
+ 5.em.also {
assertThat(it.isSp).isFalse()
assertThat(it.isUnspecified).isFalse()
assertThat(it.isEm).isTrue()
@@ -114,7 +116,7 @@
@Test
fun construct_em_from_double() {
- TextUnit.Em(5.0).also {
+ 5.0.em.also {
assertThat(it.isSp).isFalse()
assertThat(it.isUnspecified).isFalse()
assertThat(it.isEm).isTrue()
diff --git a/compose/ui/ui-util/api/current.txt b/compose/ui/ui-util/api/current.txt
index 70e5e24..ff4b31a 100644
--- a/compose/ui/ui-util/api/current.txt
+++ b/compose/ui/ui-util/api/current.txt
@@ -5,10 +5,6 @@
method public static inline <T> T! trace(String sectionName, kotlin.jvm.functions.Function0<? extends T> block);
}
- public final class CharHelpersKt {
- method public static boolean isSurrogatePair(char high, char low);
- }
-
public final class InlineClassHelperKt {
method public static inline long packFloats(float val1, float val2);
method public static inline long packInts(int val1, int val2);
diff --git a/compose/ui/ui-util/api/public_plus_experimental_current.txt b/compose/ui/ui-util/api/public_plus_experimental_current.txt
index 70e5e24..ff4b31a 100644
--- a/compose/ui/ui-util/api/public_plus_experimental_current.txt
+++ b/compose/ui/ui-util/api/public_plus_experimental_current.txt
@@ -5,10 +5,6 @@
method public static inline <T> T! trace(String sectionName, kotlin.jvm.functions.Function0<? extends T> block);
}
- public final class CharHelpersKt {
- method public static boolean isSurrogatePair(char high, char low);
- }
-
public final class InlineClassHelperKt {
method public static inline long packFloats(float val1, float val2);
method public static inline long packInts(int val1, int val2);
diff --git a/compose/ui/ui-util/api/restricted_current.txt b/compose/ui/ui-util/api/restricted_current.txt
index 70e5e24..ff4b31a 100644
--- a/compose/ui/ui-util/api/restricted_current.txt
+++ b/compose/ui/ui-util/api/restricted_current.txt
@@ -5,10 +5,6 @@
method public static inline <T> T! trace(String sectionName, kotlin.jvm.functions.Function0<? extends T> block);
}
- public final class CharHelpersKt {
- method public static boolean isSurrogatePair(char high, char low);
- }
-
public final class InlineClassHelperKt {
method public static inline long packFloats(float val1, float val2);
method public static inline long packInts(int val1, int val2);
diff --git a/compose/ui/ui-util/src/commonMain/kotlin/androidx/compose/ui/util/CharHelpers.kt b/compose/ui/ui-util/src/commonMain/kotlin/androidx/compose/ui/util/CharHelpers.kt
index 9280df0..74c52a9 100644
--- a/compose/ui/ui-util/src/commonMain/kotlin/androidx/compose/ui/util/CharHelpers.kt
+++ b/compose/ui/ui-util/src/commonMain/kotlin/androidx/compose/ui/util/CharHelpers.kt
@@ -15,8 +15,6 @@
*/
package androidx.compose.ui.util
-fun isSurrogatePair(high: Char, low: Char): Boolean = high.isHighSurrogate() && low.isLowSurrogate()
-
// Returns -1 if cannot go back.
expect fun String.findPrecedingBreak(index: Int): Int
diff --git a/compose/ui/ui/api/current.txt b/compose/ui/ui/api/current.txt
index 8b9f17e..c22fe58 100644
--- a/compose/ui/ui/api/current.txt
+++ b/compose/ui/ui/api/current.txt
@@ -742,23 +742,20 @@
package androidx.compose.ui.graphics.vector {
@androidx.compose.runtime.Immutable public final class ImageVector {
- method public String component1();
- method public float component2-D9Ej5fM();
- method public float component3-D9Ej5fM();
- method public float component4();
- method public float component5();
- method public androidx.compose.ui.graphics.vector.VectorGroup component6();
- method @androidx.compose.runtime.Immutable public androidx.compose.ui.graphics.vector.ImageVector copy-pRTh4Qo(String name, float defaultWidth, float defaultHeight, float viewportWidth, float viewportHeight, androidx.compose.ui.graphics.vector.VectorGroup root);
method public float getDefaultHeight-D9Ej5fM();
method public float getDefaultWidth-D9Ej5fM();
method public String getName();
method public androidx.compose.ui.graphics.vector.VectorGroup getRoot();
+ method public androidx.compose.ui.graphics.BlendMode getTintBlendMode();
+ method public long getTintColor-0d7_KjU();
method public float getViewportHeight();
method public float getViewportWidth();
property public final float defaultHeight;
property public final float defaultWidth;
property public final String name;
property public final androidx.compose.ui.graphics.vector.VectorGroup root;
+ property public final androidx.compose.ui.graphics.BlendMode tintBlendMode;
+ property public final long tintColor;
property public final float viewportHeight;
property public final float viewportWidth;
}
@@ -859,7 +856,7 @@
method @Deprecated @androidx.compose.runtime.Composable public static androidx.compose.ui.graphics.vector.VectorPainter VectorPainter(androidx.compose.ui.graphics.vector.ImageVector image);
method @Deprecated @androidx.compose.runtime.Composable public static androidx.compose.ui.graphics.vector.VectorPainter VectorPainter-RKTc9UI(float defaultWidth, float defaultHeight, optional float viewportWidth, optional float viewportHeight, optional String name, kotlin.jvm.functions.Function2<? super java.lang.Float,? super java.lang.Float,kotlin.Unit> children);
method @androidx.compose.runtime.Composable public static androidx.compose.ui.graphics.vector.VectorPainter rememberVectorPainter(androidx.compose.ui.graphics.vector.ImageVector image);
- method @androidx.compose.runtime.Composable public static androidx.compose.ui.graphics.vector.VectorPainter rememberVectorPainter-RKTc9UI(float defaultWidth, float defaultHeight, optional float viewportWidth, optional float viewportHeight, optional String name, kotlin.jvm.functions.Function2<? super java.lang.Float,? super java.lang.Float,kotlin.Unit> content);
+ method @androidx.compose.runtime.Composable public static androidx.compose.ui.graphics.vector.VectorPainter rememberVectorPainter-u_AqRoo(float defaultWidth, float defaultHeight, optional float viewportWidth, optional float viewportHeight, optional String name, optional long tintColor, optional androidx.compose.ui.graphics.BlendMode tintBlendMode, kotlin.jvm.functions.Function2<? super java.lang.Float,? super java.lang.Float,kotlin.Unit> content);
field public static final String RootGroupName = "VectorRootGroup";
}
diff --git a/compose/ui/ui/api/public_plus_experimental_current.txt b/compose/ui/ui/api/public_plus_experimental_current.txt
index 8b9f17e..c22fe58 100644
--- a/compose/ui/ui/api/public_plus_experimental_current.txt
+++ b/compose/ui/ui/api/public_plus_experimental_current.txt
@@ -742,23 +742,20 @@
package androidx.compose.ui.graphics.vector {
@androidx.compose.runtime.Immutable public final class ImageVector {
- method public String component1();
- method public float component2-D9Ej5fM();
- method public float component3-D9Ej5fM();
- method public float component4();
- method public float component5();
- method public androidx.compose.ui.graphics.vector.VectorGroup component6();
- method @androidx.compose.runtime.Immutable public androidx.compose.ui.graphics.vector.ImageVector copy-pRTh4Qo(String name, float defaultWidth, float defaultHeight, float viewportWidth, float viewportHeight, androidx.compose.ui.graphics.vector.VectorGroup root);
method public float getDefaultHeight-D9Ej5fM();
method public float getDefaultWidth-D9Ej5fM();
method public String getName();
method public androidx.compose.ui.graphics.vector.VectorGroup getRoot();
+ method public androidx.compose.ui.graphics.BlendMode getTintBlendMode();
+ method public long getTintColor-0d7_KjU();
method public float getViewportHeight();
method public float getViewportWidth();
property public final float defaultHeight;
property public final float defaultWidth;
property public final String name;
property public final androidx.compose.ui.graphics.vector.VectorGroup root;
+ property public final androidx.compose.ui.graphics.BlendMode tintBlendMode;
+ property public final long tintColor;
property public final float viewportHeight;
property public final float viewportWidth;
}
@@ -859,7 +856,7 @@
method @Deprecated @androidx.compose.runtime.Composable public static androidx.compose.ui.graphics.vector.VectorPainter VectorPainter(androidx.compose.ui.graphics.vector.ImageVector image);
method @Deprecated @androidx.compose.runtime.Composable public static androidx.compose.ui.graphics.vector.VectorPainter VectorPainter-RKTc9UI(float defaultWidth, float defaultHeight, optional float viewportWidth, optional float viewportHeight, optional String name, kotlin.jvm.functions.Function2<? super java.lang.Float,? super java.lang.Float,kotlin.Unit> children);
method @androidx.compose.runtime.Composable public static androidx.compose.ui.graphics.vector.VectorPainter rememberVectorPainter(androidx.compose.ui.graphics.vector.ImageVector image);
- method @androidx.compose.runtime.Composable public static androidx.compose.ui.graphics.vector.VectorPainter rememberVectorPainter-RKTc9UI(float defaultWidth, float defaultHeight, optional float viewportWidth, optional float viewportHeight, optional String name, kotlin.jvm.functions.Function2<? super java.lang.Float,? super java.lang.Float,kotlin.Unit> content);
+ method @androidx.compose.runtime.Composable public static androidx.compose.ui.graphics.vector.VectorPainter rememberVectorPainter-u_AqRoo(float defaultWidth, float defaultHeight, optional float viewportWidth, optional float viewportHeight, optional String name, optional long tintColor, optional androidx.compose.ui.graphics.BlendMode tintBlendMode, kotlin.jvm.functions.Function2<? super java.lang.Float,? super java.lang.Float,kotlin.Unit> content);
field public static final String RootGroupName = "VectorRootGroup";
}
diff --git a/compose/ui/ui/api/restricted_current.txt b/compose/ui/ui/api/restricted_current.txt
index 7603187..3e636de 100644
--- a/compose/ui/ui/api/restricted_current.txt
+++ b/compose/ui/ui/api/restricted_current.txt
@@ -742,23 +742,20 @@
package androidx.compose.ui.graphics.vector {
@androidx.compose.runtime.Immutable public final class ImageVector {
- method public String component1();
- method public float component2-D9Ej5fM();
- method public float component3-D9Ej5fM();
- method public float component4();
- method public float component5();
- method public androidx.compose.ui.graphics.vector.VectorGroup component6();
- method @androidx.compose.runtime.Immutable public androidx.compose.ui.graphics.vector.ImageVector copy-pRTh4Qo(String name, float defaultWidth, float defaultHeight, float viewportWidth, float viewportHeight, androidx.compose.ui.graphics.vector.VectorGroup root);
method public float getDefaultHeight-D9Ej5fM();
method public float getDefaultWidth-D9Ej5fM();
method public String getName();
method public androidx.compose.ui.graphics.vector.VectorGroup getRoot();
+ method public androidx.compose.ui.graphics.BlendMode getTintBlendMode();
+ method public long getTintColor-0d7_KjU();
method public float getViewportHeight();
method public float getViewportWidth();
property public final float defaultHeight;
property public final float defaultWidth;
property public final String name;
property public final androidx.compose.ui.graphics.vector.VectorGroup root;
+ property public final androidx.compose.ui.graphics.BlendMode tintBlendMode;
+ property public final long tintColor;
property public final float viewportHeight;
property public final float viewportWidth;
}
@@ -859,7 +856,7 @@
method @Deprecated @androidx.compose.runtime.Composable public static androidx.compose.ui.graphics.vector.VectorPainter VectorPainter(androidx.compose.ui.graphics.vector.ImageVector image);
method @Deprecated @androidx.compose.runtime.Composable public static androidx.compose.ui.graphics.vector.VectorPainter VectorPainter-RKTc9UI(float defaultWidth, float defaultHeight, optional float viewportWidth, optional float viewportHeight, optional String name, kotlin.jvm.functions.Function2<? super java.lang.Float,? super java.lang.Float,kotlin.Unit> children);
method @androidx.compose.runtime.Composable public static androidx.compose.ui.graphics.vector.VectorPainter rememberVectorPainter(androidx.compose.ui.graphics.vector.ImageVector image);
- method @androidx.compose.runtime.Composable public static androidx.compose.ui.graphics.vector.VectorPainter rememberVectorPainter-RKTc9UI(float defaultWidth, float defaultHeight, optional float viewportWidth, optional float viewportHeight, optional String name, kotlin.jvm.functions.Function2<? super java.lang.Float,? super java.lang.Float,kotlin.Unit> content);
+ method @androidx.compose.runtime.Composable public static androidx.compose.ui.graphics.vector.VectorPainter rememberVectorPainter-u_AqRoo(float defaultWidth, float defaultHeight, optional float viewportWidth, optional float viewportHeight, optional String name, optional long tintColor, optional androidx.compose.ui.graphics.BlendMode tintBlendMode, kotlin.jvm.functions.Function2<? super java.lang.Float,? super java.lang.Float,kotlin.Unit> content);
field public static final String RootGroupName = "VectorRootGroup";
}
diff --git a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/PointerInputDuringSubCompDemo.kt b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/PointerInputDuringSubCompDemo.kt
index 03d0312..f4b26b2 100644
--- a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/PointerInputDuringSubCompDemo.kt
+++ b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/PointerInputDuringSubCompDemo.kt
@@ -39,8 +39,8 @@
import androidx.compose.ui.input.pointer.changedToDownIgnoreConsumed
import androidx.compose.ui.input.pointer.changedToUpIgnoreConsumed
import androidx.compose.ui.unit.IntSize
-import androidx.compose.ui.unit.TextUnit
import androidx.compose.ui.unit.dp
+import androidx.compose.ui.unit.em
/**
* Demonstration of how various press/tap gesture interact together in a nested fashion.
@@ -78,7 +78,7 @@
) {
Text(
"${pointerCount.value}",
- fontSize = TextUnit.Em(16),
+ fontSize = 16.em,
color = Color.Black
)
}
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/AndroidAccessibilityTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/AndroidAccessibilityTest.kt
index 127437a..02fb300 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/AndroidAccessibilityTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/AndroidAccessibilityTest.kt
@@ -63,6 +63,7 @@
import androidx.core.view.ViewCompat
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat
import androidx.test.ext.junit.runners.AndroidJUnit4
+import androidx.test.filters.FlakyTest
import androidx.test.filters.LargeTest
import androidx.test.filters.SdkSuppress
import androidx.test.platform.app.InstrumentationRegistry
@@ -349,6 +350,7 @@
}
@Test
+ @FlakyTest(bugId = 177511084, detail = "sync issues with suspend input")
fun sendStateChangeEvent_whenClickToggleable() {
rule.onNodeWithTag(ToggleableTag)
.assertIsOn()
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/graphics/vector/VectorTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/graphics/vector/VectorTest.kt
index ee21e48..66d65f3 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/graphics/vector/VectorTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/graphics/vector/VectorTest.kt
@@ -77,6 +77,22 @@
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.O)
@Test
+ fun testVectorIntrinsicTint() {
+ rule.setContent {
+ val background = Modifier.paint(
+ createTestVectorPainter(200, Color.Magenta),
+ alignment = Alignment.Center
+ )
+ AtLeastSize(size = 200, modifier = background) {
+ }
+ }
+ takeScreenShot(200).apply {
+ assertEquals(getPixel(100, 100), Color.Magenta.toArgb())
+ }
+ }
+
+ @SdkSuppress(minSdkVersion = Build.VERSION_CODES.O)
+ @Test
fun testVectorAlignment() {
rule.setContent {
VectorTint(minimumSize = 500, alignment = Alignment.BottomEnd)
@@ -293,7 +309,6 @@
minimumSize: Int = size,
alignment: Alignment = Alignment.Center
) {
-
val background = Modifier.paint(
createTestVectorPainter(size),
colorFilter = ColorFilter.tint(Color.Cyan),
@@ -304,7 +319,10 @@
}
@Composable
- private fun createTestVectorPainter(size: Int = 200): VectorPainter {
+ private fun createTestVectorPainter(
+ size: Int = 200,
+ tintColor: Color = Color.Unspecified
+ ): VectorPainter {
val sizePx = size.toFloat()
val sizeDp = (size / AmbientDensity.current.density).dp
return rememberVectorPainter(
@@ -320,7 +338,8 @@
},
fill = SolidColor(Color.Black)
)
- }
+ },
+ tintColor = tintColor
)
}
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/graphics/vector/compat/XmlVectorParserTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/graphics/vector/compat/XmlVectorParserTest.kt
index 1b40a79..69b17d8 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/graphics/vector/compat/XmlVectorParserTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/graphics/vector/compat/XmlVectorParserTest.kt
@@ -16,8 +16,10 @@
package androidx.compose.ui.graphics.vector.compat
+import androidx.compose.ui.graphics.BlendMode
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.SolidColor
+import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.graphics.vector.PathNode
import androidx.compose.ui.graphics.vector.VectorGroup
import androidx.compose.ui.graphics.vector.VectorNode
@@ -160,6 +162,57 @@
path[2].assertType<PathNode.Close>()
}
+ @Test
+ fun testParsePlus() {
+ val asset = loadVector(R.drawable.ic_triangle_plus)
+ assertEquals(Color.Blue, asset.tintColor)
+ assertEquals(BlendMode.Plus, asset.tintBlendMode)
+ }
+
+ @Test
+ fun testParseScreen() {
+ val asset = loadVector(R.drawable.ic_triangle_screen)
+ assertEquals(Color.Blue, asset.tintColor)
+ assertEquals(BlendMode.Screen, asset.tintBlendMode)
+ }
+
+ @Test
+ fun testParseSrcAtop() {
+ val asset = loadVector(R.drawable.ic_triangle_src_atop)
+ assertEquals(Color.Blue, asset.tintColor)
+ assertEquals(BlendMode.SrcAtop, asset.tintBlendMode)
+ }
+
+ @Test
+ fun testParseSrcIn() {
+ val asset = loadVector(R.drawable.ic_triangle_src_in)
+ assertEquals(Color.Blue, asset.tintColor)
+ assertEquals(BlendMode.SrcIn, asset.tintBlendMode)
+ }
+
+ @Test
+ fun testParseModulate() {
+ val asset = loadVector(R.drawable.ic_triangle_modulate)
+ assertEquals(Color.Blue, asset.tintColor)
+ assertEquals(BlendMode.Modulate, asset.tintBlendMode)
+ }
+
+ @Test
+ fun testParseSrcOver() {
+ val asset = loadVector(R.drawable.ic_triangle_src_over)
+ assertEquals(Color.Blue, asset.tintColor)
+ assertEquals(BlendMode.SrcOver, asset.tintBlendMode)
+ }
+
+ private fun loadVector(id: Int): ImageVector {
+ val res = InstrumentationRegistry.getInstrumentation().targetContext.resources
+ return loadVectorResource(
+ null,
+ res,
+ id
+ )
+ }
+
/**
* Asserts that [this] is the expected type [T], and then returns [this] cast to [T].
*/
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/input/pointer/SuspendingPointerInputFilterTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/input/pointer/SuspendingPointerInputFilterTest.kt
index 8a0e14b..1299cb3 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/input/pointer/SuspendingPointerInputFilterTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/input/pointer/SuspendingPointerInputFilterTest.kt
@@ -16,17 +16,28 @@
package androidx.compose.ui.input.pointer
+import androidx.compose.foundation.layout.Box
+import androidx.compose.runtime.ExperimentalComposeApi
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.setValue
+import androidx.compose.runtime.snapshots.withMutableSnapshot
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.platform.InspectableValue
import androidx.compose.ui.platform.ValueElement
import androidx.compose.ui.platform.ViewConfiguration
import androidx.compose.ui.platform.isDebugInspectorInfoEnabled
+import androidx.compose.ui.platform.setContent
+import androidx.compose.ui.test.TestActivity
import androidx.compose.ui.unit.Duration
import androidx.compose.ui.unit.IntSize
import androidx.compose.ui.unit.Uptime
import androidx.compose.ui.unit.milliseconds
+import androidx.lifecycle.Lifecycle
+import androidx.test.core.app.ActivityScenario
import androidx.test.ext.junit.runners.AndroidJUnit4
+import androidx.test.filters.MediumTest
import androidx.test.filters.SmallTest
import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.CompletableDeferred
@@ -37,13 +48,17 @@
import kotlinx.coroutines.flow.toList
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
+import kotlinx.coroutines.suspendCancellableCoroutine
import kotlinx.coroutines.test.runBlockingTest
import kotlinx.coroutines.withTimeout
import org.junit.After
import org.junit.Assert.assertEquals
+import org.junit.Assert.assertTrue
import org.junit.Assert.fail
import org.junit.Test
import org.junit.runner.RunWith
+import java.util.concurrent.CountDownLatch
+import java.util.concurrent.TimeUnit
@SmallTest
@RunWith(AndroidJUnit4::class)
@@ -226,6 +241,40 @@
ValueElement("block", block)
)
}
+
+ @OptIn(ExperimentalComposeApi::class)
+ @Test
+ @MediumTest
+ fun testRestartPointerInput() = runBlocking<Unit> {
+ var toAdd by mutableStateOf("initial")
+ val result = mutableListOf<String>()
+ val latch = CountDownLatch(2)
+ ActivityScenario.launch(TestActivity::class.java).use { scenario ->
+ scenario.moveToState(Lifecycle.State.CREATED)
+ scenario.onActivity {
+ it.setContent {
+ // Read the value in composition to change the lambda capture below
+ val toCapture = toAdd
+ Box(
+ Modifier.pointerInput {
+ result += toCapture
+ latch.countDown()
+ suspendCancellableCoroutine<Unit> {}
+ }
+ )
+ }
+ }
+ scenario.moveToState(Lifecycle.State.STARTED)
+ withMutableSnapshot {
+ toAdd = "secondary"
+ }
+ assertTrue("waiting for relaunch timed out", latch.await(1, TimeUnit.SECONDS))
+ assertEquals(
+ listOf("initial", "secondary"),
+ result
+ )
+ }
+ }
}
private fun PointerInputChange.toPointerEvent() = PointerEvent(listOf(this))
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/viewinterop/ComposeViewTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/viewinterop/ComposeViewTest.kt
index 2a8ddd0..b075004 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/viewinterop/ComposeViewTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/viewinterop/ComposeViewTest.kt
@@ -34,7 +34,7 @@
import androidx.compose.ui.platform.ViewCompositionStrategy
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.test.assertTextEquals
-import androidx.compose.ui.test.junit4.createAndroidComposeRuleLegacy
+import androidx.compose.ui.test.junit4.createAndroidComposeRule
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.unit.IntSize
import androidx.lifecycle.Lifecycle
@@ -59,9 +59,8 @@
@MediumTest
@RunWith(AndroidJUnit4::class)
class ComposeViewTest {
- @Suppress("DEPRECATION") // Needed because this test is setting its own content.
@get:Rule
- val rule = createAndroidComposeRuleLegacy<ComponentActivity>()
+ val rule = createAndroidComposeRule<ComponentActivity>()
@Test
fun composeViewComposedContent() {
diff --git a/compose/ui/ui/src/androidAndroidTest/res/drawable/ic_triangle_modulate.xml b/compose/ui/ui/src/androidAndroidTest/res/drawable/ic_triangle_modulate.xml
new file mode 100644
index 0000000..8047fab5
--- /dev/null
+++ b/compose/ui/ui/src/androidAndroidTest/res/drawable/ic_triangle_modulate.xml
@@ -0,0 +1,26 @@
+<!--
+ Copyright 2019 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.
+ -->
+
+<vector android:height="64dp"
+ android:width="64dp"
+ android:viewportHeight="32"
+ android:viewportWidth="32"
+ android:tint="#0000FF"
+ android:tintMode="multiply"
+ xmlns:android="http://schemas.android.com/apk/res/android">
+
+ <path android:fillColor="#FF0000" android:pathData="h 32, l 0, 32, z" />
+</vector>
diff --git a/compose/ui/ui/src/androidAndroidTest/res/drawable/ic_triangle_plus.xml b/compose/ui/ui/src/androidAndroidTest/res/drawable/ic_triangle_plus.xml
new file mode 100644
index 0000000..e83d9b7
--- /dev/null
+++ b/compose/ui/ui/src/androidAndroidTest/res/drawable/ic_triangle_plus.xml
@@ -0,0 +1,26 @@
+<!--
+ Copyright 2019 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.
+ -->
+
+<vector android:height="64dp"
+ android:width="64dp"
+ android:viewportHeight="32"
+ android:viewportWidth="32"
+ android:tint="#0000FF"
+ android:tintMode="add"
+ xmlns:android="http://schemas.android.com/apk/res/android">
+
+ <path android:fillColor="#FF0000" android:pathData="h 32, l 0, 32, z" />
+</vector>
diff --git a/compose/ui/ui/src/androidAndroidTest/res/drawable/ic_triangle_screen.xml b/compose/ui/ui/src/androidAndroidTest/res/drawable/ic_triangle_screen.xml
new file mode 100644
index 0000000..3438421
--- /dev/null
+++ b/compose/ui/ui/src/androidAndroidTest/res/drawable/ic_triangle_screen.xml
@@ -0,0 +1,26 @@
+<!--
+ Copyright 2019 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.
+ -->
+
+<vector android:height="64dp"
+ android:width="64dp"
+ android:viewportHeight="32"
+ android:viewportWidth="32"
+ android:tint="#0000FF"
+ android:tintMode="screen"
+ xmlns:android="http://schemas.android.com/apk/res/android">
+
+ <path android:fillColor="#FF0000" android:pathData="h 32, l 0, 32, z" />
+</vector>
diff --git a/compose/ui/ui/src/androidAndroidTest/res/drawable/ic_triangle_src_atop.xml b/compose/ui/ui/src/androidAndroidTest/res/drawable/ic_triangle_src_atop.xml
new file mode 100644
index 0000000..565d988
--- /dev/null
+++ b/compose/ui/ui/src/androidAndroidTest/res/drawable/ic_triangle_src_atop.xml
@@ -0,0 +1,26 @@
+<!--
+ Copyright 2019 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.
+ -->
+
+<vector android:height="64dp"
+ android:width="64dp"
+ android:viewportHeight="32"
+ android:viewportWidth="32"
+ android:tint="#0000FF"
+ android:tintMode="src_atop"
+ xmlns:android="http://schemas.android.com/apk/res/android">
+
+ <path android:fillColor="#FF0000" android:pathData="h 32, l 0, 32, z" />
+</vector>
diff --git a/compose/ui/ui/src/androidAndroidTest/res/drawable/ic_triangle_src_in.xml b/compose/ui/ui/src/androidAndroidTest/res/drawable/ic_triangle_src_in.xml
new file mode 100644
index 0000000..9616797
--- /dev/null
+++ b/compose/ui/ui/src/androidAndroidTest/res/drawable/ic_triangle_src_in.xml
@@ -0,0 +1,26 @@
+<!--
+ Copyright 2019 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.
+ -->
+
+<vector android:height="64dp"
+ android:width="64dp"
+ android:viewportHeight="32"
+ android:viewportWidth="32"
+ android:tint="#0000FF"
+ android:tintMode="src_in"
+ xmlns:android="http://schemas.android.com/apk/res/android">
+
+ <path android:fillColor="#FF0000" android:pathData="h 32, l 0, 32, z" />
+</vector>
diff --git a/compose/ui/ui/src/androidAndroidTest/res/drawable/ic_triangle_src_over.xml b/compose/ui/ui/src/androidAndroidTest/res/drawable/ic_triangle_src_over.xml
new file mode 100644
index 0000000..c530460
--- /dev/null
+++ b/compose/ui/ui/src/androidAndroidTest/res/drawable/ic_triangle_src_over.xml
@@ -0,0 +1,26 @@
+<!--
+ Copyright 2019 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.
+ -->
+
+<vector android:height="64dp"
+ android:width="64dp"
+ android:viewportHeight="32"
+ android:viewportWidth="32"
+ android:tint="#0000FF"
+ android:tintMode="src_over"
+ xmlns:android="http://schemas.android.com/apk/res/android">
+
+ <path android:fillColor="#FF0000" android:pathData="h 32, l 0, 32, z" />
+</vector>
diff --git a/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/graphics/vector/compat/XmlVectorParser.kt b/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/graphics/vector/compat/XmlVectorParser.kt
index ee27a7a..f55167e 100644
--- a/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/graphics/vector/compat/XmlVectorParser.kt
+++ b/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/graphics/vector/compat/XmlVectorParser.kt
@@ -18,6 +18,8 @@
import android.content.res.Resources
import android.util.AttributeSet
+import android.util.TypedValue
+import androidx.compose.ui.graphics.BlendMode
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.PathFillType
@@ -181,6 +183,42 @@
AndroidVectorResources.STYLEABLE_VECTOR_DRAWABLE_HEIGHT, 0.0f
)
+ val tintColor = if (
+ vectorAttrs.hasValue(AndroidVectorResources.STYLEABLE_VECTOR_DRAWABLE_TINT)
+ ) {
+ // first check if is a simple color
+ val value = TypedValue()
+ vectorAttrs.getValue(AndroidVectorResources.STYLEABLE_VECTOR_DRAWABLE_TINT, value)
+ if (value.type >= TypedValue.TYPE_FIRST_COLOR_INT &&
+ value.type <= TypedValue.TYPE_LAST_COLOR_INT
+ ) {
+ Color(value.data)
+ } else {
+ Color.Unspecified
+ }
+ } else {
+ Color.Unspecified
+ }
+
+ val blendModeValue = vectorAttrs.getInt(
+ AndroidVectorResources.STYLEABLE_VECTOR_DRAWABLE_TINT_MODE, -1
+ )
+ val tintBlendMode = if (blendModeValue != -1) {
+ when (blendModeValue) {
+ 3 -> BlendMode.SrcOver
+ 5 -> BlendMode.SrcIn
+ 9 -> BlendMode.SrcAtop
+ // b/73224934 PorterDuff Multiply maps to Skia Modulate so actually
+ // return BlendMode.MODULATE here
+ 14 -> BlendMode.Modulate
+ 15 -> BlendMode.Screen
+ 16 -> BlendMode.Plus
+ else -> BlendMode.SrcIn
+ }
+ } else {
+ BlendMode.SrcIn
+ }
+
val defaultWidthDp = (defaultWidth / res.displayMetrics.density).dp
val defaultHeightDp = (defaultHeight / res.displayMetrics.density).dp
@@ -190,7 +228,9 @@
defaultWidth = defaultWidthDp,
defaultHeight = defaultHeightDp,
viewportWidth = viewportWidth,
- viewportHeight = viewportHeight
+ viewportHeight = viewportHeight,
+ tintColor = tintColor,
+ tintBlendMode = tintBlendMode
)
}
diff --git a/compose/ui/ui/src/androidMain/res/values/public.xml b/compose/ui/ui/src/androidMain/res/values/public.xml
index e52eb82..4d54254 100644
--- a/compose/ui/ui/src/androidMain/res/values/public.xml
+++ b/compose/ui/ui/src/androidMain/res/values/public.xml
@@ -15,6 +15,4 @@
-->
<resources>
- <!-- b/170882230 Defining empty <public /> tag here to make everything else private -->
- <public />
</resources>
diff --git a/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/graphics/vector/ImageVector.kt b/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/graphics/vector/ImageVector.kt
index ea4ca1b..50b224e 100644
--- a/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/graphics/vector/ImageVector.kt
+++ b/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/graphics/vector/ImageVector.kt
@@ -17,7 +17,9 @@
package androidx.compose.ui.graphics.vector
import androidx.compose.runtime.Immutable
+import androidx.compose.ui.graphics.BlendMode
import androidx.compose.ui.graphics.Brush
+import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.PathFillType
import androidx.compose.ui.graphics.StrokeCap
import androidx.compose.ui.graphics.StrokeJoin
@@ -28,7 +30,7 @@
* It can be composed and rendered by passing it as an argument to [rememberVectorPainter]
*/
@Immutable
-data class ImageVector internal constructor(
+class ImageVector internal constructor(
/**
* Name of the Vector asset
@@ -60,7 +62,17 @@
/**
* Root group of the vector asset that contains all the child groups and paths
*/
- val root: VectorGroup
+ val root: VectorGroup,
+
+ /**
+ * Optional tint color to be applied to the vector graphic
+ */
+ val tintColor: Color,
+
+ /**
+ * Blend mode used to apply [tintColor]
+ */
+ val tintBlendMode: BlendMode
) {
/**
* Builder used to construct a Vector graphic tree.
@@ -99,7 +111,17 @@
* Used to define the height of the viewport space. Viewport is basically the virtual canvas
* where the paths are drawn on.
*/
- private val viewportHeight: Float
+ private val viewportHeight: Float,
+
+ /**
+ * Optional color used to tint the entire vector image
+ */
+ private val tintColor: Color = Color.Unspecified,
+
+ /**
+ * Blend mode used to apply the tint color
+ */
+ private val tintBlendMode: BlendMode = BlendMode.SrcIn
) {
private val nodes = Stack<GroupParams>()
@@ -321,7 +343,9 @@
defaultHeight,
viewportWidth,
viewportHeight,
- root.asVectorGroup()
+ root.asVectorGroup(),
+ tintColor,
+ tintBlendMode
)
isConsumed = true
@@ -375,6 +399,34 @@
var children: MutableList<VectorNode> = mutableListOf()
)
}
+
+ override fun equals(other: Any?): Boolean {
+ if (this === other) return true
+ if (other !is ImageVector) return false
+
+ if (name != other.name) return false
+ if (defaultWidth != other.defaultWidth) return false
+ if (defaultHeight != other.defaultHeight) return false
+ if (viewportWidth != other.viewportWidth) return false
+ if (viewportHeight != other.viewportHeight) return false
+ if (root != other.root) return false
+ if (tintColor != other.tintColor) return false
+ if (tintBlendMode != other.tintBlendMode) return false
+
+ return true
+ }
+
+ override fun hashCode(): Int {
+ var result = name.hashCode()
+ result = 31 * result + defaultWidth.hashCode()
+ result = 31 * result + defaultHeight.hashCode()
+ result = 31 * result + viewportWidth.hashCode()
+ result = 31 * result + viewportHeight.hashCode()
+ result = 31 * result + root.hashCode()
+ result = 31 * result + tintColor.hashCode()
+ result = 31 * result + tintBlendMode.hashCode()
+ return result
+ }
}
sealed class VectorNode
diff --git a/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/graphics/vector/Vector.kt b/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/graphics/vector/Vector.kt
index c2b0754..dcbea87 100644
--- a/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/graphics/vector/Vector.kt
+++ b/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/graphics/vector/Vector.kt
@@ -114,6 +114,8 @@
internal var invalidateCallback = {}
+ internal var intrinsicColorFilter: ColorFilter? = null
+
var viewportWidth: Float = 0f
set(value) {
if (field != value) {
@@ -140,6 +142,11 @@
}
fun DrawScope.draw(alpha: Float, colorFilter: ColorFilter?) {
+ val targetColorFilter = if (colorFilter != null) {
+ colorFilter
+ } else {
+ intrinsicColorFilter
+ }
// If the content of the vector has changed, or we are drawing a different size
// update the cached image to ensure we are scaling the vector appropriately
if (isDirty || previousDrawSize != size) {
@@ -154,7 +161,7 @@
isDirty = false
previousDrawSize = size
}
- cacheDrawScope.drawInto(this, alpha, colorFilter)
+ cacheDrawScope.drawInto(this, alpha, targetColorFilter)
}
override fun DrawScope.draw() {
diff --git a/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/graphics/vector/VectorPainter.kt b/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/graphics/vector/VectorPainter.kt
index 4ad3dd1..a67e1f5 100644
--- a/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/graphics/vector/VectorPainter.kt
+++ b/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/graphics/vector/VectorPainter.kt
@@ -20,10 +20,13 @@
import androidx.compose.runtime.compositionReference
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.onCommit
import androidx.compose.runtime.onDispose
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.geometry.Size
+import androidx.compose.ui.graphics.BlendMode
+import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.graphics.drawscope.DrawScope
import androidx.compose.ui.graphics.painter.Painter
@@ -48,6 +51,8 @@
* paths are drawn on.
* This parameter is optional. Not providing it will use the [defaultHeight] converted to pixels
* @param [name] optional identifier used to identify the root of this vector graphic
+ * @param [tintColor] optional color used to tint the root group of this vector graphic
+ * @param [tintBlendMode] BlendMode used in combination with [tintColor]
* @param [content] Composable used to define the structure and contents of the vector graphic
*/
@Composable
@@ -57,6 +62,8 @@
viewportWidth: Float = Float.NaN,
viewportHeight: Float = Float.NaN,
name: String = RootGroupName,
+ tintColor: Color = Color.Unspecified,
+ tintBlendMode: BlendMode = BlendMode.SrcIn,
content: @Composable (viewportWidth: Float, viewportHeight: Float) -> Unit
): VectorPainter {
val density = AmbientDensity.current
@@ -66,12 +73,23 @@
val vpWidth = if (viewportWidth.isNaN()) widthPx else viewportWidth
val vpHeight = if (viewportHeight.isNaN()) heightPx else viewportHeight
- return remember { VectorPainter() }.apply {
+ val painter = remember { VectorPainter() }.apply {
// This assignment is thread safe as the internal Size parameter is
// backed by a mutableState object
size = Size(widthPx, heightPx)
RenderVector(name, vpWidth, vpHeight, content)
}
+ onCommit {
+ // Initialize the intrinsic color filter if a tint color is provided on the
+ // vector itself. Note this tint can be overridden by an explicit ColorFilter
+ // provided on the Modifier.paint call
+ painter.intrinsicColorFilter = if (tintColor != Color.Unspecified) {
+ ColorFilter(tintColor, tintBlendMode)
+ } else {
+ null
+ }
+ }
+ return painter
}
/**
@@ -109,12 +127,12 @@
children: @Composable (viewportWidth: Float, viewportHeight: Float) -> Unit
): VectorPainter =
rememberVectorPainter(
- defaultWidth,
- defaultHeight,
- viewportWidth,
- viewportHeight,
- name,
- children
+ defaultWidth = defaultWidth,
+ defaultHeight = defaultHeight,
+ viewportWidth = viewportWidth,
+ viewportHeight = viewportHeight,
+ name = name,
+ content = children
)
/**
@@ -157,6 +175,8 @@
viewportWidth = image.viewportWidth,
viewportHeight = image.viewportHeight,
name = image.name,
+ tintColor = image.tintColor,
+ tintBlendMode = image.tintBlendMode,
content = { _, _ -> RenderVectorGroup(group = image.root) }
)
@@ -169,6 +189,15 @@
internal var size by mutableStateOf(Size.Zero)
+ /**
+ * configures the intrinsic tint that may be defined on a VectorPainter
+ */
+ internal var intrinsicColorFilter: ColorFilter?
+ get() = vector.intrinsicColorFilter
+ set(value) {
+ vector.intrinsicColorFilter = value
+ }
+
private val vector = VectorComponent().apply {
invalidateCallback = {
isDirty = true
@@ -207,7 +236,9 @@
get() = size
override fun DrawScope.onDraw() {
- with(vector) { draw(currentAlpha, currentColorFilter) }
+ with(vector) {
+ draw(currentAlpha, currentColorFilter ?: intrinsicColorFilter)
+ }
// This conditional is necessary to obtain invalidation callbacks as the state is
// being read here which adds this callback to the snapshot observation
if (isDirty) {
diff --git a/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/input/pointer/SuspendingPointerInputFilter.kt b/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/input/pointer/SuspendingPointerInputFilter.kt
index 3f9f347..0511169 100644
--- a/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/input/pointer/SuspendingPointerInputFilter.kt
+++ b/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/input/pointer/SuspendingPointerInputFilter.kt
@@ -144,7 +144,7 @@
val density = AmbientDensity.current
val viewConfiguration = AmbientViewConfiguration.current
remember(density) { SuspendingPointerInputFilter(viewConfiguration, density) }.apply {
- LaunchedEffect(this) {
+ LaunchedEffect(this, block) {
block()
}
}
diff --git a/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/layout/SubcomposeLayout.kt b/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/layout/SubcomposeLayout.kt
index bce7512..a8161b6 100644
--- a/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/layout/SubcomposeLayout.kt
+++ b/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/layout/SubcomposeLayout.kt
@@ -19,9 +19,9 @@
import androidx.compose.runtime.Applier
import androidx.compose.runtime.Composable
import androidx.compose.runtime.Composition
-import androidx.compose.runtime.CompositionLifecycleObserver
import androidx.compose.runtime.CompositionReference
import androidx.compose.runtime.ExperimentalComposeApi
+import androidx.compose.runtime.RememberObserver
import androidx.compose.runtime.compositionReference
import androidx.compose.runtime.currentComposer
import androidx.compose.runtime.emit
@@ -102,7 +102,7 @@
private class SubcomposeLayoutState :
SubcomposeMeasureScope,
- CompositionLifecycleObserver {
+ RememberObserver {
var compositionRef: CompositionReference? = null
// MeasureScope delegation
@@ -215,11 +215,11 @@
}
}
- override fun onEnter() {
+ override fun onRemembered() {
// do nothing
}
- override fun onLeave() {
+ override fun onForgotten() {
nodeToNodeState.values.forEach {
it.composition!!.dispose()
}
@@ -227,6 +227,8 @@
slodIdToNode.clear()
}
+ override fun onAbandoned() = onForgotten()
+
private class NodeState(
val slotId: Any?,
var content: @Composable () -> Unit,
diff --git a/compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/input/key/Key.kt b/compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/input/key/Key.kt
index a93a3a9..5ad1221 100644
--- a/compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/input/key/Key.kt
+++ b/compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/input/key/Key.kt
@@ -17,10 +17,10 @@
package androidx.compose.ui.input.key
import java.awt.event.KeyEvent
-import java.awt.event.KeyEvent.KEY_LOCATION_LEFT as LocationLeft
-import java.awt.event.KeyEvent.KEY_LOCATION_NUMPAD as LocationNumpad
-import java.awt.event.KeyEvent.KEY_LOCATION_RIGHT as LocationRight
-import java.awt.event.KeyEvent.KEY_LOCATION_UNKNOWN as LocationUnknown
+import java.awt.event.KeyEvent.KEY_LOCATION_LEFT
+import java.awt.event.KeyEvent.KEY_LOCATION_NUMPAD
+import java.awt.event.KeyEvent.KEY_LOCATION_RIGHT
+import java.awt.event.KeyEvent.KEY_LOCATION_STANDARD
import androidx.compose.ui.util.unpackInt1
// TODO(demin): implement most of key codes
@@ -82,22 +82,22 @@
actual val Z = Key(KeyEvent.VK_Z)
actual val Comma = Key(KeyEvent.VK_COMMA)
actual val Period = Key(KeyEvent.VK_PERIOD)
- actual val AltLeft = Key(KeyEvent.VK_ALT, LocationLeft)
- actual val AltRight = Key(KeyEvent.VK_ALT, LocationRight)
- actual val ShiftLeft = Key(KeyEvent.VK_SHIFT, LocationLeft)
- actual val ShiftRight = Key(KeyEvent.VK_SHIFT, LocationRight)
+ actual val AltLeft = Key(KeyEvent.VK_ALT, KEY_LOCATION_LEFT)
+ actual val AltRight = Key(KeyEvent.VK_ALT, KEY_LOCATION_RIGHT)
+ actual val ShiftLeft = Key(KeyEvent.VK_SHIFT, KEY_LOCATION_LEFT)
+ actual val ShiftRight = Key(KeyEvent.VK_SHIFT, KEY_LOCATION_RIGHT)
actual val Tab = Key(KeyEvent.VK_TAB)
actual val Spacebar = Key(KeyEvent.VK_SPACE)
actual val Enter = Key(KeyEvent.VK_ENTER)
actual val Backspace = Key(KeyEvent.VK_BACK_SPACE)
actual val Delete = Key(KeyEvent.VK_DELETE)
actual val Escape = Key(KeyEvent.VK_ESCAPE)
- actual val CtrlLeft = Key(KeyEvent.VK_CONTROL, LocationLeft)
- actual val CtrlRight = Key(KeyEvent.VK_CONTROL, LocationRight)
+ actual val CtrlLeft = Key(KeyEvent.VK_CONTROL, KEY_LOCATION_LEFT)
+ actual val CtrlRight = Key(KeyEvent.VK_CONTROL, KEY_LOCATION_RIGHT)
actual val CapsLock = Key(KeyEvent.VK_CAPS_LOCK)
actual val ScrollLock = Key(KeyEvent.VK_SCROLL_LOCK)
- actual val MetaLeft = Key(KeyEvent.VK_META, LocationLeft)
- actual val MetaRight = Key(KeyEvent.VK_META, LocationRight)
+ actual val MetaLeft = Key(KeyEvent.VK_META, KEY_LOCATION_LEFT)
+ actual val MetaRight = Key(KeyEvent.VK_META, KEY_LOCATION_RIGHT)
actual val PrintScreen = Key(KeyEvent.VK_PRINTSCREEN)
actual val Grave = Key(KeyEvent.VK_BACK_QUOTE)
actual val LeftBracket = Key(KeyEvent.VK_OPEN_BRACKET)
@@ -121,27 +121,27 @@
actual val F10 = Key(KeyEvent.VK_F10)
actual val F11 = Key(KeyEvent.VK_F11)
actual val F12 = Key(KeyEvent.VK_F12)
- actual val NumLock = Key(KeyEvent.VK_NUM_LOCK, LocationNumpad)
- actual val NumPad0 = Key(KeyEvent.VK_NUMPAD0, LocationNumpad)
- actual val NumPad1 = Key(KeyEvent.VK_NUMPAD1, LocationNumpad)
- actual val NumPad2 = Key(KeyEvent.VK_NUMPAD2, LocationNumpad)
- actual val NumPad3 = Key(KeyEvent.VK_NUMPAD3, LocationNumpad)
- actual val NumPad4 = Key(KeyEvent.VK_NUMPAD4, LocationNumpad)
- actual val NumPad5 = Key(KeyEvent.VK_NUMPAD5, LocationNumpad)
- actual val NumPad6 = Key(KeyEvent.VK_NUMPAD6, LocationNumpad)
- actual val NumPad7 = Key(KeyEvent.VK_NUMPAD7, LocationNumpad)
- actual val NumPad8 = Key(KeyEvent.VK_NUMPAD8, LocationNumpad)
- actual val NumPad9 = Key(KeyEvent.VK_NUMPAD9, LocationNumpad)
- actual val NumPadDivide = Key(KeyEvent.VK_DIVIDE, LocationNumpad)
- actual val NumPadMultiply = Key(KeyEvent.VK_MULTIPLY, LocationNumpad)
- actual val NumPadSubtract = Key(KeyEvent.VK_SUBTRACT, LocationNumpad)
- actual val NumPadAdd = Key(KeyEvent.VK_ADD, LocationNumpad)
- actual val NumPadDot = Key(KeyEvent.VK_PERIOD, LocationNumpad)
- actual val NumPadComma = Key(KeyEvent.VK_COMMA, LocationNumpad)
- actual val NumPadEnter = Key(KeyEvent.VK_ENTER, LocationNumpad)
- actual val NumPadEquals = Key(KeyEvent.VK_EQUALS, LocationNumpad)
- actual val NumPadLeftParenthesis = Key(KeyEvent.VK_LEFT_PARENTHESIS, LocationNumpad)
- actual val NumPadRightParenthesis = Key(KeyEvent.VK_RIGHT_PARENTHESIS, LocationNumpad)
+ actual val NumLock = Key(KeyEvent.VK_NUM_LOCK, KEY_LOCATION_NUMPAD)
+ actual val NumPad0 = Key(KeyEvent.VK_NUMPAD0, KEY_LOCATION_NUMPAD)
+ actual val NumPad1 = Key(KeyEvent.VK_NUMPAD1, KEY_LOCATION_NUMPAD)
+ actual val NumPad2 = Key(KeyEvent.VK_NUMPAD2, KEY_LOCATION_NUMPAD)
+ actual val NumPad3 = Key(KeyEvent.VK_NUMPAD3, KEY_LOCATION_NUMPAD)
+ actual val NumPad4 = Key(KeyEvent.VK_NUMPAD4, KEY_LOCATION_NUMPAD)
+ actual val NumPad5 = Key(KeyEvent.VK_NUMPAD5, KEY_LOCATION_NUMPAD)
+ actual val NumPad6 = Key(KeyEvent.VK_NUMPAD6, KEY_LOCATION_NUMPAD)
+ actual val NumPad7 = Key(KeyEvent.VK_NUMPAD7, KEY_LOCATION_NUMPAD)
+ actual val NumPad8 = Key(KeyEvent.VK_NUMPAD8, KEY_LOCATION_NUMPAD)
+ actual val NumPad9 = Key(KeyEvent.VK_NUMPAD9, KEY_LOCATION_NUMPAD)
+ actual val NumPadDivide = Key(KeyEvent.VK_DIVIDE, KEY_LOCATION_NUMPAD)
+ actual val NumPadMultiply = Key(KeyEvent.VK_MULTIPLY, KEY_LOCATION_NUMPAD)
+ actual val NumPadSubtract = Key(KeyEvent.VK_SUBTRACT, KEY_LOCATION_NUMPAD)
+ actual val NumPadAdd = Key(KeyEvent.VK_ADD, KEY_LOCATION_NUMPAD)
+ actual val NumPadDot = Key(KeyEvent.VK_PERIOD, KEY_LOCATION_NUMPAD)
+ actual val NumPadComma = Key(KeyEvent.VK_COMMA, KEY_LOCATION_NUMPAD)
+ actual val NumPadEnter = Key(KeyEvent.VK_ENTER, KEY_LOCATION_NUMPAD)
+ actual val NumPadEquals = Key(KeyEvent.VK_EQUALS, KEY_LOCATION_NUMPAD)
+ actual val NumPadLeftParenthesis = Key(KeyEvent.VK_LEFT_PARENTHESIS, KEY_LOCATION_NUMPAD)
+ actual val NumPadRightParenthesis = Key(KeyEvent.VK_RIGHT_PARENTHESIS, KEY_LOCATION_NUMPAD)
// Unsupported Keys. These keys will never be sent by the desktop. However we need unique
// keycodes so that these constants can be used in a when statement without a warning.
@@ -330,7 +330,13 @@
}
}
-fun Key(nativeKeyCode: Int, nativeKeyLocation: Int = LocationUnknown): Key {
+/**
+ * Creates instance of [Key].
+ *
+ * @param nativeKeyCode represents this key as defined in [java.awt.event.KeyEvent]
+ * @param nativeKeyLocation represents the location of key as defined in [java.awt.event.KeyEvent]
+ */
+fun Key(nativeKeyCode: Int, nativeKeyLocation: Int = KEY_LOCATION_STANDARD): Key {
// First 32 bits are for keycode.
val keyCode = nativeKeyCode.toLong().shl(32)
diff --git a/compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/input/key/KeyEvent.kt b/compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/input/key/KeyEvent.kt
index 01f98e5..504ba3b 100644
--- a/compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/input/key/KeyEvent.kt
+++ b/compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/input/key/KeyEvent.kt
@@ -28,7 +28,7 @@
* The key that was pressed.
*/
actual val KeyEvent.key: Key
- get() = Key(nativeKeyEvent.keyCode)
+ get() = Key(nativeKeyEvent.keyCode, nativeKeyEvent.keyLocation)
/**
* The UTF16 value corresponding to the key event that was pressed. The unicode character
diff --git a/compose/ui/ui/src/desktopTest/kotlin/androidx/compose/ui/input/key/KeyInputUtil.kt b/compose/ui/ui/src/desktopTest/kotlin/androidx/compose/ui/input/key/KeyInputUtil.kt
index 3950a2d..24533e3 100644
--- a/compose/ui/ui/src/desktopTest/kotlin/androidx/compose/ui/input/key/KeyInputUtil.kt
+++ b/compose/ui/ui/src/desktopTest/kotlin/androidx/compose/ui/input/key/KeyInputUtil.kt
@@ -59,7 +59,7 @@
0,
VK_UNDEFINED,
KeyEventAwt.getKeyText(key.nativeKeyCode)[0],
- key.nativeKeyLocation
+ java.awt.event.KeyEvent.KEY_LOCATION_UNKNOWN
)
)
}
diff --git a/compose/ui/ui/src/desktopTest/kotlin/androidx/compose/ui/input/key/KeyTest.kt b/compose/ui/ui/src/desktopTest/kotlin/androidx/compose/ui/input/key/KeyTest.kt
index cadb0d0..ced3eff 100644
--- a/compose/ui/ui/src/desktopTest/kotlin/androidx/compose/ui/input/key/KeyTest.kt
+++ b/compose/ui/ui/src/desktopTest/kotlin/androidx/compose/ui/input/key/KeyTest.kt
@@ -57,7 +57,7 @@
}
@Test
- fun composeKey_to_unknownDesktopKeyLocation() {
+ fun composeKey_to_standardDesktopKeyLocation() {
// Arrange.
val key = Key.A
@@ -65,7 +65,7 @@
val desktopKeyLocation = key.nativeKeyLocation
// Arrange.
- assertThat(desktopKeyLocation).isEqualTo(KeyEvent.KEY_LOCATION_UNKNOWN)
+ assertThat(desktopKeyLocation).isEqualTo(KeyEvent.KEY_LOCATION_STANDARD)
}
@Test
diff --git a/development/build_log_simplifier/messages.ignore b/development/build_log_simplifier/messages.ignore
index 6ab7ed0..76dc4e1 100644
--- a/development/build_log_simplifier/messages.ignore
+++ b/development/build_log_simplifier/messages.ignore
@@ -20,7 +20,6 @@
\- Declare the version of Java your build requires
\- Java [0-9]+ support
For more details see https\:\/\/docs\.gradle\.org\/[0-9]+\.[0-9]+\.[0-9]+\/release\-notes\.html
-Starting a Gradle Daemon \(subsequent builds will be faster\)
To honour the JVM settings for this build a new JVM will be forked\. Please consider using the daemon\: https\:\/\/docs\.gradle\.org\/[0-9]+\.[0-9]+\.[0-9]+\/userguide\/gradle_daemon\.html\.
For more details see https://docs\.gradle\.org/[0-9]+\.[0-9]+/release\-notes\.html
To honour the JVM settings for this build a new JVM will be forked\. Please consider using the daemon: https://docs\.gradle\.org/[0-9]+\.[0-9]+/userguide/gradle_daemon\.html\.
@@ -634,20 +633,4 @@
w\: \$SUPPORT\/viewpager[0-9]+\/viewpager[0-9]+\/src\/androidTest\/java\/androidx\/viewpager[0-9]+\/widget\/OnApplyWindowInsetsListenerTest\.kt\: \([0-9]+\, [0-9]+\)\: Unnecessary non\-null assertion \(\!\!\) on a non\-null receiver of type WindowInsetsCompat
w\: \$SUPPORT\/viewpager[0-9]+\/viewpager[0-9]+\/src\/androidTest\/java\/androidx\/viewpager[0-9]+\/widget\/OnApplyWindowInsetsListenerTest\.kt\: \([0-9]+\, [0-9]+\)\: \'consumeStableInsets\(\)\: WindowInsetsCompat\' is deprecated\. Deprecated in Java
w\: \$SUPPORT\/viewpager[0-9]+\/viewpager[0-9]+\/src\/androidTest\/java\/androidx\/viewpager[0-9]+\/widget\/OnApplyWindowInsetsListenerTest\.kt\: \([0-9]+\, [0-9]+\)\: \'consumeDisplayCutout\(\)\: WindowInsetsCompat\' is deprecated\. Deprecated in Java
-# > Task :contentpager:contentpager:compileDebugAndroidTestJavaWithJavac
-# > Task :wear:wear-tiles:generateApi
-src/main/java/androidx/wear/tiles/builders/ActionBuilders\.java:[0-9]+: info: Unresolved import: `androidx\.wear\.tiles\.proto\.ActionProto` \[UnresolvedImport\]
-src/main/java/androidx/wear/tiles/builders/ActionBuilders\.java:[0-9]+: info: Unresolved import: `androidx\.wear\.tiles\.proto\.ActionProto` \[UnresolvedImport\]src/main/java/androidx/wear/tiles/builders/ActionBuilders\.java:[0-9]+: info: Unresolved import: `androidx\.wear\.tiles\.proto\.ActionProto` \[UnresolvedImport\]
-src/main/java/androidx/wear/tiles/builders/ColorBuilders\.java:[0-9]+: info: Unresolved import: `androidx\.wear\.tiles\.proto\.ColorProto` \[UnresolvedImport\]
-src/main/java/androidx/wear/tiles/readers/DeviceParametersReaders\.java:[0-9]+: info: Unresolved import: `androidx\.wear\.tiles\.proto\.DeviceParametersProto` \[UnresolvedImport\]
-src/main/java/androidx/wear/tiles/builders/DimensionBuilders\.java:[0-9]+: info: Unresolved import: `androidx\.wear\.tiles\.proto\.DimensionProto` \[UnresolvedImport\]
-src/main/java/androidx/wear/tiles/builders/LayoutElementBuilders\.java:[0-9]+: info: Unresolved import: `androidx\.wear\.tiles\.proto\.LayoutElementProto` \[UnresolvedImport\]src/main/java/androidx/wear/tiles/builders/LayoutElementBuilders\.java:[0-9]+: info: Unresolved import: `androidx\.wear\.tiles\.proto\.LayoutElementProto` \[UnresolvedImport\]
-src/main/java/androidx/wear/tiles/builders/LayoutElementBuilders\.java:[0-9]+: info: Unresolved import: `androidx\.wear\.tiles\.proto\.TypesProto` \[UnresolvedImport\]src/main/java/androidx/wear/tiles/builders/LayoutElementBuilders\.java:[0-9]+: info: Unresolved import: `androidx\.wear\.tiles\.proto\.TypesProto` \[UnresolvedImport\]
-src/main/java/androidx/wear/tiles/builders/LayoutElementBuilders\.java:[0-9]+: info: Unresolved import: `androidx\.wear\.tiles\.proto\.LayoutElementProto` \[UnresolvedImport\]
-src/main/java/androidx/wear/tiles/builders/LayoutElementBuilders\.java:[0-9]+: info: Unresolved import: `androidx\.wear\.tiles\.proto\.TypesProto` \[UnresolvedImport\]
-src/main/java/androidx/wear/tiles/readers/RequestReaders\.java:[0-9]+: info: Unresolved import: `androidx\.wear\.tiles\.proto\.RequestProto` \[UnresolvedImport\]src/main/java/androidx/wear/tiles/readers/RequestReaders\.java:[0-9]+: info: Unresolved import: `androidx\.wear\.tiles\.proto\.RequestProto` \[UnresolvedImport\]src/main/java/androidx/wear/tiles/readers/RequestReaders\.java:[0-9]+: info: Unresolved import: `androidx\.wear\.tiles\.proto\.RequestProto` \[UnresolvedImport\]
-src/main/java/androidx/wear/tiles/builders/ResourceBuilders\.java:[0-9]+: info: Unresolved import: `androidx\.wear\.tiles\.proto\.ResourceProto` \[UnresolvedImport\]src/main/java/androidx/wear/tiles/builders/ResourceBuilders\.java:[0-9]+: info: Unresolved import: `androidx\.wear\.tiles\.proto\.ResourceProto` \[UnresolvedImport\]
-src/main/java/androidx/wear/tiles/readers/RequestReaders\.java:[0-9]+: info: Unresolved import: `androidx\.wear\.tiles\.proto\.RequestProto` \[UnresolvedImport\]
-src/main/java/androidx/wear/tiles/builders/ResourceBuilders\.java:[0-9]+: info: Unresolved import: `androidx\.wear\.tiles\.proto\.ResourceProto` \[UnresolvedImport\]
-src/main/java/androidx/wear/tiles/builders/TileBuilders\.java:[0-9]+: info: Unresolved import: `androidx\.wear\.tiles\.proto\.TileProto` \[UnresolvedImport\]
-src/main/java/androidx/wear/tiles/builders/TimelineBuilders\.java:[0-9]+: info: Unresolved import: `androidx\.wear\.tiles\.proto\.TimelineProto` \[UnresolvedImport\]
\ No newline at end of file
+# > Task :contentpager:contentpager:compileDebugAndroidTestJavaWithJavac
\ No newline at end of file
diff --git a/docs/api_guidelines.md b/docs/api_guidelines.md
index aa55d65..9b1fcb7 100644
--- a/docs/api_guidelines.md
+++ b/docs/api_guidelines.md
@@ -982,6 +982,10 @@
### Java 8 {#dependencies-java8}
+NOTE All Jetpack libraries will migrate to Java 8 as soon as Android Studio 4.2
+launches to stable. Until then, new dependencies on Java 8 should weigh the pros
+and cons as documented here.
+
Libraries that take a dependency on a library targeting Java 8 must _also_
target Java 8, which will incur a ~5% build performance (as of 8/2019) hit for
clients. New libraries targeting Java 8 may use Java 8 dependencies; however,
diff --git a/docs/policies.md b/docs/policies.md
index 1cf4502..f42d6dc 100644
--- a/docs/policies.md
+++ b/docs/policies.md
@@ -27,17 +27,16 @@
samples/ [<feature-name>:samples]
```
-For example, the `room` library group's directory structure is:
+For example, the `navigation` library group's directory structure is:
```
-room/
- common/ [room:room-common]
+navigation/
+ navigation-benchmark/ [navigation:navigation-benchmark]
...
- rxjava2/ [room:room-rxjava2]
- testing/ [room:room-testing]
+ navigation-ui/ [navigation:navigation-ui]
+ navigation-ui-ktx/ [navigation:navigation-ui-ktx]
integration-tests/
- testapp/ [room:testapp]
- testapp-kotlin/ [room:testapp-kotlin]
+ testapp/ [navigation:integration-tests:testapp]
```
## Terminology {#terminology}
diff --git a/docs/versioning.md b/docs/versioning.md
index 16c7498..3b320ba 100644
--- a/docs/versioning.md
+++ b/docs/versioning.md
@@ -295,8 +295,9 @@
1. Update the version listed in
`frameworks/support/buildSrc/src/main/kotlin/androidx/build/LibraryVersions.kt`
-1. Run `./gradlew <your-lib>:updateApi`. This will create an API txt file for
- the new version of your library.
+1. If your library is a `beta` or `rc01` version, run `./gradlew
+ <your-lib>:updateApi`. This will create an API txt file for the new version
+ of your library. For other versions, this step is not reqired
1. Verify changes with `./gradlew checkApi verifyDependencyVersions`.
1. Commit these change as one commit.
1. Upload these changes to Gerrit for review.
diff --git a/fragment/fragment/src/main/res/values/public.xml b/fragment/fragment/src/main/res/values/public.xml
index 0aaeb15..73009f1 100644
--- a/fragment/fragment/src/main/res/values/public.xml
+++ b/fragment/fragment/src/main/res/values/public.xml
@@ -16,5 +16,4 @@
-->
<resources>
- <public />
-</resources>
\ No newline at end of file
+</resources>
diff --git a/hilt/hilt-common/api/current.txt b/hilt/hilt-common/api/current.txt
index b150978..2d016ea 100644
--- a/hilt/hilt-common/api/current.txt
+++ b/hilt/hilt-common/api/current.txt
@@ -1,21 +1,21 @@
// Signature format: 4.0
package androidx.hilt {
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.RUNTIME) @java.lang.annotation.Target(java.lang.annotation.ElementType.PARAMETER) public @interface Assisted {
+ @Deprecated @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.RUNTIME) @java.lang.annotation.Target(java.lang.annotation.ElementType.PARAMETER) public @interface Assisted {
}
}
package androidx.hilt.lifecycle {
- @dagger.hilt.GeneratesRootInput @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target(java.lang.annotation.ElementType.CONSTRUCTOR) public @interface ViewModelInject {
+ @Deprecated @dagger.hilt.GeneratesRootInput @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target(java.lang.annotation.ElementType.CONSTRUCTOR) public @interface ViewModelInject {
}
}
package androidx.hilt.work {
- @dagger.hilt.GeneratesRootInput @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target(java.lang.annotation.ElementType.CONSTRUCTOR) public @interface WorkerInject {
+ @dagger.hilt.GeneratesRootInput @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE) public @interface HiltWorker {
}
}
diff --git a/hilt/hilt-common/api/public_plus_experimental_current.txt b/hilt/hilt-common/api/public_plus_experimental_current.txt
index b150978..2d016ea 100644
--- a/hilt/hilt-common/api/public_plus_experimental_current.txt
+++ b/hilt/hilt-common/api/public_plus_experimental_current.txt
@@ -1,21 +1,21 @@
// Signature format: 4.0
package androidx.hilt {
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.RUNTIME) @java.lang.annotation.Target(java.lang.annotation.ElementType.PARAMETER) public @interface Assisted {
+ @Deprecated @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.RUNTIME) @java.lang.annotation.Target(java.lang.annotation.ElementType.PARAMETER) public @interface Assisted {
}
}
package androidx.hilt.lifecycle {
- @dagger.hilt.GeneratesRootInput @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target(java.lang.annotation.ElementType.CONSTRUCTOR) public @interface ViewModelInject {
+ @Deprecated @dagger.hilt.GeneratesRootInput @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target(java.lang.annotation.ElementType.CONSTRUCTOR) public @interface ViewModelInject {
}
}
package androidx.hilt.work {
- @dagger.hilt.GeneratesRootInput @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target(java.lang.annotation.ElementType.CONSTRUCTOR) public @interface WorkerInject {
+ @dagger.hilt.GeneratesRootInput @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE) public @interface HiltWorker {
}
}
diff --git a/hilt/hilt-common/api/restricted_current.txt b/hilt/hilt-common/api/restricted_current.txt
index b150978..2d016ea 100644
--- a/hilt/hilt-common/api/restricted_current.txt
+++ b/hilt/hilt-common/api/restricted_current.txt
@@ -1,21 +1,21 @@
// Signature format: 4.0
package androidx.hilt {
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.RUNTIME) @java.lang.annotation.Target(java.lang.annotation.ElementType.PARAMETER) public @interface Assisted {
+ @Deprecated @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.RUNTIME) @java.lang.annotation.Target(java.lang.annotation.ElementType.PARAMETER) public @interface Assisted {
}
}
package androidx.hilt.lifecycle {
- @dagger.hilt.GeneratesRootInput @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target(java.lang.annotation.ElementType.CONSTRUCTOR) public @interface ViewModelInject {
+ @Deprecated @dagger.hilt.GeneratesRootInput @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target(java.lang.annotation.ElementType.CONSTRUCTOR) public @interface ViewModelInject {
}
}
package androidx.hilt.work {
- @dagger.hilt.GeneratesRootInput @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target(java.lang.annotation.ElementType.CONSTRUCTOR) public @interface WorkerInject {
+ @dagger.hilt.GeneratesRootInput @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE) public @interface HiltWorker {
}
}
diff --git a/hilt/hilt-common/build.gradle b/hilt/hilt-common/build.gradle
index 8c6ee95..197ab1c 100644
--- a/hilt/hilt-common/build.gradle
+++ b/hilt/hilt-common/build.gradle
@@ -37,4 +37,7 @@
mavenGroup = LibraryGroups.HILT
inceptionYear = "2020"
description = "AndroidX Hilt Extension Annotations"
+ // TODO(danysantiago): Remove once @ViewModelInject is deleted.
+ // This suppresses the the warning in the generated code by Hilt's GeneratesRootInput processor.
+ failOnDeprecationWarnings = false
}
diff --git a/hilt/hilt-common/src/main/java/androidx/hilt/Assisted.java b/hilt/hilt-common/src/main/java/androidx/hilt/Assisted.java
index 6da5548..14cc41e 100644
--- a/hilt/hilt-common/src/main/java/androidx/hilt/Assisted.java
+++ b/hilt/hilt-common/src/main/java/androidx/hilt/Assisted.java
@@ -22,12 +22,12 @@
import java.lang.annotation.Target;
/**
- * Marks a parameter in a {@link androidx.hilt.lifecycle.ViewModelInject}-annotated constructor
- * or a {@link androidx.hilt.work.WorkerInject}-annotated constructor to be assisted
- * injected at runtime via a factory.
+ * Marks a parameter in a {@link androidx.hilt.lifecycle.ViewModelInject}-annotated constructor.
+ *
+ * @deprecated Use <a href="https://dagger.dev/api/latest/dagger/assisted/Assisted">Assisted</a>
*/
-// TODO(danysantiago): Remove and replace with dagger.assisted.
@Target(ElementType.PARAMETER)
@Retention(RetentionPolicy.RUNTIME)
+@Deprecated
public @interface Assisted {
}
diff --git a/hilt/hilt-common/src/main/java/androidx/hilt/lifecycle/ViewModelInject.java b/hilt/hilt-common/src/main/java/androidx/hilt/lifecycle/ViewModelInject.java
index 9abeb64..5b4666e 100644
--- a/hilt/hilt-common/src/main/java/androidx/hilt/lifecycle/ViewModelInject.java
+++ b/hilt/hilt-common/src/main/java/androidx/hilt/lifecycle/ViewModelInject.java
@@ -30,7 +30,8 @@
* with {@code ViewModelInject} will have its dependencies defined in the constructor parameters
* injected by Dagger's Hilt. The {@code ViewModel} will be available for creation by the
* {@link androidx.hilt.lifecycle.HiltViewModelFactory} and can be retrieved by default in an {@code
- * Activity} or {@code Fragment} annotated with {@link dagger.hilt.android.AndroidEntryPoint}.
+ * Activity} or {@code Fragment} annotated with
+ * <a href="https://dagger.dev/api/latest/dagger/hilt/android/AndroidEntryPoint">AndroidEntryPoint</a>.
* <p>
* Example:
* <pre>
@@ -54,14 +55,18 @@
* constructor can optionally define a {@link androidx.hilt.Assisted}-annotated
* {@link androidx.lifecycle.SavedStateHandle} parameter along with any other dependency. The
* {@code SavedStateHandle} must not be a type param of {@link javax.inject.Provider} nor
- * {@link dagger.Lazy} and must not be qualified.
+ * <a href="https://dagger.dev/api/latest/dagger/Lazy">Lazy</a> and must not be qualified.
* <p>
* Only dependencies available in the
- * {@link dagger.hilt.android.components.ActivityRetainedComponent} can be injected into the
- * {@code ViewModel}.
+ * <a href="https://dagger.dev/api/latest/dagger/hilt/components/ActivityRetainedComponent">ActivityRetainedComponent</a>
+ * can be injected into the {@code ViewModel}.
+ *
+ * @deprecated Use
+ * <a href="https://dagger.dev/api/latest/dagger/hilt/android/lifecycle/HiltViewModel">HiltViewModel</a>.
*/
@Target(ElementType.CONSTRUCTOR)
@Retention(RetentionPolicy.CLASS)
@GeneratesRootInput
+@Deprecated
public @interface ViewModelInject {
}
diff --git a/hilt/hilt-common/src/main/java/androidx/hilt/work/WorkerInject.java b/hilt/hilt-common/src/main/java/androidx/hilt/work/HiltWorker.java
similarity index 62%
rename from hilt/hilt-common/src/main/java/androidx/hilt/work/WorkerInject.java
rename to hilt/hilt-common/src/main/java/androidx/hilt/work/HiltWorker.java
index 7beca86..6233a06 100644
--- a/hilt/hilt-common/src/main/java/androidx/hilt/work/WorkerInject.java
+++ b/hilt/hilt-common/src/main/java/androidx/hilt/work/HiltWorker.java
@@ -26,17 +26,19 @@
/**
* Identifies a {@link androidx.work.ListenableWorker}'s constructor for injection.
* <p>
- * Similar to {@link javax.inject.Inject}, a {@code Worker} containing a constructor annotated
- * with {@code WorkerInject} will have its dependencies defined in the constructor parameters
- * injected by Dagger's Hilt. The {@code Worker} will be available for creation by the
+ * The {@code Worker} will be available for creation by the
* {@link androidx.hilt.work.HiltWorkerFactory} that should be set in {@code WorkManager}'s
* configuration via
* {@link androidx.work.Configuration.Builder#setWorkerFactory(androidx.work.WorkerFactory)}.
+ * The {@code HiltWorker} containing a constructor annotated with
+ * <a href="https://dagger.dev/api/latest/dagger/assisted/AssistedInject">AssistedInject</a> will
+ * have its dependencies defined in the constructor parameters injected by Dagger's Hilt.
* <p>
* Example:
* <pre>
+ * @HiltWorker
* public class UploadWorker extends Worker {
- * @WorkerInject
+ * @AssistedInject
* public UploadWorker(@Assisted Context context, @Assisted WorkerParameters params,
* HttpClient httpClient) {
* // ...
@@ -57,17 +59,22 @@
* }
* </pre>
* <p>
- * Only one constructor in the {@code Worker} must be annotated with {@code WorkerInject}. The
- * constructor must define parameters for a {@link androidx.hilt.Assisted}-annotated {@code Context}
- * and a {@link androidx.hilt.Assisted}-annotated {@code WorkerParameters} along with any other
- * dependencies. Both the {@code Context} and {@code WorkerParameters} must not be a type param
- * of {@link javax.inject.Provider} nor {@link dagger.Lazy} and must not be qualified.
+ * Only one constructor in the {@code Worker} must be annotated with
+ * <a href="https://dagger.dev/api/latest/dagger/assisted/AssistedInject">AssistedInject</a>.
+ * The constructor must define parameters for a
+ * <a href="https://dagger.dev/api/latest/dagger/assisted/Assisted">Assisted</a>-annotated
+ * {@code Context} and a
+ * <a href="https://dagger.dev/api/latest/dagger/assisted/Assisted">Assisted</a>-annotated
+ * {@code WorkerParameters} along with any other dependencies. Both the {@code Context} and
+ * {@code WorkerParameters} must not be a type param of {@link javax.inject.Provider} nor
+ * <a href="https://dagger.dev/api/latest/dagger/Lazy">Lazy</a> and must not be qualified.
* <p>
- * Only dependencies available in the {@link dagger.hilt.components.SingletonComponent}
+ * Only dependencies available in the
+ * <a href="https://dagger.dev/api/latest/dagger/hilt/components/SingletonComponent">SingletonComponent</a>
* can be injected into the {@code Worker}.
*/
-@Target(ElementType.CONSTRUCTOR)
+@Target(ElementType.TYPE)
@Retention(RetentionPolicy.CLASS)
@GeneratesRootInput
-public @interface WorkerInject {
+public @interface HiltWorker {
}
diff --git a/hilt/hilt-compiler/src/main/kotlin/androidx/hilt/AndroidXHiltProcessor.kt b/hilt/hilt-compiler/src/main/kotlin/androidx/hilt/AndroidXHiltProcessor.kt
index fb305895..e5c8c10 100644
--- a/hilt/hilt-compiler/src/main/kotlin/androidx/hilt/AndroidXHiltProcessor.kt
+++ b/hilt/hilt-compiler/src/main/kotlin/androidx/hilt/AndroidXHiltProcessor.kt
@@ -17,7 +17,7 @@
package androidx.hilt
import androidx.hilt.lifecycle.ViewModelInjectStep
-import androidx.hilt.work.WorkerInjectStep
+import androidx.hilt.work.WorkerStep
import com.google.auto.service.AutoService
import net.ltgt.gradle.incap.IncrementalAnnotationProcessor
import net.ltgt.gradle.incap.IncrementalAnnotationProcessorType.ISOLATING
@@ -37,7 +37,7 @@
override fun getSupportedAnnotationTypes() = setOf(
ClassNames.VIEW_MODEL_INJECT.canonicalName(),
- ClassNames.WORKER_INJECT.canonicalName()
+ ClassNames.HILT_WORKER.canonicalName()
)
override fun getSupportedSourceVersion() = SourceVersion.latest()
@@ -56,7 +56,7 @@
private fun getSteps() = listOf(
ViewModelInjectStep(processingEnv),
- WorkerInjectStep(processingEnv)
+ WorkerStep(processingEnv)
)
interface Step {
diff --git a/hilt/hilt-compiler/src/main/kotlin/androidx/hilt/ClassNames.kt b/hilt/hilt-compiler/src/main/kotlin/androidx/hilt/ClassNames.kt
index c627b01..f6fbb5b 100644
--- a/hilt/hilt-compiler/src/main/kotlin/androidx/hilt/ClassNames.kt
+++ b/hilt/hilt-compiler/src/main/kotlin/androidx/hilt/ClassNames.kt
@@ -21,9 +21,13 @@
internal object ClassNames {
val ACTIVITY_RETAINED_COMPONENT =
ClassName.get("dagger.hilt.android.components", "ActivityRetainedComponent")
- val ASSISTED = ClassName.get("androidx.hilt", "Assisted")
+ val ANDROIDX_ASSISTED = ClassName.get("androidx.hilt", "Assisted")
+ val ASSISTED = ClassName.get("dagger.assisted", "Assisted")
+ val ASSISTED_FACTORY = ClassName.get("dagger.assisted", "AssistedFactory")
+ val ASSISTED_INJECT = ClassName.get("dagger.assisted", "AssistedInject")
val BINDS = ClassName.get("dagger", "Binds")
val CONTEXT = ClassName.get("android.content", "Context")
+ val HILT_WORKER = ClassName.get("androidx.hilt.work", "HiltWorker")
val NON_NULL = ClassName.get("androidx.annotation", "NonNull")
val INJECT = ClassName.get("javax.inject", "Inject")
val INSTALL_IN = ClassName.get("dagger.hilt", "InstallIn")
@@ -42,6 +46,5 @@
val STRING_KEY = ClassName.get("dagger.multibindings", "StringKey")
val WORKER = ClassName.get("androidx.work", "Worker")
val WORKER_ASSISTED_FACTORY = ClassName.get("androidx.hilt.work", "WorkerAssistedFactory")
- val WORKER_INJECT = ClassName.get("androidx.hilt.work", "WorkerInject")
val WORKER_PARAMETERS = ClassName.get("androidx.work", "WorkerParameters")
}
diff --git a/hilt/hilt-compiler/src/main/kotlin/androidx/hilt/assisted/DependencyRequest.kt b/hilt/hilt-compiler/src/main/kotlin/androidx/hilt/assisted/DependencyRequest.kt
index eb4d5e6..a2edb27 100644
--- a/hilt/hilt-compiler/src/main/kotlin/androidx/hilt/assisted/DependencyRequest.kt
+++ b/hilt/hilt-compiler/src/main/kotlin/androidx/hilt/assisted/DependencyRequest.kt
@@ -59,7 +59,10 @@
return DependencyRequest(
name = simpleName.toString(),
type = type,
- isAssisted = hasAnnotation(ClassNames.ASSISTED.canonicalName()) && qualifier == null,
+ isAssisted = (
+ hasAnnotation(ClassNames.ANDROIDX_ASSISTED.canonicalName()) ||
+ hasAnnotation(ClassNames.ASSISTED.canonicalName())
+ ) && qualifier == null,
qualifier = qualifier
)
}
\ No newline at end of file
diff --git a/hilt/hilt-compiler/src/main/kotlin/androidx/hilt/lifecycle/ViewModelInjectStep.kt b/hilt/hilt-compiler/src/main/kotlin/androidx/hilt/lifecycle/ViewModelInjectStep.kt
index c86a7bf..fadbe8e 100644
--- a/hilt/hilt-compiler/src/main/kotlin/androidx/hilt/lifecycle/ViewModelInjectStep.kt
+++ b/hilt/hilt-compiler/src/main/kotlin/androidx/hilt/lifecycle/ViewModelInjectStep.kt
@@ -121,7 +121,7 @@
valid = false
}
firstOrNull()?.let {
- if (!it.hasAnnotation(ClassNames.ASSISTED.canonicalName())) {
+ if (!it.hasAnnotation(ClassNames.ANDROIDX_ASSISTED.canonicalName())) {
error("Missing @Assisted annotation in param '${it.simpleName}'.", it)
valid = false
}
diff --git a/hilt/hilt-compiler/src/main/kotlin/androidx/hilt/work/WorkerInjectElements.kt b/hilt/hilt-compiler/src/main/kotlin/androidx/hilt/work/WorkerElements.kt
similarity index 97%
rename from hilt/hilt-compiler/src/main/kotlin/androidx/hilt/work/WorkerInjectElements.kt
rename to hilt/hilt-compiler/src/main/kotlin/androidx/hilt/work/WorkerElements.kt
index 03f4c05..0b6c84d 100644
--- a/hilt/hilt-compiler/src/main/kotlin/androidx/hilt/work/WorkerInjectElements.kt
+++ b/hilt/hilt-compiler/src/main/kotlin/androidx/hilt/work/WorkerElements.kt
@@ -27,7 +27,7 @@
/**
* Data class that represents a Hilt injected Worker
*/
-internal data class WorkerInjectElements(
+internal data class WorkerElements(
val typeElement: TypeElement,
val constructorElement: ExecutableElement
) {
diff --git a/hilt/hilt-compiler/src/main/kotlin/androidx/hilt/work/WorkerGenerator.kt b/hilt/hilt-compiler/src/main/kotlin/androidx/hilt/work/WorkerGenerator.kt
index 3552dfc..4052322 100644
--- a/hilt/hilt-compiler/src/main/kotlin/androidx/hilt/work/WorkerGenerator.kt
+++ b/hilt/hilt-compiler/src/main/kotlin/androidx/hilt/work/WorkerGenerator.kt
@@ -17,7 +17,6 @@
package androidx.hilt.work
import androidx.hilt.ClassNames
-import androidx.hilt.assisted.AssistedFactoryGenerator
import androidx.hilt.ext.S
import androidx.hilt.ext.T
import androidx.hilt.ext.addGeneratedAnnotation
@@ -46,40 +45,27 @@
* ```
* and
* ```
- * public final class $_AssistedFactory extends WorkerAssistedFactory<$> {
+ * @AssistedFactory
+ * public interface $_AssistedFactory extends WorkerAssistedFactory<$> {
*
- * private final Provider<Dep1> dep1;
- * private final Provider<Dep2> dep2;
- * ...
- *
- * @Inject
- * $_AssistedFactory(Provider<Dep1> dep1, Provider<Dep2> dep2, ...) {
- * this.dep1 = dep1;
- * this.dep2 = dep2;
- * ...
- * }
- *
- * @Override
- * @NonNull
- * public $ create(@NonNull Context context, @NonNull WorkerParameter params) {
- * return new $(context, params, dep1.get(), dep2.get());
- * }
* }
* ```
*/
internal class WorkerGenerator(
private val processingEnv: ProcessingEnvironment,
- private val injectedWorker: WorkerInjectElements
+ private val injectedWorker: WorkerElements
) {
fun generate() {
- AssistedFactoryGenerator(
- processingEnv = processingEnv,
- productClassName = injectedWorker.className,
- factoryClassName = injectedWorker.factoryClassName,
- factorySuperTypeName = injectedWorker.factorySuperTypeName,
- originatingElement = injectedWorker.typeElement,
- dependencyRequests = injectedWorker.dependencyRequests
- ).generate()
+ val assistedFactoryTypeSpec = TypeSpec.interfaceBuilder(injectedWorker.factoryClassName)
+ .addOriginatingElement(injectedWorker.typeElement)
+ .addGeneratedAnnotation(processingEnv.elementUtils, processingEnv.sourceVersion)
+ .addAnnotation(ClassNames.ASSISTED_FACTORY)
+ .addModifiers(Modifier.PUBLIC)
+ .addSuperinterface(injectedWorker.factorySuperTypeName)
+ .build()
+ JavaFile.builder(injectedWorker.factoryClassName.packageName(), assistedFactoryTypeSpec)
+ .build()
+ .writeTo(processingEnv.filer)
val hiltModuleTypeSpec = TypeSpec.interfaceBuilder(injectedWorker.moduleClassName)
.addOriginatingElement(injectedWorker.typeElement)
diff --git a/hilt/hilt-compiler/src/main/kotlin/androidx/hilt/work/WorkerInjectStep.kt b/hilt/hilt-compiler/src/main/kotlin/androidx/hilt/work/WorkerInjectStep.kt
deleted file mode 100644
index 346f308..0000000
--- a/hilt/hilt-compiler/src/main/kotlin/androidx/hilt/work/WorkerInjectStep.kt
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * 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.hilt.work
-
-import androidx.hilt.AndroidXHiltProcessor
-import androidx.hilt.ClassNames
-import androidx.hilt.ext.hasAnnotation
-import com.google.auto.common.MoreElements
-import com.squareup.javapoet.TypeName
-import javax.annotation.processing.ProcessingEnvironment
-import javax.lang.model.element.Element
-import javax.lang.model.element.ExecutableElement
-import javax.lang.model.element.Modifier
-import javax.lang.model.element.NestingKind
-import javax.lang.model.element.TypeElement
-import javax.lang.model.util.ElementFilter
-import javax.tools.Diagnostic
-
-/**
- * Processing step that generates code enabling assisted injection of Workers using Hilt.
- */
-class WorkerInjectStep(
- private val processingEnv: ProcessingEnvironment
-) : AndroidXHiltProcessor.Step {
-
- private val elements = processingEnv.elementUtils
- private val types = processingEnv.typeUtils
- private val messager = processingEnv.messager
-
- override fun annotation() = ClassNames.WORKER_INJECT.canonicalName()
-
- override fun process(annotatedElements: Set<Element>) {
- val parsedElements = mutableSetOf<TypeElement>()
- annotatedElements.forEach { element ->
- val constructorElement =
- MoreElements.asExecutable(element)
- val typeElement =
- MoreElements.asType(constructorElement.enclosingElement)
- if (parsedElements.add(typeElement)) {
- parse(typeElement, constructorElement)?.let { worker ->
- WorkerGenerator(
- processingEnv,
- worker
- ).generate()
- }
- }
- }
- }
-
- private fun parse(
- typeElement: TypeElement,
- constructorElement: ExecutableElement
- ): WorkerInjectElements? {
- var valid = true
-
- if (elements.getTypeElement(ClassNames.WORKER_ASSISTED_FACTORY.toString()) == null) {
- error(
- "To use @WorkerInject you must add the 'work' artifact. " +
- "androidx.hilt:hilt-work:<version>"
- )
- valid = false
- }
-
- if (!types.isSubtype(
- typeElement.asType(),
- elements.getTypeElement(ClassNames.LISTENABLE_WORKER.toString()).asType()
- )
- ) {
- error(
- "@WorkerInject is only supported on types that subclass " +
- "${ClassNames.LISTENABLE_WORKER}."
- )
- valid = false
- }
-
- ElementFilter.constructorsIn(typeElement.enclosedElements).filter {
- it.hasAnnotation(ClassNames.WORKER_INJECT.canonicalName())
- }.let { constructors ->
- if (constructors.size > 1) {
- error("Multiple @WorkerInject annotated constructors found.", typeElement)
- valid = false
- }
- constructors.filter { it.modifiers.contains(Modifier.PRIVATE) }.forEach {
- error("@WorkerInject annotated constructors must not be private.", it)
- valid = false
- }
- }
-
- if (typeElement.nestingKind == NestingKind.MEMBER &&
- !typeElement.modifiers.contains(Modifier.STATIC)
- ) {
- error(
- "@WorkerInject may only be used on inner classes if they are static.",
- typeElement
- )
- valid = false
- }
-
- constructorElement.parameters.filter {
- TypeName.get(it.asType()) == ClassNames.CONTEXT
- }.apply {
- if (size != 1) {
- error(
- "Expected exactly one constructor argument of type " +
- "${ClassNames.CONTEXT}, found $size",
- constructorElement
- )
- valid = false
- }
- firstOrNull()?.let {
- if (!it.hasAnnotation(ClassNames.ASSISTED.canonicalName())) {
- error("Missing @Assisted annotation in param '${it.simpleName}'.", it)
- valid = false
- }
- }
- }
-
- constructorElement.parameters.filter {
- TypeName.get(it.asType()) == ClassNames.WORKER_PARAMETERS
- }.apply {
- if (size != 1) {
- error(
- "Expected exactly one constructor argument of type " +
- "${ClassNames.WORKER_PARAMETERS}, found $size",
- constructorElement
- )
- valid = false
- }
- firstOrNull()?.let {
- if (!it.hasAnnotation(ClassNames.ASSISTED.canonicalName())) {
- error("Missing @Assisted annotation in param '${it.simpleName}'.", it)
- valid = false
- }
- }
- }
-
- if (!valid) return null
-
- return WorkerInjectElements(typeElement, constructorElement)
- }
-
- private fun error(message: String, element: Element? = null) {
- messager.printMessage(Diagnostic.Kind.ERROR, message, element)
- }
-}
\ No newline at end of file
diff --git a/hilt/hilt-compiler/src/main/kotlin/androidx/hilt/work/WorkerStep.kt b/hilt/hilt-compiler/src/main/kotlin/androidx/hilt/work/WorkerStep.kt
new file mode 100644
index 0000000..0fbdfa3
--- /dev/null
+++ b/hilt/hilt-compiler/src/main/kotlin/androidx/hilt/work/WorkerStep.kt
@@ -0,0 +1,153 @@
+/*
+ * 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.hilt.work
+
+import androidx.hilt.AndroidXHiltProcessor
+import androidx.hilt.ClassNames
+import androidx.hilt.ext.hasAnnotation
+import com.google.auto.common.MoreElements
+import com.squareup.javapoet.TypeName
+import javax.annotation.processing.ProcessingEnvironment
+import javax.lang.model.element.Element
+import javax.lang.model.element.Modifier
+import javax.lang.model.element.NestingKind
+import javax.lang.model.element.TypeElement
+import javax.lang.model.util.ElementFilter
+import javax.tools.Diagnostic
+
+/**
+ * Processing step that generates code enabling assisted injection of Workers using Hilt.
+ */
+class WorkerStep(
+ private val processingEnv: ProcessingEnvironment
+) : AndroidXHiltProcessor.Step {
+
+ private val elements = processingEnv.elementUtils
+ private val types = processingEnv.typeUtils
+ private val messager = processingEnv.messager
+
+ override fun annotation() = ClassNames.HILT_WORKER.canonicalName()
+
+ override fun process(annotatedElements: Set<Element>) {
+ val parsedElements = mutableSetOf<TypeElement>()
+ annotatedElements.forEach { element ->
+ val typeElement = MoreElements.asType(element)
+ if (parsedElements.add(typeElement)) {
+ parse(typeElement)?.let { worker ->
+ WorkerGenerator(
+ processingEnv,
+ worker
+ ).generate()
+ }
+ }
+ }
+ }
+
+ private fun parse(typeElement: TypeElement): WorkerElements? {
+ var valid = true
+
+ if (elements.getTypeElement(ClassNames.WORKER_ASSISTED_FACTORY.toString()) == null) {
+ error(
+ "To use @HiltWorker you must add the 'work' artifact. " +
+ "androidx.hilt:hilt-work:<version>"
+ )
+ valid = false
+ }
+
+ if (!types.isSubtype(
+ typeElement.asType(),
+ elements.getTypeElement(ClassNames.LISTENABLE_WORKER.toString()).asType()
+ )
+ ) {
+ error(
+ "@HiltWorker is only supported on types that subclass " +
+ "${ClassNames.LISTENABLE_WORKER}."
+ )
+ valid = false
+ }
+
+ val constructors = ElementFilter.constructorsIn(typeElement.enclosedElements).filter {
+ if (it.hasAnnotation(ClassNames.INJECT.canonicalName())) {
+ error(
+ "Worker constructor should be annotated with @AssistedInject instead of " +
+ "@Inject."
+ )
+ valid = false
+ }
+ it.hasAnnotation(ClassNames.ASSISTED_INJECT.canonicalName())
+ }
+ if (constructors.size != 1) {
+ error(
+ "@HiltWorker annotated class should contain exactly one @AssistedInject " +
+ "annotated constructor.",
+ typeElement
+ )
+ valid = false
+ }
+ constructors.filter { it.modifiers.contains(Modifier.PRIVATE) }.forEach {
+ error("@AssistedInject annotated constructors must not be private.", it)
+ valid = false
+ }
+
+ if (typeElement.nestingKind == NestingKind.MEMBER &&
+ !typeElement.modifiers.contains(Modifier.STATIC)
+ ) {
+ error(
+ "@HiltWorker may only be used on inner classes if they are static.",
+ typeElement
+ )
+ valid = false
+ }
+
+ if (!valid) return null
+
+ val injectConstructor = constructors.first()
+ var contextIndex = -1
+ var workerParametersIndex = -1
+ injectConstructor.parameters.forEachIndexed { index, param ->
+ if (TypeName.get(param.asType()) == ClassNames.CONTEXT) {
+ if (!param.hasAnnotation(ClassNames.ASSISTED.canonicalName())) {
+ error("Missing @Assisted annotation in param '${param.simpleName}'.", param)
+ valid = false
+ }
+ contextIndex = index
+ }
+ if (TypeName.get(param.asType()) == ClassNames.WORKER_PARAMETERS) {
+ if (!param.hasAnnotation(ClassNames.ASSISTED.canonicalName())) {
+ error("Missing @Assisted annotation in param '${param.simpleName}'.", param)
+ valid = false
+ }
+ workerParametersIndex = index
+ }
+ }
+ if (contextIndex > workerParametersIndex) {
+ error(
+ "The 'Context' parameter must be declared before the 'WorkerParameters' in the " +
+ "@AssistedInject constructor of a @HiltWorker annotated class.",
+ injectConstructor
+ )
+ }
+
+ if (!valid) return null
+
+ return WorkerElements(typeElement, injectConstructor)
+ }
+
+ private fun error(message: String, element: Element? = null) {
+ messager.printMessage(Diagnostic.Kind.ERROR, message, element)
+ }
+}
\ No newline at end of file
diff --git a/hilt/hilt-compiler/src/test/kotlin/androidx/hilt/work/WorkerGeneratorTest.kt b/hilt/hilt-compiler/src/test/kotlin/androidx/hilt/work/WorkerGeneratorTest.kt
index 9d87edb..fc892a0 100644
--- a/hilt/hilt-compiler/src/test/kotlin/androidx/hilt/work/WorkerGeneratorTest.kt
+++ b/hilt/hilt-compiler/src/test/kotlin/androidx/hilt/work/WorkerGeneratorTest.kt
@@ -41,14 +41,16 @@
package androidx.hilt.work.test;
import android.content.Context;
- import androidx.hilt.Assisted;
- import androidx.hilt.work.WorkerInject;
+ import androidx.hilt.work.HiltWorker;
import androidx.work.Worker;
import androidx.work.WorkerParameters;
+ import dagger.assisted.Assisted;
+ import dagger.assisted.AssistedInject;
import java.lang.String;
+ @HiltWorker
class MyWorker extends Worker {
- @WorkerInject
+ @AssistedInject
MyWorker(@Assisted Context context, @Assisted WorkerParameters params, String s,
Foo f, long l) {
super(context, params);
@@ -59,37 +61,13 @@
val expected = """
package androidx.hilt.work.test;
- import android.content.Context;
- import androidx.annotation.NonNull;
import androidx.hilt.work.WorkerAssistedFactory;
- import androidx.work.WorkerParameters;
- import java.lang.Long;
- import java.lang.Override;
- import java.lang.String;
+ import dagger.assisted.AssistedFactory;
import $GENERATED_TYPE;
- import javax.inject.Inject;
- import javax.inject.Provider;
$GENERATED_ANNOTATION
- public final class MyWorker_AssistedFactory implements
- WorkerAssistedFactory<MyWorker> {
-
- private final Provider<String> s;
- private final Provider<Foo> f;
- private final Provider<Long> l;
-
- @Inject
- MyWorker_AssistedFactory(Provider<String> s, Provider<Foo> f, Provider<Long> l) {
- this.s = s;
- this.f = f;
- this.l = l;
- }
-
- @Override
- @NonNull
- public MyWorker create(Context context, WorkerParameters parameters) {
- return new MyWorker(context, parameters, s.get(), f.get(), l.get());
- }
+ @AssistedFactory
+ public interface MyWorker_AssistedFactory extends WorkerAssistedFactory<MyWorker> {
}
""".toJFO("androidx.hilt.work.test.MyWorker_AssistedFactory")
@@ -111,13 +89,15 @@
package androidx.hilt.work.test;
import android.content.Context;
- import androidx.hilt.Assisted;
- import androidx.hilt.work.WorkerInject;
+ import androidx.hilt.work.HiltWorker;
import androidx.work.Worker;
import androidx.work.WorkerParameters;
+ import dagger.assisted.Assisted;
+ import dagger.assisted.AssistedInject;
+ @HiltWorker
class MyWorker extends Worker {
- @WorkerInject
+ @AssistedInject
MyWorker(@Assisted Context context, @Assisted WorkerParameters params) {
super(context, params);
}
diff --git a/hilt/hilt-compiler/src/test/kotlin/androidx/hilt/work/WorkerInjectStepTest.kt b/hilt/hilt-compiler/src/test/kotlin/androidx/hilt/work/WorkerInjectStepTest.kt
deleted file mode 100644
index 0f83fb6..0000000
--- a/hilt/hilt-compiler/src/test/kotlin/androidx/hilt/work/WorkerInjectStepTest.kt
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * 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.hilt.work
-
-import androidx.hilt.Sources
-import androidx.hilt.compiler
-import androidx.hilt.toJFO
-import com.google.testing.compile.CompilationSubject.assertThat
-import org.junit.Test
-import org.junit.runner.RunWith
-import org.junit.runners.JUnit4
-
-@RunWith(JUnit4::class)
-class WorkerInjectStepTest {
-
- @Test
- fun verifyEnclosingElementExtendsWorker() {
- val myWorker = """
- package androidx.hilt.work.test;
-
- import android.content.Context;
- import androidx.hilt.Assisted;
- import androidx.hilt.work.WorkerInject;
- import androidx.work.WorkerParameters;
-
- class MyWorker {
- @WorkerInject
- MyWorker(@Assisted Context context, @Assisted WorkerParameters params) { }
- }
- """.toJFO("androidx.hilt.work.work.MyWorker")
-
- val compilation = compiler()
- .compile(myWorker, Sources.LISTENABLE_WORKER, Sources.WORKER, Sources.WORKER_PARAMETERS)
- assertThat(compilation).apply {
- failed()
- hadErrorCount(1)
- hadErrorContainingMatch(
- "@WorkerInject is only supported on types that subclass " +
- "androidx.work.ListenableWorker."
- )
- }
- }
-
- @Test
- fun verifySingleAnnotatedConstructor() {
- val myWorker = """
- package androidx.hilt.work.test;
-
- import android.content.Context;
- import androidx.hilt.Assisted;
- import androidx.hilt.work.WorkerInject;
- import androidx.work.Worker;
- import androidx.work.WorkerParameters;
- import java.lang.String;
-
- class MyWorker extends Worker {
- @WorkerInject
- MyWorker(@Assisted Context context, @Assisted WorkerParameters params) {
- super(context, params);
- }
-
- @WorkerInject
- MyWorker(Context context, WorkerParameters params, String s) {
- super(context, params);
- }
- }
- """.toJFO("androidx.hilt.work.test.MyWorker")
-
- val compilation = compiler()
- .compile(myWorker, Sources.LISTENABLE_WORKER, Sources.WORKER, Sources.WORKER_PARAMETERS)
- assertThat(compilation).apply {
- failed()
- hadErrorCount(1)
- hadErrorContainingMatch("Multiple @WorkerInject annotated constructors found.")
- }
- }
-
- @Test
- fun verifyNonPrivateConstructor() {
- val myWorker = """
- package androidx.hilt.work.test;
-
- import android.content.Context;
- import androidx.hilt.Assisted;
- import androidx.hilt.work.WorkerInject;
- import androidx.work.Worker;
- import androidx.work.WorkerParameters;
-
- class MyWorker extends Worker {
- @WorkerInject
- private MyWorker(@Assisted Context context, @Assisted WorkerParameters params) {
- super(context, params);
- }
- }
- """.toJFO("androidx.hilt.work.test.MyWorker")
-
- val compilation = compiler()
- .compile(myWorker, Sources.LISTENABLE_WORKER, Sources.WORKER, Sources.WORKER_PARAMETERS)
- assertThat(compilation).apply {
- failed()
- hadErrorCount(1)
- hadErrorContainingMatch(
- "@WorkerInject annotated constructors must not be " +
- "private."
- )
- }
- }
-
- @Test
- fun verifyInnerClassIsStatic() {
- val myWorker = """
- package androidx.hilt.work.test;
-
- import android.content.Context;
- import androidx.hilt.Assisted;
- import androidx.hilt.work.WorkerInject;
- import androidx.work.Worker;
- import androidx.work.WorkerParameters;
-
- class Outer {
- class MyWorker extends Worker {
- @WorkerInject
- MyWorker(@Assisted Context context, @Assisted WorkerParameters params) {
- super(context, params);
- }
- }
- }
- """.toJFO("androidx.hilt.work.test.Outer")
-
- val compilation = compiler()
- .compile(myWorker, Sources.LISTENABLE_WORKER, Sources.WORKER, Sources.WORKER_PARAMETERS)
- assertThat(compilation).apply {
- failed()
- hadErrorCount(1)
- hadErrorContainingMatch(
- "@WorkerInject may only be used on inner classes " +
- "if they are static."
- )
- }
- }
-}
\ No newline at end of file
diff --git a/hilt/hilt-compiler/src/test/kotlin/androidx/hilt/work/WorkerStepTest.kt b/hilt/hilt-compiler/src/test/kotlin/androidx/hilt/work/WorkerStepTest.kt
new file mode 100644
index 0000000..9783c14
--- /dev/null
+++ b/hilt/hilt-compiler/src/test/kotlin/androidx/hilt/work/WorkerStepTest.kt
@@ -0,0 +1,231 @@
+/*
+ * 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.hilt.work
+
+import androidx.hilt.Sources
+import androidx.hilt.compiler
+import androidx.hilt.toJFO
+import com.google.testing.compile.CompilationSubject.assertThat
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.junit.runners.JUnit4
+
+@RunWith(JUnit4::class)
+class WorkerStepTest {
+
+ @Test
+ fun verifyEnclosingElementExtendsWorker() {
+ val myWorker = """
+ package androidx.hilt.work.test;
+
+ import android.content.Context;
+ import androidx.hilt.work.HiltWorker;
+ import androidx.work.WorkerParameters;
+ import dagger.assisted.Assisted;
+ import dagger.assisted.AssistedInject;
+
+ @HiltWorker
+ class MyWorker {
+ @AssistedInject
+ MyWorker(@Assisted Context context, @Assisted WorkerParameters params) { }
+ }
+ """.toJFO("androidx.hilt.work.work.MyWorker")
+
+ val compilation = compiler()
+ .compile(myWorker, Sources.LISTENABLE_WORKER, Sources.WORKER, Sources.WORKER_PARAMETERS)
+ assertThat(compilation).apply {
+ failed()
+ hadErrorCount(1)
+ hadErrorContainingMatch(
+ "@HiltWorker is only supported on types that subclass " +
+ "androidx.work.ListenableWorker."
+ )
+ }
+ }
+
+ @Test
+ fun verifySingleAnnotatedConstructor() {
+ val myWorker = """
+ package androidx.hilt.work.test;
+
+ import android.content.Context;
+ import androidx.hilt.work.HiltWorker;
+ import androidx.work.Worker;
+ import androidx.work.WorkerParameters;
+ import dagger.assisted.Assisted;
+ import dagger.assisted.AssistedInject;
+ import java.lang.String;
+
+ @HiltWorker
+ class MyWorker extends Worker {
+ @AssistedInject
+ MyWorker(@Assisted Context context, @Assisted WorkerParameters params) {
+ super(context, params);
+ }
+
+ @AssistedInject
+ MyWorker(Context context, WorkerParameters params, String s) {
+ super(context, params);
+ }
+ }
+ """.toJFO("androidx.hilt.work.test.MyWorker")
+
+ val compilation = compiler()
+ .compile(myWorker, Sources.LISTENABLE_WORKER, Sources.WORKER, Sources.WORKER_PARAMETERS)
+ assertThat(compilation).apply {
+ failed()
+ hadErrorCount(1)
+ hadErrorContainingMatch(
+ "@HiltWorker annotated class should contain exactly one @AssistedInject " +
+ "annotated constructor."
+ )
+ }
+ }
+
+ @Test
+ fun verifyNonPrivateConstructor() {
+ val myWorker = """
+ package androidx.hilt.work.test;
+
+ import android.content.Context;
+ import androidx.hilt.work.HiltWorker;
+ import androidx.work.Worker;
+ import androidx.work.WorkerParameters;
+ import dagger.assisted.Assisted;
+ import dagger.assisted.AssistedInject;
+
+ @HiltWorker
+ class MyWorker extends Worker {
+ @AssistedInject
+ private MyWorker(@Assisted Context context, @Assisted WorkerParameters params) {
+ super(context, params);
+ }
+ }
+ """.toJFO("androidx.hilt.work.test.MyWorker")
+
+ val compilation = compiler()
+ .compile(myWorker, Sources.LISTENABLE_WORKER, Sources.WORKER, Sources.WORKER_PARAMETERS)
+ assertThat(compilation).apply {
+ failed()
+ hadErrorCount(1)
+ hadErrorContainingMatch(
+ "@AssistedInject annotated constructors must not be private."
+ )
+ }
+ }
+
+ @Test
+ fun verifyInnerClassIsStatic() {
+ val myWorker = """
+ package androidx.hilt.work.test;
+
+ import android.content.Context;
+ import androidx.hilt.work.HiltWorker;
+ import androidx.work.Worker;
+ import androidx.work.WorkerParameters;
+ import dagger.assisted.Assisted;
+ import dagger.assisted.AssistedInject;
+
+ class Outer {
+ @HiltWorker
+ class MyWorker extends Worker {
+ @AssistedInject
+ MyWorker(@Assisted Context context, @Assisted WorkerParameters params) {
+ super(context, params);
+ }
+ }
+ }
+ """.toJFO("androidx.hilt.work.test.Outer")
+
+ val compilation = compiler()
+ .compile(myWorker, Sources.LISTENABLE_WORKER, Sources.WORKER, Sources.WORKER_PARAMETERS)
+ assertThat(compilation).apply {
+ failed()
+ hadErrorCount(1)
+ hadErrorContainingMatch(
+ "@HiltWorker may only be used on inner classes " +
+ "if they are static."
+ )
+ }
+ }
+
+ @Test
+ fun verifyConstructorAnnotation() {
+ val myWorker = """
+ package androidx.hilt.work.test;
+
+ import android.content.Context;
+ import androidx.hilt.work.HiltWorker;
+ import androidx.work.Worker;
+ import androidx.work.WorkerParameters;
+ import dagger.assisted.Assisted;
+ import dagger.assisted.AssistedInject;
+ import java.lang.String;
+ import javax.inject.Inject;
+
+ @HiltWorker
+ class MyWorker extends Worker {
+ @Inject
+ MyWorker(@Assisted Context context, @Assisted WorkerParameters params) {
+ super(context, params);
+ }
+ }
+ """.toJFO("androidx.hilt.work.test.MyWorker")
+
+ val compilation = compiler()
+ .compile(myWorker, Sources.LISTENABLE_WORKER, Sources.WORKER, Sources.WORKER_PARAMETERS)
+ assertThat(compilation).apply {
+ failed()
+ hadErrorContainingMatch(
+ "Worker constructor should be annotated with @AssistedInject instead of @Inject."
+ )
+ }
+ }
+
+ @Test
+ fun verifyAssistedParamOrder() {
+ val myWorker = """
+ package androidx.hilt.work.test;
+
+ import android.content.Context;
+ import androidx.hilt.work.HiltWorker;
+ import androidx.work.Worker;
+ import androidx.work.WorkerParameters;
+ import dagger.assisted.Assisted;
+ import dagger.assisted.AssistedInject;
+ import java.lang.String;
+
+ @HiltWorker
+ class MyWorker extends Worker {
+ @AssistedInject
+ MyWorker(@Assisted WorkerParameters params, @Assisted Context context) {
+ super(context, params);
+ }
+ }
+ """.toJFO("androidx.hilt.work.test.MyWorker")
+
+ val compilation = compiler()
+ .compile(myWorker, Sources.LISTENABLE_WORKER, Sources.WORKER, Sources.WORKER_PARAMETERS)
+ assertThat(compilation).apply {
+ failed()
+ hadErrorContainingMatch(
+ "The 'Context' parameter must be declared before the 'WorkerParameters' in the " +
+ "@AssistedInject constructor of a @HiltWorker annotated class.",
+ )
+ }
+ }
+}
\ No newline at end of file
diff --git a/hilt/hilt-lifecycle-viewmodel/api/current.txt b/hilt/hilt-lifecycle-viewmodel/api/current.txt
index e1428ad..26f52c2 100644
--- a/hilt/hilt-lifecycle-viewmodel/api/current.txt
+++ b/hilt/hilt-lifecycle-viewmodel/api/current.txt
@@ -1,8 +1,8 @@
// Signature format: 4.0
package androidx.hilt.lifecycle {
- public final class HiltViewModelFactory extends androidx.lifecycle.AbstractSavedStateViewModelFactory implements androidx.lifecycle.ViewModelProvider.Factory {
- method protected <T extends androidx.lifecycle.ViewModel> T create(String, Class<T!>, androidx.lifecycle.SavedStateHandle);
+ @Deprecated public final class HiltViewModelFactory extends androidx.lifecycle.AbstractSavedStateViewModelFactory implements androidx.lifecycle.ViewModelProvider.Factory {
+ method @Deprecated protected <T extends androidx.lifecycle.ViewModel> T create(String, Class<T!>, androidx.lifecycle.SavedStateHandle);
}
}
diff --git a/hilt/hilt-lifecycle-viewmodel/api/public_plus_experimental_current.txt b/hilt/hilt-lifecycle-viewmodel/api/public_plus_experimental_current.txt
index e1428ad..26f52c2 100644
--- a/hilt/hilt-lifecycle-viewmodel/api/public_plus_experimental_current.txt
+++ b/hilt/hilt-lifecycle-viewmodel/api/public_plus_experimental_current.txt
@@ -1,8 +1,8 @@
// Signature format: 4.0
package androidx.hilt.lifecycle {
- public final class HiltViewModelFactory extends androidx.lifecycle.AbstractSavedStateViewModelFactory implements androidx.lifecycle.ViewModelProvider.Factory {
- method protected <T extends androidx.lifecycle.ViewModel> T create(String, Class<T!>, androidx.lifecycle.SavedStateHandle);
+ @Deprecated public final class HiltViewModelFactory extends androidx.lifecycle.AbstractSavedStateViewModelFactory implements androidx.lifecycle.ViewModelProvider.Factory {
+ method @Deprecated protected <T extends androidx.lifecycle.ViewModel> T create(String, Class<T!>, androidx.lifecycle.SavedStateHandle);
}
}
diff --git a/hilt/hilt-lifecycle-viewmodel/api/restricted_current.txt b/hilt/hilt-lifecycle-viewmodel/api/restricted_current.txt
index 1388712..dc6b1ab 100644
--- a/hilt/hilt-lifecycle-viewmodel/api/restricted_current.txt
+++ b/hilt/hilt-lifecycle-viewmodel/api/restricted_current.txt
@@ -1,8 +1,8 @@
// Signature format: 4.0
package androidx.hilt.lifecycle {
- public final class HiltViewModelFactory extends androidx.lifecycle.AbstractSavedStateViewModelFactory implements androidx.lifecycle.ViewModelProvider.Factory {
- method protected <T extends androidx.lifecycle.ViewModel> T create(String, Class<T!>, androidx.lifecycle.SavedStateHandle);
+ @Deprecated public final class HiltViewModelFactory extends androidx.lifecycle.AbstractSavedStateViewModelFactory implements androidx.lifecycle.ViewModelProvider.Factory {
+ method @Deprecated protected <T extends androidx.lifecycle.ViewModel> T create(String, Class<T!>, androidx.lifecycle.SavedStateHandle);
}
@RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public interface ViewModelAssistedFactory<T extends androidx.lifecycle.ViewModel> {
diff --git a/hilt/hilt-lifecycle-viewmodel/src/main/java/androidx/hilt/lifecycle/HiltViewModelFactory.java b/hilt/hilt-lifecycle-viewmodel/src/main/java/androidx/hilt/lifecycle/HiltViewModelFactory.java
index 2a266a3..454bd30f 100644
--- a/hilt/hilt-lifecycle-viewmodel/src/main/java/androidx/hilt/lifecycle/HiltViewModelFactory.java
+++ b/hilt/hilt-lifecycle-viewmodel/src/main/java/androidx/hilt/lifecycle/HiltViewModelFactory.java
@@ -39,7 +39,11 @@
* {@link dagger.hilt.android.components.FragmentComponent}. An instance of this factory will also
* be the default factory by activities and fragments annotated with
* {@link dagger.hilt.android.AndroidEntryPoint}.
+ *
+ * @deprecated References to this type and bindings to it should be removed. An equivalent factory
+ * to this is now provided out of the box by Hilt.
*/
+@Deprecated
public final class HiltViewModelFactory extends AbstractSavedStateViewModelFactory {
private static final String KEY_PREFIX = "androidx.hilt.lifecycle.HiltViewModelFactory";
diff --git a/hilt/hilt-lifecycle-viewmodel/src/main/java/androidx/hilt/lifecycle/ViewModelFactoryModules.java b/hilt/hilt-lifecycle-viewmodel/src/main/java/androidx/hilt/lifecycle/ViewModelFactoryModules.java
index 1792a7d..87355f1 100644
--- a/hilt/hilt-lifecycle-viewmodel/src/main/java/androidx/hilt/lifecycle/ViewModelFactoryModules.java
+++ b/hilt/hilt-lifecycle-viewmodel/src/main/java/androidx/hilt/lifecycle/ViewModelFactoryModules.java
@@ -49,6 +49,7 @@
* @hide
*/
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP_PREFIX)
+@SuppressWarnings("deprecation")
public final class ViewModelFactoryModules {
/**
diff --git a/hilt/hilt-work/proguard-rules.pro b/hilt/hilt-work/proguard-rules.pro
index 553d9ca..cd5c2e5 100644
--- a/hilt/hilt-work/proguard-rules.pro
+++ b/hilt/hilt-work/proguard-rules.pro
@@ -1,5 +1,2 @@
# Keep class names of Hilt injected Workers since their name are used as a multibinding map key.
--keepclasseswithmembernames class * extends androidx.work.ListenableWorker {
- @androidx.hilt.work.WorkerInject
- <init>(...);
-}
\ No newline at end of file
+-keepnames @androidx.hilt.work.HiltWorker class * extends androidx.work.ListenableWorker
\ No newline at end of file
diff --git a/hilt/integration-tests/viewmodelapp/src/androidTest/java/androidx/hilt/integration/viewmodelapp/MyViewModels.kt b/hilt/integration-tests/viewmodelapp/src/androidTest/java/androidx/hilt/integration/viewmodelapp/MyViewModels.kt
index 4284828..18324a6 100644
--- a/hilt/integration-tests/viewmodelapp/src/androidTest/java/androidx/hilt/integration/viewmodelapp/MyViewModels.kt
+++ b/hilt/integration-tests/viewmodelapp/src/androidTest/java/androidx/hilt/integration/viewmodelapp/MyViewModels.kt
@@ -14,6 +14,8 @@
* limitations under the License.
*/
+@file:Suppress("DEPRECATION")
+
package androidx.hilt.integration.viewmodelapp
import android.app.Application
diff --git a/hilt/integration-tests/viewmodelapp/src/main/java/androidx/hilt/integration/viewmodelapp/SimpleViewModel.kt b/hilt/integration-tests/viewmodelapp/src/main/java/androidx/hilt/integration/viewmodelapp/SimpleViewModel.kt
index 45bbd5f..c23f608 100644
--- a/hilt/integration-tests/viewmodelapp/src/main/java/androidx/hilt/integration/viewmodelapp/SimpleViewModel.kt
+++ b/hilt/integration-tests/viewmodelapp/src/main/java/androidx/hilt/integration/viewmodelapp/SimpleViewModel.kt
@@ -14,6 +14,8 @@
* limitations under the License.
*/
+@file:Suppress("DEPRECATION")
+
package androidx.hilt.integration.viewmodelapp
import androidx.hilt.Assisted
diff --git a/hilt/integration-tests/workerapp/src/main/java/androidx/hilt/integration/workerapp/SimpleWorker.kt b/hilt/integration-tests/workerapp/src/main/java/androidx/hilt/integration/workerapp/SimpleWorker.kt
index cc4c474..5fc9f80 100644
--- a/hilt/integration-tests/workerapp/src/main/java/androidx/hilt/integration/workerapp/SimpleWorker.kt
+++ b/hilt/integration-tests/workerapp/src/main/java/androidx/hilt/integration/workerapp/SimpleWorker.kt
@@ -18,14 +18,16 @@
import android.content.Context
import android.util.Log
-import androidx.hilt.Assisted
-import androidx.hilt.work.WorkerInject
+import androidx.hilt.work.HiltWorker
import androidx.work.CoroutineWorker
import androidx.work.Worker
import androidx.work.WorkerParameters
+import dagger.assisted.Assisted
+import dagger.assisted.AssistedInject
import javax.inject.Inject
-class SimpleWorker @WorkerInject constructor(
+@HiltWorker
+class SimpleWorker @AssistedInject constructor(
@Assisted context: Context,
@Assisted params: WorkerParameters,
private val logger: MyLogger
@@ -36,7 +38,8 @@
}
}
-class SimpleCoroutineWorker @WorkerInject constructor(
+@HiltWorker
+class SimpleCoroutineWorker @AssistedInject constructor(
@Assisted context: Context,
@Assisted params: WorkerParameters,
private val logger: MyLogger
@@ -48,7 +51,8 @@
}
object TopClass {
- class NestedWorker @WorkerInject constructor(
+ @HiltWorker
+ class NestedWorker @AssistedInject constructor(
@Assisted context: Context,
@Assisted params: WorkerParameters,
private val logger: MyLogger
diff --git a/paging/common/src/test/kotlin/androidx/paging/PageFetcherSnapshotTest.kt b/paging/common/src/test/kotlin/androidx/paging/PageFetcherSnapshotTest.kt
index 12e1b7e..c1caf9d 100644
--- a/paging/common/src/test/kotlin/androidx/paging/PageFetcherSnapshotTest.kt
+++ b/paging/common/src/test/kotlin/androidx/paging/PageFetcherSnapshotTest.kt
@@ -92,11 +92,9 @@
val fetcherState = collectFetcherState(pageFetcher)
advanceUntilIdle()
- assertThat(fetcherState.newEvents()).isEqualTo(
- listOf<PageEvent<Int>>(
- LoadStateUpdate(REFRESH, false, Loading),
- createRefresh(1..2)
- )
+ assertThat(fetcherState.newEvents()).containsExactly(
+ LoadStateUpdate<Int>(REFRESH, false, Loading),
+ createRefresh(1..2)
)
fetcherState.pagingDataList[0].receiver.accessHint(
@@ -110,14 +108,12 @@
)
)
advanceUntilIdle()
- assertThat(fetcherState.newEvents()).isEqualTo(
- listOf<PageEvent<Int>>(
- LoadStateUpdate(PREPEND, false, Loading),
- createPrepend(
- pageOffset = -1,
- range = 0..0,
- startState = NotLoading.Complete
- )
+ assertThat(fetcherState.newEvents()).containsExactly(
+ LoadStateUpdate<Int>(PREPEND, false, Loading),
+ createPrepend(
+ pageOffset = -1,
+ range = 0..0,
+ startState = NotLoading.Complete
)
)
@@ -130,11 +126,9 @@
val fetcherState = collectFetcherState(pageFetcher)
advanceUntilIdle()
- assertThat(fetcherState.newEvents()).isEqualTo(
- listOf<PageEvent<Int>>(
- LoadStateUpdate(REFRESH, false, Loading),
- createRefresh(1..2)
- )
+ assertThat(fetcherState.newEvents()).containsExactly(
+ LoadStateUpdate<Int>(REFRESH, false, Loading),
+ createRefresh(1..2)
)
fetcherState.pagingDataList[0].receiver.accessHint(
@@ -148,14 +142,12 @@
)
)
advanceUntilIdle()
- assertThat(fetcherState.newEvents()).isEqualTo(
- listOf<PageEvent<Int>>(
- LoadStateUpdate(PREPEND, false, Loading),
- createPrepend(
- pageOffset = -1,
- range = 0..0,
- startState = NotLoading.Complete
- )
+ assertThat(fetcherState.newEvents()).containsExactly(
+ LoadStateUpdate<Int>(PREPEND, false, Loading),
+ createPrepend(
+ pageOffset = -1,
+ range = 0..0,
+ startState = NotLoading.Complete
)
)
@@ -170,21 +162,19 @@
)
)
advanceUntilIdle()
- assertThat(fetcherState.newEvents()).isEqualTo(
- listOf<PageEvent<Int>>(
- LoadStateUpdate(APPEND, false, Loading),
- Drop(
- loadType = PREPEND,
- minPageOffset = -1,
- maxPageOffset = -1,
- placeholdersRemaining = 1
- ),
- createAppend(
- pageOffset = 1,
- range = 3..3,
- startState = NotLoading.Incomplete,
- endState = NotLoading.Incomplete
- )
+ assertThat(fetcherState.newEvents()).containsExactly(
+ LoadStateUpdate<Int>(APPEND, false, Loading),
+ Drop<Int>(
+ loadType = PREPEND,
+ minPageOffset = -1,
+ maxPageOffset = -1,
+ placeholdersRemaining = 1
+ ),
+ createAppend(
+ pageOffset = 1,
+ range = 3..3,
+ startState = NotLoading.Incomplete,
+ endState = NotLoading.Incomplete
)
)
@@ -197,11 +187,9 @@
val fetcherState = collectFetcherState(pageFetcher)
advanceUntilIdle()
- assertThat(fetcherState.newEvents()).isEqualTo(
- listOf<PageEvent<Int>>(
- LoadStateUpdate(REFRESH, false, Loading),
- createRefresh(range = 97..98)
- )
+ assertThat(fetcherState.newEvents()).containsExactly(
+ LoadStateUpdate<Int>(REFRESH, false, Loading),
+ createRefresh(range = 97..98)
)
fetcherState.pagingDataList[0].receiver.accessHint(
@@ -215,11 +203,9 @@
)
)
advanceUntilIdle()
- assertThat(fetcherState.newEvents()).isEqualTo(
- listOf<PageEvent<Int>>(
- LoadStateUpdate(APPEND, false, Loading),
- createAppend(pageOffset = 1, range = 99..99, endState = NotLoading.Complete)
- )
+ assertThat(fetcherState.newEvents()).containsExactly(
+ LoadStateUpdate<Int>(APPEND, false, Loading),
+ createAppend(pageOffset = 1, range = 99..99, endState = NotLoading.Complete)
)
fetcherState.job.cancel()
@@ -231,11 +217,10 @@
val fetcherState = collectFetcherState(pageFetcher)
advanceUntilIdle()
- assertThat(fetcherState.newEvents()).isEqualTo(
- listOf<PageEvent<Int>>(
- LoadStateUpdate(REFRESH, false, Loading),
- createRefresh(range = 97..98)
- )
+ assertThat(fetcherState.newEvents()).containsExactly(
+ LoadStateUpdate<Int>(REFRESH, false, Loading),
+ createRefresh(range = 97..98)
+
)
fetcherState.pagingDataList[0].receiver.accessHint(
@@ -249,15 +234,13 @@
)
)
advanceUntilIdle()
- assertThat(fetcherState.newEvents()).isEqualTo(
- listOf<PageEvent<Int>>(
- LoadStateUpdate(APPEND, false, Loading),
- createAppend(
- pageOffset = 1,
- range = 99..99,
- startState = NotLoading.Incomplete,
- endState = NotLoading.Complete
- )
+ assertThat(fetcherState.newEvents()).containsExactly(
+ LoadStateUpdate<Int>(APPEND, false, Loading),
+ createAppend(
+ pageOffset = 1,
+ range = 99..99,
+ startState = NotLoading.Incomplete,
+ endState = NotLoading.Complete
)
)
@@ -272,21 +255,19 @@
)
)
advanceUntilIdle()
- assertThat(fetcherState.newEvents()).isEqualTo(
- listOf<PageEvent<Int>>(
- LoadStateUpdate(PREPEND, false, Loading),
- Drop(
- loadType = APPEND,
- minPageOffset = 1,
- maxPageOffset = 1,
- placeholdersRemaining = 1
- ),
- createPrepend(
- pageOffset = -1,
- range = 96..96,
- startState = NotLoading.Incomplete,
- endState = NotLoading.Incomplete
- )
+ assertThat(fetcherState.newEvents()).containsExactly(
+ LoadStateUpdate<Int>(PREPEND, false, Loading),
+ Drop<Int>(
+ loadType = APPEND,
+ minPageOffset = 1,
+ maxPageOffset = 1,
+ placeholdersRemaining = 1
+ ),
+ createPrepend(
+ pageOffset = -1,
+ range = 96..96,
+ startState = NotLoading.Incomplete,
+ endState = NotLoading.Incomplete
)
)
@@ -300,8 +281,8 @@
advanceUntilIdle()
- val expected: List<PageEvent<Int>> = listOf(
- LoadStateUpdate(REFRESH, false, Loading),
+ assertThat(fetcherState.pageEventLists[0]).containsExactly(
+ LoadStateUpdate<Int>(REFRESH, false, Loading),
createRefresh(
range = 0..1,
startState = NotLoading.Complete,
@@ -309,7 +290,6 @@
)
)
- assertEvents(expected, fetcherState.pageEventLists[0])
fetcherState.job.cancel()
}
@@ -320,8 +300,8 @@
advanceUntilIdle()
- val expected: List<PageEvent<Int>> = listOf(
- LoadStateUpdate(REFRESH, false, Loading),
+ assertThat(fetcherState.pageEventLists[0]).containsExactly(
+ LoadStateUpdate<Int>(REFRESH, false, Loading),
createRefresh(
range = 98..99,
startState = NotLoading.Incomplete,
@@ -329,7 +309,6 @@
)
)
- assertEvents(expected, fetcherState.pageEventLists[0])
fetcherState.job.cancel()
}
@@ -340,12 +319,11 @@
advanceUntilIdle()
- val expected: List<PageEvent<Int>> = listOf(
- LoadStateUpdate(REFRESH, false, Loading),
+ assertThat(fetcherState.pageEventLists[0]).containsExactly(
+ LoadStateUpdate<Int>(REFRESH, false, Loading),
createRefresh(range = 50..51)
)
- assertEvents(expected, fetcherState.pageEventLists[0])
fetcherState.job.cancel()
}
@@ -366,14 +344,13 @@
)
advanceUntilIdle()
- val expected: List<PageEvent<Int>> = listOf(
- LoadStateUpdate(REFRESH, false, Loading),
+ assertThat(fetcherState.pageEventLists[0]).containsExactly(
+ LoadStateUpdate<Int>(REFRESH, false, Loading),
createRefresh(range = 50..51),
- LoadStateUpdate(PREPEND, false, Loading),
+ LoadStateUpdate<Int>(PREPEND, false, Loading),
createPrepend(pageOffset = -1, range = 49..49)
)
- assertEvents(expected, fetcherState.pageEventLists[0])
fetcherState.job.cancel()
}
@@ -383,11 +360,9 @@
val fetcherState = collectFetcherState(pageFetcher)
advanceUntilIdle()
- assertThat(fetcherState.newEvents()).isEqualTo(
- listOf<PageEvent<Int>>(
- LoadStateUpdate(REFRESH, false, Loading),
- createRefresh(range = 50..51)
- )
+ assertThat(fetcherState.newEvents()).containsExactly(
+ LoadStateUpdate<Int>(REFRESH, false, Loading),
+ createRefresh(range = 50..51)
)
fetcherState.pagingDataList[0].receiver.accessHint(
@@ -401,11 +376,9 @@
)
)
advanceUntilIdle()
- assertThat(fetcherState.newEvents()).isEqualTo(
- listOf<PageEvent<Int>>(
- LoadStateUpdate(PREPEND, false, Loading),
- createPrepend(pageOffset = -1, range = 49..49)
- )
+ assertThat(fetcherState.newEvents()).containsExactly(
+ LoadStateUpdate<Int>(PREPEND, false, Loading),
+ createPrepend(pageOffset = -1, range = 49..49)
)
fetcherState.job.cancel()
@@ -427,11 +400,9 @@
advanceUntilIdle()
// Make sure the job didn't complete exceptionally
assertFalse { fetcherState.job.isCancelled }
- assertThat(fetcherState.newEvents()).isEqualTo(
- listOf<PageEvent<Int>>(
- LoadStateUpdate(REFRESH, false, Loading),
- createRefresh(range = 50..51)
- )
+ assertThat(fetcherState.newEvents()).containsExactly(
+ LoadStateUpdate<Int>(REFRESH, false, Loading),
+ createRefresh(range = 50..51)
)
fetcherState.pagingDataList[0].receiver.accessHint(
@@ -446,11 +417,9 @@
)
advanceUntilIdle()
assertFalse { fetcherState.job.isCancelled }
- assertThat(fetcherState.newEvents()).isEqualTo(
- listOf<PageEvent<Int>>(
- LoadStateUpdate(PREPEND, false, Loading),
- createPrepend(pageOffset = -1, range = 48..49)
- )
+ assertThat(fetcherState.newEvents()).containsExactly(
+ LoadStateUpdate<Int>(PREPEND, false, Loading),
+ createPrepend(pageOffset = -1, range = 48..49)
)
fetcherState.pagingDataList[0].receiver.accessHint(
@@ -465,17 +434,15 @@
)
advanceUntilIdle()
assertFalse { fetcherState.job.isCancelled }
- assertThat(fetcherState.newEvents()).isEqualTo(
- listOf<PageEvent<Int>>(
- LoadStateUpdate(PREPEND, false, Loading),
- Drop(
- loadType = APPEND,
- minPageOffset = 0,
- maxPageOffset = 0,
- placeholdersRemaining = 50
- ),
- createPrepend(pageOffset = -2, range = 46..47)
- )
+ assertThat(fetcherState.newEvents()).containsExactly(
+ LoadStateUpdate<Int>(PREPEND, false, Loading),
+ Drop<Int>(
+ loadType = APPEND,
+ minPageOffset = 0,
+ maxPageOffset = 0,
+ placeholdersRemaining = 50
+ ),
+ createPrepend(pageOffset = -2, range = 46..47)
)
fetcherState.job.cancel()
@@ -499,11 +466,13 @@
val fetcherState = collectFetcherState(pageFetcher)
advanceUntilIdle()
- assertThat(fetcherState.newEvents()).isEqualTo(
- listOf<PageEvent<Int>>(
- LoadStateUpdate(loadType = REFRESH, fromMediator = false, loadState = Loading),
- createRefresh(range = 50..54)
- )
+ assertThat(fetcherState.newEvents()).containsExactly(
+ LoadStateUpdate<Int>(
+ loadType = REFRESH,
+ fromMediator = false,
+ loadState = Loading
+ ),
+ createRefresh(range = 50..54)
)
fetcherState.pagingDataList[0].receiver.accessHint(
@@ -517,16 +486,18 @@
)
)
advanceUntilIdle()
- assertThat(fetcherState.newEvents()).isEqualTo(
- listOf<PageEvent<Int>>(
- LoadStateUpdate(loadType = PREPEND, fromMediator = false, loadState = Loading),
- createPrepend(
- pageOffset = -1,
- range = 49..49,
- startState = Loading
- ),
- createPrepend(pageOffset = -2, range = 48..48)
- )
+ assertThat(fetcherState.newEvents()).containsExactly(
+ LoadStateUpdate<Int>(
+ loadType = PREPEND,
+ fromMediator = false,
+ loadState = Loading
+ ),
+ createPrepend(
+ pageOffset = -1,
+ range = 49..49,
+ startState = Loading
+ ),
+ createPrepend(pageOffset = -2, range = 48..48)
)
// Make sure the job didn't complete exceptionally
@@ -550,11 +521,9 @@
val fetcherState = collectFetcherState(pageFetcher)
advanceUntilIdle()
- assertThat(fetcherState.newEvents()).isEqualTo(
- listOf<PageEvent<Int>>(
- LoadStateUpdate(REFRESH, false, Loading),
- createRefresh(range = 50..51)
- )
+ assertThat(fetcherState.newEvents()).containsExactly(
+ LoadStateUpdate<Int>(REFRESH, false, Loading),
+ createRefresh(range = 50..51)
)
fetcherState.pagingDataList[0].receiver.accessHint(
@@ -568,11 +537,9 @@
)
)
advanceUntilIdle()
- assertThat(fetcherState.newEvents()).isEqualTo(
- listOf<PageEvent<Int>>(
- LoadStateUpdate(PREPEND, false, Loading),
- createPrepend(pageOffset = -1, range = 48..49)
- )
+ assertThat(fetcherState.newEvents()).containsExactly(
+ LoadStateUpdate<Int>(PREPEND, false, Loading),
+ createPrepend(pageOffset = -1, range = 48..49)
)
fetcherState.pagingDataList[0].receiver.accessHint(
@@ -598,18 +565,16 @@
)
)
advanceUntilIdle()
- assertThat(fetcherState.newEvents()).isEqualTo(
- listOf<PageEvent<Int>>(
- LoadStateUpdate(PREPEND, false, Loading),
- LoadStateUpdate(APPEND, false, Loading),
- Drop(
- loadType = APPEND,
- minPageOffset = 0,
- maxPageOffset = 0,
- placeholdersRemaining = 50
- ),
- createPrepend(pageOffset = -2, range = 46..47)
- )
+ assertThat(fetcherState.newEvents()).containsExactly(
+ LoadStateUpdate<Int>(PREPEND, false, Loading),
+ LoadStateUpdate<Int>(APPEND, false, Loading),
+ Drop<Int>(
+ loadType = APPEND,
+ minPageOffset = 0,
+ maxPageOffset = 0,
+ placeholdersRemaining = 50
+ ),
+ createPrepend(pageOffset = -2, range = 46..47)
)
fetcherState.job.cancel()
@@ -629,11 +594,9 @@
val fetcherState = collectFetcherState(pageFetcher)
advanceUntilIdle()
- assertThat(fetcherState.newEvents()).isEqualTo(
- listOf<PageEvent<Int>>(
- LoadStateUpdate(REFRESH, false, Loading),
- createRefresh(50..52)
- )
+ assertThat(fetcherState.newEvents()).containsExactly(
+ LoadStateUpdate<Int>(REFRESH, false, Loading),
+ createRefresh(50..52)
)
fetcherState.pagingDataList[0].receiver.accessHint(
@@ -647,12 +610,10 @@
)
)
advanceUntilIdle()
- assertThat(fetcherState.newEvents()).isEqualTo(
- listOf<PageEvent<Int>>(
- LoadStateUpdate(PREPEND, false, Loading),
- createPrepend(pageOffset = -1, range = 49..49, startState = Loading),
- createPrepend(pageOffset = -2, range = 48..48)
- )
+ assertThat(fetcherState.newEvents()).containsExactly(
+ LoadStateUpdate<Int>(PREPEND, false, Loading),
+ createPrepend(pageOffset = -1, range = 49..49, startState = Loading),
+ createPrepend(pageOffset = -2, range = 48..48)
)
fetcherState.job.cancel()
@@ -671,11 +632,13 @@
val fetcherState = collectFetcherState(pageFetcher)
advanceUntilIdle()
- assertThat(fetcherState.newEvents()).isEqualTo(
- listOf<PageEvent<Int>>(
- LoadStateUpdate(loadType = REFRESH, fromMediator = false, loadState = Loading),
- createRefresh(range = 50..52)
- )
+ assertThat(fetcherState.newEvents()).containsExactly(
+ LoadStateUpdate<Int>(
+ loadType = REFRESH,
+ fromMediator = false,
+ loadState = Loading
+ ),
+ createRefresh(range = 50..52)
)
// PREPEND a few pages.
@@ -690,12 +653,14 @@
)
)
advanceUntilIdle()
- assertThat(fetcherState.newEvents()).isEqualTo(
- listOf<PageEvent<Int>>(
- LoadStateUpdate(loadType = PREPEND, fromMediator = false, loadState = Loading),
- createPrepend(pageOffset = -1, range = 49..49, startState = Loading),
- createPrepend(pageOffset = -2, range = 48..48)
- )
+ assertThat(fetcherState.newEvents()).containsExactly(
+ LoadStateUpdate<Int>(
+ loadType = PREPEND,
+ fromMediator = false,
+ loadState = Loading
+ ),
+ createPrepend(pageOffset = -1, range = 49..49, startState = Loading),
+ createPrepend(pageOffset = -2, range = 48..48)
)
// APPEND a few pages causing PREPEND pages to drop
@@ -710,24 +675,26 @@
)
)
advanceUntilIdle()
- assertThat(fetcherState.newEvents()).isEqualTo(
- listOf<PageEvent<Int>>(
- LoadStateUpdate(loadType = APPEND, fromMediator = false, loadState = Loading),
- Drop(
- loadType = PREPEND,
- minPageOffset = -2,
- maxPageOffset = -2,
- placeholdersRemaining = 49
- ),
- createAppend(pageOffset = 1, range = 53..53, endState = Loading),
- Drop(
- loadType = PREPEND,
- minPageOffset = -1,
- maxPageOffset = -1,
- placeholdersRemaining = 50
- ),
- createAppend(pageOffset = 2, range = 54..54)
- )
+ assertThat(fetcherState.newEvents()).containsExactly(
+ LoadStateUpdate<Int>(
+ loadType = APPEND,
+ fromMediator = false,
+ loadState = Loading
+ ),
+ Drop<Int>(
+ loadType = PREPEND,
+ minPageOffset = -2,
+ maxPageOffset = -2,
+ placeholdersRemaining = 49
+ ),
+ createAppend(pageOffset = 1, range = 53..53, endState = Loading),
+ Drop<Int>(
+ loadType = PREPEND,
+ minPageOffset = -1,
+ maxPageOffset = -1,
+ placeholdersRemaining = 50
+ ),
+ createAppend(pageOffset = 2, range = 54..54)
)
// PREPEND a page, this hint would normally be ignored, but has a newer generationId.
@@ -742,17 +709,19 @@
)
)
advanceUntilIdle()
- assertThat(fetcherState.newEvents()).isEqualTo(
- listOf<PageEvent<Int>>(
- LoadStateUpdate(loadType = PREPEND, fromMediator = false, loadState = Loading),
- Drop(
- loadType = APPEND,
- minPageOffset = 2,
- maxPageOffset = 2,
- placeholdersRemaining = 46
- ),
- createPrepend(pageOffset = -1, range = 49..49)
- )
+ assertThat(fetcherState.newEvents()).containsExactly(
+ LoadStateUpdate<Int>(
+ loadType = PREPEND,
+ fromMediator = false,
+ loadState = Loading
+ ),
+ Drop<Int>(
+ loadType = APPEND,
+ minPageOffset = 2,
+ maxPageOffset = 2,
+ placeholdersRemaining = 46
+ ),
+ createPrepend(pageOffset = -1, range = 49..49)
)
fetcherState.job.cancel()
@@ -764,11 +733,9 @@
val fetcherState = collectFetcherState(pageFetcher)
advanceUntilIdle()
- assertThat(fetcherState.newEvents()).isEqualTo(
- listOf<PageEvent<Int>>(
- LoadStateUpdate(REFRESH, false, Loading),
- createRefresh(50..51)
- )
+ assertThat(fetcherState.newEvents()).containsExactly(
+ LoadStateUpdate<Int>(REFRESH, false, Loading),
+ createRefresh(50..51)
)
fetcherState.pagingDataList[0].receiver.accessHint(
@@ -782,11 +749,9 @@
)
)
advanceUntilIdle()
- assertThat(fetcherState.newEvents()).isEqualTo(
- listOf<PageEvent<Int>>(
- LoadStateUpdate(APPEND, false, Loading),
- createAppend(1, 52..52)
- )
+ assertThat(fetcherState.newEvents()).containsExactly(
+ LoadStateUpdate<Int>(APPEND, false, Loading),
+ createAppend(1, 52..52)
)
fetcherState.job.cancel()
@@ -805,11 +770,9 @@
val fetcherState = collectFetcherState(pageFetcher)
advanceUntilIdle()
- assertThat(fetcherState.newEvents()).isEqualTo(
- listOf<PageEvent<Int>>(
- LoadStateUpdate(REFRESH, false, Loading),
- createRefresh(50..52)
- )
+ assertThat(fetcherState.newEvents()).containsExactly(
+ LoadStateUpdate<Int>(REFRESH, false, Loading),
+ createRefresh(50..52)
)
fetcherState.pagingDataList[0].receiver.accessHint(
@@ -823,17 +786,15 @@
)
)
advanceUntilIdle()
- assertThat(fetcherState.newEvents()).isEqualTo(
- listOf<PageEvent<Int>>(
- LoadStateUpdate(APPEND, false, Loading),
- createAppend(
- pageOffset = 1,
- range = 53..53,
- startState = NotLoading.Incomplete,
- endState = Loading
- ),
- createAppend(2, 54..54)
- )
+ assertThat(fetcherState.newEvents()).containsExactly(
+ LoadStateUpdate<Int>(APPEND, false, Loading),
+ createAppend(
+ pageOffset = 1,
+ range = 53..53,
+ startState = NotLoading.Incomplete,
+ endState = Loading
+ ),
+ createAppend(2, 54..54)
)
fetcherState.job.cancel()
@@ -852,11 +813,9 @@
val fetcherState = collectFetcherState(pageFetcher)
advanceUntilIdle()
- assertThat(fetcherState.newEvents()).isEqualTo(
- listOf<PageEvent<Int>>(
- LoadStateUpdate(REFRESH, false, Loading),
- createRefresh(range = 50..51)
- )
+ assertThat(fetcherState.newEvents()).containsExactly(
+ LoadStateUpdate<Int>(REFRESH, false, Loading),
+ createRefresh(range = 50..51)
)
fetcherState.pagingDataList[0].receiver.accessHint(
@@ -870,11 +829,9 @@
)
)
advanceUntilIdle()
- assertThat(fetcherState.newEvents()).isEqualTo(
- listOf<PageEvent<Int>>(
- LoadStateUpdate(APPEND, false, Loading),
- createAppend(pageOffset = 1, range = 52..53)
- )
+ assertThat(fetcherState.newEvents()).containsExactly(
+ LoadStateUpdate<Int>(APPEND, false, Loading),
+ createAppend(pageOffset = 1, range = 52..53)
)
fetcherState.pagingDataList[0].receiver.accessHint(
@@ -888,17 +845,15 @@
)
)
advanceUntilIdle()
- assertThat(fetcherState.newEvents()).isEqualTo(
- listOf<PageEvent<Int>>(
- LoadStateUpdate(APPEND, false, Loading),
- Drop(
- loadType = PREPEND,
- minPageOffset = 0,
- maxPageOffset = 0,
- placeholdersRemaining = 52
- ),
- createAppend(pageOffset = 2, range = 54..55)
- )
+ assertThat(fetcherState.newEvents()).containsExactly(
+ LoadStateUpdate<Int>(APPEND, false, Loading),
+ Drop<Int>(
+ loadType = PREPEND,
+ minPageOffset = 0,
+ maxPageOffset = 0,
+ placeholdersRemaining = 52
+ ),
+ createAppend(pageOffset = 2, range = 54..55)
)
fetcherState.job.cancel()
@@ -921,11 +876,9 @@
val fetcherState = collectFetcherState(pageFetcher)
advanceUntilIdle()
- assertThat(fetcherState.newEvents()).isEqualTo(
- listOf<PageEvent<Int>>(
- LoadStateUpdate(REFRESH, false, Loading),
- createRefresh(range = 50..54)
- )
+ assertThat(fetcherState.newEvents()).containsExactly(
+ LoadStateUpdate<Int>(REFRESH, false, Loading),
+ createRefresh(range = 50..54)
)
fetcherState.pagingDataList[0].receiver.accessHint(
@@ -939,16 +892,14 @@
)
)
advanceUntilIdle()
- assertThat(fetcherState.newEvents()).isEqualTo(
- listOf<PageEvent<Int>>(
- LoadStateUpdate(APPEND, false, Loading),
- createAppend(
- pageOffset = 1,
- range = 55..55,
- endState = Loading
- ),
- createAppend(pageOffset = 2, range = 56..56)
- )
+ assertThat(fetcherState.newEvents()).containsExactly(
+ LoadStateUpdate<Int>(APPEND, false, Loading),
+ createAppend(
+ pageOffset = 1,
+ range = 55..55,
+ endState = Loading
+ ),
+ createAppend(pageOffset = 2, range = 56..56)
)
fetcherState.job.cancel()
@@ -969,11 +920,9 @@
val fetcherState = collectFetcherState(pageFetcher)
advanceUntilIdle()
- assertThat(fetcherState.newEvents()).isEqualTo(
- listOf<PageEvent<Int>>(
- LoadStateUpdate(REFRESH, false, Loading),
- createRefresh(range = 50..51)
- )
+ assertThat(fetcherState.newEvents()).containsExactly(
+ LoadStateUpdate<Int>(REFRESH, false, Loading),
+ createRefresh(range = 50..51)
)
fetcherState.pagingDataList[0].receiver.accessHint(
@@ -987,11 +936,9 @@
)
)
advanceUntilIdle()
- assertThat(fetcherState.newEvents()).isEqualTo(
- listOf<PageEvent<Int>>(
- LoadStateUpdate(APPEND, false, Loading),
- createAppend(pageOffset = 1, range = 52..53)
- )
+ assertThat(fetcherState.newEvents()).containsExactly(
+ LoadStateUpdate<Int>(APPEND, false, Loading),
+ createAppend(pageOffset = 1, range = 52..53)
)
// Start hint processing until load starts, but hasn't finished.
@@ -1017,22 +964,20 @@
)
)
advanceUntilIdle()
- assertThat(fetcherState.newEvents()).isEqualTo(
- listOf<PageEvent<Int>>(
- LoadStateUpdate(APPEND, false, Loading),
- LoadStateUpdate(PREPEND, false, Loading),
- Drop(
- loadType = PREPEND,
- minPageOffset = 0,
- maxPageOffset = 0,
- placeholdersRemaining = 52
- ),
- createAppend(
- pageOffset = 2,
- range = 54..55,
- startState = NotLoading.Incomplete,
- endState = NotLoading.Incomplete
- )
+ assertThat(fetcherState.newEvents()).containsExactly(
+ LoadStateUpdate<Int>(APPEND, false, Loading),
+ LoadStateUpdate<Int>(PREPEND, false, Loading),
+ Drop<Int>(
+ loadType = PREPEND,
+ minPageOffset = 0,
+ maxPageOffset = 0,
+ placeholdersRemaining = 52
+ ),
+ createAppend(
+ pageOffset = 2,
+ range = 54..55,
+ startState = NotLoading.Incomplete,
+ endState = NotLoading.Incomplete
)
)
@@ -1053,11 +998,13 @@
val fetcherState = collectFetcherState(pageFetcher)
advanceUntilIdle()
- assertThat(fetcherState.newEvents()).isEqualTo(
- listOf<PageEvent<Int>>(
- LoadStateUpdate(loadType = REFRESH, fromMediator = false, loadState = Loading),
- createRefresh(range = 50..52)
- )
+ assertThat(fetcherState.newEvents()).containsExactly(
+ LoadStateUpdate<Int>(
+ loadType = REFRESH,
+ fromMediator = false,
+ loadState = Loading
+ ),
+ createRefresh(range = 50..52)
)
// APPEND a few pages.
@@ -1072,12 +1019,14 @@
)
)
advanceUntilIdle()
- assertThat(fetcherState.newEvents()).isEqualTo(
- listOf<PageEvent<Int>>(
- LoadStateUpdate(loadType = APPEND, fromMediator = false, loadState = Loading),
- createAppend(pageOffset = 1, range = 53..53, endState = Loading),
- createAppend(pageOffset = 2, range = 54..54)
- )
+ assertThat(fetcherState.newEvents()).containsExactly(
+ LoadStateUpdate<Int>(
+ loadType = APPEND,
+ fromMediator = false,
+ loadState = Loading
+ ),
+ createAppend(pageOffset = 1, range = 53..53, endState = Loading),
+ createAppend(pageOffset = 2, range = 54..54)
)
// PREPEND a few pages causing APPEND pages to drop
@@ -1092,24 +1041,26 @@
)
)
advanceUntilIdle()
- assertThat(fetcherState.newEvents()).isEqualTo(
- listOf<PageEvent<Int>>(
- LoadStateUpdate(loadType = PREPEND, fromMediator = false, loadState = Loading),
- Drop(
- loadType = APPEND,
- minPageOffset = 2,
- maxPageOffset = 2,
- placeholdersRemaining = 46
- ),
- createPrepend(pageOffset = -1, range = 49..49, startState = Loading),
- Drop(
- loadType = APPEND,
- minPageOffset = 1,
- maxPageOffset = 1,
- placeholdersRemaining = 47
- ),
- createPrepend(pageOffset = -2, range = 48..48)
- )
+ assertThat(fetcherState.newEvents()).containsExactly(
+ LoadStateUpdate<Int>(
+ loadType = PREPEND,
+ fromMediator = false,
+ loadState = Loading
+ ),
+ Drop<Int>(
+ loadType = APPEND,
+ minPageOffset = 2,
+ maxPageOffset = 2,
+ placeholdersRemaining = 46
+ ),
+ createPrepend(pageOffset = -1, range = 49..49, startState = Loading),
+ Drop<Int>(
+ loadType = APPEND,
+ minPageOffset = 1,
+ maxPageOffset = 1,
+ placeholdersRemaining = 47
+ ),
+ createPrepend(pageOffset = -2, range = 48..48)
)
// APPEND a page, this hint would normally be ignored, but has a newer generationId.
@@ -1124,17 +1075,19 @@
)
)
advanceUntilIdle()
- assertThat(fetcherState.newEvents()).isEqualTo(
- listOf<PageEvent<Int>>(
- LoadStateUpdate(loadType = APPEND, fromMediator = false, loadState = Loading),
- Drop(
- loadType = PREPEND,
- minPageOffset = -2,
- maxPageOffset = -2,
- placeholdersRemaining = 49
- ),
- createAppend(pageOffset = 1, range = 53..53)
- )
+ assertThat(fetcherState.newEvents()).containsExactly(
+ LoadStateUpdate<Int>(
+ loadType = APPEND,
+ fromMediator = false,
+ loadState = Loading
+ ),
+ Drop<Int>(
+ loadType = PREPEND,
+ minPageOffset = -2,
+ maxPageOffset = -2,
+ placeholdersRemaining = 49
+ ),
+ createAppend(pageOffset = 1, range = 53..53)
)
fetcherState.job.cancel()
@@ -1146,20 +1099,16 @@
val fetcherState = collectFetcherState(pageFetcher)
advanceUntilIdle()
- assertThat(fetcherState.newEvents()).isEqualTo(
- listOf<PageEvent<Int>>(
- LoadStateUpdate(REFRESH, false, Loading),
- createRefresh(50..51)
- )
+ assertThat(fetcherState.newEvents()).containsExactly(
+ LoadStateUpdate<Int>(REFRESH, false, Loading),
+ createRefresh(50..51)
)
pageFetcher.refresh()
advanceUntilIdle()
- assertThat(fetcherState.newEvents()).isEqualTo(
- listOf<PageEvent<Int>>(
- LoadStateUpdate(REFRESH, false, Loading),
- createRefresh(50..51)
- )
+ assertThat(fetcherState.newEvents()).containsExactly(
+ LoadStateUpdate<Int>(REFRESH, false, Loading),
+ createRefresh(50..51)
)
fetcherState.job.cancel()
@@ -1171,11 +1120,9 @@
val fetcherState = collectFetcherState(pageFetcher)
advanceUntilIdle()
- assertThat(fetcherState.newEvents()).isEqualTo(
- listOf<PageEvent<Int>>(
- LoadStateUpdate(REFRESH, false, Loading),
- createRefresh(50..51)
- )
+ assertThat(fetcherState.newEvents()).containsExactly(
+ LoadStateUpdate<Int>(REFRESH, false, Loading),
+ createRefresh(50..51)
)
fetcherState.pagingDataList[0].receiver.accessHint(
@@ -1190,21 +1137,17 @@
)
advanceUntilIdle()
- assertThat(fetcherState.newEvents()).isEqualTo(
- listOf<PageEvent<Int>>(
- LoadStateUpdate(APPEND, false, Loading),
- createAppend(1, 52..52)
- )
+ assertThat(fetcherState.newEvents()).containsExactly(
+ LoadStateUpdate<Int>(APPEND, false, Loading),
+ createAppend(1, 52..52)
)
pageFetcher.refresh()
advanceUntilIdle()
- assertThat(fetcherState.newEvents()).isEqualTo(
- listOf<PageEvent<Int>>(
- LoadStateUpdate(REFRESH, false, Loading),
- createRefresh(51..52)
- )
+ assertThat(fetcherState.newEvents()).containsExactly(
+ LoadStateUpdate<Int>(REFRESH, false, Loading),
+ createRefresh(51..52)
)
fetcherState.job.cancel()
@@ -1244,15 +1187,13 @@
collectSnapshotData(pager) { state, _ ->
advanceUntilIdle()
- assertThat(state.newEvents()).isEqualTo(
- listOf<PageEvent<Int>>(
- LoadStateUpdate(
- loadType = REFRESH,
- fromMediator = false,
- loadState = Loading
- ),
- createRefresh(range = 50..51)
- )
+ assertThat(state.newEvents()).containsExactly(
+ LoadStateUpdate<Int>(
+ loadType = REFRESH,
+ fromMediator = false,
+ loadState = Loading
+ ),
+ createRefresh(range = 50..51)
)
pageSource.errorNextLoad = true
@@ -1267,32 +1208,28 @@
)
)
advanceUntilIdle()
- assertThat(state.newEvents()).isEqualTo(
- listOf<PageEvent<Int>>(
- LoadStateUpdate(
- loadType = APPEND,
- fromMediator = false,
- loadState = Loading
- ),
- LoadStateUpdate(
- loadType = APPEND,
- fromMediator = false,
- loadState = Error(LOAD_ERROR)
- )
+ assertThat(state.newEvents()).containsExactly(
+ LoadStateUpdate<Int>(
+ loadType = APPEND,
+ fromMediator = false,
+ loadState = Loading
+ ),
+ LoadStateUpdate<Int>(
+ loadType = APPEND,
+ fromMediator = false,
+ loadState = Error(LOAD_ERROR)
)
)
retryBus.send(Unit)
advanceUntilIdle()
- assertThat(state.newEvents()).isEqualTo(
- listOf<PageEvent<Int>>(
- LoadStateUpdate(
- loadType = APPEND,
- fromMediator = false,
- loadState = Loading
- ),
- createAppend(pageOffset = 1, range = 52..52)
- )
+ assertThat(state.newEvents()).containsExactly(
+ LoadStateUpdate<Int>(
+ loadType = APPEND,
+ fromMediator = false,
+ loadState = Loading
+ ),
+ createAppend(pageOffset = 1, range = 52..52)
)
}
}
@@ -1307,15 +1244,13 @@
collectSnapshotData(pager) { state, _ ->
advanceUntilIdle()
- assertThat(state.newEvents()).isEqualTo(
- listOf<PageEvent<Int>>(
- LoadStateUpdate(
- loadType = REFRESH,
- fromMediator = false,
- loadState = Loading
- ),
- createRefresh(range = 50..51)
- )
+ assertThat(state.newEvents()).containsExactly(
+ LoadStateUpdate<Int>(
+ loadType = REFRESH,
+ fromMediator = false,
+ loadState = Loading
+ ),
+ createRefresh(range = 50..51)
)
pager.accessHint(
@@ -1329,15 +1264,13 @@
)
)
advanceUntilIdle()
- assertThat(state.newEvents()).isEqualTo(
- listOf<PageEvent<Int>>(
- LoadStateUpdate(
- loadType = APPEND,
- fromMediator = false,
- loadState = Loading
- ),
- createAppend(pageOffset = 1, range = 52..52)
- )
+ assertThat(state.newEvents()).containsExactly(
+ LoadStateUpdate<Int>(
+ loadType = APPEND,
+ fromMediator = false,
+ loadState = Loading
+ ),
+ createAppend(pageOffset = 1, range = 52..52)
)
retryBus.send(Unit)
advanceUntilIdle()
@@ -1355,15 +1288,13 @@
collectSnapshotData(pager) { state, _ ->
advanceUntilIdle()
- assertThat(state.newEvents()).isEqualTo(
- listOf<PageEvent<Int>>(
- LoadStateUpdate(
- loadType = REFRESH,
- fromMediator = false,
- loadState = Loading
- ),
- createRefresh(range = 50..51)
- )
+ assertThat(state.newEvents()).containsExactly(
+ LoadStateUpdate<Int>(
+ loadType = REFRESH,
+ fromMediator = false,
+ loadState = Loading
+ ),
+ createRefresh(range = 50..51)
)
pageSource.errorNextLoad = true
pager.accessHint(
@@ -1377,31 +1308,27 @@
)
)
advanceUntilIdle()
- assertThat(state.newEvents()).isEqualTo(
- listOf<PageEvent<Int>>(
- LoadStateUpdate(
- loadType = APPEND,
- fromMediator = false,
- loadState = Loading
- ),
- LoadStateUpdate(
- loadType = APPEND,
- fromMediator = false,
- loadState = Error(LOAD_ERROR)
- )
+ assertThat(state.newEvents()).containsExactly(
+ LoadStateUpdate<Int>(
+ loadType = APPEND,
+ fromMediator = false,
+ loadState = Loading
+ ),
+ LoadStateUpdate<Int>(
+ loadType = APPEND,
+ fromMediator = false,
+ loadState = Error(LOAD_ERROR)
)
)
retryBus.send(Unit)
advanceUntilIdle()
- assertThat(state.newEvents()).isEqualTo(
- listOf<PageEvent<Int>>(
- LoadStateUpdate(
- loadType = APPEND,
- fromMediator = false,
- loadState = Loading
- ),
- createAppend(pageOffset = 1, range = 52..52)
- )
+ assertThat(state.newEvents()).containsExactly(
+ LoadStateUpdate<Int>(
+ loadType = APPEND,
+ fromMediator = false,
+ loadState = Loading
+ ),
+ createAppend(pageOffset = 1, range = 52..52)
)
retryBus.send(Unit)
advanceUntilIdle()
@@ -1426,15 +1353,13 @@
collectSnapshotData(pager) { state, _ ->
// Initial REFRESH
advanceUntilIdle()
- assertThat(state.newEvents()).isEqualTo(
- listOf<PageEvent<Int>>(
- LoadStateUpdate(
- loadType = REFRESH,
- fromMediator = false,
- loadState = Loading
- ),
- createRefresh(range = 50..51)
- )
+ assertThat(state.newEvents()).containsExactly(
+ LoadStateUpdate<Int>(
+ loadType = REFRESH,
+ fromMediator = false,
+ loadState = Loading
+ ),
+ createRefresh(range = 50..51)
)
// Failed APPEND
@@ -1450,18 +1375,16 @@
)
)
advanceUntilIdle()
- assertThat(state.newEvents()).isEqualTo(
- listOf<PageEvent<Int>>(
- LoadStateUpdate(
- loadType = APPEND,
- fromMediator = false,
- loadState = Loading
- ),
- LoadStateUpdate(
- loadType = APPEND,
- fromMediator = false,
- loadState = Error(LOAD_ERROR)
- )
+ assertThat(state.newEvents()).containsExactly(
+ LoadStateUpdate<Int>(
+ loadType = APPEND,
+ fromMediator = false,
+ loadState = Loading
+ ),
+ LoadStateUpdate<Int>(
+ loadType = APPEND,
+ fromMediator = false,
+ loadState = Error(LOAD_ERROR)
)
)
@@ -1478,44 +1401,40 @@
)
)
advanceUntilIdle()
- assertThat(state.newEvents()).isEqualTo(
- listOf<PageEvent<Int>>(
- LoadStateUpdate(
- loadType = PREPEND,
- fromMediator = false,
- loadState = Loading
- ),
- LoadStateUpdate(
- loadType = PREPEND,
- fromMediator = false,
- loadState = Error(LOAD_ERROR)
- )
+ assertThat(state.newEvents()).containsExactly(
+ LoadStateUpdate<Int>(
+ loadType = PREPEND,
+ fromMediator = false,
+ loadState = Loading
+ ),
+ LoadStateUpdate<Int>(
+ loadType = PREPEND,
+ fromMediator = false,
+ loadState = Error(LOAD_ERROR)
)
)
// Retry should trigger in both directions.
retryBus.send(Unit)
advanceUntilIdle()
- assertThat(state.newEvents()).isEqualTo(
- listOf<PageEvent<Int>>(
- LoadStateUpdate(
- loadType = PREPEND,
- fromMediator = false,
- loadState = Loading
- ),
- LoadStateUpdate(
- loadType = APPEND,
- fromMediator = false,
- loadState = Loading
- ),
- createPrepend(
- pageOffset = -1,
- range = 49..49,
- startState = NotLoading.Incomplete,
- endState = Loading
- ),
- createAppend(pageOffset = 1, range = 52..52)
- )
+ assertThat(state.newEvents()).containsExactly(
+ LoadStateUpdate<Int>(
+ loadType = PREPEND,
+ fromMediator = false,
+ loadState = Loading
+ ),
+ LoadStateUpdate<Int>(
+ loadType = APPEND,
+ fromMediator = false,
+ loadState = Loading
+ ),
+ createPrepend(
+ pageOffset = -1,
+ range = 49..49,
+ startState = NotLoading.Incomplete,
+ endState = Loading
+ ),
+ createAppend(pageOffset = 1, range = 52..52)
)
}
}
@@ -1546,15 +1465,13 @@
itemsAfter = 48
)
advanceUntilIdle()
- assertThat(pageEvents.newEvents()).isEqualTo(
- listOf<PageEvent<Int>>(
- LoadStateUpdate(REFRESH, false, Loading),
- Refresh(
- pages = listOf(TransformablePage(listOf(0, 1))),
- placeholdersBefore = 50,
- placeholdersAfter = 48,
- combinedLoadStates = CombinedLoadStates.IDLE_SOURCE
- )
+ assertThat(pageEvents.newEvents()).containsExactly(
+ LoadStateUpdate<Int>(REFRESH, false, Loading),
+ Refresh(
+ pages = listOf(TransformablePage(listOf(0, 1))),
+ placeholdersBefore = 50,
+ placeholdersAfter = 48,
+ combinedLoadStates = CombinedLoadStates.IDLE_SOURCE
)
)
@@ -1570,21 +1487,18 @@
)
)
advanceUntilIdle()
- assertThat(pageEvents.newEvents()).isEqualTo(
- listOf<PageEvent<Int>>(
- LoadStateUpdate(APPEND, false, Loading),
- LoadStateUpdate(APPEND, false, Error(LOAD_ERROR))
- )
+ assertThat(pageEvents.newEvents()).containsExactly(
+ LoadStateUpdate<Int>(APPEND, false, Loading),
+ LoadStateUpdate<Int>(APPEND, false, Error(LOAD_ERROR))
)
// Retry failed APPEND
retryBus.send(Unit)
advanceUntilIdle()
- assertThat(pageEvents.newEvents()).isEqualTo(
- listOf<PageEvent<Int>>(
- LoadStateUpdate(APPEND, false, Loading),
- LoadStateUpdate(APPEND, false, Error(LOAD_ERROR))
- )
+ assertThat(pageEvents.newEvents()).containsExactly(
+ LoadStateUpdate<Int>(APPEND, false, Loading),
+ LoadStateUpdate<Int>(APPEND, false, Error(LOAD_ERROR))
+
)
// This hint should be ignored even though in the non-error state it would
@@ -1600,7 +1514,7 @@
)
)
advanceUntilIdle()
- assertThat(pageEvents.newEvents()).isEqualTo(listOf<PageEvent<Int>>())
+ assertThat(pageEvents.newEvents()).isEmpty()
// Hint to trigger PREPEND
pager.accessHint(
@@ -1614,23 +1528,19 @@
)
)
advanceUntilIdle()
- assertThat(pageEvents.newEvents()).isEqualTo(
- listOf<PageEvent<Int>>(
- LoadStateUpdate(PREPEND, false, Loading),
- LoadStateUpdate(PREPEND, false, Error(LOAD_ERROR))
- )
+ assertThat(pageEvents.newEvents()).containsExactly(
+ LoadStateUpdate<Int>(PREPEND, false, Loading),
+ LoadStateUpdate<Int>(PREPEND, false, Error(LOAD_ERROR))
)
// Retry failed hints, both PREPEND and APPEND should trigger.
retryBus.send(Unit)
advanceUntilIdle()
- assertThat(pageEvents.newEvents()).isEqualTo(
- listOf<PageEvent<Int>>(
- LoadStateUpdate(PREPEND, false, Loading),
- LoadStateUpdate(APPEND, false, Loading),
- LoadStateUpdate(PREPEND, false, Error(LOAD_ERROR)),
- LoadStateUpdate(APPEND, false, Error(LOAD_ERROR))
- )
+ assertThat(pageEvents.newEvents()).containsExactly(
+ LoadStateUpdate<Int>(PREPEND, false, Loading),
+ LoadStateUpdate<Int>(APPEND, false, Loading),
+ LoadStateUpdate<Int>(PREPEND, false, Error(LOAD_ERROR)),
+ LoadStateUpdate<Int>(APPEND, false, Error(LOAD_ERROR))
)
// This hint should be ignored even though in the non-error state it would
@@ -1646,7 +1556,7 @@
)
)
advanceUntilIdle()
- assertThat(pageEvents.newEvents()).isEqualTo(listOf<PageEvent<Int>>())
+ assertThat(pageEvents.newEvents()).isEmpty()
}
}
}
@@ -1661,20 +1571,16 @@
pageSource.errorNextLoad = true
advanceUntilIdle()
- assertThat(state.newEvents()).isEqualTo(
- listOf<PageEvent<Int>>(
- LoadStateUpdate(REFRESH, false, Loading),
- LoadStateUpdate(REFRESH, false, Error(LOAD_ERROR))
- )
+ assertThat(state.newEvents()).containsExactly(
+ LoadStateUpdate<Int>(REFRESH, false, Loading),
+ LoadStateUpdate<Int>(REFRESH, false, Error(LOAD_ERROR))
)
retryBus.send(Unit)
advanceUntilIdle()
- assertThat(state.newEvents()).isEqualTo(
- listOf<PageEvent<Int>>(
- LoadStateUpdate(REFRESH, false, Loading),
- createRefresh(50..51)
- )
+ assertThat(state.newEvents()).containsExactly(
+ LoadStateUpdate<Int>(REFRESH, false, Loading),
+ createRefresh(50..51)
)
}
}
@@ -1688,18 +1594,16 @@
collectSnapshotData(pager) { state, _ ->
pageSource.errorNextLoad = true
advanceUntilIdle()
- assertThat(state.newEvents()).isEqualTo(
- listOf<PageEvent<Int>>(
- LoadStateUpdate(
- loadType = REFRESH,
- fromMediator = false,
- loadState = Loading
- ),
- LoadStateUpdate(
- loadType = REFRESH,
- fromMediator = false,
- loadState = Error(LOAD_ERROR)
- )
+ assertThat(state.newEvents()).containsExactly(
+ LoadStateUpdate<Int>(
+ loadType = REFRESH,
+ fromMediator = false,
+ loadState = Loading
+ ),
+ LoadStateUpdate<Int>(
+ loadType = REFRESH,
+ fromMediator = false,
+ loadState = Error(LOAD_ERROR)
)
)
pager.accessHint(
@@ -1717,21 +1621,19 @@
retryBus.send(Unit)
advanceUntilIdle()
- assertThat(state.newEvents()).isEqualTo(
- listOf<PageEvent<Int>>(
- LoadStateUpdate(
- loadType = REFRESH,
- fromMediator = false,
- loadState = Loading
- ),
- createRefresh(range = 50..51),
- LoadStateUpdate(
- loadType = PREPEND,
- fromMediator = false,
- loadState = Loading
- ),
- createPrepend(pageOffset = -1, range = 49..49)
- )
+ assertThat(state.newEvents()).containsExactly(
+ LoadStateUpdate<Int>(
+ loadType = REFRESH,
+ fromMediator = false,
+ loadState = Loading
+ ),
+ createRefresh(range = 50..51),
+ LoadStateUpdate<Int>(
+ loadType = PREPEND,
+ fromMediator = false,
+ loadState = Loading
+ ),
+ createPrepend(pageOffset = -1, range = 49..49)
)
}
}
@@ -1850,12 +1752,11 @@
advanceUntilIdle()
- val expected: List<PageEvent<Int>> = listOf(
- LoadStateUpdate(REFRESH, false, Loading),
+ assertThat(fetcherState.pageEventLists[0]).containsExactly(
+ LoadStateUpdate<Int>(REFRESH, false, Loading),
createRefresh(range = 50..51).let { Refresh(it.pages, 0, 0, it.combinedLoadStates) }
)
- assertEvents(expected, fetcherState.pageEventLists[0])
fetcherState.job.cancel()
}
@@ -1872,11 +1773,9 @@
val fetcherState = collectFetcherState(pageFetcher)
advanceUntilIdle()
- assertThat(fetcherState.newEvents()).isEqualTo(
- listOf<PageEvent<Int>>(
- LoadStateUpdate(REFRESH, false, Loading),
- createRefresh(range = 50..51).let { Refresh(it.pages, 0, 0, it.combinedLoadStates) }
- )
+ assertThat(fetcherState.newEvents()).containsExactly(
+ LoadStateUpdate<Int>(REFRESH, false, Loading),
+ createRefresh(range = 50..51).let { Refresh(it.pages, 0, 0, it.combinedLoadStates) }
)
fetcherState.pagingDataList[0].receiver.accessHint(
ViewportHint.Access(
@@ -1889,11 +1788,9 @@
)
)
advanceUntilIdle()
- assertThat(fetcherState.newEvents()).isEqualTo(
- listOf<PageEvent<Int>>(
- LoadStateUpdate(PREPEND, false, Loading),
- createPrepend(-1, 49..49).let { Prepend(it.pages, 0, it.combinedLoadStates) }
- )
+ assertThat(fetcherState.newEvents()).containsExactly(
+ LoadStateUpdate<Int>(PREPEND, false, Loading),
+ createPrepend(-1, 49..49).let { Prepend(it.pages, 0, it.combinedLoadStates) }
)
fetcherState.job.cancel()
@@ -1912,11 +1809,9 @@
val fetcherState = collectFetcherState(pageFetcher)
advanceUntilIdle()
- assertThat(fetcherState.newEvents()).isEqualTo(
- listOf<PageEvent<Int>>(
- LoadStateUpdate(REFRESH, false, Loading),
- createRefresh(range = 50..51).let { Refresh(it.pages, 0, 0, it.combinedLoadStates) }
- )
+ assertThat(fetcherState.newEvents()).containsExactly(
+ LoadStateUpdate<Int>(REFRESH, false, Loading),
+ createRefresh(range = 50..51).let { Refresh(it.pages, 0, 0, it.combinedLoadStates) }
)
fetcherState.pagingDataList[0].receiver.accessHint(
@@ -1930,11 +1825,9 @@
)
)
advanceUntilIdle()
- assertThat(fetcherState.newEvents()).isEqualTo(
- listOf<PageEvent<Int>>(
- LoadStateUpdate(APPEND, false, Loading),
- createAppend(1, 52..52).let { Append(it.pages, 0, it.combinedLoadStates) }
- )
+ assertThat(fetcherState.newEvents()).containsExactly(
+ LoadStateUpdate<Int>(APPEND, false, Loading),
+ createAppend(1, 52..52).let { Append(it.pages, 0, it.combinedLoadStates) }
)
fetcherState.job.cancel()
@@ -1953,11 +1846,9 @@
val fetcherState = collectFetcherState(pageFetcher)
advanceUntilIdle()
- assertThat(fetcherState.newEvents()).isEqualTo(
- listOf<PageEvent<Int>>(
- LoadStateUpdate(REFRESH, false, Loading),
- createRefresh(range = 50..52)
- )
+ assertThat(fetcherState.newEvents()).containsExactly(
+ LoadStateUpdate<Int>(REFRESH, false, Loading),
+ createRefresh(range = 50..52)
)
fetcherState.pagingDataList[0].receiver.accessHint(
ViewportHint.Access(
@@ -1970,11 +1861,9 @@
)
)
advanceUntilIdle()
- assertThat(fetcherState.newEvents()).isEqualTo(
- listOf<PageEvent<Int>>(
- LoadStateUpdate(APPEND, false, Loading),
- createAppend(pageOffset = 1, range = 53..53)
- )
+ assertThat(fetcherState.newEvents()).containsExactly(
+ LoadStateUpdate<Int>(APPEND, false, Loading),
+ createAppend(pageOffset = 1, range = 53..53)
)
fetcherState.job.cancel()
@@ -2138,11 +2027,9 @@
collectSnapshotData(pager) { state, _ ->
pagingSource.errorNextLoad = true
advanceUntilIdle()
- assertThat(state.newEvents()).isEqualTo(
- listOf<PageEvent<Int>>(
- LoadStateUpdate(REFRESH, false, Loading),
- LoadStateUpdate(REFRESH, false, Error(LOAD_ERROR))
- )
+ assertThat(state.newEvents()).containsExactly(
+ LoadStateUpdate<Int>(REFRESH, false, Loading),
+ LoadStateUpdate<Int>(REFRESH, false, Error(LOAD_ERROR))
)
pagingSource.errorNextLoad = true
@@ -2150,11 +2037,9 @@
// Should be ignored by pager as it's still processing previous retry.
retryBus.send(Unit)
advanceUntilIdle()
- assertThat(state.newEvents()).isEqualTo(
- listOf<PageEvent<Int>>(
- LoadStateUpdate(REFRESH, false, Loading),
- LoadStateUpdate(REFRESH, false, Error(LOAD_ERROR))
- )
+ assertThat(state.newEvents()).containsExactly(
+ LoadStateUpdate<Int>(REFRESH, false, Loading),
+ LoadStateUpdate<Int>(REFRESH, false, Error(LOAD_ERROR))
)
}
}
@@ -2297,47 +2182,54 @@
val state = collectFetcherState(pager)
advanceUntilIdle()
- assertThat(state.newEvents()).isEqualTo(
- listOf(
- LoadStateUpdate(loadType = REFRESH, fromMediator = true, loadState = Loading),
- LoadStateUpdate(loadType = REFRESH, fromMediator = false, loadState = Loading),
- LoadStateUpdate(
- loadType = REFRESH,
- fromMediator = true,
- loadState = NotLoading(endOfPaginationReached = true)
- ),
- LoadStateUpdate(
- loadType = PREPEND,
- fromMediator = true,
- loadState = NotLoading(endOfPaginationReached = true)
- ),
- LoadStateUpdate(
- loadType = APPEND,
- fromMediator = true,
- loadState = NotLoading(endOfPaginationReached = true)
- ),
- Refresh(
- pages = listOf(
- TransformablePage(
- originalPageOffsets = intArrayOf(0),
- data = listOf(0),
- hintOriginalPageOffset = 0,
- hintOriginalIndices = null
- )
- ),
- placeholdersBefore = 0,
- placeholdersAfter = 0,
- combinedLoadStates = remoteLoadStatesOf(
- refresh = NotLoading(endOfPaginationReached = true),
- prepend = NotLoading(endOfPaginationReached = true),
- append = NotLoading(endOfPaginationReached = true),
- refreshLocal = NotLoading(endOfPaginationReached = false),
- prependLocal = NotLoading(endOfPaginationReached = true),
- appendLocal = NotLoading(endOfPaginationReached = true),
- refreshRemote = NotLoading(endOfPaginationReached = true),
- prependRemote = NotLoading(endOfPaginationReached = true),
- appendRemote = NotLoading(endOfPaginationReached = true),
+
+ assertThat(state.newEvents()).containsExactly(
+ LoadStateUpdate<Int>(
+ loadType = REFRESH,
+ fromMediator = true,
+ loadState = Loading
+ ),
+ LoadStateUpdate<Int>(
+ loadType = REFRESH,
+ fromMediator = false,
+ loadState = Loading
+ ),
+ LoadStateUpdate<PageEvent<Int>>(
+ loadType = REFRESH,
+ fromMediator = true,
+ loadState = NotLoading(endOfPaginationReached = true)
+ ),
+ LoadStateUpdate<Int>(
+ loadType = PREPEND,
+ fromMediator = true,
+ loadState = NotLoading(endOfPaginationReached = true)
+ ),
+ LoadStateUpdate<Int>(
+ loadType = APPEND,
+ fromMediator = true,
+ loadState = NotLoading(endOfPaginationReached = true)
+ ),
+ Refresh(
+ pages = listOf(
+ TransformablePage(
+ originalPageOffsets = intArrayOf(0),
+ data = listOf(0),
+ hintOriginalPageOffset = 0,
+ hintOriginalIndices = null
)
+ ),
+ placeholdersBefore = 0,
+ placeholdersAfter = 0,
+ combinedLoadStates = remoteLoadStatesOf(
+ refresh = NotLoading(endOfPaginationReached = true),
+ prepend = NotLoading(endOfPaginationReached = true),
+ append = NotLoading(endOfPaginationReached = true),
+ refreshLocal = NotLoading(endOfPaginationReached = false),
+ prependLocal = NotLoading(endOfPaginationReached = true),
+ appendLocal = NotLoading(endOfPaginationReached = true),
+ refreshRemote = NotLoading(endOfPaginationReached = true),
+ prependRemote = NotLoading(endOfPaginationReached = true),
+ appendRemote = NotLoading(endOfPaginationReached = true),
)
)
)
@@ -2927,57 +2819,53 @@
advanceTimeBy(1000)
- assertThat(fetcherState.newEvents()).isEqualTo(
- listOf(
- LoadStateUpdate(
- loadType = REFRESH,
- fromMediator = true,
- loadState = Loading,
- ),
- LoadStateUpdate(
- loadType = REFRESH,
- fromMediator = false,
- loadState = Loading,
- ),
- Refresh(
- pages = listOf(
- TransformablePage(
- originalPageOffset = 0,
- data = listOf(50)
- )
- ),
- placeholdersBefore = 50,
- placeholdersAfter = 49,
- combinedLoadStates = remoteLoadStatesOf(
- refresh = Loading,
- prependLocal = NotLoading.Complete,
- appendLocal = NotLoading.Complete,
- refreshRemote = Loading,
+ assertThat(fetcherState.newEvents()).containsExactly(
+ LoadStateUpdate<Int>(
+ loadType = REFRESH,
+ fromMediator = true,
+ loadState = Loading,
+ ),
+ LoadStateUpdate<Int>(
+ loadType = REFRESH,
+ fromMediator = false,
+ loadState = Loading,
+ ),
+ Refresh(
+ pages = listOf(
+ TransformablePage(
+ originalPageOffset = 0,
+ data = listOf(50)
)
),
+ placeholdersBefore = 50,
+ placeholdersAfter = 49,
+ combinedLoadStates = remoteLoadStatesOf(
+ refresh = Loading,
+ prependLocal = NotLoading.Complete,
+ appendLocal = NotLoading.Complete,
+ refreshRemote = Loading,
+ )
),
)
advanceUntilIdle()
- assertThat(fetcherState.newEvents()).isEqualTo(
- listOf<PageEvent<Int>>(
- LoadStateUpdate(
- loadType = REFRESH,
- fromMediator = true,
- loadState = NotLoading.Complete,
- ),
- LoadStateUpdate(
- loadType = PREPEND,
- fromMediator = true,
- loadState = NotLoading.Complete
- ),
- LoadStateUpdate(
- loadType = APPEND,
- fromMediator = true,
- loadState = NotLoading.Complete
- ),
- )
+ assertThat(fetcherState.newEvents()).containsExactly(
+ LoadStateUpdate<Int>(
+ loadType = REFRESH,
+ fromMediator = true,
+ loadState = NotLoading.Complete,
+ ),
+ LoadStateUpdate<Int>(
+ loadType = PREPEND,
+ fromMediator = true,
+ loadState = NotLoading.Complete
+ ),
+ LoadStateUpdate<Int>(
+ loadType = APPEND,
+ fromMediator = true,
+ loadState = NotLoading.Complete
+ ),
)
fetcherState.job.cancel()
@@ -3234,22 +3122,30 @@
)
collectSnapshotData(pageFetcherSnapshot) { state, _ ->
advanceUntilIdle()
- assertThat(state.newEvents()).isEqualTo(
- listOf(
- LoadStateUpdate(loadType = REFRESH, fromMediator = false, loadState = Loading),
- createRefresh(range = 50..51),
- )
+ assertThat(state.newEvents()).containsExactly(
+ LoadStateUpdate<Int>(
+ loadType = REFRESH,
+ fromMediator = false,
+ loadState = Loading
+ ),
+ createRefresh(range = 50..51),
)
pageFetcherSnapshot.accessHint(ViewportHint.Initial(0, 0, 0, 0))
advanceUntilIdle()
- assertThat(state.newEvents()).isEqualTo(
- listOf(
- LoadStateUpdate(loadType = PREPEND, fromMediator = false, loadState = Loading),
- LoadStateUpdate(loadType = APPEND, fromMediator = false, loadState = Loading),
- createPrepend(pageOffset = -1, range = 49..49, endState = Loading),
- createAppend(pageOffset = 1, range = 52..52),
- )
+ assertThat(state.newEvents()).containsExactly(
+ LoadStateUpdate<Int>(
+ loadType = PREPEND,
+ fromMediator = false,
+ loadState = Loading
+ ),
+ LoadStateUpdate<Int>(
+ loadType = APPEND,
+ fromMediator = false,
+ loadState = Loading
+ ),
+ createPrepend(pageOffset = -1, range = 49..49, endState = Loading),
+ createAppend(pageOffset = 1, range = 52..52),
)
}
}
diff --git a/room/runtime/api/current.txt b/room/runtime/api/current.txt
index 460a85c..d9b5519 100644
--- a/room/runtime/api/current.txt
+++ b/room/runtime/api/current.txt
@@ -86,7 +86,7 @@
method public androidx.room.RoomDatabase.Builder<T!> fallbackToDestructiveMigrationFrom(int...);
method public androidx.room.RoomDatabase.Builder<T!> fallbackToDestructiveMigrationOnDowngrade();
method public androidx.room.RoomDatabase.Builder<T!> openHelperFactory(androidx.sqlite.db.SupportSQLiteOpenHelper.Factory?);
- method public androidx.room.RoomDatabase.Builder<T!> setAutoCloseTimeout(long, java.util.concurrent.TimeUnit);
+ method public androidx.room.RoomDatabase.Builder<T!> setAutoCloseTimeout(@IntRange(from=0) long, java.util.concurrent.TimeUnit);
method public androidx.room.RoomDatabase.Builder<T!> setJournalMode(androidx.room.RoomDatabase.JournalMode);
method public androidx.room.RoomDatabase.Builder<T!> setQueryCallback(androidx.room.RoomDatabase.QueryCallback, java.util.concurrent.Executor);
method public androidx.room.RoomDatabase.Builder<T!> setQueryExecutor(java.util.concurrent.Executor);
diff --git a/room/runtime/api/public_plus_experimental_current.txt b/room/runtime/api/public_plus_experimental_current.txt
index 5813624..d0cfe70 100644
--- a/room/runtime/api/public_plus_experimental_current.txt
+++ b/room/runtime/api/public_plus_experimental_current.txt
@@ -87,7 +87,7 @@
method public androidx.room.RoomDatabase.Builder<T!> fallbackToDestructiveMigrationFrom(int...);
method public androidx.room.RoomDatabase.Builder<T!> fallbackToDestructiveMigrationOnDowngrade();
method public androidx.room.RoomDatabase.Builder<T!> openHelperFactory(androidx.sqlite.db.SupportSQLiteOpenHelper.Factory?);
- method public androidx.room.RoomDatabase.Builder<T!> setAutoCloseTimeout(long, java.util.concurrent.TimeUnit);
+ method public androidx.room.RoomDatabase.Builder<T!> setAutoCloseTimeout(@IntRange(from=0) long, java.util.concurrent.TimeUnit);
method public androidx.room.RoomDatabase.Builder<T!> setJournalMode(androidx.room.RoomDatabase.JournalMode);
method public androidx.room.RoomDatabase.Builder<T!> setQueryCallback(androidx.room.RoomDatabase.QueryCallback, java.util.concurrent.Executor);
method public androidx.room.RoomDatabase.Builder<T!> setQueryExecutor(java.util.concurrent.Executor);
diff --git a/room/runtime/api/restricted_current.txt b/room/runtime/api/restricted_current.txt
index 31ff929..0db4e83 100644
--- a/room/runtime/api/restricted_current.txt
+++ b/room/runtime/api/restricted_current.txt
@@ -129,7 +129,7 @@
method public androidx.room.RoomDatabase.Builder<T!> fallbackToDestructiveMigrationFrom(int...);
method public androidx.room.RoomDatabase.Builder<T!> fallbackToDestructiveMigrationOnDowngrade();
method public androidx.room.RoomDatabase.Builder<T!> openHelperFactory(androidx.sqlite.db.SupportSQLiteOpenHelper.Factory?);
- method public androidx.room.RoomDatabase.Builder<T!> setAutoCloseTimeout(long, java.util.concurrent.TimeUnit);
+ method public androidx.room.RoomDatabase.Builder<T!> setAutoCloseTimeout(@IntRange(from=0) long, java.util.concurrent.TimeUnit);
method public androidx.room.RoomDatabase.Builder<T!> setJournalMode(androidx.room.RoomDatabase.JournalMode);
method public androidx.room.RoomDatabase.Builder<T!> setQueryCallback(androidx.room.RoomDatabase.QueryCallback, java.util.concurrent.Executor);
method public androidx.room.RoomDatabase.Builder<T!> setQueryExecutor(java.util.concurrent.Executor);
diff --git a/room/runtime/src/main/java/androidx/room/RoomDatabase.java b/room/runtime/src/main/java/androidx/room/RoomDatabase.java
index d76e1c1..9b652bf 100644
--- a/room/runtime/src/main/java/androidx/room/RoomDatabase.java
+++ b/room/runtime/src/main/java/androidx/room/RoomDatabase.java
@@ -26,6 +26,7 @@
import android.util.Log;
import androidx.annotation.CallSuper;
+import androidx.annotation.IntRange;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
@@ -1226,7 +1227,7 @@
* {@link RoomDatabase.Builder#build()}.
*
* @param autoCloseTimeout the amount of time after the last usage before closing the
- * database
+ * database. Must greater or equal to zero.
* @param autoCloseTimeUnit the timeunit for autoCloseTimeout.
* @return This {@link Builder} instance
*/
@@ -1234,8 +1235,8 @@
@SuppressWarnings("MissingGetterMatchingBuilder")
@ExperimentalRoomApi // When experimental is removed, add these parameters to
// DatabaseConfiguration
- public Builder<T> setAutoCloseTimeout(long autoCloseTimeout,
- @NonNull TimeUnit autoCloseTimeUnit) {
+ public Builder<T> setAutoCloseTimeout(
+ @IntRange(from = 0) long autoCloseTimeout, @NonNull TimeUnit autoCloseTimeUnit) {
if (autoCloseTimeout < 0) {
throw new IllegalArgumentException("autoCloseTimeout must be >= 0");
}
diff --git a/wear/wear-complications-data/api/current.txt b/wear/wear-complications-data/api/current.txt
index fb2fe12..b44459d 100644
--- a/wear/wear-complications-data/api/current.txt
+++ b/wear/wear-complications-data/api/current.txt
@@ -79,17 +79,19 @@
}
public final class ComplicationProviderInfo implements android.os.Parcelable {
- ctor public ComplicationProviderInfo(String, String, android.graphics.drawable.Icon, int);
+ ctor public ComplicationProviderInfo(String, String, android.graphics.drawable.Icon, int, android.content.ComponentName);
ctor public ComplicationProviderInfo(android.os.Parcel);
method public int describeContents();
method public String? getAppName();
method public int getComplicationType();
+ method public android.content.ComponentName? getProviderComponentName();
method public android.graphics.drawable.Icon? getProviderIcon();
method public String? getProviderName();
- method public void setAppName(String?);
+ method public void setAppName(String);
method public void setComplicationType(int);
- method public void setProviderIcon(android.graphics.drawable.Icon?);
- method public void setProviderName(String?);
+ method public void setProviderComponentName(android.content.ComponentName);
+ method public void setProviderIcon(android.graphics.drawable.Icon);
+ method public void setProviderName(String);
method public void writeToParcel(android.os.Parcel, int);
field public static final android.os.Parcelable.Creator<android.support.wearable.complications.ComplicationProviderInfo!> CREATOR;
}
@@ -168,6 +170,7 @@
public class ProviderInfoRetriever implements java.lang.AutoCloseable {
ctor public ProviderInfoRetriever(android.content.Context);
method public void close();
+ method @RequiresApi(android.os.Build.VERSION_CODES.R) public com.google.common.util.concurrent.ListenableFuture<androidx.wear.complications.data.ComplicationData!> requestPreviewComplicationData(android.content.ComponentName, androidx.wear.complications.data.ComplicationType);
method public com.google.common.util.concurrent.ListenableFuture<androidx.wear.complications.ProviderInfoRetriever.ProviderInfo![]!> retrieveProviderInfo(android.content.ComponentName, int[]);
}
diff --git a/wear/wear-complications-data/api/public_plus_experimental_current.txt b/wear/wear-complications-data/api/public_plus_experimental_current.txt
index 73bb203..be22720 100644
--- a/wear/wear-complications-data/api/public_plus_experimental_current.txt
+++ b/wear/wear-complications-data/api/public_plus_experimental_current.txt
@@ -79,17 +79,19 @@
}
public final class ComplicationProviderInfo implements android.os.Parcelable {
- ctor public ComplicationProviderInfo(String, String, android.graphics.drawable.Icon, int);
+ ctor public ComplicationProviderInfo(String, String, android.graphics.drawable.Icon, int, android.content.ComponentName);
ctor public ComplicationProviderInfo(android.os.Parcel);
method public int describeContents();
method public String? getAppName();
method public int getComplicationType();
+ method public android.content.ComponentName? getProviderComponentName();
method public android.graphics.drawable.Icon? getProviderIcon();
method public String? getProviderName();
- method public void setAppName(String?);
+ method public void setAppName(String);
method public void setComplicationType(int);
- method public void setProviderIcon(android.graphics.drawable.Icon?);
- method public void setProviderName(String?);
+ method public void setProviderComponentName(android.content.ComponentName);
+ method public void setProviderIcon(android.graphics.drawable.Icon);
+ method public void setProviderName(String);
method public void writeToParcel(android.os.Parcel, int);
field public static final android.os.Parcelable.Creator<android.support.wearable.complications.ComplicationProviderInfo!> CREATOR;
}
@@ -168,6 +170,7 @@
public class ProviderInfoRetriever implements java.lang.AutoCloseable {
ctor public ProviderInfoRetriever(android.content.Context);
method public void close();
+ method @RequiresApi(android.os.Build.VERSION_CODES.R) public com.google.common.util.concurrent.ListenableFuture<androidx.wear.complications.data.ComplicationData!> requestPreviewComplicationData(android.content.ComponentName, androidx.wear.complications.data.ComplicationType);
method public com.google.common.util.concurrent.ListenableFuture<androidx.wear.complications.ProviderInfoRetriever.ProviderInfo![]!> retrieveProviderInfo(android.content.ComponentName, int[]);
}
diff --git a/wear/wear-complications-data/api/restricted_current.txt b/wear/wear-complications-data/api/restricted_current.txt
index ac3164c..a471693 100644
--- a/wear/wear-complications-data/api/restricted_current.txt
+++ b/wear/wear-complications-data/api/restricted_current.txt
@@ -85,17 +85,19 @@
}
public final class ComplicationProviderInfo implements android.os.Parcelable {
- ctor public ComplicationProviderInfo(String, String, android.graphics.drawable.Icon, @android.support.wearable.complications.ComplicationData.ComplicationType int);
+ ctor public ComplicationProviderInfo(String, String, android.graphics.drawable.Icon, @android.support.wearable.complications.ComplicationData.ComplicationType int, android.content.ComponentName);
ctor public ComplicationProviderInfo(android.os.Parcel);
method public int describeContents();
method public String? getAppName();
method @android.support.wearable.complications.ComplicationData.ComplicationType public int getComplicationType();
+ method public android.content.ComponentName? getProviderComponentName();
method public android.graphics.drawable.Icon? getProviderIcon();
method public String? getProviderName();
- method public void setAppName(String?);
+ method public void setAppName(String);
method public void setComplicationType(@android.support.wearable.complications.ComplicationData.ComplicationType int);
- method public void setProviderIcon(android.graphics.drawable.Icon?);
- method public void setProviderName(String?);
+ method public void setProviderComponentName(android.content.ComponentName);
+ method public void setProviderIcon(android.graphics.drawable.Icon);
+ method public void setProviderName(String);
method public void writeToParcel(android.os.Parcel, int);
field public static final android.os.Parcelable.Creator<android.support.wearable.complications.ComplicationProviderInfo!> CREATOR;
}
@@ -202,6 +204,7 @@
public class ProviderInfoRetriever implements java.lang.AutoCloseable {
ctor public ProviderInfoRetriever(android.content.Context);
method public void close();
+ method @RequiresApi(android.os.Build.VERSION_CODES.R) public com.google.common.util.concurrent.ListenableFuture<androidx.wear.complications.data.ComplicationData!> requestPreviewComplicationData(android.content.ComponentName, androidx.wear.complications.data.ComplicationType);
method public com.google.common.util.concurrent.ListenableFuture<androidx.wear.complications.ProviderInfoRetriever.ProviderInfo![]!> retrieveProviderInfo(android.content.ComponentName, int[]);
}
diff --git a/wear/wear-complications-data/src/main/aidl/android/support/wearable/complications/IPreviewComplicationDataCallback.aidl b/wear/wear-complications-data/src/main/aidl/android/support/wearable/complications/IPreviewComplicationDataCallback.aidl
new file mode 100644
index 0000000..f30007b
--- /dev/null
+++ b/wear/wear-complications-data/src/main/aidl/android/support/wearable/complications/IPreviewComplicationDataCallback.aidl
@@ -0,0 +1,16 @@
+package android.support.wearable.complications;
+
+import android.support.wearable.complications.ComplicationData;
+
+/**
+ * Callback for IProviderInfoService.requestPreviewComplicationData to fetch
+ * preview {@link ComplicationData} from a provider.
+ *
+ * @hide
+ */
+oneway interface IPreviewComplicationDataCallback {
+ /**
+ * Updates complication data for the given complication.
+ */
+ void updateComplicationData(in ComplicationData data);
+}
diff --git a/wear/wear-complications-data/src/main/aidl/android/support/wearable/complications/IProviderInfoService.aidl b/wear/wear-complications-data/src/main/aidl/android/support/wearable/complications/IProviderInfoService.aidl
index c58cdba..312b1e0 100644
--- a/wear/wear-complications-data/src/main/aidl/android/support/wearable/complications/IProviderInfoService.aidl
+++ b/wear/wear-complications-data/src/main/aidl/android/support/wearable/complications/IProviderInfoService.aidl
@@ -1,7 +1,9 @@
package android.support.wearable.complications;
import android.content.ComponentName;
+import android.support.wearable.complications.ComplicationData;
import android.support.wearable.complications.ComplicationProviderInfo;
+import android.support.wearable.complications.IPreviewComplicationDataCallback;
/**
* Interface for a service that allows provider info to be retrieved from the system.
@@ -9,6 +11,15 @@
* @hide
*/
interface IProviderInfoService {
+ // IMPORTANT NOTE: All methods must be given an explicit transaction id that must never change
+ // in the future to remain binary backwards compatible.
+ // Next Id: 3
+
+ /**
+ * API version number. This should be incremented every time a new method is added.
+ */
+ const int API_VERSION = 1;
+
/**
* Returns provider info for each of the provided ids, in an array in the same order as the ids.
* For each id, if no provider is configured then null will be added at that index of the
@@ -16,4 +27,30 @@
*/
ComplicationProviderInfo[] getProviderInfos(
in ComponentName watchFaceComponent, in int[] ids) = 0;
+
+ /**
+ * Returns the version number for this API which the client can use to determine which methods
+ * are available.
+ *
+ * @since API version 1. Note this will correctly return 0 for API level 0 due to the way AIDL
+ * is implemented.
+ */
+ int getApiVersion() = 1;
+
+ /**
+ * Requests preview complication data for the specified provder component and complication type.
+ * Returns true if the result will be delivered by previewComplicationDataCallback or false if
+ * there was an error and no callback will be issued.
+ *
+ * @param providerComponent The {@link ComponentName} of the provider we want preview data for
+ * @param complicationType The type of the complication, see
+ * {@link ComplicationData.ComplicationType}
+ * @param previewComplicationDataCallback The {@link IPreviewComplicationDataCallback} on which
+ * any preview data will be reported
+ * @since API version 1.
+ */
+ boolean requestPreviewComplicationData(
+ in ComponentName providerComponent,
+ int complicationType,
+ in IPreviewComplicationDataCallback previewComplicationDataCallback) = 2;
}
diff --git a/wear/wear-complications-data/src/main/java/android/support/wearable/complications/ComplicationProviderInfo.java b/wear/wear-complications-data/src/main/java/android/support/wearable/complications/ComplicationProviderInfo.java
index 95d8020..e127e6f 100644
--- a/wear/wear-complications-data/src/main/java/android/support/wearable/complications/ComplicationProviderInfo.java
+++ b/wear/wear-complications-data/src/main/java/android/support/wearable/complications/ComplicationProviderInfo.java
@@ -17,6 +17,7 @@
package android.support.wearable.complications;
import android.annotation.SuppressLint;
+import android.content.ComponentName;
import android.graphics.drawable.Icon;
import android.os.Bundle;
import android.os.Parcel;
@@ -48,6 +49,7 @@
};
private static final String KEY_APP_NAME = "app_name";
+ private static final String KEY_PROVIDER_COMPONENT_NAME = "provider_component";
private static final String KEY_PROVIDER_NAME = "provider_name";
private static final String KEY_PROVIDER_ICON = "provider_icon";
private static final String KEY_PROVIDER_TYPE = "complication_type";
@@ -56,6 +58,7 @@
@Nullable private String mProviderName;
@Nullable private Icon mProviderIcon;
@ComplicationData.ComplicationType private int mComplicationType;
+ @Nullable private ComponentName mProviderComponentName;
/**
* Constructs a {@link ComplicationProviderInfo} with the details of a complication provider.
@@ -64,14 +67,17 @@
* @param providerName The name of the complication provider within the app
* @param providerIcon The icon for the complication provider
* @param complicationType The type of complication provided
+ * @param providerComponentName The preview complication data
*/
public ComplicationProviderInfo(
@NonNull String appName, @NonNull String providerName, @NonNull Icon providerIcon,
- @ComplicationData.ComplicationType int complicationType) {
+ @ComplicationData.ComplicationType int complicationType,
+ @NonNull ComponentName providerComponentName) {
this.mAppName = appName;
this.mProviderName = providerName;
this.mProviderIcon = providerIcon;
this.mComplicationType = complicationType;
+ this.mProviderComponentName = providerComponentName;
}
/**
@@ -84,6 +90,7 @@
mProviderName = bundle.getString(KEY_PROVIDER_NAME);
mProviderIcon = bundle.getParcelable(KEY_PROVIDER_ICON);
mComplicationType = bundle.getInt(KEY_PROVIDER_TYPE);
+ mProviderComponentName = bundle.getParcelable(KEY_PROVIDER_COMPONENT_NAME);
}
/**
@@ -99,6 +106,7 @@
bundle.putString(KEY_PROVIDER_NAME, mProviderName);
bundle.putParcelable(KEY_PROVIDER_ICON, mProviderIcon);
bundle.putInt(KEY_PROVIDER_TYPE, mComplicationType);
+ bundle.putParcelable(KEY_PROVIDER_COMPONENT_NAME, mProviderComponentName);
dest.writeBundle(bundle);
}
@@ -109,7 +117,7 @@
}
/** Sets the name of the application containing the complication provider. */
- public void setAppName(@Nullable String appName) {
+ public void setAppName(@NonNull String appName) {
mAppName = appName;
}
@@ -120,7 +128,7 @@
}
/** Sets the name of the complication provider */
- public void setProviderName(@Nullable String providerName) {
+ public void setProviderName(@NonNull String providerName) {
mProviderName = providerName;
}
@@ -131,7 +139,7 @@
}
/** Sets the icon for the complication provider. */
- public void setProviderIcon(@Nullable Icon providerIcon) {
+ public void setProviderIcon(@NonNull Icon providerIcon) {
mProviderIcon = providerIcon;
}
@@ -145,6 +153,16 @@
mComplicationType = complicationType;
}
+ /** Returns the provider's {@link ComponentName}. */
+ public @Nullable ComponentName getProviderComponentName() {
+ return mProviderComponentName;
+ }
+
+ /** Sets the provider's {@link ComponentName}. */
+ public void setProviderComponentName(@NonNull ComponentName providerComponentName) {
+ mProviderComponentName = providerComponentName;
+ }
+
@Override
public int describeContents() {
return 0;
@@ -164,6 +182,8 @@
+ mProviderIcon
+ ", complicationType="
+ mComplicationType
+ + ", providerComponentName="
+ + mProviderComponentName
+ '}';
}
}
diff --git a/wear/wear-complications-data/src/main/java/androidx/wear/complications/ProviderInfoRetriever.java b/wear/wear-complications-data/src/main/java/androidx/wear/complications/ProviderInfoRetriever.java
index 18fbc08..6234498 100644
--- a/wear/wear-complications-data/src/main/java/androidx/wear/complications/ProviderInfoRetriever.java
+++ b/wear/wear-complications-data/src/main/java/androidx/wear/complications/ProviderInfoRetriever.java
@@ -21,14 +21,22 @@
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
+import android.os.Build;
import android.os.IBinder;
import android.os.RemoteException;
+import android.support.wearable.complications.ComplicationData;
import android.support.wearable.complications.ComplicationProviderInfo;
+import android.support.wearable.complications.IPreviewComplicationDataCallback;
import android.support.wearable.complications.IProviderInfoService;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
+import androidx.annotation.RequiresApi;
+import androidx.annotation.RestrictTo;
+import androidx.annotation.VisibleForTesting;
import androidx.concurrent.futures.ResolvableFuture;
+import androidx.wear.complications.data.ComplicationType;
+import androidx.wear.complications.data.DataKt;
import com.google.common.util.concurrent.ListenableFuture;
@@ -119,6 +127,16 @@
}
/**
+ * @hide
+ */
+ @VisibleForTesting
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ public ProviderInfoRetriever(@NonNull IProviderInfoService service) {
+ mContext = null;
+ mServiceFuture.set(service);
+ }
+
+ /**
* Requests {@link ComplicationProviderInfo} for the specified complication ids on the specified
* watch face. When the info is received, the listener will receive a callback for each id.
* These callbacks will occur on the main thread.
@@ -172,6 +190,65 @@
}
/**
+ * Requests preview {@link ComplicationData} for a provider {@link ComponentName} and
+ * {@link ComplicationType}.
+ *
+ * @param providerComponent The {@link ComponentName} of the complication provider from which
+ * preview data is requested.
+ * @param complicationType The requested {@link ComplicationType} for the preview data.
+ * @return A {@link ListenableFuture} for the preview {@link ComplicationData}. This may resolve
+ * to `null` if the provider component doesn't exist, or if it doesn't support complicationType,
+ * or if the remote service doesn't support this API.
+ */
+ @NonNull
+ @RequiresApi(Build.VERSION_CODES.R)
+ public ListenableFuture<androidx.wear.complications.data.ComplicationData>
+ requestPreviewComplicationData(
+ @NonNull ComponentName providerComponent,
+ @NonNull ComplicationType complicationType) {
+ final ResolvableFuture<androidx.wear.complications.data.ComplicationData> mResultFuture =
+ ResolvableFuture.create();
+ mServiceFuture.addListener(
+ () -> {
+ try {
+ if (mServiceFuture.isCancelled()) {
+ mResultFuture.set(null);
+ return;
+ }
+ IProviderInfoService service = mServiceFuture.get();
+ if (service.getApiVersion() < 1) {
+ mResultFuture.set(null);
+ return;
+ }
+ if (!service.requestPreviewComplicationData(
+ providerComponent,
+ complicationType.asWireComplicationType(),
+ new IPreviewComplicationDataCallback.Stub() {
+ @Override
+ public void updateComplicationData(ComplicationData data) {
+ if (data == null) {
+ mResultFuture.set(null);
+ } else {
+ mResultFuture.set(DataKt.asApiComplicationData(data));
+ }
+ }
+ })) {
+ mResultFuture.set(null);
+ }
+ } catch (RemoteException e) {
+ mResultFuture.setException(e);
+ } catch (InterruptedException e) {
+ mResultFuture.setException(e);
+ } catch (ExecutionException e) {
+ mResultFuture.setException(e);
+ }
+ },
+ runnable -> runnable.run()
+ );
+ return mResultFuture;
+ }
+
+ /**
* Releases the connection to the complication system used by this class. This must
* be called when the retriever is no longer needed.
*
diff --git a/wear/wear-complications-data/src/main/res/values-fr-rCA/complication_strings.xml b/wear/wear-complications-data/src/main/res/values-fr-rCA/complication_strings.xml
index 63e28549..7b514b3 100644
--- a/wear/wear-complications-data/src/main/res/values-fr-rCA/complication_strings.xml
+++ b/wear/wear-complications-data/src/main/res/values-fr-rCA/complication_strings.xml
@@ -3,34 +3,28 @@
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<plurals name="time_difference_short_days" formatted="false" msgid="8500262093840795448">
<item quantity="one"><xliff:g id="NUMBER_OF_DAYS_1">%d</xliff:g> j</item>
- <item quantity="many"><xliff:g id="NUMBER_OF_DAYS_1">%d</xliff:g>d</item>
<item quantity="other"><xliff:g id="NUMBER_OF_DAYS_1">%d</xliff:g> j</item>
</plurals>
<plurals name="time_difference_short_hours" formatted="false" msgid="3258361256003469346">
<item quantity="one"><xliff:g id="NUMBER_OF_HOURS_1">%d</xliff:g> h</item>
- <item quantity="many"><xliff:g id="NUMBER_OF_HOURS_1">%d</xliff:g>h</item>
<item quantity="other"><xliff:g id="NUMBER_OF_HOURS_1">%d</xliff:g> h</item>
</plurals>
<plurals name="time_difference_short_minutes" formatted="false" msgid="3812930575997556650">
<item quantity="one"><xliff:g id="NUMBER_OF_MINUTES_1">%d</xliff:g> m</item>
- <item quantity="many"><xliff:g id="NUMBER_OF_MINUTES_1">%d</xliff:g>m</item>
<item quantity="other"><xliff:g id="NUMBER_OF_MINUTES_1">%d</xliff:g> m</item>
</plurals>
<string name="time_difference_short_days_and_hours" msgid="1756744715731328189">"<xliff:g id="SHORT_DAYS">%1$s</xliff:g> <xliff:g id="SHORT_HOURS">%2$s</xliff:g>"</string>
<string name="time_difference_short_hours_and_minutes" msgid="7429995187969936129">"<xliff:g id="SHORT_HOURS">%1$s</xliff:g> <xliff:g id="SHORT_MINUTES">%2$s</xliff:g>"</string>
<plurals name="time_difference_words_days" formatted="false" msgid="345557497041553025">
<item quantity="one"><xliff:g id="NUMBER_OF_DAYS_1">%d</xliff:g> jour</item>
- <item quantity="many"><xliff:g id="NUMBER_OF_DAYS_1">%d</xliff:g> days</item>
<item quantity="other"><xliff:g id="NUMBER_OF_DAYS_1">%d</xliff:g> jours</item>
</plurals>
<plurals name="time_difference_words_hours" formatted="false" msgid="2990178439049007198">
<item quantity="one"><xliff:g id="NUMBER_OF_HOURS_1">%d</xliff:g> heure</item>
- <item quantity="many"><xliff:g id="NUMBER_OF_HOURS_1">%d</xliff:g> hours</item>
<item quantity="other"><xliff:g id="NUMBER_OF_HOURS_1">%d</xliff:g> heures</item>
</plurals>
<plurals name="time_difference_words_minutes" formatted="false" msgid="9081188175463984403">
<item quantity="one"><xliff:g id="NUMBER_OF_MINUTES_1">%d</xliff:g> min</item>
- <item quantity="many"><xliff:g id="NUMBER_OF_MINUTES_1">%d</xliff:g> mins</item>
<item quantity="other"><xliff:g id="NUMBER_OF_MINUTES_1">%d</xliff:g> min</item>
</plurals>
<string name="time_difference_now" msgid="1141173224250945412">"Maint."</string>
diff --git a/wear/wear-complications-data/src/main/res/values-fr/complication_strings.xml b/wear/wear-complications-data/src/main/res/values-fr/complication_strings.xml
index a9e60e1..391c42e 100644
--- a/wear/wear-complications-data/src/main/res/values-fr/complication_strings.xml
+++ b/wear/wear-complications-data/src/main/res/values-fr/complication_strings.xml
@@ -3,34 +3,28 @@
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<plurals name="time_difference_short_days" formatted="false" msgid="8500262093840795448">
<item quantity="one"><xliff:g id="NUMBER_OF_DAYS_1">%d</xliff:g> j</item>
- <item quantity="many"><xliff:g id="NUMBER_OF_DAYS_1">%d</xliff:g>d</item>
<item quantity="other"><xliff:g id="NUMBER_OF_DAYS_1">%d</xliff:g> j</item>
</plurals>
<plurals name="time_difference_short_hours" formatted="false" msgid="3258361256003469346">
<item quantity="one"><xliff:g id="NUMBER_OF_HOURS_1">%d</xliff:g> h</item>
- <item quantity="many"><xliff:g id="NUMBER_OF_HOURS_1">%d</xliff:g>h</item>
<item quantity="other"><xliff:g id="NUMBER_OF_HOURS_1">%d</xliff:g> h</item>
</plurals>
<plurals name="time_difference_short_minutes" formatted="false" msgid="3812930575997556650">
<item quantity="one"><xliff:g id="NUMBER_OF_MINUTES_1">%d</xliff:g> m</item>
- <item quantity="many"><xliff:g id="NUMBER_OF_MINUTES_1">%d</xliff:g>m</item>
<item quantity="other"><xliff:g id="NUMBER_OF_MINUTES_1">%d</xliff:g> m</item>
</plurals>
<string name="time_difference_short_days_and_hours" msgid="1756744715731328189">"<xliff:g id="SHORT_DAYS">%1$s</xliff:g> <xliff:g id="SHORT_HOURS">%2$s</xliff:g>"</string>
<string name="time_difference_short_hours_and_minutes" msgid="7429995187969936129">"<xliff:g id="SHORT_HOURS">%1$s</xliff:g> <xliff:g id="SHORT_MINUTES">%2$s</xliff:g>"</string>
<plurals name="time_difference_words_days" formatted="false" msgid="345557497041553025">
<item quantity="one"><xliff:g id="NUMBER_OF_DAYS_1">%d</xliff:g> jour</item>
- <item quantity="many"><xliff:g id="NUMBER_OF_DAYS_1">%d</xliff:g> days</item>
<item quantity="other"><xliff:g id="NUMBER_OF_DAYS_1">%d</xliff:g> jours</item>
</plurals>
<plurals name="time_difference_words_hours" formatted="false" msgid="2990178439049007198">
<item quantity="one"><xliff:g id="NUMBER_OF_HOURS_1">%d</xliff:g> heure</item>
- <item quantity="many"><xliff:g id="NUMBER_OF_HOURS_1">%d</xliff:g> hours</item>
<item quantity="other"><xliff:g id="NUMBER_OF_HOURS_1">%d</xliff:g> heures</item>
</plurals>
<plurals name="time_difference_words_minutes" formatted="false" msgid="9081188175463984403">
<item quantity="one"><xliff:g id="NUMBER_OF_MINUTES_1">%d</xliff:g> min</item>
- <item quantity="many"><xliff:g id="NUMBER_OF_MINUTES_1">%d</xliff:g> mins</item>
<item quantity="other"><xliff:g id="NUMBER_OF_MINUTES_1">%d</xliff:g> min</item>
</plurals>
<string name="time_difference_now" msgid="1141173224250945412">"Maint."</string>
diff --git a/wear/wear-complications-data/src/test/java/androidx/wear/complications/ProviderInfoRetrieverTest.java b/wear/wear-complications-data/src/test/java/androidx/wear/complications/ProviderInfoRetrieverTest.java
new file mode 100644
index 0000000..07ec788
--- /dev/null
+++ b/wear/wear-complications-data/src/test/java/androidx/wear/complications/ProviderInfoRetrieverTest.java
@@ -0,0 +1,112 @@
+/*
+ * Copyright 2021 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.wear.complications;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.eq;
+import static org.mockito.Mockito.when;
+
+import android.content.ComponentName;
+import android.support.wearable.complications.IPreviewComplicationDataCallback;
+import android.support.wearable.complications.IProviderInfoService;
+
+import androidx.test.core.app.ApplicationProvider;
+import androidx.wear.complications.data.ComplicationData;
+import androidx.wear.complications.data.ComplicationText;
+import androidx.wear.complications.data.ComplicationType;
+import androidx.wear.complications.data.LongTextComplicationData;
+
+import com.google.common.util.concurrent.ListenableFuture;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Mockito;
+
+@RunWith(SharedRobolectricTestRunner.class)
+public class ProviderInfoRetrieverTest {
+ private IProviderInfoService mMockService = Mockito.mock(IProviderInfoService.class);
+ private ProviderInfoRetriever mProviderInfoRetriever = new ProviderInfoRetriever(mMockService);
+
+ @Test
+ public void requestPreviewComplicationData() throws Exception {
+ final ComponentName component = new ComponentName("provider.package", "provider.class");
+ final ComplicationType type = ComplicationType.LONG_TEXT;
+ when(mMockService.getApiVersion()).thenReturn(1);
+ final ArgumentCaptor<IPreviewComplicationDataCallback> callbackCaptor =
+ ArgumentCaptor.forClass(IPreviewComplicationDataCallback.class);
+ when(mMockService.requestPreviewComplicationData(
+ eq(component), eq(type.asWireComplicationType()), callbackCaptor.capture()))
+ .thenReturn(true);
+ ListenableFuture<ComplicationData> future =
+ mProviderInfoRetriever.requestPreviewComplicationData(component, type);
+
+ ComplicationData testData =
+ new LongTextComplicationData.Builder(ComplicationText.plain("Test Text")).build();
+ callbackCaptor.getValue().updateComplicationData(testData.asWireComplicationData());
+ assertThat(future.get().getType()).isEqualTo(type);
+ assertThat(((LongTextComplicationData) testData).getText().getTextAt(
+ ApplicationProvider.getApplicationContext().getResources(), 0))
+ .isEqualTo("Test Text");
+ }
+
+ @Test
+ public void requestPreviewComplicationDataProviderReturnsNull() throws Exception {
+ final ComponentName component = new ComponentName("provider.package", "provider.class");
+ final ComplicationType type = ComplicationType.LONG_TEXT;
+ when(mMockService.getApiVersion()).thenReturn(1);
+ final ArgumentCaptor<IPreviewComplicationDataCallback> callbackCaptor =
+ ArgumentCaptor.forClass(IPreviewComplicationDataCallback.class);
+ when(mMockService.requestPreviewComplicationData(
+ eq(component), eq(type.asWireComplicationType()), callbackCaptor.capture()))
+ .thenReturn(true);
+ ListenableFuture<ComplicationData> future =
+ mProviderInfoRetriever.requestPreviewComplicationData(component, type);
+
+ callbackCaptor.getValue().updateComplicationData(null);
+ assertThat(future.get()).isNull();
+ }
+
+ @Test
+ public void requestPreviewComplicationDataApiNotSupported() throws Exception {
+ final ComponentName component = new ComponentName("provider.package", "provider.class");
+ final ComplicationType type = ComplicationType.LONG_TEXT;
+ when(mMockService.getApiVersion()).thenReturn(0);
+ when(mMockService.requestPreviewComplicationData(
+ eq(component), eq(type.asWireComplicationType()), Mockito.any()))
+ .thenReturn(true);
+ ListenableFuture<ComplicationData> future =
+ mProviderInfoRetriever.requestPreviewComplicationData(component, type);
+
+ assertThat(future.get()).isNull();
+ }
+
+ @Test
+ public void requestPreviewComplicationDataApiReturnsFalse() throws Exception {
+ final ComponentName component = new ComponentName("provider.package", "provider.class");
+ final ComplicationType type = ComplicationType.LONG_TEXT;
+ when(mMockService.getApiVersion()).thenReturn(1);
+ when(mMockService.requestPreviewComplicationData(
+ eq(component), eq(type.asWireComplicationType()), Mockito.any()))
+ .thenReturn(false);
+ ListenableFuture<ComplicationData> future =
+ mProviderInfoRetriever.requestPreviewComplicationData(component, type);
+
+ assertThat(future.get()).isNull();
+ }
+}
diff --git a/wear/wear-complications-provider/src/main/java/androidx/wear/complications/ComplicationTextUtils.java b/wear/wear-complications-provider/src/main/java/androidx/wear/complications/ComplicationTextUtils.java
deleted file mode 100644
index 8b44d36..0000000
--- a/wear/wear-complications-provider/src/main/java/androidx/wear/complications/ComplicationTextUtils.java
+++ /dev/null
@@ -1,240 +0,0 @@
-/*
- * 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.wear.complications;
-
-import static java.util.concurrent.TimeUnit.DAYS;
-import static java.util.concurrent.TimeUnit.HOURS;
-import static java.util.concurrent.TimeUnit.MINUTES;
-import static java.util.concurrent.TimeUnit.SECONDS;
-
-import android.text.format.DateFormat;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.RestrictTo;
-
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.Locale;
-
-/**
- * Utilities to obtain the best date or time format for a given locale.
- *
- * @hide
- */
-@RestrictTo(RestrictTo.Scope.LIBRARY)
-public class ComplicationTextUtils {
-
- private ComplicationTextUtils() {}
-
- private static final int TEST_STEPS = 13;
- private static final int SHORT_TEXT_MAX_LENGTH = 7;
-
- /**
- * The amount of time to advance at each test step if a given symbol appears in a format
- * skeleton.
- */
- private static final TimeUnitMapping[] TIME_UNIT_MAPPINGS = {
- new TimeUnitMapping(SECONDS.toMillis(47), "S", "s"),
- new TimeUnitMapping(MINUTES.toMillis(47), "m"),
- new TimeUnitMapping(HOURS.toMillis(5), "H", "K", "h", "k", "j", "J"),
- new TimeUnitMapping(DAYS.toMillis(1), "D", "E", "F", "c", "d", "g"),
- new TimeUnitMapping(DAYS.toMillis(27), "M", "L")
- };
-
- /** Formats to use instead of the return value of getBestDateTimePattern. */
- private static final FormatMapping[] FORMAT_MAPPINGS = {
- // In Finnish and German, date should be followed by "." but the best format does not
- // include this when date is on its own.
- new FormatMapping("fi", "d", "d."),
- new FormatMapping("fi", "dd", "dd."),
- new FormatMapping("de", "d", "d."),
- new FormatMapping("de", "dd", "dd."),
-
- // German MMM gives LLL as best format, which returns e.g. "Jan", whereas MMM returns "Jan."
- // Same for Norwegian.
- new FormatMapping("de", "MMM", "MMM"),
- new FormatMapping("no", "MMM", "MMM"),
- new FormatMapping("nb", "MMM", "MMM"),
-
- // Norwegian time formats should use a dot instead of a colon
- new FormatMapping("no", "HHmm", "HH.mm"),
- new FormatMapping("no", "hmm", "h.mm a"),
- new FormatMapping("nb", "HHmm", "HH.mm"),
- new FormatMapping("nb", "hmm", "h.mm a"),
-
- // Japanese day of week should use the full form instead of the abbreviated one as that is
- // three characters anyway.
- new FormatMapping("ja", "EEE", "EEEE"),
- };
-
- /**
- * Returns a pattern suitable for use with {@link SimpleDateFormat} to represent a time value in
- * the given locale. The resulting text should fit within a short text field for any input time
- * value. This may be achieved by showing a 12h time without an am/pm indicator in languages in
- * which that indicator would be too long.
- */
- @NonNull
- public static String shortTextTimeFormat(@NonNull Locale locale, boolean use24Hour) {
- if (use24Hour) {
- return bestShortTextDateFormat(locale, new String[] {"HHmm"}, "HH:mm");
- }
-
- // For 12h clock, the dayPeriod (am/pm) part is often problematic. Try bestDateTimePattern
- // first...
- long timeStep = MINUTES.toMillis(97);
- String pattern = DateFormat.getBestDateTimePattern(locale, "hmm");
- if (isShortEnough(locale, pattern, timeStep)) {
- return pattern;
- }
-
- // Too long - try removing the space before am/pm, if there is one.
- String patternWithoutSpaceBeforeAmPm = pattern.replace(" a", "a");
- if (!pattern.equals(patternWithoutSpaceBeforeAmPm)
- && isShortEnough(locale, patternWithoutSpaceBeforeAmPm, timeStep)) {
- return patternWithoutSpaceBeforeAmPm;
- }
-
- // Still too long - try stripping the am/pm part entirely.
- String patternWithoutAmPm = pattern.replace("a", "").trim();
- if (!pattern.equals(patternWithoutAmPm)
- && isShortEnough(locale, patternWithoutAmPm, timeStep)) {
- return patternWithoutAmPm;
- }
-
- // Still too long. Fall back.
- return "h:mm";
- }
-
- /**
- * Returns a pattern suitable for use with {@link SimpleDateFormat} to represent a day and
- * month, in the given locale, e.g. "25 Jan" in en-GB. The resulting text should fit within a
- * short text field for any input time value.
- */
- @NonNull
- public static String shortTextDayMonthFormat(@NonNull Locale locale) {
- return bestShortTextDateFormat(locale, new String[] {"MMMd", "MMd", "Md"}, "d/MM");
- }
-
- /**
- * Returns a pattern suitable for use with {@link SimpleDateFormat} to represent a month, in the
- * given locale, e.g. "Jan" in en-GB. The resulting text should fit within a short text field
- * for any input time value.
- */
- @NonNull
- public static String shortTextMonthFormat(@NonNull Locale locale) {
- return bestShortTextDateFormat(locale, new String[] {"MMM", "MM", "M"}, "MM");
- }
-
- /**
- * Returns a pattern suitable for use with {@link SimpleDateFormat} to represent the day part of
- * a given date, in the given locale, e.g. "25" in en-GB, or "25." in de. The resulting text
- * should fit within a short text field for any input time value.
- */
- @NonNull
- public static String shortTextDayOfMonthFormat(@NonNull Locale locale) {
- return bestShortTextDateFormat(locale, new String[] {"dd", "d"}, "dd");
- }
-
- /**
- * Returns a pattern suitable for use with {@link SimpleDateFormat} to represent the day of the
- * week, in the given locale, e.g. "Thu" in en-GB. The resulting text should fit within a short
- * text field for any input time value.
- */
- @NonNull
- public static String shortTextDayOfWeekFormat(@NonNull Locale locale) {
- return bestShortTextDateFormat(locale, new String[] {"EEE", "EEEEEE", "EEEEE"}, "EEEEE");
- }
-
- /**
- * Returns a date format pattern that will produce results that fit into a short text field when
- * used with the given locale. The skeletons will be passed to {@link
- * DateFormat#getBestDateTimePattern}, and the resulting pattern will be tested for a number of
- * times to see if the text will fit. The first result that fits for all the test times will be
- * returned. If none of the skeletons produces a suitable result, the fallback will be returned
- * instead.
- */
- @NonNull
- private static String bestShortTextDateFormat(
- @NonNull Locale locale, @NonNull String[] skeletons, @NonNull String fallback) {
- for (String skeleton : skeletons) {
- String pattern = null;
- for (FormatMapping mapping : FORMAT_MAPPINGS) {
- if (locale.getLanguage().equals(mapping.mLanguage)
- && skeleton.equals(mapping.mSkeleton)) {
- pattern = mapping.mPattern;
- break;
- }
- }
- if (pattern == null) {
- pattern = DateFormat.getBestDateTimePattern(locale, skeleton);
- }
- if (isShortEnough(locale, pattern, timeStepForSkeleton(skeleton))) {
- return pattern;
- }
- }
- return fallback;
- }
-
- private static boolean isShortEnough(
- @NonNull Locale locale, @NonNull String pattern, long timeStep) {
- SimpleDateFormat format = new SimpleDateFormat(pattern, locale);
- long testTime = System.currentTimeMillis();
-
- for (int i = 0; i < TEST_STEPS; i++) {
- if (format.format(new Date(testTime)).length() > SHORT_TEXT_MAX_LENGTH) {
- return false;
- }
- testTime += timeStep;
- }
- return true;
- }
-
- private static long timeStepForSkeleton(@NonNull String skeleton) {
- long timeStep = 0;
- for (TimeUnitMapping timeMapping : TIME_UNIT_MAPPINGS) {
- for (String symbol : timeMapping.mStrings) {
- if (skeleton.contains(symbol)) {
- timeStep += timeMapping.mTimeUnit;
- break;
- }
- }
- }
- return timeStep;
- }
-
- private static class FormatMapping {
- final String mLanguage;
- final String mSkeleton;
- final String mPattern;
-
- FormatMapping(String language, String skeleton, String pattern) {
- this.mLanguage = language;
- this.mSkeleton = skeleton;
- this.mPattern = pattern;
- }
- }
-
- private static class TimeUnitMapping {
- final long mTimeUnit;
- final String[] mStrings;
-
- TimeUnitMapping(long timeUnit, String... symbols) {
- this.mTimeUnit = timeUnit;
- this.mStrings = symbols;
- }
- }
-}
diff --git a/wear/wear-complications-provider/src/test/java/androidx/wear/complications/ComplicationTextUtilsTest.java b/wear/wear-complications-provider/src/test/java/androidx/wear/complications/ComplicationTextUtilsTest.java
deleted file mode 100644
index e547f3c..0000000
--- a/wear/wear-complications-provider/src/test/java/androidx/wear/complications/ComplicationTextUtilsTest.java
+++ /dev/null
@@ -1,233 +0,0 @@
-/*
- * 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.wear.complications;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import android.text.format.DateFormat;
-
-import androidx.test.core.app.ApplicationProvider;
-import androidx.wear.complications.data.ComplicationText;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.annotation.Config;
-import org.robolectric.annotation.Implementation;
-import org.robolectric.annotation.Implements;
-import org.robolectric.annotation.internal.DoNotInstrument;
-
-import java.util.Locale;
-
-@RunWith(RobolectricTestRunner.class)
-@Config(shadows = ComplicationTextUtilsTest.ShadowDateFormat.class)
-@DoNotInstrument
-public class ComplicationTextUtilsTest {
-
- @Test
- public void time24HourUsesCustomFormatIfNotTooLong() {
- // In ShadowDateFormat, best time format for Norwegian is set to return with a dot instead
- // of
- // a colon (which matches the actual return value for that language).
- assertThat(ComplicationTextUtils.shortTextTimeFormat(new Locale("no"), true))
- .isEqualTo("HH.mm");
- }
-
- @Test
- public void time24HourUsesStandardExpectedFormatIfNotTooLong() {
- assertThat(ComplicationTextUtils.shortTextTimeFormat(new Locale("en", "GB"), true))
- .isEqualTo("HH:mm");
- }
-
- @Test
- public void time12HourRemovesSpaceBeforeAmPmIfNecessary() {
- // Default is "h:mm a" but that can be 8 characters
- assertThat(ComplicationTextUtils.shortTextTimeFormat(new Locale("en", "US"), false))
- .isEqualTo("h:mma");
- }
-
- @Test
- public void time12HourStripsAmPmIfTooLong() {
- // Czech am/pm is "odp./dop." which are too long to fit after the time.
- assertThat(ComplicationTextUtils.shortTextTimeFormat(new Locale("cs"), false))
- .isEqualTo("h:mm");
- }
-
- @Test
- public void standardDayMonthFormat() {
- assertThat(ComplicationTextUtils.shortTextDayMonthFormat(new Locale("en", "GB")))
- .isEqualTo("d MMM");
- }
-
- @Test
- public void usDayMonthFormat() {
- assertThat(ComplicationTextUtils.shortTextDayMonthFormat(new Locale("en", "US")))
- .isEqualTo("MMM d");
- }
-
- @Test
- public void tooLongTextDayMonthFormat() {
- // In ShadowDateFormat, best date format for Brazilian Portuguese is set to return with
- // extra
- // characters that mean it cannot fit within the short text limit. This matches the actual
- // return value for that language.
- assertThat(ComplicationTextUtils.shortTextDayMonthFormat(new Locale("pt", "BR")))
- .isEqualTo("d/MM");
- }
-
- @Test
- public void vietnameseTextDayMonthFormat() {
- // In Vietnamese, an MMM month can be e.g. "thg 10", which means "d MMM" is too long even
- // though
- // the same format pattern is acceptable in other languages.
- assertThat(ComplicationTextUtils.shortTextDayMonthFormat(new Locale("vi")))
- .isEqualTo("d/MM");
- }
-
- @Test
- public void monthFallback() {
- // In ShadowDateFormat, best date format for this language returns a too-long pattern for
- // any
- // input. Result should be the specified fallback.
- assertThat(ComplicationTextUtils.shortTextMonthFormat(new Locale("mfe"))).isEqualTo("MM");
- }
-
- @Test
- public void standardShortMonthFormat() {
- assertThat(ComplicationTextUtils.shortTextMonthFormat(new Locale("en", "GB")))
- .isEqualTo("LLL");
- }
-
- @Test
- public void germanShortMonthFormat() {
- // In German, the desired output is e.g. "Jan." instead of "Jan". To get this result, the
- // pattern "MMM" should be used instead of "LLL".
- assertThat(ComplicationTextUtils.shortTextMonthFormat(new Locale("de"))).isEqualTo("MMM");
- }
-
- @Test
- public void standardDayOfMonthFormat() {
- assertThat(ComplicationTextUtils.shortTextDayOfMonthFormat(new Locale("en", "GB")))
- .isEqualTo("dd");
- }
-
- @Test
- public void finnishDayOfMonthFormat() {
- assertThat(ComplicationTextUtils.shortTextDayOfMonthFormat(new Locale("fi")))
- .isEqualTo("dd.");
- }
-
- @Test
- public void germanDayOfMonthFormat() {
- assertThat(ComplicationTextUtils.shortTextDayOfMonthFormat(new Locale("de")))
- .isEqualTo("dd.");
- }
-
- @Test
- public void standardDayOfWeekFormat() {
- assertThat(ComplicationTextUtils.shortTextDayOfWeekFormat(new Locale("en", "GB")))
- .isEqualTo("EEE");
- }
-
- @Test
- public void fallbackDayOfWeekFormat() {
- assertThat(ComplicationTextUtils.shortTextDayOfWeekFormat(new Locale("mfe")))
- .isEqualTo("EEEEE");
- }
-
- @Test
- public void japaneseDayOfWeekFormat() {
- assertThat(ComplicationTextUtils.shortTextDayOfWeekFormat(new Locale("ja", "JP")))
- .isEqualTo("EEEE");
- }
-
- @Test
- public void japaneseDayOfWeekString() {
- long testTimeMillis = 1610093242000000L; // Fri, 08 Jan 2021 08:07:22 +0000
- Locale locale = new Locale("ja", "JP");
-
- Locale defaultLocale = Locale.getDefault();
- try {
- Locale.setDefault(locale);
- String format = ComplicationTextUtils.shortTextDayOfWeekFormat(locale);
- assertThat(
- ComplicationText.timeFormatBuilder(format).build()
- .getTextAt(
- ApplicationProvider.getApplicationContext().getResources(),
- testTimeMillis))
- .isEqualTo("金曜日");
- } finally {
- Locale.setDefault(defaultLocale);
- }
- }
-
- /** Robolectric shadow for Android DateFormat. */
- @Implements(value = DateFormat.class)
- public static class ShadowDateFormat {
- @Implementation
- public static String getBestDateTimePattern(Locale locale, String skeleton) {
- // Special case returning too long pattern for any skeleton, to test fallback.
- if (locale.getLanguage().equals("mfe")) {
- return "'too long'MMMd";
- }
-
- switch (skeleton) {
- case "HHmm":
- switch (locale.getLanguage()) {
- case "no":
- return "HH.mm";
- default:
- return "HH:mm";
- }
- case "hhmm":
- switch (locale.getLanguage()) {
- case "no":
- return "h.mm a";
- default:
- return "hh:mm a";
- }
- case "hmm":
- switch (locale.getLanguage()) {
- case "no":
- return "h.mm a";
- default:
- return "h:mm a";
- }
- case "MMMd":
- switch (locale.getCountry()) {
- case "BR":
- return "d 'de' MMM";
- case "US":
- return "MMM d";
- default:
- return "d MMM";
- }
- case "MMd":
- switch (locale.getCountry()) {
- case "US":
- return "MM/d";
- default:
- return "d/MM";
- }
- case "MMM":
- return "LLL";
- default:
- return skeleton;
- }
- }
- }
-}
diff --git a/wear/wear-tiles/api/current.txt b/wear/wear-tiles/api/current.txt
deleted file mode 100644
index 85c4a7f..0000000
--- a/wear/wear-tiles/api/current.txt
+++ /dev/null
@@ -1,615 +0,0 @@
-// Signature format: 4.0
-package androidx.wear.tiles {
-
- public class SysUiTileUpdateRequester implements androidx.wear.tiles.TileUpdateRequester {
- ctor public SysUiTileUpdateRequester(android.content.Context);
- method public void requestUpdate(Class<? extends android.app.Service>);
- field public static final String ACTION_BIND_UPDATE_REQUESTER = "androidx.wear.tiles.action.BIND_UPDATE_REQUESTER";
- }
-
- public abstract class TileProviderService extends android.app.Service {
- ctor public TileProviderService();
- method public static androidx.wear.tiles.TileUpdateRequester getUpdater(android.content.Context);
- method public android.os.IBinder? onBind(android.content.Intent);
- method @MainThread protected abstract com.google.common.util.concurrent.ListenableFuture<androidx.wear.tiles.builders.ResourceBuilders.Resources!> onResourcesRequest(androidx.wear.tiles.readers.RequestReaders.ResourcesRequest);
- method @MainThread protected abstract com.google.common.util.concurrent.ListenableFuture<androidx.wear.tiles.builders.TileBuilders.Tile!> onTileRequest(androidx.wear.tiles.readers.RequestReaders.TileRequest);
- field public static final String ACTION_BIND_TILE_PROVIDER = "androidx.wear.tiles.action.BIND_TILE_PROVIDER";
- field public static final String EXTRA_CLICKABLE_ID = "androidx.wear.tiles.extra.CLICKABLE_ID";
- field public static final String METADATA_PREVIEW_KEY = "androidx.wear.tiles.PREVIEW";
- }
-
- public interface TileUpdateRequester {
- method public void requestUpdate(Class<? extends android.app.Service>);
- }
-
-}
-
-package androidx.wear.tiles.builders {
-
- public final class ActionBuilders {
- }
-
- public static interface ActionBuilders.Action {
- }
-
- public static interface ActionBuilders.Action.Builder {
- method public androidx.wear.tiles.builders.ActionBuilders.Action build();
- }
-
- public static final class ActionBuilders.AndroidActivity {
- method public static androidx.wear.tiles.builders.ActionBuilders.AndroidActivity.Builder builder();
- }
-
- public static final class ActionBuilders.AndroidActivity.Builder {
- method public androidx.wear.tiles.builders.ActionBuilders.AndroidActivity build();
- method public androidx.wear.tiles.builders.ActionBuilders.AndroidActivity.Builder setClassName(String);
- method public androidx.wear.tiles.builders.ActionBuilders.AndroidActivity.Builder setPackageName(String);
- }
-
- public static final class ActionBuilders.LaunchAction implements androidx.wear.tiles.builders.ActionBuilders.Action {
- method public static androidx.wear.tiles.builders.ActionBuilders.LaunchAction.Builder builder();
- }
-
- public static final class ActionBuilders.LaunchAction.Builder implements androidx.wear.tiles.builders.ActionBuilders.Action.Builder {
- method public androidx.wear.tiles.builders.ActionBuilders.LaunchAction build();
- method public androidx.wear.tiles.builders.ActionBuilders.LaunchAction.Builder setAndroidActivity(androidx.wear.tiles.builders.ActionBuilders.AndroidActivity);
- method public androidx.wear.tiles.builders.ActionBuilders.LaunchAction.Builder setAndroidActivity(androidx.wear.tiles.builders.ActionBuilders.AndroidActivity.Builder);
- }
-
- public static final class ActionBuilders.LoadAction implements androidx.wear.tiles.builders.ActionBuilders.Action {
- method public static androidx.wear.tiles.builders.ActionBuilders.LoadAction.Builder builder();
- }
-
- public static final class ActionBuilders.LoadAction.Builder implements androidx.wear.tiles.builders.ActionBuilders.Action.Builder {
- method public androidx.wear.tiles.builders.ActionBuilders.LoadAction build();
- }
-
- public final class ColorBuilders {
- method public static androidx.wear.tiles.builders.ColorBuilders.ColorProp argb(@ColorInt int);
- }
-
- public static final class ColorBuilders.ColorProp {
- method public static androidx.wear.tiles.builders.ColorBuilders.ColorProp.Builder builder();
- }
-
- public static final class ColorBuilders.ColorProp.Builder {
- method public androidx.wear.tiles.builders.ColorBuilders.ColorProp build();
- method public androidx.wear.tiles.builders.ColorBuilders.ColorProp.Builder setArgb(@ColorInt int);
- }
-
- public final class DimensionBuilders {
- method public static androidx.wear.tiles.builders.DimensionBuilders.DegreesProp degrees(float);
- method public static androidx.wear.tiles.builders.DimensionBuilders.DpProp dp(@Dimension(unit=androidx.annotation.Dimension.DP) float);
- method public static androidx.wear.tiles.builders.DimensionBuilders.ExpandedDimensionProp expand();
- method public static androidx.wear.tiles.builders.DimensionBuilders.SpProp sp(@Dimension(unit=androidx.annotation.Dimension.SP) int);
- method public static androidx.wear.tiles.builders.DimensionBuilders.WrappedDimensionProp wrap();
- }
-
- public static interface DimensionBuilders.ContainerDimension {
- }
-
- public static interface DimensionBuilders.ContainerDimension.Builder {
- method public androidx.wear.tiles.builders.DimensionBuilders.ContainerDimension build();
- }
-
- public static final class DimensionBuilders.DegreesProp implements androidx.wear.tiles.builders.DimensionBuilders.LinearOrAngularDimension {
- method public static androidx.wear.tiles.builders.DimensionBuilders.DegreesProp.Builder builder();
- }
-
- public static final class DimensionBuilders.DegreesProp.Builder implements androidx.wear.tiles.builders.DimensionBuilders.LinearOrAngularDimension.Builder {
- method public androidx.wear.tiles.builders.DimensionBuilders.DegreesProp build();
- method public androidx.wear.tiles.builders.DimensionBuilders.DegreesProp.Builder setValue(float);
- }
-
- public static final class DimensionBuilders.DpProp implements androidx.wear.tiles.builders.DimensionBuilders.ContainerDimension androidx.wear.tiles.builders.DimensionBuilders.ImageDimension androidx.wear.tiles.builders.DimensionBuilders.LinearOrAngularDimension {
- method public static androidx.wear.tiles.builders.DimensionBuilders.DpProp.Builder builder();
- }
-
- public static final class DimensionBuilders.DpProp.Builder implements androidx.wear.tiles.builders.DimensionBuilders.ContainerDimension.Builder androidx.wear.tiles.builders.DimensionBuilders.ImageDimension.Builder androidx.wear.tiles.builders.DimensionBuilders.LinearOrAngularDimension.Builder {
- method public androidx.wear.tiles.builders.DimensionBuilders.DpProp build();
- method public androidx.wear.tiles.builders.DimensionBuilders.DpProp.Builder setValue(@Dimension(unit=androidx.annotation.Dimension.DP) float);
- }
-
- public static final class DimensionBuilders.ExpandedDimensionProp implements androidx.wear.tiles.builders.DimensionBuilders.ContainerDimension androidx.wear.tiles.builders.DimensionBuilders.ImageDimension {
- method public static androidx.wear.tiles.builders.DimensionBuilders.ExpandedDimensionProp.Builder builder();
- }
-
- public static final class DimensionBuilders.ExpandedDimensionProp.Builder implements androidx.wear.tiles.builders.DimensionBuilders.ContainerDimension.Builder androidx.wear.tiles.builders.DimensionBuilders.ImageDimension.Builder {
- method public androidx.wear.tiles.builders.DimensionBuilders.ExpandedDimensionProp build();
- }
-
- public static interface DimensionBuilders.ImageDimension {
- }
-
- public static interface DimensionBuilders.ImageDimension.Builder {
- method public androidx.wear.tiles.builders.DimensionBuilders.ImageDimension build();
- }
-
- public static interface DimensionBuilders.LinearOrAngularDimension {
- }
-
- public static interface DimensionBuilders.LinearOrAngularDimension.Builder {
- method public androidx.wear.tiles.builders.DimensionBuilders.LinearOrAngularDimension build();
- }
-
- public static final class DimensionBuilders.ProportionalDimensionProp implements androidx.wear.tiles.builders.DimensionBuilders.ImageDimension {
- method public static androidx.wear.tiles.builders.DimensionBuilders.ProportionalDimensionProp.Builder builder();
- }
-
- public static final class DimensionBuilders.ProportionalDimensionProp.Builder implements androidx.wear.tiles.builders.DimensionBuilders.ImageDimension.Builder {
- method public androidx.wear.tiles.builders.DimensionBuilders.ProportionalDimensionProp build();
- method public androidx.wear.tiles.builders.DimensionBuilders.ProportionalDimensionProp.Builder setAspectRatioHeight(@IntRange(from=0) int);
- method public androidx.wear.tiles.builders.DimensionBuilders.ProportionalDimensionProp.Builder setAspectRatioWidth(@IntRange(from=0) int);
- }
-
- public static final class DimensionBuilders.SpProp {
- method public static androidx.wear.tiles.builders.DimensionBuilders.SpProp.Builder builder();
- }
-
- public static final class DimensionBuilders.SpProp.Builder {
- method public androidx.wear.tiles.builders.DimensionBuilders.SpProp build();
- method public androidx.wear.tiles.builders.DimensionBuilders.SpProp.Builder setValue(@Dimension(unit=androidx.annotation.Dimension.SP) int);
- }
-
- public static final class DimensionBuilders.WrappedDimensionProp implements androidx.wear.tiles.builders.DimensionBuilders.ContainerDimension {
- method public static androidx.wear.tiles.builders.DimensionBuilders.WrappedDimensionProp.Builder builder();
- }
-
- public static final class DimensionBuilders.WrappedDimensionProp.Builder implements androidx.wear.tiles.builders.DimensionBuilders.ContainerDimension.Builder {
- method public androidx.wear.tiles.builders.DimensionBuilders.WrappedDimensionProp build();
- }
-
- public final class LayoutElementBuilders {
- field public static final int ARC_ANCHOR_CENTER = 2; // 0x2
- field public static final int ARC_ANCHOR_END = 3; // 0x3
- field public static final int ARC_ANCHOR_START = 1; // 0x1
- field public static final int ARC_ANCHOR_UNDEFINED = 0; // 0x0
- field public static final int CONTENT_SCALE_MODE_CROP = 2; // 0x2
- field public static final int CONTENT_SCALE_MODE_FILL_BOUNDS = 3; // 0x3
- field public static final int CONTENT_SCALE_MODE_FIT = 1; // 0x1
- field public static final int CONTENT_SCALE_MODE_UNDEFINED = 0; // 0x0
- field public static final int FONT_WEIGHT_BOLD = 700; // 0x2bc
- field public static final int FONT_WEIGHT_NORMAL = 400; // 0x190
- field public static final int FONT_WEIGHT_UNDEFINED = 0; // 0x0
- field public static final int HALIGN_CENTER = 2; // 0x2
- field public static final int HALIGN_END = 5; // 0x5
- field public static final int HALIGN_LEFT = 1; // 0x1
- field public static final int HALIGN_RIGHT = 3; // 0x3
- field public static final int HALIGN_START = 4; // 0x4
- field public static final int HALIGN_UNDEFINED = 0; // 0x0
- field public static final int TEXT_ALIGN_CENTER = 2; // 0x2
- field public static final int TEXT_ALIGN_END = 3; // 0x3
- field public static final int TEXT_ALIGN_START = 1; // 0x1
- field public static final int TEXT_ALIGN_UNDEFINED = 0; // 0x0
- field public static final int TEXT_OVERFLOW_ELLIPSIZE_END = 2; // 0x2
- field public static final int TEXT_OVERFLOW_TRUNCATE = 1; // 0x1
- field public static final int TEXT_OVERFLOW_UNDEFINED = 0; // 0x0
- field public static final int VALIGN_BOTTOM = 3; // 0x3
- field public static final int VALIGN_CENTER = 2; // 0x2
- field public static final int VALIGN_TOP = 1; // 0x1
- field public static final int VALIGN_UNDEFINED = 0; // 0x0
- }
-
- public static final class LayoutElementBuilders.Arc implements androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement {
- method public static androidx.wear.tiles.builders.LayoutElementBuilders.Arc.Builder builder();
- }
-
- public static final class LayoutElementBuilders.Arc.Builder implements androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement.Builder {
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Arc.Builder addContent(androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Arc.Builder addContent(androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Arc build();
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Arc.Builder setAnchorAngle(androidx.wear.tiles.builders.DimensionBuilders.DegreesProp);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Arc.Builder setAnchorAngle(androidx.wear.tiles.builders.DimensionBuilders.DegreesProp.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Arc.Builder setAnchorType(int);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Arc.Builder setLength(androidx.wear.tiles.builders.DimensionBuilders.DegreesProp);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Arc.Builder setLength(androidx.wear.tiles.builders.DimensionBuilders.DegreesProp.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Arc.Builder setRotateContents(boolean);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Arc.Builder setThickness(androidx.wear.tiles.builders.DimensionBuilders.DpProp);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Arc.Builder setThickness(androidx.wear.tiles.builders.DimensionBuilders.DpProp.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Arc.Builder setVerticalAlign(int);
- }
-
- public static final class LayoutElementBuilders.Audible implements androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement {
- method public static androidx.wear.tiles.builders.LayoutElementBuilders.Audible.Builder builder();
- }
-
- public static final class LayoutElementBuilders.Audible.Builder implements androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement.Builder {
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Audible build();
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Audible.Builder setAccessibilityLabel(String);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Audible.Builder setContent(androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Audible.Builder setContent(androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement.Builder);
- }
-
- public static final class LayoutElementBuilders.Border {
- method public static androidx.wear.tiles.builders.LayoutElementBuilders.Border.Builder builder();
- }
-
- public static final class LayoutElementBuilders.Border.Builder {
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Border build();
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Border.Builder setColor(androidx.wear.tiles.builders.ColorBuilders.ColorProp);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Border.Builder setColor(androidx.wear.tiles.builders.ColorBuilders.ColorProp.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Border.Builder setWidth(androidx.wear.tiles.builders.DimensionBuilders.DpProp);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Border.Builder setWidth(androidx.wear.tiles.builders.DimensionBuilders.DpProp.Builder);
- }
-
- public static final class LayoutElementBuilders.Box implements androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement {
- method public static androidx.wear.tiles.builders.LayoutElementBuilders.Box.Builder builder();
- }
-
- public static final class LayoutElementBuilders.Box.Builder implements androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement.Builder {
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Box.Builder addContent(androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Box.Builder addContent(androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Box build();
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Box.Builder setHeight(androidx.wear.tiles.builders.DimensionBuilders.ContainerDimension);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Box.Builder setHeight(androidx.wear.tiles.builders.DimensionBuilders.ContainerDimension.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Box.Builder setHorizontalAlignment(int);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Box.Builder setStyle(androidx.wear.tiles.builders.LayoutElementBuilders.BoxStyle);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Box.Builder setStyle(androidx.wear.tiles.builders.LayoutElementBuilders.BoxStyle.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Box.Builder setVerticalAlignment(int);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Box.Builder setWidth(androidx.wear.tiles.builders.DimensionBuilders.ContainerDimension);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Box.Builder setWidth(androidx.wear.tiles.builders.DimensionBuilders.ContainerDimension.Builder);
- }
-
- public static final class LayoutElementBuilders.BoxStyle {
- method public static androidx.wear.tiles.builders.LayoutElementBuilders.BoxStyle.Builder builder();
- }
-
- public static final class LayoutElementBuilders.BoxStyle.Builder {
- method public androidx.wear.tiles.builders.LayoutElementBuilders.BoxStyle build();
- method public androidx.wear.tiles.builders.LayoutElementBuilders.BoxStyle.Builder setBackgroundColor(androidx.wear.tiles.builders.ColorBuilders.ColorProp);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.BoxStyle.Builder setBackgroundColor(androidx.wear.tiles.builders.ColorBuilders.ColorProp.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.BoxStyle.Builder setBorder(androidx.wear.tiles.builders.LayoutElementBuilders.Border);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.BoxStyle.Builder setBorder(androidx.wear.tiles.builders.LayoutElementBuilders.Border.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.BoxStyle.Builder setCorner(androidx.wear.tiles.builders.LayoutElementBuilders.Corner);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.BoxStyle.Builder setCorner(androidx.wear.tiles.builders.LayoutElementBuilders.Corner.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.BoxStyle.Builder setPadding(androidx.wear.tiles.builders.LayoutElementBuilders.Padding);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.BoxStyle.Builder setPadding(androidx.wear.tiles.builders.LayoutElementBuilders.Padding.Builder);
- }
-
- public static final class LayoutElementBuilders.Clickable implements androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement {
- method public static androidx.wear.tiles.builders.LayoutElementBuilders.Clickable.Builder builder();
- }
-
- public static final class LayoutElementBuilders.Clickable.Builder implements androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement.Builder {
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Clickable build();
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Clickable.Builder setContent(androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Clickable.Builder setContent(androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Clickable.Builder setId(String);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Clickable.Builder setOnClick(androidx.wear.tiles.builders.ActionBuilders.Action);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Clickable.Builder setOnClick(androidx.wear.tiles.builders.ActionBuilders.Action.Builder);
- }
-
- public static final class LayoutElementBuilders.Column implements androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement {
- method public static androidx.wear.tiles.builders.LayoutElementBuilders.Column.Builder builder();
- }
-
- public static final class LayoutElementBuilders.Column.Builder implements androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement.Builder {
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Column.Builder addContent(androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Column.Builder addContent(androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Column build();
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Column.Builder setHeight(androidx.wear.tiles.builders.DimensionBuilders.ContainerDimension);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Column.Builder setHeight(androidx.wear.tiles.builders.DimensionBuilders.ContainerDimension.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Column.Builder setHorizontalAlignment(int);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Column.Builder setWidth(androidx.wear.tiles.builders.DimensionBuilders.ContainerDimension);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Column.Builder setWidth(androidx.wear.tiles.builders.DimensionBuilders.ContainerDimension.Builder);
- }
-
- public static final class LayoutElementBuilders.Corner {
- method public static androidx.wear.tiles.builders.LayoutElementBuilders.Corner.Builder builder();
- }
-
- public static final class LayoutElementBuilders.Corner.Builder {
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Corner build();
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Corner.Builder setRadius(androidx.wear.tiles.builders.DimensionBuilders.DpProp);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Corner.Builder setRadius(androidx.wear.tiles.builders.DimensionBuilders.DpProp.Builder);
- }
-
- public static final class LayoutElementBuilders.FontStyle {
- method public static androidx.wear.tiles.builders.LayoutElementBuilders.FontStyle.Builder builder();
- }
-
- public static final class LayoutElementBuilders.FontStyle.Builder {
- method public androidx.wear.tiles.builders.LayoutElementBuilders.FontStyle build();
- method @Deprecated public androidx.wear.tiles.builders.LayoutElementBuilders.FontStyle.Builder setBold(boolean);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.FontStyle.Builder setColor(androidx.wear.tiles.builders.ColorBuilders.ColorProp);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.FontStyle.Builder setColor(androidx.wear.tiles.builders.ColorBuilders.ColorProp.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.FontStyle.Builder setItalic(boolean);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.FontStyle.Builder setSize(androidx.wear.tiles.builders.DimensionBuilders.SpProp);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.FontStyle.Builder setSize(androidx.wear.tiles.builders.DimensionBuilders.SpProp.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.FontStyle.Builder setUnderline(boolean);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.FontStyle.Builder setWeight(int);
- }
-
- public static class LayoutElementBuilders.FontStyles {
- method public androidx.wear.tiles.builders.LayoutElementBuilders.FontStyle body1();
- method public androidx.wear.tiles.builders.LayoutElementBuilders.FontStyle body2();
- method public androidx.wear.tiles.builders.LayoutElementBuilders.FontStyle button();
- method public androidx.wear.tiles.builders.LayoutElementBuilders.FontStyle caption1();
- method public androidx.wear.tiles.builders.LayoutElementBuilders.FontStyle caption2();
- method public androidx.wear.tiles.builders.LayoutElementBuilders.FontStyle display1();
- method public androidx.wear.tiles.builders.LayoutElementBuilders.FontStyle display2();
- method public androidx.wear.tiles.builders.LayoutElementBuilders.FontStyle display3();
- method public androidx.wear.tiles.builders.LayoutElementBuilders.FontStyle title1();
- method public androidx.wear.tiles.builders.LayoutElementBuilders.FontStyle title2();
- method public androidx.wear.tiles.builders.LayoutElementBuilders.FontStyle title3();
- method public static androidx.wear.tiles.builders.LayoutElementBuilders.FontStyles withDeviceParameters(androidx.wear.tiles.readers.DeviceParametersReaders.DeviceParameters);
- }
-
- public static final class LayoutElementBuilders.Image implements androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement {
- method public static androidx.wear.tiles.builders.LayoutElementBuilders.Image.Builder builder();
- }
-
- public static final class LayoutElementBuilders.Image.Builder implements androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement.Builder {
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Image build();
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Image.Builder setContentScaleMode(int);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Image.Builder setHeight(androidx.wear.tiles.builders.DimensionBuilders.ImageDimension);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Image.Builder setHeight(androidx.wear.tiles.builders.DimensionBuilders.ImageDimension.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Image.Builder setResourceId(String);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Image.Builder setWidth(androidx.wear.tiles.builders.DimensionBuilders.ImageDimension);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Image.Builder setWidth(androidx.wear.tiles.builders.DimensionBuilders.ImageDimension.Builder);
- }
-
- public static interface LayoutElementBuilders.LayoutElement {
- }
-
- public static interface LayoutElementBuilders.LayoutElement.Builder {
- method public androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement build();
- }
-
- public static final class LayoutElementBuilders.Line implements androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement {
- method public static androidx.wear.tiles.builders.LayoutElementBuilders.Line.Builder builder();
- }
-
- public static final class LayoutElementBuilders.Line.Builder implements androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement.Builder {
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Line build();
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Line.Builder setLength(androidx.wear.tiles.builders.DimensionBuilders.LinearOrAngularDimension);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Line.Builder setLength(androidx.wear.tiles.builders.DimensionBuilders.LinearOrAngularDimension.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Line.Builder setStyle(androidx.wear.tiles.builders.LayoutElementBuilders.LineStyle);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Line.Builder setStyle(androidx.wear.tiles.builders.LayoutElementBuilders.LineStyle.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Line.Builder setThickness(androidx.wear.tiles.builders.DimensionBuilders.DpProp);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Line.Builder setThickness(androidx.wear.tiles.builders.DimensionBuilders.DpProp.Builder);
- }
-
- public static final class LayoutElementBuilders.LineStyle {
- method public static androidx.wear.tiles.builders.LayoutElementBuilders.LineStyle.Builder builder();
- }
-
- public static final class LayoutElementBuilders.LineStyle.Builder {
- method public androidx.wear.tiles.builders.LayoutElementBuilders.LineStyle build();
- method public androidx.wear.tiles.builders.LayoutElementBuilders.LineStyle.Builder setColor(androidx.wear.tiles.builders.ColorBuilders.ColorProp);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.LineStyle.Builder setColor(androidx.wear.tiles.builders.ColorBuilders.ColorProp.Builder);
- }
-
- public static final class LayoutElementBuilders.Padding {
- method public static androidx.wear.tiles.builders.LayoutElementBuilders.Padding.Builder builder();
- }
-
- public static final class LayoutElementBuilders.Padding.Builder {
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Padding build();
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Padding.Builder setBottom(androidx.wear.tiles.builders.DimensionBuilders.DpProp);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Padding.Builder setBottom(androidx.wear.tiles.builders.DimensionBuilders.DpProp.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Padding.Builder setEnd(androidx.wear.tiles.builders.DimensionBuilders.DpProp);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Padding.Builder setEnd(androidx.wear.tiles.builders.DimensionBuilders.DpProp.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Padding.Builder setRtlAware(boolean);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Padding.Builder setStart(androidx.wear.tiles.builders.DimensionBuilders.DpProp);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Padding.Builder setStart(androidx.wear.tiles.builders.DimensionBuilders.DpProp.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Padding.Builder setTop(androidx.wear.tiles.builders.DimensionBuilders.DpProp);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Padding.Builder setTop(androidx.wear.tiles.builders.DimensionBuilders.DpProp.Builder);
- }
-
- public static final class LayoutElementBuilders.Row implements androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement {
- method public static androidx.wear.tiles.builders.LayoutElementBuilders.Row.Builder builder();
- }
-
- public static final class LayoutElementBuilders.Row.Builder implements androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement.Builder {
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Row.Builder addContent(androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Row.Builder addContent(androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Row build();
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Row.Builder setHeight(androidx.wear.tiles.builders.DimensionBuilders.ContainerDimension);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Row.Builder setHeight(androidx.wear.tiles.builders.DimensionBuilders.ContainerDimension.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Row.Builder setVerticalAlignment(int);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Row.Builder setWidth(androidx.wear.tiles.builders.DimensionBuilders.ContainerDimension);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Row.Builder setWidth(androidx.wear.tiles.builders.DimensionBuilders.ContainerDimension.Builder);
- }
-
- public static final class LayoutElementBuilders.Spacer implements androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement {
- method public static androidx.wear.tiles.builders.LayoutElementBuilders.Spacer.Builder builder();
- }
-
- public static final class LayoutElementBuilders.Spacer.Builder implements androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement.Builder {
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Spacer build();
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Spacer.Builder setHeight(androidx.wear.tiles.builders.DimensionBuilders.DpProp);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Spacer.Builder setHeight(androidx.wear.tiles.builders.DimensionBuilders.DpProp.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Spacer.Builder setWidth(androidx.wear.tiles.builders.DimensionBuilders.LinearOrAngularDimension);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Spacer.Builder setWidth(androidx.wear.tiles.builders.DimensionBuilders.LinearOrAngularDimension.Builder);
- }
-
- public static interface LayoutElementBuilders.Span {
- }
-
- public static interface LayoutElementBuilders.Span.Builder {
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Span build();
- }
-
- public static final class LayoutElementBuilders.Spannable implements androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement {
- method public static androidx.wear.tiles.builders.LayoutElementBuilders.Spannable.Builder builder();
- }
-
- public static final class LayoutElementBuilders.Spannable.Builder implements androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement.Builder {
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Spannable.Builder addSpan(androidx.wear.tiles.builders.LayoutElementBuilders.Span);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Spannable.Builder addSpan(androidx.wear.tiles.builders.LayoutElementBuilders.Span.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Spannable build();
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Spannable.Builder setStyle(androidx.wear.tiles.builders.LayoutElementBuilders.SpannableStyle);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Spannable.Builder setStyle(androidx.wear.tiles.builders.LayoutElementBuilders.SpannableStyle.Builder);
- }
-
- public static final class LayoutElementBuilders.SpannableStyle {
- method public static androidx.wear.tiles.builders.LayoutElementBuilders.SpannableStyle.Builder builder();
- }
-
- public static final class LayoutElementBuilders.SpannableStyle.Builder {
- method public androidx.wear.tiles.builders.LayoutElementBuilders.SpannableStyle build();
- method public androidx.wear.tiles.builders.LayoutElementBuilders.SpannableStyle.Builder setMaxLines(@IntRange(from=0) int);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.SpannableStyle.Builder setMultilineAlignment(int);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.SpannableStyle.Builder setOverflow(int);
- }
-
- public static final class LayoutElementBuilders.Text implements androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement androidx.wear.tiles.builders.LayoutElementBuilders.Span {
- method public static androidx.wear.tiles.builders.LayoutElementBuilders.Text.Builder builder();
- }
-
- public static final class LayoutElementBuilders.Text.Builder implements androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement.Builder androidx.wear.tiles.builders.LayoutElementBuilders.Span.Builder {
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Text build();
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Text.Builder setFontStyle(androidx.wear.tiles.builders.LayoutElementBuilders.FontStyle);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Text.Builder setFontStyle(androidx.wear.tiles.builders.LayoutElementBuilders.FontStyle.Builder);
- method @Deprecated public androidx.wear.tiles.builders.LayoutElementBuilders.Text.Builder setStyle(androidx.wear.tiles.builders.LayoutElementBuilders.TextStyle);
- method @Deprecated public androidx.wear.tiles.builders.LayoutElementBuilders.Text.Builder setStyle(androidx.wear.tiles.builders.LayoutElementBuilders.TextStyle.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Text.Builder setText(String);
- }
-
- public static final class LayoutElementBuilders.TextStyle {
- method public static androidx.wear.tiles.builders.LayoutElementBuilders.TextStyle.Builder builder();
- }
-
- public static final class LayoutElementBuilders.TextStyle.Builder {
- method public androidx.wear.tiles.builders.LayoutElementBuilders.TextStyle build();
- method @Deprecated public androidx.wear.tiles.builders.LayoutElementBuilders.TextStyle.Builder setColor(androidx.wear.tiles.builders.ColorBuilders.ColorProp);
- method @Deprecated public androidx.wear.tiles.builders.LayoutElementBuilders.TextStyle.Builder setColor(androidx.wear.tiles.builders.ColorBuilders.ColorProp.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.TextStyle.Builder setMaxLines(@IntRange(from=0) int);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.TextStyle.Builder setMultilineAlignment(int);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.TextStyle.Builder setOverflow(int);
- }
-
- public final class ResourceBuilders {
- field public static final int IMAGE_FORMAT_RGB_565 = 1; // 0x1
- field public static final int IMAGE_FORMAT_UNDEFINED = 0; // 0x0
- }
-
- public static final class ResourceBuilders.AndroidImageResourceByResId {
- method public static androidx.wear.tiles.builders.ResourceBuilders.AndroidImageResourceByResId.Builder builder();
- }
-
- public static final class ResourceBuilders.AndroidImageResourceByResId.Builder {
- method public androidx.wear.tiles.builders.ResourceBuilders.AndroidImageResourceByResId build();
- method public androidx.wear.tiles.builders.ResourceBuilders.AndroidImageResourceByResId.Builder setResourceId(@DrawableRes int);
- }
-
- public static final class ResourceBuilders.ImageResource {
- method public static androidx.wear.tiles.builders.ResourceBuilders.ImageResource.Builder builder();
- }
-
- public static final class ResourceBuilders.ImageResource.Builder {
- method public androidx.wear.tiles.builders.ResourceBuilders.ImageResource build();
- method public androidx.wear.tiles.builders.ResourceBuilders.ImageResource.Builder setAndroidResourceByResid(androidx.wear.tiles.builders.ResourceBuilders.AndroidImageResourceByResId);
- method public androidx.wear.tiles.builders.ResourceBuilders.ImageResource.Builder setAndroidResourceByResid(androidx.wear.tiles.builders.ResourceBuilders.AndroidImageResourceByResId.Builder);
- method public androidx.wear.tiles.builders.ResourceBuilders.ImageResource.Builder setInlineResource(androidx.wear.tiles.builders.ResourceBuilders.InlineImageResource);
- method public androidx.wear.tiles.builders.ResourceBuilders.ImageResource.Builder setInlineResource(androidx.wear.tiles.builders.ResourceBuilders.InlineImageResource.Builder);
- }
-
- public static final class ResourceBuilders.InlineImageResource {
- method public static androidx.wear.tiles.builders.ResourceBuilders.InlineImageResource.Builder builder();
- }
-
- public static final class ResourceBuilders.InlineImageResource.Builder {
- method public androidx.wear.tiles.builders.ResourceBuilders.InlineImageResource build();
- method public androidx.wear.tiles.builders.ResourceBuilders.InlineImageResource.Builder setData(byte[]);
- method public androidx.wear.tiles.builders.ResourceBuilders.InlineImageResource.Builder setFormat(int);
- method public androidx.wear.tiles.builders.ResourceBuilders.InlineImageResource.Builder setHeightPx(@Dimension(unit=androidx.annotation.Dimension.PX) int);
- method public androidx.wear.tiles.builders.ResourceBuilders.InlineImageResource.Builder setWidthPx(@Dimension(unit=androidx.annotation.Dimension.PX) int);
- }
-
- public static final class ResourceBuilders.Resources {
- method public static androidx.wear.tiles.builders.ResourceBuilders.Resources.Builder builder();
- }
-
- public static final class ResourceBuilders.Resources.Builder {
- method public androidx.wear.tiles.builders.ResourceBuilders.Resources.Builder addIdToImageMapping(String, androidx.wear.tiles.builders.ResourceBuilders.ImageResource);
- method public androidx.wear.tiles.builders.ResourceBuilders.Resources.Builder addIdToImageMapping(String, androidx.wear.tiles.builders.ResourceBuilders.ImageResource.Builder);
- method public androidx.wear.tiles.builders.ResourceBuilders.Resources build();
- method public androidx.wear.tiles.builders.ResourceBuilders.Resources.Builder setVersion(String);
- }
-
- public final class TileBuilders {
- }
-
- public static final class TileBuilders.Tile {
- method public static androidx.wear.tiles.builders.TileBuilders.Tile.Builder builder();
- }
-
- public static final class TileBuilders.Tile.Builder {
- method public androidx.wear.tiles.builders.TileBuilders.Tile build();
- method public androidx.wear.tiles.builders.TileBuilders.Tile.Builder setResourcesVersion(String);
- method public androidx.wear.tiles.builders.TileBuilders.Tile.Builder setTimeline(androidx.wear.tiles.builders.TimelineBuilders.Timeline);
- method public androidx.wear.tiles.builders.TileBuilders.Tile.Builder setTimeline(androidx.wear.tiles.builders.TimelineBuilders.Timeline.Builder);
- }
-
- public final class TimelineBuilders {
- }
-
- public static final class TimelineBuilders.TimeInterval {
- method public static androidx.wear.tiles.builders.TimelineBuilders.TimeInterval.Builder builder();
- }
-
- public static final class TimelineBuilders.TimeInterval.Builder {
- method public androidx.wear.tiles.builders.TimelineBuilders.TimeInterval build();
- method public androidx.wear.tiles.builders.TimelineBuilders.TimeInterval.Builder setEndMillis(long);
- method public androidx.wear.tiles.builders.TimelineBuilders.TimeInterval.Builder setStartMillis(long);
- }
-
- public static final class TimelineBuilders.Timeline {
- method public static androidx.wear.tiles.builders.TimelineBuilders.Timeline.Builder builder();
- }
-
- public static final class TimelineBuilders.Timeline.Builder {
- method public androidx.wear.tiles.builders.TimelineBuilders.Timeline.Builder addTimelineEntry(androidx.wear.tiles.builders.TimelineBuilders.TimelineEntry);
- method public androidx.wear.tiles.builders.TimelineBuilders.Timeline.Builder addTimelineEntry(androidx.wear.tiles.builders.TimelineBuilders.TimelineEntry.Builder);
- method public androidx.wear.tiles.builders.TimelineBuilders.Timeline build();
- }
-
- public static final class TimelineBuilders.TimelineEntry {
- method public static androidx.wear.tiles.builders.TimelineBuilders.TimelineEntry.Builder builder();
- }
-
- public static final class TimelineBuilders.TimelineEntry.Builder {
- method public androidx.wear.tiles.builders.TimelineBuilders.TimelineEntry build();
- method public androidx.wear.tiles.builders.TimelineBuilders.TimelineEntry.Builder setContent(androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement);
- method public androidx.wear.tiles.builders.TimelineBuilders.TimelineEntry.Builder setContent(androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement.Builder);
- method public androidx.wear.tiles.builders.TimelineBuilders.TimelineEntry.Builder setValidity(androidx.wear.tiles.builders.TimelineBuilders.TimeInterval);
- method public androidx.wear.tiles.builders.TimelineBuilders.TimelineEntry.Builder setValidity(androidx.wear.tiles.builders.TimelineBuilders.TimeInterval.Builder);
- }
-
-}
-
-package androidx.wear.tiles.readers {
-
- public class DeviceParametersReaders {
- field public static final int DEVICE_PLATFORM_UNDEFINED = 0; // 0x0
- field public static final int DEVICE_PLATFORM_WEAR_OS = 1; // 0x1
- field public static final int SCREEN_SHAPE_RECT = 2; // 0x2
- field public static final int SCREEN_SHAPE_ROUND = 1; // 0x1
- field public static final int SCREEN_SHAPE_UNDEFINED = 0; // 0x0
- }
-
- public static class DeviceParametersReaders.DeviceParameters {
- method public int getDevicePlatform();
- method @FloatRange(from=0.0, fromInclusive=false) public float getScreenDensity();
- method @Dimension(unit=androidx.annotation.Dimension.DP) public int getScreenHeightDp();
- method public int getScreenShape();
- method @Dimension(unit=androidx.annotation.Dimension.DP) public int getScreenWidthDp();
- }
-
- public class RequestReaders {
- }
-
- public static class RequestReaders.ResourcesRequest {
- method public java.util.List<java.lang.String!> getResourceIds();
- method public String getVersion();
- }
-
- public static class RequestReaders.TileRequest {
- method public String getClickableId();
- method public androidx.wear.tiles.readers.DeviceParametersReaders.DeviceParameters? getDeviceParameters();
- }
-
-}
-
diff --git a/wear/wear-tiles/api/public_plus_experimental_current.txt b/wear/wear-tiles/api/public_plus_experimental_current.txt
deleted file mode 100644
index 85c4a7f..0000000
--- a/wear/wear-tiles/api/public_plus_experimental_current.txt
+++ /dev/null
@@ -1,615 +0,0 @@
-// Signature format: 4.0
-package androidx.wear.tiles {
-
- public class SysUiTileUpdateRequester implements androidx.wear.tiles.TileUpdateRequester {
- ctor public SysUiTileUpdateRequester(android.content.Context);
- method public void requestUpdate(Class<? extends android.app.Service>);
- field public static final String ACTION_BIND_UPDATE_REQUESTER = "androidx.wear.tiles.action.BIND_UPDATE_REQUESTER";
- }
-
- public abstract class TileProviderService extends android.app.Service {
- ctor public TileProviderService();
- method public static androidx.wear.tiles.TileUpdateRequester getUpdater(android.content.Context);
- method public android.os.IBinder? onBind(android.content.Intent);
- method @MainThread protected abstract com.google.common.util.concurrent.ListenableFuture<androidx.wear.tiles.builders.ResourceBuilders.Resources!> onResourcesRequest(androidx.wear.tiles.readers.RequestReaders.ResourcesRequest);
- method @MainThread protected abstract com.google.common.util.concurrent.ListenableFuture<androidx.wear.tiles.builders.TileBuilders.Tile!> onTileRequest(androidx.wear.tiles.readers.RequestReaders.TileRequest);
- field public static final String ACTION_BIND_TILE_PROVIDER = "androidx.wear.tiles.action.BIND_TILE_PROVIDER";
- field public static final String EXTRA_CLICKABLE_ID = "androidx.wear.tiles.extra.CLICKABLE_ID";
- field public static final String METADATA_PREVIEW_KEY = "androidx.wear.tiles.PREVIEW";
- }
-
- public interface TileUpdateRequester {
- method public void requestUpdate(Class<? extends android.app.Service>);
- }
-
-}
-
-package androidx.wear.tiles.builders {
-
- public final class ActionBuilders {
- }
-
- public static interface ActionBuilders.Action {
- }
-
- public static interface ActionBuilders.Action.Builder {
- method public androidx.wear.tiles.builders.ActionBuilders.Action build();
- }
-
- public static final class ActionBuilders.AndroidActivity {
- method public static androidx.wear.tiles.builders.ActionBuilders.AndroidActivity.Builder builder();
- }
-
- public static final class ActionBuilders.AndroidActivity.Builder {
- method public androidx.wear.tiles.builders.ActionBuilders.AndroidActivity build();
- method public androidx.wear.tiles.builders.ActionBuilders.AndroidActivity.Builder setClassName(String);
- method public androidx.wear.tiles.builders.ActionBuilders.AndroidActivity.Builder setPackageName(String);
- }
-
- public static final class ActionBuilders.LaunchAction implements androidx.wear.tiles.builders.ActionBuilders.Action {
- method public static androidx.wear.tiles.builders.ActionBuilders.LaunchAction.Builder builder();
- }
-
- public static final class ActionBuilders.LaunchAction.Builder implements androidx.wear.tiles.builders.ActionBuilders.Action.Builder {
- method public androidx.wear.tiles.builders.ActionBuilders.LaunchAction build();
- method public androidx.wear.tiles.builders.ActionBuilders.LaunchAction.Builder setAndroidActivity(androidx.wear.tiles.builders.ActionBuilders.AndroidActivity);
- method public androidx.wear.tiles.builders.ActionBuilders.LaunchAction.Builder setAndroidActivity(androidx.wear.tiles.builders.ActionBuilders.AndroidActivity.Builder);
- }
-
- public static final class ActionBuilders.LoadAction implements androidx.wear.tiles.builders.ActionBuilders.Action {
- method public static androidx.wear.tiles.builders.ActionBuilders.LoadAction.Builder builder();
- }
-
- public static final class ActionBuilders.LoadAction.Builder implements androidx.wear.tiles.builders.ActionBuilders.Action.Builder {
- method public androidx.wear.tiles.builders.ActionBuilders.LoadAction build();
- }
-
- public final class ColorBuilders {
- method public static androidx.wear.tiles.builders.ColorBuilders.ColorProp argb(@ColorInt int);
- }
-
- public static final class ColorBuilders.ColorProp {
- method public static androidx.wear.tiles.builders.ColorBuilders.ColorProp.Builder builder();
- }
-
- public static final class ColorBuilders.ColorProp.Builder {
- method public androidx.wear.tiles.builders.ColorBuilders.ColorProp build();
- method public androidx.wear.tiles.builders.ColorBuilders.ColorProp.Builder setArgb(@ColorInt int);
- }
-
- public final class DimensionBuilders {
- method public static androidx.wear.tiles.builders.DimensionBuilders.DegreesProp degrees(float);
- method public static androidx.wear.tiles.builders.DimensionBuilders.DpProp dp(@Dimension(unit=androidx.annotation.Dimension.DP) float);
- method public static androidx.wear.tiles.builders.DimensionBuilders.ExpandedDimensionProp expand();
- method public static androidx.wear.tiles.builders.DimensionBuilders.SpProp sp(@Dimension(unit=androidx.annotation.Dimension.SP) int);
- method public static androidx.wear.tiles.builders.DimensionBuilders.WrappedDimensionProp wrap();
- }
-
- public static interface DimensionBuilders.ContainerDimension {
- }
-
- public static interface DimensionBuilders.ContainerDimension.Builder {
- method public androidx.wear.tiles.builders.DimensionBuilders.ContainerDimension build();
- }
-
- public static final class DimensionBuilders.DegreesProp implements androidx.wear.tiles.builders.DimensionBuilders.LinearOrAngularDimension {
- method public static androidx.wear.tiles.builders.DimensionBuilders.DegreesProp.Builder builder();
- }
-
- public static final class DimensionBuilders.DegreesProp.Builder implements androidx.wear.tiles.builders.DimensionBuilders.LinearOrAngularDimension.Builder {
- method public androidx.wear.tiles.builders.DimensionBuilders.DegreesProp build();
- method public androidx.wear.tiles.builders.DimensionBuilders.DegreesProp.Builder setValue(float);
- }
-
- public static final class DimensionBuilders.DpProp implements androidx.wear.tiles.builders.DimensionBuilders.ContainerDimension androidx.wear.tiles.builders.DimensionBuilders.ImageDimension androidx.wear.tiles.builders.DimensionBuilders.LinearOrAngularDimension {
- method public static androidx.wear.tiles.builders.DimensionBuilders.DpProp.Builder builder();
- }
-
- public static final class DimensionBuilders.DpProp.Builder implements androidx.wear.tiles.builders.DimensionBuilders.ContainerDimension.Builder androidx.wear.tiles.builders.DimensionBuilders.ImageDimension.Builder androidx.wear.tiles.builders.DimensionBuilders.LinearOrAngularDimension.Builder {
- method public androidx.wear.tiles.builders.DimensionBuilders.DpProp build();
- method public androidx.wear.tiles.builders.DimensionBuilders.DpProp.Builder setValue(@Dimension(unit=androidx.annotation.Dimension.DP) float);
- }
-
- public static final class DimensionBuilders.ExpandedDimensionProp implements androidx.wear.tiles.builders.DimensionBuilders.ContainerDimension androidx.wear.tiles.builders.DimensionBuilders.ImageDimension {
- method public static androidx.wear.tiles.builders.DimensionBuilders.ExpandedDimensionProp.Builder builder();
- }
-
- public static final class DimensionBuilders.ExpandedDimensionProp.Builder implements androidx.wear.tiles.builders.DimensionBuilders.ContainerDimension.Builder androidx.wear.tiles.builders.DimensionBuilders.ImageDimension.Builder {
- method public androidx.wear.tiles.builders.DimensionBuilders.ExpandedDimensionProp build();
- }
-
- public static interface DimensionBuilders.ImageDimension {
- }
-
- public static interface DimensionBuilders.ImageDimension.Builder {
- method public androidx.wear.tiles.builders.DimensionBuilders.ImageDimension build();
- }
-
- public static interface DimensionBuilders.LinearOrAngularDimension {
- }
-
- public static interface DimensionBuilders.LinearOrAngularDimension.Builder {
- method public androidx.wear.tiles.builders.DimensionBuilders.LinearOrAngularDimension build();
- }
-
- public static final class DimensionBuilders.ProportionalDimensionProp implements androidx.wear.tiles.builders.DimensionBuilders.ImageDimension {
- method public static androidx.wear.tiles.builders.DimensionBuilders.ProportionalDimensionProp.Builder builder();
- }
-
- public static final class DimensionBuilders.ProportionalDimensionProp.Builder implements androidx.wear.tiles.builders.DimensionBuilders.ImageDimension.Builder {
- method public androidx.wear.tiles.builders.DimensionBuilders.ProportionalDimensionProp build();
- method public androidx.wear.tiles.builders.DimensionBuilders.ProportionalDimensionProp.Builder setAspectRatioHeight(@IntRange(from=0) int);
- method public androidx.wear.tiles.builders.DimensionBuilders.ProportionalDimensionProp.Builder setAspectRatioWidth(@IntRange(from=0) int);
- }
-
- public static final class DimensionBuilders.SpProp {
- method public static androidx.wear.tiles.builders.DimensionBuilders.SpProp.Builder builder();
- }
-
- public static final class DimensionBuilders.SpProp.Builder {
- method public androidx.wear.tiles.builders.DimensionBuilders.SpProp build();
- method public androidx.wear.tiles.builders.DimensionBuilders.SpProp.Builder setValue(@Dimension(unit=androidx.annotation.Dimension.SP) int);
- }
-
- public static final class DimensionBuilders.WrappedDimensionProp implements androidx.wear.tiles.builders.DimensionBuilders.ContainerDimension {
- method public static androidx.wear.tiles.builders.DimensionBuilders.WrappedDimensionProp.Builder builder();
- }
-
- public static final class DimensionBuilders.WrappedDimensionProp.Builder implements androidx.wear.tiles.builders.DimensionBuilders.ContainerDimension.Builder {
- method public androidx.wear.tiles.builders.DimensionBuilders.WrappedDimensionProp build();
- }
-
- public final class LayoutElementBuilders {
- field public static final int ARC_ANCHOR_CENTER = 2; // 0x2
- field public static final int ARC_ANCHOR_END = 3; // 0x3
- field public static final int ARC_ANCHOR_START = 1; // 0x1
- field public static final int ARC_ANCHOR_UNDEFINED = 0; // 0x0
- field public static final int CONTENT_SCALE_MODE_CROP = 2; // 0x2
- field public static final int CONTENT_SCALE_MODE_FILL_BOUNDS = 3; // 0x3
- field public static final int CONTENT_SCALE_MODE_FIT = 1; // 0x1
- field public static final int CONTENT_SCALE_MODE_UNDEFINED = 0; // 0x0
- field public static final int FONT_WEIGHT_BOLD = 700; // 0x2bc
- field public static final int FONT_WEIGHT_NORMAL = 400; // 0x190
- field public static final int FONT_WEIGHT_UNDEFINED = 0; // 0x0
- field public static final int HALIGN_CENTER = 2; // 0x2
- field public static final int HALIGN_END = 5; // 0x5
- field public static final int HALIGN_LEFT = 1; // 0x1
- field public static final int HALIGN_RIGHT = 3; // 0x3
- field public static final int HALIGN_START = 4; // 0x4
- field public static final int HALIGN_UNDEFINED = 0; // 0x0
- field public static final int TEXT_ALIGN_CENTER = 2; // 0x2
- field public static final int TEXT_ALIGN_END = 3; // 0x3
- field public static final int TEXT_ALIGN_START = 1; // 0x1
- field public static final int TEXT_ALIGN_UNDEFINED = 0; // 0x0
- field public static final int TEXT_OVERFLOW_ELLIPSIZE_END = 2; // 0x2
- field public static final int TEXT_OVERFLOW_TRUNCATE = 1; // 0x1
- field public static final int TEXT_OVERFLOW_UNDEFINED = 0; // 0x0
- field public static final int VALIGN_BOTTOM = 3; // 0x3
- field public static final int VALIGN_CENTER = 2; // 0x2
- field public static final int VALIGN_TOP = 1; // 0x1
- field public static final int VALIGN_UNDEFINED = 0; // 0x0
- }
-
- public static final class LayoutElementBuilders.Arc implements androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement {
- method public static androidx.wear.tiles.builders.LayoutElementBuilders.Arc.Builder builder();
- }
-
- public static final class LayoutElementBuilders.Arc.Builder implements androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement.Builder {
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Arc.Builder addContent(androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Arc.Builder addContent(androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Arc build();
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Arc.Builder setAnchorAngle(androidx.wear.tiles.builders.DimensionBuilders.DegreesProp);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Arc.Builder setAnchorAngle(androidx.wear.tiles.builders.DimensionBuilders.DegreesProp.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Arc.Builder setAnchorType(int);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Arc.Builder setLength(androidx.wear.tiles.builders.DimensionBuilders.DegreesProp);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Arc.Builder setLength(androidx.wear.tiles.builders.DimensionBuilders.DegreesProp.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Arc.Builder setRotateContents(boolean);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Arc.Builder setThickness(androidx.wear.tiles.builders.DimensionBuilders.DpProp);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Arc.Builder setThickness(androidx.wear.tiles.builders.DimensionBuilders.DpProp.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Arc.Builder setVerticalAlign(int);
- }
-
- public static final class LayoutElementBuilders.Audible implements androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement {
- method public static androidx.wear.tiles.builders.LayoutElementBuilders.Audible.Builder builder();
- }
-
- public static final class LayoutElementBuilders.Audible.Builder implements androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement.Builder {
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Audible build();
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Audible.Builder setAccessibilityLabel(String);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Audible.Builder setContent(androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Audible.Builder setContent(androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement.Builder);
- }
-
- public static final class LayoutElementBuilders.Border {
- method public static androidx.wear.tiles.builders.LayoutElementBuilders.Border.Builder builder();
- }
-
- public static final class LayoutElementBuilders.Border.Builder {
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Border build();
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Border.Builder setColor(androidx.wear.tiles.builders.ColorBuilders.ColorProp);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Border.Builder setColor(androidx.wear.tiles.builders.ColorBuilders.ColorProp.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Border.Builder setWidth(androidx.wear.tiles.builders.DimensionBuilders.DpProp);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Border.Builder setWidth(androidx.wear.tiles.builders.DimensionBuilders.DpProp.Builder);
- }
-
- public static final class LayoutElementBuilders.Box implements androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement {
- method public static androidx.wear.tiles.builders.LayoutElementBuilders.Box.Builder builder();
- }
-
- public static final class LayoutElementBuilders.Box.Builder implements androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement.Builder {
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Box.Builder addContent(androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Box.Builder addContent(androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Box build();
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Box.Builder setHeight(androidx.wear.tiles.builders.DimensionBuilders.ContainerDimension);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Box.Builder setHeight(androidx.wear.tiles.builders.DimensionBuilders.ContainerDimension.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Box.Builder setHorizontalAlignment(int);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Box.Builder setStyle(androidx.wear.tiles.builders.LayoutElementBuilders.BoxStyle);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Box.Builder setStyle(androidx.wear.tiles.builders.LayoutElementBuilders.BoxStyle.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Box.Builder setVerticalAlignment(int);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Box.Builder setWidth(androidx.wear.tiles.builders.DimensionBuilders.ContainerDimension);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Box.Builder setWidth(androidx.wear.tiles.builders.DimensionBuilders.ContainerDimension.Builder);
- }
-
- public static final class LayoutElementBuilders.BoxStyle {
- method public static androidx.wear.tiles.builders.LayoutElementBuilders.BoxStyle.Builder builder();
- }
-
- public static final class LayoutElementBuilders.BoxStyle.Builder {
- method public androidx.wear.tiles.builders.LayoutElementBuilders.BoxStyle build();
- method public androidx.wear.tiles.builders.LayoutElementBuilders.BoxStyle.Builder setBackgroundColor(androidx.wear.tiles.builders.ColorBuilders.ColorProp);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.BoxStyle.Builder setBackgroundColor(androidx.wear.tiles.builders.ColorBuilders.ColorProp.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.BoxStyle.Builder setBorder(androidx.wear.tiles.builders.LayoutElementBuilders.Border);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.BoxStyle.Builder setBorder(androidx.wear.tiles.builders.LayoutElementBuilders.Border.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.BoxStyle.Builder setCorner(androidx.wear.tiles.builders.LayoutElementBuilders.Corner);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.BoxStyle.Builder setCorner(androidx.wear.tiles.builders.LayoutElementBuilders.Corner.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.BoxStyle.Builder setPadding(androidx.wear.tiles.builders.LayoutElementBuilders.Padding);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.BoxStyle.Builder setPadding(androidx.wear.tiles.builders.LayoutElementBuilders.Padding.Builder);
- }
-
- public static final class LayoutElementBuilders.Clickable implements androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement {
- method public static androidx.wear.tiles.builders.LayoutElementBuilders.Clickable.Builder builder();
- }
-
- public static final class LayoutElementBuilders.Clickable.Builder implements androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement.Builder {
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Clickable build();
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Clickable.Builder setContent(androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Clickable.Builder setContent(androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Clickable.Builder setId(String);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Clickable.Builder setOnClick(androidx.wear.tiles.builders.ActionBuilders.Action);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Clickable.Builder setOnClick(androidx.wear.tiles.builders.ActionBuilders.Action.Builder);
- }
-
- public static final class LayoutElementBuilders.Column implements androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement {
- method public static androidx.wear.tiles.builders.LayoutElementBuilders.Column.Builder builder();
- }
-
- public static final class LayoutElementBuilders.Column.Builder implements androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement.Builder {
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Column.Builder addContent(androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Column.Builder addContent(androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Column build();
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Column.Builder setHeight(androidx.wear.tiles.builders.DimensionBuilders.ContainerDimension);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Column.Builder setHeight(androidx.wear.tiles.builders.DimensionBuilders.ContainerDimension.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Column.Builder setHorizontalAlignment(int);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Column.Builder setWidth(androidx.wear.tiles.builders.DimensionBuilders.ContainerDimension);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Column.Builder setWidth(androidx.wear.tiles.builders.DimensionBuilders.ContainerDimension.Builder);
- }
-
- public static final class LayoutElementBuilders.Corner {
- method public static androidx.wear.tiles.builders.LayoutElementBuilders.Corner.Builder builder();
- }
-
- public static final class LayoutElementBuilders.Corner.Builder {
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Corner build();
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Corner.Builder setRadius(androidx.wear.tiles.builders.DimensionBuilders.DpProp);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Corner.Builder setRadius(androidx.wear.tiles.builders.DimensionBuilders.DpProp.Builder);
- }
-
- public static final class LayoutElementBuilders.FontStyle {
- method public static androidx.wear.tiles.builders.LayoutElementBuilders.FontStyle.Builder builder();
- }
-
- public static final class LayoutElementBuilders.FontStyle.Builder {
- method public androidx.wear.tiles.builders.LayoutElementBuilders.FontStyle build();
- method @Deprecated public androidx.wear.tiles.builders.LayoutElementBuilders.FontStyle.Builder setBold(boolean);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.FontStyle.Builder setColor(androidx.wear.tiles.builders.ColorBuilders.ColorProp);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.FontStyle.Builder setColor(androidx.wear.tiles.builders.ColorBuilders.ColorProp.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.FontStyle.Builder setItalic(boolean);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.FontStyle.Builder setSize(androidx.wear.tiles.builders.DimensionBuilders.SpProp);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.FontStyle.Builder setSize(androidx.wear.tiles.builders.DimensionBuilders.SpProp.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.FontStyle.Builder setUnderline(boolean);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.FontStyle.Builder setWeight(int);
- }
-
- public static class LayoutElementBuilders.FontStyles {
- method public androidx.wear.tiles.builders.LayoutElementBuilders.FontStyle body1();
- method public androidx.wear.tiles.builders.LayoutElementBuilders.FontStyle body2();
- method public androidx.wear.tiles.builders.LayoutElementBuilders.FontStyle button();
- method public androidx.wear.tiles.builders.LayoutElementBuilders.FontStyle caption1();
- method public androidx.wear.tiles.builders.LayoutElementBuilders.FontStyle caption2();
- method public androidx.wear.tiles.builders.LayoutElementBuilders.FontStyle display1();
- method public androidx.wear.tiles.builders.LayoutElementBuilders.FontStyle display2();
- method public androidx.wear.tiles.builders.LayoutElementBuilders.FontStyle display3();
- method public androidx.wear.tiles.builders.LayoutElementBuilders.FontStyle title1();
- method public androidx.wear.tiles.builders.LayoutElementBuilders.FontStyle title2();
- method public androidx.wear.tiles.builders.LayoutElementBuilders.FontStyle title3();
- method public static androidx.wear.tiles.builders.LayoutElementBuilders.FontStyles withDeviceParameters(androidx.wear.tiles.readers.DeviceParametersReaders.DeviceParameters);
- }
-
- public static final class LayoutElementBuilders.Image implements androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement {
- method public static androidx.wear.tiles.builders.LayoutElementBuilders.Image.Builder builder();
- }
-
- public static final class LayoutElementBuilders.Image.Builder implements androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement.Builder {
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Image build();
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Image.Builder setContentScaleMode(int);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Image.Builder setHeight(androidx.wear.tiles.builders.DimensionBuilders.ImageDimension);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Image.Builder setHeight(androidx.wear.tiles.builders.DimensionBuilders.ImageDimension.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Image.Builder setResourceId(String);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Image.Builder setWidth(androidx.wear.tiles.builders.DimensionBuilders.ImageDimension);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Image.Builder setWidth(androidx.wear.tiles.builders.DimensionBuilders.ImageDimension.Builder);
- }
-
- public static interface LayoutElementBuilders.LayoutElement {
- }
-
- public static interface LayoutElementBuilders.LayoutElement.Builder {
- method public androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement build();
- }
-
- public static final class LayoutElementBuilders.Line implements androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement {
- method public static androidx.wear.tiles.builders.LayoutElementBuilders.Line.Builder builder();
- }
-
- public static final class LayoutElementBuilders.Line.Builder implements androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement.Builder {
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Line build();
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Line.Builder setLength(androidx.wear.tiles.builders.DimensionBuilders.LinearOrAngularDimension);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Line.Builder setLength(androidx.wear.tiles.builders.DimensionBuilders.LinearOrAngularDimension.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Line.Builder setStyle(androidx.wear.tiles.builders.LayoutElementBuilders.LineStyle);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Line.Builder setStyle(androidx.wear.tiles.builders.LayoutElementBuilders.LineStyle.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Line.Builder setThickness(androidx.wear.tiles.builders.DimensionBuilders.DpProp);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Line.Builder setThickness(androidx.wear.tiles.builders.DimensionBuilders.DpProp.Builder);
- }
-
- public static final class LayoutElementBuilders.LineStyle {
- method public static androidx.wear.tiles.builders.LayoutElementBuilders.LineStyle.Builder builder();
- }
-
- public static final class LayoutElementBuilders.LineStyle.Builder {
- method public androidx.wear.tiles.builders.LayoutElementBuilders.LineStyle build();
- method public androidx.wear.tiles.builders.LayoutElementBuilders.LineStyle.Builder setColor(androidx.wear.tiles.builders.ColorBuilders.ColorProp);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.LineStyle.Builder setColor(androidx.wear.tiles.builders.ColorBuilders.ColorProp.Builder);
- }
-
- public static final class LayoutElementBuilders.Padding {
- method public static androidx.wear.tiles.builders.LayoutElementBuilders.Padding.Builder builder();
- }
-
- public static final class LayoutElementBuilders.Padding.Builder {
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Padding build();
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Padding.Builder setBottom(androidx.wear.tiles.builders.DimensionBuilders.DpProp);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Padding.Builder setBottom(androidx.wear.tiles.builders.DimensionBuilders.DpProp.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Padding.Builder setEnd(androidx.wear.tiles.builders.DimensionBuilders.DpProp);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Padding.Builder setEnd(androidx.wear.tiles.builders.DimensionBuilders.DpProp.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Padding.Builder setRtlAware(boolean);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Padding.Builder setStart(androidx.wear.tiles.builders.DimensionBuilders.DpProp);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Padding.Builder setStart(androidx.wear.tiles.builders.DimensionBuilders.DpProp.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Padding.Builder setTop(androidx.wear.tiles.builders.DimensionBuilders.DpProp);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Padding.Builder setTop(androidx.wear.tiles.builders.DimensionBuilders.DpProp.Builder);
- }
-
- public static final class LayoutElementBuilders.Row implements androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement {
- method public static androidx.wear.tiles.builders.LayoutElementBuilders.Row.Builder builder();
- }
-
- public static final class LayoutElementBuilders.Row.Builder implements androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement.Builder {
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Row.Builder addContent(androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Row.Builder addContent(androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Row build();
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Row.Builder setHeight(androidx.wear.tiles.builders.DimensionBuilders.ContainerDimension);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Row.Builder setHeight(androidx.wear.tiles.builders.DimensionBuilders.ContainerDimension.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Row.Builder setVerticalAlignment(int);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Row.Builder setWidth(androidx.wear.tiles.builders.DimensionBuilders.ContainerDimension);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Row.Builder setWidth(androidx.wear.tiles.builders.DimensionBuilders.ContainerDimension.Builder);
- }
-
- public static final class LayoutElementBuilders.Spacer implements androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement {
- method public static androidx.wear.tiles.builders.LayoutElementBuilders.Spacer.Builder builder();
- }
-
- public static final class LayoutElementBuilders.Spacer.Builder implements androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement.Builder {
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Spacer build();
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Spacer.Builder setHeight(androidx.wear.tiles.builders.DimensionBuilders.DpProp);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Spacer.Builder setHeight(androidx.wear.tiles.builders.DimensionBuilders.DpProp.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Spacer.Builder setWidth(androidx.wear.tiles.builders.DimensionBuilders.LinearOrAngularDimension);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Spacer.Builder setWidth(androidx.wear.tiles.builders.DimensionBuilders.LinearOrAngularDimension.Builder);
- }
-
- public static interface LayoutElementBuilders.Span {
- }
-
- public static interface LayoutElementBuilders.Span.Builder {
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Span build();
- }
-
- public static final class LayoutElementBuilders.Spannable implements androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement {
- method public static androidx.wear.tiles.builders.LayoutElementBuilders.Spannable.Builder builder();
- }
-
- public static final class LayoutElementBuilders.Spannable.Builder implements androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement.Builder {
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Spannable.Builder addSpan(androidx.wear.tiles.builders.LayoutElementBuilders.Span);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Spannable.Builder addSpan(androidx.wear.tiles.builders.LayoutElementBuilders.Span.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Spannable build();
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Spannable.Builder setStyle(androidx.wear.tiles.builders.LayoutElementBuilders.SpannableStyle);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Spannable.Builder setStyle(androidx.wear.tiles.builders.LayoutElementBuilders.SpannableStyle.Builder);
- }
-
- public static final class LayoutElementBuilders.SpannableStyle {
- method public static androidx.wear.tiles.builders.LayoutElementBuilders.SpannableStyle.Builder builder();
- }
-
- public static final class LayoutElementBuilders.SpannableStyle.Builder {
- method public androidx.wear.tiles.builders.LayoutElementBuilders.SpannableStyle build();
- method public androidx.wear.tiles.builders.LayoutElementBuilders.SpannableStyle.Builder setMaxLines(@IntRange(from=0) int);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.SpannableStyle.Builder setMultilineAlignment(int);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.SpannableStyle.Builder setOverflow(int);
- }
-
- public static final class LayoutElementBuilders.Text implements androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement androidx.wear.tiles.builders.LayoutElementBuilders.Span {
- method public static androidx.wear.tiles.builders.LayoutElementBuilders.Text.Builder builder();
- }
-
- public static final class LayoutElementBuilders.Text.Builder implements androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement.Builder androidx.wear.tiles.builders.LayoutElementBuilders.Span.Builder {
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Text build();
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Text.Builder setFontStyle(androidx.wear.tiles.builders.LayoutElementBuilders.FontStyle);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Text.Builder setFontStyle(androidx.wear.tiles.builders.LayoutElementBuilders.FontStyle.Builder);
- method @Deprecated public androidx.wear.tiles.builders.LayoutElementBuilders.Text.Builder setStyle(androidx.wear.tiles.builders.LayoutElementBuilders.TextStyle);
- method @Deprecated public androidx.wear.tiles.builders.LayoutElementBuilders.Text.Builder setStyle(androidx.wear.tiles.builders.LayoutElementBuilders.TextStyle.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Text.Builder setText(String);
- }
-
- public static final class LayoutElementBuilders.TextStyle {
- method public static androidx.wear.tiles.builders.LayoutElementBuilders.TextStyle.Builder builder();
- }
-
- public static final class LayoutElementBuilders.TextStyle.Builder {
- method public androidx.wear.tiles.builders.LayoutElementBuilders.TextStyle build();
- method @Deprecated public androidx.wear.tiles.builders.LayoutElementBuilders.TextStyle.Builder setColor(androidx.wear.tiles.builders.ColorBuilders.ColorProp);
- method @Deprecated public androidx.wear.tiles.builders.LayoutElementBuilders.TextStyle.Builder setColor(androidx.wear.tiles.builders.ColorBuilders.ColorProp.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.TextStyle.Builder setMaxLines(@IntRange(from=0) int);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.TextStyle.Builder setMultilineAlignment(int);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.TextStyle.Builder setOverflow(int);
- }
-
- public final class ResourceBuilders {
- field public static final int IMAGE_FORMAT_RGB_565 = 1; // 0x1
- field public static final int IMAGE_FORMAT_UNDEFINED = 0; // 0x0
- }
-
- public static final class ResourceBuilders.AndroidImageResourceByResId {
- method public static androidx.wear.tiles.builders.ResourceBuilders.AndroidImageResourceByResId.Builder builder();
- }
-
- public static final class ResourceBuilders.AndroidImageResourceByResId.Builder {
- method public androidx.wear.tiles.builders.ResourceBuilders.AndroidImageResourceByResId build();
- method public androidx.wear.tiles.builders.ResourceBuilders.AndroidImageResourceByResId.Builder setResourceId(@DrawableRes int);
- }
-
- public static final class ResourceBuilders.ImageResource {
- method public static androidx.wear.tiles.builders.ResourceBuilders.ImageResource.Builder builder();
- }
-
- public static final class ResourceBuilders.ImageResource.Builder {
- method public androidx.wear.tiles.builders.ResourceBuilders.ImageResource build();
- method public androidx.wear.tiles.builders.ResourceBuilders.ImageResource.Builder setAndroidResourceByResid(androidx.wear.tiles.builders.ResourceBuilders.AndroidImageResourceByResId);
- method public androidx.wear.tiles.builders.ResourceBuilders.ImageResource.Builder setAndroidResourceByResid(androidx.wear.tiles.builders.ResourceBuilders.AndroidImageResourceByResId.Builder);
- method public androidx.wear.tiles.builders.ResourceBuilders.ImageResource.Builder setInlineResource(androidx.wear.tiles.builders.ResourceBuilders.InlineImageResource);
- method public androidx.wear.tiles.builders.ResourceBuilders.ImageResource.Builder setInlineResource(androidx.wear.tiles.builders.ResourceBuilders.InlineImageResource.Builder);
- }
-
- public static final class ResourceBuilders.InlineImageResource {
- method public static androidx.wear.tiles.builders.ResourceBuilders.InlineImageResource.Builder builder();
- }
-
- public static final class ResourceBuilders.InlineImageResource.Builder {
- method public androidx.wear.tiles.builders.ResourceBuilders.InlineImageResource build();
- method public androidx.wear.tiles.builders.ResourceBuilders.InlineImageResource.Builder setData(byte[]);
- method public androidx.wear.tiles.builders.ResourceBuilders.InlineImageResource.Builder setFormat(int);
- method public androidx.wear.tiles.builders.ResourceBuilders.InlineImageResource.Builder setHeightPx(@Dimension(unit=androidx.annotation.Dimension.PX) int);
- method public androidx.wear.tiles.builders.ResourceBuilders.InlineImageResource.Builder setWidthPx(@Dimension(unit=androidx.annotation.Dimension.PX) int);
- }
-
- public static final class ResourceBuilders.Resources {
- method public static androidx.wear.tiles.builders.ResourceBuilders.Resources.Builder builder();
- }
-
- public static final class ResourceBuilders.Resources.Builder {
- method public androidx.wear.tiles.builders.ResourceBuilders.Resources.Builder addIdToImageMapping(String, androidx.wear.tiles.builders.ResourceBuilders.ImageResource);
- method public androidx.wear.tiles.builders.ResourceBuilders.Resources.Builder addIdToImageMapping(String, androidx.wear.tiles.builders.ResourceBuilders.ImageResource.Builder);
- method public androidx.wear.tiles.builders.ResourceBuilders.Resources build();
- method public androidx.wear.tiles.builders.ResourceBuilders.Resources.Builder setVersion(String);
- }
-
- public final class TileBuilders {
- }
-
- public static final class TileBuilders.Tile {
- method public static androidx.wear.tiles.builders.TileBuilders.Tile.Builder builder();
- }
-
- public static final class TileBuilders.Tile.Builder {
- method public androidx.wear.tiles.builders.TileBuilders.Tile build();
- method public androidx.wear.tiles.builders.TileBuilders.Tile.Builder setResourcesVersion(String);
- method public androidx.wear.tiles.builders.TileBuilders.Tile.Builder setTimeline(androidx.wear.tiles.builders.TimelineBuilders.Timeline);
- method public androidx.wear.tiles.builders.TileBuilders.Tile.Builder setTimeline(androidx.wear.tiles.builders.TimelineBuilders.Timeline.Builder);
- }
-
- public final class TimelineBuilders {
- }
-
- public static final class TimelineBuilders.TimeInterval {
- method public static androidx.wear.tiles.builders.TimelineBuilders.TimeInterval.Builder builder();
- }
-
- public static final class TimelineBuilders.TimeInterval.Builder {
- method public androidx.wear.tiles.builders.TimelineBuilders.TimeInterval build();
- method public androidx.wear.tiles.builders.TimelineBuilders.TimeInterval.Builder setEndMillis(long);
- method public androidx.wear.tiles.builders.TimelineBuilders.TimeInterval.Builder setStartMillis(long);
- }
-
- public static final class TimelineBuilders.Timeline {
- method public static androidx.wear.tiles.builders.TimelineBuilders.Timeline.Builder builder();
- }
-
- public static final class TimelineBuilders.Timeline.Builder {
- method public androidx.wear.tiles.builders.TimelineBuilders.Timeline.Builder addTimelineEntry(androidx.wear.tiles.builders.TimelineBuilders.TimelineEntry);
- method public androidx.wear.tiles.builders.TimelineBuilders.Timeline.Builder addTimelineEntry(androidx.wear.tiles.builders.TimelineBuilders.TimelineEntry.Builder);
- method public androidx.wear.tiles.builders.TimelineBuilders.Timeline build();
- }
-
- public static final class TimelineBuilders.TimelineEntry {
- method public static androidx.wear.tiles.builders.TimelineBuilders.TimelineEntry.Builder builder();
- }
-
- public static final class TimelineBuilders.TimelineEntry.Builder {
- method public androidx.wear.tiles.builders.TimelineBuilders.TimelineEntry build();
- method public androidx.wear.tiles.builders.TimelineBuilders.TimelineEntry.Builder setContent(androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement);
- method public androidx.wear.tiles.builders.TimelineBuilders.TimelineEntry.Builder setContent(androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement.Builder);
- method public androidx.wear.tiles.builders.TimelineBuilders.TimelineEntry.Builder setValidity(androidx.wear.tiles.builders.TimelineBuilders.TimeInterval);
- method public androidx.wear.tiles.builders.TimelineBuilders.TimelineEntry.Builder setValidity(androidx.wear.tiles.builders.TimelineBuilders.TimeInterval.Builder);
- }
-
-}
-
-package androidx.wear.tiles.readers {
-
- public class DeviceParametersReaders {
- field public static final int DEVICE_PLATFORM_UNDEFINED = 0; // 0x0
- field public static final int DEVICE_PLATFORM_WEAR_OS = 1; // 0x1
- field public static final int SCREEN_SHAPE_RECT = 2; // 0x2
- field public static final int SCREEN_SHAPE_ROUND = 1; // 0x1
- field public static final int SCREEN_SHAPE_UNDEFINED = 0; // 0x0
- }
-
- public static class DeviceParametersReaders.DeviceParameters {
- method public int getDevicePlatform();
- method @FloatRange(from=0.0, fromInclusive=false) public float getScreenDensity();
- method @Dimension(unit=androidx.annotation.Dimension.DP) public int getScreenHeightDp();
- method public int getScreenShape();
- method @Dimension(unit=androidx.annotation.Dimension.DP) public int getScreenWidthDp();
- }
-
- public class RequestReaders {
- }
-
- public static class RequestReaders.ResourcesRequest {
- method public java.util.List<java.lang.String!> getResourceIds();
- method public String getVersion();
- }
-
- public static class RequestReaders.TileRequest {
- method public String getClickableId();
- method public androidx.wear.tiles.readers.DeviceParametersReaders.DeviceParameters? getDeviceParameters();
- }
-
-}
-
diff --git a/wear/wear-tiles/api/res-current.txt b/wear/wear-tiles/api/res-current.txt
deleted file mode 100644
index e69de29..0000000
--- a/wear/wear-tiles/api/res-current.txt
+++ /dev/null
diff --git a/wear/wear-tiles/api/restricted_current.txt b/wear/wear-tiles/api/restricted_current.txt
deleted file mode 100644
index 85c4a7f..0000000
--- a/wear/wear-tiles/api/restricted_current.txt
+++ /dev/null
@@ -1,615 +0,0 @@
-// Signature format: 4.0
-package androidx.wear.tiles {
-
- public class SysUiTileUpdateRequester implements androidx.wear.tiles.TileUpdateRequester {
- ctor public SysUiTileUpdateRequester(android.content.Context);
- method public void requestUpdate(Class<? extends android.app.Service>);
- field public static final String ACTION_BIND_UPDATE_REQUESTER = "androidx.wear.tiles.action.BIND_UPDATE_REQUESTER";
- }
-
- public abstract class TileProviderService extends android.app.Service {
- ctor public TileProviderService();
- method public static androidx.wear.tiles.TileUpdateRequester getUpdater(android.content.Context);
- method public android.os.IBinder? onBind(android.content.Intent);
- method @MainThread protected abstract com.google.common.util.concurrent.ListenableFuture<androidx.wear.tiles.builders.ResourceBuilders.Resources!> onResourcesRequest(androidx.wear.tiles.readers.RequestReaders.ResourcesRequest);
- method @MainThread protected abstract com.google.common.util.concurrent.ListenableFuture<androidx.wear.tiles.builders.TileBuilders.Tile!> onTileRequest(androidx.wear.tiles.readers.RequestReaders.TileRequest);
- field public static final String ACTION_BIND_TILE_PROVIDER = "androidx.wear.tiles.action.BIND_TILE_PROVIDER";
- field public static final String EXTRA_CLICKABLE_ID = "androidx.wear.tiles.extra.CLICKABLE_ID";
- field public static final String METADATA_PREVIEW_KEY = "androidx.wear.tiles.PREVIEW";
- }
-
- public interface TileUpdateRequester {
- method public void requestUpdate(Class<? extends android.app.Service>);
- }
-
-}
-
-package androidx.wear.tiles.builders {
-
- public final class ActionBuilders {
- }
-
- public static interface ActionBuilders.Action {
- }
-
- public static interface ActionBuilders.Action.Builder {
- method public androidx.wear.tiles.builders.ActionBuilders.Action build();
- }
-
- public static final class ActionBuilders.AndroidActivity {
- method public static androidx.wear.tiles.builders.ActionBuilders.AndroidActivity.Builder builder();
- }
-
- public static final class ActionBuilders.AndroidActivity.Builder {
- method public androidx.wear.tiles.builders.ActionBuilders.AndroidActivity build();
- method public androidx.wear.tiles.builders.ActionBuilders.AndroidActivity.Builder setClassName(String);
- method public androidx.wear.tiles.builders.ActionBuilders.AndroidActivity.Builder setPackageName(String);
- }
-
- public static final class ActionBuilders.LaunchAction implements androidx.wear.tiles.builders.ActionBuilders.Action {
- method public static androidx.wear.tiles.builders.ActionBuilders.LaunchAction.Builder builder();
- }
-
- public static final class ActionBuilders.LaunchAction.Builder implements androidx.wear.tiles.builders.ActionBuilders.Action.Builder {
- method public androidx.wear.tiles.builders.ActionBuilders.LaunchAction build();
- method public androidx.wear.tiles.builders.ActionBuilders.LaunchAction.Builder setAndroidActivity(androidx.wear.tiles.builders.ActionBuilders.AndroidActivity);
- method public androidx.wear.tiles.builders.ActionBuilders.LaunchAction.Builder setAndroidActivity(androidx.wear.tiles.builders.ActionBuilders.AndroidActivity.Builder);
- }
-
- public static final class ActionBuilders.LoadAction implements androidx.wear.tiles.builders.ActionBuilders.Action {
- method public static androidx.wear.tiles.builders.ActionBuilders.LoadAction.Builder builder();
- }
-
- public static final class ActionBuilders.LoadAction.Builder implements androidx.wear.tiles.builders.ActionBuilders.Action.Builder {
- method public androidx.wear.tiles.builders.ActionBuilders.LoadAction build();
- }
-
- public final class ColorBuilders {
- method public static androidx.wear.tiles.builders.ColorBuilders.ColorProp argb(@ColorInt int);
- }
-
- public static final class ColorBuilders.ColorProp {
- method public static androidx.wear.tiles.builders.ColorBuilders.ColorProp.Builder builder();
- }
-
- public static final class ColorBuilders.ColorProp.Builder {
- method public androidx.wear.tiles.builders.ColorBuilders.ColorProp build();
- method public androidx.wear.tiles.builders.ColorBuilders.ColorProp.Builder setArgb(@ColorInt int);
- }
-
- public final class DimensionBuilders {
- method public static androidx.wear.tiles.builders.DimensionBuilders.DegreesProp degrees(float);
- method public static androidx.wear.tiles.builders.DimensionBuilders.DpProp dp(@Dimension(unit=androidx.annotation.Dimension.DP) float);
- method public static androidx.wear.tiles.builders.DimensionBuilders.ExpandedDimensionProp expand();
- method public static androidx.wear.tiles.builders.DimensionBuilders.SpProp sp(@Dimension(unit=androidx.annotation.Dimension.SP) int);
- method public static androidx.wear.tiles.builders.DimensionBuilders.WrappedDimensionProp wrap();
- }
-
- public static interface DimensionBuilders.ContainerDimension {
- }
-
- public static interface DimensionBuilders.ContainerDimension.Builder {
- method public androidx.wear.tiles.builders.DimensionBuilders.ContainerDimension build();
- }
-
- public static final class DimensionBuilders.DegreesProp implements androidx.wear.tiles.builders.DimensionBuilders.LinearOrAngularDimension {
- method public static androidx.wear.tiles.builders.DimensionBuilders.DegreesProp.Builder builder();
- }
-
- public static final class DimensionBuilders.DegreesProp.Builder implements androidx.wear.tiles.builders.DimensionBuilders.LinearOrAngularDimension.Builder {
- method public androidx.wear.tiles.builders.DimensionBuilders.DegreesProp build();
- method public androidx.wear.tiles.builders.DimensionBuilders.DegreesProp.Builder setValue(float);
- }
-
- public static final class DimensionBuilders.DpProp implements androidx.wear.tiles.builders.DimensionBuilders.ContainerDimension androidx.wear.tiles.builders.DimensionBuilders.ImageDimension androidx.wear.tiles.builders.DimensionBuilders.LinearOrAngularDimension {
- method public static androidx.wear.tiles.builders.DimensionBuilders.DpProp.Builder builder();
- }
-
- public static final class DimensionBuilders.DpProp.Builder implements androidx.wear.tiles.builders.DimensionBuilders.ContainerDimension.Builder androidx.wear.tiles.builders.DimensionBuilders.ImageDimension.Builder androidx.wear.tiles.builders.DimensionBuilders.LinearOrAngularDimension.Builder {
- method public androidx.wear.tiles.builders.DimensionBuilders.DpProp build();
- method public androidx.wear.tiles.builders.DimensionBuilders.DpProp.Builder setValue(@Dimension(unit=androidx.annotation.Dimension.DP) float);
- }
-
- public static final class DimensionBuilders.ExpandedDimensionProp implements androidx.wear.tiles.builders.DimensionBuilders.ContainerDimension androidx.wear.tiles.builders.DimensionBuilders.ImageDimension {
- method public static androidx.wear.tiles.builders.DimensionBuilders.ExpandedDimensionProp.Builder builder();
- }
-
- public static final class DimensionBuilders.ExpandedDimensionProp.Builder implements androidx.wear.tiles.builders.DimensionBuilders.ContainerDimension.Builder androidx.wear.tiles.builders.DimensionBuilders.ImageDimension.Builder {
- method public androidx.wear.tiles.builders.DimensionBuilders.ExpandedDimensionProp build();
- }
-
- public static interface DimensionBuilders.ImageDimension {
- }
-
- public static interface DimensionBuilders.ImageDimension.Builder {
- method public androidx.wear.tiles.builders.DimensionBuilders.ImageDimension build();
- }
-
- public static interface DimensionBuilders.LinearOrAngularDimension {
- }
-
- public static interface DimensionBuilders.LinearOrAngularDimension.Builder {
- method public androidx.wear.tiles.builders.DimensionBuilders.LinearOrAngularDimension build();
- }
-
- public static final class DimensionBuilders.ProportionalDimensionProp implements androidx.wear.tiles.builders.DimensionBuilders.ImageDimension {
- method public static androidx.wear.tiles.builders.DimensionBuilders.ProportionalDimensionProp.Builder builder();
- }
-
- public static final class DimensionBuilders.ProportionalDimensionProp.Builder implements androidx.wear.tiles.builders.DimensionBuilders.ImageDimension.Builder {
- method public androidx.wear.tiles.builders.DimensionBuilders.ProportionalDimensionProp build();
- method public androidx.wear.tiles.builders.DimensionBuilders.ProportionalDimensionProp.Builder setAspectRatioHeight(@IntRange(from=0) int);
- method public androidx.wear.tiles.builders.DimensionBuilders.ProportionalDimensionProp.Builder setAspectRatioWidth(@IntRange(from=0) int);
- }
-
- public static final class DimensionBuilders.SpProp {
- method public static androidx.wear.tiles.builders.DimensionBuilders.SpProp.Builder builder();
- }
-
- public static final class DimensionBuilders.SpProp.Builder {
- method public androidx.wear.tiles.builders.DimensionBuilders.SpProp build();
- method public androidx.wear.tiles.builders.DimensionBuilders.SpProp.Builder setValue(@Dimension(unit=androidx.annotation.Dimension.SP) int);
- }
-
- public static final class DimensionBuilders.WrappedDimensionProp implements androidx.wear.tiles.builders.DimensionBuilders.ContainerDimension {
- method public static androidx.wear.tiles.builders.DimensionBuilders.WrappedDimensionProp.Builder builder();
- }
-
- public static final class DimensionBuilders.WrappedDimensionProp.Builder implements androidx.wear.tiles.builders.DimensionBuilders.ContainerDimension.Builder {
- method public androidx.wear.tiles.builders.DimensionBuilders.WrappedDimensionProp build();
- }
-
- public final class LayoutElementBuilders {
- field public static final int ARC_ANCHOR_CENTER = 2; // 0x2
- field public static final int ARC_ANCHOR_END = 3; // 0x3
- field public static final int ARC_ANCHOR_START = 1; // 0x1
- field public static final int ARC_ANCHOR_UNDEFINED = 0; // 0x0
- field public static final int CONTENT_SCALE_MODE_CROP = 2; // 0x2
- field public static final int CONTENT_SCALE_MODE_FILL_BOUNDS = 3; // 0x3
- field public static final int CONTENT_SCALE_MODE_FIT = 1; // 0x1
- field public static final int CONTENT_SCALE_MODE_UNDEFINED = 0; // 0x0
- field public static final int FONT_WEIGHT_BOLD = 700; // 0x2bc
- field public static final int FONT_WEIGHT_NORMAL = 400; // 0x190
- field public static final int FONT_WEIGHT_UNDEFINED = 0; // 0x0
- field public static final int HALIGN_CENTER = 2; // 0x2
- field public static final int HALIGN_END = 5; // 0x5
- field public static final int HALIGN_LEFT = 1; // 0x1
- field public static final int HALIGN_RIGHT = 3; // 0x3
- field public static final int HALIGN_START = 4; // 0x4
- field public static final int HALIGN_UNDEFINED = 0; // 0x0
- field public static final int TEXT_ALIGN_CENTER = 2; // 0x2
- field public static final int TEXT_ALIGN_END = 3; // 0x3
- field public static final int TEXT_ALIGN_START = 1; // 0x1
- field public static final int TEXT_ALIGN_UNDEFINED = 0; // 0x0
- field public static final int TEXT_OVERFLOW_ELLIPSIZE_END = 2; // 0x2
- field public static final int TEXT_OVERFLOW_TRUNCATE = 1; // 0x1
- field public static final int TEXT_OVERFLOW_UNDEFINED = 0; // 0x0
- field public static final int VALIGN_BOTTOM = 3; // 0x3
- field public static final int VALIGN_CENTER = 2; // 0x2
- field public static final int VALIGN_TOP = 1; // 0x1
- field public static final int VALIGN_UNDEFINED = 0; // 0x0
- }
-
- public static final class LayoutElementBuilders.Arc implements androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement {
- method public static androidx.wear.tiles.builders.LayoutElementBuilders.Arc.Builder builder();
- }
-
- public static final class LayoutElementBuilders.Arc.Builder implements androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement.Builder {
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Arc.Builder addContent(androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Arc.Builder addContent(androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Arc build();
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Arc.Builder setAnchorAngle(androidx.wear.tiles.builders.DimensionBuilders.DegreesProp);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Arc.Builder setAnchorAngle(androidx.wear.tiles.builders.DimensionBuilders.DegreesProp.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Arc.Builder setAnchorType(int);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Arc.Builder setLength(androidx.wear.tiles.builders.DimensionBuilders.DegreesProp);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Arc.Builder setLength(androidx.wear.tiles.builders.DimensionBuilders.DegreesProp.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Arc.Builder setRotateContents(boolean);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Arc.Builder setThickness(androidx.wear.tiles.builders.DimensionBuilders.DpProp);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Arc.Builder setThickness(androidx.wear.tiles.builders.DimensionBuilders.DpProp.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Arc.Builder setVerticalAlign(int);
- }
-
- public static final class LayoutElementBuilders.Audible implements androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement {
- method public static androidx.wear.tiles.builders.LayoutElementBuilders.Audible.Builder builder();
- }
-
- public static final class LayoutElementBuilders.Audible.Builder implements androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement.Builder {
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Audible build();
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Audible.Builder setAccessibilityLabel(String);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Audible.Builder setContent(androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Audible.Builder setContent(androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement.Builder);
- }
-
- public static final class LayoutElementBuilders.Border {
- method public static androidx.wear.tiles.builders.LayoutElementBuilders.Border.Builder builder();
- }
-
- public static final class LayoutElementBuilders.Border.Builder {
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Border build();
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Border.Builder setColor(androidx.wear.tiles.builders.ColorBuilders.ColorProp);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Border.Builder setColor(androidx.wear.tiles.builders.ColorBuilders.ColorProp.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Border.Builder setWidth(androidx.wear.tiles.builders.DimensionBuilders.DpProp);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Border.Builder setWidth(androidx.wear.tiles.builders.DimensionBuilders.DpProp.Builder);
- }
-
- public static final class LayoutElementBuilders.Box implements androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement {
- method public static androidx.wear.tiles.builders.LayoutElementBuilders.Box.Builder builder();
- }
-
- public static final class LayoutElementBuilders.Box.Builder implements androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement.Builder {
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Box.Builder addContent(androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Box.Builder addContent(androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Box build();
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Box.Builder setHeight(androidx.wear.tiles.builders.DimensionBuilders.ContainerDimension);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Box.Builder setHeight(androidx.wear.tiles.builders.DimensionBuilders.ContainerDimension.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Box.Builder setHorizontalAlignment(int);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Box.Builder setStyle(androidx.wear.tiles.builders.LayoutElementBuilders.BoxStyle);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Box.Builder setStyle(androidx.wear.tiles.builders.LayoutElementBuilders.BoxStyle.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Box.Builder setVerticalAlignment(int);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Box.Builder setWidth(androidx.wear.tiles.builders.DimensionBuilders.ContainerDimension);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Box.Builder setWidth(androidx.wear.tiles.builders.DimensionBuilders.ContainerDimension.Builder);
- }
-
- public static final class LayoutElementBuilders.BoxStyle {
- method public static androidx.wear.tiles.builders.LayoutElementBuilders.BoxStyle.Builder builder();
- }
-
- public static final class LayoutElementBuilders.BoxStyle.Builder {
- method public androidx.wear.tiles.builders.LayoutElementBuilders.BoxStyle build();
- method public androidx.wear.tiles.builders.LayoutElementBuilders.BoxStyle.Builder setBackgroundColor(androidx.wear.tiles.builders.ColorBuilders.ColorProp);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.BoxStyle.Builder setBackgroundColor(androidx.wear.tiles.builders.ColorBuilders.ColorProp.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.BoxStyle.Builder setBorder(androidx.wear.tiles.builders.LayoutElementBuilders.Border);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.BoxStyle.Builder setBorder(androidx.wear.tiles.builders.LayoutElementBuilders.Border.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.BoxStyle.Builder setCorner(androidx.wear.tiles.builders.LayoutElementBuilders.Corner);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.BoxStyle.Builder setCorner(androidx.wear.tiles.builders.LayoutElementBuilders.Corner.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.BoxStyle.Builder setPadding(androidx.wear.tiles.builders.LayoutElementBuilders.Padding);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.BoxStyle.Builder setPadding(androidx.wear.tiles.builders.LayoutElementBuilders.Padding.Builder);
- }
-
- public static final class LayoutElementBuilders.Clickable implements androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement {
- method public static androidx.wear.tiles.builders.LayoutElementBuilders.Clickable.Builder builder();
- }
-
- public static final class LayoutElementBuilders.Clickable.Builder implements androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement.Builder {
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Clickable build();
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Clickable.Builder setContent(androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Clickable.Builder setContent(androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Clickable.Builder setId(String);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Clickable.Builder setOnClick(androidx.wear.tiles.builders.ActionBuilders.Action);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Clickable.Builder setOnClick(androidx.wear.tiles.builders.ActionBuilders.Action.Builder);
- }
-
- public static final class LayoutElementBuilders.Column implements androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement {
- method public static androidx.wear.tiles.builders.LayoutElementBuilders.Column.Builder builder();
- }
-
- public static final class LayoutElementBuilders.Column.Builder implements androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement.Builder {
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Column.Builder addContent(androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Column.Builder addContent(androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Column build();
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Column.Builder setHeight(androidx.wear.tiles.builders.DimensionBuilders.ContainerDimension);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Column.Builder setHeight(androidx.wear.tiles.builders.DimensionBuilders.ContainerDimension.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Column.Builder setHorizontalAlignment(int);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Column.Builder setWidth(androidx.wear.tiles.builders.DimensionBuilders.ContainerDimension);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Column.Builder setWidth(androidx.wear.tiles.builders.DimensionBuilders.ContainerDimension.Builder);
- }
-
- public static final class LayoutElementBuilders.Corner {
- method public static androidx.wear.tiles.builders.LayoutElementBuilders.Corner.Builder builder();
- }
-
- public static final class LayoutElementBuilders.Corner.Builder {
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Corner build();
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Corner.Builder setRadius(androidx.wear.tiles.builders.DimensionBuilders.DpProp);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Corner.Builder setRadius(androidx.wear.tiles.builders.DimensionBuilders.DpProp.Builder);
- }
-
- public static final class LayoutElementBuilders.FontStyle {
- method public static androidx.wear.tiles.builders.LayoutElementBuilders.FontStyle.Builder builder();
- }
-
- public static final class LayoutElementBuilders.FontStyle.Builder {
- method public androidx.wear.tiles.builders.LayoutElementBuilders.FontStyle build();
- method @Deprecated public androidx.wear.tiles.builders.LayoutElementBuilders.FontStyle.Builder setBold(boolean);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.FontStyle.Builder setColor(androidx.wear.tiles.builders.ColorBuilders.ColorProp);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.FontStyle.Builder setColor(androidx.wear.tiles.builders.ColorBuilders.ColorProp.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.FontStyle.Builder setItalic(boolean);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.FontStyle.Builder setSize(androidx.wear.tiles.builders.DimensionBuilders.SpProp);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.FontStyle.Builder setSize(androidx.wear.tiles.builders.DimensionBuilders.SpProp.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.FontStyle.Builder setUnderline(boolean);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.FontStyle.Builder setWeight(int);
- }
-
- public static class LayoutElementBuilders.FontStyles {
- method public androidx.wear.tiles.builders.LayoutElementBuilders.FontStyle body1();
- method public androidx.wear.tiles.builders.LayoutElementBuilders.FontStyle body2();
- method public androidx.wear.tiles.builders.LayoutElementBuilders.FontStyle button();
- method public androidx.wear.tiles.builders.LayoutElementBuilders.FontStyle caption1();
- method public androidx.wear.tiles.builders.LayoutElementBuilders.FontStyle caption2();
- method public androidx.wear.tiles.builders.LayoutElementBuilders.FontStyle display1();
- method public androidx.wear.tiles.builders.LayoutElementBuilders.FontStyle display2();
- method public androidx.wear.tiles.builders.LayoutElementBuilders.FontStyle display3();
- method public androidx.wear.tiles.builders.LayoutElementBuilders.FontStyle title1();
- method public androidx.wear.tiles.builders.LayoutElementBuilders.FontStyle title2();
- method public androidx.wear.tiles.builders.LayoutElementBuilders.FontStyle title3();
- method public static androidx.wear.tiles.builders.LayoutElementBuilders.FontStyles withDeviceParameters(androidx.wear.tiles.readers.DeviceParametersReaders.DeviceParameters);
- }
-
- public static final class LayoutElementBuilders.Image implements androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement {
- method public static androidx.wear.tiles.builders.LayoutElementBuilders.Image.Builder builder();
- }
-
- public static final class LayoutElementBuilders.Image.Builder implements androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement.Builder {
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Image build();
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Image.Builder setContentScaleMode(int);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Image.Builder setHeight(androidx.wear.tiles.builders.DimensionBuilders.ImageDimension);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Image.Builder setHeight(androidx.wear.tiles.builders.DimensionBuilders.ImageDimension.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Image.Builder setResourceId(String);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Image.Builder setWidth(androidx.wear.tiles.builders.DimensionBuilders.ImageDimension);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Image.Builder setWidth(androidx.wear.tiles.builders.DimensionBuilders.ImageDimension.Builder);
- }
-
- public static interface LayoutElementBuilders.LayoutElement {
- }
-
- public static interface LayoutElementBuilders.LayoutElement.Builder {
- method public androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement build();
- }
-
- public static final class LayoutElementBuilders.Line implements androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement {
- method public static androidx.wear.tiles.builders.LayoutElementBuilders.Line.Builder builder();
- }
-
- public static final class LayoutElementBuilders.Line.Builder implements androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement.Builder {
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Line build();
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Line.Builder setLength(androidx.wear.tiles.builders.DimensionBuilders.LinearOrAngularDimension);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Line.Builder setLength(androidx.wear.tiles.builders.DimensionBuilders.LinearOrAngularDimension.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Line.Builder setStyle(androidx.wear.tiles.builders.LayoutElementBuilders.LineStyle);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Line.Builder setStyle(androidx.wear.tiles.builders.LayoutElementBuilders.LineStyle.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Line.Builder setThickness(androidx.wear.tiles.builders.DimensionBuilders.DpProp);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Line.Builder setThickness(androidx.wear.tiles.builders.DimensionBuilders.DpProp.Builder);
- }
-
- public static final class LayoutElementBuilders.LineStyle {
- method public static androidx.wear.tiles.builders.LayoutElementBuilders.LineStyle.Builder builder();
- }
-
- public static final class LayoutElementBuilders.LineStyle.Builder {
- method public androidx.wear.tiles.builders.LayoutElementBuilders.LineStyle build();
- method public androidx.wear.tiles.builders.LayoutElementBuilders.LineStyle.Builder setColor(androidx.wear.tiles.builders.ColorBuilders.ColorProp);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.LineStyle.Builder setColor(androidx.wear.tiles.builders.ColorBuilders.ColorProp.Builder);
- }
-
- public static final class LayoutElementBuilders.Padding {
- method public static androidx.wear.tiles.builders.LayoutElementBuilders.Padding.Builder builder();
- }
-
- public static final class LayoutElementBuilders.Padding.Builder {
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Padding build();
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Padding.Builder setBottom(androidx.wear.tiles.builders.DimensionBuilders.DpProp);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Padding.Builder setBottom(androidx.wear.tiles.builders.DimensionBuilders.DpProp.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Padding.Builder setEnd(androidx.wear.tiles.builders.DimensionBuilders.DpProp);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Padding.Builder setEnd(androidx.wear.tiles.builders.DimensionBuilders.DpProp.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Padding.Builder setRtlAware(boolean);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Padding.Builder setStart(androidx.wear.tiles.builders.DimensionBuilders.DpProp);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Padding.Builder setStart(androidx.wear.tiles.builders.DimensionBuilders.DpProp.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Padding.Builder setTop(androidx.wear.tiles.builders.DimensionBuilders.DpProp);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Padding.Builder setTop(androidx.wear.tiles.builders.DimensionBuilders.DpProp.Builder);
- }
-
- public static final class LayoutElementBuilders.Row implements androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement {
- method public static androidx.wear.tiles.builders.LayoutElementBuilders.Row.Builder builder();
- }
-
- public static final class LayoutElementBuilders.Row.Builder implements androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement.Builder {
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Row.Builder addContent(androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Row.Builder addContent(androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Row build();
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Row.Builder setHeight(androidx.wear.tiles.builders.DimensionBuilders.ContainerDimension);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Row.Builder setHeight(androidx.wear.tiles.builders.DimensionBuilders.ContainerDimension.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Row.Builder setVerticalAlignment(int);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Row.Builder setWidth(androidx.wear.tiles.builders.DimensionBuilders.ContainerDimension);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Row.Builder setWidth(androidx.wear.tiles.builders.DimensionBuilders.ContainerDimension.Builder);
- }
-
- public static final class LayoutElementBuilders.Spacer implements androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement {
- method public static androidx.wear.tiles.builders.LayoutElementBuilders.Spacer.Builder builder();
- }
-
- public static final class LayoutElementBuilders.Spacer.Builder implements androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement.Builder {
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Spacer build();
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Spacer.Builder setHeight(androidx.wear.tiles.builders.DimensionBuilders.DpProp);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Spacer.Builder setHeight(androidx.wear.tiles.builders.DimensionBuilders.DpProp.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Spacer.Builder setWidth(androidx.wear.tiles.builders.DimensionBuilders.LinearOrAngularDimension);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Spacer.Builder setWidth(androidx.wear.tiles.builders.DimensionBuilders.LinearOrAngularDimension.Builder);
- }
-
- public static interface LayoutElementBuilders.Span {
- }
-
- public static interface LayoutElementBuilders.Span.Builder {
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Span build();
- }
-
- public static final class LayoutElementBuilders.Spannable implements androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement {
- method public static androidx.wear.tiles.builders.LayoutElementBuilders.Spannable.Builder builder();
- }
-
- public static final class LayoutElementBuilders.Spannable.Builder implements androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement.Builder {
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Spannable.Builder addSpan(androidx.wear.tiles.builders.LayoutElementBuilders.Span);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Spannable.Builder addSpan(androidx.wear.tiles.builders.LayoutElementBuilders.Span.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Spannable build();
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Spannable.Builder setStyle(androidx.wear.tiles.builders.LayoutElementBuilders.SpannableStyle);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Spannable.Builder setStyle(androidx.wear.tiles.builders.LayoutElementBuilders.SpannableStyle.Builder);
- }
-
- public static final class LayoutElementBuilders.SpannableStyle {
- method public static androidx.wear.tiles.builders.LayoutElementBuilders.SpannableStyle.Builder builder();
- }
-
- public static final class LayoutElementBuilders.SpannableStyle.Builder {
- method public androidx.wear.tiles.builders.LayoutElementBuilders.SpannableStyle build();
- method public androidx.wear.tiles.builders.LayoutElementBuilders.SpannableStyle.Builder setMaxLines(@IntRange(from=0) int);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.SpannableStyle.Builder setMultilineAlignment(int);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.SpannableStyle.Builder setOverflow(int);
- }
-
- public static final class LayoutElementBuilders.Text implements androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement androidx.wear.tiles.builders.LayoutElementBuilders.Span {
- method public static androidx.wear.tiles.builders.LayoutElementBuilders.Text.Builder builder();
- }
-
- public static final class LayoutElementBuilders.Text.Builder implements androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement.Builder androidx.wear.tiles.builders.LayoutElementBuilders.Span.Builder {
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Text build();
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Text.Builder setFontStyle(androidx.wear.tiles.builders.LayoutElementBuilders.FontStyle);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Text.Builder setFontStyle(androidx.wear.tiles.builders.LayoutElementBuilders.FontStyle.Builder);
- method @Deprecated public androidx.wear.tiles.builders.LayoutElementBuilders.Text.Builder setStyle(androidx.wear.tiles.builders.LayoutElementBuilders.TextStyle);
- method @Deprecated public androidx.wear.tiles.builders.LayoutElementBuilders.Text.Builder setStyle(androidx.wear.tiles.builders.LayoutElementBuilders.TextStyle.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.Text.Builder setText(String);
- }
-
- public static final class LayoutElementBuilders.TextStyle {
- method public static androidx.wear.tiles.builders.LayoutElementBuilders.TextStyle.Builder builder();
- }
-
- public static final class LayoutElementBuilders.TextStyle.Builder {
- method public androidx.wear.tiles.builders.LayoutElementBuilders.TextStyle build();
- method @Deprecated public androidx.wear.tiles.builders.LayoutElementBuilders.TextStyle.Builder setColor(androidx.wear.tiles.builders.ColorBuilders.ColorProp);
- method @Deprecated public androidx.wear.tiles.builders.LayoutElementBuilders.TextStyle.Builder setColor(androidx.wear.tiles.builders.ColorBuilders.ColorProp.Builder);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.TextStyle.Builder setMaxLines(@IntRange(from=0) int);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.TextStyle.Builder setMultilineAlignment(int);
- method public androidx.wear.tiles.builders.LayoutElementBuilders.TextStyle.Builder setOverflow(int);
- }
-
- public final class ResourceBuilders {
- field public static final int IMAGE_FORMAT_RGB_565 = 1; // 0x1
- field public static final int IMAGE_FORMAT_UNDEFINED = 0; // 0x0
- }
-
- public static final class ResourceBuilders.AndroidImageResourceByResId {
- method public static androidx.wear.tiles.builders.ResourceBuilders.AndroidImageResourceByResId.Builder builder();
- }
-
- public static final class ResourceBuilders.AndroidImageResourceByResId.Builder {
- method public androidx.wear.tiles.builders.ResourceBuilders.AndroidImageResourceByResId build();
- method public androidx.wear.tiles.builders.ResourceBuilders.AndroidImageResourceByResId.Builder setResourceId(@DrawableRes int);
- }
-
- public static final class ResourceBuilders.ImageResource {
- method public static androidx.wear.tiles.builders.ResourceBuilders.ImageResource.Builder builder();
- }
-
- public static final class ResourceBuilders.ImageResource.Builder {
- method public androidx.wear.tiles.builders.ResourceBuilders.ImageResource build();
- method public androidx.wear.tiles.builders.ResourceBuilders.ImageResource.Builder setAndroidResourceByResid(androidx.wear.tiles.builders.ResourceBuilders.AndroidImageResourceByResId);
- method public androidx.wear.tiles.builders.ResourceBuilders.ImageResource.Builder setAndroidResourceByResid(androidx.wear.tiles.builders.ResourceBuilders.AndroidImageResourceByResId.Builder);
- method public androidx.wear.tiles.builders.ResourceBuilders.ImageResource.Builder setInlineResource(androidx.wear.tiles.builders.ResourceBuilders.InlineImageResource);
- method public androidx.wear.tiles.builders.ResourceBuilders.ImageResource.Builder setInlineResource(androidx.wear.tiles.builders.ResourceBuilders.InlineImageResource.Builder);
- }
-
- public static final class ResourceBuilders.InlineImageResource {
- method public static androidx.wear.tiles.builders.ResourceBuilders.InlineImageResource.Builder builder();
- }
-
- public static final class ResourceBuilders.InlineImageResource.Builder {
- method public androidx.wear.tiles.builders.ResourceBuilders.InlineImageResource build();
- method public androidx.wear.tiles.builders.ResourceBuilders.InlineImageResource.Builder setData(byte[]);
- method public androidx.wear.tiles.builders.ResourceBuilders.InlineImageResource.Builder setFormat(int);
- method public androidx.wear.tiles.builders.ResourceBuilders.InlineImageResource.Builder setHeightPx(@Dimension(unit=androidx.annotation.Dimension.PX) int);
- method public androidx.wear.tiles.builders.ResourceBuilders.InlineImageResource.Builder setWidthPx(@Dimension(unit=androidx.annotation.Dimension.PX) int);
- }
-
- public static final class ResourceBuilders.Resources {
- method public static androidx.wear.tiles.builders.ResourceBuilders.Resources.Builder builder();
- }
-
- public static final class ResourceBuilders.Resources.Builder {
- method public androidx.wear.tiles.builders.ResourceBuilders.Resources.Builder addIdToImageMapping(String, androidx.wear.tiles.builders.ResourceBuilders.ImageResource);
- method public androidx.wear.tiles.builders.ResourceBuilders.Resources.Builder addIdToImageMapping(String, androidx.wear.tiles.builders.ResourceBuilders.ImageResource.Builder);
- method public androidx.wear.tiles.builders.ResourceBuilders.Resources build();
- method public androidx.wear.tiles.builders.ResourceBuilders.Resources.Builder setVersion(String);
- }
-
- public final class TileBuilders {
- }
-
- public static final class TileBuilders.Tile {
- method public static androidx.wear.tiles.builders.TileBuilders.Tile.Builder builder();
- }
-
- public static final class TileBuilders.Tile.Builder {
- method public androidx.wear.tiles.builders.TileBuilders.Tile build();
- method public androidx.wear.tiles.builders.TileBuilders.Tile.Builder setResourcesVersion(String);
- method public androidx.wear.tiles.builders.TileBuilders.Tile.Builder setTimeline(androidx.wear.tiles.builders.TimelineBuilders.Timeline);
- method public androidx.wear.tiles.builders.TileBuilders.Tile.Builder setTimeline(androidx.wear.tiles.builders.TimelineBuilders.Timeline.Builder);
- }
-
- public final class TimelineBuilders {
- }
-
- public static final class TimelineBuilders.TimeInterval {
- method public static androidx.wear.tiles.builders.TimelineBuilders.TimeInterval.Builder builder();
- }
-
- public static final class TimelineBuilders.TimeInterval.Builder {
- method public androidx.wear.tiles.builders.TimelineBuilders.TimeInterval build();
- method public androidx.wear.tiles.builders.TimelineBuilders.TimeInterval.Builder setEndMillis(long);
- method public androidx.wear.tiles.builders.TimelineBuilders.TimeInterval.Builder setStartMillis(long);
- }
-
- public static final class TimelineBuilders.Timeline {
- method public static androidx.wear.tiles.builders.TimelineBuilders.Timeline.Builder builder();
- }
-
- public static final class TimelineBuilders.Timeline.Builder {
- method public androidx.wear.tiles.builders.TimelineBuilders.Timeline.Builder addTimelineEntry(androidx.wear.tiles.builders.TimelineBuilders.TimelineEntry);
- method public androidx.wear.tiles.builders.TimelineBuilders.Timeline.Builder addTimelineEntry(androidx.wear.tiles.builders.TimelineBuilders.TimelineEntry.Builder);
- method public androidx.wear.tiles.builders.TimelineBuilders.Timeline build();
- }
-
- public static final class TimelineBuilders.TimelineEntry {
- method public static androidx.wear.tiles.builders.TimelineBuilders.TimelineEntry.Builder builder();
- }
-
- public static final class TimelineBuilders.TimelineEntry.Builder {
- method public androidx.wear.tiles.builders.TimelineBuilders.TimelineEntry build();
- method public androidx.wear.tiles.builders.TimelineBuilders.TimelineEntry.Builder setContent(androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement);
- method public androidx.wear.tiles.builders.TimelineBuilders.TimelineEntry.Builder setContent(androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement.Builder);
- method public androidx.wear.tiles.builders.TimelineBuilders.TimelineEntry.Builder setValidity(androidx.wear.tiles.builders.TimelineBuilders.TimeInterval);
- method public androidx.wear.tiles.builders.TimelineBuilders.TimelineEntry.Builder setValidity(androidx.wear.tiles.builders.TimelineBuilders.TimeInterval.Builder);
- }
-
-}
-
-package androidx.wear.tiles.readers {
-
- public class DeviceParametersReaders {
- field public static final int DEVICE_PLATFORM_UNDEFINED = 0; // 0x0
- field public static final int DEVICE_PLATFORM_WEAR_OS = 1; // 0x1
- field public static final int SCREEN_SHAPE_RECT = 2; // 0x2
- field public static final int SCREEN_SHAPE_ROUND = 1; // 0x1
- field public static final int SCREEN_SHAPE_UNDEFINED = 0; // 0x0
- }
-
- public static class DeviceParametersReaders.DeviceParameters {
- method public int getDevicePlatform();
- method @FloatRange(from=0.0, fromInclusive=false) public float getScreenDensity();
- method @Dimension(unit=androidx.annotation.Dimension.DP) public int getScreenHeightDp();
- method public int getScreenShape();
- method @Dimension(unit=androidx.annotation.Dimension.DP) public int getScreenWidthDp();
- }
-
- public class RequestReaders {
- }
-
- public static class RequestReaders.ResourcesRequest {
- method public java.util.List<java.lang.String!> getResourceIds();
- method public String getVersion();
- }
-
- public static class RequestReaders.TileRequest {
- method public String getClickableId();
- method public androidx.wear.tiles.readers.DeviceParametersReaders.DeviceParameters? getDeviceParameters();
- }
-
-}
-
diff --git a/wear/wear-tiles/build.gradle b/wear/wear-tiles/build.gradle
index 69b52c1..dc09849 100644
--- a/wear/wear-tiles/build.gradle
+++ b/wear/wear-tiles/build.gradle
@@ -23,7 +23,6 @@
plugins {
id("AndroidXPlugin")
id("com.android.library")
- id("com.google.protobuf")
}
dependencies {
@@ -37,32 +36,11 @@
defaultConfig {
minSdkVersion 24
}
- buildFeatures {
- aidl = true
- }
// Use Robolectric 4.+
testOptions.unitTests.includeAndroidResources = true
}
-protobuf {
- protoc {
- artifact = PROTOBUF_COMPILER
- }
- // Generates the java proto-lite code for the protos in this project. See
- // https://github.com/google/protobuf-gradle-plugin#customizing-protobuf-compilation
- // for more information.
- generateProtoTasks {
- all().each { task ->
- task.builtins {
- java {
- option 'lite'
- }
- }
- }
- }
-}
-
androidx {
name = "Android Wear Tiles"
type = LibraryType.PUBLISHED_LIBRARY
@@ -70,4 +48,5 @@
mavenVersion = LibraryVersions.WEAR_TILES
inceptionYear = "2020"
description = "Android Wear Tiles"
+ runApiTasks = new RunApiTasks.No("API tracking disabled while the package is empty")
}
diff --git a/wear/wear-tiles/src/main/aidl/androidx/wear/tiles/ResourcesCallback.aidl b/wear/wear-tiles/src/main/aidl/androidx/wear/tiles/ResourcesCallback.aidl
deleted file mode 100644
index 468a4e6..0000000
--- a/wear/wear-tiles/src/main/aidl/androidx/wear/tiles/ResourcesCallback.aidl
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * 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.wear.tiles;
-
-import androidx.wear.tiles.ResourcesData;
-
-/**
- * Callback used to return resources from a Tile Provider to the system.
- *
- * Note that this callback is not versioned; new fields in the inner TileData will be handled
- * by standard proto version compatibility in the underlying payload. Any significant changes to
- * this interface will be handled by instead adding new calls into TileProvider.
- *
- * @hide
- */
-interface ResourcesCallback {
- /**
- * Pass a new resource bundle to the system. This should be called in
- * response to a request from ProtoTileProvider.onResourcesRequest.
- */
- oneway void updateResources(in ResourcesData resourcesData) = 0;
-}
diff --git a/wear/wear-tiles/src/main/aidl/androidx/wear/tiles/ResourcesData.aidl b/wear/wear-tiles/src/main/aidl/androidx/wear/tiles/ResourcesData.aidl
deleted file mode 100644
index 8ff0e5c..0000000
--- a/wear/wear-tiles/src/main/aidl/androidx/wear/tiles/ResourcesData.aidl
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * 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.wear.tiles;
-
-parcelable ResourcesData;
diff --git a/wear/wear-tiles/src/main/aidl/androidx/wear/tiles/ResourcesRequestData.aidl b/wear/wear-tiles/src/main/aidl/androidx/wear/tiles/ResourcesRequestData.aidl
deleted file mode 100644
index 4053273..0000000
--- a/wear/wear-tiles/src/main/aidl/androidx/wear/tiles/ResourcesRequestData.aidl
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * 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.wear.tiles;
-
-parcelable ResourcesRequestData;
diff --git a/wear/wear-tiles/src/main/aidl/androidx/wear/tiles/TileCallback.aidl b/wear/wear-tiles/src/main/aidl/androidx/wear/tiles/TileCallback.aidl
deleted file mode 100644
index 19414da..0000000
--- a/wear/wear-tiles/src/main/aidl/androidx/wear/tiles/TileCallback.aidl
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * 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.wear.tiles;
-
-import androidx.wear.tiles.TileData;
-
-/**
- * Callback used to return tile contents from a Tile Provider to the system.
- *
- * Note that this callback is not versioned; new fields in the inner TileData will be handled
- * by standard proto version compatibility in the underlying payload. Any significant changes to
- * this interface will be handled by instead adding new calls into TileProvider.
- *
- * @hide
- */
-interface TileCallback {
- /**
- * Pass a new tile timeline to the system. This should be called in
- * response to a request from ProtoTileProvider.onTileRequest.
- */
- oneway void updateTileData(in TileData tileData) = 0;
-}
diff --git a/wear/wear-tiles/src/main/aidl/androidx/wear/tiles/TileData.aidl b/wear/wear-tiles/src/main/aidl/androidx/wear/tiles/TileData.aidl
deleted file mode 100644
index 1186962..0000000
--- a/wear/wear-tiles/src/main/aidl/androidx/wear/tiles/TileData.aidl
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * 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.wear.tiles;
-
-parcelable TileData;
diff --git a/wear/wear-tiles/src/main/aidl/androidx/wear/tiles/TileProvider.aidl b/wear/wear-tiles/src/main/aidl/androidx/wear/tiles/TileProvider.aidl
deleted file mode 100644
index 8fe1393..0000000
--- a/wear/wear-tiles/src/main/aidl/androidx/wear/tiles/TileProvider.aidl
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * 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.wear.tiles;
-
-import android.widget.RemoteViews;
-import androidx.wear.tiles.TileCallback;
-import androidx.wear.tiles.TileRequestData;
-import androidx.wear.tiles.ResourcesCallback;
-import androidx.wear.tiles.ResourcesRequestData;
-
-/**
- * Interface to be implemented by a service which provides Tiles to a Wear
- * device.
- *
- * @hide
- */
-interface TileProvider {
-
- const int API_VERSION = 1;
-
- /**
- * Gets the version of this TileProvider interface implemented by this
- * service. Note that this does not imply any schema version; just which
- * calls within this interface are supported.
- *
- * @since version 1
- */
- int getApiVersion() = 0;
-
- /**
- * Called when the system requests a new Tile timeline from this tile
- * provider. The tile provider should optionally call host.updateTileData
- * with the supplied ID, and a Tile timeline.
- *
- * @since version 1
- */
- oneway void onTileRequest(int id, in TileRequestData requestData, TileCallback callback) = 1;
-
- /**
- * Called when the system requires a new resource bundle, typically after
- * providing a tile with a different resource version. The tile provider
- * must call host.updateResourceData with the supplied ID, and a resource
- * bundle.
- *
- * @since version 1
- */
- oneway void onResourcesRequest(int id, in ResourcesRequestData requestData, ResourcesCallback callback) = 2;
-
- /**
- * Called when the Tile is added to the carousel. This will be followed by
- * a call to onTileRequest when the system is ready to render the tile.
- *
- * @since version 1
- */
- oneway void onTileAdd(int id) = 3;
-
- /**
- * Called when the Tile is removed from the carousel.
- *
- * @since version 1
- */
- oneway void onTileRemove(int id) = 4;
-}
diff --git a/wear/wear-tiles/src/main/aidl/androidx/wear/tiles/TileRequestData.aidl b/wear/wear-tiles/src/main/aidl/androidx/wear/tiles/TileRequestData.aidl
deleted file mode 100644
index c7237d6..0000000
--- a/wear/wear-tiles/src/main/aidl/androidx/wear/tiles/TileRequestData.aidl
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * 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.wear.tiles;
-
-parcelable TileRequestData;
diff --git a/wear/wear-tiles/src/main/aidl/androidx/wear/tiles/TileUpdateRequestData.aidl b/wear/wear-tiles/src/main/aidl/androidx/wear/tiles/TileUpdateRequestData.aidl
deleted file mode 100644
index ef0c9cb..0000000
--- a/wear/wear-tiles/src/main/aidl/androidx/wear/tiles/TileUpdateRequestData.aidl
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * 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.wear.tiles;
-
-parcelable TileUpdateRequestData;
diff --git a/wear/wear-tiles/src/main/aidl/androidx/wear/tiles/TileUpdateRequesterService.aidl b/wear/wear-tiles/src/main/aidl/androidx/wear/tiles/TileUpdateRequesterService.aidl
deleted file mode 100644
index b7c1009..0000000
--- a/wear/wear-tiles/src/main/aidl/androidx/wear/tiles/TileUpdateRequesterService.aidl
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * 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.wear.tiles;
-
-import android.content.ComponentName;
-import androidx.wear.tiles.TileUpdateRequestData;
-
-/**
- * Interface, implemented by Tile Renderers, which allows a Tile Provider to
- * request that a Tile Renderer fetches a new Timeline from it.
- *
- * @hide
- */
-interface TileUpdateRequesterService {
- const int API_VERSION = 1;
-
- /**
- * Gets the version of this TileProvider interface implemented by this
- * service. Note that this does not imply any schema version; just which
- * calls within this interface are supported.
- *
- * @since version 1
- */
- int getApiVersion() = 0;
-
- /**
- * Request that the Tile Renderer fetches a new Timeline from the Tile
- * Provider service identified by {@code component}. The package name in
- * {@code component} must have the same UID as the calling process,
- * otherwise this call will be ignored.
- *
- * {@code updateData} is provided as a placeholder to allow a payload of
- * parameters to be passed in future. This is currently blank in all
- * implementations, but allows for easy expansion.
- *
- * Note that this call may be rate limited, hence the tile fetch request
- * may not occur immediately after calling this method.
- *
- * @since version 1
- */
- oneway void requestUpdate(in ComponentName component, in TileUpdateRequestData updateData) = 1;
-}
diff --git a/wear/wear-tiles/src/main/java/androidx/wear/tiles/ProtoParcelable.java b/wear/wear-tiles/src/main/java/androidx/wear/tiles/ProtoParcelable.java
deleted file mode 100644
index 06b437c..0000000
--- a/wear/wear-tiles/src/main/java/androidx/wear/tiles/ProtoParcelable.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * 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.wear.tiles;
-
-import android.annotation.SuppressLint;
-import android.os.Parcel;
-import android.os.Parcelable;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.RestrictTo;
-
-import java.lang.reflect.Array;
-import java.util.Arrays;
-import java.util.function.BiFunction;
-
-/**
- * Base class for holders of protobuf messages that can be parceled to be transferred to the rest of
- * the system.
- *
- * @hide
- */
-@RestrictTo(RestrictTo.Scope.LIBRARY)
-@SuppressWarnings("AndroidApiChecker") // Uses java.util.function.Function
-public abstract class ProtoParcelable implements Parcelable {
- private final byte[] mContents;
- private final int mVersion;
-
- static <T extends ProtoParcelable> Creator<T> newCreator(
- Class<T> clazz, BiFunction<byte[], Integer, T> creator) {
- return new Creator<T>() {
-
- @Override
- public T createFromParcel(Parcel source) {
- int version = source.readInt();
- byte[] payload = source.createByteArray();
-
- return creator.apply(payload, version);
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public T[] newArray(int size) {
- return (T[]) Array.newInstance(clazz, size);
- }
- };
- }
-
- protected ProtoParcelable(@NonNull byte[] contents, int version) {
- this.mContents = contents;
- this.mVersion = version;
- }
-
- /** Get the payload contained within this ProtoParcelable. */
- @NonNull
- public byte[] getContents() {
- return mContents;
- }
-
- /**
- * Gets the version of this Parcelable. This can be used to detect what type of data is returned
- * by {@link #getContents()}.
- */
- public int getVersion() {
- return mVersion;
- }
-
- @Override
- public int describeContents() {
- return 0;
- }
-
- @Override
- public void writeToParcel(@NonNull Parcel dest, int flags) {
- dest.writeInt(mVersion);
- dest.writeByteArray(mContents);
- }
-
- @Override
- @SuppressLint("EqualsGetClass")
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
-
- // We want to use getClass here, as this class is designed to be subtyped immediately.
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
- ProtoParcelable that = (ProtoParcelable) o;
- return mVersion == that.mVersion && Arrays.equals(mContents, that.mContents);
- }
-
- @Override
- public int hashCode() {
- return Arrays.hashCode(mContents);
- }
-}
diff --git a/wear/wear-tiles/src/main/java/androidx/wear/tiles/ResourcesData.java b/wear/wear-tiles/src/main/java/androidx/wear/tiles/ResourcesData.java
deleted file mode 100644
index 502c2e3..0000000
--- a/wear/wear-tiles/src/main/java/androidx/wear/tiles/ResourcesData.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * 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.wear.tiles;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.RestrictTo;
-
-/**
- * Holder for ProtoTiles' Resources class, to be parceled and transferred to Wear.
- *
- * <p>All this does is to serialize Resources as a protobuf and transmit it.
- *
- * @hide
- */
-@RestrictTo(RestrictTo.Scope.LIBRARY)
-public final class ResourcesData extends ProtoParcelable {
- public static final int VERSION_PROTOBUF = 1;
-
- public static final Creator<ResourcesData> CREATOR =
- newCreator(ResourcesData.class, ResourcesData::new);
-
- public ResourcesData(@NonNull byte[] payload, int version) {
- super(payload, version);
- }
-}
diff --git a/wear/wear-tiles/src/main/java/androidx/wear/tiles/ResourcesRequestData.java b/wear/wear-tiles/src/main/java/androidx/wear/tiles/ResourcesRequestData.java
deleted file mode 100644
index b26bb9b..0000000
--- a/wear/wear-tiles/src/main/java/androidx/wear/tiles/ResourcesRequestData.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * 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.wear.tiles;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.RestrictTo;
-
-/**
- * Holder for ProtoTiles' ResourceRequest class, to be parceled and transferred to Wear.
- *
- * <p>All this does is to serialize ResourceRequest as a protobuf and transmit it.
- *
- * @hide
- */
-@RestrictTo(RestrictTo.Scope.LIBRARY)
-public final class ResourcesRequestData extends ProtoParcelable {
- public static final int VERSION_PROTOBUF = 1;
- public static final Creator<ResourcesRequestData> CREATOR =
- newCreator(ResourcesRequestData.class, ResourcesRequestData::new);
-
- public ResourcesRequestData(@NonNull byte[] params, int version) {
- super(params, version);
- }
-}
diff --git a/wear/wear-tiles/src/main/java/androidx/wear/tiles/SysUiTileUpdateRequester.java b/wear/wear-tiles/src/main/java/androidx/wear/tiles/SysUiTileUpdateRequester.java
deleted file mode 100644
index effad77..0000000
--- a/wear/wear-tiles/src/main/java/androidx/wear/tiles/SysUiTileUpdateRequester.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * 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.wear.tiles;
-
-import android.app.Service;
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
-import android.content.ServiceConnection;
-import android.content.pm.PackageManager;
-import android.content.pm.ResolveInfo;
-import android.content.pm.ServiceInfo;
-import android.os.IBinder;
-import android.os.RemoteException;
-import android.util.Log;
-
-import androidx.annotation.GuardedBy;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-/** Variant of {@link TileUpdateRequester} which requests an update from the Wear SysUI app. */
-// TODO(b/173688156): Renovate this whole class, and especially work around all the locks.
-public class SysUiTileUpdateRequester implements TileUpdateRequester {
- private static final String TAG = "HTUpdateRequester";
-
- // TODO(b/174002885): Stop hardcoding Home package name.
- private static final String TARGET_SYSUI = "com.google.android.wearable.app";
-
- public static final String ACTION_BIND_UPDATE_REQUESTER =
- "androidx.wear.tiles.action.BIND_UPDATE_REQUESTER";
-
- private final Context mAppContext;
-
- final Object mLock = new Object();
-
- @GuardedBy("mLock")
- TileUpdateRequesterService mUpdateRequestService;
-
- @GuardedBy("mLock")
- boolean mBindInProgress = false;
-
- @GuardedBy("mLock")
- final Set<Class<? extends Service>> mPendingServices = new HashSet<>();
-
- public SysUiTileUpdateRequester(@NonNull Context appContext) {
- this.mAppContext = appContext;
- }
-
- @Override
- public void requestUpdate(@NonNull Class<? extends Service> tileProvider) {
- synchronized (mLock) {
- if (mUpdateRequestService != null && mUpdateRequestService.asBinder().isBinderAlive()) {
- sendTileUpdateRequest(tileProvider);
- return;
- } else if (mBindInProgress) {
- // Update scheduled anyway, skip.
- mPendingServices.add(tileProvider);
- return;
- } else {
- // Can release the lock after this
- mPendingServices.add(tileProvider);
- mBindInProgress = true;
- }
- }
-
- // Something was wrong with the binder, trigger a request.
- Intent bindIntent = buildUpdateBindIntent();
-
- if (bindIntent == null) {
- Log.e(TAG, "Could not build bind intent");
- synchronized (mLock) {
- mBindInProgress = false;
- }
- return;
- }
-
- bindAndUpdate(bindIntent);
- }
-
- @Nullable
- private Intent buildUpdateBindIntent() {
- Intent bindIntent = new Intent(ACTION_BIND_UPDATE_REQUESTER);
- bindIntent.setPackage(TARGET_SYSUI);
-
- // Find the concrete ComponentName of the service that implements what we need.
- PackageManager pm = mAppContext.getPackageManager();
-
- List<ResolveInfo> services =
- pm.queryIntentServices(
- bindIntent,
- PackageManager.GET_META_DATA | PackageManager.GET_RESOLVED_FILTER);
-
- if (services.isEmpty()) {
- Log.w(TAG, "Couldn't find any services filtering on " + ACTION_BIND_UPDATE_REQUESTER);
- return null;
- }
-
- ServiceInfo serviceInfo = services.get(0).serviceInfo;
-
- bindIntent.setClassName(serviceInfo.packageName, serviceInfo.name);
-
- return bindIntent;
- }
-
- // TODO(b/174002003): Make this unbind from the service.
- private void bindAndUpdate(Intent i) {
- mAppContext.bindService(
- i,
- new ServiceConnection() {
- @Override
- public void onServiceConnected(ComponentName name, IBinder service) {
- synchronized (mLock) {
- mUpdateRequestService =
- TileUpdateRequesterService.Stub.asInterface(service);
- mBindInProgress = false;
-
- for (Class<? extends Service> tileProvider : mPendingServices) {
- sendTileUpdateRequest(tileProvider);
- }
-
- mPendingServices.clear();
- }
- }
-
- @Override
- public void onServiceDisconnected(ComponentName name) {
- synchronized (mLock) {
- mUpdateRequestService = null;
- }
- }
- },
- Context.BIND_AUTO_CREATE);
- }
-
- @GuardedBy("mLock")
- void sendTileUpdateRequest(Class<? extends Service> tileProvider) {
- try {
- ComponentName cn = new ComponentName(mAppContext, tileProvider);
- mUpdateRequestService.requestUpdate(cn, new TileUpdateRequestData());
- } catch (RemoteException ex) {
- Log.w(TAG, "RemoteException while requesting tile update");
- }
- }
-}
diff --git a/wear/wear-tiles/src/main/java/androidx/wear/tiles/TileData.java b/wear/wear-tiles/src/main/java/androidx/wear/tiles/TileData.java
deleted file mode 100644
index 755d603..0000000
--- a/wear/wear-tiles/src/main/java/androidx/wear/tiles/TileData.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * 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.wear.tiles;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.RestrictTo;
-
-/**
- * Holder for ProtoTiles' Tile class, to be parceled and transferred to Wear.
- *
- * <p>All this does is to serialize Tile as a protobuf and transmit it.
- *
- * @hide
- */
-@RestrictTo(RestrictTo.Scope.LIBRARY)
-public final class TileData extends ProtoParcelable {
- public static final int VERSION_PROTOBUF = 1;
- public static final Creator<TileData> CREATOR = newCreator(TileData.class, TileData::new);
-
- public TileData(@NonNull byte[] tile, int version) {
- super(tile, version);
- }
-}
diff --git a/wear/wear-tiles/src/main/java/androidx/wear/tiles/TileProviderService.java b/wear/wear-tiles/src/main/java/androidx/wear/tiles/TileProviderService.java
deleted file mode 100644
index d7aedcc..0000000
--- a/wear/wear-tiles/src/main/java/androidx/wear/tiles/TileProviderService.java
+++ /dev/null
@@ -1,232 +0,0 @@
-/*
- * 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.wear.tiles;
-
-import android.app.Service;
-import android.content.Context;
-import android.content.Intent;
-import android.os.Handler;
-import android.os.IBinder;
-import android.os.RemoteException;
-import android.util.Log;
-
-import androidx.annotation.MainThread;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import androidx.wear.tiles.builders.ResourceBuilders.Resources;
-import androidx.wear.tiles.builders.TileBuilders.Tile;
-import androidx.wear.tiles.readers.RequestReaders.ResourcesRequest;
-import androidx.wear.tiles.readers.RequestReaders.TileRequest;
-
-import com.google.common.util.concurrent.ListenableFuture;
-
-import java.lang.ref.WeakReference;
-import java.util.concurrent.ExecutionException;
-
-/**
- * Base class for a service providing data for an app tile.
- *
- * <p>A provider service must implement {@link #onTileRequest} and {@link #onResourcesRequest} to
- * respond to requests for updates from the system.
- *
- * <p>The manifest declaration of this service must include an intent filter for {@link
- * #ACTION_BIND_TILE_PROVIDER}.
- *
- * <p>The manifest entry should also include {@code
- * android:permission="com.google.android.wearable.permission.BIND_TILE_PROVIDER"} to ensure that
- * only the system can bind to it.
- */
-public abstract class TileProviderService extends Service {
-
- private static final String TAG = "TileProviderService";
-
- /**
- * The intent action used to send update requests to the provider. Tile provider services must
- * declare an intent filter for this action in the manifest.
- */
- public static final String ACTION_BIND_TILE_PROVIDER =
- "androidx.wear.tiles.action.BIND_TILE_PROVIDER";
-
- /** The ID for the Intent extra containing the ID of the Clickable. */
- public static final String EXTRA_CLICKABLE_ID = "androidx.wear.tiles.extra.CLICKABLE_ID";
-
- /**
- * The name of the metadata key that should contain a drawable to be presented as a Tile
- * preview.
- */
- public static final String METADATA_PREVIEW_KEY = "androidx.wear.tiles.PREVIEW";
-
- /**
- * Called when the system is requesting a new timeline from this Tile Provider. Note that this
- * may be called from a background thread.
- *
- * @param requestParams Parameters about the request. See {@link TileRequestData} for more info.
- */
- @MainThread
- @NonNull
- protected abstract ListenableFuture<Tile> onTileRequest(@NonNull TileRequest requestParams);
-
- /**
- * Called when the system is requesting a resource bundle from this Tile Provider. Note that
- * this may be called from a background thread.
- *
- * @param requestParams Parameters about the request. See {@link ResourcesRequestData} for more
- * info.
- */
- @MainThread
- @NonNull
- protected abstract ListenableFuture<Resources> onResourcesRequest(
- @NonNull ResourcesRequest requestParams);
-
- /**
- * Gets an instance of {@link TileUpdateRequester} to allow a Tile Provider to notify the tile's
- * renderer that it should request a new Timeline from this {@link TileProviderService}.
- *
- * @param context The application context.
- */
- @NonNull
- public static TileUpdateRequester getUpdater(@NonNull Context context) {
- return new SysUiTileUpdateRequester(context);
- }
-
- private TileProvider.Stub mBinder;
-
- @Override
- @Nullable
- public IBinder onBind(@NonNull Intent intent) {
- if (ACTION_BIND_TILE_PROVIDER.equals(intent.getAction())) {
- if (mBinder == null) {
- mBinder = new TileProviderWrapper(this, new Handler(getMainLooper()));
- }
- return mBinder;
- }
- return null;
- }
-
- @SuppressWarnings("ExecutorTaskName")
- private static class TileProviderWrapper extends TileProvider.Stub {
-
- private final WeakReference<TileProviderService> mServiceRef;
- private final Handler mHandler;
-
- TileProviderWrapper(TileProviderService tileProviderService, Handler handler) {
- mServiceRef = new WeakReference<>(tileProviderService);
- this.mHandler = handler;
- }
-
- @Override
- public int getApiVersion() {
- return TileProvider.API_VERSION;
- }
-
- @Override
- public void onTileRequest(
- int tileId, TileRequestData requestParams, TileCallback callback) {
- mHandler.post(
- () -> {
- TileProviderService tileProviderService = mServiceRef.get();
- if (tileProviderService != null) {
- if (requestParams.getVersion() != TileRequestData.VERSION_PROTOBUF) {
- Log.e(
- TAG,
- "TileRequestData had unexpected version: "
- + requestParams.getVersion());
- return;
- }
-
- // TODO(b/166074385): Add tileId to TileRequest
- ListenableFuture<Tile> tileFuture =
- tileProviderService.onTileRequest(
- TileRequest.fromParcelable(requestParams));
-
- tileFuture.addListener(
- () -> {
- try {
- callback.updateTileData(
- new TileData(
- tileFuture
- .get()
- .toProto()
- .toByteArray(),
- TileData.VERSION_PROTOBUF));
- } catch (ExecutionException | InterruptedException ex) {
- Log.e(TAG, "onTileRequest Future failed", ex);
- } catch (RemoteException ex) {
- Log.e(
- TAG,
- "RemoteException while returning tile payload",
- ex);
- }
- },
- mHandler::post);
- }
- });
- }
-
- @Override
- public void onResourcesRequest(
- int tileId, ResourcesRequestData requestParams, ResourcesCallback callback) {
- mHandler.post(
- () -> {
- TileProviderService tileProviderService = mServiceRef.get();
- if (tileProviderService != null) {
- if (requestParams.getVersion()
- != ResourcesRequestData.VERSION_PROTOBUF) {
- Log.e(
- TAG,
- "ResourcesRequestData had unexpected version: "
- + requestParams.getVersion());
- return;
- }
-
- // TODO(b/166074385): Add tileId to ResourcesRequest
- ListenableFuture<Resources> resourcesFuture =
- tileProviderService.onResourcesRequest(
- ResourcesRequest.fromParcelable(requestParams));
-
- resourcesFuture.addListener(
- () -> {
- try {
- callback.updateResources(
- new ResourcesData(
- resourcesFuture
- .get()
- .toProto()
- .toByteArray(),
- ResourcesData.VERSION_PROTOBUF));
- } catch (ExecutionException | InterruptedException ex) {
- Log.e(TAG, "onResourcesRequest Future failed", ex);
- } catch (RemoteException ex) {
- Log.e(
- TAG,
- "RemoteException while returning resources"
- + " payload",
- ex);
- }
- },
- mHandler::post);
- }
- });
- }
-
- @Override
- public void onTileAdd(int id) {}
-
- @Override
- public void onTileRemove(int id) {}
- }
-}
diff --git a/wear/wear-tiles/src/main/java/androidx/wear/tiles/TileRequestData.java b/wear/wear-tiles/src/main/java/androidx/wear/tiles/TileRequestData.java
deleted file mode 100644
index 3c4dc86..0000000
--- a/wear/wear-tiles/src/main/java/androidx/wear/tiles/TileRequestData.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * 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.wear.tiles;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.RestrictTo;
-
-/**
- * Holder for ProtoTiles' TileRequest class, to be parceled and transferred to Wear.
- *
- * <p>All this does is to serialize TileRequest as a protobuf and transmit it.
- *
- * @hide
- */
-@RestrictTo(RestrictTo.Scope.LIBRARY)
-public final class TileRequestData extends ProtoParcelable {
- public static final int VERSION_PROTOBUF = 1;
- public static final Creator<TileRequestData> CREATOR =
- newCreator(TileRequestData.class, TileRequestData::new);
-
- public TileRequestData(@NonNull byte[] params, int version) {
- super(params, version);
- }
-}
diff --git a/wear/wear-tiles/src/main/java/androidx/wear/tiles/TileUpdateRequestData.java b/wear/wear-tiles/src/main/java/androidx/wear/tiles/TileUpdateRequestData.java
deleted file mode 100644
index b26cf22..0000000
--- a/wear/wear-tiles/src/main/java/androidx/wear/tiles/TileUpdateRequestData.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * 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.wear.tiles;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.RestrictTo;
-
-/**
- * Holder for parameters, used when a Tile update request is triggered. This is currently a
- * placeholder to allow for future expansion, and should be filled in with an empty byte array.
- *
- * @hide
- */
-@RestrictTo(RestrictTo.Scope.LIBRARY)
-public final class TileUpdateRequestData extends ProtoParcelable {
- public static final int VERSION_PLACEHOLDER = 1;
- public static final Creator<TileUpdateRequestData> CREATOR =
- newCreator(TileUpdateRequestData.class, TileUpdateRequestData::new);
-
- private TileUpdateRequestData(@NonNull byte[] params, int version) {
- super(params, version);
- }
-
- public TileUpdateRequestData() {
- this(new byte[] {}, VERSION_PLACEHOLDER);
- }
-}
diff --git a/wear/wear-tiles/src/main/java/androidx/wear/tiles/TileUpdateRequester.java b/wear/wear-tiles/src/main/java/androidx/wear/tiles/TileUpdateRequester.java
deleted file mode 100644
index 4d868ae..0000000
--- a/wear/wear-tiles/src/main/java/androidx/wear/tiles/TileUpdateRequester.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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.wear.tiles;
-
-import android.app.Service;
-
-import androidx.annotation.NonNull;
-
-/**
- * Interface used for a Tile Provider to notify a Tile Renderer that it should fetch a new Timeline
- * from it.
- */
-public interface TileUpdateRequester {
- /** Notify the Tile Renderer that it should fetch a new Timeline from this Tile Provider. */
- void requestUpdate(@NonNull Class<? extends Service> tileProvider);
-}
diff --git a/wear/wear-tiles/src/main/java/androidx/wear/tiles/builders/ActionBuilders.java b/wear/wear-tiles/src/main/java/androidx/wear/tiles/builders/ActionBuilders.java
deleted file mode 100644
index e812996..0000000
--- a/wear/wear-tiles/src/main/java/androidx/wear/tiles/builders/ActionBuilders.java
+++ /dev/null
@@ -1,218 +0,0 @@
-/*
- * Copyright 2021 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.wear.tiles.builders;
-
-import android.annotation.SuppressLint;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.RestrictTo;
-import androidx.annotation.RestrictTo.Scope;
-import androidx.wear.tiles.proto.ActionProto;
-
-/** Builders for actions that can be performed when a user interacts with layout elements. */
-public final class ActionBuilders {
- private ActionBuilders() {}
-
- /** A launch action to send an intent to an Android activity. */
- public static final class AndroidActivity {
- private final ActionProto.AndroidActivity mImpl;
-
- AndroidActivity(ActionProto.AndroidActivity impl) {
- this.mImpl = impl;
- }
-
- /** Returns a new {@link Builder}. */
- @NonNull
- public static Builder builder() {
- return new Builder();
- }
-
- /**
- * Get the protocol buffer representation of this object.
- *
- * @hide
- */
- @RestrictTo(Scope.LIBRARY)
- @NonNull
- public ActionProto.AndroidActivity toProto() {
- return mImpl;
- }
-
- /** Builder for {@link AndroidActivity} */
- public static final class Builder {
- private final ActionProto.AndroidActivity.Builder mImpl =
- ActionProto.AndroidActivity.newBuilder();
-
- Builder() {}
-
- /** Sets the package name to send the intent to, for example, "com.google.weather". */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setPackageName(@NonNull String packageName) {
- mImpl.setPackageName(packageName);
- return this;
- }
-
- /**
- * Sets the fully qualified class name (including the package) to send the intent to,
- * for example, "com.google.weather.WeatherOverviewActivity".
- */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setClassName(@NonNull String className) {
- mImpl.setClassName(className);
- return this;
- }
-
- /** Builds an instance from accumulated values. */
- @NonNull
- public AndroidActivity build() {
- return new AndroidActivity(mImpl.build());
- }
- }
- }
-
- /**
- * An action used to launch another activity on the system. This can hold multiple different
- * underlying action types, which will be picked based on what the underlying runtime believes
- * to be suitable.
- */
- public static final class LaunchAction implements Action {
- private final ActionProto.LaunchAction mImpl;
-
- LaunchAction(ActionProto.LaunchAction impl) {
- this.mImpl = impl;
- }
-
- /** Returns a new {@link Builder}. */
- @NonNull
- public static Builder builder() {
- return new Builder();
- }
-
- /** @hide */
- @RestrictTo(Scope.LIBRARY)
- @NonNull
- ActionProto.LaunchAction toProto() {
- return mImpl;
- }
-
- /** @hide */
- @Override
- @RestrictTo(Scope.LIBRARY)
- @NonNull
- public ActionProto.Action toActionProto() {
- return ActionProto.Action.newBuilder().setLaunchAction(mImpl).build();
- }
-
- /** Builder for {@link LaunchAction}. */
- public static final class Builder implements Action.Builder {
- private final ActionProto.LaunchAction.Builder mImpl =
- ActionProto.LaunchAction.newBuilder();
-
- Builder() {}
-
- /** Sets an action to launch an Android activity. */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setAndroidActivity(@NonNull AndroidActivity androidActivity) {
- mImpl.setAndroidActivity(androidActivity.toProto());
- return this;
- }
-
- /** Sets an action to launch an Android activity. */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setAndroidActivity(
- @NonNull AndroidActivity.Builder androidActivityBuilder) {
- mImpl.setAndroidActivity(androidActivityBuilder.build().toProto());
- return this;
- }
-
- @Override
- @NonNull
- public LaunchAction build() {
- return new LaunchAction(mImpl.build());
- }
- }
- }
-
- /** An action used to load (or reload) the tile contents. */
- public static final class LoadAction implements Action {
- private final ActionProto.LoadAction mImpl;
-
- LoadAction(ActionProto.LoadAction impl) {
- this.mImpl = impl;
- }
-
- /** Returns a new {@link Builder}. */
- @NonNull
- public static Builder builder() {
- return new Builder();
- }
-
- /** @hide */
- @RestrictTo(Scope.LIBRARY)
- @NonNull
- ActionProto.LoadAction toProto() {
- return mImpl;
- }
-
- /** @hide */
- @Override
- @RestrictTo(Scope.LIBRARY)
- @NonNull
- public ActionProto.Action toActionProto() {
- return ActionProto.Action.newBuilder().setLoadAction(mImpl).build();
- }
-
- /** Builder for {@link LoadAction}. */
- public static final class Builder implements Action.Builder {
- private final ActionProto.LoadAction.Builder mImpl =
- ActionProto.LoadAction.newBuilder();
-
- Builder() {}
-
- @Override
- @NonNull
- public LoadAction build() {
- return new LoadAction(mImpl.build());
- }
- }
- }
-
- /** Interface defining an action that can be used by a layout element. */
- public interface Action {
- /**
- * Get the protocol buffer representation of this object.
- *
- * @hide
- */
- @RestrictTo(Scope.LIBRARY)
- @NonNull
- ActionProto.Action toActionProto();
-
- /** Builder to create {@link Action} objects. */
- @SuppressLint("StaticFinalBuilder")
- interface Builder {
-
- /** Builds an instance with values accumulated in this Builder. */
- @NonNull
- Action build();
- }
- }
-}
diff --git a/wear/wear-tiles/src/main/java/androidx/wear/tiles/builders/ColorBuilders.java b/wear/wear-tiles/src/main/java/androidx/wear/tiles/builders/ColorBuilders.java
deleted file mode 100644
index 12bba94..0000000
--- a/wear/wear-tiles/src/main/java/androidx/wear/tiles/builders/ColorBuilders.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright 2021 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.wear.tiles.builders;
-
-import android.annotation.SuppressLint;
-
-import androidx.annotation.ColorInt;
-import androidx.annotation.NonNull;
-import androidx.annotation.RestrictTo;
-import androidx.annotation.RestrictTo.Scope;
-import androidx.wear.tiles.proto.ColorProto;
-
-/** Builders for color utilities for layout elements. */
-public final class ColorBuilders {
- private ColorBuilders() {}
-
- /** Shortcut for building a {@link ColorProp} using an ARGB value. */
- @NonNull
- public static ColorProp argb(@ColorInt int colorArgb) {
- return ColorProp.builder().setArgb(colorArgb).build();
- }
-
- /** A property defining a color. */
- public static final class ColorProp {
- private final ColorProto.ColorProp mImpl;
-
- ColorProp(ColorProto.ColorProp impl) {
- this.mImpl = impl;
- }
-
- /** Returns a new {@link Builder}. */
- @NonNull
- public static Builder builder() {
- return new Builder();
- }
-
- /**
- * Get the protocol buffer representation of this object.
- *
- * @hide
- */
- @RestrictTo(Scope.LIBRARY)
- @NonNull
- public ColorProto.ColorProp toProto() {
- return mImpl;
- }
-
- /** Builder for {@link ColorProp} */
- public static final class Builder {
- private final ColorProto.ColorProp.Builder mImpl = ColorProto.ColorProp.newBuilder();
-
- Builder() {}
-
- /** Sets the color value, in ARGB format. */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setArgb(@ColorInt int argb) {
- mImpl.setArgb(argb);
- return this;
- }
-
- /** Builds an instance from accumulated values. */
- @NonNull
- public ColorProp build() {
- return new ColorProp(mImpl.build());
- }
- }
- }
-}
diff --git a/wear/wear-tiles/src/main/java/androidx/wear/tiles/builders/DimensionBuilders.java b/wear/wear-tiles/src/main/java/androidx/wear/tiles/builders/DimensionBuilders.java
deleted file mode 100644
index 24a6277..0000000
--- a/wear/wear-tiles/src/main/java/androidx/wear/tiles/builders/DimensionBuilders.java
+++ /dev/null
@@ -1,487 +0,0 @@
-/*
- * Copyright 2021 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.wear.tiles.builders;
-
-import static androidx.annotation.Dimension.DP;
-import static androidx.annotation.Dimension.SP;
-
-import android.annotation.SuppressLint;
-
-import androidx.annotation.Dimension;
-import androidx.annotation.IntRange;
-import androidx.annotation.NonNull;
-import androidx.annotation.RestrictTo;
-import androidx.annotation.RestrictTo.Scope;
-import androidx.wear.tiles.proto.DimensionProto;
-
-/** Builders for dimensions for layout elements. */
-public final class DimensionBuilders {
- private DimensionBuilders() {}
-
- private static final ExpandedDimensionProp EXPAND = ExpandedDimensionProp.builder().build();
- private static final WrappedDimensionProp WRAP = WrappedDimensionProp.builder().build();
-
- /** Shortcut for building a {@link DpProp} using a measurement in DP. */
- @NonNull
- public static DpProp dp(@Dimension(unit = DP) float valueDp) {
- return DpProp.builder().setValue(valueDp).build();
- }
-
- /** Shortcut for building a {@link SpProp} using a measurement in SP. */
- @NonNull
- public static SpProp sp(@Dimension(unit = SP) int valueSp) {
- return SpProp.builder().setValue(valueSp).build();
- }
-
- /** Shortcut for building an {@link DegreesProp} using a measurement in degrees. */
- @NonNull
- public static DegreesProp degrees(float valueDegrees) {
- return DegreesProp.builder().setValue(valueDegrees).build();
- }
-
- /**
- * Shortcut for building an {@link ExpandedDimensionProp} that will expand to the size of its
- * parent.
- */
- @NonNull
- public static ExpandedDimensionProp expand() {
- return EXPAND;
- }
-
- /**
- * Shortcut for building an {@link WrappedDimensionProp} that will shrink to the size of its
- * children.
- */
- @NonNull
- public static WrappedDimensionProp wrap() {
- return WRAP;
- }
-
- /** A type for linear dimensions, measured in dp. */
- public static final class DpProp
- implements LinearOrAngularDimension, ContainerDimension, ImageDimension {
- private final DimensionProto.DpProp mImpl;
-
- DpProp(DimensionProto.DpProp impl) {
- this.mImpl = impl;
- }
-
- /** Returns a new {@link Builder}. */
- @NonNull
- public static Builder builder() {
- return new Builder();
- }
-
- /** @hide */
- @RestrictTo(Scope.LIBRARY)
- @NonNull
- DimensionProto.DpProp toProto() {
- return mImpl;
- }
-
- /** @hide */
- @Override
- @RestrictTo(Scope.LIBRARY)
- @NonNull
- public DimensionProto.LinearOrAngularDimension toLinearOrAngularDimensionProto() {
- return DimensionProto.LinearOrAngularDimension.newBuilder()
- .setLinearDimension(mImpl)
- .build();
- }
-
- /** @hide */
- @Override
- @RestrictTo(Scope.LIBRARY)
- @NonNull
- public DimensionProto.ContainerDimension toContainerDimensionProto() {
- return DimensionProto.ContainerDimension.newBuilder().setLinearDimension(mImpl).build();
- }
-
- /** @hide */
- @Override
- @RestrictTo(Scope.LIBRARY)
- @NonNull
- public DimensionProto.ImageDimension toImageDimensionProto() {
- return DimensionProto.ImageDimension.newBuilder().setLinearDimension(mImpl).build();
- }
-
- /** Builder for {@link DpProp}. */
- public static final class Builder
- implements LinearOrAngularDimension.Builder,
- ContainerDimension.Builder,
- ImageDimension.Builder {
- private final DimensionProto.DpProp.Builder mImpl = DimensionProto.DpProp.newBuilder();
-
- Builder() {}
-
- /** Sets the value, in dp. */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setValue(@Dimension(unit = DP) float value) {
- mImpl.setValue(value);
- return this;
- }
-
- @Override
- @NonNull
- public DpProp build() {
- return new DpProp(mImpl.build());
- }
- }
- }
-
- /** A type for font sizes, measured in sp. */
- public static final class SpProp {
- private final DimensionProto.SpProp mImpl;
-
- SpProp(DimensionProto.SpProp impl) {
- this.mImpl = impl;
- }
-
- /** Returns a new {@link Builder}. */
- @NonNull
- public static Builder builder() {
- return new Builder();
- }
-
- /**
- * Get the protocol buffer representation of this object.
- *
- * @hide
- */
- @RestrictTo(Scope.LIBRARY)
- @NonNull
- public DimensionProto.SpProp toProto() {
- return mImpl;
- }
-
- /** Builder for {@link SpProp} */
- public static final class Builder {
- private final DimensionProto.SpProp.Builder mImpl = DimensionProto.SpProp.newBuilder();
-
- Builder() {}
-
- /** Sets the value, in sp. */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setValue(@Dimension(unit = SP) int value) {
- mImpl.setValue(value);
- return this;
- }
-
- /** Builds an instance from accumulated values. */
- @NonNull
- public SpProp build() {
- return new SpProp(mImpl.build());
- }
- }
- }
-
- /** A type for angular dimensions, measured in degrees. */
- public static final class DegreesProp implements LinearOrAngularDimension {
- private final DimensionProto.DegreesProp mImpl;
-
- DegreesProp(DimensionProto.DegreesProp impl) {
- this.mImpl = impl;
- }
-
- /** Returns a new {@link Builder}. */
- @NonNull
- public static Builder builder() {
- return new Builder();
- }
-
- /** @hide */
- @RestrictTo(Scope.LIBRARY)
- @NonNull
- DimensionProto.DegreesProp toProto() {
- return mImpl;
- }
-
- /** @hide */
- @Override
- @RestrictTo(Scope.LIBRARY)
- @NonNull
- public DimensionProto.LinearOrAngularDimension toLinearOrAngularDimensionProto() {
- return DimensionProto.LinearOrAngularDimension.newBuilder()
- .setAngularDimension(mImpl)
- .build();
- }
-
- /** Builder for {@link DegreesProp}. */
- public static final class Builder implements LinearOrAngularDimension.Builder {
- private final DimensionProto.DegreesProp.Builder mImpl =
- DimensionProto.DegreesProp.newBuilder();
-
- Builder() {}
-
- /** Sets the value, in degrees. */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setValue(float value) {
- mImpl.setValue(value);
- return this;
- }
-
- @Override
- @NonNull
- public DegreesProp build() {
- return new DegreesProp(mImpl.build());
- }
- }
- }
-
- /**
- * A type for a dimension that fills all the space it can (i.e. MATCH_PARENT in Android
- * parlance).
- */
- public static final class ExpandedDimensionProp implements ContainerDimension, ImageDimension {
- private final DimensionProto.ExpandedDimensionProp mImpl;
-
- ExpandedDimensionProp(DimensionProto.ExpandedDimensionProp impl) {
- this.mImpl = impl;
- }
-
- /** Returns a new {@link Builder}. */
- @NonNull
- public static Builder builder() {
- return new Builder();
- }
-
- /** @hide */
- @RestrictTo(Scope.LIBRARY)
- @NonNull
- DimensionProto.ExpandedDimensionProp toProto() {
- return mImpl;
- }
-
- /** @hide */
- @Override
- @RestrictTo(Scope.LIBRARY)
- @NonNull
- public DimensionProto.ContainerDimension toContainerDimensionProto() {
- return DimensionProto.ContainerDimension.newBuilder()
- .setExpandedDimension(mImpl)
- .build();
- }
-
- /** @hide */
- @Override
- @RestrictTo(Scope.LIBRARY)
- @NonNull
- public DimensionProto.ImageDimension toImageDimensionProto() {
- return DimensionProto.ImageDimension.newBuilder().setExpandedDimension(mImpl).build();
- }
-
- /** Builder for {@link ExpandedDimensionProp}. */
- public static final class Builder
- implements ContainerDimension.Builder, ImageDimension.Builder {
- private final DimensionProto.ExpandedDimensionProp.Builder mImpl =
- DimensionProto.ExpandedDimensionProp.newBuilder();
-
- Builder() {}
-
- @Override
- @NonNull
- public ExpandedDimensionProp build() {
- return new ExpandedDimensionProp(mImpl.build());
- }
- }
- }
-
- /**
- * A type for a dimension that sizes itself to the size of its children (i.e. WRAP_CONTENT in
- * Android parlance).
- */
- public static final class WrappedDimensionProp implements ContainerDimension {
- private final DimensionProto.WrappedDimensionProp mImpl;
-
- WrappedDimensionProp(DimensionProto.WrappedDimensionProp impl) {
- this.mImpl = impl;
- }
-
- /** Returns a new {@link Builder}. */
- @NonNull
- public static Builder builder() {
- return new Builder();
- }
-
- /** @hide */
- @RestrictTo(Scope.LIBRARY)
- @NonNull
- DimensionProto.WrappedDimensionProp toProto() {
- return mImpl;
- }
-
- /** @hide */
- @Override
- @RestrictTo(Scope.LIBRARY)
- @NonNull
- public DimensionProto.ContainerDimension toContainerDimensionProto() {
- return DimensionProto.ContainerDimension.newBuilder()
- .setWrappedDimension(mImpl)
- .build();
- }
-
- /** Builder for {@link WrappedDimensionProp}. */
- public static final class Builder implements ContainerDimension.Builder {
- private final DimensionProto.WrappedDimensionProp.Builder mImpl =
- DimensionProto.WrappedDimensionProp.newBuilder();
-
- Builder() {}
-
- @Override
- @NonNull
- public WrappedDimensionProp build() {
- return new WrappedDimensionProp(mImpl.build());
- }
- }
- }
-
- /**
- * A type for a dimension that scales itself proportionally to another dimension such that the
- * aspect ratio defined by the given width and height values is preserved.
- *
- * <p>Note that the width and height are unitless; only their ratio is relevant. This allows for
- * specifying an element's size using common ratios (e.g. width=4, height=3), or to allow an
- * element to be resized proportionally based on the size of an underlying asset (e.g. an
- * 800x600 image being added to a smaller container and resized accordingly).
- */
- public static final class ProportionalDimensionProp implements ImageDimension {
- private final DimensionProto.ProportionalDimensionProp mImpl;
-
- ProportionalDimensionProp(DimensionProto.ProportionalDimensionProp impl) {
- this.mImpl = impl;
- }
-
- /** Returns a new {@link Builder}. */
- @NonNull
- public static Builder builder() {
- return new Builder();
- }
-
- /** @hide */
- @RestrictTo(Scope.LIBRARY)
- @NonNull
- DimensionProto.ProportionalDimensionProp toProto() {
- return mImpl;
- }
-
- /** @hide */
- @Override
- @RestrictTo(Scope.LIBRARY)
- @NonNull
- public DimensionProto.ImageDimension toImageDimensionProto() {
- return DimensionProto.ImageDimension.newBuilder()
- .setProportionalDimension(mImpl)
- .build();
- }
-
- /** Builder for {@link ProportionalDimensionProp}. */
- public static final class Builder implements ImageDimension.Builder {
- private final DimensionProto.ProportionalDimensionProp.Builder mImpl =
- DimensionProto.ProportionalDimensionProp.newBuilder();
-
- Builder() {}
-
- /** Sets the width to be used when calculating the aspect ratio to preserve. */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setAspectRatioWidth(@IntRange(from = 0) int aspectRatioWidth) {
- mImpl.setAspectRatioWidth(aspectRatioWidth);
- return this;
- }
-
- /** Sets the height to be used when calculating the aspect ratio ratio to preserve. */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setAspectRatioHeight(@IntRange(from = 0) int aspectRatioHeight) {
- mImpl.setAspectRatioHeight(aspectRatioHeight);
- return this;
- }
-
- @Override
- @NonNull
- public ProportionalDimensionProp build() {
- return new ProportionalDimensionProp(mImpl.build());
- }
- }
- }
-
- /** Interface defining a dimension that can be linear or angular. */
- public interface LinearOrAngularDimension {
- /**
- * Get the protocol buffer representation of this object.
- *
- * @hide
- */
- @RestrictTo(Scope.LIBRARY)
- @NonNull
- DimensionProto.LinearOrAngularDimension toLinearOrAngularDimensionProto();
-
- /** Builder to create {@link LinearOrAngularDimension} objects. */
- @SuppressLint("StaticFinalBuilder")
- interface Builder {
-
- /** Builds an instance with values accumulated in this Builder. */
- @NonNull
- LinearOrAngularDimension build();
- }
- }
-
- /** Interface defining a dimension that can be applied to a container. */
- public interface ContainerDimension {
- /**
- * Get the protocol buffer representation of this object.
- *
- * @hide
- */
- @RestrictTo(Scope.LIBRARY)
- @NonNull
- DimensionProto.ContainerDimension toContainerDimensionProto();
-
- /** Builder to create {@link ContainerDimension} objects. */
- @SuppressLint("StaticFinalBuilder")
- interface Builder {
-
- /** Builds an instance with values accumulated in this Builder. */
- @NonNull
- ContainerDimension build();
- }
- }
-
- /** Interface defining a dimension that can be applied to an image. */
- public interface ImageDimension {
- /**
- * Get the protocol buffer representation of this object.
- *
- * @hide
- */
- @RestrictTo(Scope.LIBRARY)
- @NonNull
- DimensionProto.ImageDimension toImageDimensionProto();
-
- /** Builder to create {@link ImageDimension} objects. */
- @SuppressLint("StaticFinalBuilder")
- interface Builder {
-
- /** Builds an instance with values accumulated in this Builder. */
- @NonNull
- ImageDimension build();
- }
- }
-}
diff --git a/wear/wear-tiles/src/main/java/androidx/wear/tiles/builders/LayoutElementBuilders.java b/wear/wear-tiles/src/main/java/androidx/wear/tiles/builders/LayoutElementBuilders.java
deleted file mode 100644
index 75028ba..0000000
--- a/wear/wear-tiles/src/main/java/androidx/wear/tiles/builders/LayoutElementBuilders.java
+++ /dev/null
@@ -1,2442 +0,0 @@
-/*
- * Copyright 2021 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.wear.tiles.builders;
-
-import android.annotation.SuppressLint;
-
-import androidx.annotation.IntDef;
-import androidx.annotation.IntRange;
-import androidx.annotation.NonNull;
-import androidx.annotation.RestrictTo;
-import androidx.annotation.RestrictTo.Scope;
-import androidx.wear.tiles.builders.ActionBuilders.Action;
-import androidx.wear.tiles.builders.ColorBuilders.ColorProp;
-import androidx.wear.tiles.builders.DimensionBuilders.ContainerDimension;
-import androidx.wear.tiles.builders.DimensionBuilders.DegreesProp;
-import androidx.wear.tiles.builders.DimensionBuilders.DpProp;
-import androidx.wear.tiles.builders.DimensionBuilders.ImageDimension;
-import androidx.wear.tiles.builders.DimensionBuilders.LinearOrAngularDimension;
-import androidx.wear.tiles.builders.DimensionBuilders.SpProp;
-import androidx.wear.tiles.proto.LayoutElementProto;
-import androidx.wear.tiles.proto.TypesProto;
-import androidx.wear.tiles.readers.DeviceParametersReaders.DeviceParameters;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-
-/**
- * Builders for composable layout elements that can be combined together to create renderable UI
- * layouts.
- */
-public final class LayoutElementBuilders {
- private LayoutElementBuilders() {}
-
- /**
- * The horizontal alignment of an element within its container.
- *
- * @hide
- */
- @RestrictTo(RestrictTo.Scope.LIBRARY)
- @IntDef({HALIGN_UNDEFINED, HALIGN_LEFT, HALIGN_CENTER, HALIGN_RIGHT, HALIGN_START, HALIGN_END})
- @Retention(RetentionPolicy.SOURCE)
- public @interface HorizontalAlignment {}
-
- /** Horizontal alignment is undefined. */
- public static final int HALIGN_UNDEFINED = 0;
-
- /** Horizontally align to the left. */
- public static final int HALIGN_LEFT = 1;
-
- /** Horizontally align to center. */
- public static final int HALIGN_CENTER = 2;
-
- /** Horizontally align to the right. */
- public static final int HALIGN_RIGHT = 3;
-
- /** Horizontally align to the content start (left in LTR layouts, right in RTL layouts). */
- public static final int HALIGN_START = 4;
-
- /** Horizontally align to the content end (right in LTR layouts, left in RTL layouts). */
- public static final int HALIGN_END = 5;
-
- /**
- * The vertical alignment of an element within its container.
- *
- * @hide
- */
- @RestrictTo(RestrictTo.Scope.LIBRARY)
- @IntDef({VALIGN_UNDEFINED, VALIGN_TOP, VALIGN_CENTER, VALIGN_BOTTOM})
- @Retention(RetentionPolicy.SOURCE)
- public @interface VerticalAlignment {}
-
- /** Vertical alignment is undefined. */
- public static final int VALIGN_UNDEFINED = 0;
-
- /** Vertically align to the top. */
- public static final int VALIGN_TOP = 1;
-
- /** Vertically align to center. */
- public static final int VALIGN_CENTER = 2;
-
- /** Vertically align to the bottom. */
- public static final int VALIGN_BOTTOM = 3;
-
- /**
- * The weight to be applied to the font.
- *
- * @hide
- */
- @RestrictTo(RestrictTo.Scope.LIBRARY)
- @IntDef({FONT_WEIGHT_UNDEFINED, FONT_WEIGHT_NORMAL, FONT_WEIGHT_BOLD})
- @Retention(RetentionPolicy.SOURCE)
- public @interface FontWeight {}
-
- /** Font weight is undefined. */
- public static final int FONT_WEIGHT_UNDEFINED = 0;
-
- /** Normal font weight. */
- public static final int FONT_WEIGHT_NORMAL = 400;
-
- /** Bold font weight. */
- public static final int FONT_WEIGHT_BOLD = 700;
-
- /**
- * Alignment of a text element.
- *
- * @hide
- */
- @RestrictTo(RestrictTo.Scope.LIBRARY)
- @IntDef({TEXT_ALIGN_UNDEFINED, TEXT_ALIGN_START, TEXT_ALIGN_CENTER, TEXT_ALIGN_END})
- @Retention(RetentionPolicy.SOURCE)
- public @interface TextAlignment {}
-
- /** Alignment is undefined. */
- public static final int TEXT_ALIGN_UNDEFINED = 0;
-
- /**
- * Align to the "start" of the {@link Text} element (left in LTR layouts, right in RTL layouts).
- */
- public static final int TEXT_ALIGN_START = 1;
-
- /** Align to the center of the {@link Text} element. */
- public static final int TEXT_ALIGN_CENTER = 2;
-
- /**
- * Align to the "end" of the {@link Text} element (right in LTR layouts, left in RTL layouts).
- */
- public static final int TEXT_ALIGN_END = 3;
-
- /**
- * How text that will not fit inside the bounds of a {@link Text} element will be handled.
- *
- * @hide
- */
- @RestrictTo(RestrictTo.Scope.LIBRARY)
- @IntDef({TEXT_OVERFLOW_UNDEFINED, TEXT_OVERFLOW_TRUNCATE, TEXT_OVERFLOW_ELLIPSIZE_END})
- @Retention(RetentionPolicy.SOURCE)
- public @interface TextOverflow {}
-
- /** Overflow behavior is undefined. */
- public static final int TEXT_OVERFLOW_UNDEFINED = 0;
-
- /**
- * Truncate the text to fit inside of the {@link Text} element's bounds. If text is truncated,
- * it will be truncated on a word boundary.
- */
- public static final int TEXT_OVERFLOW_TRUNCATE = 1;
-
- /**
- * Truncate the text to fit in the {@link Text} element's bounds, but add an ellipsis (i.e. ...)
- * to the end of the text if it has been truncated.
- */
- public static final int TEXT_OVERFLOW_ELLIPSIZE_END = 2;
-
- /**
- * The anchor position of an {@link Arc}'s elements. This is used to specify how elements added
- * to an {@link Arc} should be laid out with respect to anchor_angle.
- *
- * <p>As an example, assume that the following diagrams are wrapped to an arc, and each
- * represents an {@link Arc} element containing a single {@link Text} element. The {@link Text}
- * element's anchor_angle is "0" for all cases.
- *
- * <pre>{@code
- * ARC_ANCHOR_START:
- * -180 0 180
- * Hello World!
- *
- *
- * ARC_ANCHOR_CENTER:
- * -180 0 180
- * Hello World!
- *
- * ARC_ANCHOR_END:
- * -180 0 180
- * Hello World!
- *
- * }</pre>
- *
- * @hide
- */
- @RestrictTo(RestrictTo.Scope.LIBRARY)
- @IntDef({ARC_ANCHOR_UNDEFINED, ARC_ANCHOR_START, ARC_ANCHOR_CENTER, ARC_ANCHOR_END})
- @Retention(RetentionPolicy.SOURCE)
- public @interface ArcAnchorType {}
-
- /** Anchor position is undefined. */
- public static final int ARC_ANCHOR_UNDEFINED = 0;
-
- /**
- * Anchor at the start of the elements. This will cause elements added to an arc to begin at the
- * given anchor_angle, and sweep around to the right.
- */
- public static final int ARC_ANCHOR_START = 1;
-
- /**
- * Anchor at the center of the elements. This will cause the center of the whole set of elements
- * added to an arc to be pinned at the given anchor_angle.
- */
- public static final int ARC_ANCHOR_CENTER = 2;
-
- /**
- * Anchor at the end of the elements. This will cause the set of elements inside the arc to end
- * at the specified anchor_angle, i.e. all elements should be to the left of anchor_angle.
- */
- public static final int ARC_ANCHOR_END = 3;
-
- /**
- * How content which does not match the dimensions of its bounds (e.g. an image resource being
- * drawn inside an {@link Image}) will be resized to fit its bounds.
- *
- * @hide
- */
- @RestrictTo(RestrictTo.Scope.LIBRARY)
- @IntDef({
- CONTENT_SCALE_MODE_UNDEFINED,
- CONTENT_SCALE_MODE_FIT,
- CONTENT_SCALE_MODE_CROP,
- CONTENT_SCALE_MODE_FILL_BOUNDS
- })
- @Retention(RetentionPolicy.SOURCE)
- public @interface ContentScaleMode {}
-
- /** Content scaling is undefined. */
- public static final int CONTENT_SCALE_MODE_UNDEFINED = 0;
-
- /**
- * Content will be scaled to fit inside its bounds, proportionally. As an example, If a 10x5
- * image was going to be drawn inside a 50x50 {@link Image} element, the actual image resource
- * would be drawn as a 50x25 image, centered within the 50x50 bounds.
- */
- public static final int CONTENT_SCALE_MODE_FIT = 1;
-
- /**
- * Content will be resized proportionally so it completely fills its bounds, and anything
- * outside of the bounds will be cropped. As an example, if a 10x5 image was going to be drawn
- * inside a 50x50 {@link Image} element, the image resource would be drawn as a 100x50 image,
- * centered within its bounds (and with 25px cropped from both the left and right sides).
- */
- public static final int CONTENT_SCALE_MODE_CROP = 2;
-
- /**
- * Content will be resized to fill its bounds, without taking into account the aspect ratio. If
- * a 10x5 image was going to be drawn inside a 50x50 {@link Image} element, the image would be
- * drawn as a 50x50 image, stretched vertically.
- */
- public static final int CONTENT_SCALE_MODE_FILL_BOUNDS = 3;
-
- /** The styling of a font (e.g. font size, and metrics). */
- public static final class FontStyle {
- private final LayoutElementProto.FontStyle mImpl;
-
- FontStyle(LayoutElementProto.FontStyle impl) {
- this.mImpl = impl;
- }
-
- /** Returns a new {@link Builder}. */
- @NonNull
- public static Builder builder() {
- return new Builder();
- }
-
- /**
- * Get the protocol buffer representation of this object.
- *
- * @hide
- */
- @RestrictTo(Scope.LIBRARY)
- @NonNull
- public LayoutElementProto.FontStyle toProto() {
- return mImpl;
- }
-
- /** Builder for {@link FontStyle} */
- public static final class Builder {
- private final LayoutElementProto.FontStyle.Builder mImpl =
- LayoutElementProto.FontStyle.newBuilder();
-
- Builder() {}
-
- /**
- * Sets the size of the font, in scaled pixels (sp). If not specified, defaults to the
- * size of the system's "body" font.
- */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setSize(@NonNull SpProp size) {
- mImpl.setSize(size.toProto());
- return this;
- }
-
- /**
- * Sets the size of the font, in scaled pixels (sp). If not specified, defaults to the
- * size of the system's "body" font.
- */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setSize(@NonNull SpProp.Builder sizeBuilder) {
- mImpl.setSize(sizeBuilder.build().toProto());
- return this;
- }
-
- /**
- * Sets whether the text should be rendered in a bold typeface. If not specified,
- * defaults to "false".
- *
- * @deprecated Use weight instead.
- */
- @SuppressLint("MissingGetterMatchingBuilder")
- @Deprecated
- @NonNull
- public Builder setBold(boolean bold) {
- mImpl.setBold(TypesProto.BoolProp.newBuilder().setValue(bold));
- return this;
- }
-
- /**
- * Sets whether the text should be rendered in a italic typeface. If not specified,
- * defaults to "false".
- */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setItalic(boolean italic) {
- mImpl.setItalic(TypesProto.BoolProp.newBuilder().setValue(italic));
- return this;
- }
-
- /**
- * Sets whether the text should be rendered with an underline. If not specified,
- * defaults to "false".
- */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setUnderline(boolean underline) {
- mImpl.setUnderline(TypesProto.BoolProp.newBuilder().setValue(underline));
- return this;
- }
-
- /** Sets the text color. If not defined, defaults to white. */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setColor(@NonNull ColorProp color) {
- mImpl.setColor(color.toProto());
- return this;
- }
-
- /** Sets the text color. If not defined, defaults to white. */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setColor(@NonNull ColorProp.Builder colorBuilder) {
- mImpl.setColor(colorBuilder.build().toProto());
- return this;
- }
-
- /**
- * Sets the weight of the font. If the provided value is not supported on a platform,
- * the nearest supported value will be used. If not defined, or when set to an invalid
- * value, defaults to "normal".
- */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setWeight(@FontWeight int weight) {
- mImpl.setWeight(
- LayoutElementProto.FontWeightProp.newBuilder()
- .setValue(LayoutElementProto.FontWeight.forNumber(weight)));
- return this;
- }
-
- /** Builds an instance from accumulated values. */
- @NonNull
- public FontStyle build() {
- return new FontStyle(mImpl.build());
- }
- }
- }
-
- /** The padding around a {@link Box} element. */
- public static final class Padding {
- private final LayoutElementProto.Padding mImpl;
-
- Padding(LayoutElementProto.Padding impl) {
- this.mImpl = impl;
- }
-
- /** Returns a new {@link Builder}. */
- @NonNull
- public static Builder builder() {
- return new Builder();
- }
-
- /**
- * Get the protocol buffer representation of this object.
- *
- * @hide
- */
- @RestrictTo(Scope.LIBRARY)
- @NonNull
- public LayoutElementProto.Padding toProto() {
- return mImpl;
- }
-
- /** Builder for {@link Padding} */
- public static final class Builder {
- private final LayoutElementProto.Padding.Builder mImpl =
- LayoutElementProto.Padding.newBuilder();
-
- Builder() {}
-
- /**
- * Sets the padding on the end of the content, depending on the layout direction, in DP
- * and the value of "rtl_aware".
- */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setEnd(@NonNull DpProp end) {
- mImpl.setEnd(end.toProto());
- return this;
- }
-
- /**
- * Sets the padding on the end of the content, depending on the layout direction, in DP
- * and the value of "rtl_aware".
- */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setEnd(@NonNull DpProp.Builder endBuilder) {
- mImpl.setEnd(endBuilder.build().toProto());
- return this;
- }
-
- /**
- * Sets the padding on the start of the content, depending on the layout direction, in
- * DP and the value of "rtl_aware".
- */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setStart(@NonNull DpProp start) {
- mImpl.setStart(start.toProto());
- return this;
- }
-
- /**
- * Sets the padding on the start of the content, depending on the layout direction, in
- * DP and the value of "rtl_aware".
- */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setStart(@NonNull DpProp.Builder startBuilder) {
- mImpl.setStart(startBuilder.build().toProto());
- return this;
- }
-
- /** Sets the padding at the top, in DP. */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setTop(@NonNull DpProp top) {
- mImpl.setTop(top.toProto());
- return this;
- }
-
- /** Sets the padding at the top, in DP. */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setTop(@NonNull DpProp.Builder topBuilder) {
- mImpl.setTop(topBuilder.build().toProto());
- return this;
- }
-
- /** Sets the padding at the bottom, in DP. */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setBottom(@NonNull DpProp bottom) {
- mImpl.setBottom(bottom.toProto());
- return this;
- }
-
- /** Sets the padding at the bottom, in DP. */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setBottom(@NonNull DpProp.Builder bottomBuilder) {
- mImpl.setBottom(bottomBuilder.build().toProto());
- return this;
- }
-
- /**
- * Sets whether the start/end padding is aware of RTL support. If true, the values for
- * start/end will follow the layout direction (i.e. start will refer to the right hand
- * side of the container if the device is using an RTL locale). If false, start/end will
- * always map to left/right, accordingly.
- */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setRtlAware(boolean rtlAware) {
- mImpl.setRtlAware(TypesProto.BoolProp.newBuilder().setValue(rtlAware));
- return this;
- }
-
- /** Builds an instance from accumulated values. */
- @NonNull
- public Padding build() {
- return new Padding(mImpl.build());
- }
- }
- }
-
- /** The border around a {@link Box} element. */
- public static final class Border {
- private final LayoutElementProto.Border mImpl;
-
- Border(LayoutElementProto.Border impl) {
- this.mImpl = impl;
- }
-
- /** Returns a new {@link Builder}. */
- @NonNull
- public static Builder builder() {
- return new Builder();
- }
-
- /**
- * Get the protocol buffer representation of this object.
- *
- * @hide
- */
- @RestrictTo(Scope.LIBRARY)
- @NonNull
- public LayoutElementProto.Border toProto() {
- return mImpl;
- }
-
- /** Builder for {@link Border} */
- public static final class Builder {
- private final LayoutElementProto.Border.Builder mImpl =
- LayoutElementProto.Border.newBuilder();
-
- Builder() {}
-
- /** Sets the width of the border, in DP. */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setWidth(@NonNull DpProp width) {
- mImpl.setWidth(width.toProto());
- return this;
- }
-
- /** Sets the width of the border, in DP. */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setWidth(@NonNull DpProp.Builder widthBuilder) {
- mImpl.setWidth(widthBuilder.build().toProto());
- return this;
- }
-
- /** Sets the color of the border. */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setColor(@NonNull ColorProp color) {
- mImpl.setColor(color.toProto());
- return this;
- }
-
- /** Sets the color of the border. */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setColor(@NonNull ColorProp.Builder colorBuilder) {
- mImpl.setColor(colorBuilder.build().toProto());
- return this;
- }
-
- /** Builds an instance from accumulated values. */
- @NonNull
- public Border build() {
- return new Border(mImpl.build());
- }
- }
- }
-
- /** The corner of a {@link Box} element. */
- public static final class Corner {
- private final LayoutElementProto.Corner mImpl;
-
- Corner(LayoutElementProto.Corner impl) {
- this.mImpl = impl;
- }
-
- /** Returns a new {@link Builder}. */
- @NonNull
- public static Builder builder() {
- return new Builder();
- }
-
- /**
- * Get the protocol buffer representation of this object.
- *
- * @hide
- */
- @RestrictTo(Scope.LIBRARY)
- @NonNull
- public LayoutElementProto.Corner toProto() {
- return mImpl;
- }
-
- /** Builder for {@link Corner} */
- public static final class Builder {
- private final LayoutElementProto.Corner.Builder mImpl =
- LayoutElementProto.Corner.newBuilder();
-
- Builder() {}
-
- /** Sets the radius of the corner in DP. */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setRadius(@NonNull DpProp radius) {
- mImpl.setRadius(radius.toProto());
- return this;
- }
-
- /** Sets the radius of the corner in DP. */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setRadius(@NonNull DpProp.Builder radiusBuilder) {
- mImpl.setRadius(radiusBuilder.build().toProto());
- return this;
- }
-
- /** Builds an instance from accumulated values. */
- @NonNull
- public Corner build() {
- return new Corner(mImpl.build());
- }
- }
- }
-
- /** The style of a {@link Text} element. */
- public static final class TextStyle {
- private final LayoutElementProto.TextStyle mImpl;
-
- TextStyle(LayoutElementProto.TextStyle impl) {
- this.mImpl = impl;
- }
-
- /** Returns a new {@link Builder}. */
- @NonNull
- public static Builder builder() {
- return new Builder();
- }
-
- /**
- * Get the protocol buffer representation of this object.
- *
- * @hide
- */
- @RestrictTo(Scope.LIBRARY)
- @NonNull
- public LayoutElementProto.TextStyle toProto() {
- return mImpl;
- }
-
- /** Builder for {@link TextStyle} */
- public static final class Builder {
- private final LayoutElementProto.TextStyle.Builder mImpl =
- LayoutElementProto.TextStyle.newBuilder();
-
- Builder() {}
-
- /**
- * Sets the text color. If not defined, defaults to white.
- *
- * @deprecated Use color property of {@link FontStyle} instead.
- */
- @SuppressLint("MissingGetterMatchingBuilder")
- @Deprecated
- @NonNull
- public Builder setColor(@NonNull ColorProp color) {
- mImpl.setColor(color.toProto());
- return this;
- }
-
- /**
- * Sets the text color. If not defined, defaults to white.
- *
- * @deprecated Use color property of {@link FontStyle} instead.
- */
- @SuppressLint("MissingGetterMatchingBuilder")
- @Deprecated
- @NonNull
- public Builder setColor(@NonNull ColorProp.Builder colorBuilder) {
- mImpl.setColor(colorBuilder.build().toProto());
- return this;
- }
-
- /**
- * Sets the maximum number of lines that can be represented by the {@link Text} element.
- * If not defined, the {@link Text} element will be treated as a single-line element.
- */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setMaxLines(@IntRange(from = 0) int maxLines) {
- mImpl.setMaxLines(TypesProto.Int32Prop.newBuilder().setValue(maxLines));
- return this;
- }
-
- /**
- * Sets alignment of the text within its bounds. Note that a {@link Text} element will
- * size itself to wrap its contents, so this option is meaningless for single-line text
- * (for that, use alignment of the outer container). For multi-line text, however, this
- * will set the alignment of lines relative to the {@link Text} element bounds. If not
- * defined, defaults to TEXT_ALIGN_CENTER.
- */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setMultilineAlignment(@TextAlignment int multilineAlignment) {
- mImpl.setMultilineAlignment(
- LayoutElementProto.TextAlignmentProp.newBuilder()
- .setValue(
- LayoutElementProto.TextAlignment.forNumber(
- multilineAlignment)));
- return this;
- }
-
- /**
- * Sets specifies how to handle text which overflows the bound of the {@link Text}
- * element. A {@link Text} element will grow as large as possible inside its parent
- * container (while still respecting max_lines); if it cannot grow large enough to
- * render all of its text, the text which cannot fit inside its container will be
- * truncated. If not defined, defaults to TEXT_OVERFLOW_TRUNCATE.
- */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setOverflow(@TextOverflow int overflow) {
- mImpl.setOverflow(
- LayoutElementProto.TextOverflowProp.newBuilder()
- .setValue(LayoutElementProto.TextOverflow.forNumber(overflow)));
- return this;
- }
-
- /** Builds an instance from accumulated values. */
- @NonNull
- public TextStyle build() {
- return new TextStyle(mImpl.build());
- }
- }
- }
-
- /** The style of a {@link Spannable} element. */
- public static final class SpannableStyle {
- private final LayoutElementProto.SpannableStyle mImpl;
-
- SpannableStyle(LayoutElementProto.SpannableStyle impl) {
- this.mImpl = impl;
- }
-
- /** Returns a new {@link Builder}. */
- @NonNull
- public static Builder builder() {
- return new Builder();
- }
-
- /**
- * Get the protocol buffer representation of this object.
- *
- * @hide
- */
- @RestrictTo(Scope.LIBRARY)
- @NonNull
- public LayoutElementProto.SpannableStyle toProto() {
- return mImpl;
- }
-
- /** Builder for {@link SpannableStyle} */
- public static final class Builder {
- private final LayoutElementProto.SpannableStyle.Builder mImpl =
- LayoutElementProto.SpannableStyle.newBuilder();
-
- Builder() {}
-
- /**
- * Sets the maximum number of lines that can be represented by the {@link Spannable}
- * element. If not defined, the {@link Text} element will be treated as a single-line
- * element.
- */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setMaxLines(@IntRange(from = 0) int maxLines) {
- mImpl.setMaxLines(TypesProto.Int32Prop.newBuilder().setValue(maxLines));
- return this;
- }
-
- /**
- * Sets alignment of the {@link Spannable} content within its bounds. Note that a {@link
- * Spannable} element will size itself to wrap its contents, so this option is
- * meaningless for single-line content (for that, use alignment of the outer container).
- * For multi-line content, however, this will set the alignment of lines relative to the
- * {@link Spannable} element bounds. If not defined, defaults to TEXT_ALIGN_CENTER.
- */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setMultilineAlignment(@HorizontalAlignment int multilineAlignment) {
- mImpl.setMultilineAlignment(
- LayoutElementProto.HorizontalAlignmentProp.newBuilder()
- .setValue(
- LayoutElementProto.HorizontalAlignment.forNumber(
- multilineAlignment)));
- return this;
- }
-
- /**
- * Sets specifies how to handle content which overflows the bound of the {@link
- * Spannable} element. A {@link Spannable} element will grow as large as possible inside
- * its parent container (while still respecting max_lines); if it cannot grow large
- * enough to render all of its content, the content which cannot fit inside its
- * container will be truncated. If not defined, defaults to TEXT_OVERFLOW_TRUNCATE.
- */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setOverflow(@TextOverflow int overflow) {
- mImpl.setOverflow(
- LayoutElementProto.TextOverflowProp.newBuilder()
- .setValue(LayoutElementProto.TextOverflow.forNumber(overflow)));
- return this;
- }
-
- /** Builds an instance from accumulated values. */
- @NonNull
- public SpannableStyle build() {
- return new SpannableStyle(mImpl.build());
- }
- }
- }
-
- /** The style of a {@link Box}. */
- public static final class BoxStyle {
- private final LayoutElementProto.BoxStyle mImpl;
-
- BoxStyle(LayoutElementProto.BoxStyle impl) {
- this.mImpl = impl;
- }
-
- /** Returns a new {@link Builder}. */
- @NonNull
- public static Builder builder() {
- return new Builder();
- }
-
- /**
- * Get the protocol buffer representation of this object.
- *
- * @hide
- */
- @RestrictTo(Scope.LIBRARY)
- @NonNull
- public LayoutElementProto.BoxStyle toProto() {
- return mImpl;
- }
-
- /** Builder for {@link BoxStyle} */
- public static final class Builder {
- private final LayoutElementProto.BoxStyle.Builder mImpl =
- LayoutElementProto.BoxStyle.newBuilder();
-
- Builder() {}
-
- /**
- * Sets the background color for this {@link Box}. If not defined, defaults to being
- * transparent.
- */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setBackgroundColor(@NonNull ColorProp backgroundColor) {
- mImpl.setBackgroundColor(backgroundColor.toProto());
- return this;
- }
-
- /**
- * Sets the background color for this {@link Box}. If not defined, defaults to being
- * transparent.
- */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setBackgroundColor(@NonNull ColorProp.Builder backgroundColorBuilder) {
- mImpl.setBackgroundColor(backgroundColorBuilder.build().toProto());
- return this;
- }
-
- /**
- * Sets an optional padding inside of this {@link Box}. If not defined, {@link Box} will
- * not have any padding.
- */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setPadding(@NonNull Padding padding) {
- mImpl.setPadding(padding.toProto());
- return this;
- }
-
- /**
- * Sets an optional padding inside of this {@link Box}. If not defined, {@link Box} will
- * not have any padding.
- */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setPadding(@NonNull Padding.Builder paddingBuilder) {
- mImpl.setPadding(paddingBuilder.build().toProto());
- return this;
- }
-
- /**
- * Sets an optional border for this {@link Box}. If not defined, {@link Box} will not
- * have a border.
- */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setBorder(@NonNull Border border) {
- mImpl.setBorder(border.toProto());
- return this;
- }
-
- /**
- * Sets an optional border for this {@link Box}. If not defined, {@link Box} will not
- * have a border.
- */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setBorder(@NonNull Border.Builder borderBuilder) {
- mImpl.setBorder(borderBuilder.build().toProto());
- return this;
- }
-
- /**
- * Sets the corner properties of this {@link Box}. This only affects the drawing of this
- * {@link Box} if either "color" or "border" are also set. If not defined, defaults to
- * having a square corner.
- */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setCorner(@NonNull Corner corner) {
- mImpl.setCorner(corner.toProto());
- return this;
- }
-
- /**
- * Sets the corner properties of this {@link Box}. This only affects the drawing of this
- * {@link Box} if either "color" or "border" are also set. If not defined, defaults to
- * having a square corner.
- */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setCorner(@NonNull Corner.Builder cornerBuilder) {
- mImpl.setCorner(cornerBuilder.build().toProto());
- return this;
- }
-
- /** Builds an instance from accumulated values. */
- @NonNull
- public BoxStyle build() {
- return new BoxStyle(mImpl.build());
- }
- }
- }
-
- /** The style of a line. */
- public static final class LineStyle {
- private final LayoutElementProto.LineStyle mImpl;
-
- LineStyle(LayoutElementProto.LineStyle impl) {
- this.mImpl = impl;
- }
-
- /** Returns a new {@link Builder}. */
- @NonNull
- public static Builder builder() {
- return new Builder();
- }
-
- /**
- * Get the protocol buffer representation of this object.
- *
- * @hide
- */
- @RestrictTo(Scope.LIBRARY)
- @NonNull
- public LayoutElementProto.LineStyle toProto() {
- return mImpl;
- }
-
- /** Builder for {@link LineStyle} */
- public static final class Builder {
- private final LayoutElementProto.LineStyle.Builder mImpl =
- LayoutElementProto.LineStyle.newBuilder();
-
- Builder() {}
-
- /** Sets color of this line. If not defined, defaults to white. */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setColor(@NonNull ColorProp color) {
- mImpl.setColor(color.toProto());
- return this;
- }
-
- /** Sets color of this line. If not defined, defaults to white. */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setColor(@NonNull ColorProp.Builder colorBuilder) {
- mImpl.setColor(colorBuilder.build().toProto());
- return this;
- }
-
- /** Builds an instance from accumulated values. */
- @NonNull
- public LineStyle build() {
- return new LineStyle(mImpl.build());
- }
- }
- }
-
- /** A text string. */
- public static final class Text implements Span, LayoutElement {
- private final LayoutElementProto.Text mImpl;
-
- Text(LayoutElementProto.Text impl) {
- this.mImpl = impl;
- }
-
- /** Returns a new {@link Builder}. */
- @NonNull
- public static Builder builder() {
- return new Builder();
- }
-
- /** @hide */
- @RestrictTo(Scope.LIBRARY)
- @NonNull
- LayoutElementProto.Text toProto() {
- return mImpl;
- }
-
- /** @hide */
- @Override
- @RestrictTo(Scope.LIBRARY)
- @NonNull
- public LayoutElementProto.Span toSpanProto() {
- return LayoutElementProto.Span.newBuilder().setText(mImpl).build();
- }
-
- /** @hide */
- @Override
- @RestrictTo(Scope.LIBRARY)
- @NonNull
- public LayoutElementProto.LayoutElement toLayoutElementProto() {
- return LayoutElementProto.LayoutElement.newBuilder().setText(mImpl).build();
- }
-
- /** Builder for {@link Text}. */
- public static final class Builder implements Span.Builder, LayoutElement.Builder {
- private final LayoutElementProto.Text.Builder mImpl =
- LayoutElementProto.Text.newBuilder();
-
- Builder() {}
-
- /** Sets the text to render. */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setText(@NonNull String text) {
- mImpl.setText(TypesProto.StringProp.newBuilder().setValue(text));
- return this;
- }
-
- /**
- * Sets an optional style for this text string.
- *
- * @deprecated Use {@link Spannable} with {@link SpannableStyle} instead.
- */
- @SuppressLint("MissingGetterMatchingBuilder")
- @Deprecated
- @NonNull
- public Builder setStyle(@NonNull TextStyle style) {
- mImpl.setStyle(style.toProto());
- return this;
- }
-
- /**
- * Sets an optional style for this text string.
- *
- * @deprecated Use {@link Spannable} with {@link SpannableStyle} instead.
- */
- @SuppressLint("MissingGetterMatchingBuilder")
- @Deprecated
- @NonNull
- public Builder setStyle(@NonNull TextStyle.Builder styleBuilder) {
- mImpl.setStyle(styleBuilder.build().toProto());
- return this;
- }
-
- /**
- * Sets the style of font to use (size, bold etc). If not specified, defaults to the
- * platform's default body font.
- */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setFontStyle(@NonNull FontStyle fontStyle) {
- mImpl.setFontStyle(fontStyle.toProto());
- return this;
- }
-
- /**
- * Sets the style of font to use (size, bold etc). If not specified, defaults to the
- * platform's default body font.
- */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setFontStyle(@NonNull FontStyle.Builder fontStyleBuilder) {
- mImpl.setFontStyle(fontStyleBuilder.build().toProto());
- return this;
- }
-
- @Override
- @NonNull
- public Text build() {
- return new Text(mImpl.build());
- }
- }
- }
-
- /**
- * A holder for an element which can have associated {@link
- * androidx.wear.tiles.builders.ActionBuilders.Action} items for click events. When an element
- * wrapped in a {@link Clickable} is clicked, it will fire the associated action.
- */
- public static final class Clickable implements LayoutElement {
- private final LayoutElementProto.Clickable mImpl;
-
- Clickable(LayoutElementProto.Clickable impl) {
- this.mImpl = impl;
- }
-
- /** Returns a new {@link Builder}. */
- @NonNull
- public static Builder builder() {
- return new Builder();
- }
-
- /** @hide */
- @RestrictTo(Scope.LIBRARY)
- @NonNull
- LayoutElementProto.Clickable toProto() {
- return mImpl;
- }
-
- /** @hide */
- @Override
- @RestrictTo(Scope.LIBRARY)
- @NonNull
- public LayoutElementProto.LayoutElement toLayoutElementProto() {
- return LayoutElementProto.LayoutElement.newBuilder().setClickable(mImpl).build();
- }
-
- /** Builder for {@link Clickable}. */
- public static final class Builder implements LayoutElement.Builder {
- private final LayoutElementProto.Clickable.Builder mImpl =
- LayoutElementProto.Clickable.newBuilder();
-
- Builder() {}
-
- /** Sets the ID associated with this action. */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setId(@NonNull String id) {
- mImpl.setId(id);
- return this;
- }
-
- /** Sets the layout element to attach the action to. */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setContent(@NonNull LayoutElement content) {
- mImpl.setContent(content.toLayoutElementProto());
- return this;
- }
-
- /** Sets the layout element to attach the action to. */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setContent(@NonNull LayoutElement.Builder contentBuilder) {
- mImpl.setContent(contentBuilder.build().toLayoutElementProto());
- return this;
- }
-
- /** Sets the action to perform when "content" is clicked. */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setOnClick(@NonNull Action onClick) {
- mImpl.setOnClick(onClick.toActionProto());
- return this;
- }
-
- /** Sets the action to perform when "content" is clicked. */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setOnClick(@NonNull Action.Builder onClickBuilder) {
- mImpl.setOnClick(onClickBuilder.build().toActionProto());
- return this;
- }
-
- @Override
- @NonNull
- public Clickable build() {
- return new Clickable(mImpl.build());
- }
- }
- }
-
- /**
- * An image.
- *
- * <p>Images used in this element must exist in the resource bundle that corresponds to this
- * layout. Images must have their dimension specified, and will be rendered at this width and
- * height, regardless of their native dimension.
- */
- public static final class Image implements LayoutElement {
- private final LayoutElementProto.Image mImpl;
-
- Image(LayoutElementProto.Image impl) {
- this.mImpl = impl;
- }
-
- /** Returns a new {@link Builder}. */
- @NonNull
- public static Builder builder() {
- return new Builder();
- }
-
- /** @hide */
- @RestrictTo(Scope.LIBRARY)
- @NonNull
- LayoutElementProto.Image toProto() {
- return mImpl;
- }
-
- /** @hide */
- @Override
- @RestrictTo(Scope.LIBRARY)
- @NonNull
- public LayoutElementProto.LayoutElement toLayoutElementProto() {
- return LayoutElementProto.LayoutElement.newBuilder().setImage(mImpl).build();
- }
-
- /** Builder for {@link Image}. */
- public static final class Builder implements LayoutElement.Builder {
- private final LayoutElementProto.Image.Builder mImpl =
- LayoutElementProto.Image.newBuilder();
-
- Builder() {}
-
- /**
- * Sets the resource_id of the image to render. This must exist in the supplied resource
- * bundle.
- */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setResourceId(@NonNull String resourceId) {
- mImpl.setResourceId(TypesProto.StringProp.newBuilder().setValue(resourceId));
- return this;
- }
-
- /** Sets the width of this image. If not defined, the image will not be rendered. */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setWidth(@NonNull ImageDimension width) {
- mImpl.setWidth(width.toImageDimensionProto());
- return this;
- }
-
- /** Sets the width of this image. If not defined, the image will not be rendered. */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setWidth(@NonNull ImageDimension.Builder widthBuilder) {
- mImpl.setWidth(widthBuilder.build().toImageDimensionProto());
- return this;
- }
-
- /** Sets the height of this image. If not defined, the image will not be rendered. */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setHeight(@NonNull ImageDimension height) {
- mImpl.setHeight(height.toImageDimensionProto());
- return this;
- }
-
- /** Sets the height of this image. If not defined, the image will not be rendered. */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setHeight(@NonNull ImageDimension.Builder heightBuilder) {
- mImpl.setHeight(heightBuilder.build().toImageDimensionProto());
- return this;
- }
-
- /**
- * Sets how to scale the image resource inside the bounds specified by width/height if
- * its size does not match those bounds. Defaults to CONTENT_SCALE_MODE_FIT.
- */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setContentScaleMode(@ContentScaleMode int contentScaleMode) {
- mImpl.setContentScaleMode(
- LayoutElementProto.ContentScaleModeProp.newBuilder()
- .setValue(
- LayoutElementProto.ContentScaleMode.forNumber(
- contentScaleMode)));
- return this;
- }
-
- @Override
- @NonNull
- public Image build() {
- return new Image(mImpl.build());
- }
- }
- }
-
- /** A simple spacer, typically used to provide padding between adjacent elements. */
- public static final class Spacer implements LayoutElement {
- private final LayoutElementProto.Spacer mImpl;
-
- Spacer(LayoutElementProto.Spacer impl) {
- this.mImpl = impl;
- }
-
- /** Returns a new {@link Builder}. */
- @NonNull
- public static Builder builder() {
- return new Builder();
- }
-
- /** @hide */
- @RestrictTo(Scope.LIBRARY)
- @NonNull
- LayoutElementProto.Spacer toProto() {
- return mImpl;
- }
-
- /** @hide */
- @Override
- @RestrictTo(Scope.LIBRARY)
- @NonNull
- public LayoutElementProto.LayoutElement toLayoutElementProto() {
- return LayoutElementProto.LayoutElement.newBuilder().setSpacer(mImpl).build();
- }
-
- /** Builder for {@link Spacer}. */
- public static final class Builder implements LayoutElement.Builder {
- private final LayoutElementProto.Spacer.Builder mImpl =
- LayoutElementProto.Spacer.newBuilder();
-
- Builder() {}
-
- /**
- * Sets the width of this {@link Spacer}. When this is added as the direct child of an
- * {@link Arc}, this must be specified as an angular dimension, otherwise a linear
- * dimension must be used. If not defined, defaults to 0.
- */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setWidth(@NonNull LinearOrAngularDimension width) {
- mImpl.setWidth(width.toLinearOrAngularDimensionProto());
- return this;
- }
-
- /**
- * Sets the width of this {@link Spacer}. When this is added as the direct child of an
- * {@link Arc}, this must be specified as an angular dimension, otherwise a linear
- * dimension must be used. If not defined, defaults to 0.
- */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setWidth(@NonNull LinearOrAngularDimension.Builder widthBuilder) {
- mImpl.setWidth(widthBuilder.build().toLinearOrAngularDimensionProto());
- return this;
- }
-
- /** Sets the height of this spacer. If not defined, defaults to 0. */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setHeight(@NonNull DpProp height) {
- mImpl.setHeight(height.toProto());
- return this;
- }
-
- /** Sets the height of this spacer. If not defined, defaults to 0. */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setHeight(@NonNull DpProp.Builder heightBuilder) {
- mImpl.setHeight(heightBuilder.build().toProto());
- return this;
- }
-
- @Override
- @NonNull
- public Spacer build() {
- return new Spacer(mImpl.build());
- }
- }
- }
-
- /**
- * A container which stacks all of its children on top of one another. This also allows to add a
- * background color, or to have a border around them with some padding.
- */
- public static final class Box implements LayoutElement {
- private final LayoutElementProto.Box mImpl;
-
- Box(LayoutElementProto.Box impl) {
- this.mImpl = impl;
- }
-
- /** Returns a new {@link Builder}. */
- @NonNull
- public static Builder builder() {
- return new Builder();
- }
-
- /** @hide */
- @RestrictTo(Scope.LIBRARY)
- @NonNull
- LayoutElementProto.Box toProto() {
- return mImpl;
- }
-
- /** @hide */
- @Override
- @RestrictTo(Scope.LIBRARY)
- @NonNull
- public LayoutElementProto.LayoutElement toLayoutElementProto() {
- return LayoutElementProto.LayoutElement.newBuilder().setBox(mImpl).build();
- }
-
- /** Builder for {@link Box}. */
- public static final class Builder implements LayoutElement.Builder {
- private final LayoutElementProto.Box.Builder mImpl =
- LayoutElementProto.Box.newBuilder();
-
- Builder() {}
-
- /** Adds one item to the child element(s) to wrap. */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder addContent(@NonNull LayoutElement content) {
- mImpl.addContents(content.toLayoutElementProto());
- return this;
- }
-
- /** Adds one item to the child element(s) to wrap. */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder addContent(@NonNull LayoutElement.Builder contentBuilder) {
- mImpl.addContents(contentBuilder.build().toLayoutElementProto());
- return this;
- }
-
- /** Sets the style of the {@link Box} (padding, background color, border etc). */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setStyle(@NonNull BoxStyle style) {
- mImpl.setStyle(style.toProto());
- return this;
- }
-
- /** Sets the style of the {@link Box} (padding, background color, border etc). */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setStyle(@NonNull BoxStyle.Builder styleBuilder) {
- mImpl.setStyle(styleBuilder.build().toProto());
- return this;
- }
-
- /**
- * Sets the height of this {@link Box}. If not defined, this will size itself to fit all
- * of its children (i.e. a WrappedDimension).
- */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setHeight(@NonNull ContainerDimension height) {
- mImpl.setHeight(height.toContainerDimensionProto());
- return this;
- }
-
- /**
- * Sets the height of this {@link Box}. If not defined, this will size itself to fit all
- * of its children (i.e. a WrappedDimension).
- */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setHeight(@NonNull ContainerDimension.Builder heightBuilder) {
- mImpl.setHeight(heightBuilder.build().toContainerDimensionProto());
- return this;
- }
-
- /**
- * Sets the width of this {@link Box}. If not defined, this will size itself to fit all
- * of its children (i.e. a WrappedDimension).
- */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setWidth(@NonNull ContainerDimension width) {
- mImpl.setWidth(width.toContainerDimensionProto());
- return this;
- }
-
- /**
- * Sets the width of this {@link Box}. If not defined, this will size itself to fit all
- * of its children (i.e. a WrappedDimension).
- */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setWidth(@NonNull ContainerDimension.Builder widthBuilder) {
- mImpl.setWidth(widthBuilder.build().toContainerDimensionProto());
- return this;
- }
-
- /**
- * Sets the horizontal alignment of the element inside this {@link Box}. If not defined,
- * defaults to HALIGN_CENTER.
- */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setHorizontalAlignment(@HorizontalAlignment int horizontalAlignment) {
- mImpl.setHorizontalAlignment(
- LayoutElementProto.HorizontalAlignmentProp.newBuilder()
- .setValue(
- LayoutElementProto.HorizontalAlignment.forNumber(
- horizontalAlignment)));
- return this;
- }
-
- /**
- * Sets the vertical alignment of the element inside this {@link Box}. If not defined,
- * defaults to VALIGN_CENTER.
- */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setVerticalAlignment(@VerticalAlignment int verticalAlignment) {
- mImpl.setVerticalAlignment(
- LayoutElementProto.VerticalAlignmentProp.newBuilder()
- .setValue(
- LayoutElementProto.VerticalAlignment.forNumber(
- verticalAlignment)));
- return this;
- }
-
- @Override
- @NonNull
- public Box build() {
- return new Box(mImpl.build());
- }
- }
- }
-
- /**
- * Interface defining a single {@link Span}. Each {@link Span} forms part of a larger {@link
- * Spannable} widget. At the moment, the only widgets which can be added to {@link Spannable}
- * containers are {@link Text} elements.
- */
- public interface Span {
- /**
- * Get the protocol buffer representation of this object.
- *
- * @hide
- */
- @RestrictTo(Scope.LIBRARY)
- @NonNull
- LayoutElementProto.Span toSpanProto();
-
- /** Builder to create {@link Span} objects. */
- @SuppressLint("StaticFinalBuilder")
- interface Builder {
-
- /** Builds an instance with values accumulated in this Builder. */
- @NonNull
- Span build();
- }
- }
-
- /**
- * A container of {@link Span} elements. Currently, this only supports {@link Text} elements,
- * where each individual {@link Span} can have different styling applied to it but the resulting
- * text will flow naturally. This allows sections of a paragraph of text to have different
- * styling applied to it, for example, making one or two words bold or italic.
- */
- public static final class Spannable implements LayoutElement {
- private final LayoutElementProto.Spannable mImpl;
-
- Spannable(LayoutElementProto.Spannable impl) {
- this.mImpl = impl;
- }
-
- /** Returns a new {@link Builder}. */
- @NonNull
- public static Builder builder() {
- return new Builder();
- }
-
- /** @hide */
- @RestrictTo(Scope.LIBRARY)
- @NonNull
- LayoutElementProto.Spannable toProto() {
- return mImpl;
- }
-
- /** @hide */
- @Override
- @RestrictTo(Scope.LIBRARY)
- @NonNull
- public LayoutElementProto.LayoutElement toLayoutElementProto() {
- return LayoutElementProto.LayoutElement.newBuilder().setSpannable(mImpl).build();
- }
-
- /** Builder for {@link Spannable}. */
- public static final class Builder implements LayoutElement.Builder {
- private final LayoutElementProto.Spannable.Builder mImpl =
- LayoutElementProto.Spannable.newBuilder();
-
- Builder() {}
-
- /** Adds one item to the {@link Span} elements that form this {@link Spannable}. */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder addSpan(@NonNull Span span) {
- mImpl.addSpans(span.toSpanProto());
- return this;
- }
-
- /** Adds one item to the {@link Span} elements that form this {@link Spannable}. */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder addSpan(@NonNull Span.Builder spanBuilder) {
- mImpl.addSpans(spanBuilder.build().toSpanProto());
- return this;
- }
-
- /** Sets the style of this {@link Spannable}. */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setStyle(@NonNull SpannableStyle style) {
- mImpl.setStyle(style.toProto());
- return this;
- }
-
- /** Sets the style of this {@link Spannable}. */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setStyle(@NonNull SpannableStyle.Builder styleBuilder) {
- mImpl.setStyle(styleBuilder.build().toProto());
- return this;
- }
-
- @Override
- @NonNull
- public Spannable build() {
- return new Spannable(mImpl.build());
- }
- }
- }
-
- /**
- * A column of elements. Each child element will be laid out vertically, one after another (i.e.
- * stacking down). This element will size itself to the smallest size required to hold all of
- * its children (e.g. if it contains three elements sized 10x10, 20x20 and 30x30, the resulting
- * column will be 30x60).
- *
- * <p>If specified, horizontal_alignment can be used to control the gravity inside the
- * container, affecting the horizontal placement of children whose width are smaller than the
- * resulting column width.
- */
- public static final class Column implements LayoutElement {
- private final LayoutElementProto.Column mImpl;
-
- Column(LayoutElementProto.Column impl) {
- this.mImpl = impl;
- }
-
- /** Returns a new {@link Builder}. */
- @NonNull
- public static Builder builder() {
- return new Builder();
- }
-
- /** @hide */
- @RestrictTo(Scope.LIBRARY)
- @NonNull
- LayoutElementProto.Column toProto() {
- return mImpl;
- }
-
- /** @hide */
- @Override
- @RestrictTo(Scope.LIBRARY)
- @NonNull
- public LayoutElementProto.LayoutElement toLayoutElementProto() {
- return LayoutElementProto.LayoutElement.newBuilder().setColumn(mImpl).build();
- }
-
- /** Builder for {@link Column}. */
- public static final class Builder implements LayoutElement.Builder {
- private final LayoutElementProto.Column.Builder mImpl =
- LayoutElementProto.Column.newBuilder();
-
- Builder() {}
-
- /** Adds one item to the list of child elements to place inside this {@link Column}. */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder addContent(@NonNull LayoutElement content) {
- mImpl.addContents(content.toLayoutElementProto());
- return this;
- }
-
- /** Adds one item to the list of child elements to place inside this {@link Column}. */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder addContent(@NonNull LayoutElement.Builder contentBuilder) {
- mImpl.addContents(contentBuilder.build().toLayoutElementProto());
- return this;
- }
-
- /**
- * Sets the horizontal alignment of elements inside this column, if they are narrower
- * than the resulting width of the column. If not defined, defaults to HALIGN_CENTER.
- */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setHorizontalAlignment(@HorizontalAlignment int horizontalAlignment) {
- mImpl.setHorizontalAlignment(
- LayoutElementProto.HorizontalAlignmentProp.newBuilder()
- .setValue(
- LayoutElementProto.HorizontalAlignment.forNumber(
- horizontalAlignment)));
- return this;
- }
-
- /**
- * Sets the width of this column. If not defined, this will size itself to fit all of
- * its children (i.e. a WrappedDimension).
- */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setWidth(@NonNull ContainerDimension width) {
- mImpl.setWidth(width.toContainerDimensionProto());
- return this;
- }
-
- /**
- * Sets the width of this column. If not defined, this will size itself to fit all of
- * its children (i.e. a WrappedDimension).
- */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setWidth(@NonNull ContainerDimension.Builder widthBuilder) {
- mImpl.setWidth(widthBuilder.build().toContainerDimensionProto());
- return this;
- }
-
- /**
- * Sets the height of this column. If not defined, this will size itself to fit all of
- * its children (i.e. a WrappedDimension).
- */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setHeight(@NonNull ContainerDimension height) {
- mImpl.setHeight(height.toContainerDimensionProto());
- return this;
- }
-
- /**
- * Sets the height of this column. If not defined, this will size itself to fit all of
- * its children (i.e. a WrappedDimension).
- */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setHeight(@NonNull ContainerDimension.Builder heightBuilder) {
- mImpl.setHeight(heightBuilder.build().toContainerDimensionProto());
- return this;
- }
-
- @Override
- @NonNull
- public Column build() {
- return new Column(mImpl.build());
- }
- }
- }
-
- /**
- * A row of elements. Each child will be laid out horizontally, one after another (i.e. stacking
- * to the right). This element will size itself to the smallest size required to hold all of its
- * children (e.g. if it contains three elements sized 10x10, 20x20 and 30x30, the resulting row
- * will be 60x30).
- *
- * <p>If specified, vertical_alignment can be used to control the gravity inside the container,
- * affecting the vertical placement of children whose width are smaller than the resulting row
- * height.
- */
- public static final class Row implements LayoutElement {
- private final LayoutElementProto.Row mImpl;
-
- Row(LayoutElementProto.Row impl) {
- this.mImpl = impl;
- }
-
- /** Returns a new {@link Builder}. */
- @NonNull
- public static Builder builder() {
- return new Builder();
- }
-
- /** @hide */
- @RestrictTo(Scope.LIBRARY)
- @NonNull
- LayoutElementProto.Row toProto() {
- return mImpl;
- }
-
- /** @hide */
- @Override
- @RestrictTo(Scope.LIBRARY)
- @NonNull
- public LayoutElementProto.LayoutElement toLayoutElementProto() {
- return LayoutElementProto.LayoutElement.newBuilder().setRow(mImpl).build();
- }
-
- /** Builder for {@link Row}. */
- public static final class Builder implements LayoutElement.Builder {
- private final LayoutElementProto.Row.Builder mImpl =
- LayoutElementProto.Row.newBuilder();
-
- Builder() {}
-
- /** Adds one item to the list of child elements to place inside this {@link Row}. */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder addContent(@NonNull LayoutElement content) {
- mImpl.addContents(content.toLayoutElementProto());
- return this;
- }
-
- /** Adds one item to the list of child elements to place inside this {@link Row}. */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder addContent(@NonNull LayoutElement.Builder contentBuilder) {
- mImpl.addContents(contentBuilder.build().toLayoutElementProto());
- return this;
- }
-
- /**
- * Sets the vertical alignment of elements inside this row, if they are narrower than
- * the resulting height of the row. If not defined, defaults to VALIGN_CENTER.
- */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setVerticalAlignment(@VerticalAlignment int verticalAlignment) {
- mImpl.setVerticalAlignment(
- LayoutElementProto.VerticalAlignmentProp.newBuilder()
- .setValue(
- LayoutElementProto.VerticalAlignment.forNumber(
- verticalAlignment)));
- return this;
- }
-
- /**
- * Sets the width of this row. If not defined, this will size itself to fit all of its
- * children (i.e. a WrappedDimension).
- */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setWidth(@NonNull ContainerDimension width) {
- mImpl.setWidth(width.toContainerDimensionProto());
- return this;
- }
-
- /**
- * Sets the width of this row. If not defined, this will size itself to fit all of its
- * children (i.e. a WrappedDimension).
- */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setWidth(@NonNull ContainerDimension.Builder widthBuilder) {
- mImpl.setWidth(widthBuilder.build().toContainerDimensionProto());
- return this;
- }
-
- /**
- * Sets the height of this row. If not defined, this will size itself to fit all of its
- * children (i.e. a WrappedDimension).
- */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setHeight(@NonNull ContainerDimension height) {
- mImpl.setHeight(height.toContainerDimensionProto());
- return this;
- }
-
- /**
- * Sets the height of this row. If not defined, this will size itself to fit all of its
- * children (i.e. a WrappedDimension).
- */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setHeight(@NonNull ContainerDimension.Builder heightBuilder) {
- mImpl.setHeight(heightBuilder.build().toContainerDimensionProto());
- return this;
- }
-
- @Override
- @NonNull
- public Row build() {
- return new Row(mImpl.build());
- }
- }
- }
-
- /**
- * A wrapper for an element which has a screen reader description associated with it. This
- * should generally be used sparingly, and in most cases should only be applied to the top-level
- * layout element or to Clickables.
- */
- public static final class Audible implements LayoutElement {
- private final LayoutElementProto.Audible mImpl;
-
- Audible(LayoutElementProto.Audible impl) {
- this.mImpl = impl;
- }
-
- /** Returns a new {@link Builder}. */
- @NonNull
- public static Builder builder() {
- return new Builder();
- }
-
- /** @hide */
- @RestrictTo(Scope.LIBRARY)
- @NonNull
- LayoutElementProto.Audible toProto() {
- return mImpl;
- }
-
- /** @hide */
- @Override
- @RestrictTo(Scope.LIBRARY)
- @NonNull
- public LayoutElementProto.LayoutElement toLayoutElementProto() {
- return LayoutElementProto.LayoutElement.newBuilder().setAudible(mImpl).build();
- }
-
- /** Builder for {@link Audible}. */
- public static final class Builder implements LayoutElement.Builder {
- private final LayoutElementProto.Audible.Builder mImpl =
- LayoutElementProto.Audible.newBuilder();
-
- Builder() {}
-
- /** Sets the element to wrap with the screen reader description. */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setContent(@NonNull LayoutElement content) {
- mImpl.setContent(content.toLayoutElementProto());
- return this;
- }
-
- /** Sets the element to wrap with the screen reader description. */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setContent(@NonNull LayoutElement.Builder contentBuilder) {
- mImpl.setContent(contentBuilder.build().toLayoutElementProto());
- return this;
- }
-
- /**
- * Sets the accessibility label associated with this element. This will be dictated when
- * the element is focused by the screen reader.
- */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setAccessibilityLabel(@NonNull String accessibilityLabel) {
- mImpl.setAccessibilityLabel(accessibilityLabel);
- return this;
- }
-
- @Override
- @NonNull
- public Audible build() {
- return new Audible(mImpl.build());
- }
- }
- }
-
- /**
- * A line. When added to a normal container, this renders as a horizontal line which can be used
- * to provide a visual break between elements. When added to an arc, it will render as a round
- * progress bar.
- */
- public static final class Line implements LayoutElement {
- private final LayoutElementProto.Line mImpl;
-
- Line(LayoutElementProto.Line impl) {
- this.mImpl = impl;
- }
-
- /** Returns a new {@link Builder}. */
- @NonNull
- public static Builder builder() {
- return new Builder();
- }
-
- /** @hide */
- @RestrictTo(Scope.LIBRARY)
- @NonNull
- LayoutElementProto.Line toProto() {
- return mImpl;
- }
-
- /** @hide */
- @Override
- @RestrictTo(Scope.LIBRARY)
- @NonNull
- public LayoutElementProto.LayoutElement toLayoutElementProto() {
- return LayoutElementProto.LayoutElement.newBuilder().setLine(mImpl).build();
- }
-
- /** Builder for {@link Line}. */
- public static final class Builder implements LayoutElement.Builder {
- private final LayoutElementProto.Line.Builder mImpl =
- LayoutElementProto.Line.newBuilder();
-
- Builder() {}
-
- /**
- * Sets the length of this {@link Line}. When this is added as the direct child of an
- * {@link Arc}, this must be specified as an AngularDimension, otherwise a
- * LinearDimension must be used. If not defined, defaults to 0.
- */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setLength(@NonNull LinearOrAngularDimension length) {
- mImpl.setLength(length.toLinearOrAngularDimensionProto());
- return this;
- }
-
- /**
- * Sets the length of this {@link Line}. When this is added as the direct child of an
- * {@link Arc}, this must be specified as an AngularDimension, otherwise a
- * LinearDimension must be used. If not defined, defaults to 0.
- */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setLength(@NonNull LinearOrAngularDimension.Builder lengthBuilder) {
- mImpl.setLength(lengthBuilder.build().toLinearOrAngularDimensionProto());
- return this;
- }
-
- /** Sets the thickness of this line. If not defined, defaults to 0. */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setThickness(@NonNull DpProp thickness) {
- mImpl.setThickness(thickness.toProto());
- return this;
- }
-
- /** Sets the thickness of this line. If not defined, defaults to 0. */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setThickness(@NonNull DpProp.Builder thicknessBuilder) {
- mImpl.setThickness(thicknessBuilder.build().toProto());
- return this;
- }
-
- /** Sets the style of this line. */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setStyle(@NonNull LineStyle style) {
- mImpl.setStyle(style.toProto());
- return this;
- }
-
- /** Sets the style of this line. */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setStyle(@NonNull LineStyle.Builder styleBuilder) {
- mImpl.setStyle(styleBuilder.build().toProto());
- return this;
- }
-
- @Override
- @NonNull
- public Line build() {
- return new Line(mImpl.build());
- }
- }
- }
-
- /**
- * An arc container. This container will fill itself to a circle, which fits inside its parent
- * container, and all of its children will be placed on that circle. The fields anchor_angle and
- * anchor_type can be used to specify where to draw children within this circle.
- *
- * <p>Note that there are two special cases. {@link Text} and {@link Line} elements which are
- * added as direct descendants to an arc will be drawn as a curved widget around the arc, rather
- * than just placed on the arc and drawn normally.
- */
- public static final class Arc implements LayoutElement {
- private final LayoutElementProto.Arc mImpl;
-
- Arc(LayoutElementProto.Arc impl) {
- this.mImpl = impl;
- }
-
- /** Returns a new {@link Builder}. */
- @NonNull
- public static Builder builder() {
- return new Builder();
- }
-
- /** @hide */
- @RestrictTo(Scope.LIBRARY)
- @NonNull
- LayoutElementProto.Arc toProto() {
- return mImpl;
- }
-
- /** @hide */
- @Override
- @RestrictTo(Scope.LIBRARY)
- @NonNull
- public LayoutElementProto.LayoutElement toLayoutElementProto() {
- return LayoutElementProto.LayoutElement.newBuilder().setArc(mImpl).build();
- }
-
- /** Builder for {@link Arc}. */
- public static final class Builder implements LayoutElement.Builder {
- private final LayoutElementProto.Arc.Builder mImpl =
- LayoutElementProto.Arc.newBuilder();
-
- Builder() {}
-
- /** Adds one item to contents of this container. */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder addContent(@NonNull LayoutElement content) {
- mImpl.addContents(content.toLayoutElementProto());
- return this;
- }
-
- /** Adds one item to contents of this container. */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder addContent(@NonNull LayoutElement.Builder contentBuilder) {
- mImpl.addContents(contentBuilder.build().toLayoutElementProto());
- return this;
- }
-
- /**
- * Sets the length of this {@link Arc} as an angle. If not defined, this will size
- * itself to fit all of its children. If defined, this should be a value > 0 degrees.
- */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setLength(@NonNull DegreesProp length) {
- mImpl.setLength(length.toProto());
- return this;
- }
-
- /**
- * Sets the length of this {@link Arc} as an angle. If not defined, this will size
- * itself to fit all of its children. If defined, this should be a value > 0 degrees.
- */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setLength(@NonNull DegreesProp.Builder lengthBuilder) {
- mImpl.setLength(lengthBuilder.build().toProto());
- return this;
- }
-
- /**
- * Sets the thickness of this {@link Arc}. If not defined, this will size itself to fit
- * all of its children.
- */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setThickness(@NonNull DpProp thickness) {
- mImpl.setThickness(thickness.toProto());
- return this;
- }
-
- /**
- * Sets the thickness of this {@link Arc}. If not defined, this will size itself to fit
- * all of its children.
- */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setThickness(@NonNull DpProp.Builder thicknessBuilder) {
- mImpl.setThickness(thicknessBuilder.build().toProto());
- return this;
- }
-
- /**
- * Sets whether this {@link Arc}'s children should be rotated, according to its position
- * in the arc or not. As an example, assume that an {@link Image} has been added to the
- * arc, and ends up at the 3 o clock position. If rotate_contents = true, the image will
- * be placed at the 3 o clock position, and will be rotated clockwise through 90
- * degrees. If rotate_contents = false, the image will be placed at the 3 o clock
- * position, but itself will not be rotated. If not defined, defaults to true.
- */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setRotateContents(boolean rotateContents) {
- mImpl.setRotateContents(TypesProto.BoolProp.newBuilder().setValue(rotateContents));
- return this;
- }
-
- /**
- * Sets the angle for the anchor, used with anchor_type to determine where to draw
- * children. Note that 0 degrees is the 12 o clock position on a device, and the angle
- * sweeps clockwise. If not defined, defaults to 0 degrees.
- *
- * <p>Values do not have to be clamped to the range 0-360; values less than 0 degrees
- * will sweep anti-clockwise (i.e. -90 degrees is equivalent to 270 degrees), and values
- * >360 will be be placed at X mod 360 degrees.
- */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setAnchorAngle(@NonNull DegreesProp anchorAngle) {
- mImpl.setAnchorAngle(anchorAngle.toProto());
- return this;
- }
-
- /**
- * Sets the angle for the anchor, used with anchor_type to determine where to draw
- * children. Note that 0 degrees is the 12 o clock position on a device, and the angle
- * sweeps clockwise. If not defined, defaults to 0 degrees.
- *
- * <p>Values do not have to be clamped to the range 0-360; values less than 0 degrees
- * will sweep anti-clockwise (i.e. -90 degrees is equivalent to 270 degrees), and values
- * >360 will be be placed at X mod 360 degrees.
- */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setAnchorAngle(@NonNull DegreesProp.Builder anchorAngleBuilder) {
- mImpl.setAnchorAngle(anchorAngleBuilder.build().toProto());
- return this;
- }
-
- /**
- * Sets how to align the contents of this container relative to anchor_angle. See the
- * descriptions of options in {@link ArcAnchorType} for more information. If not
- * defined, defaults to ARC_ANCHOR_CENTER.
- */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setAnchorType(@ArcAnchorType int anchorType) {
- mImpl.setAnchorType(
- LayoutElementProto.ArcAnchorTypeProp.newBuilder()
- .setValue(LayoutElementProto.ArcAnchorType.forNumber(anchorType)));
- return this;
- }
-
- /**
- * Sets vertical alignment of elements within the arc. If the {@link Arc}'s thickness is
- * larger than the thickness of the element being drawn, this controls whether the
- * element should be drawn towards the inner or outer edge of the arc, or drawn in the
- * center. If not defined, defaults to VALIGN_CENTER.
- */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setVerticalAlign(@VerticalAlignment int verticalAlign) {
- mImpl.setVerticalAlign(
- LayoutElementProto.VerticalAlignmentProp.newBuilder()
- .setValue(
- LayoutElementProto.VerticalAlignment.forNumber(
- verticalAlign)));
- return this;
- }
-
- @Override
- @NonNull
- public Arc build() {
- return new Arc(mImpl.build());
- }
- }
- }
-
- /**
- * Interface defining the root of all layout elements. This exists to act as a holder for all of
- * the actual layout elements above.
- */
- public interface LayoutElement {
- /**
- * Get the protocol buffer representation of this object.
- *
- * @hide
- */
- @RestrictTo(Scope.LIBRARY)
- @NonNull
- LayoutElementProto.LayoutElement toLayoutElementProto();
-
- /** Builder to create {@link LayoutElement} objects. */
- @SuppressLint("StaticFinalBuilder")
- interface Builder {
-
- /** Builds an instance with values accumulated in this Builder. */
- @NonNull
- LayoutElement build();
- }
- }
-
- /** Font styles, currently set up to match Wear's font styling. */
- public static class FontStyles {
- private static final int LARGE_SCREEN_WIDTH_DP = 210;
-
- private final int mScreenWidthDp;
-
- private FontStyles(int screenWidthDp) {
- this.mScreenWidthDp = screenWidthDp;
- }
-
- private boolean isLargeScreen() {
- return mScreenWidthDp >= LARGE_SCREEN_WIDTH_DP;
- }
-
- /**
- * Create a FontStyles instance, using the given device parameters to determine font sizes.
- */
- @NonNull
- public static FontStyles withDeviceParameters(@NonNull DeviceParameters deviceParameters) {
- return new FontStyles(deviceParameters.getScreenWidthDp());
- }
-
- /** Font style for large display text. */
- @NonNull
- public FontStyle display1() {
- return FontStyle.builder()
- .setBold(true)
- .setSize(DimensionBuilders.sp(isLargeScreen() ? 54 : 50))
- .build();
- }
-
- /** Font style for medium display text. */
- @NonNull
- public FontStyle display2() {
- return FontStyle.builder()
- .setBold(true)
- .setSize(DimensionBuilders.sp(isLargeScreen() ? 44 : 40))
- .build();
- }
-
- /** Font style for small display text. */
- @NonNull
- public FontStyle display3() {
- return FontStyle.builder()
- .setBold(true)
- .setSize(DimensionBuilders.sp(isLargeScreen() ? 34 : 30))
- .build();
- }
-
- /** Font style for large title text. */
- @NonNull
- public FontStyle title1() {
- return FontStyle.builder()
- .setBold(true)
- .setSize(DimensionBuilders.sp(isLargeScreen() ? 26 : 24))
- .build();
- }
-
- /** Font style for medium title text. */
- @NonNull
- public FontStyle title2() {
- return FontStyle.builder()
- .setBold(true)
- .setSize(DimensionBuilders.sp(isLargeScreen() ? 22 : 20))
- .build();
- }
-
- /** Font style for small title text. */
- @NonNull
- public FontStyle title3() {
- return FontStyle.builder()
- .setBold(true)
- .setSize(DimensionBuilders.sp(isLargeScreen() ? 18 : 16))
- .build();
- }
-
- /** Font style for large body text. */
- @NonNull
- public FontStyle body1() {
- return FontStyle.builder()
- .setSize(DimensionBuilders.sp(isLargeScreen() ? 18 : 16))
- .build();
- }
-
- /** Font style for medium body text. */
- @NonNull
- public FontStyle body2() {
- return FontStyle.builder()
- .setSize(DimensionBuilders.sp(isLargeScreen() ? 16 : 14))
- .build();
- }
-
- /** Font style for button text. */
- @NonNull
- public FontStyle button() {
- return FontStyle.builder()
- .setBold(true)
- .setSize(DimensionBuilders.sp(isLargeScreen() ? 16 : 14))
- .build();
- }
-
- /** Font style for large caption text. */
- @NonNull
- public FontStyle caption1() {
- return FontStyle.builder()
- .setSize(DimensionBuilders.sp(isLargeScreen() ? 16 : 14))
- .build();
- }
-
- /** Font style for medium caption text. */
- @NonNull
- public FontStyle caption2() {
- return FontStyle.builder()
- .setSize(DimensionBuilders.sp(isLargeScreen() ? 14 : 12))
- .build();
- }
- }
-}
diff --git a/wear/wear-tiles/src/main/java/androidx/wear/tiles/builders/ResourceBuilders.java b/wear/wear-tiles/src/main/java/androidx/wear/tiles/builders/ResourceBuilders.java
deleted file mode 100644
index bdc46b1..0000000
--- a/wear/wear-tiles/src/main/java/androidx/wear/tiles/builders/ResourceBuilders.java
+++ /dev/null
@@ -1,336 +0,0 @@
-/*
- * Copyright 2021 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.wear.tiles.builders;
-
-import static androidx.annotation.Dimension.PX;
-
-import android.annotation.SuppressLint;
-
-import androidx.annotation.Dimension;
-import androidx.annotation.DrawableRes;
-import androidx.annotation.IntDef;
-import androidx.annotation.NonNull;
-import androidx.annotation.RestrictTo;
-import androidx.annotation.RestrictTo.Scope;
-import androidx.wear.tiles.proto.ResourceProto;
-
-import com.google.protobuf.ByteString;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-
-/** Builders for the resources for a layout. */
-public final class ResourceBuilders {
- private ResourceBuilders() {}
-
- /**
- * Format describing the contents of an image data byte array.
- *
- * @hide
- */
- @RestrictTo(RestrictTo.Scope.LIBRARY)
- @IntDef({IMAGE_FORMAT_UNDEFINED, IMAGE_FORMAT_RGB_565})
- @Retention(RetentionPolicy.SOURCE)
- public @interface ImageFormat {}
-
- /** An undefined image format. */
- public static final int IMAGE_FORMAT_UNDEFINED = 0;
-
- /**
- * An image format where each pixel is stored on 2 bytes, with red using 5 bits, green using 6
- * bits and blue using 5 bits of precision.
- */
- public static final int IMAGE_FORMAT_RGB_565 = 1;
-
- /** An image resource which maps to an Android drawable by resource ID. */
- public static final class AndroidImageResourceByResId {
- private final ResourceProto.AndroidImageResourceByResId mImpl;
-
- AndroidImageResourceByResId(ResourceProto.AndroidImageResourceByResId impl) {
- this.mImpl = impl;
- }
-
- /** Returns a new {@link Builder}. */
- @NonNull
- public static Builder builder() {
- return new Builder();
- }
-
- /**
- * Get the protocol buffer representation of this object.
- *
- * @hide
- */
- @RestrictTo(Scope.LIBRARY)
- @NonNull
- public ResourceProto.AndroidImageResourceByResId toProto() {
- return mImpl;
- }
-
- /** Builder for {@link AndroidImageResourceByResId} */
- public static final class Builder {
- private final ResourceProto.AndroidImageResourceByResId.Builder mImpl =
- ResourceProto.AndroidImageResourceByResId.newBuilder();
-
- Builder() {}
-
- /**
- * Sets the Android resource ID of this image. This must refer to a drawable under
- * R.drawable.
- */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setResourceId(@DrawableRes int resourceId) {
- mImpl.setResourceId(resourceId);
- return this;
- }
-
- /** Builds an instance from accumulated values. */
- @NonNull
- public AndroidImageResourceByResId build() {
- return new AndroidImageResourceByResId(mImpl.build());
- }
- }
- }
-
- /**
- * An image resource whose data is fully inlined, with no dependency on a system or app
- * resource.
- */
- public static final class InlineImageResource {
- private final ResourceProto.InlineImageResource mImpl;
-
- InlineImageResource(ResourceProto.InlineImageResource impl) {
- this.mImpl = impl;
- }
-
- /** Returns a new {@link Builder}. */
- @NonNull
- public static Builder builder() {
- return new Builder();
- }
-
- /**
- * Get the protocol buffer representation of this object.
- *
- * @hide
- */
- @RestrictTo(Scope.LIBRARY)
- @NonNull
- public ResourceProto.InlineImageResource toProto() {
- return mImpl;
- }
-
- /** Builder for {@link InlineImageResource} */
- public static final class Builder {
- private final ResourceProto.InlineImageResource.Builder mImpl =
- ResourceProto.InlineImageResource.newBuilder();
-
- Builder() {}
-
- /** Sets the byte array representing the image. */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setData(@NonNull byte[] data) {
- mImpl.setData(ByteString.copyFrom(data));
- return this;
- }
-
- /** Sets the native width of the image, in pixels. */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setWidthPx(@Dimension(unit = PX) int widthPx) {
- mImpl.setWidthPx(widthPx);
- return this;
- }
-
- /** Sets the native height of the image, in pixels. */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setHeightPx(@Dimension(unit = PX) int heightPx) {
- mImpl.setHeightPx(heightPx);
- return this;
- }
-
- /** Sets the format of the byte array data representing the image. */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setFormat(@ImageFormat int format) {
- mImpl.setFormat(ResourceProto.ImageFormat.forNumber(format));
- return this;
- }
-
- /** Builds an instance from accumulated values. */
- @NonNull
- public InlineImageResource build() {
- return new InlineImageResource(mImpl.build());
- }
- }
- }
-
- /**
- * An image resource, which can be used by layouts. This holds multiple underlying resource
- * types, which the underlying runtime will pick according to what it thinks is appropriate.
- */
- public static final class ImageResource {
- private final ResourceProto.ImageResource mImpl;
-
- ImageResource(ResourceProto.ImageResource impl) {
- this.mImpl = impl;
- }
-
- /** Returns a new {@link Builder}. */
- @NonNull
- public static Builder builder() {
- return new Builder();
- }
-
- /**
- * Get the protocol buffer representation of this object.
- *
- * @hide
- */
- @RestrictTo(Scope.LIBRARY)
- @NonNull
- public ResourceProto.ImageResource toProto() {
- return mImpl;
- }
-
- /** Builder for {@link ImageResource} */
- public static final class Builder {
- private final ResourceProto.ImageResource.Builder mImpl =
- ResourceProto.ImageResource.newBuilder();
-
- Builder() {}
-
- /** Sets an image resource that maps to an Android drawable by resource ID. */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setAndroidResourceByResid(
- @NonNull AndroidImageResourceByResId androidResourceByResid) {
- mImpl.setAndroidResourceByResid(androidResourceByResid.toProto());
- return this;
- }
-
- /** Sets an image resource that maps to an Android drawable by resource ID. */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setAndroidResourceByResid(
- @NonNull AndroidImageResourceByResId.Builder androidResourceByResidBuilder) {
- mImpl.setAndroidResourceByResid(androidResourceByResidBuilder.build().toProto());
- return this;
- }
-
- /** Sets an image resource that contains the image data inline. */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setInlineResource(@NonNull InlineImageResource inlineResource) {
- mImpl.setInlineResource(inlineResource.toProto());
- return this;
- }
-
- /** Sets an image resource that contains the image data inline. */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setInlineResource(
- @NonNull InlineImageResource.Builder inlineResourceBuilder) {
- mImpl.setInlineResource(inlineResourceBuilder.build().toProto());
- return this;
- }
-
- /** Builds an instance from accumulated values. */
- @NonNull
- public ImageResource build() {
- return new ImageResource(mImpl.build());
- }
- }
- }
-
- /** The resources for a layout. */
- public static final class Resources {
- private final ResourceProto.Resources mImpl;
-
- Resources(ResourceProto.Resources impl) {
- this.mImpl = impl;
- }
-
- /** Returns a new {@link Builder}. */
- @NonNull
- public static Builder builder() {
- return new Builder();
- }
-
- /**
- * Get the protocol buffer representation of this object.
- *
- * @hide
- */
- @RestrictTo(Scope.LIBRARY)
- @NonNull
- public ResourceProto.Resources toProto() {
- return mImpl;
- }
-
- /** Builder for {@link Resources} */
- public static final class Builder {
- private final ResourceProto.Resources.Builder mImpl =
- ResourceProto.Resources.newBuilder();
-
- Builder() {}
-
- /**
- * Sets the version of this {@link Resources} instance.
- *
- * <p>Each tile specifies the version of resources it requires. After fetching a tile,
- * the renderer will use the resources version specified by the tile to separately fetch
- * the resources.
- *
- * <p>This value must match the version of the resources required by the tile for the
- * tile to render successfully.
- */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setVersion(@NonNull String version) {
- mImpl.setVersion(version);
- return this;
- }
-
- /** Adds an entry into a map of resource_ids to images, which can be used by layouts. */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder addIdToImageMapping(@NonNull String id, @NonNull ImageResource image) {
- mImpl.putIdToImage(id, image.toProto());
- return this;
- }
-
- /** Adds an entry into a map of resource_ids to images, which can be used by layouts. */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder addIdToImageMapping(
- @NonNull String id, @NonNull ImageResource.Builder imageBuilder) {
- mImpl.putIdToImage(id, imageBuilder.build().toProto());
- return this;
- }
-
- /** Builds an instance from accumulated values. */
- @NonNull
- public Resources build() {
- return new Resources(mImpl.build());
- }
- }
- }
-}
diff --git a/wear/wear-tiles/src/main/java/androidx/wear/tiles/builders/TileBuilders.java b/wear/wear-tiles/src/main/java/androidx/wear/tiles/builders/TileBuilders.java
deleted file mode 100644
index 966309b..0000000
--- a/wear/wear-tiles/src/main/java/androidx/wear/tiles/builders/TileBuilders.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright 2021 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.wear.tiles.builders;
-
-import android.annotation.SuppressLint;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.RestrictTo;
-import androidx.annotation.RestrictTo.Scope;
-import androidx.wear.tiles.builders.TimelineBuilders.Timeline;
-import androidx.wear.tiles.proto.TileProto;
-
-/** Builders for the components of a tile that can be rendered by a tile renderer. */
-public final class TileBuilders {
- private TileBuilders() {}
-
- /**
- * A holder for a tile. This specifies the resources to use for this delivery of the tile, and
- * the timeline for the tile.
- */
- public static final class Tile {
- private final TileProto.Tile mImpl;
-
- Tile(TileProto.Tile impl) {
- this.mImpl = impl;
- }
-
- /** Returns a new {@link Builder}. */
- @NonNull
- public static Builder builder() {
- return new Builder();
- }
-
- /**
- * Get the protocol buffer representation of this object.
- *
- * @hide
- */
- @RestrictTo(Scope.LIBRARY)
- @NonNull
- public TileProto.Tile toProto() {
- return mImpl;
- }
-
- /** Builder for {@link Tile} */
- public static final class Builder {
- private final TileProto.Tile.Builder mImpl = TileProto.Tile.newBuilder();
-
- Builder() {}
-
- /** Sets the resource version required for these tiles. */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setResourcesVersion(@NonNull String resourcesVersion) {
- mImpl.setResourcesVersion(resourcesVersion);
- return this;
- }
-
- /** Sets the tiles to show in the carousel, along with their validity periods. */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setTimeline(@NonNull Timeline timeline) {
- mImpl.setTimeline(timeline.toProto());
- return this;
- }
-
- /** Sets the tiles to show in the carousel, along with their validity periods. */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setTimeline(@NonNull Timeline.Builder timelineBuilder) {
- mImpl.setTimeline(timelineBuilder.build().toProto());
- return this;
- }
-
- /** Builds an instance from accumulated values. */
- @NonNull
- public Tile build() {
- return new Tile(mImpl.build());
- }
- }
- }
-}
diff --git a/wear/wear-tiles/src/main/java/androidx/wear/tiles/builders/TimelineBuilders.java b/wear/wear-tiles/src/main/java/androidx/wear/tiles/builders/TimelineBuilders.java
deleted file mode 100644
index e284cba..0000000
--- a/wear/wear-tiles/src/main/java/androidx/wear/tiles/builders/TimelineBuilders.java
+++ /dev/null
@@ -1,232 +0,0 @@
-/*
- * Copyright 2021 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.wear.tiles.builders;
-
-import android.annotation.SuppressLint;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.RestrictTo;
-import androidx.annotation.RestrictTo.Scope;
-import androidx.wear.tiles.builders.LayoutElementBuilders.LayoutElement;
-import androidx.wear.tiles.proto.TimelineProto;
-
-/**
- * Builders for a timeline with entries representing content that should be displayed within given
- * time intervals.
- */
-public final class TimelineBuilders {
- private TimelineBuilders() {}
-
- /**
- * A time interval, typically used to describe the validity period of a {@link TimelineEntry}.
- */
- public static final class TimeInterval {
- private final TimelineProto.TimeInterval mImpl;
-
- TimeInterval(TimelineProto.TimeInterval impl) {
- this.mImpl = impl;
- }
-
- /** Returns a new {@link Builder}. */
- @NonNull
- public static Builder builder() {
- return new Builder();
- }
-
- /**
- * Get the protocol buffer representation of this object.
- *
- * @hide
- */
- @RestrictTo(Scope.LIBRARY)
- @NonNull
- public TimelineProto.TimeInterval toProto() {
- return mImpl;
- }
-
- /** Builder for {@link TimeInterval} */
- public static final class Builder {
- private final TimelineProto.TimeInterval.Builder mImpl =
- TimelineProto.TimeInterval.newBuilder();
-
- Builder() {}
-
- /** Sets starting point of the time interval, in milliseconds since the Unix epoch. */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setStartMillis(long startMillis) {
- mImpl.setStartMillis(startMillis);
- return this;
- }
-
- /** Sets end point of the time interval, in milliseconds since the Unix epoch. */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setEndMillis(long endMillis) {
- mImpl.setEndMillis(endMillis);
- return this;
- }
-
- /** Builds an instance from accumulated values. */
- @NonNull
- public TimeInterval build() {
- return new TimeInterval(mImpl.build());
- }
- }
- }
-
- /** One piece of renderable content along with the time that it is valid for. */
- public static final class TimelineEntry {
- private final TimelineProto.TimelineEntry mImpl;
-
- TimelineEntry(TimelineProto.TimelineEntry impl) {
- this.mImpl = impl;
- }
-
- /** Returns a new {@link Builder}. */
- @NonNull
- public static Builder builder() {
- return new Builder();
- }
-
- /**
- * Get the protocol buffer representation of this object.
- *
- * @hide
- */
- @RestrictTo(Scope.LIBRARY)
- @NonNull
- public TimelineProto.TimelineEntry toProto() {
- return mImpl;
- }
-
- /** Builder for {@link TimelineEntry} */
- public static final class Builder {
- private final TimelineProto.TimelineEntry.Builder mImpl =
- TimelineProto.TimelineEntry.newBuilder();
-
- Builder() {}
-
- /** Sets the contents of this timeline entry. */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setContent(@NonNull LayoutElement content) {
- mImpl.setContent(content.toLayoutElementProto());
- return this;
- }
-
- /** Sets the contents of this timeline entry. */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setContent(@NonNull LayoutElement.Builder contentBuilder) {
- mImpl.setContent(contentBuilder.build().toLayoutElementProto());
- return this;
- }
-
- /** Sets the validity period for this timeline entry. */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setValidity(@NonNull TimeInterval validity) {
- mImpl.setValidity(validity.toProto());
- return this;
- }
-
- /** Sets the validity period for this timeline entry. */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setValidity(@NonNull TimeInterval.Builder validityBuilder) {
- mImpl.setValidity(validityBuilder.build().toProto());
- return this;
- }
-
- /** Builds an instance from accumulated values. */
- @NonNull
- public TimelineEntry build() {
- return new TimelineEntry(mImpl.build());
- }
- }
- }
-
- /**
- * A collection of {@link TimelineEntry} items.
- *
- * <p>{@link TimelineEntry} items can be used to update a layout on-screen at known times,
- * without having to explicitly update a layout. This allows for cases where, say, a calendar
- * can be used to show the next event, and automatically switch to showing the next event when
- * one has passed.
- *
- * <p>The active {@link TimelineEntry} is switched, at most, once a minute. In the case where
- * the validity periods of {@link TimelineEntry} items overlap, the item with the shortest*
- * validity period will be shown. This allows a layout provider to show a "default" layout, and
- * override it at set points without having to explicitly insert the default layout between the
- * "override" layout.
- */
- public static final class Timeline {
- private final TimelineProto.Timeline mImpl;
-
- Timeline(TimelineProto.Timeline impl) {
- this.mImpl = impl;
- }
-
- /** Returns a new {@link Builder}. */
- @NonNull
- public static Builder builder() {
- return new Builder();
- }
-
- /**
- * Get the protocol buffer representation of this object.
- *
- * @hide
- */
- @RestrictTo(Scope.LIBRARY)
- @NonNull
- public TimelineProto.Timeline toProto() {
- return mImpl;
- }
-
- /** Builder for {@link Timeline} */
- public static final class Builder {
- private final TimelineProto.Timeline.Builder mImpl =
- TimelineProto.Timeline.newBuilder();
-
- Builder() {}
-
- /** Adds one item to the entries in a timeline. */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder addTimelineEntry(@NonNull TimelineEntry timelineEntry) {
- mImpl.addTimelineEntries(timelineEntry.toProto());
- return this;
- }
-
- /** Adds one item to the entries in a timeline. */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder addTimelineEntry(@NonNull TimelineEntry.Builder timelineEntryBuilder) {
- mImpl.addTimelineEntries(timelineEntryBuilder.build().toProto());
- return this;
- }
-
- /** Builds an instance from accumulated values. */
- @NonNull
- public Timeline build() {
- return new Timeline(mImpl.build());
- }
- }
- }
-}
diff --git a/wear/wear-tiles/src/main/java/androidx/wear/tiles/builders/package-info.java b/wear/wear-tiles/src/main/java/androidx/wear/tiles/builders/package-info.java
deleted file mode 100644
index f049ed9..0000000
--- a/wear/wear-tiles/src/main/java/androidx/wear/tiles/builders/package-info.java
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * 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.
- */
-
-/** Contains builders for all available tile components and properties. */
-package androidx.wear.tiles.builders;
diff --git a/wear/wear-tiles/src/main/java/androidx/wear/tiles/package-info.java b/wear/wear-tiles/src/main/java/androidx/wear/tiles/package-info.java
deleted file mode 100644
index 622c725..0000000
--- a/wear/wear-tiles/src/main/java/androidx/wear/tiles/package-info.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * 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.
- */
-
-/**
- * Contains {@link androidx.wear.tiles.TileProviderService}, which all apps using the Tiles API
- * should extend in order to provide tile data.
- */
-package androidx.wear.tiles;
diff --git a/wear/wear-tiles/src/main/java/androidx/wear/tiles/readers/DeviceParametersReaders.java b/wear/wear-tiles/src/main/java/androidx/wear/tiles/readers/DeviceParametersReaders.java
deleted file mode 100644
index 238d8e6..0000000
--- a/wear/wear-tiles/src/main/java/androidx/wear/tiles/readers/DeviceParametersReaders.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * 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.wear.tiles.readers;
-
-import static androidx.annotation.Dimension.DP;
-
-import androidx.annotation.Dimension;
-import androidx.annotation.FloatRange;
-import androidx.annotation.IntDef;
-import androidx.annotation.RestrictTo;
-import androidx.wear.tiles.proto.DeviceParametersProto;
-import androidx.wear.tiles.readers.RequestReaders.TileRequest;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-
-/** Readers for androidx.wear.tiles' device parameters structures. */
-public class DeviceParametersReaders {
- private DeviceParametersReaders() {}
-
- /**
- * The platform of the device requesting a tile.
- *
- * @hide
- */
- @RestrictTo(RestrictTo.Scope.LIBRARY)
- @IntDef({DEVICE_PLATFORM_UNDEFINED, DEVICE_PLATFORM_WEAR_OS})
- @Retention(RetentionPolicy.SOURCE)
- public @interface DevicePlatform {}
-
- /** Device platform is undefined. */
- public static final int DEVICE_PLATFORM_UNDEFINED = 0;
-
- /** Device is a Wear OS by Google device. */
- public static final int DEVICE_PLATFORM_WEAR_OS = 1;
-
- /**
- * The shape of a screen.
- *
- * @hide
- */
- @RestrictTo(RestrictTo.Scope.LIBRARY)
- @IntDef({SCREEN_SHAPE_UNDEFINED, SCREEN_SHAPE_ROUND, SCREEN_SHAPE_RECT})
- @Retention(RetentionPolicy.SOURCE)
- public @interface ScreenShape {}
-
- /** Screen shape is undefined. */
- public static final int SCREEN_SHAPE_UNDEFINED = 0;
-
- /** A round screen (typically found on most Wear devices). */
- public static final int SCREEN_SHAPE_ROUND = 1;
-
- /** Rectangular screens. */
- public static final int SCREEN_SHAPE_RECT = 2;
-
- /** Reader for the Device Parameters returned from {@link TileRequest#getDeviceParameters()}. */
- public static class DeviceParameters {
- private final DeviceParametersProto.DeviceParameters mProto;
-
- DeviceParameters(DeviceParametersProto.DeviceParameters proto) {
- this.mProto = proto;
- }
-
- /** Get the width of the screen, in DP. */
- @Dimension(unit = DP)
- public int getScreenWidthDp() {
- return mProto.getScreenWidthDp();
- }
-
- /** Get the height of the screen, in DP. */
- @Dimension(unit = DP)
- public int getScreenHeightDp() {
- return mProto.getScreenHeightDp();
- }
-
- /**
- * Get the density of the screen. This value is the scaling factor to get from DP to Pixels,
- * where PX = DP * density.
- */
- @FloatRange(from = 0.0, fromInclusive = false)
- public float getScreenDensity() {
- return mProto.getScreenDensity();
- }
-
- /** Get the platform of the device. */
- @DevicePlatform
- public int getDevicePlatform() {
- return mProto.getDevicePlatformValue();
- }
-
- /** Get the shape of the screen of the device. */
- @ScreenShape
- public int getScreenShape() {
- return mProto.getScreenShapeValue();
- }
- }
-}
diff --git a/wear/wear-tiles/src/main/java/androidx/wear/tiles/readers/RequestReaders.java b/wear/wear-tiles/src/main/java/androidx/wear/tiles/readers/RequestReaders.java
deleted file mode 100644
index a096b0a..0000000
--- a/wear/wear-tiles/src/main/java/androidx/wear/tiles/readers/RequestReaders.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * 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.wear.tiles.readers;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import androidx.annotation.RestrictTo;
-import androidx.annotation.RestrictTo.Scope;
-import androidx.wear.tiles.ResourcesRequestData;
-import androidx.wear.tiles.TileRequestData;
-import androidx.wear.tiles.proto.RequestProto;
-import androidx.wear.tiles.readers.DeviceParametersReaders.DeviceParameters;
-
-import com.google.protobuf.ExtensionRegistryLite;
-import com.google.protobuf.InvalidProtocolBufferException;
-
-import java.util.List;
-
-/** Request readers for androidx.wear.tiles' Parcelable classes. */
-public class RequestReaders {
- private RequestReaders() {}
-
- /** Reader for a {@link TileRequestData} instance. */
- public static class TileRequest {
- private final RequestProto.TileRequest mProto;
-
- private TileRequest(RequestProto.TileRequest proto) {
- this.mProto = proto;
- }
-
- /** Get the Clickable ID which triggered this Tile request. */
- @NonNull
- public String getClickableId() {
- return mProto.getClickableId();
- }
-
- /** Get parameters describing the device requesting this tile. */
- @Nullable
- public DeviceParameters getDeviceParameters() {
- if (!mProto.hasDeviceParameters()) {
- return null;
- }
-
- return new DeviceParameters(mProto.getDeviceParameters());
- }
-
- /** @hide */
- @RestrictTo(Scope.LIBRARY)
- @NonNull
- public static TileRequest fromParcelable(@NonNull TileRequestData parcelable) {
- try {
- return new TileRequest(
- RequestProto.TileRequest.parseFrom(
- parcelable.getContents(),
- ExtensionRegistryLite.getEmptyRegistry()));
- } catch (InvalidProtocolBufferException ex) {
- throw new IllegalArgumentException(
- "Passed TileRequestData did not contain a valid proto payload", ex);
- }
- }
- }
-
- /** Reader for a {@link ResourcesRequestData} instance. */
- public static class ResourcesRequest {
- private final RequestProto.ResourcesRequest mProto;
-
- private ResourcesRequest(@NonNull RequestProto.ResourcesRequest proto) {
- this.mProto = proto;
- }
-
- /** @hide */
- @RestrictTo(Scope.LIBRARY)
- @NonNull
- public static ResourcesRequest fromParcelable(@NonNull ResourcesRequestData parcelable) {
- try {
- return new ResourcesRequest(
- RequestProto.ResourcesRequest.parseFrom(
- parcelable.getContents(),
- ExtensionRegistryLite.getEmptyRegistry()));
- } catch (InvalidProtocolBufferException ex) {
- throw new IllegalArgumentException(
- "Passed ResourcesRequestData did not contain a valid proto payload", ex);
- }
- }
-
- /** Get the resource version requested by this {@link ResourcesRequestData}. */
- @NonNull
- public String getVersion() {
- return mProto.getVersion();
- }
-
- /**
- * Get the resource IDs requested by this {@link ResourcesRequestData}. May be empty, in
- * which case all resources should be returned.
- */
- @NonNull
- public List<String> getResourceIds() {
- return mProto.getResourceIdsList();
- }
- }
-}
diff --git a/wear/wear-tiles/src/main/java/androidx/wear/tiles/readers/package-info.java b/wear/wear-tiles/src/main/java/androidx/wear/tiles/readers/package-info.java
deleted file mode 100644
index 48deb88..0000000
--- a/wear/wear-tiles/src/main/java/androidx/wear/tiles/readers/package-info.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * 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.
- */
-
-/**
- * Contains {@link androidx.wear.tiles.readers.RequestReaders.TileRequest} and {@link
- * androidx.wear.tiles.readers.RequestReaders.ResourcesRequest}, which are passed as parameters to
- * {@link androidx.wear.tiles.TileProviderService#onTileRequest} and {@link
- * androidx.wear.tiles.TileProviderService#onResourcesRequest} respectively.
- */
-package androidx.wear.tiles.readers;
diff --git a/wear/wear-tiles/src/main/proto/action.proto b/wear/wear-tiles/src/main/proto/action.proto
deleted file mode 100644
index 20811e7..0000000
--- a/wear/wear-tiles/src/main/proto/action.proto
+++ /dev/null
@@ -1,41 +0,0 @@
-// Actions that can be performed when a user interacts with layout elements.
-syntax = "proto3";
-
-package androidx.wear.tiles.proto;
-
-
-
-
-option java_package = "androidx.wear.tiles.proto";
-option java_outer_classname = "ActionProto";
-
-// A launch action to send an intent to an Android activity.
-message AndroidActivity {
- // The package name to send the intent to, for example, "com.google.weather".
- string package_name = 1;
-
- // The fully qualified class name (including the package) to send the intent
- // to, for example, "com.google.weather.WeatherOverviewActivity".
- string class_name = 2;
-}
-
-// An action used to launch another activity on the system. This can hold
-// multiple different underlying action types, which will be picked based on
-// what the underlying runtime believes to be suitable.
-message LaunchAction {
- // An action to launch an Android activity.
- AndroidActivity android_activity = 1;
-}
-
-// An action used to load (or reload) the tile contents.
-message LoadAction {
- // Nothing yet.
-}
-
-// An action that can be used by a layout element.
-message Action {
- oneof value {
- LaunchAction launch_action = 1;
- LoadAction load_action = 2;
- }
-}
diff --git a/wear/wear-tiles/src/main/proto/color.proto b/wear/wear-tiles/src/main/proto/color.proto
deleted file mode 100644
index 92a3abe..0000000
--- a/wear/wear-tiles/src/main/proto/color.proto
+++ /dev/null
@@ -1,14 +0,0 @@
-// Color utilities for layout elements.
-syntax = "proto3";
-
-package androidx.wear.tiles.proto;
-
-
-option java_package = "androidx.wear.tiles.proto";
-option java_outer_classname = "ColorProto";
-
-// A property defining a color.
-message ColorProp {
- // The color value, in ARGB format.
- uint32 argb = 1;
-}
diff --git a/wear/wear-tiles/src/main/proto/device_parameters.proto b/wear/wear-tiles/src/main/proto/device_parameters.proto
deleted file mode 100644
index f518540..0000000
--- a/wear/wear-tiles/src/main/proto/device_parameters.proto
+++ /dev/null
@@ -1,50 +0,0 @@
-// Request messages used to fetch tiles and resources
-syntax = "proto3";
-
-package androidx.wear.tiles.proto;
-
-
-option java_package = "androidx.wear.tiles.proto";
-option java_outer_classname = "DeviceParametersProto";
-
-// The platform of the device requesting a tile.
-enum DevicePlatform {
- // Device platform is undefined.
- DEVICE_PLATFORM_UNDEFINED = 0;
-
- // Device is a Wear OS by Google device.
- DEVICE_PLATFORM_WEAR_OS = 1;
-}
-
-// The shape of a screen.
-enum ScreenShape {
- // Screen shape is undefined.
- SCREEN_SHAPE_UNDEFINED = 0;
-
- // A round screen (typically found on most Wear devices).
- SCREEN_SHAPE_ROUND = 1;
-
- // Rectangular screens.
- SCREEN_SHAPE_RECT = 2;
-}
-
-// Parameters describing the device requesting a tile update. This contains
-// physical and logical characteristics about the device (e.g. screen size and
-// density, etc).
-message DeviceParameters {
- // Width of the device's screen in DP.
- uint32 screen_width_dp = 1;
-
- // Height of the device's screen in DP.
- uint32 screen_height_dp = 2;
-
- // Density of the display. This value is the scaling factor to get from DP to
- // Pixels (px = dp * density).
- float screen_density = 3;
-
- // The platform of the device.
- DevicePlatform device_platform = 4;
-
- // The shape of the device's screen
- ScreenShape screen_shape = 5;
-}
diff --git a/wear/wear-tiles/src/main/proto/dimension.proto b/wear/wear-tiles/src/main/proto/dimension.proto
deleted file mode 100644
index 5c5abb7..0000000
--- a/wear/wear-tiles/src/main/proto/dimension.proto
+++ /dev/null
@@ -1,79 +0,0 @@
-// Dimensions for layout elements.
-syntax = "proto3";
-
-package androidx.wear.tiles.proto;
-
-
-
-
-option java_package = "androidx.wear.tiles.proto";
-option java_outer_classname = "DimensionProto";
-
-// A type for linear dimensions, measured in dp.
-message DpProp {
- // The value, in dp.
- float value = 1;
-}
-
-// A type for font sizes, measured in sp.
-message SpProp {
- // The value, in sp.
- uint32 value = 1;
-}
-
-// A type for angular dimensions, measured in degrees.
-message DegreesProp {
- // The value, in degrees.
- float value = 1;
-}
-
-// A type for a dimension that fills all the space it can (i.e. MATCH_PARENT in
-// Android parlance)
-message ExpandedDimensionProp {}
-
-// A type for a dimension that sizes itself to the size of its children (i.e.
-// WRAP_CONTENT in Android parlance)
-message WrappedDimensionProp {}
-
-// A type for a dimension that scales itself proportionally to another dimension
-// such that the aspect ratio defined by the given width and height values is
-// preserved.
-//
-// Note that the width and height are unitless; only their ratio is relevant.
-// This allows for specifying an element's size using common ratios (e.g.
-// width=4, height=3), or to allow an element to be resized proportionally based
-// on the size of an underlying asset (e.g. an 800x600 image being added to a
-// smaller container and resized accordingly).
-message ProportionalDimensionProp {
- // The width to be used when calculating the aspect ratio to preserve.
- uint32 aspect_ratio_width = 1;
-
- // The height to be used when calculating the aspect ratio ratio to preserve.
- uint32 aspect_ratio_height = 2;
-}
-
-// A dimension that can be linear or angular.
-message LinearOrAngularDimension {
- oneof inner {
- DpProp linear_dimension = 1;
- DegreesProp angular_dimension = 2;
- }
-}
-
-// A dimension that can be applied to a container.
-message ContainerDimension {
- oneof inner {
- DpProp linear_dimension = 1;
- ExpandedDimensionProp expanded_dimension = 2;
- WrappedDimensionProp wrapped_dimension = 3;
- }
-}
-
-// A dimension that can be applied to an image.
-message ImageDimension {
- oneof inner {
- DpProp linear_dimension = 1;
- ExpandedDimensionProp expanded_dimension = 2;
- ProportionalDimensionProp proportional_dimension = 3;
- }
-}
diff --git a/wear/wear-tiles/src/main/proto/layout.proto b/wear/wear-tiles/src/main/proto/layout.proto
deleted file mode 100644
index fafc3fd..0000000
--- a/wear/wear-tiles/src/main/proto/layout.proto
+++ /dev/null
@@ -1,609 +0,0 @@
-// Composable layout elements that can be combined together to create renderable
-// UI layouts.
-syntax = "proto3";
-
-package androidx.wear.tiles.proto;
-
-import "action.proto";
-import "color.proto";
-import "dimension.proto";
-
-import "types.proto";
-
-
-option java_package = "androidx.wear.tiles.proto";
-option java_outer_classname = "LayoutElementProto";
-
-// The horizontal alignment of an element within its container.
-enum HorizontalAlignment {
- // Horizontal alignment is undefined.
- HALIGN_UNDEFINED = 0;
-
- // Horizontally align to the left.
- HALIGN_LEFT = 1;
-
- // Horizontally align to center.
- HALIGN_CENTER = 2;
-
- // Horizontally align to the right.
- HALIGN_RIGHT = 3;
-
- // Horizontally align to the content start (left in LTR layouts, right in RTL
- // layouts).
- HALIGN_START = 4;
-
- // Horizontally align to the content end (right in LTR layouts, left in RTL
- // layouts).
- HALIGN_END = 5;
-}
-
-// An extensible HorizontalAlignment property.
-message HorizontalAlignmentProp {
- // The value
- HorizontalAlignment value = 1;
-}
-
-// The vertical alignment of an element within its container.
-enum VerticalAlignment {
- // Vertical alignment is undefined.
- VALIGN_UNDEFINED = 0;
-
- // Vertically align to the top.
- VALIGN_TOP = 1;
-
- // Vertically align to center.
- VALIGN_CENTER = 2;
-
- // Vertically align to the bottom.
- VALIGN_BOTTOM = 3;
-}
-
-// An extensible VerticalAlignment property.
-message VerticalAlignmentProp {
- // The value.
- VerticalAlignment value = 1;
-}
-
-// The weight to be applied to the font.
-enum FontWeight {
- // Font weight is undefined.
- FONT_WEIGHT_UNDEFINED = 0;
-
- // Normal font weight.
- FONT_WEIGHT_NORMAL = 400;
-
- // Bold font weight.
- FONT_WEIGHT_BOLD = 700;
-}
-
-// An extensible FontWeight property.
-message FontWeightProp {
- // The value.
- FontWeight value = 1;
-}
-
-// The styling of a font (e.g. font size, and metrics).
-message FontStyle {
- // The size of the font, in scaled pixels (sp). If not specified, defaults to
- // the size of the system's "body" font.
- SpProp size = 1;
-
- // Whether the text should be rendered in a bold typeface. If not specified,
- // defaults to "false".
- //
- // DEPRECATED: Use weight instead.
- BoolProp bold = 2 [deprecated = true];
-
- // Whether the text should be rendered in a italic typeface. If not specified,
- // defaults to "false".
- BoolProp italic = 3;
-
- // Whether the text should be rendered with an underline. If not specified,
- // defaults to "false".
- BoolProp underline = 4;
-
- // The text color. If not defined, defaults to white.
- ColorProp color = 5;
-
- // The weight of the font. If the provided value is not supported on a
- // platform, the nearest supported value will be used. If not defined, or
- // when set to an invalid value, defaults to "normal".
- FontWeightProp weight = 6;
-}
-
-// Alignment of a text element.
-enum TextAlignment {
- // Alignment is undefined.
- TEXT_ALIGN_UNDEFINED = 0;
-
- // Align to the "start" of the Text element (left in LTR layouts, right in
- // RTL layouts).
- TEXT_ALIGN_START = 1;
-
- // Align to the center of the Text element.
- TEXT_ALIGN_CENTER = 2;
-
- // Align to the "end" of the Text element (right in LTR layouts, left in RTL
- // layouts).
- TEXT_ALIGN_END = 3;
-}
-
-// An extensible TextAlignment property.
-message TextAlignmentProp {
- // The value.
- TextAlignment value = 1;
-}
-
-// How text that will not fit inside the bounds of a Text element will be
-// handled.
-//
-// TODO(b/175536688): Rename this to align with Spannable
-enum TextOverflow {
- // Overflow behavior is undefined.
- TEXT_OVERFLOW_UNDEFINED = 0;
-
- // Truncate the text to fit inside of the Text element's bounds. If text is
- // truncated, it will be truncated on a word boundary.
- TEXT_OVERFLOW_TRUNCATE = 1;
-
- // Truncate the text to fit in the Text element's bounds, but add an ellipsis
- // (i.e. ...) to the end of the text if it has been truncated.
- TEXT_OVERFLOW_ELLIPSIZE_END = 2;
-}
-
-// An extensible TextOverflow property.
-message TextOverflowProp {
- // The value.
- TextOverflow value = 1;
-}
-
-// The anchor position of an Arc's elements. This is used to specify how
-// elements added to an Arc should be laid out with respect to anchor_angle.
-//
-// As an example, assume that the following diagrams are wrapped to an arc, and
-// each represents an Arc element containing a single Text element. The Text
-// element's anchor_angle is "0" for all cases.
-//
-// ```
-// ARC_ANCHOR_START:
-// -180 0 180
-// Hello World!
-//
-//
-// ARC_ANCHOR_CENTER:
-// -180 0 180
-// Hello World!
-//
-// ARC_ANCHOR_END:
-// -180 0 180
-// Hello World!
-// ```
-enum ArcAnchorType {
- // Anchor position is undefined.
- ARC_ANCHOR_UNDEFINED = 0;
-
- // Anchor at the start of the elements. This will cause elements added to an
- // arc to begin at the given anchor_angle, and sweep around to the right.
- ARC_ANCHOR_START = 1;
-
- // Anchor at the center of the elements. This will cause the center of the
- // whole set of elements added to an arc to be pinned at the given
- // anchor_angle.
- ARC_ANCHOR_CENTER = 2;
-
- // Anchor at the end of the elements. This will cause the set of elements
- // inside the arc to end at the specified anchor_angle, i.e. all elements
- // should be to the left of anchor_angle.
- ARC_ANCHOR_END = 3;
-}
-
-// An extensible ArcAnchorType property.
-message ArcAnchorTypeProp {
- // The value.
- ArcAnchorType value = 1;
-}
-
-// The padding around a Box element.
-message Padding {
- // The padding on the end of the content, depending on the layout direction,
- // in DP and the value of "rtl_aware".
- DpProp end = 1;
-
- // The padding on the start of the content, depending on the layout direction,
- // in DP and the value of "rtl_aware".
- DpProp start = 2;
-
- // The padding at the top, in DP.
- DpProp top = 3;
-
- // The padding at the bottom, in DP.
- DpProp bottom = 4;
-
- // Whether the start/end padding is aware of RTL support. If true, the values
- // for start/end will follow the layout direction (i.e. start will refer to
- // the right hand side of the container if the device is using an RTL locale).
- // If false, start/end will always map to left/right, accordingly.
- BoolProp rtl_aware = 5;
-}
-
-// The border around a Box element.
-message Border {
- // The width of the border, in DP.
- DpProp width = 1;
-
- // The color of the border.
- ColorProp color = 2;
-}
-
-// The corner of a Box element.
-message Corner {
- // The radius of the corner in DP.
- DpProp radius = 1;
-}
-
-// The style of a Text element.
-message TextStyle {
- // The text color. If not defined, defaults to white.
- //
- // DEPRECATED: Use color property of FontStyle instead.
- ColorProp color = 1 [deprecated = true];
-
- // The maximum number of lines that can be represented by the Text element.
- // If not defined, the Text element will be treated as a single-line element.
- Int32Prop max_lines = 2;
-
- // Alignment of the text within its bounds. Note that a Text element will size
- // itself to wrap its contents, so this option is meaningless for single-line
- // text (for that, use alignment of the outer container). For multi-line text,
- // however, this will set the alignment of lines relative to the Text element
- // bounds. If not defined, defaults to TEXT_ALIGN_CENTER.
- TextAlignmentProp multiline_alignment = 3;
-
- // Specifies how to handle text which overflows the bound of the Text element.
- // A Text element will grow as large as possible inside its parent container
- // (while still respecting max_lines); if it cannot grow large enough to
- // render all of its text, the text which cannot fit inside its container will
- // be truncated. If not defined, defaults to TEXT_OVERFLOW_TRUNCATE.
- TextOverflowProp overflow = 4;
-}
-
-// The style of a Spannable element.
-message SpannableStyle {
- // The maximum number of lines that can be represented by the Spannable
- // element. If not defined, the Text element will be treated as a single-line
- // element.
- Int32Prop max_lines = 1;
-
- // Alignment of the Spannable content within its bounds. Note that a Spannable
- // element will size itself to wrap its contents, so this option is
- // meaningless for single-line content (for that, use alignment of the outer
- // container). For multi-line content, however, this will set the alignment of
- // lines relative to the Spannable element bounds. If not defined, defaults to
- // TEXT_ALIGN_CENTER.
- HorizontalAlignmentProp multiline_alignment = 2;
-
- // Specifies how to handle content which overflows the bound of the Spannable
- // element. A Spannable element will grow as large as possible inside its
- // parent container (while still respecting max_lines); if it cannot grow
- // large enough to render all of its content, the content which cannot fit
- // inside its container will be truncated. If not defined, defaults to
- // TEXT_OVERFLOW_TRUNCATE.
- TextOverflowProp overflow = 3;
-}
-
-// The style of a Box.
-message BoxStyle {
- // The background color for this Box. If not defined, defaults to being
- // transparent.
- ColorProp background_color = 1;
-
- // An optional padding inside of this Box. If not defined, Box will not have
- // any padding.
- Padding padding = 2;
-
- // An optional border for this Box. If not defined, Box will not have a
- // border.
- Border border = 3;
-
- // The corner properties of this Box. This only affects the drawing of this
- // Box if either "color" or "border" are also set. If not defined, defaults to
- // having a square corner.
- Corner corner = 4;
-}
-
-// The style of a line.
-message LineStyle {
- // Color of this line. If not defined, defaults to white.
- ColorProp color = 1;
-}
-
-// A text string.
-message Text {
- // The text to render.
- StringProp text = 1;
-
- // An optional style for this text string.
- //
- // DEPRECATED: Use Spannable with SpannableStyle instead.
- TextStyle style = 2 [deprecated = true];
-
- // The style of font to use (size, bold etc). If not specified, defaults to
- // the platform's default body font.
- FontStyle font_style = 3;
-}
-
-// A holder for an element which can have associated Action items for click
-// events. When an element wrapped in a Clickable is clicked, it will fire the
-// associated action.
-message Clickable {
- // The ID associated with this action.
- string id = 1;
-
- // The layout element to attach the action to.
- LayoutElement content = 2;
-
- // The action to perform when "content" is clicked.
- Action on_click = 3;
-}
-
-// How content which does not match the dimensions of its bounds (e.g. an image
-// resource being drawn inside an Image) will be resized to fit its bounds.
-enum ContentScaleMode {
- // Content scaling is undefined.
- CONTENT_SCALE_MODE_UNDEFINED = 0;
-
- // Content will be scaled to fit inside its bounds, proportionally. As an
- // example, If a 10x5 image was going to be drawn inside a 50x50 Image
- // element, the actual image resource would be drawn as a 50x25 image,
- // centered within the 50x50 bounds.
- CONTENT_SCALE_MODE_FIT = 1;
-
- // Content will be resized proportionally so it completely fills its bounds,
- // and anything outside of the bounds will be cropped. As an example, if a
- // 10x5 image was going to be drawn inside a 50x50 Image element, the image
- // resource would be drawn as a 100x50 image, centered within its bounds (and
- // with 25px cropped from both the left and right sides).
- CONTENT_SCALE_MODE_CROP = 2;
-
- // Content will be resized to fill its bounds, without taking into account the
- // aspect ratio. If a 10x5 image was going to be drawn inside a 50x50 Image
- // element, the image would be drawn as a 50x50 image, stretched vertically.
- CONTENT_SCALE_MODE_FILL_BOUNDS = 3;
-}
-
-// An extensible ContentScaleMode property.
-message ContentScaleModeProp {
- ContentScaleMode value = 1;
-}
-
-// An image.
-//
-// Images used in this element must exist in the resource bundle that
-// corresponds to this layout. Images must have their dimension specified, and
-// will be rendered at this width and height, regardless of their native
-// dimension.
-message Image {
- // The resource_id of the image to render. This must exist in the supplied
- // resource bundle.
- StringProp resource_id = 1;
-
- // The width of this image. If not defined, the image will not be rendered.
- ImageDimension width = 2;
-
- // The height of this image. If not defined, the image will not be rendered.
- ImageDimension height = 3;
-
- // How to scale the image resource inside the bounds specified by width/height
- // if its size does not match those bounds. Defaults to
- // CONTENT_SCALE_MODE_FIT.
- ContentScaleModeProp content_scale_mode = 4;
-}
-
-// A simple spacer, typically used to provide padding between adjacent elements.
-message Spacer {
- // The width of this Spacer. When this is added as the direct child of an Arc,
- // this must be specified as an angular dimension, otherwise a linear
- // dimension must be used. If not defined, defaults to 0.
- LinearOrAngularDimension width = 1;
-
- // The height of this spacer. If not defined, defaults to 0.
- DpProp height = 2;
-}
-
-// A container which stacks all of its children on top of one another. This also
-// allows to add a background color, or to have a border around them with some
-// padding.
-message Box {
- // The child element(s) to wrap.
- repeated LayoutElement contents = 1;
-
- // The style of the Box (padding, background color, border etc).
- BoxStyle style = 2;
-
- // The height of this Box. If not defined, this will size itself to fit all of
- // its children (i.e. a WrappedDimension).
- ContainerDimension height = 3;
-
- // The width of this Box. If not defined, this will size itself to fit all of
- // its children (i.e. a WrappedDimension).
- ContainerDimension width = 4;
-
- // The horizontal alignment of the element inside this Box. If not defined,
- // defaults to HALIGN_CENTER.
- HorizontalAlignmentProp horizontal_alignment = 5;
-
- // The vertical alignment of the element inside this Box. If not defined,
- // defaults to VALIGN_CENTER.
- VerticalAlignmentProp vertical_alignment = 6;
-}
-
-// A single Span. Each Span forms part of a larger Spannable widget. At the
-// moment, the only widgets which can be added to Spannable containers are
-// Text elements.
-message Span {
- oneof inner {
- Text text = 1;
- }
-}
-
-// A container of Span elements. Currently, this only supports Text elements,
-// where each individual Span can have different styling applied to it but the
-// resulting text will flow naturally. This allows sections of a paragraph of
-// text to have different styling applied to it, for example, making one or two
-// words bold or italic.
-message Spannable {
- // The Span elements that form this Spannable.
- repeated Span spans = 1;
-
- // The style of this Spannable
- SpannableStyle style = 2;
-}
-
-// A column of elements. Each child element will be laid out vertically, one
-// after another (i.e. stacking down). This element will size itself to the
-// smallest size required to hold all of its children (e.g. if it contains three
-// elements sized 10x10, 20x20 and 30x30, the resulting column will be 30x60).
-//
-// If specified, horizontal_alignment can be used to control the gravity inside
-// the container, affecting the horizontal placement of children whose width are
-// smaller than the resulting column width.
-message Column {
- // The list of child elements to place inside this Column.
- repeated LayoutElement contents = 1;
-
- // The horizontal alignment of elements inside this column, if they are
- // narrower than the resulting width of the column. If not defined, defaults
- // to HALIGN_CENTER.
- HorizontalAlignmentProp horizontal_alignment = 2;
-
- // The width of this column. If not defined, this will size itself to fit
- // all of its children (i.e. a WrappedDimension).
- ContainerDimension width = 3;
-
- // The height of this column. If not defined, this will size itself to fit
- // all of its children (i.e. a WrappedDimension).
- ContainerDimension height = 4;
-}
-
-// A row of elements. Each child will be laid out horizontally, one after
-// another (i.e. stacking to the right). This element will size itself to the
-// smallest size required to hold all of its children (e.g. if it contains three
-// elements sized 10x10, 20x20 and 30x30, the resulting row will be 60x30).
-//
-// If specified, vertical_alignment can be used to control the gravity inside
-// the container, affecting the vertical placement of children whose width are
-// smaller than the resulting row height.
-message Row {
- // The list of child elements to place inside this Row.
- repeated LayoutElement contents = 1;
-
- // The vertical alignment of elements inside this row, if they are narrower
- // than the resulting height of the row. If not defined, defaults to
- // VALIGN_CENTER.
- VerticalAlignmentProp vertical_alignment = 2;
-
- // The width of this row. If not defined, this will size itself to fit
- // all of its children (i.e. a WrappedDimension).
- ContainerDimension width = 3;
-
- // The height of this row. If not defined, this will size itself to fit
- // all of its children (i.e. a WrappedDimension).
- ContainerDimension height = 4;
-}
-
-// A wrapper for an element which has a screen reader description associated
-// with it. This should generally be used sparingly, and in most cases should
-// only be applied to the top-level layout element or to Clickables.
-message Audible {
- // The element to wrap with the screen reader description.
- LayoutElement content = 1;
-
- // The accessibility label associated with this element. This will be dictated
- // when the element is focused by the screen reader.
- string accessibility_label = 2;
-}
-
-// A line. When added to a normal container, this renders as a horizontal line
-// which can be used to provide a visual break between elements. When added to
-// an arc, it will render as a round progress bar.
-message Line {
- // The length of this Line. When this is added as the direct child of an Arc,
- // this must be specified as an AngularDimension, otherwise a LinearDimension
- // must be used. If not defined, defaults to 0.
- LinearOrAngularDimension length = 1;
-
- // The thickness of this line. If not defined, defaults to 0.
- DpProp thickness = 2;
-
- // The style of this line.
- LineStyle style = 3;
-}
-
-// An arc container. This container will fill itself to a circle, which fits
-// inside its parent container, and all of its children will be placed on that
-// circle. The fields anchor_angle and anchor_type can be used to specify where
-// to draw children within this circle.
-//
-// Note that there are two special cases. Text and Line elements which are added
-// as direct descendants to an arc will be drawn as a curved widget around the
-// arc, rather than just placed on the arc and drawn normally.
-message Arc {
- // Contents of this container.
- repeated LayoutElement contents = 1;
-
- // The length of this Arc as an angle. If not defined, this will size itself
- // to fit all of its children. If defined, this should be a value > 0 degrees.
- DegreesProp length = 2;
-
- // The thickness of this Arc. If not defined, this will size itself to fit all
- // of its children.
- DpProp thickness = 3;
-
- // Whether this Arc's children should be rotated, according to its position
- // in the arc or not. As an example, assume that an Image has been added to
- // the arc, and ends up at the 3 o clock position. If rotate_contents = true,
- // the image will be placed at the 3 o clock position, and will be rotated
- // clockwise through 90 degrees. If rotate_contents = false, the image will be
- // placed at the 3 o clock position, but itself will not be rotated. If not
- // defined, defaults to true.
- BoolProp rotate_contents = 4;
-
- // The angle for the anchor, used with anchor_type to determine where to draw
- // children. Note that 0 degrees is the 12 o clock position on a device, and
- // the angle sweeps clockwise. If not defined, defaults to 0 degrees.
- //
- // Values do not have to be clamped to the range 0-360; values less than 0
- // degrees will sweep anti-clockwise (i.e. -90 degrees is equivalent to 270
- // degrees), and values >360 will be be placed at X mod 360 degrees.
- DegreesProp anchor_angle = 5;
-
- // How to align the contents of this container relative to anchor_angle. See
- // the descriptions of options in ArcAnchorType for more information. If not
- // defined, defaults to ARC_ANCHOR_CENTER.
- ArcAnchorTypeProp anchor_type = 6;
-
- // Vertical alignment of elements within the arc. If the Arc's thickness is
- // larger than the thickness of the element being drawn, this controls whether
- // the element should be drawn towards the inner or outer edge of the arc, or
- // drawn in the center.
- // If not defined, defaults to VALIGN_CENTER
- VerticalAlignmentProp vertical_align = 7;
-}
-
-// The root of all layout elements. This exists to act as a holder for all of
-// the actual layout elements above.
-message LayoutElement {
- oneof inner {
- Column column = 1;
- Row row = 2;
- Box box = 3;
- Spacer spacer = 4;
- Text text = 5;
- Image image = 6;
- Clickable clickable = 7;
- Audible audible = 8;
- Line line = 9;
- Arc arc = 10;
- Spannable spannable = 11;
- }
-}
diff --git a/wear/wear-tiles/src/main/proto/requests.proto b/wear/wear-tiles/src/main/proto/requests.proto
deleted file mode 100644
index d642b9d..0000000
--- a/wear/wear-tiles/src/main/proto/requests.proto
+++ /dev/null
@@ -1,35 +0,0 @@
-// Request messages used to fetch tiles and resources
-syntax = "proto3";
-
-package androidx.wear.tiles.proto;
-
-import "device_parameters.proto";
-
-
-
-option java_package = "androidx.wear.tiles.proto";
-option java_outer_classname = "RequestProto";
-
-// Parameters passed to a Tile provider when the renderer is requesting a new
-// version of the tile.
-message TileRequest {
- // The ID of the Clickable that was tapped to cause this request. Empty string
- // if the request was not caused by a Clickable.
- // TODO(b/167954298): Pass a State object here instead.
- string clickable_id = 1;
-
- // Parameters describing the device requesting the tile update.
- DeviceParameters device_parameters = 2
- ;
-}
-
-// Parameters passed to a Tile provider when the renderer is requesting a
-// specific resource version.
-message ResourcesRequest {
- // The version of the resources being fetched
- string version = 1;
-
- // Requested resource IDs. If not specified, all resources for the given
- // version must be provided in the response.
- repeated string resource_ids = 2;
-}
diff --git a/wear/wear-tiles/src/main/proto/resources.proto b/wear/wear-tiles/src/main/proto/resources.proto
deleted file mode 100644
index c090ee5..0000000
--- a/wear/wear-tiles/src/main/proto/resources.proto
+++ /dev/null
@@ -1,70 +0,0 @@
-// The resources for a layout.
-syntax = "proto3";
-
-package androidx.wear.tiles.proto;
-
-
-
-
-option java_package = "androidx.wear.tiles.proto";
-option java_outer_classname = "ResourceProto";
-
-// Format describing the contents of an image data byte array.
-enum ImageFormat {
- // An undefined image format.
- IMAGE_FORMAT_UNDEFINED = 0;
-
- // An image format where each pixel is stored on 2 bytes, with red using 5
- // bits, green using 6 bits and blue using 5 bits of precision.
- IMAGE_FORMAT_RGB_565 = 1;
-}
-
-// An image resource which maps to an Android drawable by resource ID.
-message AndroidImageResourceByResId {
- // The Android resource ID of this image. This must refer to a drawable under
- // R.drawable.
- int32 resource_id = 1;
-}
-
-// An image resource whose data is fully inlined, with no dependency on a
-// system or app resource.
-message InlineImageResource {
- // The byte array representing the image.
- bytes data = 1;
-
- // The native width of the image, in pixels.
- int32 width_px = 2;
-
- // The native height of the image, in pixels.
- int32 height_px = 3;
-
- // The format of the byte array data representing the image.
- ImageFormat format = 4;
-}
-
-// An image resource, which can be used by layouts. This holds multiple
-// underlying resource types, which the underlying runtime will pick according
-// to what it thinks is appropriate.
-message ImageResource {
- // An image resource that maps to an Android drawable by resource ID.
- AndroidImageResourceByResId android_resource_by_resid = 1;
-
- // An image resource that contains the image data inline.
- InlineImageResource inline_resource = 2;
-}
-
-// The resources for a layout.
-message Resources {
- // The version of this Resources instance.
- //
- // Each tile specifies the version of resources it requires. After fetching a
- // tile, the renderer will use the resources version specified by the tile
- // to separately fetch the resources.
- //
- // This value must match the version of the resources required by the tile
- // for the tile to render successfully.
- string version = 1;
-
- // A map of resource_ids to images, which can be used by layouts.
- map<string, ImageResource> id_to_image = 2;
-}
diff --git a/wear/wear-tiles/src/main/proto/tile.proto b/wear/wear-tiles/src/main/proto/tile.proto
deleted file mode 100644
index 923c4d1..0000000
--- a/wear/wear-tiles/src/main/proto/tile.proto
+++ /dev/null
@@ -1,21 +0,0 @@
-// The components of a tile that can be rendered by a tile renderer.
-syntax = "proto3";
-
-package androidx.wear.tiles.proto;
-
-
-import "timeline.proto";
-
-
-option java_package = "androidx.wear.tiles.proto";
-option java_outer_classname = "TileProto";
-
-// A holder for a tile. This specifies the resources to use for this delivery
-// of the tile, and the timeline for the tile.
-message Tile {
- // The resource version required for these tiles.
- string resources_version = 1;
-
- // The tiles to show in the carousel, along with their validity periods.
- Timeline timeline = 2;
-}
diff --git a/wear/wear-tiles/src/main/proto/timeline.proto b/wear/wear-tiles/src/main/proto/timeline.proto
deleted file mode 100644
index 85b0fdd..0000000
--- a/wear/wear-tiles/src/main/proto/timeline.proto
+++ /dev/null
@@ -1,48 +0,0 @@
-// A timeline with entries representing content that should be displayed within
-// given time intervals.
-syntax = "proto3";
-
-package androidx.wear.tiles.proto;
-
-
-import "layout.proto";
-
-
-option java_package = "androidx.wear.tiles.proto";
-option java_outer_classname = "TimelineProto";
-
-// A time interval, typically used to describe the validity period of a
-// TimelineEntry
-message TimeInterval {
- // Starting point of the time interval, in milliseconds since the Unix epoch.
- int64 start_millis = 1;
-
- // End point of the time interval, in milliseconds since the Unix epoch.
- int64 end_millis = 2;
-}
-
-// One piece of renderable content along with the time that it is valid for.
-message TimelineEntry {
- // The contents of this timeline entry.
- LayoutElement content = 1;
-
- // The validity period for this timeline entry.
- TimeInterval validity = 2;
-}
-
-// A collection of TimelineEntry items.
-//
-// TimelineEntry items can be used to update a layout on-screen at known times,
-// without having to explicitly update a layout. This allows for cases where,
-// say, a calendar can be used to show the next event, and automatically switch
-// to showing the next event when one has passed.
-//
-// The active TimelineEntry is switched, at most, once a minute. In the case
-// where the validity periods of TimelineEntry items overlap, the item with the
-// *shortest* validity period will be shown. This allows a layout provider to
-// show a "default" layout, and override it at set points without having to
-// explicitly insert the default layout between the "override" layout.
-message Timeline {
- // The entries in a timeline.
- repeated TimelineEntry timeline_entries = 1;
-}
diff --git a/wear/wear-tiles/src/main/proto/types.proto b/wear/wear-tiles/src/main/proto/types.proto
deleted file mode 100644
index 40398f2..0000000
--- a/wear/wear-tiles/src/main/proto/types.proto
+++ /dev/null
@@ -1,32 +0,0 @@
-// Extensible primitive types used by layout elements.
-syntax = "proto3";
-
-package androidx.wear.tiles.proto;
-
-
-option java_package = "androidx.wear.tiles.proto";
-option java_outer_classname = "TypesProto";
-
-// An int32 type.
-message Int32Prop {
- // The value.
- int32 value = 1;
-}
-
-// A string type.
-message StringProp {
- // The value.
- string value = 1;
-}
-
-// A float type.
-message FloatProp {
- // The value.
- float value = 1;
-}
-
-// A boolean type.
-message BoolProp {
- // The value.
- bool value = 1;
-}
diff --git a/wear/wear-watchface/src/main/java/androidx/wear/watchface/WatchFace.kt b/wear/wear-watchface/src/main/java/androidx/wear/watchface/WatchFace.kt
index f23ea9e..0127548 100644
--- a/wear/wear-watchface/src/main/java/androidx/wear/watchface/WatchFace.kt
+++ b/wear/wear-watchface/src/main/java/androidx/wear/watchface/WatchFace.kt
@@ -350,10 +350,11 @@
// Complications are highlighted when tapped and after this delay the highlight is removed.
internal const val CANCEL_COMPLICATION_HIGHLIGHTED_DELAY_MS = 300L
- // The threshold used to judge whether the battery is low. Ideally we would use the
- // threshold for Intent.ACTION_BATTERY_LOW but it's not documented and the value below is an
- // assumption.
- internal const val LOW_BATTERY_THRESHOLD = 15.0f
+ // The threshold used to judge whether the battery is low during initialization. Ideally
+ // we would use the threshold for Intent.ACTION_BATTERY_LOW but it's not documented or
+ // available programmatically. The value below is the default but it could be overridden
+ // by OEMs.
+ internal const val INITIAL_LOW_BATTERY_THRESHOLD = 15.0f
}
private val systemTimeProvider = watchface.systemTimeProvider
@@ -632,7 +633,8 @@
} ?: 100.0f
val isBatteryLowAndNotCharging =
watchState.isBatteryLowAndNotCharging as MutableObservableWatchData
- isBatteryLowAndNotCharging.value = (batteryPercent < LOW_BATTERY_THRESHOLD) && !isCharging
+ isBatteryLowAndNotCharging.value =
+ (batteryPercent < INITIAL_LOW_BATTERY_THRESHOLD) && !isCharging
}
/**
diff --git a/wear/wear/src/main/res/values-mn/strings.xml b/wear/wear/src/main/res/values-mn/strings.xml
index 3477a4f..8728919 100644
--- a/wear/wear/src/main/res/values-mn/strings.xml
+++ b/wear/wear/src/main/res/values-mn/strings.xml
@@ -16,6 +16,6 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="ws_navigation_drawer_content_description" msgid="777117228299084604">"Навигацийн шургуулга"</string>
+ <string name="ws_navigation_drawer_content_description" msgid="777117228299084604">"Навигацын шургуулга"</string>
<string name="ws_action_drawer_content_description" msgid="8863821639144537553">"Үйлдлийн татуурга"</string>
</resources>
diff --git a/webkit/webkit/src/main/java/androidx/webkit/internal/WebViewProviderAdapter.java b/webkit/webkit/src/main/java/androidx/webkit/internal/WebViewProviderAdapter.java
index a8b4e5b..75676d0 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/internal/WebViewProviderAdapter.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/internal/WebViewProviderAdapter.java
@@ -142,6 +142,7 @@
/**
* Adapter method for {@link WebViewCompat#getWebViewRendererClient()}.
*/
+ @RequiresApi(19)
@Nullable
public WebViewRenderProcessClient getWebViewRenderProcessClient() {
InvocationHandler handler = mImpl.getWebViewRendererClient();
diff --git a/work/workmanager/src/androidTest/java/androidx/work/impl/workers/ConstraintTrackingWorkerTest.java b/work/workmanager/src/androidTest/java/androidx/work/impl/workers/ConstraintTrackingWorkerTest.java
index e376704..d0a5e57 100644
--- a/work/workmanager/src/androidTest/java/androidx/work/impl/workers/ConstraintTrackingWorkerTest.java
+++ b/work/workmanager/src/androidTest/java/androidx/work/impl/workers/ConstraintTrackingWorkerTest.java
@@ -27,14 +27,16 @@
import android.content.Context;
import android.os.Handler;
-import android.os.Looper;
+import android.os.HandlerThread;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
+import androidx.core.os.HandlerCompat;
import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.LargeTest;
import androidx.test.filters.SdkSuppress;
+import androidx.testutils.RepeatRule;
import androidx.work.Configuration;
import androidx.work.Constraints;
import androidx.work.Data;
@@ -67,7 +69,9 @@
import org.hamcrest.CoreMatchers;
import org.jetbrains.annotations.NotNull;
+import org.junit.After;
import org.junit.Before;
+import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -85,6 +89,7 @@
private static final String TEST_ARGUMENT_NAME = "test";
private Context mContext;
+ private HandlerThread mHandlerThread;
private Handler mHandler;
private WorkerFactory mWorkerFactory;
@@ -104,10 +109,15 @@
private NetworkStateTracker mNetworkStateTracker;
private StorageNotLowTracker mStorageNotLowTracker;
+ @Rule
+ public final RepeatRule mRepeatRule = new RepeatRule();
+
@Before
public void setUp() {
mContext = ApplicationProvider.getApplicationContext().getApplicationContext();
- mHandler = new Handler(Looper.getMainLooper());
+ mHandlerThread = new HandlerThread("ConstraintTrackingHandler");
+ mHandlerThread.start();
+ mHandler = HandlerCompat.createAsync(mHandlerThread.getLooper());
mWorkerFactory = new SpyingWorkerFactory();
mConfiguration = new Configuration.Builder()
.setExecutor(new SynchronousExecutor())
@@ -140,6 +150,11 @@
Trackers.setInstance(mTracker);
}
+ @After
+ public void tearDown() {
+ mHandlerThread.quitSafely();
+ }
+
@Test
@SdkSuppress(minSdkVersion = 23, maxSdkVersion = 25)
public void testConstraintTrackingWorker_onConstraintsMet() {
@@ -192,9 +207,9 @@
}, DELAY_IN_MS);
Thread.sleep(TEST_TIMEOUT_IN_MS);
- executorService.shutdown();
WorkSpec workSpec = mDatabase.workSpecDao().getWorkSpec(mWork.getStringId());
assertThat(workSpec.state, is(WorkInfo.State.ENQUEUED));
+ executorService.shutdown();
}
@Test