diff --git a/a2ui/a2ui-model/src/main/kotlin/androidx/a2ui/model/schema/A2uiObjectSchema.kt b/a2ui/a2ui-model/src/main/kotlin/androidx/a2ui/model/schema/A2uiObjectSchema.kt index 16e0a11f6e72c..64bbdf35c0f72 100644 --- a/a2ui/a2ui-model/src/main/kotlin/androidx/a2ui/model/schema/A2uiObjectSchema.kt +++ b/a2ui/a2ui-model/src/main/kotlin/androidx/a2ui/model/schema/A2uiObjectSchema.kt @@ -61,7 +61,7 @@ public constructor( put(KEY_TYPE, TYPE_OBJECT) put(KEY_PROPERTIES, JsonObject(properties.mapValues { it.value.toJsonElement() })) if (required.isNotEmpty()) { - put(KEY_REQUIRED, JsonArray(required.map { JsonPrimitive(it) })) + put(KEY_REQUIRED, JsonArray(required.sorted().map { JsonPrimitive(it) })) } if (!isAdditionalPropertiesAllowed) { put(KEY_ADDITIONAL_PROPERTIES, false) diff --git a/a2ui/a2ui-model/src/test/kotlin/androidx/a2ui/model/schema/A2uiObjectSchemaTest.kt b/a2ui/a2ui-model/src/test/kotlin/androidx/a2ui/model/schema/A2uiObjectSchemaTest.kt index 26eefb58491c5..29b1366206d81 100644 --- a/a2ui/a2ui-model/src/test/kotlin/androidx/a2ui/model/schema/A2uiObjectSchemaTest.kt +++ b/a2ui/a2ui-model/src/test/kotlin/androidx/a2ui/model/schema/A2uiObjectSchemaTest.kt @@ -21,9 +21,12 @@ import com.google.common.truth.Truth.assertThat import kotlin.test.Test import kotlin.test.assertFailsWith import kotlinx.serialization.json.Json +import kotlinx.serialization.json.JsonArray +import kotlinx.serialization.json.JsonObject import kotlinx.serialization.json.JsonPrimitive import kotlinx.serialization.json.buildJsonArray import kotlinx.serialization.json.buildJsonObject +import kotlinx.serialization.json.jsonPrimitive import kotlinx.serialization.json.put import org.junit.runner.RunWith import org.junit.runners.JUnit4 @@ -75,6 +78,28 @@ class A2uiObjectSchemaTest { assertThat(Json.parseToJsonElement(schema.toJsonSchema())).isEqualTo(expected) } + @Test + fun toJsonSchema_withMultipleRequiredProperties_serializesRequiredInAlphabeticalOrder() { + val schema = + A2uiObjectSchema( + properties = + mapOf( + "zebra" to A2uiBooleanSchema(), + "alpha" to A2uiBooleanSchema(), + "middle" to A2uiBooleanSchema(), + ), + // Pass in non-alphabetical order to ensure sorting occurs regardless of input set + // iteration order + required = linkedSetOf("zebra", "alpha", "middle"), + ) + + val jsonElement = Json.parseToJsonElement(schema.toJsonSchema()) as JsonObject + val requiredArray = jsonElement[REQUIRED_FIELD] as JsonArray + val requiredList = requiredArray.map { it.jsonPrimitive.content } + + assertThat(requiredList).containsExactly("alpha", "middle", "zebra").inOrder() + } + @Test fun toJsonSchema_withEmptyRequired_doesNotIncludeRequiredField() { val schema = diff --git a/buildSrc/public/src/main/kotlin/androidx/build/AndroidXConfig.kt b/buildSrc/public/src/main/kotlin/androidx/build/AndroidXConfig.kt index 122b12b90e089..2693e494f3156 100644 --- a/buildSrc/public/src/main/kotlin/androidx/build/AndroidXConfig.kt +++ b/buildSrc/public/src/main/kotlin/androidx/build/AndroidXConfig.kt @@ -25,7 +25,7 @@ import org.gradle.api.file.FileCollection /** AndroidX configuration backed by Gradle properties. */ abstract class AndroidConfigImpl(private val project: Project) : AndroidConfig { - override val buildToolsVersion: String = "36.0.0" + override val buildToolsVersion: String = "37.0.0" override val compileSdk: Int by lazy { val sdkString = project.extraPropertyOrNull(COMPILE_SDK)?.toString() diff --git a/car/app/app-samples/showcase/common/src/main/java/androidx/car/app/sample/showcase/common/screens/templatelayouts/sectioneditemtemplates/ProgressBarDemoScreen.kt b/car/app/app-samples/showcase/common/src/main/java/androidx/car/app/sample/showcase/common/screens/templatelayouts/sectioneditemtemplates/ProgressBarDemoScreen.kt index 3f0de8c1a267c..07dd4c34f9931 100644 --- a/car/app/app-samples/showcase/common/src/main/java/androidx/car/app/sample/showcase/common/screens/templatelayouts/sectioneditemtemplates/ProgressBarDemoScreen.kt +++ b/car/app/app-samples/showcase/common/src/main/java/androidx/car/app/sample/showcase/common/screens/templatelayouts/sectioneditemtemplates/ProgressBarDemoScreen.kt @@ -33,6 +33,7 @@ import androidx.car.app.model.Header import androidx.car.app.model.Row import androidx.car.app.model.RowSection import androidx.car.app.model.SectionedItemTemplate +import androidx.car.app.model.StrokeCap import androidx.car.app.model.Template import androidx.car.app.sample.showcase.common.R import androidx.core.graphics.drawable.IconCompat @@ -64,6 +65,7 @@ class ProgressBarDemoScreen(carContext: CarContext) : Screen(carContext) { .addSection(createRegularRowsSection()) .addSection(createRowConfigurationsSection()) .addSection(createColoredRowsSection()) + .addSection(createStrokeCapRowsSection()) .addSection(createGridSection(GridSection.ITEM_SIZE_SMALL)) .addSection(createGridSection(GridSection.ITEM_SIZE_MEDIUM)) .addSection(createGridSection(GridSection.ITEM_SIZE_LARGE)) @@ -102,7 +104,7 @@ class ProgressBarDemoScreen(carContext: CarContext) : Screen(carContext) { val colors = listOf(CarColor.RED, CarColor.GREEN, CarColor.BLUE, CarColor.YELLOW) val colorNames = listOf("Red", "Green", "Blue", "Yellow") - val rows = + val coloredRows = colors.zip(colorNames).map { (color, name) -> Row.Builder() .setTitle("$name Progress Bar Row") @@ -110,12 +112,81 @@ class ProgressBarDemoScreen(carContext: CarContext) : Screen(carContext) { .setImage(testImage, Row.IMAGE_TYPE_LARGE) .setProgressBar( CarProgressBar.Builder(0.5f) - .setStyle(CarProgressBarStyle.Builder().setColor(color).build()) + .setStyle( + CarProgressBarStyle.Builder() + .setColor(color) + .setTrackColor(color) + .build() + ) + .build() + ) + .build() + } + + // Track color examples + val trackColoredRows = + listOf( + Row.Builder() + .setTitle("Green Progress Bar Row with Blue Track") + .addText("Colored progress bar example") + .setImage(testImage, Row.IMAGE_TYPE_LARGE) + .setProgressBar( + CarProgressBar.Builder(0.5f) + .setStyle( + CarProgressBarStyle.Builder() + .setColor(CarColor.GREEN) + .setTrackColor(CarColor.BLUE) + .build() + ) + .build() + ) + .build(), + Row.Builder() + .setTitle("Red Progress Bar Row with Yellow Track") + .addText("Colored progress bar example") + .setImage(testImage, Row.IMAGE_TYPE_LARGE) + .setProgressBar( + CarProgressBar.Builder(0.5f) + .setStyle( + CarProgressBarStyle.Builder() + .setColor(CarColor.RED) + .setTrackColor(CarColor.YELLOW) + .build() + ) + .build() + ) + .build(), + ) + + return RowSection.Builder() + .setTitle("Colored Progress Bars") + .setItems(coloredRows + trackColoredRows) + .build() + } + + private fun createStrokeCapRowsSection(): RowSection { + val strokeCaps = + listOf( + StrokeCap.DEFAULT, + StrokeCap.ROUND, + StrokeCap.SQUARE, + ) + val strokeCapNames = listOf("System default", "Round", "Square") + + val rows = + strokeCaps.zip(strokeCapNames).map { (strokeCap, name) -> + Row.Builder() + .setTitle("$name Stroke Cap Progress Bar Row") + .addText("Custom shaped progress bar example") + .setImage(testImage, Row.IMAGE_TYPE_LARGE) + .setProgressBar( + CarProgressBar.Builder(0.5f) + .setStyle(CarProgressBarStyle.Builder().setStrokeCap(strokeCap).build()) .build() ) .build() } - return RowSection.Builder().setTitle("Colored Progress Bars").setItems(rows).build() + return RowSection.Builder().setTitle("Shaped Progress Bars").setItems(rows).build() } private fun createGridSection( diff --git a/compose/animation/animation-core/src/commonMain/kotlin/androidx/compose/animation/core/Transition.kt b/compose/animation/animation-core/src/commonMain/kotlin/androidx/compose/animation/core/Transition.kt index bd0418352d5ee..729c5e5202c78 100644 --- a/compose/animation/animation-core/src/commonMain/kotlin/androidx/compose/animation/core/Transition.kt +++ b/compose/animation/animation-core/src/commonMain/kotlin/androidx/compose/animation/core/Transition.kt @@ -28,7 +28,6 @@ import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.MutableState import androidx.compose.runtime.Stable import androidx.compose.runtime.State -import androidx.compose.runtime.computedStateOf import androidx.compose.runtime.derivedStateOf import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableFloatStateOf @@ -1377,7 +1376,7 @@ protected constructor( // target change. val runFrameLoop by remember(this) { - computedStateOf { + derivedStateOf { this.targetState != currentState || isRunning || updateChildrenNeeded } } @@ -2124,8 +2123,8 @@ public inline fun Transition.animateValue( // recomposition for both the first and second frame of the animation. As a temporary // workaround, `derivedStateOf` is added here to avoid recomposing when the state value is the // same. - val targetValue = targetValueByState(remember(this) { computedStateOf { targetState } }.value) - val animationSpec = transitionSpec(remember(this) { computedStateOf { segment } }.value) + val targetValue = targetValueByState(remember(this) { derivedStateOf { targetState } }.value) + val animationSpec = transitionSpec(remember(this) { derivedStateOf { segment } }.value) return createTransitionAnimation(initialValue, targetValue, animationSpec, typeConverter, label) } diff --git a/compose/animation/animation-graphics/src/commonMain/kotlin/androidx/compose/animation/graphics/vector/Animator.kt b/compose/animation/animation-graphics/src/commonMain/kotlin/androidx/compose/animation/graphics/vector/Animator.kt index ae6a7e2a65ce7..fe574939c760b 100644 --- a/compose/animation/animation-graphics/src/commonMain/kotlin/androidx/compose/animation/graphics/vector/Animator.kt +++ b/compose/animation/animation-graphics/src/commonMain/kotlin/androidx/compose/animation/graphics/vector/Animator.kt @@ -31,7 +31,7 @@ import androidx.compose.animation.core.repeatable import androidx.compose.animation.core.tween import androidx.compose.runtime.Composable import androidx.compose.runtime.State -import androidx.compose.runtime.computedStateOf +import androidx.compose.runtime.derivedStateOf import androidx.compose.runtime.remember import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.SolidColor @@ -238,7 +238,7 @@ private class PathPropertyValues : PropertyValues>() { if (atEnd) overallDuration.toFloat() else 0f } @Suppress("UnrememberedMutableState") // b/279909531 - return computedStateOf { interpolate(timeState.value) } + return derivedStateOf { interpolate(timeState.value) } } private fun interpolate(timeMillis: Float): List { diff --git a/compose/animation/animation/integration-tests/animation-demos/src/main/java/androidx/compose/animation/demos/suspendfun/OffsetKeyframeSplinePlaygroundDemo.kt b/compose/animation/animation/integration-tests/animation-demos/src/main/java/androidx/compose/animation/demos/suspendfun/OffsetKeyframeSplinePlaygroundDemo.kt index 291e1dd2fbeff..ade461b155c1b 100644 --- a/compose/animation/animation/integration-tests/animation-demos/src/main/java/androidx/compose/animation/demos/suspendfun/OffsetKeyframeSplinePlaygroundDemo.kt +++ b/compose/animation/animation/integration-tests/animation-demos/src/main/java/androidx/compose/animation/demos/suspendfun/OffsetKeyframeSplinePlaygroundDemo.kt @@ -40,7 +40,7 @@ import androidx.compose.material.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.MutableState -import androidx.compose.runtime.computedStateOf +import androidx.compose.runtime.derivedStateOf import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableFloatStateOf import androidx.compose.runtime.mutableIntStateOf @@ -145,7 +145,7 @@ private class SplineKeyframesPlaygroundModel(private val scope: CoroutineScope) private val pointCount = 6 private val animatedOffset = Animatable(Offset.Zero, Offset.VectorConverter) private val anchors = mutableStateListOf() - private val anchorCount by computedStateOf { anchors.size } + private val anchorCount by derivedStateOf { anchors.size } // Note that this is not the duration per keyframe, just an arbitrary number so that the total // duration scales with number of anchors @@ -155,7 +155,7 @@ private class SplineKeyframesPlaygroundModel(private val scope: CoroutineScope) private val samplePoints = mutableListOf() private val sampleCount = 100 - val totalDuration by computedStateOf { anchors.size * durationPerAnchor.floatValue } + val totalDuration by derivedStateOf { anchors.size * durationPerAnchor.floatValue } private var isInit = false diff --git a/compose/animation/animation/src/commonMain/kotlin/androidx/compose/animation/AnimatedVisibility.kt b/compose/animation/animation/src/commonMain/kotlin/androidx/compose/animation/AnimatedVisibility.kt index d4551f3102258..62638d14d0898 100644 --- a/compose/animation/animation/src/commonMain/kotlin/androidx/compose/animation/AnimatedVisibility.kt +++ b/compose/animation/animation/src/commonMain/kotlin/androidx/compose/animation/AnimatedVisibility.kt @@ -34,7 +34,7 @@ import androidx.compose.foundation.layout.ColumnScope import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.RowScope import androidx.compose.runtime.Composable -import androidx.compose.runtime.computedStateOf +import androidx.compose.runtime.derivedStateOf import androidx.compose.runtime.getValue import androidx.compose.runtime.key import androidx.compose.runtime.mutableStateOf @@ -825,12 +825,15 @@ internal fun AnimatedEnterExitImpl( val shouldDisposeAfterExit by remember(childTransition, shouldDisposeBlock) { - computedStateOf { - childTransition.exitFinished && + derivedStateOf { + if (childTransition.exitFinished) { shouldDisposeBlock( childTransition.currentState, childTransition.targetState, ) + } else { + false + } } } diff --git a/compose/foundation/foundation/build.gradle b/compose/foundation/foundation/build.gradle index f08ba23eccea4..8950209f45b91 100644 --- a/compose/foundation/foundation/build.gradle +++ b/compose/foundation/foundation/build.gradle @@ -60,7 +60,7 @@ androidXMultiplatform { androidMain.dependencies { api("androidx.annotation:annotation:1.8.1") api("androidx.annotation:annotation-experimental:1.4.1") - implementation("androidx.emoji2:emoji2:1.7.0-rc01") + implementation("androidx.emoji2:emoji2:1.7.0") implementation("androidx.core:core:1.13.1") } @@ -73,7 +73,7 @@ androidXMultiplatform { implementation("androidx.activity:activity-compose:1.3.1") implementation("androidx.lifecycle:lifecycle-runtime:2.10.0") implementation("androidx.savedstate:savedstate:1.2.1") - implementation("androidx.emoji2:emoji2-bundled:1.7.0-rc01") + implementation("androidx.emoji2:emoji2-bundled:1.7.0") implementation(libs.testUiautomator) implementation(libs.testRules) diff --git a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/Scroll.kt b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/Scroll.kt index 1fe2e1af03315..a4fbf10c64b2a 100644 --- a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/Scroll.kt +++ b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/Scroll.kt @@ -31,7 +31,7 @@ import androidx.compose.foundation.interaction.MutableInteractionSource import androidx.compose.runtime.Composable import androidx.compose.runtime.Stable import androidx.compose.runtime.annotation.FrequentlyChangingValue -import androidx.compose.runtime.computedStateOf +import androidx.compose.runtime.derivedStateOf import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableIntStateOf import androidx.compose.runtime.mutableStateOf @@ -178,9 +178,9 @@ public class ScrollState(initial: Int) : ScrollableState { override val isScrollInProgress: Boolean get() = scrollableState.isScrollInProgress - override val canScrollForward: Boolean by computedStateOf { value < maxValue } + override val canScrollForward: Boolean by derivedStateOf { value < maxValue } - override val canScrollBackward: Boolean by computedStateOf { value > 0 } + override val canScrollBackward: Boolean by derivedStateOf { value > 0 } @get:Suppress("GetterSetterNames") override val lastScrolledForward: Boolean diff --git a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/LazyLayoutSemanticState.kt b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/LazyLayoutSemanticState.kt index 63232a1a704ef..7c49215089668 100644 --- a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/LazyLayoutSemanticState.kt +++ b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/LazyLayoutSemanticState.kt @@ -20,7 +20,7 @@ import androidx.compose.foundation.gestures.Orientation import androidx.compose.foundation.lazy.layout.LazyLayoutSemanticState import androidx.compose.foundation.lazy.layout.estimatedLazyMaxScrollOffset import androidx.compose.foundation.lazy.layout.estimatedLazyScrollOffset -import androidx.compose.runtime.computedStateOf +import androidx.compose.runtime.derivedStateOf import androidx.compose.runtime.getValue import androidx.compose.ui.semantics.CollectionInfo @@ -31,7 +31,7 @@ internal fun LazyLayoutSemanticState( object : LazyLayoutSemanticState { // The total number of items in the list, derived from layout info. - private val totalItemsCount by computedStateOf { state.layoutInfo.totalItemsCount } + private val totalItemsCount by derivedStateOf { state.layoutInfo.totalItemsCount } override val scrollOffset: Float get() = diff --git a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/pager/PagerState.kt b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/pager/PagerState.kt index 9603c575cc005..702c6f07452e8 100644 --- a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/pager/PagerState.kt +++ b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/pager/PagerState.kt @@ -46,7 +46,6 @@ import androidx.compose.foundation.lazy.layout.PrefetchScheduler import androidx.compose.runtime.Composable import androidx.compose.runtime.Stable import androidx.compose.runtime.annotation.FrequentlyChangingValue -import androidx.compose.runtime.computedStateOf import androidx.compose.runtime.derivedStateOf import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableIntStateOf @@ -57,6 +56,7 @@ import androidx.compose.runtime.saveable.listSaver import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.runtime.setValue import androidx.compose.runtime.snapshots.Snapshot +import androidx.compose.runtime.structuralEqualityPolicy import androidx.compose.ui.geometry.Offset import androidx.compose.ui.layout.AlignmentLine import androidx.compose.ui.layout.MeasureResult @@ -406,13 +406,14 @@ internal constructor( * * @sample androidx.compose.foundation.samples.ObservingStateChangesInPagerStateSample */ - public val settledPage: Int by computedStateOf { - if (isScrollInProgress) { - settledPageState - } else { - this.currentPage + public val settledPage: Int by + derivedStateOf(structuralEqualityPolicy()) { + if (isScrollInProgress) { + settledPageState + } else { + this.currentPage + } } - } /** * The page this [Pager] intends to settle to. During fling or animated scroll (from @@ -423,26 +424,27 @@ internal constructor( * * @sample androidx.compose.foundation.samples.ObservingStateChangesInPagerStateSample */ - public val targetPage: Int by computedStateOf { - val finalPage = - if (!isScrollInProgress) { - this.currentPage - } else if (programmaticScrollTargetPage != -1) { - programmaticScrollTargetPage - } else { - // act on scroll only - if (abs(this.currentPageOffsetFraction) >= abs(positionThresholdFraction)) { - if (lastScrolledForward) { - firstVisiblePage + 1 + public val targetPage: Int by + derivedStateOf(structuralEqualityPolicy()) { + val finalPage = + if (!isScrollInProgress) { + this.currentPage + } else if (programmaticScrollTargetPage != -1) { + programmaticScrollTargetPage + } else { + // act on scroll only + if (abs(this.currentPageOffsetFraction) >= abs(positionThresholdFraction)) { + if (lastScrolledForward) { + firstVisiblePage + 1 + } else { + firstVisiblePage + } } else { - firstVisiblePage + this.currentPage } - } else { - this.currentPage } - } - finalPage.coerceInPageRange() - } + finalPage.coerceInPageRange() + } /** * Indicates how far the current page is to the snapped position, this will vary from -0.5 (page diff --git a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/BasicTextField.kt b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/BasicTextField.kt index 7789e91130a08..8c25e68c8cd66 100644 --- a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/BasicTextField.kt +++ b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/BasicTextField.kt @@ -62,7 +62,6 @@ import androidx.compose.foundation.text.selection.rememberPlatformSelectionBehav import androidx.compose.runtime.Composable import androidx.compose.runtime.DisposableEffect import androidx.compose.runtime.SideEffect -import androidx.compose.runtime.computedStateOf import androidx.compose.runtime.derivedStateOf import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf @@ -438,7 +437,7 @@ internal fun BasicTextField( remember(interactionSource, windowInfo) { // Using derived state here to avoid recomposing when window focus is // obtained after the initial focus. - computedStateOf { isFocused && windowInfo.isWindowFocused } + derivedStateOf { isFocused && windowInfo.isWindowFocused } } rememberClipboardEventsHandler( diff --git a/compose/material3/adaptive/samples/build.gradle b/compose/material3/adaptive/samples/build.gradle index 2a8910e47aebd..747bc58c80db5 100644 --- a/compose/material3/adaptive/samples/build.gradle +++ b/compose/material3/adaptive/samples/build.gradle @@ -36,15 +36,15 @@ dependencies { compileOnly(project(":annotation:annotation-sampled")) - implementation("androidx.compose.foundation:foundation:1.6.0-rc01") - implementation("androidx.compose.foundation:foundation-layout:1.6.0-rc01") + implementation("androidx.compose.foundation:foundation:1.6.0") + implementation("androidx.compose.foundation:foundation-layout:1.6.0") implementation("androidx.compose.material:material-icons-core:1.6.8") implementation(project(":compose:material3:adaptive:adaptive-layout")) implementation(project(":compose:material3:adaptive:adaptive-navigation")) implementation(project(":compose:material3:adaptive:adaptive-navigation3")) implementation(project(":compose:material3:material3")) implementation(project(":compose:material3:material3-window-size-class")) - implementation("androidx.compose.ui:ui-util:1.6.0-rc01") + implementation("androidx.compose.ui:ui-util:1.6.0") implementation("androidx.compose.ui:ui-tooling:1.4.1") implementation("androidx.compose.ui:ui-tooling-preview:1.4.1") implementation("androidx.navigation:navigation-compose:2.7.7") diff --git a/compose/remote/remote-creation-compose/api/current.txt b/compose/remote/remote-creation-compose/api/current.txt index 9e52db95eeb60..8e05e997b2c0b 100644 --- a/compose/remote/remote-creation-compose/api/current.txt +++ b/compose/remote/remote-creation-compose/api/current.txt @@ -634,8 +634,11 @@ package androidx.compose.remote.creation.compose.modifier { public static final class RemoteModifier.Companion implements androidx.compose.remote.creation.compose.modifier.RemoteModifier { } - public final class RemoteScrollState { + @androidx.compose.runtime.Stable public final class RemoteScrollState { ctor @androidx.compose.runtime.annotation.RememberInComposition public RemoteScrollState(androidx.compose.remote.creation.compose.state.MutableRemoteFloat positionState, int notches); + ctor @androidx.compose.runtime.annotation.RememberInComposition public RemoteScrollState(float position, int notches); + ctor @androidx.compose.runtime.annotation.RememberInComposition public RemoteScrollState(optional int notches); + ctor @BytecodeOnly @androidx.compose.runtime.annotation.RememberInComposition public RemoteScrollState(int, int, kotlin.jvm.internal.DefaultConstructorMarker!); method @InaccessibleFromKotlin public int getNotches(); method @InaccessibleFromKotlin public androidx.compose.remote.creation.compose.state.MutableRemoteFloat getPositionState(); property public int notches; @@ -937,12 +940,13 @@ package androidx.compose.remote.creation.compose.state { } public final class MutableRemoteBoolean extends androidx.compose.remote.creation.compose.state.RemoteBoolean implements androidx.compose.remote.creation.compose.state.MutableRemoteState { + ctor @androidx.compose.runtime.annotation.RememberInComposition public MutableRemoteBoolean(boolean initialValue); property public Boolean? constantValueOrNull; field public static final androidx.compose.remote.creation.compose.state.MutableRemoteBoolean.Companion Companion; } public static final class MutableRemoteBoolean.Companion { - method public operator androidx.compose.remote.creation.compose.state.MutableRemoteBoolean invoke(boolean initialValue); + method @androidx.compose.runtime.annotation.RememberInComposition public operator androidx.compose.remote.creation.compose.state.MutableRemoteBoolean invoke(boolean initialValue); } public final class MutableRemoteEnum> extends androidx.compose.remote.creation.compose.state.RemoteEnum implements androidx.compose.remote.creation.compose.state.MutableRemoteState { @@ -952,55 +956,61 @@ package androidx.compose.remote.creation.compose.state { } public static final class MutableRemoteEnum.Companion { - method @KotlinOnly public inline operator > androidx.compose.remote.creation.compose.state.MutableRemoteEnum invoke(T initialValue); + method @KotlinOnly @androidx.compose.runtime.annotation.RememberInComposition public inline operator > androidx.compose.remote.creation.compose.state.MutableRemoteEnum invoke(T initialValue); } public final class MutableRemoteFloat extends androidx.compose.remote.creation.compose.state.RemoteFloat implements androidx.compose.remote.creation.compose.state.MutableRemoteState { + ctor @androidx.compose.runtime.annotation.RememberInComposition public MutableRemoteFloat(float initialValue); + ctor @androidx.compose.runtime.annotation.RememberInComposition public MutableRemoteFloat(kotlin.jvm.functions.Function1 value); method @InaccessibleFromKotlin public Float? getConstantValueOrNull(); property public Float? constantValueOrNull; field public static final androidx.compose.remote.creation.compose.state.MutableRemoteFloat.Companion Companion; } public static final class MutableRemoteFloat.Companion { - method public operator androidx.compose.remote.creation.compose.state.MutableRemoteFloat invoke(float initialValue); + method @androidx.compose.runtime.annotation.RememberInComposition public operator androidx.compose.remote.creation.compose.state.MutableRemoteFloat invoke(float initialValue); } public final class MutableRemoteImageBitmap extends androidx.compose.remote.creation.compose.state.RemoteImageBitmap implements androidx.compose.remote.creation.compose.state.MutableRemoteState { + ctor @androidx.compose.runtime.annotation.RememberInComposition public MutableRemoteImageBitmap(androidx.compose.ui.graphics.ImageBitmap initialValue); field public static final androidx.compose.remote.creation.compose.state.MutableRemoteImageBitmap.Companion Companion; } public static final class MutableRemoteImageBitmap.Companion { - method public operator androidx.compose.remote.creation.compose.state.MutableRemoteImageBitmap invoke(androidx.compose.ui.graphics.ImageBitmap initialValue); + method @androidx.compose.runtime.annotation.RememberInComposition public operator androidx.compose.remote.creation.compose.state.MutableRemoteImageBitmap invoke(androidx.compose.ui.graphics.ImageBitmap initialValue); } public final class MutableRemoteInt extends androidx.compose.remote.creation.compose.state.RemoteInt implements androidx.compose.remote.creation.compose.state.MutableRemoteState { + ctor @androidx.compose.runtime.annotation.RememberInComposition public MutableRemoteInt(int initialValue); field public static final androidx.compose.remote.creation.compose.state.MutableRemoteInt.Companion Companion; } public static final class MutableRemoteInt.Companion { - method public operator androidx.compose.remote.creation.compose.state.MutableRemoteInt invoke(int initialValue); + method @androidx.compose.runtime.annotation.RememberInComposition public operator androidx.compose.remote.creation.compose.state.MutableRemoteInt invoke(int initialValue); } public final class MutableRemoteLong extends androidx.compose.remote.creation.compose.state.RemoteLong implements androidx.compose.remote.creation.compose.state.MutableRemoteState { + ctor @androidx.compose.runtime.annotation.RememberInComposition public MutableRemoteLong(long initialValue); property public Long? constantValueOrNull; field public static final androidx.compose.remote.creation.compose.state.MutableRemoteLong.Companion Companion; } public static final class MutableRemoteLong.Companion { - method public operator androidx.compose.remote.creation.compose.state.MutableRemoteLong invoke(long initialValue); + method @androidx.compose.runtime.annotation.RememberInComposition public operator androidx.compose.remote.creation.compose.state.MutableRemoteLong invoke(long initialValue); } @androidx.compose.runtime.Stable public interface MutableRemoteState extends androidx.compose.remote.creation.compose.state.RemoteState { } public final class MutableRemoteString extends androidx.compose.remote.creation.compose.state.RemoteString implements androidx.compose.remote.creation.compose.state.MutableRemoteState { + ctor @androidx.compose.runtime.annotation.RememberInComposition public MutableRemoteString(String value); method @InaccessibleFromKotlin public String? getConstantValueOrNull(); property public String? constantValueOrNull; field public static final androidx.compose.remote.creation.compose.state.MutableRemoteString.Companion Companion; } public static final class MutableRemoteString.Companion { - method public operator androidx.compose.remote.creation.compose.state.MutableRemoteString invoke(String initialValue); + method @androidx.compose.runtime.annotation.RememberInComposition public operator androidx.compose.remote.creation.compose.state.MutableRemoteString invoke(String initialValue); } public final class RemoteAnimationKt { @@ -1098,6 +1108,7 @@ package androidx.compose.remote.creation.compose.state { } @androidx.compose.runtime.Stable public final class RemoteDp extends androidx.compose.remote.creation.compose.state.BaseRemoteState { + method public static androidx.compose.remote.creation.compose.state.RemoteDp createNamedRemoteDp(String name, optional androidx.compose.remote.creation.compose.state.RemoteState.Domain domain, kotlin.jvm.functions.Function0 value); method @BytecodeOnly public static androidx.compose.remote.creation.compose.state.RemoteDp createNamedRemoteDp-lG28NQ4(String, float, androidx.compose.remote.creation.compose.state.RemoteState.Domain); method public operator androidx.compose.remote.creation.compose.state.RemoteFloat div(androidx.compose.remote.creation.compose.state.RemoteDp other); method public operator androidx.compose.remote.creation.compose.state.RemoteDp div(androidx.compose.remote.creation.compose.state.RemoteFloat other); @@ -1125,7 +1136,9 @@ package androidx.compose.remote.creation.compose.state { } public static final class RemoteDp.Companion { + method public androidx.compose.remote.creation.compose.state.RemoteDp createNamedRemoteDp(String name, optional androidx.compose.remote.creation.compose.state.RemoteState.Domain domain, kotlin.jvm.functions.Function0 value); method @KotlinOnly public androidx.compose.remote.creation.compose.state.RemoteDp createNamedRemoteDp(String name, androidx.compose.ui.unit.Dp defaultValue, optional androidx.compose.remote.creation.compose.state.RemoteState.Domain domain); + method @BytecodeOnly public static androidx.compose.remote.creation.compose.state.RemoteDp! createNamedRemoteDp$default(androidx.compose.remote.creation.compose.state.RemoteDp.Companion!, String!, androidx.compose.remote.creation.compose.state.RemoteState.Domain!, kotlin.jvm.functions.Function0!, int, Object!); method @BytecodeOnly public androidx.compose.remote.creation.compose.state.RemoteDp createNamedRemoteDp-lG28NQ4(String, float, androidx.compose.remote.creation.compose.state.RemoteState.Domain); method @BytecodeOnly public static androidx.compose.remote.creation.compose.state.RemoteDp! createNamedRemoteDp-lG28NQ4$default(androidx.compose.remote.creation.compose.state.RemoteDp.Companion!, String!, float, androidx.compose.remote.creation.compose.state.RemoteState.Domain!, int, Object!); method @KotlinOnly public operator androidx.compose.remote.creation.compose.state.RemoteDp invoke(androidx.compose.ui.unit.Dp value); @@ -1270,7 +1283,9 @@ package androidx.compose.remote.creation.compose.state { } public abstract class RemoteImageBitmap extends androidx.compose.remote.creation.compose.state.BaseRemoteState { + method public static final androidx.compose.remote.creation.compose.state.RemoteImageBitmap createNamedRemoteImageBitmap(String name, optional androidx.compose.remote.creation.compose.state.RemoteState.Domain domain, kotlin.jvm.functions.Function0 value); method public static final androidx.compose.remote.creation.compose.state.RemoteImageBitmap createNamedRemoteImageBitmap(String name, androidx.compose.ui.graphics.ImageBitmap defaultValue, optional androidx.compose.remote.creation.compose.state.RemoteState.Domain domain); + method public static final androidx.compose.remote.creation.compose.state.RemoteImageBitmap createNamedRemoteImageBitmap(String name, String url, optional androidx.compose.remote.creation.compose.state.RemoteState.Domain domain); method @InaccessibleFromKotlin public androidx.compose.ui.graphics.ImageBitmap? getConstantValueOrNull(); method @InaccessibleFromKotlin public final androidx.compose.remote.creation.compose.state.RemoteFloat getHeight(); method @InaccessibleFromKotlin public final androidx.compose.remote.creation.compose.state.RemoteFloat getWidth(); @@ -1281,8 +1296,12 @@ package androidx.compose.remote.creation.compose.state { } public static final class RemoteImageBitmap.Companion { + method public androidx.compose.remote.creation.compose.state.RemoteImageBitmap createNamedRemoteImageBitmap(String name, optional androidx.compose.remote.creation.compose.state.RemoteState.Domain domain, kotlin.jvm.functions.Function0 value); method public androidx.compose.remote.creation.compose.state.RemoteImageBitmap createNamedRemoteImageBitmap(String name, androidx.compose.ui.graphics.ImageBitmap defaultValue, optional androidx.compose.remote.creation.compose.state.RemoteState.Domain domain); + method public androidx.compose.remote.creation.compose.state.RemoteImageBitmap createNamedRemoteImageBitmap(String name, String url, optional androidx.compose.remote.creation.compose.state.RemoteState.Domain domain); + method @BytecodeOnly public static androidx.compose.remote.creation.compose.state.RemoteImageBitmap! createNamedRemoteImageBitmap$default(androidx.compose.remote.creation.compose.state.RemoteImageBitmap.Companion!, String!, androidx.compose.remote.creation.compose.state.RemoteState.Domain!, kotlin.jvm.functions.Function0!, int, Object!); method @BytecodeOnly public static androidx.compose.remote.creation.compose.state.RemoteImageBitmap! createNamedRemoteImageBitmap$default(androidx.compose.remote.creation.compose.state.RemoteImageBitmap.Companion!, String!, androidx.compose.ui.graphics.ImageBitmap!, androidx.compose.remote.creation.compose.state.RemoteState.Domain!, int, Object!); + method @BytecodeOnly public static androidx.compose.remote.creation.compose.state.RemoteImageBitmap! createNamedRemoteImageBitmap$default(androidx.compose.remote.creation.compose.state.RemoteImageBitmap.Companion!, String!, String!, androidx.compose.remote.creation.compose.state.RemoteState.Domain!, int, Object!); method public operator androidx.compose.remote.creation.compose.state.RemoteImageBitmap invoke(androidx.compose.ui.graphics.ImageBitmap value); method public operator androidx.compose.remote.creation.compose.state.RemoteImageBitmap invoke(String url); } diff --git a/compose/remote/remote-creation-compose/api/restricted_current.txt b/compose/remote/remote-creation-compose/api/restricted_current.txt index 9e52db95eeb60..8e05e997b2c0b 100644 --- a/compose/remote/remote-creation-compose/api/restricted_current.txt +++ b/compose/remote/remote-creation-compose/api/restricted_current.txt @@ -634,8 +634,11 @@ package androidx.compose.remote.creation.compose.modifier { public static final class RemoteModifier.Companion implements androidx.compose.remote.creation.compose.modifier.RemoteModifier { } - public final class RemoteScrollState { + @androidx.compose.runtime.Stable public final class RemoteScrollState { ctor @androidx.compose.runtime.annotation.RememberInComposition public RemoteScrollState(androidx.compose.remote.creation.compose.state.MutableRemoteFloat positionState, int notches); + ctor @androidx.compose.runtime.annotation.RememberInComposition public RemoteScrollState(float position, int notches); + ctor @androidx.compose.runtime.annotation.RememberInComposition public RemoteScrollState(optional int notches); + ctor @BytecodeOnly @androidx.compose.runtime.annotation.RememberInComposition public RemoteScrollState(int, int, kotlin.jvm.internal.DefaultConstructorMarker!); method @InaccessibleFromKotlin public int getNotches(); method @InaccessibleFromKotlin public androidx.compose.remote.creation.compose.state.MutableRemoteFloat getPositionState(); property public int notches; @@ -937,12 +940,13 @@ package androidx.compose.remote.creation.compose.state { } public final class MutableRemoteBoolean extends androidx.compose.remote.creation.compose.state.RemoteBoolean implements androidx.compose.remote.creation.compose.state.MutableRemoteState { + ctor @androidx.compose.runtime.annotation.RememberInComposition public MutableRemoteBoolean(boolean initialValue); property public Boolean? constantValueOrNull; field public static final androidx.compose.remote.creation.compose.state.MutableRemoteBoolean.Companion Companion; } public static final class MutableRemoteBoolean.Companion { - method public operator androidx.compose.remote.creation.compose.state.MutableRemoteBoolean invoke(boolean initialValue); + method @androidx.compose.runtime.annotation.RememberInComposition public operator androidx.compose.remote.creation.compose.state.MutableRemoteBoolean invoke(boolean initialValue); } public final class MutableRemoteEnum> extends androidx.compose.remote.creation.compose.state.RemoteEnum implements androidx.compose.remote.creation.compose.state.MutableRemoteState { @@ -952,55 +956,61 @@ package androidx.compose.remote.creation.compose.state { } public static final class MutableRemoteEnum.Companion { - method @KotlinOnly public inline operator > androidx.compose.remote.creation.compose.state.MutableRemoteEnum invoke(T initialValue); + method @KotlinOnly @androidx.compose.runtime.annotation.RememberInComposition public inline operator > androidx.compose.remote.creation.compose.state.MutableRemoteEnum invoke(T initialValue); } public final class MutableRemoteFloat extends androidx.compose.remote.creation.compose.state.RemoteFloat implements androidx.compose.remote.creation.compose.state.MutableRemoteState { + ctor @androidx.compose.runtime.annotation.RememberInComposition public MutableRemoteFloat(float initialValue); + ctor @androidx.compose.runtime.annotation.RememberInComposition public MutableRemoteFloat(kotlin.jvm.functions.Function1 value); method @InaccessibleFromKotlin public Float? getConstantValueOrNull(); property public Float? constantValueOrNull; field public static final androidx.compose.remote.creation.compose.state.MutableRemoteFloat.Companion Companion; } public static final class MutableRemoteFloat.Companion { - method public operator androidx.compose.remote.creation.compose.state.MutableRemoteFloat invoke(float initialValue); + method @androidx.compose.runtime.annotation.RememberInComposition public operator androidx.compose.remote.creation.compose.state.MutableRemoteFloat invoke(float initialValue); } public final class MutableRemoteImageBitmap extends androidx.compose.remote.creation.compose.state.RemoteImageBitmap implements androidx.compose.remote.creation.compose.state.MutableRemoteState { + ctor @androidx.compose.runtime.annotation.RememberInComposition public MutableRemoteImageBitmap(androidx.compose.ui.graphics.ImageBitmap initialValue); field public static final androidx.compose.remote.creation.compose.state.MutableRemoteImageBitmap.Companion Companion; } public static final class MutableRemoteImageBitmap.Companion { - method public operator androidx.compose.remote.creation.compose.state.MutableRemoteImageBitmap invoke(androidx.compose.ui.graphics.ImageBitmap initialValue); + method @androidx.compose.runtime.annotation.RememberInComposition public operator androidx.compose.remote.creation.compose.state.MutableRemoteImageBitmap invoke(androidx.compose.ui.graphics.ImageBitmap initialValue); } public final class MutableRemoteInt extends androidx.compose.remote.creation.compose.state.RemoteInt implements androidx.compose.remote.creation.compose.state.MutableRemoteState { + ctor @androidx.compose.runtime.annotation.RememberInComposition public MutableRemoteInt(int initialValue); field public static final androidx.compose.remote.creation.compose.state.MutableRemoteInt.Companion Companion; } public static final class MutableRemoteInt.Companion { - method public operator androidx.compose.remote.creation.compose.state.MutableRemoteInt invoke(int initialValue); + method @androidx.compose.runtime.annotation.RememberInComposition public operator androidx.compose.remote.creation.compose.state.MutableRemoteInt invoke(int initialValue); } public final class MutableRemoteLong extends androidx.compose.remote.creation.compose.state.RemoteLong implements androidx.compose.remote.creation.compose.state.MutableRemoteState { + ctor @androidx.compose.runtime.annotation.RememberInComposition public MutableRemoteLong(long initialValue); property public Long? constantValueOrNull; field public static final androidx.compose.remote.creation.compose.state.MutableRemoteLong.Companion Companion; } public static final class MutableRemoteLong.Companion { - method public operator androidx.compose.remote.creation.compose.state.MutableRemoteLong invoke(long initialValue); + method @androidx.compose.runtime.annotation.RememberInComposition public operator androidx.compose.remote.creation.compose.state.MutableRemoteLong invoke(long initialValue); } @androidx.compose.runtime.Stable public interface MutableRemoteState extends androidx.compose.remote.creation.compose.state.RemoteState { } public final class MutableRemoteString extends androidx.compose.remote.creation.compose.state.RemoteString implements androidx.compose.remote.creation.compose.state.MutableRemoteState { + ctor @androidx.compose.runtime.annotation.RememberInComposition public MutableRemoteString(String value); method @InaccessibleFromKotlin public String? getConstantValueOrNull(); property public String? constantValueOrNull; field public static final androidx.compose.remote.creation.compose.state.MutableRemoteString.Companion Companion; } public static final class MutableRemoteString.Companion { - method public operator androidx.compose.remote.creation.compose.state.MutableRemoteString invoke(String initialValue); + method @androidx.compose.runtime.annotation.RememberInComposition public operator androidx.compose.remote.creation.compose.state.MutableRemoteString invoke(String initialValue); } public final class RemoteAnimationKt { @@ -1098,6 +1108,7 @@ package androidx.compose.remote.creation.compose.state { } @androidx.compose.runtime.Stable public final class RemoteDp extends androidx.compose.remote.creation.compose.state.BaseRemoteState { + method public static androidx.compose.remote.creation.compose.state.RemoteDp createNamedRemoteDp(String name, optional androidx.compose.remote.creation.compose.state.RemoteState.Domain domain, kotlin.jvm.functions.Function0 value); method @BytecodeOnly public static androidx.compose.remote.creation.compose.state.RemoteDp createNamedRemoteDp-lG28NQ4(String, float, androidx.compose.remote.creation.compose.state.RemoteState.Domain); method public operator androidx.compose.remote.creation.compose.state.RemoteFloat div(androidx.compose.remote.creation.compose.state.RemoteDp other); method public operator androidx.compose.remote.creation.compose.state.RemoteDp div(androidx.compose.remote.creation.compose.state.RemoteFloat other); @@ -1125,7 +1136,9 @@ package androidx.compose.remote.creation.compose.state { } public static final class RemoteDp.Companion { + method public androidx.compose.remote.creation.compose.state.RemoteDp createNamedRemoteDp(String name, optional androidx.compose.remote.creation.compose.state.RemoteState.Domain domain, kotlin.jvm.functions.Function0 value); method @KotlinOnly public androidx.compose.remote.creation.compose.state.RemoteDp createNamedRemoteDp(String name, androidx.compose.ui.unit.Dp defaultValue, optional androidx.compose.remote.creation.compose.state.RemoteState.Domain domain); + method @BytecodeOnly public static androidx.compose.remote.creation.compose.state.RemoteDp! createNamedRemoteDp$default(androidx.compose.remote.creation.compose.state.RemoteDp.Companion!, String!, androidx.compose.remote.creation.compose.state.RemoteState.Domain!, kotlin.jvm.functions.Function0!, int, Object!); method @BytecodeOnly public androidx.compose.remote.creation.compose.state.RemoteDp createNamedRemoteDp-lG28NQ4(String, float, androidx.compose.remote.creation.compose.state.RemoteState.Domain); method @BytecodeOnly public static androidx.compose.remote.creation.compose.state.RemoteDp! createNamedRemoteDp-lG28NQ4$default(androidx.compose.remote.creation.compose.state.RemoteDp.Companion!, String!, float, androidx.compose.remote.creation.compose.state.RemoteState.Domain!, int, Object!); method @KotlinOnly public operator androidx.compose.remote.creation.compose.state.RemoteDp invoke(androidx.compose.ui.unit.Dp value); @@ -1270,7 +1283,9 @@ package androidx.compose.remote.creation.compose.state { } public abstract class RemoteImageBitmap extends androidx.compose.remote.creation.compose.state.BaseRemoteState { + method public static final androidx.compose.remote.creation.compose.state.RemoteImageBitmap createNamedRemoteImageBitmap(String name, optional androidx.compose.remote.creation.compose.state.RemoteState.Domain domain, kotlin.jvm.functions.Function0 value); method public static final androidx.compose.remote.creation.compose.state.RemoteImageBitmap createNamedRemoteImageBitmap(String name, androidx.compose.ui.graphics.ImageBitmap defaultValue, optional androidx.compose.remote.creation.compose.state.RemoteState.Domain domain); + method public static final androidx.compose.remote.creation.compose.state.RemoteImageBitmap createNamedRemoteImageBitmap(String name, String url, optional androidx.compose.remote.creation.compose.state.RemoteState.Domain domain); method @InaccessibleFromKotlin public androidx.compose.ui.graphics.ImageBitmap? getConstantValueOrNull(); method @InaccessibleFromKotlin public final androidx.compose.remote.creation.compose.state.RemoteFloat getHeight(); method @InaccessibleFromKotlin public final androidx.compose.remote.creation.compose.state.RemoteFloat getWidth(); @@ -1281,8 +1296,12 @@ package androidx.compose.remote.creation.compose.state { } public static final class RemoteImageBitmap.Companion { + method public androidx.compose.remote.creation.compose.state.RemoteImageBitmap createNamedRemoteImageBitmap(String name, optional androidx.compose.remote.creation.compose.state.RemoteState.Domain domain, kotlin.jvm.functions.Function0 value); method public androidx.compose.remote.creation.compose.state.RemoteImageBitmap createNamedRemoteImageBitmap(String name, androidx.compose.ui.graphics.ImageBitmap defaultValue, optional androidx.compose.remote.creation.compose.state.RemoteState.Domain domain); + method public androidx.compose.remote.creation.compose.state.RemoteImageBitmap createNamedRemoteImageBitmap(String name, String url, optional androidx.compose.remote.creation.compose.state.RemoteState.Domain domain); + method @BytecodeOnly public static androidx.compose.remote.creation.compose.state.RemoteImageBitmap! createNamedRemoteImageBitmap$default(androidx.compose.remote.creation.compose.state.RemoteImageBitmap.Companion!, String!, androidx.compose.remote.creation.compose.state.RemoteState.Domain!, kotlin.jvm.functions.Function0!, int, Object!); method @BytecodeOnly public static androidx.compose.remote.creation.compose.state.RemoteImageBitmap! createNamedRemoteImageBitmap$default(androidx.compose.remote.creation.compose.state.RemoteImageBitmap.Companion!, String!, androidx.compose.ui.graphics.ImageBitmap!, androidx.compose.remote.creation.compose.state.RemoteState.Domain!, int, Object!); + method @BytecodeOnly public static androidx.compose.remote.creation.compose.state.RemoteImageBitmap! createNamedRemoteImageBitmap$default(androidx.compose.remote.creation.compose.state.RemoteImageBitmap.Companion!, String!, String!, androidx.compose.remote.creation.compose.state.RemoteState.Domain!, int, Object!); method public operator androidx.compose.remote.creation.compose.state.RemoteImageBitmap invoke(androidx.compose.ui.graphics.ImageBitmap value); method public operator androidx.compose.remote.creation.compose.state.RemoteImageBitmap invoke(String url); } diff --git a/compose/remote/remote-creation-compose/build.gradle b/compose/remote/remote-creation-compose/build.gradle index ee1c92732c60a..43eaf7c5a35a5 100644 --- a/compose/remote/remote-creation-compose/build.gradle +++ b/compose/remote/remote-creation-compose/build.gradle @@ -52,7 +52,7 @@ dependencies { api("androidx.compose.ui:ui:1.11.0") implementation(project(":compose:remote:remote-core")) implementation(project(":compose:remote:remote-creation")) - implementation("androidx.graphics:graphics-path:1.1.0-rc01") + implementation("androidx.graphics:graphics-path:1.1.0") implementation("androidx.compose.ui:ui-text:1.11.0") implementation("androidx.core:core-ktx:1.16.0") implementation("androidx.compose.foundation:foundation:1.11.0") diff --git a/compose/remote/remote-creation-compose/src/main/java/androidx/compose/remote/creation/compose/modifier/ScrollModifier.kt b/compose/remote/remote-creation-compose/src/main/java/androidx/compose/remote/creation/compose/modifier/ScrollModifier.kt index 7214c2aa63cab..9e20e659280fd 100644 --- a/compose/remote/remote-creation-compose/src/main/java/androidx/compose/remote/creation/compose/modifier/ScrollModifier.kt +++ b/compose/remote/remote-creation-compose/src/main/java/androidx/compose/remote/creation/compose/modifier/ScrollModifier.kt @@ -16,12 +16,12 @@ package androidx.compose.remote.creation.compose.modifier -import androidx.annotation.RestrictTo import androidx.compose.remote.creation.compose.state.MutableRemoteFloat import androidx.compose.remote.creation.compose.state.RemoteStateScope import androidx.compose.remote.creation.modifiers.RecordingModifier import androidx.compose.remote.creation.modifiers.ScrollModifier as CoreScrollModifier import androidx.compose.runtime.Composable +import androidx.compose.runtime.Stable import androidx.compose.runtime.annotation.RememberInComposition import androidx.compose.runtime.remember @@ -37,15 +37,13 @@ import androidx.compose.runtime.remember * greater than 0, the scroll position will snap to the nearest notch when the scroll gesture * ends. If 0, scrolling is continuous. */ +@Stable public class RemoteScrollState @RememberInComposition constructor(public val positionState: MutableRemoteFloat, public val notches: Int) { - internal constructor( - position: Float, - notches: Int, - ) : this(MutableRemoteFloat(position), notches) + @RememberInComposition + public constructor(position: Float, notches: Int) : this(MutableRemoteFloat(position), notches) - @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) @RememberInComposition public constructor(notches: Int = 0) : this(MutableRemoteFloat(), notches) diff --git a/compose/remote/remote-creation-compose/src/main/java/androidx/compose/remote/creation/compose/state/RemoteBoolean.kt b/compose/remote/remote-creation-compose/src/main/java/androidx/compose/remote/creation/compose/state/RemoteBoolean.kt index 0fccad7fa6f5a..a7e968483ac0b 100644 --- a/compose/remote/remote-creation-compose/src/main/java/androidx/compose/remote/creation/compose/state/RemoteBoolean.kt +++ b/compose/remote/remote-creation-compose/src/main/java/androidx/compose/remote/creation/compose/state/RemoteBoolean.kt @@ -477,7 +477,6 @@ public class MutableRemoteBoolean internal constructor(remoteInt: MutableRemoteInt) : RemoteBoolean(remoteInt), MutableRemoteState { - @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) @RememberInComposition public constructor(initialValue: Boolean) : this(MutableRemoteInt(if (initialValue) 1 else 0)) @@ -514,6 +513,7 @@ internal constructor(remoteInt: MutableRemoteInt) : * @param initialValue The initial value for this mutable boolean. * @return A [MutableRemoteBoolean] instance. */ + @RememberInComposition public operator fun invoke(initialValue: Boolean): MutableRemoteBoolean { val initInt: Int = if (initialValue) 1 else 0 return MutableRemoteBoolean(MutableRemoteInt(initInt)) diff --git a/compose/remote/remote-creation-compose/src/main/java/androidx/compose/remote/creation/compose/state/RemoteDp.kt b/compose/remote/remote-creation-compose/src/main/java/androidx/compose/remote/creation/compose/state/RemoteDp.kt index 72bbaa0bd15e9..611248e0e21a4 100644 --- a/compose/remote/remote-creation-compose/src/main/java/androidx/compose/remote/creation/compose/state/RemoteDp.kt +++ b/compose/remote/remote-creation-compose/src/main/java/androidx/compose/remote/creation/compose/state/RemoteDp.kt @@ -204,7 +204,6 @@ internal constructor( ) } - @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) @JvmStatic public fun createNamedRemoteDp( name: String, diff --git a/compose/remote/remote-creation-compose/src/main/java/androidx/compose/remote/creation/compose/state/RemoteEnum.kt b/compose/remote/remote-creation-compose/src/main/java/androidx/compose/remote/creation/compose/state/RemoteEnum.kt index ebd5638f44352..6a1e60955ccbe 100644 --- a/compose/remote/remote-creation-compose/src/main/java/androidx/compose/remote/creation/compose/state/RemoteEnum.kt +++ b/compose/remote/remote-creation-compose/src/main/java/androidx/compose/remote/creation/compose/state/RemoteEnum.kt @@ -21,6 +21,7 @@ import androidx.compose.remote.creation.compose.capture.RemoteComposeCreationSta import androidx.compose.remote.creation.compose.layout.RemoteComposable import androidx.compose.remote.creation.compose.state.RemoteInt.Companion.createNamedRemoteInt import androidx.compose.runtime.Composable +import androidx.compose.runtime.annotation.RememberInComposition import androidx.compose.runtime.remember import androidx.compose.ui.util.fastFold import androidx.compose.ui.util.fastForEach @@ -221,6 +222,7 @@ public constructor(internal val intValue: RemoteInt, internal val enumEntries: E */ public class MutableRemoteEnum> @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) +@RememberInComposition public constructor(public val remoteInt: MutableRemoteInt, enumEntries: EnumEntries) : RemoteEnum(remoteInt, enumEntries), MutableRemoteState { @@ -250,10 +252,11 @@ public constructor(public val remoteInt: MutableRemoteInt, enumEntries: EnumEntr * @param initialValue The initial value for this mutable enum. * @return A [MutableRemoteEnum] instance. */ + @RememberInComposition public inline operator fun > invoke( initialValue: T ): MutableRemoteEnum = - MutableRemoteEnum(MutableRemoteInt.invoke(initialValue.ordinal), enumEntries()) + MutableRemoteEnum(MutableRemoteInt(initialValue.ordinal), enumEntries()) } } diff --git a/compose/remote/remote-creation-compose/src/main/java/androidx/compose/remote/creation/compose/state/RemoteFloat.kt b/compose/remote/remote-creation-compose/src/main/java/androidx/compose/remote/creation/compose/state/RemoteFloat.kt index ac85727141e57..47efcc70599a7 100644 --- a/compose/remote/remote-creation-compose/src/main/java/androidx/compose/remote/creation/compose/state/RemoteFloat.kt +++ b/compose/remote/remote-creation-compose/src/main/java/androidx/compose/remote/creation/compose/state/RemoteFloat.kt @@ -1562,7 +1562,6 @@ internal constructor( * * @param initialValue The initial [Float] value. */ - @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) @RememberInComposition public constructor( initialValue: Float @@ -1576,7 +1575,6 @@ internal constructor( * * @param value A lambda evaluated within [RemoteFloatContext] that provides the initial value. */ - @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) @RememberInComposition public constructor( value: RemoteFloatContext.() -> RemoteFloat @@ -1617,6 +1615,7 @@ internal constructor( * @param initialValue The initial value for the state. * @return A new [MutableRemoteFloat] instance. */ + @RememberInComposition public operator fun invoke(initialValue: Float): MutableRemoteFloat { return MutableRemoteFloat(cacheKey = RemoteStateInstanceKey()) { creationState -> creationState.document.floatExpression(initialValue) @@ -1666,22 +1665,24 @@ internal constructor( }, ) - /** - * Creates a [RemoteFloatExpression] from a lambda returning a [FloatArray]. - * - * @param value A lambda returning the raw [FloatArray] representing the expression. - */ - @RememberInComposition - public constructor( - value: () -> FloatArray - ) : this( - constantValueOrNull = null, - cacheKey = RemoteStateInstanceKey(), - arrayProvider = { creationState -> - val floatArrayId = creationState.document.addFloatArray(value()) - floatArrayOf(floatArrayId) - }, - ) + public companion object { + /** + * Creates a [RemoteFloatExpression] from a lambda returning a [FloatArray]. + * + * @param value A lambda returning the raw [FloatArray] representing the expression. + */ + @RememberInComposition + public fun fromFloatArray(value: () -> FloatArray): RemoteFloatExpression { + return RemoteFloatExpression( + constantValueOrNull = null, + cacheKey = RemoteStateInstanceKey(), + arrayProvider = { creationState -> + val floatArrayId = creationState.document.addFloatArray(value()) + floatArrayOf(floatArrayId) + }, + ) + } + } init { if (constantValueOrNull?.isNaN() == true) { @@ -2037,7 +2038,7 @@ public fun toArray(a: RemoteFloat, creationState: RemoteComposeCreationState): F @Composable @RemoteComposable public fun rememberRemoteFloatArray(value: () -> FloatArray): RemoteFloat { - return remember { RemoteFloatExpression(value) } + return remember { RemoteFloatExpression.fromFloatArray(value) } } /** diff --git a/compose/remote/remote-creation-compose/src/main/java/androidx/compose/remote/creation/compose/state/RemoteImageBitmap.kt b/compose/remote/remote-creation-compose/src/main/java/androidx/compose/remote/creation/compose/state/RemoteImageBitmap.kt index 9f3f73f6bf2f3..47a53c0db9714 100644 --- a/compose/remote/remote-creation-compose/src/main/java/androidx/compose/remote/creation/compose/state/RemoteImageBitmap.kt +++ b/compose/remote/remote-creation-compose/src/main/java/androidx/compose/remote/creation/compose/state/RemoteImageBitmap.kt @@ -142,7 +142,6 @@ internal constructor( ) } - @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) @JvmStatic public fun createNamedRemoteImageBitmap( name: String, @@ -161,7 +160,6 @@ internal constructor( } } - @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) @JvmStatic public fun createNamedRemoteImageBitmap( name: String, @@ -213,7 +211,6 @@ internal constructor( * * @param initialValue The initial [ImageBitmap] value. */ - @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) @RememberInComposition public constructor( initialValue: ImageBitmap @@ -236,6 +233,7 @@ internal constructor( * @param initialValue The initial value for the state. * @return A new [MutableRemoteImageBitmap] instance. */ + @RememberInComposition public operator fun invoke(initialValue: ImageBitmap): MutableRemoteImageBitmap { return MutableRemoteImageBitmap(initialValue) } diff --git a/compose/remote/remote-creation-compose/src/main/java/androidx/compose/remote/creation/compose/state/RemoteInt.kt b/compose/remote/remote-creation-compose/src/main/java/androidx/compose/remote/creation/compose/state/RemoteInt.kt index 3a5ea73e3302e..555a219b3aed3 100644 --- a/compose/remote/remote-creation-compose/src/main/java/androidx/compose/remote/creation/compose/state/RemoteInt.kt +++ b/compose/remote/remote-creation-compose/src/main/java/androidx/compose/remote/creation/compose/state/RemoteInt.kt @@ -1010,7 +1010,6 @@ internal constructor( * * @param initialValue The initial [Int] value. */ - @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) @RememberInComposition public constructor( initialValue: Int @@ -1027,6 +1026,7 @@ internal constructor( * @param initialValue The initial value for the state. * @return A new [MutableRemoteInt] instance. */ + @RememberInComposition public operator fun invoke(initialValue: Int): MutableRemoteInt { return MutableRemoteInt(initialValue) } diff --git a/compose/remote/remote-creation-compose/src/main/java/androidx/compose/remote/creation/compose/state/RemoteLong.kt b/compose/remote/remote-creation-compose/src/main/java/androidx/compose/remote/creation/compose/state/RemoteLong.kt index 4cea6a3386d18..275426ea5512e 100644 --- a/compose/remote/remote-creation-compose/src/main/java/androidx/compose/remote/creation/compose/state/RemoteLong.kt +++ b/compose/remote/remote-creation-compose/src/main/java/androidx/compose/remote/creation/compose/state/RemoteLong.kt @@ -238,7 +238,6 @@ internal constructor( * * @param initialValue The initial [Long] value. */ - @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) @RememberInComposition public constructor( initialValue: Long @@ -263,6 +262,7 @@ internal constructor( * @param initialValue The initial value for the state. * @return A new [MutableRemoteLong] instance. */ + @RememberInComposition public operator fun invoke(initialValue: Long): MutableRemoteLong { return MutableRemoteLong(initialValue) } diff --git a/compose/remote/remote-creation-compose/src/main/java/androidx/compose/remote/creation/compose/state/RemoteString.kt b/compose/remote/remote-creation-compose/src/main/java/androidx/compose/remote/creation/compose/state/RemoteString.kt index d4da23cb2fb76..584cbf8a7ed1b 100644 --- a/compose/remote/remote-creation-compose/src/main/java/androidx/compose/remote/creation/compose/state/RemoteString.kt +++ b/compose/remote/remote-creation-compose/src/main/java/androidx/compose/remote/creation/compose/state/RemoteString.kt @@ -1064,7 +1064,6 @@ internal constructor( * * @param value The initial [String] value. */ - @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) @RememberInComposition public constructor( value: String @@ -1098,6 +1097,7 @@ internal constructor( * @param initialValue The initial value for the state. * @return A new [MutableRemoteString] instance. */ + @RememberInComposition public operator fun invoke(initialValue: String): MutableRemoteString = MutableRemoteString(initialValue) diff --git a/compose/remote/remote-player-compose/src/main/java/androidx/compose/remote/player/compose/embedded/CoreDataAccessors.kt b/compose/remote/remote-player-compose/src/main/java/androidx/compose/remote/player/compose/embedded/CoreDataAccessors.kt index 58d5d1403807e..4befdd019c303 100644 --- a/compose/remote/remote-player-compose/src/main/java/androidx/compose/remote/player/compose/embedded/CoreDataAccessors.kt +++ b/compose/remote/remote-player-compose/src/main/java/androidx/compose/remote/player/compose/embedded/CoreDataAccessors.kt @@ -57,6 +57,7 @@ import androidx.compose.remote.core.operations.layout.Container import androidx.compose.remote.core.operations.layout.LayoutComponent import androidx.compose.remote.core.operations.layout.LayoutComponentContent import androidx.compose.remote.core.operations.layout.LoopOperation +import androidx.compose.remote.core.operations.layout.MultiClickModifier import androidx.compose.remote.core.operations.layout.animation.AnimationSpec import androidx.compose.remote.core.operations.layout.managers.ColumnLayout import androidx.compose.remote.core.operations.layout.managers.CoreText @@ -1455,3 +1456,10 @@ internal fun paddingRawValues(op: PaddingModifierOperation): FloatArray { paddingBottomField.getFloat(op), ) } + +// 14. MultiClickModifier clickType Reflection +private val multiClickTypeField = + MultiClickModifier::class.java.getDeclaredField("mClickType").apply { isAccessible = true } + +internal val MultiClickModifier.clickTypeReflection: Int + get() = multiClickTypeField.getInt(this) diff --git a/compose/remote/remote-player-compose/src/main/java/androidx/compose/remote/player/compose/embedded/RcPlayer.kt b/compose/remote/remote-player-compose/src/main/java/androidx/compose/remote/player/compose/embedded/RcPlayer.kt index 3de7eae1fe34b..fe1356adc5ca6 100644 --- a/compose/remote/remote-player-compose/src/main/java/androidx/compose/remote/player/compose/embedded/RcPlayer.kt +++ b/compose/remote/remote-player-compose/src/main/java/androidx/compose/remote/player/compose/embedded/RcPlayer.kt @@ -27,6 +27,7 @@ package androidx.compose.remote.player.compose.embedded import android.annotation.SuppressLint import android.app.PendingIntent +import android.util.Log import androidx.annotation.RestrictTo import androidx.collection.IntObjectMap import androidx.collection.emptyIntObjectMap @@ -165,16 +166,12 @@ public fun RcPlayer( val resolvedTheme = remember(theme, isDark) { resolveThemeMode(theme, isDark) } val androidContext = LocalContext.current - val preprocessed = - (state as? RcPlayerStateImpl)?.preprocessed - ?: remember(document) { preprocessDocument(document) } + val preprocessed = state.preprocessed val density = LocalDensity.current val remoteContext = remember(typefaceResolver, preprocessed, state) { - val ctx = - (state as? RcPlayerStateImpl)?.remoteContext - ?: initializePlayerRemoteContext(document, clock, preprocessed) + val ctx = state.remoteContext val resolvedResolver = typefaceResolver ?: EmbeddedPlayerTypefaceResolver ctx.setTypefaceResolver(resolvedResolver) ctx.useChoreographer = true @@ -213,9 +210,7 @@ public fun RcPlayer( // clocks // (FloatAnimation via Animatable, StateLayout via AnimatedContent) initialize t=0 once and // settle immediately to idle without a background loop. - val currentTimeMillisState = - (state as? RcPlayerStateImpl)?.currentTimeMillisState - ?: remember { mutableFloatStateOf(0f) } + val currentTimeMillisState = state.currentTimeMillisState val needsContinuousLoop = preprocessed.hasContinuousTime || preprocessed.hasParticles || preprocessed.hasWakeIn val needsDiscreteLoop = !needsContinuousLoop && preprocessed.hasDiscreteTime @@ -227,20 +222,7 @@ public fun RcPlayer( // store / other computed States and captures its write as the result. No imperative recompute // pass, no dirty flags — changing an input invalidates exactly the dependent States, and chains // compose naturally. - val graphContext = - (state as? RcPlayerStateImpl)?.graphContext - ?: remember(document, remoteContext) { - (remoteContext.mRemoteComposeState as? SnapshotRemoteComposeState)?.let { - snapshotState -> - GraphContext( - snapshotState, - preprocessed.computedOpIndex, - currentTimeMillisState, - clock, - ) - .also { gc -> gc.setTypefaceResolver(remoteContext.typefaceResolver) } - } - } + val graphContext = state.graphContext val startClockMillis = remember(document, clock) { clock.millis() } val limiter = remember(document) { Limiter() } @@ -254,14 +236,10 @@ public fun RcPlayer( while (true) { val frameMillis = withInfiniteAnimationFrameMillis { it } - startMillis limiter.recordDrawStart(frameMillis * 1_000_000L) - val updated = - graphContext?.updateTime( - frameMillis = frameMillis.toFloat(), - updateContinuous = needsContinuousLoop, - ) ?: true - if (needsContinuousLoop || updated) { - currentTimeMillisState.floatValue = frameMillis.toFloat() - } + state.updateTime( + frameMillis = frameMillis.toFloat(), + updateContinuous = needsContinuousLoop, + ) remoteContext.currentTime = startClockMillis + frameMillis if (!needsContinuousLoop && !needsDiscreteLoop) break @@ -346,7 +324,7 @@ public fun RcPlayer( } } } - graphContext?.componentValues = componentValueStateMap + graphContext.componentValues = componentValueStateMap val stateUpdater = remember(remoteContext) { StateUpdaterImpl(remoteContext) } // The image loader: the caller-supplied one, or the default that wraps embedded bitmaps. @@ -357,7 +335,7 @@ public fun RcPlayer( // Make it reachable from the (non-composable) canvas draw path too — the document image // draws // resolve through it via the GraphContext. - graphContext?.imageLoader = resolvedImageLoader + graphContext.imageLoader = resolvedImageLoader CompositionLocalProvider( LocalCoreDocument provides document, LocalRemoteContext provides remoteContext, @@ -647,6 +625,21 @@ internal fun preprocessDocument(document: CoreDocument): DocumentPreprocessResul var hasDiscreteTime = false fun visitOp(op: Operation) { + val definedId = + when (op) { + is NamedVariable -> op.mVarId + is VariableProvider -> op.id + else -> -1 + } + // Warn when a document operation defines an ID that collides with a reserved system + // variable. + if (definedId > 0 && isTimeVariable(definedId)) { + Log.w( + "RcPlayer", + "Operation ${op.javaClass.simpleName} defines reserved system variable ID $definedId", + ) + } + if (op is TextFromFloat && Utils.isVariable(op.mValue)) { val id = Utils.idFromNan(op.mValue) if (isContinuousTimeVariable(id)) { diff --git a/compose/remote/remote-player-compose/src/main/java/androidx/compose/remote/player/compose/embedded/RcPlayerModifiers.kt b/compose/remote/remote-player-compose/src/main/java/androidx/compose/remote/player/compose/embedded/RcPlayerModifiers.kt index fc8ec6807c8ab..58c7b1c9aff0d 100644 --- a/compose/remote/remote-player-compose/src/main/java/androidx/compose/remote/player/compose/embedded/RcPlayerModifiers.kt +++ b/compose/remote/remote-player-compose/src/main/java/androidx/compose/remote/player/compose/embedded/RcPlayerModifiers.kt @@ -30,6 +30,7 @@ import androidx.compose.remote.core.Operation import androidx.compose.remote.core.operations.layout.ClickModifierOperation import androidx.compose.remote.core.operations.layout.Component import androidx.compose.remote.core.operations.layout.LayoutComponent +import androidx.compose.remote.core.operations.layout.MultiClickModifier import androidx.compose.remote.core.operations.layout.animation.AnimationSpec import androidx.compose.remote.core.operations.layout.modifiers.AlignByModifierOperation import androidx.compose.remote.core.operations.layout.modifiers.BackgroundModifierOperation @@ -64,6 +65,7 @@ import androidx.compose.remote.player.compose.embedded.modifier.graphicsLayer import androidx.compose.remote.player.compose.embedded.modifier.height import androidx.compose.remote.player.compose.embedded.modifier.heightIn import androidx.compose.remote.player.compose.embedded.modifier.marquee +import androidx.compose.remote.player.compose.embedded.modifier.multiClick import androidx.compose.remote.player.compose.embedded.modifier.offset import androidx.compose.remote.player.compose.embedded.modifier.padding import androidx.compose.remote.player.compose.embedded.modifier.ripple @@ -103,6 +105,7 @@ public fun ComponentModifiers.toModifier(drawOpsList: List? = null): // that subsequent clip operations are hoisted before drawWithContent without bypassing // preceding padding. var drawContentProcessed = false + var multiClickProcessed = false list.fastForEach { op -> modifier = when (op) { @@ -123,6 +126,24 @@ public fun ComponentModifiers.toModifier(drawOpsList: List? = null): is HeightInModifierOperation -> modifier.heightIn(op) is DimensionConstraintsModifierOperation -> modifier.dimensionConstraints(op) is ClickModifierOperation -> modifier.click(op) + is MultiClickModifier -> { + // RemoteCompose emits a separate MultiClickModifier operation per gesture type + // (e.g. CLICK_TYPE_SINGLE, CLICK_TYPE_DOUBLE, CLICK_TYPE_LONG) on the same + // component. Chaining multiple separate combinedClickable modifiers in Compose + // causes the outer pointer handler to consume gestures before inner handlers + // see them, so we coalesce all MultiClickModifier ops into a single + // combinedClickable at the position of the first MultiClickModifier. + if (!multiClickProcessed) { + multiClickProcessed = true + val multiClickOps = + ArrayList().apply { + list.fastForEach { if (it is MultiClickModifier) add(it) } + } + modifier.multiClick(multiClickOps) + } else { + modifier + } + } is ComponentVisibilityOperation -> modifier.visible(op) is MarqueeModifierOperation -> modifier.marquee(op) is CoreSemantics -> modifier.semantics(op) diff --git a/compose/remote/remote-player-compose/src/main/java/androidx/compose/remote/player/compose/embedded/RcPlayerState.kt b/compose/remote/remote-player-compose/src/main/java/androidx/compose/remote/player/compose/embedded/RcPlayerState.kt index c5948dc78f50c..db73fb0e2d88e 100644 --- a/compose/remote/remote-player-compose/src/main/java/androidx/compose/remote/player/compose/embedded/RcPlayerState.kt +++ b/compose/remote/remote-player-compose/src/main/java/androidx/compose/remote/player/compose/embedded/RcPlayerState.kt @@ -30,6 +30,7 @@ import androidx.compose.remote.player.core.platform.AndroidRemoteContext import androidx.compose.runtime.Composable import androidx.compose.runtime.MutableFloatState import androidx.compose.runtime.MutableState +import androidx.compose.runtime.Stable import androidx.compose.runtime.mutableFloatStateOf import androidx.compose.runtime.remember import androidx.compose.ui.graphics.Color @@ -56,91 +57,14 @@ import java.io.ByteArrayInputStream * the document, falling back to unprefixed `name` if defined without prefix, or `"$prefix:$name"` * otherwise. */ +@Stable @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) -public interface RcPlayerState { +public class RcPlayerState( /** The underlying [CoreDocument] managed by this state. */ - public val document: CoreDocument - + public val document: CoreDocument, /** The default prefix applied to variable names (e.g. `"USER"`, or `null` for none). */ - public val defaultPrefix: String? - - public fun floatState(name: String, prefix: String? = defaultPrefix): MutableState - - public fun intState(name: String, prefix: String? = defaultPrefix): MutableState - - public fun booleanState(name: String, prefix: String? = defaultPrefix): MutableState - - public fun stringState(name: String, prefix: String? = defaultPrefix): MutableState - - public fun colorState(name: String, prefix: String? = defaultPrefix): MutableState - - public fun floatArrayState( - name: String, - prefix: String? = defaultPrefix, - ): MutableState - - public fun bitmapState(name: String, prefix: String? = defaultPrefix): MutableState - - /** Clears any override applied to [name] and restores its authored document default. */ - public fun clearOverride(name: String, prefix: String? = defaultPrefix) -} - -/** - * Creates an [RcPlayerState] for the given [document]. - * - * @param document The [CoreDocument] to bind. - * @param defaultPrefix The default variable name prefix (default is `"USER"`). Pass `null` for no - * prefix. - */ -@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) -public fun RcPlayerState( - document: CoreDocument, - defaultPrefix: String? = "USER", -): RcPlayerState = RcPlayerStateImpl(document, defaultPrefix) - -/** - * Creates an [RcPlayerState] for the given [capturedDocument]. - * - * @param capturedDocument The [CapturedDocument] to bind. - * @param defaultPrefix The default variable name prefix (default is `"USER"`). Pass `null` for no - * prefix. - */ -@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) -public fun RcPlayerState( - capturedDocument: CapturedDocument, - defaultPrefix: String? = "USER", -): RcPlayerState { - RemoteImageSupport.enableEncodedImageReferences() - val coreDoc = - CoreDocument(RemoteClock.SYSTEM).apply { - ByteArrayInputStream(capturedDocument.bytes).use { - initFromBuffer(RemoteComposeBuffer.fromInputStream(it)) - } - } - return RcPlayerStateImpl(coreDoc, defaultPrefix) -} - -/** Creates and remembers an [RcPlayerState] for the given [document]. */ -@Composable -@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) -public fun rememberRcPlayerState( - document: CoreDocument, - defaultPrefix: String? = "USER", -): RcPlayerState = remember(document, defaultPrefix) { RcPlayerState(document, defaultPrefix) } - -/** Creates and remembers an [RcPlayerState] for the given [capturedDocument]. */ -@Composable -@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) -public fun rememberRcPlayerState( - capturedDocument: CapturedDocument, - defaultPrefix: String? = "USER", -): RcPlayerState = - remember(capturedDocument, defaultPrefix) { RcPlayerState(capturedDocument, defaultPrefix) } - -internal class RcPlayerStateImpl( - override val document: CoreDocument, - override val defaultPrefix: String?, -) : RcPlayerState { + public val defaultPrefix: String? = "USER", +) { internal val preprocessed: DocumentPreprocessResult = preprocessDocument(document) internal val remoteContext: AndroidRemoteContext = initializePlayerRemoteContext( @@ -161,6 +85,25 @@ internal class RcPlayerStateImpl( gc.setTypefaceResolver(remoteContext.typefaceResolver) } + /** + * Advances document time to [frameMillis] across both time-tracking paths: + * 1. [GraphContext.updateTime] updates the expression DAG's `timeState` (driving compiled float + * expressions like `ID_ANIMATION_TIME` and discrete wall-clock variables) and returns `true` + * if any discrete clock boundary (second/minute/hour) was crossed. + * 2. [currentTimeMillisState] drives non-DAG time readers (such as `TextFromFloat` and canvas + * operations). It is updated whenever continuous animation is active or a discrete clock + * boundary was crossed so both paths stay synchronized on every frame. + */ + internal fun updateTime(frameMillis: Float, updateContinuous: Boolean = true): Boolean { + val updated = graphContext.updateTime(frameMillis, updateContinuous) + // Advance the shared snapshot clock when running continuous animations or when a discrete + // clock boundary crossed so non-DAG operations observe the same frame timestamp. + if (updateContinuous || updated) { + currentTimeMillisState.floatValue = frameMillis + } + return updated + } + private val initialFloats = mutableMapOf() private val initialInts = mutableMapOf() private val initialColors = mutableMapOf() @@ -296,7 +239,7 @@ internal class RcPlayerStateImpl( state.clearFloatOverride(id) } - override fun floatState(name: String, prefix: String?): MutableState = + public fun floatState(name: String, prefix: String? = defaultPrefix): MutableState = getOrCreateState( floatStates, name, @@ -318,7 +261,7 @@ internal class RcPlayerStateImpl( state.clearIntegerOverride(id) } - override fun intState(name: String, prefix: String?): MutableState = + public fun intState(name: String, prefix: String? = defaultPrefix): MutableState = getOrCreateState( intStates, name, @@ -339,7 +282,7 @@ internal class RcPlayerStateImpl( state.clearIntegerOverride(id) } - override fun booleanState(name: String, prefix: String?): MutableState = + public fun booleanState(name: String, prefix: String? = defaultPrefix): MutableState = getOrCreateState( booleanStates, name, @@ -361,7 +304,7 @@ internal class RcPlayerStateImpl( state.clearDataOverride(id) } - override fun stringState(name: String, prefix: String?): MutableState = + public fun stringState(name: String, prefix: String? = defaultPrefix): MutableState = getOrCreateState( stringStates, name, @@ -388,7 +331,7 @@ internal class RcPlayerStateImpl( initialColors[id]?.let { state.overrideColor(id, it) } } - override fun colorState(name: String, prefix: String?): MutableState = + public fun colorState(name: String, prefix: String? = defaultPrefix): MutableState = getOrCreateState( colorStates, name, @@ -410,7 +353,7 @@ internal class RcPlayerStateImpl( state.clearDataOverride(id) } - override fun bitmapState(name: String, prefix: String?): MutableState = + public fun bitmapState(name: String, prefix: String? = defaultPrefix): MutableState = getOrCreateState( bitmapStates, name, @@ -441,7 +384,10 @@ internal class RcPlayerStateImpl( } } - override fun floatArrayState(name: String, prefix: String?): MutableState = + public fun floatArrayState( + name: String, + prefix: String? = defaultPrefix, + ): MutableState = getOrCreateState( floatArrayStates, name, @@ -450,7 +396,8 @@ internal class RcPlayerStateImpl( { n, v -> setFloatArray(n, v, null) }, ) - override fun clearOverride(name: String, prefix: String?) { + /** Clears any override applied to [name] and restores its authored document default. */ + public fun clearOverride(name: String, prefix: String? = defaultPrefix) { clearFloat(name, prefix) clearInt(name, prefix) clearBoolean(name, prefix) @@ -461,6 +408,45 @@ internal class RcPlayerStateImpl( } } +/** + * Creates an [RcPlayerState] for the given [capturedDocument]. + * + * @param capturedDocument The [CapturedDocument] to bind. + * @param defaultPrefix The default variable name prefix (default is `"USER"`). Pass `null` for no + * prefix. + */ +@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) +public fun RcPlayerState( + capturedDocument: CapturedDocument, + defaultPrefix: String? = "USER", +): RcPlayerState { + RemoteImageSupport.enableEncodedImageReferences() + val coreDoc = + CoreDocument(RemoteClock.SYSTEM).apply { + ByteArrayInputStream(capturedDocument.bytes).use { + initFromBuffer(RemoteComposeBuffer.fromInputStream(it)) + } + } + return RcPlayerState(coreDoc, defaultPrefix) +} + +/** Creates and remembers an [RcPlayerState] for the given [document]. */ +@Composable +@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) +public fun rememberRcPlayerState( + document: CoreDocument, + defaultPrefix: String? = "USER", +): RcPlayerState = remember(document, defaultPrefix) { RcPlayerState(document, defaultPrefix) } + +/** Creates and remembers an [RcPlayerState] for the given [capturedDocument]. */ +@Composable +@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) +public fun rememberRcPlayerState( + capturedDocument: CapturedDocument, + defaultPrefix: String? = "USER", +): RcPlayerState = + remember(capturedDocument, defaultPrefix) { RcPlayerState(capturedDocument, defaultPrefix) } + private class DelegatedMutableState( private val name: String, private val getter: (String) -> T, diff --git a/compose/remote/remote-player-compose/src/main/java/androidx/compose/remote/player/compose/embedded/modifier/ClickModifier.kt b/compose/remote/remote-player-compose/src/main/java/androidx/compose/remote/player/compose/embedded/modifier/ClickModifier.kt index c85f901d80135..5399f6fc2a1c4 100644 --- a/compose/remote/remote-player-compose/src/main/java/androidx/compose/remote/player/compose/embedded/modifier/ClickModifier.kt +++ b/compose/remote/remote-player-compose/src/main/java/androidx/compose/remote/player/compose/embedded/modifier/ClickModifier.kt @@ -18,11 +18,16 @@ package androidx.compose.remote.player.compose.embedded.modifier +import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.clickable +import androidx.compose.foundation.combinedClickable +import androidx.compose.remote.core.CoreDocument import androidx.compose.remote.core.Operation +import androidx.compose.remote.core.RemoteContext import androidx.compose.remote.core.operations.Theme import androidx.compose.remote.core.operations.Utils import androidx.compose.remote.core.operations.layout.ClickModifierOperation +import androidx.compose.remote.core.operations.layout.MultiClickModifier import androidx.compose.remote.core.operations.layout.modifiers.HostActionOperation import androidx.compose.remote.core.operations.layout.modifiers.HostNamedActionOperation import androidx.compose.remote.core.operations.layout.modifiers.RunActionOperation @@ -35,6 +40,7 @@ import androidx.compose.remote.player.compose.embedded.LocalCoreDocument import androidx.compose.remote.player.compose.embedded.LocalRemoteActionHandler import androidx.compose.remote.player.compose.embedded.LocalRemoteContext import androidx.compose.remote.player.compose.embedded.LocalRemoteNamedActionHandler +import androidx.compose.remote.player.compose.embedded.clickTypeReflection import androidx.compose.remote.player.compose.embedded.getOperationsReflection import androidx.compose.remote.player.compose.embedded.readData import androidx.compose.remote.player.compose.embedded.state.rememberRemoteStringAsState @@ -45,6 +51,7 @@ import androidx.compose.remote.player.compose.embedded.valueIdReflection import androidx.compose.remote.player.compose.embedded.valueReflection import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier +import androidx.compose.ui.util.fastFilter import androidx.compose.ui.util.fastForEach @Composable @@ -55,59 +62,103 @@ internal fun Modifier.click(op: ClickModifierOperation): Modifier { val onNamedAction = LocalRemoteNamedActionHandler.current val contentDescription = op.contentDescriptionId?.let { rememberRemoteStringAsState(it).value } - fun applyAction(action: Operation) { - when (action) { - is ValueIntegerChangeActionOperation -> - remoteContext.overrideInteger( - action.targetValueIdReflection, - action.valueReflection, - ) - is ValueFloatChangeActionOperation -> - remoteContext.overrideFloat(action.targetValueIdReflection, action.valueReflection) - is ValueStringChangeActionOperation -> - remoteContext.overrideText(action.targetValueIdReflection, action.valueIdReflection) - is ValueIntegerExpressionChangeActionOperation -> { - val targetId = Utils.idFromLong(action.targetValueIdReflection).toInt() - val expressionId = Utils.idFromLong(action.valueExpressionIdReflection) - coreDocument.evaluateIntExpression(expressionId, targetId, remoteContext) - } - is ValueFloatExpressionChangeActionOperation -> { - val targetId = action.targetValueIdReflection - val expressionId = action.valueExpressionIdReflection - coreDocument.evaluateFloatExpression(expressionId, targetId, remoteContext) - } - // Host callback (id only; HostActionOperation carries no value). - is HostActionOperation -> onAction(action.actionId, null) - // Named host action (what the public hostAction(name, value) authors): resolve the name - // and the typed value, then notify the host. - is HostNamedActionOperation -> { - val data = action.readData() - val name = remoteContext.getText(data.textId) ?: "" - val valueId = data.valueId - val value: Any? = - if (valueId == -1) { - null - } else { - when (data.type) { - HostNamedActionOperation.FLOAT_TYPE -> remoteContext.getFloat(valueId) - HostNamedActionOperation.INT_TYPE -> remoteContext.getInteger(valueId) - HostNamedActionOperation.STRING_TYPE -> remoteContext.getText(valueId) - else -> null - } - } - onNamedAction(name, value) - } - // A container of nested actions — run each. - is RunActionOperation -> action.getList().fastForEach { applyAction(it) } + return this.clickable(onClickLabel = contentDescription) { + op.mList.fastForEach { + applyClickAction(it, coreDocument, remoteContext, onAction, onNamedAction) } + coreDocument.updateVariablesReflection( + remoteContext, + Theme.SYSTEM, + coreDocument.getOperationsReflection(), + ) } +} - return this.clickable(onClickLabel = contentDescription) { - op.mList.fastForEach { applyAction(it) } +@OptIn(ExperimentalFoundationApi::class) +@Composable +internal fun Modifier.multiClick(ops: List): Modifier { + val coreDocument = LocalCoreDocument.current + val remoteContext = LocalRemoteContext.current + val onAction = LocalRemoteActionHandler.current + val onNamedAction = LocalRemoteNamedActionHandler.current + + val singleOps = ops.fastFilter { + it.clickTypeReflection == MultiClickModifier.CLICK_TYPE_SINGLE + } + val doubleOps = ops.fastFilter { + it.clickTypeReflection == MultiClickModifier.CLICK_TYPE_DOUBLE + } + val longOps = ops.fastFilter { it.clickTypeReflection == MultiClickModifier.CLICK_TYPE_LONG } + + fun dispatchOps(targetOps: List) { + targetOps.fastForEach { modifierOp -> + modifierOp.mList.fastForEach { action -> + applyClickAction(action, coreDocument, remoteContext, onAction, onNamedAction) + } + } coreDocument.updateVariablesReflection( remoteContext, Theme.SYSTEM, coreDocument.getOperationsReflection(), ) } + + return this.combinedClickable( + onClick = { dispatchOps(singleOps) }, + onDoubleClick = if (doubleOps.isNotEmpty()) ({ dispatchOps(doubleOps) }) else null, + onLongClick = if (longOps.isNotEmpty()) ({ dispatchOps(longOps) }) else null, + ) +} + +private fun applyClickAction( + action: Operation, + coreDocument: CoreDocument, + remoteContext: RemoteContext, + onAction: (Int, String?) -> Unit, + onNamedAction: (String, Any?) -> Unit, +) { + when (action) { + is ValueIntegerChangeActionOperation -> + remoteContext.overrideInteger(action.targetValueIdReflection, action.valueReflection) + is ValueFloatChangeActionOperation -> + remoteContext.overrideFloat(action.targetValueIdReflection, action.valueReflection) + is ValueStringChangeActionOperation -> + remoteContext.overrideText(action.targetValueIdReflection, action.valueIdReflection) + is ValueIntegerExpressionChangeActionOperation -> { + val targetId = Utils.idFromLong(action.targetValueIdReflection).toInt() + val expressionId = Utils.idFromLong(action.valueExpressionIdReflection) + coreDocument.evaluateIntExpression(expressionId, targetId, remoteContext) + } + is ValueFloatExpressionChangeActionOperation -> { + val targetId = action.targetValueIdReflection + val expressionId = action.valueExpressionIdReflection + coreDocument.evaluateFloatExpression(expressionId, targetId, remoteContext) + } + // Host callback (id only; HostActionOperation carries no value). + is HostActionOperation -> onAction(action.actionId, null) + // Named host action (what the public hostAction(name, value) authors): resolve the name + // and the typed value, then notify the host. + is HostNamedActionOperation -> { + val data = action.readData() + val name = remoteContext.getText(data.textId) ?: "" + val valueId = data.valueId + val value: Any? = + if (valueId == -1) { + null + } else { + when (data.type) { + HostNamedActionOperation.FLOAT_TYPE -> remoteContext.getFloat(valueId) + HostNamedActionOperation.INT_TYPE -> remoteContext.getInteger(valueId) + HostNamedActionOperation.STRING_TYPE -> remoteContext.getText(valueId) + else -> null + } + } + onNamedAction(name, value) + } + // A container of nested actions — run each. + is RunActionOperation -> + action.getList().fastForEach { + applyClickAction(it, coreDocument, remoteContext, onAction, onNamedAction) + } + } } diff --git a/compose/remote/remote-player-compose/src/test/java/androidx/compose/remote/player/compose/embedded/RcPlayerExpressionTest.kt b/compose/remote/remote-player-compose/src/test/java/androidx/compose/remote/player/compose/embedded/RcPlayerExpressionTest.kt index 04c0aaece7cba..00a5392a03f81 100644 --- a/compose/remote/remote-player-compose/src/test/java/androidx/compose/remote/player/compose/embedded/RcPlayerExpressionTest.kt +++ b/compose/remote/remote-player-compose/src/test/java/androidx/compose/remote/player/compose/embedded/RcPlayerExpressionTest.kt @@ -18,10 +18,12 @@ package androidx.compose.remote.player.compose.embedded import androidx.collection.emptyIntObjectMap import androidx.collection.mutableIntObjectMapOf +import androidx.compose.remote.core.CoreDocument import androidx.compose.remote.core.Operation import androidx.compose.remote.core.RemoteClock import androidx.compose.remote.core.RemoteContext import androidx.compose.remote.core.SystemClock +import androidx.compose.remote.core.operations.FloatConstant import androidx.compose.remote.core.operations.FloatExpression import androidx.compose.remote.core.operations.Utils import androidx.compose.remote.core.operations.layout.CanvasOperations @@ -700,4 +702,33 @@ class RcPlayerExpressionTest { assertThat(updatedA).isEqualTo(updatedB) assertThat(updatedA).isNotEqualTo(initialA) } + + @Test + fun updateTime_updatesBothGraphContextAndCurrentTimeMillisState() { + val baseInstant = Instant.parse("2026-01-01T00:00:00Z") + val clock = SystemClock(Clock.fixed(baseInstant, ZoneOffset.UTC)) + val doc = CoreDocument(clock) + val state = RcPlayerState(doc) + + state.updateTime(250f) + + assertThat(state.currentTimeMillisState.floatValue).isEqualTo(250f) + assertThat(state.graphContext.getFloat(RemoteContext.ID_ANIMATION_TIME)) + .isWithin(0.0001f) + .of(0.25f) + } + + @Test + fun preprocessDocument_reservedSystemVariableId_doesNotRemap() { + val baseInstant = Instant.parse("2026-01-01T00:00:00Z") + val clock = SystemClock(Clock.fixed(baseInstant, ZoneOffset.UTC)) + val doc = CoreDocument(clock) + doc.getOperationsReflection().add(FloatConstant(RemoteContext.ID_OFFSET_TO_UTC, 123.456f)) + + val state = RcPlayerState(doc) + + // Reserved system variable ID (10 = ID_OFFSET_TO_UTC) is not remapped or fixed; + // GraphContext continues resolving the system clock variable (0.0f in UTC). + assertThat(state.graphContext.getFloat(RemoteContext.ID_OFFSET_TO_UTC)).isEqualTo(0f) + } } diff --git a/compose/remote/remote-player-compose/src/test/java/androidx/compose/remote/player/compose/embedded/RcPlayerInteractivityTest.kt b/compose/remote/remote-player-compose/src/test/java/androidx/compose/remote/player/compose/embedded/RcPlayerInteractivityTest.kt index 248411ec74db3..6f77ab84632d1 100644 --- a/compose/remote/remote-player-compose/src/test/java/androidx/compose/remote/player/compose/embedded/RcPlayerInteractivityTest.kt +++ b/compose/remote/remote-player-compose/src/test/java/androidx/compose/remote/player/compose/embedded/RcPlayerInteractivityTest.kt @@ -26,6 +26,9 @@ import androidx.compose.remote.core.RemoteComposeBuffer import androidx.compose.remote.core.RemoteContext import androidx.compose.remote.core.SystemClock import androidx.compose.remote.core.operations.layout.Component +import androidx.compose.remote.core.operations.layout.MultiClickModifier +import androidx.compose.remote.core.operations.layout.modifiers.ComponentModifiers +import androidx.compose.remote.core.operations.layout.modifiers.HostActionOperation import androidx.compose.remote.creation.RemoteComposeWriterAndroid import androidx.compose.remote.creation.compose.action.combinedAction import androidx.compose.remote.creation.compose.action.hostAction @@ -34,6 +37,7 @@ import androidx.compose.remote.creation.compose.action.valueChange import androidx.compose.remote.creation.compose.capture.captureSingleRemoteDocument import androidx.compose.remote.creation.compose.layout.RemoteBox import androidx.compose.remote.creation.compose.layout.RemoteComposable +import androidx.compose.remote.creation.compose.layout.RemoteRow import androidx.compose.remote.creation.compose.layout.RemoteStateLayout import androidx.compose.remote.creation.compose.modifier.RemoteModifier import androidx.compose.remote.creation.compose.modifier.background @@ -87,16 +91,20 @@ import androidx.compose.remote.creation.compose.state.toDeg import androidx.compose.remote.creation.compose.state.toRad import androidx.compose.remote.creation.platform.AndroidxRcPlatformServices import androidx.compose.remote.creation.profile.Profile +import androidx.compose.remote.player.core.platform.AndroidRemoteContext import androidx.compose.runtime.Composable +import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.platform.testTag import androidx.compose.ui.test.assertIsDisplayed import androidx.compose.ui.test.assertIsNotDisplayed +import androidx.compose.ui.test.doubleClick import androidx.compose.ui.test.getUnclippedBoundsInRoot import androidx.compose.ui.test.hasClickAction import androidx.compose.ui.test.junit4.v2.createComposeRule +import androidx.compose.ui.test.longClick import androidx.compose.ui.test.onNodeWithContentDescription import androidx.compose.ui.test.onNodeWithText import androidx.compose.ui.test.performClick @@ -1381,4 +1389,90 @@ class RcPlayerInteractivityTest { rule.waitForIdle() } } + + @Test + fun multiClickModifier_dispatchesSingleDoubleAndLongClicks() { + val modifiers = + ComponentModifiers().apply { + add( + MultiClickModifier(MultiClickModifier.CLICK_TYPE_SINGLE).apply { + list.add(HostActionOperation(101)) + } + ) + add( + MultiClickModifier(MultiClickModifier.CLICK_TYPE_DOUBLE).apply { + list.add(HostActionOperation(102)) + } + ) + add( + MultiClickModifier(MultiClickModifier.CLICK_TYPE_LONG).apply { + list.add(HostActionOperation(103)) + } + ) + } + + val remoteContext = AndroidRemoteContext() + val document = CoreDocument(RemoteClock.SYSTEM) + val triggeredIds = mutableListOf() + rule.setContent { + CompositionLocalProvider( + LocalCoreDocument provides document, + LocalRemoteContext provides remoteContext, + LocalRemoteActionHandler provides { id, _ -> triggeredIds.add(id) }, + ) { + Box(modifier = modifiers.toModifier().size(100.dp)) + } + } + rule.waitForIdle() + + rule.onNode(hasClickAction()).performClick() + rule.mainClock.advanceTimeBy(400L) + rule.waitForIdle() + assertThat(triggeredIds).contains(101) + + rule.onNode(hasClickAction()).performTouchInput { doubleClick() } + rule.mainClock.advanceTimeBy(400L) + rule.waitForIdle() + assertThat(triggeredIds).contains(102) + + rule.onNode(hasClickAction()).performTouchInput { longClick() } + rule.waitForIdle() + assertThat(triggeredIds).contains(103) + } + + @Test + fun goneComponent_collapsesLayoutBoundsToZero() { + runBlocking { + val context = ApplicationProvider.getApplicationContext() + val content: @Composable @RemoteComposable () -> Unit = { + RemoteRow { + RemoteBox( + modifier = + RemoteModifier.size(80.rdp) + .visibility(Component.Visibility.GONE.ri) + .semantics { contentDescription = "GoneBox".rs } + ) + RemoteBox( + modifier = + RemoteModifier.size(80.rdp).semantics { + contentDescription = "VisibleSibling".rs + } + ) + } + } + val capturedDocument = captureSingleRemoteDocument(context = context, content = content) + rule.setContent { + Box(modifier = Modifier.size(200.dp)) { + RcPlayer(capturedDocument = capturedDocument) + } + } + rule.waitForIdle() + + // Because the preceding GONE box collapses to 0x0 in layout, VisibleSibling starts at + // left = 0dp. + val siblingBounds = + rule.onNodeWithContentDescription("VisibleSibling").getUnclippedBoundsInRoot() + assertThat(siblingBounds.left).isEqualTo(0.dp) + } + } } diff --git a/compose/remote/remote-tooling-preview/build.gradle b/compose/remote/remote-tooling-preview/build.gradle index 3bf01f6c0941b..91357318b8b52 100644 --- a/compose/remote/remote-tooling-preview/build.gradle +++ b/compose/remote/remote-tooling-preview/build.gradle @@ -41,7 +41,7 @@ dependencies { implementation("androidx.compose.runtime:runtime:1.8.3") implementation("androidx.compose.foundation:foundation:1.8.3") implementation("androidx.compose.ui:ui:1.8.3") - implementation("androidx.compose.ui:ui-tooling-preview:1.12.0-beta02") + implementation("androidx.compose.ui:ui-tooling-preview:1.12.0") api(project(":compose:remote:remote-creation-core")) implementation(project(":compose:remote:remote-core")) implementation(project(":compose:remote:remote-creation")) diff --git a/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/snapshots/SnapshotStateObserver.kt b/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/snapshots/SnapshotStateObserver.kt index 973aa6dd99b3f..886e59ab1eb8c 100644 --- a/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/snapshots/SnapshotStateObserver.kt +++ b/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/snapshots/SnapshotStateObserver.kt @@ -421,7 +421,7 @@ public class SnapshotStateObserver(private val onChangedExecutor: (callback: () deriveStateScopeCount++ } else if (state is ComputedState<*>) { if (deriveStateScopeCount == 0 && computedStateDepth == 0) { - dependencyToIndirectStates.remove(state) + dependencyToIndirectStates.removeScope(state) rootComputingState = state } computedStateDepth++ @@ -498,19 +498,7 @@ public class SnapshotStateObserver(private val onChangedExecutor: (callback: () val rootComputingState = rootComputingState if (rootComputingState != null) { - if (value is StateObjectImpl) { - value.recordReadIn(ReaderKind.SnapshotStateObserver) - } - dependencyToIndirectStates.add(value, rootComputingState) - if (value is DerivedState<*>) { - val record = value.currentRecord - record.dependencies.forEach { dependency, _ -> - if (dependency is StateObjectImpl) { - dependency.recordReadIn(ReaderKind.SnapshotStateObserver) - } - dependencyToIndirectStates.add(dependency, rootComputingState) - } - } + recordReadInComputedState(value, rootComputingState) return } @@ -539,6 +527,25 @@ public class SnapshotStateObserver(private val onChangedExecutor: (callback: () } } + private fun recordReadInComputedState( + value: Any, + computedState: ComputedState<*>, + ) { + if (value is StateObjectImpl) { + value.recordReadIn(ReaderKind.SnapshotStateObserver) + } + dependencyToIndirectStates.add(value, computedState) + if (value is DerivedState<*>) { + val record = value.currentRecord + record.dependencies.forEach { dependency, _ -> + if (dependency is StateObjectImpl) { + dependency.recordReadIn(ReaderKind.SnapshotStateObserver) + } + dependencyToIndirectStates.add(dependency, computedState) + } + } + } + /** Setup new scope for state read observation, observe them, and cleanup afterwards */ // inlined as used only in one place to not add extra function call overhead @Suppress("NOTHING_TO_INLINE") @@ -674,18 +681,16 @@ public class SnapshotStateObserver(private val onChangedExecutor: (callback: () val scopeToValues = scopeToValues val token = currentSnapshot().snapshotId.hashCode() if (indirectState is ComputedState<*>) { - Snapshot.observeInternal({ - valueToScopes.forEachScopeOf(indirectState) { scope -> - recordRead( - value = it, - currentToken = token, - currentScope = scope, - recordedValues = - scopeToValues.getOrPut(scope) { MutableObjectIntMap() }, - ) - } + val dependencyToIndirectStates = dependencyToIndirectStates + dependencyToIndirectStates.removeScope(indirectState) + Snapshot.observeInternal({ dependency -> + recordReadInComputedState(dependency, indirectState) }) { - indirectState.value + recordedIndirectStateValues[indirectState] = indirectState.value + } + valueToScopes.forEachScopeOf(indirectState) { scope -> + val recordedValues = scopeToValues.getOrPut(scope) { MutableObjectIntMap() } + recordedValues.put(indirectState, token, -1) } } else { valueToScopes.forEachScopeOf(indirectState) { scope -> diff --git a/compose/runtime/runtime/src/nonEmulatorCommonTest/kotlin/androidx/compose/runtime/snapshots/SnapshotStateObserverTestsCommon.kt b/compose/runtime/runtime/src/nonEmulatorCommonTest/kotlin/androidx/compose/runtime/snapshots/SnapshotStateObserverTestsCommon.kt index 2d6d23504e7b3..a003a5b5d889d 100644 --- a/compose/runtime/runtime/src/nonEmulatorCommonTest/kotlin/androidx/compose/runtime/snapshots/SnapshotStateObserverTestsCommon.kt +++ b/compose/runtime/runtime/src/nonEmulatorCommonTest/kotlin/androidx/compose/runtime/snapshots/SnapshotStateObserverTestsCommon.kt @@ -1262,6 +1262,33 @@ class SnapshotStateObserverTestsCommon { initialRead.value = false } + @Test + fun computedState_doesNotLeakDependenciesToScope_whenDependenciesChangeWithoutValueChanged() { + var changes = 0 + val changeBlock: (Any) -> Unit = { changes++ } + + runSimpleTest { stateObserver, _ -> + var a by mutableIntStateOf(1) + val computed = computedStateOf { a > 0 } + val scope = ValueWrapper("scope") + + Snapshot.notifyObjectsInitialized() + + stateObserver.observeReads(scope, changeBlock) { + computed.value + } + assertEquals(0, changes) + + a = 2 + Snapshot.sendApplyNotifications() + assertEquals(0, changes) + + a = 3 + Snapshot.sendApplyNotifications() + assertEquals(0, changes) + } + } + private fun runSimpleTest( block: (modelObserver: SnapshotStateObserver, data: MutableState) -> Unit ) { diff --git a/compose/ui/ui-text-google-fonts/build.gradle b/compose/ui/ui-text-google-fonts/build.gradle index 899722d7e5ce2..0862a261b143a 100644 --- a/compose/ui/ui-text-google-fonts/build.gradle +++ b/compose/ui/ui-text-google-fonts/build.gradle @@ -34,7 +34,7 @@ dependencies { implementation("androidx.compose.runtime:runtime:1.2.1") implementation(project(":compose:ui:ui-text")) implementation(project(":compose:ui:ui-util")) - implementation("androidx.core:core:1.19.0-rc01") + implementation("androidx.core:core:1.19.0") androidTestImplementation(project(":compose:ui:ui-test-junit4")) androidTestImplementation(libs.testCore) diff --git a/compose/ui/ui-text/build.gradle b/compose/ui/ui-text/build.gradle index c49bfbfd7f439..22380f061a84b 100644 --- a/compose/ui/ui-text/build.gradle +++ b/compose/ui/ui-text/build.gradle @@ -54,7 +54,6 @@ androidXMultiplatform { implementation(project(":compose:ui:ui-util")) - // TODO: Pin androidx.collection when SieveCache is available implementation("androidx.collection:collection:1.6.0") } @@ -62,11 +61,11 @@ androidXMultiplatform { api("androidx.annotation:annotation:1.8.1") api("androidx.annotation:annotation-experimental:1.4.1") implementation("androidx.core:core:1.7.0") - implementation("androidx.emoji2:emoji2:1.7.0-rc01") + implementation("androidx.emoji2:emoji2:1.7.0") } androidDeviceTest.dependencies { - implementation("androidx.emoji2:emoji2-bundled:1.7.0-rc01") + implementation("androidx.emoji2:emoji2-bundled:1.7.0") implementation(project(":compose:ui:ui-test-junit4")) implementation(project(":internal-testutils-fonts")) implementation(project(":compose:foundation:foundation")) diff --git a/compose/ui/ui/build.gradle b/compose/ui/ui/build.gradle index d3401c7b1ab47..5a02ddb83bae6 100644 --- a/compose/ui/ui/build.gradle +++ b/compose/ui/ui/build.gradle @@ -98,7 +98,7 @@ androidXMultiplatform { implementation("androidx.savedstate:savedstate-ktx:1.3.1") implementation("androidx.lifecycle:lifecycle-viewmodel:2.10.0") implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.10.0") - implementation("androidx.emoji2:emoji2:1.7.0-rc01") + implementation("androidx.emoji2:emoji2:1.7.0") implementation("androidx.window:window:1.5.0") implementation("androidx.profileinstaller:profileinstaller:1.4.0") diff --git a/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/platform/AndroidComposeView.android.kt b/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/platform/AndroidComposeView.android.kt index c552d7cbb822d..9de14d69230aa 100644 --- a/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/platform/AndroidComposeView.android.kt +++ b/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/platform/AndroidComposeView.android.kt @@ -88,7 +88,7 @@ import androidx.collection.ScatterMap import androidx.collection.mutableIntObjectMapOf import androidx.collection.mutableObjectListOf import androidx.compose.runtime.MutableState -import androidx.compose.runtime.computedStateOf +import androidx.compose.runtime.derivedStateOf import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.referentialEqualityPolicy @@ -516,7 +516,7 @@ internal class AndroidComposeView(context: Context, composeViewContext: ComposeV // relying on the derivedStateOf() notification change. This can be removed when // b/442011315 is fixed. private var isAttached by mutableStateOf(false) - private val derivedIsAttached by computedStateOf { isAttached } + private val derivedIsAttached by derivedStateOf { isAttached } /** * Because AndroidComposeView always accepts focus, we have to divert focus to another View if diff --git a/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/window/AndroidPopup.android.kt b/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/window/AndroidPopup.android.kt index 519e8d4e2414c..e02b7b96a04a7 100644 --- a/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/window/AndroidPopup.android.kt +++ b/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/window/AndroidPopup.android.kt @@ -42,7 +42,7 @@ import androidx.compose.runtime.Immutable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.SideEffect import androidx.compose.runtime.compositionLocalOf -import androidx.compose.runtime.computedStateOf +import androidx.compose.runtime.derivedStateOf import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember @@ -729,7 +729,7 @@ internal class PopupLayout( private var parentBounds: IntRect? = null /** Track parent coordinates and content size; only show popup once we have both. */ - val canCalculatePosition by computedStateOf { + val canCalculatePosition by derivedStateOf { parentLayoutCoordinates?.takeIf { it.isAttached } != null && popupContentSize != null } diff --git a/datastore/datastore-core-okio/build.gradle b/datastore/datastore-core-okio/build.gradle index aa5e90ce95562..1a4de74071a7b 100644 --- a/datastore/datastore-core-okio/build.gradle +++ b/datastore/datastore-core-okio/build.gradle @@ -75,5 +75,4 @@ androidx { type = SoftwareType.PUBLISHED_LIBRARY inceptionYear = "2020" description = "Android DataStore Core Okio- contains APIs to use datastore-core in multiplatform via okio" - kotlinTarget = KotlinTarget.KOTLIN_2_2 } diff --git a/datastore/datastore-core/build.gradle b/datastore/datastore-core/build.gradle index 276169b036ed5..8803250b0987e 100644 --- a/datastore/datastore-core/build.gradle +++ b/datastore/datastore-core/build.gradle @@ -177,6 +177,5 @@ androidx { inceptionYear = "2020" description = "Android DataStore Core - contains the underlying store used by each serialization method" legacyDisableKotlinStrictApiMode = true - kotlinTarget = KotlinTarget.KOTLIN_2_2 enableRobolectric() } diff --git a/datastore/datastore-guava/build.gradle b/datastore/datastore-guava/build.gradle index 4acb081b6e860..5dac91c8e9863 100644 --- a/datastore/datastore-guava/build.gradle +++ b/datastore/datastore-guava/build.gradle @@ -59,5 +59,4 @@ androidx { type = SoftwareType.PUBLISHED_LIBRARY inceptionYear = "2024" description = "Android DataStore Guava - contains wrappers for using DataStore using ListenableFuture" - kotlinTarget = KotlinTarget.KOTLIN_2_2 } diff --git a/datastore/datastore-preferences-core/build.gradle b/datastore/datastore-preferences-core/build.gradle index 075ea3e84ad6e..7bac5d3cb1eb2 100644 --- a/datastore/datastore-preferences-core/build.gradle +++ b/datastore/datastore-preferences-core/build.gradle @@ -106,5 +106,4 @@ androidx { inceptionYear = "2020" description = "Android Preferences DataStore without the Android Dependencies" legacyDisableKotlinStrictApiMode = true - kotlinTarget = KotlinTarget.KOTLIN_2_2 } diff --git a/datastore/datastore-preferences-external-protobuf/build.gradle b/datastore/datastore-preferences-external-protobuf/build.gradle index 7897380c4cdd4..7ecd727ed71ab 100644 --- a/datastore/datastore-preferences-external-protobuf/build.gradle +++ b/datastore/datastore-preferences-external-protobuf/build.gradle @@ -50,5 +50,4 @@ androidx { doNotDocumentReason = "Repackaging only" license.name = "BSD-3-Clause" license.url = "https://opensource.org/licenses/BSD-3-Clause" - kotlinTarget = KotlinTarget.KOTLIN_2_2 } diff --git a/datastore/datastore-preferences-proto/build.gradle b/datastore/datastore-preferences-proto/build.gradle index 554f97d5f4e99..0de6034e542d8 100644 --- a/datastore/datastore-preferences-proto/build.gradle +++ b/datastore/datastore-preferences-proto/build.gradle @@ -54,5 +54,4 @@ androidx { type = SoftwareType.PUBLISHED_PROTO_LIBRARY inceptionYear = "2020" description = "Jarjar the generated proto for use by datastore-preferences." - kotlinTarget = KotlinTarget.KOTLIN_2_2 } diff --git a/datastore/datastore-preferences-rxjava2/build.gradle b/datastore/datastore-preferences-rxjava2/build.gradle index 85018790e6362..214f9ada26611 100644 --- a/datastore/datastore-preferences-rxjava2/build.gradle +++ b/datastore/datastore-preferences-rxjava2/build.gradle @@ -75,5 +75,4 @@ androidx { inceptionYear = "2020" description = "Android DataStore Core - contains wrappers for using DataStore using RxJava2" legacyDisableKotlinStrictApiMode = true - kotlinTarget = KotlinTarget.KOTLIN_2_2 } diff --git a/datastore/datastore-preferences-rxjava3/build.gradle b/datastore/datastore-preferences-rxjava3/build.gradle index 037f0c8cfb6cf..c476b43c94ece 100644 --- a/datastore/datastore-preferences-rxjava3/build.gradle +++ b/datastore/datastore-preferences-rxjava3/build.gradle @@ -75,5 +75,4 @@ androidx { inceptionYear = "2020" description = "Android DataStore Core - contains wrappers for using DataStore using RxJava2" legacyDisableKotlinStrictApiMode = true - kotlinTarget = KotlinTarget.KOTLIN_2_2 } diff --git a/datastore/datastore-preferences/build.gradle b/datastore/datastore-preferences/build.gradle index 1193007dc1f61..9a8dcfa47f2cf 100644 --- a/datastore/datastore-preferences/build.gradle +++ b/datastore/datastore-preferences/build.gradle @@ -66,5 +66,4 @@ androidx { inceptionYear = "2020" description = "Android Preferences DataStore" legacyDisableKotlinStrictApiMode = true - kotlinTarget = KotlinTarget.KOTLIN_2_2 } diff --git a/datastore/datastore-rxjava2/build.gradle b/datastore/datastore-rxjava2/build.gradle index a2bf7ffff4703..c5ed453451771 100644 --- a/datastore/datastore-rxjava2/build.gradle +++ b/datastore/datastore-rxjava2/build.gradle @@ -68,5 +68,4 @@ androidx { inceptionYear = "2020" description = "Android DataStore Core - contains wrappers for using DataStore using RxJava2" legacyDisableKotlinStrictApiMode = true - kotlinTarget = KotlinTarget.KOTLIN_2_2 } diff --git a/datastore/datastore-rxjava3/build.gradle b/datastore/datastore-rxjava3/build.gradle index e0a4944febfd0..980139cc79249 100644 --- a/datastore/datastore-rxjava3/build.gradle +++ b/datastore/datastore-rxjava3/build.gradle @@ -69,5 +69,4 @@ androidx { inceptionYear = "2020" description = "Android DataStore Core - contains wrappers for using DataStore using RxJava2" legacyDisableKotlinStrictApiMode = true - kotlinTarget = KotlinTarget.KOTLIN_2_2 } diff --git a/datastore/datastore-tink/build.gradle b/datastore/datastore-tink/build.gradle index b64e6416bb98d..1ba5f715274ac 100644 --- a/datastore/datastore-tink/build.gradle +++ b/datastore/datastore-tink/build.gradle @@ -81,5 +81,4 @@ androidx { type = SoftwareType.PUBLISHED_LIBRARY inceptionYear = "2026" description = "Encryption support for datastore by integrating with the Tink library" - kotlinTarget = KotlinTarget.KOTLIN_2_2 } \ No newline at end of file diff --git a/datastore/datastore/build.gradle b/datastore/datastore/build.gradle index 56f652307d496..2b3bd962a68b4 100644 --- a/datastore/datastore/build.gradle +++ b/datastore/datastore/build.gradle @@ -87,5 +87,4 @@ androidx { description = "Android DataStore - contains the underlying store used by each serialization " + "method along with components that require an Android dependency" legacyDisableKotlinStrictApiMode = true - kotlinTarget = KotlinTarget.KOTLIN_2_2 } diff --git a/docs-public/build.gradle b/docs-public/build.gradle index 03944d9ae2707..abe683c691f5f 100644 --- a/docs-public/build.gradle +++ b/docs-public/build.gradle @@ -260,6 +260,7 @@ dependencies { kmpDocs("androidx.lifecycle:lifecycle-viewmodel-savedstate:2.12.0-alpha04") kmpDocs("androidx.lifecycle:lifecycle-viewmodel-testing:2.12.0-alpha04") docs("androidx.loader:loader:1.2.0") + docs("androidx.media:media:1.8.0") // androidx.media3 is not hosted in androidx docsWithoutApiSince("androidx.media3:media3-cast:1.11.1") docsWithoutApiSince("androidx.media3:media3-common:1.11.1") diff --git a/glance/wear/wear-tooling-preview/api/current.txt b/glance/wear/wear-tooling-preview/api/current.txt index 63dfe6f7a21f9..0b07f86419c65 100644 --- a/glance/wear/wear-tooling-preview/api/current.txt +++ b/glance/wear/wear-tooling-preview/api/current.txt @@ -46,9 +46,9 @@ package androidx.glance.wear.tooling.preview { } public final class WearWidgetPreviewKt { - method @KotlinOnly @androidx.compose.runtime.Composable public static void WearWidgetPreview(androidx.glance.wear.core.WearWidgetParams params, optional androidx.compose.ui.Modifier modifier, optional androidx.glance.wear.WearWidgetBrush background, optional boolean useSafeFallbackRendererVersion, kotlin.jvm.functions.Function0 content); + method @KotlinOnly @androidx.compose.runtime.Composable public static void WearWidgetPreview(androidx.glance.wear.core.WearWidgetParams params, optional androidx.compose.ui.Modifier modifier, optional androidx.glance.wear.WearWidgetBrush background, optional boolean useBaselineHostVersion, kotlin.jvm.functions.Function0 content); method @BytecodeOnly @androidx.compose.runtime.Composable public static void WearWidgetPreview(androidx.glance.wear.core.WearWidgetParams, androidx.compose.ui.Modifier?, androidx.glance.wear.WearWidgetBrush?, boolean, kotlin.jvm.functions.Function2, androidx.compose.runtime.Composer?, int, int); - method @KotlinOnly @androidx.compose.runtime.Composable public static void WearWidgetPreview(androidx.glance.wear.GlanceWearWidget widget, androidx.glance.wear.core.WearWidgetParams params, optional androidx.compose.ui.Modifier modifier, optional boolean useSafeFallbackRendererVersion); + method @KotlinOnly @androidx.compose.runtime.Composable public static void WearWidgetPreview(androidx.glance.wear.GlanceWearWidget widget, androidx.glance.wear.core.WearWidgetParams params, optional androidx.compose.ui.Modifier modifier, optional boolean useBaselineHostVersion); method @BytecodeOnly @androidx.compose.runtime.Composable public static void WearWidgetPreview(androidx.glance.wear.GlanceWearWidget, androidx.glance.wear.core.WearWidgetParams, androidx.compose.ui.Modifier?, boolean, androidx.compose.runtime.Composer?, int, int); } diff --git a/glance/wear/wear-tooling-preview/api/restricted_current.txt b/glance/wear/wear-tooling-preview/api/restricted_current.txt index 63dfe6f7a21f9..0b07f86419c65 100644 --- a/glance/wear/wear-tooling-preview/api/restricted_current.txt +++ b/glance/wear/wear-tooling-preview/api/restricted_current.txt @@ -46,9 +46,9 @@ package androidx.glance.wear.tooling.preview { } public final class WearWidgetPreviewKt { - method @KotlinOnly @androidx.compose.runtime.Composable public static void WearWidgetPreview(androidx.glance.wear.core.WearWidgetParams params, optional androidx.compose.ui.Modifier modifier, optional androidx.glance.wear.WearWidgetBrush background, optional boolean useSafeFallbackRendererVersion, kotlin.jvm.functions.Function0 content); + method @KotlinOnly @androidx.compose.runtime.Composable public static void WearWidgetPreview(androidx.glance.wear.core.WearWidgetParams params, optional androidx.compose.ui.Modifier modifier, optional androidx.glance.wear.WearWidgetBrush background, optional boolean useBaselineHostVersion, kotlin.jvm.functions.Function0 content); method @BytecodeOnly @androidx.compose.runtime.Composable public static void WearWidgetPreview(androidx.glance.wear.core.WearWidgetParams, androidx.compose.ui.Modifier?, androidx.glance.wear.WearWidgetBrush?, boolean, kotlin.jvm.functions.Function2, androidx.compose.runtime.Composer?, int, int); - method @KotlinOnly @androidx.compose.runtime.Composable public static void WearWidgetPreview(androidx.glance.wear.GlanceWearWidget widget, androidx.glance.wear.core.WearWidgetParams params, optional androidx.compose.ui.Modifier modifier, optional boolean useSafeFallbackRendererVersion); + method @KotlinOnly @androidx.compose.runtime.Composable public static void WearWidgetPreview(androidx.glance.wear.GlanceWearWidget widget, androidx.glance.wear.core.WearWidgetParams params, optional androidx.compose.ui.Modifier modifier, optional boolean useBaselineHostVersion); method @BytecodeOnly @androidx.compose.runtime.Composable public static void WearWidgetPreview(androidx.glance.wear.GlanceWearWidget, androidx.glance.wear.core.WearWidgetParams, androidx.compose.ui.Modifier?, boolean, androidx.compose.runtime.Composer?, int, int); } diff --git a/glance/wear/wear-tooling-preview/build.gradle b/glance/wear/wear-tooling-preview/build.gradle index 181f8e3bbdb75..b9cf0d87803fe 100644 --- a/glance/wear/wear-tooling-preview/build.gradle +++ b/glance/wear/wear-tooling-preview/build.gradle @@ -27,8 +27,8 @@ dependencies { api(project(":glance:wear:wear")) api(project(":compose:remote:remote-tooling-preview")) - api("androidx.compose.ui:ui-tooling:1.12.0-beta02") - api("androidx.compose.ui:ui-tooling-preview:1.12.0-beta02") + api("androidx.compose.ui:ui-tooling:1.12.0") + api("androidx.compose.ui:ui-tooling-preview:1.12.0") api("androidx.compose.ui:ui:$composeVersion") api("androidx.compose.runtime:runtime:$composeVersion") diff --git a/glance/wear/wear-tooling-preview/src/main/java/androidx/glance/wear/tooling/preview/WearWidgetPreview.kt b/glance/wear/wear-tooling-preview/src/main/java/androidx/glance/wear/tooling/preview/WearWidgetPreview.kt index 440ed90854f8d..f3efb4cf1aded 100644 --- a/glance/wear/wear-tooling-preview/src/main/java/androidx/glance/wear/tooling/preview/WearWidgetPreview.kt +++ b/glance/wear/wear-tooling-preview/src/main/java/androidx/glance/wear/tooling/preview/WearWidgetPreview.kt @@ -52,21 +52,21 @@ import kotlinx.coroutines.runBlocking * @param modifier The [Modifier] to be applied to the container box hosting the widget preview. * Note that the preview's dimensions are enforced internally based on the provided [params]. * Applying layout-modifying modifiers here might conflict with these internal specifications. - * @param useSafeFallbackRendererVersion Whether to render using a safe fallback renderer version - * (e.g., a conservative baseline version representing older hosts). This allows developers to - * test widget compatibility against older versions of the Wear OS host. If false, the preview - * renders using the latest renderer version. Defaults to false. + * @param useBaselineHostVersion Whether to render using a baseline host version (a foundational, + * definitively supported version representing older hosts). This allows developers to test widget + * compatibility against older versions of the Wear OS host. If false, the preview renders using + * the latest host version. Defaults to false. */ @Composable public fun WearWidgetPreview( widget: GlanceWearWidget, params: WearWidgetParams, modifier: Modifier = Modifier, - useSafeFallbackRendererVersion: Boolean = false, + useBaselineHostVersion: Boolean = false, ) { val context = LocalContext.current val activeRendererVersion = - if (useSafeFallbackRendererVersion) { + if (useBaselineHostVersion) { RendererVersion.SAFE_FALLBACK_VERSION } else { RendererVersion.MAX_RENDERER_VERSION @@ -113,10 +113,10 @@ public fun WearWidgetPreview( * @param modifier The [Modifier] to be applied to the container box hosting the widget preview. * @param background The [WearWidgetBrush] to be used as the background of the widget. Defaults to a * transparent solid color. - * @param useSafeFallbackRendererVersion Whether to render using a safe fallback renderer version - * (e.g., a conservative baseline version representing older hosts). This allows developers to - * test widget compatibility against older versions of the Wear OS host. If false, the preview - * renders using the latest renderer version. Defaults to false. + * @param useBaselineHostVersion Whether to render using a baseline host version (a foundational, + * definitively supported version representing older hosts). This allows developers to test widget + * compatibility against older versions of the Wear OS host. If false, the preview renders using + * the latest host version. Defaults to false. * @param content The [Composable] content of the widget to be previewed. */ @Composable @@ -124,7 +124,7 @@ public fun WearWidgetPreview( params: WearWidgetParams, modifier: Modifier = Modifier, background: WearWidgetBrush = WearWidgetBrush.color(Color.Transparent.rc), - useSafeFallbackRendererVersion: Boolean = false, + useBaselineHostVersion: Boolean = false, content: @RemoteComposable @Composable () -> Unit, ) { val widget = @@ -140,7 +140,7 @@ public fun WearWidgetPreview( widget = widget, params = params, modifier = modifier, - useSafeFallbackRendererVersion = useSafeFallbackRendererVersion, + useBaselineHostVersion = useBaselineHostVersion, ) } diff --git a/glance/wear/wear/src/main/java/androidx/glance/wear/GlanceWearWidget.kt b/glance/wear/wear/src/main/java/androidx/glance/wear/GlanceWearWidget.kt index eceba419df1ba..9105a16254154 100644 --- a/glance/wear/wear/src/main/java/androidx/glance/wear/GlanceWearWidget.kt +++ b/glance/wear/wear/src/main/java/androidx/glance/wear/GlanceWearWidget.kt @@ -154,6 +154,9 @@ internal constructor( * by the calling application. */ public suspend fun triggerUpdate(context: Context, instanceId: WidgetInstanceId) { + if (context.isDebuggableBuild()) { + updateClient.sendUpdateBroadcast(context, instanceId = instanceId) + } triggerUpdateInternal(context, instanceId, cachedHandle = null) } @@ -168,18 +171,25 @@ internal constructor( */ @SuppressLint("ListIterator") // Not running inside Compose code. public suspend fun triggerUpdateAll(context: Context) { - // In debugging mode (such as Emulator), we would always trigger a pull update instead of - // trying to use push mechanism. - if (context.isDebuggingEnabled()) { - GlanceWearWidgetManager(context).getProviderForWidget(this::class)?.let { - triggerPullUpdate(context, it, instanceId = null) - return@triggerUpdateAll + val isDebuggable = context.isDebuggableBuild() + val isDeveloperMode = context.isDeveloperModeEnabled() + if (isDebuggable || isDeveloperMode) { + GlanceWearWidgetManager(context).getProviderForWidget(this::class)?.let { provider -> + if (isDebuggable) { + updateClient.sendUpdateBroadcast(context, provider = provider) + } + // In developer mode (such as Emulator), we would always trigger a pull update + // instead of trying to use push mechanism. + if (isDeveloperMode) { + triggerPullUpdate(context, provider, instanceId = null) + return@triggerUpdateAll + } } } val activeWidgets = fetchActiveWidgets(context) if (activeWidgets.isEmpty()) { - Log.i(TAG, "No active instances found to update.") + Log.i(TAG, "No active instances found in the system to update.") return } coroutineScope { @@ -203,11 +213,7 @@ internal constructor( instanceId: WidgetInstanceId, cachedHandle: ActiveWearWidgetHandle? = null, ) { - if (context.isDebuggableBuild()) { - updateClient.sendUpdateBroadcast(context, instanceId = instanceId) - } - - if (context.isDebuggingEnabled()) { + if (context.isDeveloperModeEnabled()) { GlanceWearWidgetManager(context).getProviderForWidget(this::class)?.let { triggerPullUpdate(context, it, instanceId) return@triggerUpdateInternal @@ -289,12 +295,12 @@ internal constructor( (this.applicationInfo.flags and ApplicationInfo.FLAG_DEBUGGABLE) != 0 /** - * Returns whether debugging is enabled for the device. + * Returns whether developer mode is enabled for the device. * - * Debugging is enabled if the device is an emulator or if the developer settings are + * Developer mode is enabled if the device is an emulator or if the developer settings are * enabled. */ - internal fun Context.isDebuggingEnabled(): Boolean = + internal fun Context.isDeveloperModeEnabled(): Boolean = isEmulator() || Settings.Global.getInt( contentResolver, diff --git a/glance/wear/wear/src/main/java/androidx/glance/wear/GlanceWearWidgetManager.kt b/glance/wear/wear/src/main/java/androidx/glance/wear/GlanceWearWidgetManager.kt index 3976a9441330f..7ea129acf1f19 100644 --- a/glance/wear/wear/src/main/java/androidx/glance/wear/GlanceWearWidgetManager.kt +++ b/glance/wear/wear/src/main/java/androidx/glance/wear/GlanceWearWidgetManager.kt @@ -131,9 +131,10 @@ public class GlanceWearWidgetManager { public suspend fun fetchActiveWidgets( widget: KClass ): List { - val serviceToWidgetMapping = state.getServiceToWidgetMapping() + val targetName = widget.qualifiedName() + val serviceToWidgetMapping = state.getServiceToWidgetMapping(targetName) return fetchActiveWidgets().filter { - serviceToWidgetMapping[it.provider] == widget.qualifiedName + serviceToWidgetMapping[it.provider] == targetName } } @@ -149,8 +150,8 @@ public class GlanceWearWidgetManager { internal suspend fun getProviderForWidget( widgetClass: KClass ): ComponentName? { - val serviceToWidgetMapping = state.getServiceToWidgetMapping() val targetName = widgetClass.qualifiedName() + val serviceToWidgetMapping = state.getServiceToWidgetMapping(targetName) return serviceToWidgetMapping.entries.firstOrNull { it.value == targetName }?.key } @@ -193,10 +194,16 @@ public class GlanceWearWidgetManager { * [GlanceWearWidget]. */ private class State(private val context: Context, private val widgetCache: WearWidgetCache) { - suspend fun getServiceToWidgetMapping(): Map { + suspend fun getServiceToWidgetMapping( + targetWidgetName: String + ): Map { + val cachedMapping = widgetCache.getServiceToWidgetMapping() val mapping = - widgetCache.getServiceToWidgetMapping().takeIf { it.isNotEmpty() } - ?: recoverServiceToWidgetMapping() + if (cachedMapping.containsValue(targetWidgetName)) { + cachedMapping + } else { + cachedMapping + recoverServiceToWidgetMapping() + } return mapping.mapKeys { (serviceName, _) -> ComponentName(context, serviceName) } } diff --git a/glance/wear/wear/src/main/java/androidx/glance/wear/parcel/WidgetUpdateClientImpl.kt b/glance/wear/wear/src/main/java/androidx/glance/wear/parcel/WidgetUpdateClientImpl.kt index cbf7ef25736a6..30cd4e1acc62a 100644 --- a/glance/wear/wear/src/main/java/androidx/glance/wear/parcel/WidgetUpdateClientImpl.kt +++ b/glance/wear/wear/src/main/java/androidx/glance/wear/parcel/WidgetUpdateClientImpl.kt @@ -65,6 +65,10 @@ internal class WidgetUpdateClientImpl( provider: ComponentName?, instanceId: WidgetInstanceId?, ) { + Log.d( + TAG, + "Broadcasting an update request to the widget tray emulator (provider=$provider, instanceId=$instanceId)", + ) val intent = Intent(ACTION_REQUEST_TILE_UPDATE_BROADCAST_LEGACY).apply { provider?.let { putExtra(Intent.EXTRA_COMPONENT_NAME, it) } diff --git a/glance/wear/wear/src/test/java/androidx/glance/wear/GlanceWearWidgetManagerTest.kt b/glance/wear/wear/src/test/java/androidx/glance/wear/GlanceWearWidgetManagerTest.kt index ba3aa272a6227..df63f93997a2e 100644 --- a/glance/wear/wear/src/test/java/androidx/glance/wear/GlanceWearWidgetManagerTest.kt +++ b/glance/wear/wear/src/test/java/androidx/glance/wear/GlanceWearWidgetManagerTest.kt @@ -128,7 +128,7 @@ class GlanceWearWidgetManagerTest { executor.execute { outcomeReceiver.onError(RuntimeException()) } } - val unused = widgetManager.fetchActiveWidgets() + widgetManager.fetchActiveWidgets() } @Test @@ -376,6 +376,67 @@ class GlanceWearWidgetManagerTest { val widgets = widgetManager.fetchActiveWidgets(TestWidget1::class) assertThat(widgets).isEmpty() } + + @Test + fun getProviderForWidget_whenCacheHasOtherWidget_recoversMissingWidgetFromPackageManager() = + runTest { + whenever(widgetCache.getServiceToWidgetMapping()) + .thenReturn( + mapOf( + TestWidgetService1::class.java.name to + TestWidget1::class.java.canonicalName!! + ) + ) + + val shadowPackageManager = Shadows.shadowOf(context.packageManager) + val filter = IntentFilter(WearWidgetProviderInfo.ACTION_BIND_WIDGET_PROVIDER) + shadowPackageManager.addServiceIfNotPresent(componentLarge) + shadowPackageManager.addIntentFilterForService(componentLarge, filter) + + val provider = widgetManager.getProviderForWidget(TestWidget2::class) + + assertThat(provider).isEqualTo(componentLarge) + verify(widgetCache).update(any()) + } + + @Test + @Config(minSdk = Build.VERSION_CODES.UPSIDE_DOWN_CAKE) + fun fetchActiveWidgets_withClassArg_whenCacheHasOtherWidget_recoversMissingWidgetFromPackageManager() = + runTest { + whenever(tilesManager.getActiveTiles(any(), any())).thenAnswer { invocationOnMock -> + val executor = invocationOnMock.getArgument(0) + val outcomeReceiver = + invocationOnMock.getArgument, Exception>>(1) + executor.execute { + outcomeReceiver.onResult(listOf(tileInstanceFullScreen, tileInstanceLarge)) + } + } + whenever(widgetCache.getServiceToWidgetMapping()) + .thenReturn( + mapOf( + TestWidgetService1::class.java.name to + TestWidget1::class.java.canonicalName!! + ) + ) + + val shadowPackageManager = Shadows.shadowOf(context.packageManager) + val filter = IntentFilter(WearWidgetProviderInfo.ACTION_BIND_WIDGET_PROVIDER) + shadowPackageManager.addServiceIfNotPresent(componentLarge) + shadowPackageManager.addIntentFilterForService(componentLarge, filter) + + val widgets = widgetManager.fetchActiveWidgets(TestWidget2::class) + + assertThat(widgets) + .containsExactly( + ActiveWearWidgetHandle( + provider = componentLarge, + instanceId = + WidgetInstanceId(WidgetInstanceId.WIDGET_CAROUSEL_NAMESPACE, 2), + containerType = ContainerInfo.CONTAINER_TYPE_LARGE, + ) + ) + verify(widgetCache).update(any()) + } } private open class TestWidget1 : GlanceWearWidget() { diff --git a/glance/wear/wear/src/test/java/androidx/glance/wear/GlanceWearWidgetTest.kt b/glance/wear/wear/src/test/java/androidx/glance/wear/GlanceWearWidgetTest.kt index 5d93f074d339f..2a477a1243e8d 100644 --- a/glance/wear/wear/src/test/java/androidx/glance/wear/GlanceWearWidgetTest.kt +++ b/glance/wear/wear/src/test/java/androidx/glance/wear/GlanceWearWidgetTest.kt @@ -55,7 +55,84 @@ class GlanceWearWidgetTest { } @Test - fun triggerUpdate_debuggable_sendsUpdateBroadcast() = runTest { + fun triggerUpdate_debuggableAndDevSettings_sendsBroadcastAndPullsUpdate() = runTest { + withForceAtLeast37 { + val mockUpdateClient = mock() + val mockWidgetCache = mock() + val handle = + ActiveWearWidgetHandle( + provider = TEST_COMPONENT, + instanceId = TEST_INSTANCE_ID, + containerType = ContainerInfo.CONTAINER_TYPE_SMALL, + ) + val widget = + TestWidget(mockUpdateClient, mockWidgetCache, activeWidgets = listOf(handle)) + val context = getApplicationContext() + val testComponent = ComponentName(context, TEST_COMPONENT.className) + + whenever(mockWidgetCache.getContainerTypeForInstance(eq(TEST_INSTANCE_ID))) + .thenReturn(ContainerInfo.CONTAINER_TYPE_SMALL) + whenever( + mockWidgetCache.getWidgetParams( + eq(ContainerInfo.CONTAINER_TYPE_SMALL), + eq(TEST_INSTANCE_ID), + ) + ) + .thenReturn(testWidgetParams(TEST_INSTANCE_ID)) + WearWidgetCache(context).update { + putServiceToWidgetMapping( + testComponent.className, + TestWidget::class.java.canonicalName!!, + ) + } + + withDebuggableBuild(context, debuggable = true) { + withDevelopmentSettingsEnabled(context, enabled = true) { + widget.triggerUpdate(context, TEST_INSTANCE_ID) + + verify(mockUpdateClient) + .sendUpdateBroadcast(any(), eq(null), eq(TEST_INSTANCE_ID)) + verify(mockUpdateClient) + .requestUpdate(any(), eq(testComponent), eq(TEST_INSTANCE_ID)) + verify(mockUpdateClient, never()).pushUpdate(any(), any(), any()) + } + } + } + } + + @Test + fun triggerUpdate_debuggableAndEmulator_sendsBroadcastAndPullsUpdate() = runTest { + withForceAtLeast37 { + val mockUpdateClient = mock() + val widget = TestWidget(mockUpdateClient, activeWidgets = emptyList()) + val context = getApplicationContext() + val testComponent = ComponentName(context, TEST_COMPONENT.className) + + WearWidgetCache(context).update { + putServiceToWidgetMapping( + testComponent.className, + TestWidget::class.java.canonicalName!!, + ) + } + + withDebuggableBuild(context, debuggable = true) { + withDevelopmentSettingsEnabled(context, enabled = false) { + withHardware("ranchu") { + widget.triggerUpdate(context, TEST_INSTANCE_ID) + + verify(mockUpdateClient) + .sendUpdateBroadcast(any(), eq(null), eq(TEST_INSTANCE_ID)) + verify(mockUpdateClient) + .requestUpdate(any(), eq(testComponent), eq(TEST_INSTANCE_ID)) + verify(mockUpdateClient, never()).pushUpdate(any(), any(), any()) + } + } + } + } + } + + @Test + fun triggerUpdate_debuggableOnly_sendsBroadcastAndPushesUpdate() = runTest { withForceAtLeast37 { val mockUpdateClient = mock() val mockWidgetCache = mock() @@ -70,12 +147,17 @@ class GlanceWearWidgetTest { ) .thenReturn(testWidgetParams(TEST_INSTANCE_ID)) val context = getApplicationContext() - context.applicationInfo.flags = - context.applicationInfo.flags or android.content.pm.ApplicationInfo.FLAG_DEBUGGABLE - widget.triggerUpdate(context, TEST_INSTANCE_ID) + withDebuggableBuild(context, debuggable = true) { + withDevelopmentSettingsEnabled(context, enabled = false) { + widget.triggerUpdate(context, TEST_INSTANCE_ID) - verify(mockUpdateClient).sendUpdateBroadcast(any(), eq(null), eq(TEST_INSTANCE_ID)) + verify(mockUpdateClient) + .sendUpdateBroadcast(any(), eq(null), eq(TEST_INSTANCE_ID)) + verify(mockUpdateClient).pushUpdate(eq(context), any(), any()) + verify(mockUpdateClient, never()).requestUpdate(any(), any(), any()) + } + } } } @@ -250,19 +332,40 @@ class GlanceWearWidgetTest { fun triggerUpdate_inDebugEnv_pullsUpdate() = runTest { withForceAtLeast37 { val mockUpdateClient = mock() + val mockWidgetCache = mock() val handle = ActiveWearWidgetHandle( provider = TEST_COMPONENT, instanceId = TEST_INSTANCE_ID, containerType = ContainerInfo.CONTAINER_TYPE_SMALL, ) - val widget = TestWidget(mockUpdateClient, activeWidgets = listOf(handle)) + val widget = + TestWidget(mockUpdateClient, mockWidgetCache, activeWidgets = listOf(handle)) val context = getApplicationContext() + val testComponent = ComponentName(context, TEST_COMPONENT.className) + + whenever(mockWidgetCache.getContainerTypeForInstance(eq(TEST_INSTANCE_ID))) + .thenReturn(ContainerInfo.CONTAINER_TYPE_SMALL) + whenever( + mockWidgetCache.getWidgetParams( + eq(ContainerInfo.CONTAINER_TYPE_SMALL), + eq(TEST_INSTANCE_ID), + ) + ) + .thenReturn(testWidgetParams(TEST_INSTANCE_ID)) + WearWidgetCache(context).update { + putServiceToWidgetMapping( + testComponent.className, + TestWidget::class.java.canonicalName!!, + ) + } withDevelopmentSettingsEnabled(context) { widget.triggerUpdate(context, TEST_INSTANCE_ID) - verify(mockUpdateClient).requestUpdate(any(), any(), eq(TEST_INSTANCE_ID)) + verify(mockUpdateClient, never()).sendUpdateBroadcast(any(), any(), any()) + verify(mockUpdateClient) + .requestUpdate(any(), eq(testComponent), eq(TEST_INSTANCE_ID)) verify(mockUpdateClient, never()).pushUpdate(any(), any(), any()) } } @@ -287,6 +390,7 @@ class GlanceWearWidgetTest { withDevelopmentSettingsEnabled(context) { widget.triggerUpdate(context, TEST_INSTANCE_ID) + verify(mockUpdateClient, never()).sendUpdateBroadcast(any(), any(), any()) verify(mockUpdateClient) .requestUpdate(any(), eq(testComponent), eq(TEST_INSTANCE_ID)) verify(mockUpdateClient, never()).pushUpdate(any(), any(), any()) @@ -313,18 +417,170 @@ class GlanceWearWidgetTest { withDevelopmentSettingsEnabled(context) { widget.triggerUpdateAll(context) + verify(mockUpdateClient, never()).sendUpdateBroadcast(any(), any(), any()) verify(mockUpdateClient).requestUpdate(any(), eq(testComponent), eq(null)) } } + @Test + fun triggerUpdateAll_debuggableAndDevSettings_sendsBroadcastAndPullsUpdate() = runTest { + withForceAtLeast37 { + val mockUpdateClient = mock() + val mockWidgetCache = mock() + val handle = + ActiveWearWidgetHandle( + provider = TEST_COMPONENT, + instanceId = TEST_INSTANCE_ID, + containerType = ContainerInfo.CONTAINER_TYPE_SMALL, + ) + val widget = + TestWidget(mockUpdateClient, mockWidgetCache, activeWidgets = listOf(handle)) + val context = getApplicationContext() + + whenever(mockWidgetCache.getContainerTypeForInstance(eq(TEST_INSTANCE_ID))) + .thenReturn(ContainerInfo.CONTAINER_TYPE_SMALL) + whenever( + mockWidgetCache.getWidgetParams( + eq(ContainerInfo.CONTAINER_TYPE_SMALL), + eq(TEST_INSTANCE_ID), + ) + ) + .thenReturn(testWidgetParams(TEST_INSTANCE_ID)) + val cache = WearWidgetCache(context) + val testComponent = ComponentName(context, TEST_COMPONENT.className) + cache.update { + putServiceToWidgetMapping( + testComponent.className, + TestWidget::class.java.canonicalName!!, + ) + } + + withDebuggableBuild(context, debuggable = true) { + withDevelopmentSettingsEnabled(context, enabled = true) { + widget.triggerUpdateAll(context) + + verify(mockUpdateClient).sendUpdateBroadcast(any(), eq(testComponent), eq(null)) + verify(mockUpdateClient).requestUpdate(any(), eq(testComponent), eq(null)) + verify(mockUpdateClient, never()).pushUpdate(any(), any(), any()) + } + } + } + } + + @Test + fun triggerUpdateAll_debuggableAndEmulator_sendsBroadcastAndPullsUpdate() = runTest { + withForceAtLeast37 { + val mockUpdateClient = mock() + val widget = TestWidget(mockUpdateClient, activeWidgets = emptyList()) + val context = getApplicationContext() + + val cache = WearWidgetCache(context) + val testComponent = ComponentName(context, TEST_COMPONENT.className) + cache.update { + putServiceToWidgetMapping( + testComponent.className, + TestWidget::class.java.canonicalName!!, + ) + } + + withDebuggableBuild(context, debuggable = true) { + withDevelopmentSettingsEnabled(context, enabled = false) { + withHardware("ranchu") { + widget.triggerUpdateAll(context) + + verify(mockUpdateClient) + .sendUpdateBroadcast(any(), eq(testComponent), eq(null)) + verify(mockUpdateClient).requestUpdate(any(), eq(testComponent), eq(null)) + verify(mockUpdateClient, never()).pushUpdate(any(), any(), any()) + } + } + } + } + } + + @Test + fun triggerUpdateAll_debuggableOnly_sendsBroadcastAndPushesUpdate() = runTest { + withForceAtLeast37 { + val mockUpdateClient = mock() + val mockWidgetCache = mock() + val handle = + ActiveWearWidgetHandle( + provider = TEST_COMPONENT, + instanceId = TEST_INSTANCE_ID, + containerType = ContainerInfo.CONTAINER_TYPE_SMALL, + ) + val widget = + TestWidget(mockUpdateClient, mockWidgetCache, activeWidgets = listOf(handle)) + val context = getApplicationContext() + + whenever(mockWidgetCache.getContainerTypeForInstance(eq(TEST_INSTANCE_ID))) + .thenReturn(ContainerInfo.CONTAINER_TYPE_SMALL) + whenever( + mockWidgetCache.getWidgetParams( + eq(ContainerInfo.CONTAINER_TYPE_SMALL), + eq(TEST_INSTANCE_ID), + ) + ) + .thenReturn(testWidgetParams(TEST_INSTANCE_ID)) + val cache = WearWidgetCache(context) + val testComponent = ComponentName(context, TEST_COMPONENT.className) + cache.update { + putServiceToWidgetMapping( + testComponent.className, + TestWidget::class.java.canonicalName!!, + ) + } + + withDebuggableBuild(context, debuggable = true) { + withDevelopmentSettingsEnabled(context, enabled = false) { + widget.triggerUpdateAll(context) + + verify(mockUpdateClient).sendUpdateBroadcast(any(), eq(testComponent), eq(null)) + verify(mockUpdateClient, never()).sendUpdateBroadcast(any(), eq(null), any()) + verify(mockUpdateClient) + .pushUpdate( + eq(context), + argThat { instanceId == TEST_INSTANCE_ID }, + any(), + ) + verify(mockUpdateClient, never()).requestUpdate(any(), any(), any()) + } + } + } + } + + private suspend fun withDebuggableBuild( + context: Context, + debuggable: Boolean, + block: suspend () -> Unit, + ) { + val originalFlags = context.applicationInfo.flags + context.applicationInfo.flags = + if (debuggable) { + originalFlags or android.content.pm.ApplicationInfo.FLAG_DEBUGGABLE + } else { + originalFlags and android.content.pm.ApplicationInfo.FLAG_DEBUGGABLE.inv() + } + try { + block() + } finally { + context.applicationInfo.flags = originalFlags + } + } + private suspend fun withDevelopmentSettingsEnabled( context: Context, + enabled: Boolean = true, block: suspend () -> Unit, ) { val contentResolver = context.contentResolver val originalValue = Settings.Global.getInt(contentResolver, Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0) - Settings.Global.putInt(contentResolver, Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 1) + Settings.Global.putInt( + contentResolver, + Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, + if (enabled) 1 else 0, + ) try { block() } finally { @@ -336,6 +592,24 @@ class GlanceWearWidgetTest { } } + private suspend fun withHardware(hardware: String, block: suspend () -> Unit) { + val originalHardware = android.os.Build.HARDWARE + org.robolectric.util.ReflectionHelpers.setStaticField( + android.os.Build::class.java, + "HARDWARE", + hardware, + ) + try { + block() + } finally { + org.robolectric.util.ReflectionHelpers.setStaticField( + android.os.Build::class.java, + "HARDWARE", + originalHardware, + ) + } + } + private class TestWidget( updateClient: WidgetUpdateClient, widgetCache: WearWidgetCache? = null, diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 44ba793c92f60..410a0ee9ac937 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -66,7 +66,7 @@ kotlinCoroutines = "1.9.0" kotlinNativeUtils = "1.9.24" kotlinSerialization = "1.7.3" kotlinToolingCore = "1.9.24" -ksp = "2.3.11" +ksp = "2.3.12" ktfmt = "0.64" # Version format is: 1.KOTLIN_MAJOR_VERSION.0.KTFMT_VERSION # When updated, the id and checksum in StudioTask needs to be updated too diff --git a/health/connect/connect-client/build.gradle b/health/connect/connect-client/build.gradle index 3753dbd036a44..d41158037dd3f 100644 --- a/health/connect/connect-client/build.gradle +++ b/health/connect/connect-client/build.gradle @@ -78,7 +78,6 @@ androidx { type = SoftwareType.PUBLISHED_LIBRARY inceptionYear = "2022" description = "read or write user's health and fitness records." - legacyDisableKotlinStrictApiMode = true samples(project(":health:connect:connect-client-samples")) enableRobolectric() } diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/HealthConnectClient.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/HealthConnectClient.kt index bcfddb83fbbb9..11fcf878f5b17 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/HealthConnectClient.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/HealthConnectClient.kt @@ -89,13 +89,13 @@ import kotlin.reflect.KClass @JvmDefaultWithCompatibility /** Interface to access health and fitness records. */ -interface HealthConnectClient { +public interface HealthConnectClient { /** Access operations related to permissions. */ - val permissionController: PermissionController + public val permissionController: PermissionController /** Access operations related to feature availability. */ - val features: HealthConnectFeatures + public val features: HealthConnectFeatures get() = HealthConnectFeaturesUnavailableImpl /** @@ -129,7 +129,7 @@ interface HealthConnectClient { * [androidx.health.connect.client.records.metadata.Metadata.clientRecordVersion] takes * precedence. */ - suspend fun insertRecords(records: List): InsertRecordsResponse + public suspend fun insertRecords(records: List): InsertRecordsResponse /** * Updates one or more [Record] of given UIDs to newly specified values. Update of multiple @@ -141,7 +141,7 @@ interface HealthConnectClient { * @throws SecurityException For requests with unpermitted access. * @throws java.io.IOException For any disk I/O issues. */ - suspend fun updateRecords(records: List) + public suspend fun updateRecords(records: List) /** * Deletes one or more [Record] by their identifiers. Deletion of multiple [Record] is executed @@ -161,7 +161,7 @@ interface HealthConnectClient { * * @sample androidx.health.connect.client.samples.DeleteByUniqueIdentifier */ - suspend fun deleteRecords( + public suspend fun deleteRecords( recordType: KClass, recordIdsList: List, clientRecordIdsList: List, @@ -182,7 +182,10 @@ interface HealthConnectClient { * * @sample androidx.health.connect.client.samples.DeleteByTimeRange */ - suspend fun deleteRecords(recordType: KClass, timeRangeFilter: TimeRangeFilter) + public suspend fun deleteRecords( + recordType: KClass, + timeRangeFilter: TimeRangeFilter, + ) /** * Reads one [Record] point with its [recordType] and [recordId]. @@ -196,7 +199,7 @@ interface HealthConnectClient { * @throws SecurityException For requests with unpermitted access. * @throws java.io.IOException For any disk I/O issues. */ - suspend fun readRecord( + public suspend fun readRecord( recordType: KClass, recordId: String, ): ReadRecordResponse @@ -215,7 +218,9 @@ interface HealthConnectClient { * * @sample androidx.health.connect.client.samples.ReadStepsRange */ - suspend fun readRecords(request: ReadRecordsRequest): ReadRecordsResponse + public suspend fun readRecords( + request: ReadRecordsRequest + ): ReadRecordsResponse /** * Reads [AggregateMetric]s according to requested read criteria: [Record]s from @@ -236,7 +241,7 @@ interface HealthConnectClient { * * @sample androidx.health.connect.client.samples.AggregateHeartRate */ - suspend fun aggregate(request: AggregateRequest): AggregationResult + public suspend fun aggregate(request: AggregateRequest): AggregationResult /** * Reads [AggregateMetric]s according to requested read criteria specified in @@ -261,7 +266,7 @@ interface HealthConnectClient { * * @sample androidx.health.connect.client.samples.AggregateIntoMinutes */ - suspend fun aggregateGroupByDuration( + public suspend fun aggregateGroupByDuration( request: AggregateGroupByDurationRequest ): List @@ -288,7 +293,7 @@ interface HealthConnectClient { * * @sample androidx.health.connect.client.samples.AggregateIntoMonths */ - suspend fun aggregateGroupByPeriod( + public suspend fun aggregateGroupByPeriod( request: AggregateGroupByPeriodRequest ): List @@ -309,7 +314,7 @@ interface HealthConnectClient { * @throws SecurityException For requests with unpermitted access. * @see getChanges */ - suspend fun getChangesToken(request: ChangesTokenRequest): String + public suspend fun getChangesToken(request: ChangesTokenRequest): String /** * Retrieves changes in Health Connect, from a specific point in time represented by provided @@ -339,7 +344,7 @@ interface HealthConnectClient { * @throws SecurityException For requests with unpermitted access. * @see getChangesToken */ - suspend fun getChanges(changesToken: String): ChangesResponse + public suspend fun getChanges(changesToken: String): ChangesResponse /** * Same as [getChanges] method but also allows specifying a preferred [pageSize]. @@ -356,7 +361,7 @@ interface HealthConnectClient { * @throws SecurityException For requests with unpermitted access. * @see getChangesToken */ - suspend fun getChanges( + public suspend fun getChanges( changesToken: String, @IntRange(from = 1, to = 5000) pageSize: Int, ): ChangesResponse @@ -421,7 +426,7 @@ interface HealthConnectClient { */ @RequiresPermission("android.permission.health.WRITE_MEDICAL_DATA") @ExperimentalPersonalHealthRecordApi - suspend fun upsertMedicalResources( + public suspend fun upsertMedicalResources( requests: List ): List = throw createExceptionDueToFeatureUnavailable( @@ -468,7 +473,7 @@ interface HealthConnectClient { * @sample androidx.health.connect.client.samples.ReadMedicalResourcesByRequestSample */ @ExperimentalPersonalHealthRecordApi - suspend fun readMedicalResources( + public suspend fun readMedicalResources( request: ReadMedicalResourcesRequest ): ReadMedicalResourcesResponse = throw createExceptionDueToFeatureUnavailable( @@ -512,7 +517,7 @@ interface HealthConnectClient { * @sample androidx.health.connect.client.samples.ReadMedicalResourcesByIdsSample */ @ExperimentalPersonalHealthRecordApi - suspend fun readMedicalResources(ids: List): List = + public suspend fun readMedicalResources(ids: List): List = throw createExceptionDueToFeatureUnavailable( FEATURE_CONSTANT_NAME_PHR, "HealthConnectClient#readMedicalResources(ids: List)", @@ -542,7 +547,7 @@ interface HealthConnectClient { */ @RequiresPermission("android.permission.health.WRITE_MEDICAL_DATA") @ExperimentalPersonalHealthRecordApi - suspend fun deleteMedicalResources(ids: List): Unit = + public suspend fun deleteMedicalResources(ids: List): Unit = throw createExceptionDueToFeatureUnavailable( FEATURE_CONSTANT_NAME_PHR, "HealthConnectClient#deleteMedicalResources(ids: List)", @@ -570,7 +575,7 @@ interface HealthConnectClient { */ @RequiresPermission("android.permission.health.WRITE_MEDICAL_DATA") @ExperimentalPersonalHealthRecordApi - suspend fun deleteMedicalResources(request: DeleteMedicalResourcesRequest): Unit = + public suspend fun deleteMedicalResources(request: DeleteMedicalResourcesRequest): Unit = throw createExceptionDueToFeatureUnavailable( FEATURE_CONSTANT_NAME_PHR, "HealthConnectClient#deleteMedicalResources(request: DeleteMedicalResourcesRequest)", @@ -611,7 +616,7 @@ interface HealthConnectClient { */ @ExperimentalPersonalHealthRecordApi @RequiresPermission("android.permission.health.WRITE_MEDICAL_DATA") - suspend fun createMedicalDataSource( + public suspend fun createMedicalDataSource( request: CreateMedicalDataSourceRequest ): MedicalDataSource { throw createExceptionDueToFeatureUnavailable( @@ -644,7 +649,7 @@ interface HealthConnectClient { */ @ExperimentalPersonalHealthRecordApi @RequiresPermission("android.permission.health.WRITE_MEDICAL_DATA") - suspend fun deleteMedicalDataSourceWithData(id: String) { + public suspend fun deleteMedicalDataSourceWithData(id: String) { throw createExceptionDueToFeatureUnavailable( FEATURE_CONSTANT_NAME_PHR, "HealthConnectClient#deleteMedicalDataSourceWithData()", @@ -694,7 +699,7 @@ interface HealthConnectClient { * @sample androidx.health.connect.client.samples.GetMedicalDataSourcesByRequestSample */ @ExperimentalPersonalHealthRecordApi - suspend fun getMedicalDataSources( + public suspend fun getMedicalDataSources( request: GetMedicalDataSourcesRequest ): List { throw createExceptionDueToFeatureUnavailable( @@ -747,7 +752,7 @@ interface HealthConnectClient { * @sample androidx.health.connect.client.samples.GetMedicalDataSourcesByIdsSample */ @ExperimentalPersonalHealthRecordApi - suspend fun getMedicalDataSources(ids: List): List { + public suspend fun getMedicalDataSources(ids: List): List { throw createExceptionDueToFeatureUnavailable( FEATURE_CONSTANT_NAME_PHR, "HealthConnectClient#getMedicalDataSources()", @@ -773,7 +778,9 @@ interface HealthConnectClient { * [UnsupportedOperationException] would be thrown if the feature is not available. */ @ExperimentalMatchmakingApi - suspend fun checkIfMatchmakingIsPossible(request: MatchmakingRequest): MatchmakingResponse { + public suspend fun checkIfMatchmakingIsPossible( + request: MatchmakingRequest + ): MatchmakingResponse { throw createExceptionDueToFeatureUnavailable( FEATURE_CONSTANT_NAME_MATCHMAKING, "HealthConnectClient#checkIfMatchmakingIsPossible()", @@ -837,7 +844,7 @@ interface HealthConnectClient { * [HealthConnectFeatures.FEATURE_MATCHMAKING] as an argument. */ @ExperimentalMatchmakingApi - fun createMatchmakingIntent(request: MatchmakingRequest): Intent { + public fun createMatchmakingIntent(request: MatchmakingRequest): Intent { throw createExceptionDueToFeatureUnavailable( FEATURE_CONSTANT_NAME_MATCHMAKING, "HealthConnectClient#createMatchmakingIntent()", @@ -860,7 +867,7 @@ interface HealthConnectClient { * @throws UnsupportedOperationException if the feature is not available */ @ExperimentalDeviceDataSourceApi - suspend fun getDeviceDataSources(): GetDeviceDataSourcesResponse { + public suspend fun getDeviceDataSources(): GetDeviceDataSourcesResponse { throw createExceptionDueToFeatureUnavailable( FEATURE_CONSTANT_NAME_DEVICE_DATA_PROVIDERS, "HealthConnectClient#getDeviceDataSources()", @@ -882,7 +889,7 @@ interface HealthConnectClient { * @throws SecurityException if the caller does not hold at least one read permission */ @ExperimentalDeviceDataSourceApi - suspend fun getCurrentDeviceDataSource(): DeviceDataSource { + public suspend fun getCurrentDeviceDataSource(): DeviceDataSource { throw createExceptionDueToFeatureUnavailable( FEATURE_CONSTANT_NAME_DEVICE_DATA_PROVIDERS, "HealthConnectClient#getCurrentDeviceDataSource()", @@ -908,31 +915,31 @@ interface HealthConnectClient { * @throws UnsupportedOperationException if the feature is not available */ @ExperimentalDeviceDataSourceApi - suspend fun getDeviceDataSourceCapabilities(): DeviceDataSourceCapabilities { + public suspend fun getDeviceDataSourceCapabilities(): DeviceDataSourceCapabilities { throw createExceptionDueToFeatureUnavailable( FEATURE_CONSTANT_NAME_DEVICE_DATA_PROVIDERS, "HealthConnectClient#getDeviceDataSourceCapabilities()", ) } - companion object { + public companion object { /** * Intent action to open Health Connect settings on this phone. Developers should use this * if they want to re-direct the user to Health Connect. */ @get:JvmName("getHealthConnectSettingsAction") @JvmStatic - val ACTION_HEALTH_CONNECT_SETTINGS = + public val ACTION_HEALTH_CONNECT_SETTINGS: String = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) "android.health.connect.action.HEALTH_HOME_SETTINGS" else "androidx.health.ACTION_HEALTH_CONNECT_SETTINGS" - internal val ACTION_HEALTH_CONNECT_MANAGE_DATA = + internal val ACTION_HEALTH_CONNECT_MANAGE_DATA: String = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) "android.health.connect.action.MANAGE_HEALTH_DATA" else "androidx.health.ACTION_MANAGE_HEALTH_DATA" - internal val ACTION_HEALTH_CONNECT_MATCHMAKING = + internal val ACTION_HEALTH_CONNECT_MATCHMAKING: String = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) "android.health.connect.action.MATCHMAKING" else "" @@ -943,7 +950,7 @@ interface HealthConnectClient { * * Apps should hide any integration points to Health Connect in this case. */ - const val SDK_UNAVAILABLE = 1 + public const val SDK_UNAVAILABLE: Int = 1 /** * The Health Connect SDK APIs are currently unavailable, the provider is either not @@ -951,20 +958,20 @@ interface HealthConnectClient { * * Apps may choose to redirect to package installers to find a suitable APK. */ - const val SDK_UNAVAILABLE_PROVIDER_UPDATE_REQUIRED = 2 + public const val SDK_UNAVAILABLE_PROVIDER_UPDATE_REQUIRED: Int = 2 /** * The Health Connect SDK APIs are available. * * Apps can subsequently call [getOrCreate] to get an instance of [HealthConnectClient]. */ - const val SDK_AVAILABLE = 3 + public const val SDK_AVAILABLE: Int = 3 /** Availability Status. */ @Retention(AnnotationRetention.SOURCE) @RestrictTo(RestrictTo.Scope.LIBRARY) @IntDef(value = [SDK_UNAVAILABLE, SDK_UNAVAILABLE_PROVIDER_UPDATE_REQUIRED, SDK_AVAILABLE]) - annotation class AvailabilityStatus + public annotation class AvailabilityStatus /** * Determines whether the Health Connect SDK is available on this device at the moment. @@ -978,7 +985,7 @@ interface HealthConnectClient { @JvmOverloads @JvmStatic @AvailabilityStatus - fun getSdkStatus( + public fun getSdkStatus( context: Context, providerPackageName: String = DEFAULT_PROVIDER_PACKAGE_NAME, ): Int { @@ -1036,7 +1043,7 @@ interface HealthConnectClient { // TODO(b/540757251): Support signature checks for custom provider package names. @JvmOverloads @JvmStatic - fun getHealthConnectManageDataIntent( + public fun getHealthConnectManageDataIntent( context: Context, providerPackageName: String = DEFAULT_PROVIDER_PACKAGE_NAME, ): Intent { diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/HealthConnectClientExt.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/HealthConnectClientExt.kt index 394b00b61eee7..5d1888b05d524 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/HealthConnectClientExt.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/HealthConnectClientExt.kt @@ -42,7 +42,7 @@ import java.io.IOException * * Example usage to delete written steps data by its unique identifier: */ -suspend inline fun HealthConnectClient.deleteRecords( +public suspend inline fun HealthConnectClient.deleteRecords( recordIdsList: List, clientRecordIdsList: List, ) { @@ -69,7 +69,7 @@ suspend inline fun HealthConnectClient.deleteRecords( * * Example usage to delete written steps data in a time range: */ -suspend inline fun HealthConnectClient.deleteRecords( +public suspend inline fun HealthConnectClient.deleteRecords( timeRangeFilter: TimeRangeFilter ) { deleteRecords(recordType = T::class, timeRangeFilter = timeRangeFilter) @@ -88,6 +88,6 @@ suspend inline fun HealthConnectClient.deleteRecords( * @throws IllegalStateException If service is not available. * @see HealthConnectClient.readRecord */ -suspend inline fun HealthConnectClient.readRecord( +public suspend inline fun HealthConnectClient.readRecord( recordId: String ): ReadRecordResponse = readRecord(recordType = T::class, recordId = recordId) diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/HealthConnectFeatures.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/HealthConnectFeatures.kt index b697b0149fe7c..5aaf3345c22e6 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/HealthConnectFeatures.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/HealthConnectFeatures.kt @@ -23,7 +23,7 @@ import androidx.health.connect.client.feature.HealthConnectPlatformVersion import androidx.health.connect.client.feature.HealthConnectVersionInfo /** Interface for checking availability of features in [HealthConnectClient]. */ -interface HealthConnectFeatures { +public interface HealthConnectFeatures { /** * Checks whether the given feature is available. @@ -31,31 +31,32 @@ interface HealthConnectFeatures { * @param feature the feature to be checked. One of the "FEATURE_" constants in this class. * @return one of [FEATURE_STATUS_UNAVAILABLE] or [FEATURE_STATUS_AVAILABLE] */ - @FeatureStatus fun getFeatureStatus(@Feature feature: Int): Int + @FeatureStatus public fun getFeatureStatus(@Feature feature: Int): Int /** Constants related to HealthConnect feature availability. */ - companion object { + public companion object { /** Feature constant for reading health data in background. */ - const val FEATURE_READ_HEALTH_DATA_IN_BACKGROUND = 1 + public const val FEATURE_READ_HEALTH_DATA_IN_BACKGROUND: Int = 1 /** Feature constant for skin temperature. */ - const val FEATURE_SKIN_TEMPERATURE = 2 + public const val FEATURE_SKIN_TEMPERATURE: Int = 2 /** Feature constant for planned exercise sessions. */ - const val FEATURE_PLANNED_EXERCISE = 3 + public const val FEATURE_PLANNED_EXERCISE: Int = 3 /** Feature constant for reading health data history. */ - const val FEATURE_READ_HEALTH_DATA_HISTORY = 4 + public const val FEATURE_READ_HEALTH_DATA_HISTORY: Int = 4 /** Feature constant for mindfulness session. */ - const val FEATURE_MINDFULNESS_SESSION = 5 + public const val FEATURE_MINDFULNESS_SESSION: Int = 5 /** Feature constant for Personal Health Records APIs. */ - @ExperimentalPersonalHealthRecordApi const val FEATURE_PERSONAL_HEALTH_RECORD = 6 + @ExperimentalPersonalHealthRecordApi + public const val FEATURE_PERSONAL_HEALTH_RECORD: Int = 6 /** Feature constant for Activity Intensity APIs. */ - const val FEATURE_ACTIVITY_INTENSITY = 7 + public const val FEATURE_ACTIVITY_INTENSITY: Int = 7 /** * Feature constant for extended device types. @@ -72,7 +73,7 @@ interface HealthConnectFeatures { * If this feature is not available, these device types will be treated as * `Device.TYPE_UNKNOWN`. */ - const val FEATURE_EXTENDED_DEVICE_TYPES = 8 + public const val FEATURE_EXTENDED_DEVICE_TYPES: Int = 8 /** * Feature constant for exercise session improvements. @@ -83,10 +84,10 @@ interface HealthConnectFeatures { * - `ExerciseSegment.setIndex` * - `ExerciseSegment.rateOfPerceivedExertion` */ - const val FEATURE_EXERCISE_SESSION_IMPROVEMENTS = 9 + public const val FEATURE_EXERCISE_SESSION_IMPROVEMENTS: Int = 9 /** Feature constant for Matchmaking APIs. */ - @ExperimentalMatchmakingApi const val FEATURE_MATCHMAKING = 10 + @ExperimentalMatchmakingApi public const val FEATURE_MATCHMAKING: Int = 10 /** * Feature constant for on-device step tracking. @@ -94,7 +95,7 @@ interface HealthConnectFeatures { * On-device step tracking refers to step counts recorded directly by the on-device hardware * pedometer or sensor, distinct from steps synced or contributed by external applications. */ - const val FEATURE_ON_DEVICE_STEP_TRACKING = 11 + public const val FEATURE_ON_DEVICE_STEP_TRACKING: Int = 11 /** * Feature constant for Device Data Providers APIs. @@ -104,7 +105,7 @@ interface HealthConnectFeatures { * - [HealthConnectClient.getCurrentDeviceDataSource] * - [HealthConnectClient.getDeviceDataSourceCapabilities] */ - @ExperimentalDeviceDataSourceApi const val FEATURE_DEVICE_DATA_PROVIDERS = 12 + @ExperimentalDeviceDataSourceApi public const val FEATURE_DEVICE_DATA_PROVIDERS: Int = 12 @OptIn( ExperimentalPersonalHealthRecordApi::class, @@ -130,23 +131,23 @@ interface HealthConnectFeatures { ] ) @RestrictTo(RestrictTo.Scope.LIBRARY) - annotation class Feature + public annotation class Feature /** * Indicates that a feature is unavailable and the corresponding APIs cannot be used at * runtime. */ - const val FEATURE_STATUS_UNAVAILABLE = 1 + public const val FEATURE_STATUS_UNAVAILABLE: Int = 1 /** * Indicates that a feature is available and the corresponding APIs can be used at runtime. */ - const val FEATURE_STATUS_AVAILABLE = 2 + public const val FEATURE_STATUS_AVAILABLE: Int = 2 @Retention(AnnotationRetention.SOURCE) @IntDef(value = [FEATURE_STATUS_UNAVAILABLE, FEATURE_STATUS_AVAILABLE]) @RestrictTo(RestrictTo.Scope.LIBRARY) - annotation class FeatureStatus + public annotation class FeatureStatus private val SDK_EXT_13_PLATFORM_VERSION: HealthConnectPlatformVersion = HealthConnectPlatformVersion(buildVersionCode = 34, sdkExtensionVersion = 13) diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/PermissionController.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/PermissionController.kt index b230732a33706..3ddce0a94914d 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/PermissionController.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/PermissionController.kt @@ -22,7 +22,7 @@ import androidx.health.platform.client.service.HealthDataServiceConstants.DEFAUL @JvmDefaultWithCompatibility /** Interface for operations related to permissions. */ -interface PermissionController { +public interface PermissionController { /** * Returns a set of all health permissions granted by the user to the calling app. @@ -33,7 +33,7 @@ interface PermissionController { * @throws IllegalStateException If service is not available. * @sample androidx.health.connect.client.samples.GetPermissions */ - suspend fun getGrantedPermissions(): Set + public suspend fun getGrantedPermissions(): Set /** * Revokes all previously granted [HealthPermission] by the user to the calling app. @@ -42,9 +42,9 @@ interface PermissionController { * @throws java.io.IOException For any disk I/O issues. * @throws IllegalStateException If service is not available. */ - suspend fun revokeAllPermissions() + public suspend fun revokeAllPermissions() - companion object { + public companion object { /** * Creates an [ActivityResultContract] to request Health permissions. @@ -56,7 +56,7 @@ interface PermissionController { */ @JvmStatic @JvmOverloads - fun createRequestPermissionResultContract( + public fun createRequestPermissionResultContract( providerPackageName: String = DEFAULT_PROVIDER_PACKAGE_NAME ): ActivityResultContract, Set> { return HealthPermissionsRequestContract(providerPackageName) diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/aggregate/AggregateMetric.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/aggregate/AggregateMetric.kt index 015a0dfb5e81d..7f8254185aa78 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/aggregate/AggregateMetric.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/aggregate/AggregateMetric.kt @@ -24,7 +24,7 @@ import java.time.Duration * @see AggregationResult.contains * @see AggregationResult.get */ -class AggregateMetric +public class AggregateMetric internal constructor( /** Converter from a raw value to the resulting type [T]. Internal to SDK only. */ internal val converter: Converter<*, T>, @@ -137,7 +137,7 @@ internal constructor( } @get:RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) - val metricKey: String + public val metricKey: String get() { val aggregationTypeString = aggregationType.aggregationTypeString return if (aggregationField == null) { diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/aggregate/AggregationResult.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/aggregate/AggregationResult.kt index 6653dc6c67c8e..292fa2c14354b 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/aggregate/AggregationResult.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/aggregate/AggregationResult.kt @@ -33,11 +33,11 @@ import androidx.health.connect.client.records.metadata.DataOrigin * * @see [androidx.health.connect.client.HealthConnectClient.aggregate] */ -class AggregationResult +public class AggregationResult @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) constructor( - @get:RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) val longValues: Map, - @get:RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) val doubleValues: Map, + @get:RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) public val longValues: Map, + @get:RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) public val doubleValues: Map, /** Set of [DataOrigin]s that contributed to the aggregation result. */ public val dataOrigins: Set, ) { @@ -49,7 +49,7 @@ constructor( * @param metric an aggregate metric identifier. * @return whether given metric is set. */ - operator fun contains(metric: AggregateMetric<*>): Boolean = + public operator fun contains(metric: AggregateMetric<*>): Boolean = when (metric.converter) { is Converter.FromLong -> metric.metricKey in longValues is Converter.FromDouble -> metric.metricKey in doubleValues @@ -64,7 +64,7 @@ constructor( * @return the value of the metric, or null if not set. * @see contains */ - operator fun get(metric: AggregateMetric): T? = + public operator fun get(metric: AggregateMetric): T? = when (metric.converter) { is Converter.FromLong -> longValues[metric.metricKey]?.let(metric.converter) is Converter.FromDouble -> doubleValues[metric.metricKey]?.let(metric.converter) diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/aggregate/AggregationResultGroupedByDuration.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/aggregate/AggregationResultGroupedByDuration.kt index 640b795c0fae8..845d94792533b 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/aggregate/AggregationResultGroupedByDuration.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/aggregate/AggregationResultGroupedByDuration.kt @@ -30,7 +30,7 @@ import java.time.ZoneOffset * handle scenarios involving Day Light Savings, such as "hourly steps on a given date". * @see [androidx.health.connect.client.HealthConnectClient.aggregateGroupByDuration] */ -class AggregationResultGroupedByDuration +public class AggregationResultGroupedByDuration @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) constructor( public val result: AggregationResult, diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/aggregate/AggregationResultGroupedByPeriod.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/aggregate/AggregationResultGroupedByPeriod.kt index 9d094fa97e70f..4cf4d476a937c 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/aggregate/AggregationResultGroupedByPeriod.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/aggregate/AggregationResultGroupedByPeriod.kt @@ -26,12 +26,12 @@ import java.time.LocalDateTime * @property endTime end time of the slice. * @see [androidx.health.connect.client.HealthConnectClient.aggregateGroupByPeriod] */ -class AggregationResultGroupedByPeriod +public class AggregationResultGroupedByPeriod @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) constructor( - val result: AggregationResult, - val startTime: LocalDateTime, - val endTime: LocalDateTime, + public val result: AggregationResult, + public val startTime: LocalDateTime, + public val endTime: LocalDateTime, shouldSkipValidation: Boolean = false, ) { init { diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/changes/Change.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/changes/Change.kt index cac88c6986dae..2fadd7af67217 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/changes/Change.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/changes/Change.kt @@ -22,4 +22,4 @@ package androidx.health.connect.client.changes * @see UpsertionChange * @see DeletionChange */ -interface Change +public interface Change diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/changes/ChangesEvent.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/changes/ChangesEvent.kt index fbd22e744657c..db42f487eb4fc 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/changes/ChangesEvent.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/changes/ChangesEvent.kt @@ -25,5 +25,5 @@ import androidx.annotation.RestrictTo * @property changes List of changes required to sync. */ @RestrictTo(RestrictTo.Scope.LIBRARY) -class ChangesEvent +public class ChangesEvent internal constructor(public val nextChangesToken: String, public val changes: List) diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/changes/DeletionChange.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/changes/DeletionChange.kt index 0e1e5cec816fc..3375de1e51d0d 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/changes/DeletionChange.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/changes/DeletionChange.kt @@ -29,7 +29,7 @@ import androidx.health.connect.client.records.metadata.Metadata * * @property recordId [Metadata.id] of deleted [Record]. */ -class DeletionChange +public class DeletionChange @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) constructor(public val recordId: String) : Change { diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/changes/UpsertionChange.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/changes/UpsertionChange.kt index 3ad73fac98031..47af611db9ab7 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/changes/UpsertionChange.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/changes/UpsertionChange.kt @@ -23,7 +23,7 @@ import androidx.health.connect.client.records.Record * * @property record Updated or inserted record. */ -class UpsertionChange +public class UpsertionChange @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) constructor(public val record: Record) : Change { diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/contracts/ExerciseRouteRequestContract.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/contracts/ExerciseRouteRequestContract.kt index 5fbee5fc1ae10..d7bfd85d54dfd 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/contracts/ExerciseRouteRequestContract.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/contracts/ExerciseRouteRequestContract.kt @@ -34,7 +34,7 @@ import androidx.health.connect.client.records.ExerciseRoute */ // TODO(b/540752486): Allow passing providerPackageName and verify custom provider // signatures. -class ExerciseRouteRequestContract : ActivityResultContract() { +public class ExerciseRouteRequestContract : ActivityResultContract() { private val delegate: ActivityResultContract = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) { diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/contracts/HealthPermissionsRequestContract.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/contracts/HealthPermissionsRequestContract.kt index eda6098a20441..61522fd1aafc7 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/contracts/HealthPermissionsRequestContract.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/contracts/HealthPermissionsRequestContract.kt @@ -31,7 +31,7 @@ import androidx.health.platform.client.service.HealthDataServiceConstants.DEFAUL * It receives a set of permissions as input and returns a set with the granted permissions as * output. */ -class HealthPermissionsRequestContract( +public class HealthPermissionsRequestContract( providerPackageName: String = DEFAULT_PROVIDER_PACKAGE_NAME ) : ActivityResultContract, Set>() { diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/datanotification/DataNotification.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/datanotification/DataNotification.kt index 19aecf9e3b81f..6e127936a422b 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/datanotification/DataNotification.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/datanotification/DataNotification.kt @@ -31,9 +31,9 @@ import kotlin.reflect.KClass * @see androidx.health.platform.client.HealthDataAsyncClient.registerForDataNotifications */ @RestrictTo(RestrictTo.Scope.LIBRARY) // Not yet ready for public -class DataNotification private constructor(val dataTypes: Set>) { +public class DataNotification private constructor(public val dataTypes: Set>) { - companion object { + public companion object { private const val EXTRA_DATA_TYPES = "com.google.android.healthdata.extra.DATA_TYPES" /** @@ -47,7 +47,7 @@ class DataNotification private constructor(val dataTypes: Set * @see androidx.health.platform.client.HealthDataAsyncClient.registerForDataNotifications */ @JvmStatic - fun from(intent: Intent): DataNotification? { + public fun from(intent: Intent): DataNotification? { val dataTypes = intent.getProtoMessages(name = EXTRA_DATA_TYPES, parser = DataType::parseFrom) ?: return null diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/devicedatasource/DeviceDataSource.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/devicedatasource/DeviceDataSource.kt index f2c0f2b4da01f..1e1f7d7d33a6d 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/devicedatasource/DeviceDataSource.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/devicedatasource/DeviceDataSource.kt @@ -28,10 +28,10 @@ import androidx.health.connect.client.records.metadata.Device * @property deviceDataTypeSources set of [DeviceDataTypeSource]s provided by this device */ @ExperimentalDeviceDataSourceApi -class DeviceDataSource( - val deviceDataOrigin: DataOrigin, - val device: Device, - val deviceDataTypeSources: Set, +public class DeviceDataSource( + public val deviceDataOrigin: DataOrigin, + public val device: Device, + public val deviceDataTypeSources: Set, ) { override fun equals(other: Any?): Boolean { if (this === other) return true diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/devicedatasource/DeviceDataSourceCapabilities.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/devicedatasource/DeviceDataSourceCapabilities.kt index f2c320a6ea543..7d6524b4042b1 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/devicedatasource/DeviceDataSourceCapabilities.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/devicedatasource/DeviceDataSourceCapabilities.kt @@ -26,7 +26,7 @@ import kotlin.reflect.KClass * @property recordTypes set of [Record] types that can be provided */ @ExperimentalDeviceDataSourceApi -class DeviceDataSourceCapabilities(val recordTypes: Set>) { +public class DeviceDataSourceCapabilities(public val recordTypes: Set>) { override fun equals(other: Any?): Boolean { if (this === other) return true if (other !is DeviceDataSourceCapabilities) return false diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/devicedatasource/DeviceDataTypeSource.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/devicedatasource/DeviceDataTypeSource.kt index 61d10f0a5ff3a..23875daf27e89 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/devicedatasource/DeviceDataTypeSource.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/devicedatasource/DeviceDataTypeSource.kt @@ -28,10 +28,10 @@ import kotlin.reflect.KClass * @property isUserEnabled whether the user has enabled this data type for the device */ @ExperimentalDeviceDataSourceApi -class DeviceDataTypeSource( - val dataType: KClass, - val isAvailable: Boolean, - val isUserEnabled: Boolean, +public class DeviceDataTypeSource( + public val dataType: KClass, + public val isAvailable: Boolean, + public val isUserEnabled: Boolean, ) { override fun equals(other: Any?): Boolean { if (this === other) return true diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/devicedatasource/GetDeviceDataSourcesResponse.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/devicedatasource/GetDeviceDataSourcesResponse.kt index d669ba4a424c2..d615240606d18 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/devicedatasource/GetDeviceDataSourcesResponse.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/devicedatasource/GetDeviceDataSourcesResponse.kt @@ -26,7 +26,7 @@ import androidx.health.connect.client.ExperimentalDeviceDataSourceApi * @see [androidx.health.connect.client.HealthConnectClient.getDeviceDataSources] */ @ExperimentalDeviceDataSourceApi -class GetDeviceDataSourcesResponse(val deviceDataSources: List) { +public class GetDeviceDataSourcesResponse(public val deviceDataSources: List) { override fun equals(other: Any?): Boolean { if (this === other) return true if (other !is GetDeviceDataSourcesResponse) return false diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/feature/ExperimentalPersonalHealthRecordApi.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/feature/ExperimentalPersonalHealthRecordApi.kt index 00676331852f3..22dbd092f82fd 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/feature/ExperimentalPersonalHealthRecordApi.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/feature/ExperimentalPersonalHealthRecordApi.kt @@ -21,4 +21,4 @@ package androidx.health.connect.client.feature "This is a part of the Personal Health Record experimental Health Connect APIs and could change in the future." ) @Retention(AnnotationRetention.BINARY) -annotation class ExperimentalPersonalHealthRecordApi +public annotation class ExperimentalPersonalHealthRecordApi diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/feature/HealthConnectFeaturesUnavailableImpl.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/feature/HealthConnectFeaturesUnavailableImpl.kt index 529b50a56c54a..d3b207c91bf9e 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/feature/HealthConnectFeaturesUnavailableImpl.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/feature/HealthConnectFeaturesUnavailableImpl.kt @@ -24,6 +24,7 @@ import androidx.health.connect.client.HealthConnectFeatures * [getFeatureStatus]. */ @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) -object HealthConnectFeaturesUnavailableImpl : HealthConnectFeatures { - override fun getFeatureStatus(feature: Int) = HealthConnectFeatures.FEATURE_STATUS_UNAVAILABLE +public object HealthConnectFeaturesUnavailableImpl : HealthConnectFeatures { + override fun getFeatureStatus(feature: Int): Int = + HealthConnectFeatures.FEATURE_STATUS_UNAVAILABLE } diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/HealthConnectClientImpl.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/HealthConnectClientImpl.kt index 28860fb420b04..51f5a80bbd13c 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/HealthConnectClientImpl.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/HealthConnectClientImpl.kt @@ -71,7 +71,7 @@ import kotlinx.coroutines.guava.await * Kotlin extension implementation that exposes kotlin coroutines rather than guava * ListenableFutures. */ -class HealthConnectClientImpl +public class HealthConnectClientImpl @VisibleForTesting internal constructor( private val delegate: HealthDataAsyncClient, diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/HealthConnectClientUpsideDownImpl.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/HealthConnectClientUpsideDownImpl.kt index f6dcd9c54923d..5d043f2983bbe 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/HealthConnectClientUpsideDownImpl.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/HealthConnectClientUpsideDownImpl.kt @@ -106,7 +106,7 @@ import kotlinx.coroutines.suspendCancellableCoroutine /** Implements the [HealthConnectClient] with APIs in UpsideDownCake. */ @RequiresApi(api = 34) -class HealthConnectClientUpsideDownImpl : HealthConnectClient, PermissionController { +public class HealthConnectClientUpsideDownImpl : HealthConnectClient, PermissionController { private val executor = Dispatchers.Default.asExecutor() @@ -114,7 +114,7 @@ class HealthConnectClientUpsideDownImpl : HealthConnectClient, PermissionControl private val healthConnectManager: HealthConnectManager private val revokePermissionsFunction: (Collection) -> Unit - constructor(context: Context) : this(context, context::revokeSelfPermissionsOnKill) + public constructor(context: Context) : this(context, context::revokeSelfPermissionsOnKill) @VisibleForTesting internal constructor( diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/converters/aggregate/AggregateMetricToProto.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/converters/aggregate/AggregateMetricToProto.kt index b863e02898bad..dfe956ae40a31 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/converters/aggregate/AggregateMetricToProto.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/converters/aggregate/AggregateMetricToProto.kt @@ -21,7 +21,7 @@ import androidx.annotation.RestrictTo import androidx.health.connect.client.aggregate.AggregateMetric import androidx.health.platform.client.proto.RequestProto -fun AggregateMetric<*>.toProto(): RequestProto.AggregateMetricSpec = +public fun AggregateMetric<*>.toProto(): RequestProto.AggregateMetricSpec = RequestProto.AggregateMetricSpec.newBuilder() .setDataTypeName(dataTypeName) .setAggregationType(aggregationType.aggregationTypeString) diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/converters/aggregate/ProtoToAggregateDataRow.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/converters/aggregate/ProtoToAggregateDataRow.kt index c93b1d67420cc..e04495de84c32 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/converters/aggregate/ProtoToAggregateDataRow.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/converters/aggregate/ProtoToAggregateDataRow.kt @@ -31,7 +31,7 @@ import kotlin.math.floor // ZoneOffset.ofTotalSeconds() has been banned but safe here for serialization. @SuppressWarnings("GoodTime") -fun DataProto.AggregateDataRow.toAggregateDataRowGroupByDuration(): +public fun DataProto.AggregateDataRow.toAggregateDataRowGroupByDuration(): AggregationResultGroupedByDuration { require(hasStartTimeEpochMs()) { "start time must be set" } require(hasEndTimeEpochMs()) { "end time must be set" } @@ -44,7 +44,8 @@ fun DataProto.AggregateDataRow.toAggregateDataRowGroupByDuration(): ) } -fun DataProto.AggregateDataRow.toAggregateDataRowGroupByPeriod(): AggregationResultGroupedByPeriod { +public fun DataProto.AggregateDataRow.toAggregateDataRowGroupByPeriod(): + AggregationResultGroupedByPeriod { require(hasStartLocalDateTime()) { "start time must be set" } require(hasEndLocalDateTime()) { "end time must be set" } @@ -55,7 +56,7 @@ fun DataProto.AggregateDataRow.toAggregateDataRowGroupByPeriod(): AggregationRes ) } -fun DataProto.AggregateDataRow.retrieveAggregateDataRow(): AggregationResult { +public fun DataProto.AggregateDataRow.retrieveAggregateDataRow(): AggregationResult { val longValues: MutableMap = longValuesMap.toMutableMap() val doubleValues: MutableMap = doubleValuesMap.toMutableMap() // ActivityIntensityRecord.INTENSITY_MINUTES_TOTAL is stored in milliseconds in the proto but diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/converters/changes/ChangesEventConverter.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/converters/changes/ChangesEventConverter.kt index 20fcd521588e9..27e81dc9300a9 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/converters/changes/ChangesEventConverter.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/converters/changes/ChangesEventConverter.kt @@ -26,7 +26,7 @@ import androidx.health.connect.client.impl.converters.records.toRecord import androidx.health.platform.client.proto.ChangeProto /** Converts proto response to public API object. */ -fun toApiChangesEvent(proto: ChangeProto.ChangesEvent): ChangesEvent { +public fun toApiChangesEvent(proto: ChangeProto.ChangesEvent): ChangesEvent { return ChangesEvent( changes = extractApiChanges(proto.changesList), nextChangesToken = proto.nextChangesToken, diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/converters/datatype/DataTypeConverter.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/converters/datatype/DataTypeConverter.kt index 5a396f3527370..4c1ab7e122d5b 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/converters/datatype/DataTypeConverter.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/converters/datatype/DataTypeConverter.kt @@ -23,13 +23,13 @@ import androidx.health.platform.client.proto.DataProto.DataType import kotlin.reflect.KClass /** Converts public API object into internal proto for ipc. */ -fun KClass.toDataTypeName(): String = +public fun KClass.toDataTypeName(): String = RECORDS_CLASS_NAME_MAP[this] ?: throw UnsupportedOperationException("Not supported yet: $this") -fun KClass.toDataType(): DataType = +public fun KClass.toDataType(): DataType = DataType.newBuilder().setName(toDataTypeName()).build() -fun String.toDataTypeKClass(): KClass = +public fun String.toDataTypeKClass(): KClass = RECORDS_TYPE_NAME_MAP[this] ?: throw UnsupportedOperationException("Not supported yet: $this") -fun DataType.toDataTypeKClass(): KClass = name.toDataTypeKClass() +public fun DataType.toDataTypeKClass(): KClass = name.toDataTypeKClass() diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/converters/datatype/DataTypeIdPairConverter.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/converters/datatype/DataTypeIdPairConverter.kt index 953152e0b1dfc..59936d93b49fb 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/converters/datatype/DataTypeIdPairConverter.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/converters/datatype/DataTypeIdPairConverter.kt @@ -23,13 +23,13 @@ import androidx.health.platform.client.proto.RequestProto import kotlin.reflect.KClass /** Converts public API object into internal proto for ipc. */ -fun toDataTypeIdPairProto( +public fun toDataTypeIdPairProto( dataTypeKC: KClass, uid: String, ): RequestProto.DataTypeIdPair = RequestProto.DataTypeIdPair.newBuilder().setDataType(dataTypeKC.toDataType()).setId(uid).build() -fun toDataTypeIdPairProtoList( +public fun toDataTypeIdPairProtoList( dataTypeKC: KClass, uidsList: List, ): List { diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/converters/datatype/RecordsTypeNameMap.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/converters/datatype/RecordsTypeNameMap.kt index f88185e1bb61b..ef682d4e844a0 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/converters/datatype/RecordsTypeNameMap.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/converters/datatype/RecordsTypeNameMap.kt @@ -62,7 +62,7 @@ import androidx.health.connect.client.records.WeightRecord import androidx.health.connect.client.records.WheelchairPushesRecord import kotlin.reflect.KClass -val RECORDS_TYPE_NAME_MAP: Map> = +public val RECORDS_TYPE_NAME_MAP: Map> = mapOf( "ActiveCaloriesBurned" to ActiveCaloriesBurnedRecord::class, "ActivityIntensity" to ActivityIntensityRecord::class, @@ -108,5 +108,5 @@ val RECORDS_TYPE_NAME_MAP: Map> = "Weight" to WeightRecord::class, ) -val RECORDS_CLASS_NAME_MAP: Map, String> = +public val RECORDS_CLASS_NAME_MAP: Map, String> = RECORDS_TYPE_NAME_MAP.entries.associate { it.value to it.key } diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/converters/records/DeviceTypeConverters.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/converters/records/DeviceTypeConverters.kt index 5abf074e8032f..86233a84d6748 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/converters/records/DeviceTypeConverters.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/converters/records/DeviceTypeConverters.kt @@ -21,7 +21,7 @@ import androidx.annotation.RestrictTo import androidx.health.connect.client.records.metadata.Device import androidx.health.connect.client.records.metadata.DeviceTypes -val DEVICE_TYPE_STRING_TO_INT_MAP = +public val DEVICE_TYPE_STRING_TO_INT_MAP: Map = mapOf( DeviceTypes.UNKNOWN to Device.TYPE_UNKNOWN, DeviceTypes.CHEST_STRAP to Device.TYPE_CHEST_STRAP, @@ -34,5 +34,5 @@ val DEVICE_TYPE_STRING_TO_INT_MAP = DeviceTypes.WATCH to Device.TYPE_WATCH, ) -val DEVICE_TYPE_INT_TO_STRING_MAP: Map = +public val DEVICE_TYPE_INT_TO_STRING_MAP: Map = DEVICE_TYPE_STRING_TO_INT_MAP.entries.associate { it.value to it.key } diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/converters/records/ProtoToRecordConverters.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/converters/records/ProtoToRecordConverters.kt index 5f619e3a6ecd3..23009a39f94ed 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/converters/records/ProtoToRecordConverters.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/converters/records/ProtoToRecordConverters.kt @@ -82,7 +82,7 @@ import androidx.health.platform.client.proto.DataProto import java.time.Instant /** Converts public API object into internal proto for ipc. */ -fun toRecord(proto: DataProto.DataPoint): Record = +public fun toRecord(proto: DataProto.DataPoint): Record = with(proto) { when (dataType.name) { "ActivityIntensity" -> @@ -621,7 +621,7 @@ fun toRecord(proto: DataProto.DataPoint): Record = } } -fun toExerciseRouteData( +public fun toExerciseRouteData( protoWrapper: androidx.health.platform.client.exerciseroute.ExerciseRoute ): ExerciseRoute { return ExerciseRoute( diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/converters/records/ProtoToRecordUtils.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/converters/records/ProtoToRecordUtils.kt index ff261afa44d96..840303b7fa97f 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/converters/records/ProtoToRecordUtils.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/converters/records/ProtoToRecordUtils.kt @@ -38,28 +38,28 @@ import java.time.ZoneOffset /** Internal helper functions to convert proto to records. */ @get:SuppressWarnings("GoodTime") // Safe to use for deserialization -val DataProto.DataPoint.startTime: Instant +public val DataProto.DataPoint.startTime: Instant get() = Instant.ofEpochMilli(startTimeMillis) @get:SuppressWarnings("GoodTime") // Safe to use for deserialization -val DataProto.DataPoint.endTime: Instant +public val DataProto.DataPoint.endTime: Instant get() = Instant.ofEpochMilli(endTimeMillis) @get:SuppressWarnings("GoodTime") // Safe to use for deserialization -val DataProto.DataPoint.time: Instant +public val DataProto.DataPoint.time: Instant get() = Instant.ofEpochMilli(instantTimeMillis) @get:SuppressWarnings("GoodTime") // Safe to use for deserialization -val DataProto.DataPoint.startZoneOffset: ZoneOffset? +public val DataProto.DataPoint.startZoneOffset: ZoneOffset? get() = if (hasStartZoneOffsetSeconds()) ZoneOffset.ofTotalSeconds(startZoneOffsetSeconds) else null @get:SuppressWarnings("GoodTime") // Safe to use for deserialization -val DataProto.DataPoint.endZoneOffset: ZoneOffset? +public val DataProto.DataPoint.endZoneOffset: ZoneOffset? get() = if (hasEndZoneOffsetSeconds()) ZoneOffset.ofTotalSeconds(endZoneOffsetSeconds) else null @get:SuppressWarnings("GoodTime") // HealthDataClientImplSafe to use for deserialization -val DataProto.DataPoint.zoneOffset: ZoneOffset? +public val DataProto.DataPoint.zoneOffset: ZoneOffset? get() = if (hasZoneOffsetSeconds()) ZoneOffset.ofTotalSeconds(zoneOffsetSeconds) else null internal fun DataPointOrBuilder.getLong(key: String, defaultVal: Long = 0): Long = @@ -95,7 +95,7 @@ internal fun SeriesValueOrBuilder.getString(key: String): String? = valuesMap[ke internal fun SeriesValueOrBuilder.getEnum(key: String): String? = valuesMap[key]?.enumVal @get:SuppressWarnings("GoodTime") // Safe to use for deserialization -val DataProto.DataPoint.metadata: Metadata +public val DataProto.DataPoint.metadata: Metadata get() = Metadata( id = if (hasUid()) uid else Metadata.EMPTY_ID, diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/converters/records/RecordToProtoConverters.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/converters/records/RecordToProtoConverters.kt index 3069c22e7e819..ab13ce3d868af 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/converters/records/RecordToProtoConverters.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/converters/records/RecordToProtoConverters.kt @@ -69,7 +69,7 @@ import androidx.health.connect.client.records.WheelchairPushesRecord import androidx.health.platform.client.proto.DataProto /** Converts public API object into internal proto for ipc. */ -fun Record.toProto(): DataProto.DataPoint = +public fun Record.toProto(): DataProto.DataPoint = when (this) { is ActivityIntensityRecord -> intervalProto() diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/converters/records/RecordToProtoUtils.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/converters/records/RecordToProtoUtils.kt index 46ba1f9aed04f..069c17f7f6c44 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/converters/records/RecordToProtoUtils.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/converters/records/RecordToProtoUtils.kt @@ -82,7 +82,7 @@ private fun DataProto.DataPoint.Builder.setMetadata(metadata: Metadata) = apply } } -fun Device.toProto(): DataProto.Device { +public fun Device.toProto(): DataProto.Device { val obj = this return DataProto.Device.newBuilder() .apply { diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/converters/request/AggregateRequestToProto.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/converters/request/AggregateRequestToProto.kt index 2f882268dcb33..9c495907af918 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/converters/request/AggregateRequestToProto.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/converters/request/AggregateRequestToProto.kt @@ -27,7 +27,7 @@ import androidx.health.connect.client.request.AggregateRequest import androidx.health.platform.client.proto.DataProto import androidx.health.platform.client.proto.RequestProto -fun AggregateRequest.toProto(): RequestProto.AggregateDataRequest = +public fun AggregateRequest.toProto(): RequestProto.AggregateDataRequest = RequestProto.AggregateDataRequest.newBuilder() .setTimeSpec(timeRangeFilter.toProto()) .addAllDataOrigin(dataOriginFilter.toProtoList()) @@ -35,7 +35,7 @@ fun AggregateRequest.toProto(): RequestProto.AggregateDataRequest = .build() @SuppressWarnings("NewApi") -fun AggregateGroupByDurationRequest.toProto(): RequestProto.AggregateDataRequest = +public fun AggregateGroupByDurationRequest.toProto(): RequestProto.AggregateDataRequest = RequestProto.AggregateDataRequest.newBuilder() .setTimeSpec(timeRangeFilter.toProto()) .addAllDataOrigin(dataOriginFilter.toProtoList()) @@ -44,7 +44,7 @@ fun AggregateGroupByDurationRequest.toProto(): RequestProto.AggregateDataRequest .build() @SuppressWarnings("NewApi") -fun AggregateGroupByPeriodRequest.toProto(): RequestProto.AggregateDataRequest = +public fun AggregateGroupByPeriodRequest.toProto(): RequestProto.AggregateDataRequest = RequestProto.AggregateDataRequest.newBuilder() .setTimeSpec(timeRangeFilter.toProto()) .addAllDataOrigin(dataOriginFilter.toProtoList()) diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/converters/request/DeleteDataRangeRequestToProto.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/converters/request/DeleteDataRangeRequestToProto.kt index 6fd06d6102f69..bdfe5ce0279c9 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/converters/request/DeleteDataRangeRequestToProto.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/converters/request/DeleteDataRangeRequestToProto.kt @@ -26,7 +26,7 @@ import androidx.health.platform.client.proto.RequestProto import kotlin.reflect.KClass /** Converts public API object into internal proto for ipc. */ -fun toDeleteDataRangeRequestProto( +public fun toDeleteDataRangeRequestProto( dataTypeKC: KClass, timeRangeFilter: TimeRangeFilter, ): RequestProto.DeleteDataRangeRequest = diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/converters/request/ReadDataRangeRequestToProto.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/converters/request/ReadDataRangeRequestToProto.kt index 813ddf7eb264b..f0360afa01be1 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/converters/request/ReadDataRangeRequestToProto.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/converters/request/ReadDataRangeRequestToProto.kt @@ -26,7 +26,7 @@ import androidx.health.platform.client.proto.DataProto import androidx.health.platform.client.proto.RequestProto /** Converts public API object into internal proto for ipc. */ -fun toReadDataRangeRequestProto( +public fun toReadDataRangeRequestProto( request: ReadRecordsRequest ): RequestProto.ReadDataRangeRequest { return RequestProto.ReadDataRangeRequest.newBuilder() diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/converters/request/ReadDataRequestToProto.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/converters/request/ReadDataRequestToProto.kt index 313badf99332e..b5af10208e0f0 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/converters/request/ReadDataRequestToProto.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/converters/request/ReadDataRequestToProto.kt @@ -24,7 +24,7 @@ import androidx.health.platform.client.proto.RequestProto import kotlin.reflect.KClass /** Converts public API object into internal proto for ipc. */ -fun toReadDataRequestProto( +public fun toReadDataRequestProto( dataTypeKC: KClass, uid: String, ): RequestProto.ReadDataRequest = diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/converters/response/ProtoToChangesResponse.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/converters/response/ProtoToChangesResponse.kt index 06f65125b592a..dbf71e107b029 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/converters/response/ProtoToChangesResponse.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/converters/response/ProtoToChangesResponse.kt @@ -27,7 +27,7 @@ import androidx.health.platform.client.proto.ChangeProto import androidx.health.platform.client.proto.ResponseProto /** Converts proto response to public API object. */ -fun toChangesResponse(proto: ResponseProto.GetChangesResponse): ChangesResponse { +public fun toChangesResponse(proto: ResponseProto.GetChangesResponse): ChangesResponse { return ChangesResponse( changes = extractChanges(proto.changesList), nextChangesToken = proto.nextChangesToken, diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/converters/response/ProtoToReadRecordsResponse.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/converters/response/ProtoToReadRecordsResponse.kt index 883da1fe33c11..4c6dcc8bae714 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/converters/response/ProtoToReadRecordsResponse.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/converters/response/ProtoToReadRecordsResponse.kt @@ -25,7 +25,7 @@ import androidx.health.platform.client.proto.ResponseProto /** Converts public API object into internal proto for ipc. */ @Suppress("UNCHECKED_CAST") // Safe to cast as the type should match -fun toReadRecordsResponse( +public fun toReadRecordsResponse( proto: ResponseProto.ReadDataRangeResponse ): ReadRecordsResponse = ReadRecordsResponse( diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/converters/time/TimeRangeFilterConverter.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/converters/time/TimeRangeFilterConverter.kt index 73acea96895a9..3412225286c48 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/converters/time/TimeRangeFilterConverter.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/converters/time/TimeRangeFilterConverter.kt @@ -23,7 +23,7 @@ import androidx.health.platform.client.proto.TimeProto /** Converts public API object into internal proto for ipc. */ @SuppressWarnings("NewApi") // TODO(b/208786847) figure a way to suppress false positive NewApi -fun TimeRangeFilter.toProto(): TimeProto.TimeSpec { +public fun TimeRangeFilter.toProto(): TimeProto.TimeSpec { val obj = this return TimeProto.TimeSpec.newBuilder() .apply { diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/platform/aggregate/AggregationMappings.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/platform/aggregate/AggregationMappings.kt index b7360653ee2e9..d7b4b0103a69f 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/platform/aggregate/AggregationMappings.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/platform/aggregate/AggregationMappings.kt @@ -247,7 +247,7 @@ internal val GRAMS_AGGREGATION_METRIC_TYPE_MAP: }, ) -val KILOGRAMS_AGGREGATION_METRIC_TYPE_MAP: +public val KILOGRAMS_AGGREGATION_METRIC_TYPE_MAP: Map, PlatformAggregateMetric> = mapOf( WeightRecord.WEIGHT_AVG to PlatformWeightRecord.WEIGHT_AVG, diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/platform/records/RecordConverters.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/platform/records/RecordConverters.kt index 2e2be38de2f83..1439bf7def359 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/platform/records/RecordConverters.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/platform/records/RecordConverters.kt @@ -157,7 +157,7 @@ private fun KClass.toPlatformRecordClassExt16(): Class.toPlatformRequest(): +public fun ReadRecordsRequest.toPlatformRequest(): ReadRecordsRequestUsingFilters { return ReadRecordsRequestUsingFilters.Builder(recordType.toPlatformRecordClass()) .setTimeRangeFilter(timeRangeFilter.toPlatformTimeRangeFilter()) @@ -70,21 +70,21 @@ fun ReadRecordsRequest.toPlatformRequest(): .build() } -fun TimeRangeFilter.toPlatformTimeRangeFilter(): PlatformTimeRangeFilter { +public fun TimeRangeFilter.toPlatformTimeRangeFilter(): PlatformTimeRangeFilter { return when { isBasedOnLocalTime() -> toPlatformLocalTimeRangeFilter() else -> TimeInstantRangeFilter.Builder().setStartTime(startTime).setEndTime(endTime).build() } } -fun TimeRangeFilter.toPlatformLocalTimeRangeFilter(): LocalTimeRangeFilter { +public fun TimeRangeFilter.toPlatformLocalTimeRangeFilter(): LocalTimeRangeFilter { return LocalTimeRangeFilter.Builder() .setStartTime(localStartTime) .setEndTime(localEndTime) .build() } -fun ChangesTokenRequest.toPlatformRequest(): ChangeLogTokenRequest { +public fun ChangesTokenRequest.toPlatformRequest(): ChangeLogTokenRequest { return ChangeLogTokenRequest.Builder() .apply { dataOriginFilters.forEach { addDataOriginFilter(it.toPlatformDataOrigin()) } @@ -93,7 +93,7 @@ fun ChangesTokenRequest.toPlatformRequest(): ChangeLogTokenRequest { .build() } -fun AggregateRequest.toPlatformRequest(): AggregateRecordsRequest { +public fun AggregateRequest.toPlatformRequest(): AggregateRecordsRequest { return AggregateRecordsRequest.Builder(timeRangeFilter.toPlatformTimeRangeFilter()) .apply { dataOriginFilter.forEach { addDataOriginsFilter(it.toPlatformDataOrigin()) } @@ -104,7 +104,7 @@ fun AggregateRequest.toPlatformRequest(): AggregateRecordsRequest { .build() } -fun AggregateGroupByDurationRequest.toPlatformRequest(): AggregateRecordsRequest { +public fun AggregateGroupByDurationRequest.toPlatformRequest(): AggregateRecordsRequest { return AggregateRecordsRequest.Builder(timeRangeFilter.toPlatformTimeRangeFilter()) .apply { dataOriginFilter.forEach { addDataOriginsFilter(it.toPlatformDataOrigin()) } @@ -115,7 +115,7 @@ fun AggregateGroupByDurationRequest.toPlatformRequest(): AggregateRecordsRequest .build() } -fun AggregateGroupByPeriodRequest.toPlatformRequest(): AggregateRecordsRequest { +public fun AggregateGroupByPeriodRequest.toPlatformRequest(): AggregateRecordsRequest { return AggregateRecordsRequest.Builder(timeRangeFilter.toPlatformLocalTimeRangeFilter()) .apply { dataOriginFilter.forEach { addDataOriginsFilter(it.toPlatformDataOrigin()) } @@ -127,7 +127,7 @@ fun AggregateGroupByPeriodRequest.toPlatformRequest(): AggregateRecordsRequest.toAggregationType(): AggregationType { +public fun AggregateMetric.toAggregationType(): AggregationType { return DOUBLE_AGGREGATION_METRIC_TYPE_MAP[this] as AggregationType? ?: DURATION_AGGREGATION_METRIC_TYPE_MAP[this] as AggregationType? ?: DURATION_TO_LONG_AGGREGATION_METRIC_TYPE_MAP[this] as AggregationType? diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/platform/response/ResponseConverters.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/platform/response/ResponseConverters.kt index 040ca655c20ce..11074cdd46ef1 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/platform/response/ResponseConverters.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/platform/response/ResponseConverters.kt @@ -70,13 +70,14 @@ private const val BUCKET_DATA_ORIGINS_EXTENSION_VERSION = 10 @SuppressLint("NewApi") // already checked with a feature availability check @OptIn(ExperimentalMatchmakingApi::class) -fun PlatformMatchmakingResponse.toKtResponse(): MatchmakingResponse = +public fun PlatformMatchmakingResponse.toKtResponse(): MatchmakingResponse = MatchmakingResponse(isMatchmakingPossible = isMatchmakingPossible) -fun AggregateRecordsResponse.toSdkResponse(metrics: Set>) = - buildAggregationResult(metrics, ::get, ::getDataOrigins) +public fun AggregateRecordsResponse.toSdkResponse( + metrics: Set> +): AggregationResult = buildAggregationResult(metrics, ::get, ::getDataOrigins) -fun AggregateRecordsGroupedByDurationResponse.toSdkResponse( +public fun AggregateRecordsGroupedByDurationResponse.toSdkResponse( metrics: Set> ): AggregationResultGroupedByDuration { val platformDataOriginsGetter: (AggregationType) -> Set = @@ -98,10 +99,11 @@ fun AggregateRecordsGroupedByDurationResponse.toSdkResponse( ) } -fun AggregateRecordsGroupedByPeriodResponse.toSdkResponse(metrics: Set>) = - toSdkResponse(metrics, startTime, endTime) +public fun AggregateRecordsGroupedByPeriodResponse.toSdkResponse( + metrics: Set> +): AggregationResultGroupedByPeriod = toSdkResponse(metrics, startTime, endTime) -fun AggregateRecordsGroupedByPeriodResponse.toSdkResponse( +public fun AggregateRecordsGroupedByPeriodResponse.toSdkResponse( metrics: Set>, bucketStartTime: LocalDateTime, bucketEndTime: LocalDateTime, diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/matchmaking/MatchmakingRequest.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/matchmaking/MatchmakingRequest.kt index e5c2ddfe00909..3064fa7fe2aa9 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/matchmaking/MatchmakingRequest.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/matchmaking/MatchmakingRequest.kt @@ -54,10 +54,10 @@ import kotlin.reflect.KClass * [includedDataSources] and [excludedDataSources] cannot both be set at the same time. */ @ExperimentalMatchmakingApi -class MatchmakingRequest( - val recordTypes: Set> = emptySet(), - val includedDataSources: Set = emptySet(), - val excludedDataSources: Set = emptySet(), +public class MatchmakingRequest( + public val recordTypes: Set> = emptySet(), + public val includedDataSources: Set = emptySet(), + public val excludedDataSources: Set = emptySet(), ) { /* * Android U devices with SDK extension 23 and later use the platform's validation diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/matchmaking/MatchmakingResponse.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/matchmaking/MatchmakingResponse.kt index b36b1e4757fac..9b208fffe4c78 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/matchmaking/MatchmakingResponse.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/matchmaking/MatchmakingResponse.kt @@ -25,7 +25,7 @@ import androidx.health.connect.client.ExperimentalMatchmakingApi * device, `false` otherwise. */ @ExperimentalMatchmakingApi -class MatchmakingResponse(val isMatchmakingPossible: Boolean) { +public class MatchmakingResponse(public val isMatchmakingPossible: Boolean) { override fun toString(): String = "MatchmakingResponse(isMatchmakingPossible=$isMatchmakingPossible)" diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/permission/HealthPermission.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/permission/HealthPermission.kt index c70a479ee4dda..dcb7d695d1605 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/permission/HealthPermission.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/permission/HealthPermission.kt @@ -70,7 +70,7 @@ import kotlin.reflect.KClass * @see androidx.health.connect.client.PermissionController */ public class HealthPermission internal constructor() { - companion object { + public companion object { /** * Returns a permission defined in [HealthPermission] to read records of type [T], such as * `StepsRecord`. @@ -79,7 +79,7 @@ public class HealthPermission internal constructor() { * @throws IllegalArgumentException if the given record type is invalid. */ @JvmStatic - inline fun getReadPermission(): String { + public inline fun getReadPermission(): String { return getReadPermission(T::class) } @@ -109,7 +109,7 @@ public class HealthPermission internal constructor() { * @throws IllegalArgumentException if the given record type is invalid. */ @JvmStatic - inline fun getWritePermission(): String { + public inline fun getWritePermission(): String { return getWritePermission(T::class) } @@ -146,7 +146,8 @@ public class HealthPermission internal constructor() { * * @sample androidx.health.connect.client.samples.InsertExerciseRoute */ - const val PERMISSION_WRITE_EXERCISE_ROUTE = PERMISSION_PREFIX + "WRITE_EXERCISE_ROUTE" + public const val PERMISSION_WRITE_EXERCISE_ROUTE: String = + PERMISSION_PREFIX + "WRITE_EXERCISE_ROUTE" /** * A permission to read exercise routes. The string value for this permission is @@ -165,7 +166,8 @@ public class HealthPermission internal constructor() { * * @sample androidx.health.connect.client.samples.ReadExerciseRoute */ - const val PERMISSION_READ_EXERCISE_ROUTES = PERMISSION_PREFIX + "READ_EXERCISE_ROUTES" + public const val PERMISSION_READ_EXERCISE_ROUTES: String = + PERMISSION_PREFIX + "READ_EXERCISE_ROUTES" /** * A permission to read data in background. @@ -179,7 +181,7 @@ public class HealthPermission internal constructor() { * @sample androidx.health.connect.client.samples.RequestBackgroundReadPermission * @sample androidx.health.connect.client.samples.ReadRecordsInBackground */ - const val PERMISSION_READ_HEALTH_DATA_IN_BACKGROUND = + public const val PERMISSION_READ_HEALTH_DATA_IN_BACKGROUND: String = PERMISSION_PREFIX + "READ_HEALTH_DATA_IN_BACKGROUND" /** @@ -203,7 +205,7 @@ public class HealthPermission internal constructor() { * * @sample androidx.health.connect.client.samples.RequestHistoryReadPermission */ - const val PERMISSION_READ_HEALTH_DATA_HISTORY = + public const val PERMISSION_READ_HEALTH_DATA_HISTORY: String = PERMISSION_PREFIX + "READ_HEALTH_DATA_HISTORY" /** @@ -218,7 +220,8 @@ public class HealthPermission internal constructor() { * @sample androidx.health.connect.client.samples.RequestMedicalPermissions */ @ExperimentalPersonalHealthRecordApi - const val PERMISSION_WRITE_MEDICAL_DATA = PERMISSION_PREFIX + "WRITE_MEDICAL_DATA" + public const val PERMISSION_WRITE_MEDICAL_DATA: String = + PERMISSION_PREFIX + "WRITE_MEDICAL_DATA" /** * Allows an application to read the user's data about allergies and intolerances. @@ -231,7 +234,7 @@ public class HealthPermission internal constructor() { * @sample androidx.health.connect.client.samples.RequestMedicalPermissions */ @ExperimentalPersonalHealthRecordApi - const val PERMISSION_READ_MEDICAL_DATA_ALLERGIES_INTOLERANCES = + public const val PERMISSION_READ_MEDICAL_DATA_ALLERGIES_INTOLERANCES: String = PERMISSION_PREFIX + "READ_MEDICAL_DATA_ALLERGIES_INTOLERANCES" /** @@ -245,7 +248,7 @@ public class HealthPermission internal constructor() { * @sample androidx.health.connect.client.samples.RequestMedicalPermissions */ @ExperimentalPersonalHealthRecordApi - const val PERMISSION_READ_MEDICAL_DATA_CONDITIONS = + public const val PERMISSION_READ_MEDICAL_DATA_CONDITIONS: String = PERMISSION_PREFIX + "READ_MEDICAL_DATA_CONDITIONS" /** @@ -259,7 +262,7 @@ public class HealthPermission internal constructor() { * @sample androidx.health.connect.client.samples.RequestMedicalPermissions */ @ExperimentalPersonalHealthRecordApi - const val PERMISSION_READ_MEDICAL_DATA_LABORATORY_RESULTS = + public const val PERMISSION_READ_MEDICAL_DATA_LABORATORY_RESULTS: String = PERMISSION_PREFIX + "READ_MEDICAL_DATA_LABORATORY_RESULTS" /** @@ -273,7 +276,7 @@ public class HealthPermission internal constructor() { * @sample androidx.health.connect.client.samples.RequestMedicalPermissions */ @ExperimentalPersonalHealthRecordApi - const val PERMISSION_READ_MEDICAL_DATA_MEDICATIONS = + public const val PERMISSION_READ_MEDICAL_DATA_MEDICATIONS: String = PERMISSION_PREFIX + "READ_MEDICAL_DATA_MEDICATIONS" /** @@ -291,7 +294,7 @@ public class HealthPermission internal constructor() { * @sample androidx.health.connect.client.samples.RequestMedicalPermissions */ @ExperimentalPersonalHealthRecordApi - const val PERMISSION_READ_MEDICAL_DATA_PERSONAL_DETAILS = + public const val PERMISSION_READ_MEDICAL_DATA_PERSONAL_DETAILS: String = PERMISSION_PREFIX + "READ_MEDICAL_DATA_PERSONAL_DETAILS" /** @@ -308,7 +311,7 @@ public class HealthPermission internal constructor() { * @sample androidx.health.connect.client.samples.RequestMedicalPermissions */ @ExperimentalPersonalHealthRecordApi - const val PERMISSION_READ_MEDICAL_DATA_PRACTITIONER_DETAILS = + public const val PERMISSION_READ_MEDICAL_DATA_PRACTITIONER_DETAILS: String = PERMISSION_PREFIX + "READ_MEDICAL_DATA_PRACTITIONER_DETAILS" /** @@ -322,7 +325,7 @@ public class HealthPermission internal constructor() { * @sample androidx.health.connect.client.samples.RequestMedicalPermissions */ @ExperimentalPersonalHealthRecordApi - const val PERMISSION_READ_MEDICAL_DATA_PREGNANCY = + public const val PERMISSION_READ_MEDICAL_DATA_PREGNANCY: String = PERMISSION_PREFIX + "READ_MEDICAL_DATA_PREGNANCY" /** @@ -336,7 +339,7 @@ public class HealthPermission internal constructor() { * @sample androidx.health.connect.client.samples.RequestMedicalPermissions */ @ExperimentalPersonalHealthRecordApi - const val PERMISSION_READ_MEDICAL_DATA_PROCEDURES = + public const val PERMISSION_READ_MEDICAL_DATA_PROCEDURES: String = PERMISSION_PREFIX + "READ_MEDICAL_DATA_PROCEDURES" /** @@ -350,7 +353,7 @@ public class HealthPermission internal constructor() { * @sample androidx.health.connect.client.samples.RequestMedicalPermissions */ @ExperimentalPersonalHealthRecordApi - const val PERMISSION_READ_MEDICAL_DATA_SOCIAL_HISTORY = + public const val PERMISSION_READ_MEDICAL_DATA_SOCIAL_HISTORY: String = PERMISSION_PREFIX + "READ_MEDICAL_DATA_SOCIAL_HISTORY" /** @@ -364,7 +367,7 @@ public class HealthPermission internal constructor() { * @sample androidx.health.connect.client.samples.RequestMedicalPermissions */ @ExperimentalPersonalHealthRecordApi - const val PERMISSION_READ_MEDICAL_DATA_VACCINES = + public const val PERMISSION_READ_MEDICAL_DATA_VACCINES: String = PERMISSION_PREFIX + "READ_MEDICAL_DATA_VACCINES" /** @@ -381,7 +384,7 @@ public class HealthPermission internal constructor() { * @sample androidx.health.connect.client.samples.RequestMedicalPermissions */ @ExperimentalPersonalHealthRecordApi - const val PERMISSION_READ_MEDICAL_DATA_VISITS = + public const val PERMISSION_READ_MEDICAL_DATA_VISITS: String = PERMISSION_PREFIX + "READ_MEDICAL_DATA_VISITS" /** @@ -395,7 +398,7 @@ public class HealthPermission internal constructor() { * @sample androidx.health.connect.client.samples.RequestMedicalPermissions */ @ExperimentalPersonalHealthRecordApi - const val PERMISSION_READ_MEDICAL_DATA_VITAL_SIGNS = + public const val PERMISSION_READ_MEDICAL_DATA_VITAL_SIGNS: String = PERMISSION_PREFIX + "READ_MEDICAL_DATA_VITAL_SIGNS" // Read permissions for ACTIVITY. diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/ActiveCaloriesBurnedRecord.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/ActiveCaloriesBurnedRecord.kt index bc053f0e9213d..c6059f4ae81ac 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/ActiveCaloriesBurnedRecord.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/ActiveCaloriesBurnedRecord.kt @@ -83,7 +83,7 @@ public class ActiveCaloriesBurnedRecord( return "ActiveCaloriesBurnedRecord(startTime=$startTime, startZoneOffset=$startZoneOffset, endTime=$endTime, endZoneOffset=$endZoneOffset, energy=$energy, metadata=$metadata)" } - companion object { + public companion object { private const val TYPE_NAME = "ActiveCaloriesBurned" private const val ENERGY_FIELD_NAME = "energy" private val MAX_ENERGY = 1000_000.kilocalories @@ -93,7 +93,7 @@ public class ActiveCaloriesBurnedRecord( * [androidx.health.connect.client.aggregate.AggregationResult]. */ @JvmField - val ACTIVE_CALORIES_TOTAL: AggregateMetric = + public val ACTIVE_CALORIES_TOTAL: AggregateMetric = AggregateMetric.doubleMetric( dataTypeName = TYPE_NAME, aggregationType = AggregateMetric.AggregationType.TOTAL, diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/ActivityIntensityRecord.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/ActivityIntensityRecord.kt index 9b640349e2331..27e42952e4995 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/ActivityIntensityRecord.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/ActivityIntensityRecord.kt @@ -38,14 +38,14 @@ import java.time.ZoneOffset * [androidx.health.connect.client.HealthConnectFeatures.getFeatureStatus] and pass * [androidx.health.connect.client.HealthConnectFeatures.FEATURE_ACTIVITY_INTENSITY] as an argument. */ -class ActivityIntensityRecord( +public class ActivityIntensityRecord( override val startTime: Instant, override val startZoneOffset: ZoneOffset?, override val endTime: Instant, override val endZoneOffset: ZoneOffset?, override val metadata: Metadata, /** Type of activity intensity (moderate or vigorous). */ - @property:ActivityIntensityTypes val activityIntensityType: Int, + @property:ActivityIntensityTypes public val activityIntensityType: Int, ) : IntervalRecord { /* @@ -91,7 +91,7 @@ class ActivityIntensityRecord( return "ActivityIntensityRecord(startTime=$startTime, startZoneOffset=$startZoneOffset, endTime=$endTime, endZoneOffset=$endZoneOffset, activityIntensityType=$activityIntensityType, metadata=$metadata)" } - companion object { + public companion object { /** * Metric identifier to retrieve the total duration of moderate activity intensity from * [androidx.health.connect.client.aggregate.AggregationResult]. To check if this metric is @@ -100,7 +100,7 @@ class ActivityIntensityRecord( * the argument. */ @JvmField - val MODERATE_DURATION_TOTAL: AggregateMetric = + public val MODERATE_DURATION_TOTAL: AggregateMetric = AggregateMetric.durationMetric( "ActivityIntensity", aggregationType = AggregateMetric.AggregationType.DURATION, @@ -115,7 +115,7 @@ class ActivityIntensityRecord( * the argument. */ @JvmField - val VIGOROUS_DURATION_TOTAL: AggregateMetric = + public val VIGOROUS_DURATION_TOTAL: AggregateMetric = AggregateMetric.durationMetric( "ActivityIntensity", aggregationType = AggregateMetric.AggregationType.DURATION, @@ -131,7 +131,7 @@ class ActivityIntensityRecord( * argument. */ @JvmField - val DURATION_TOTAL: AggregateMetric = + public val DURATION_TOTAL: AggregateMetric = AggregateMetric.durationMetric( "ActivityIntensity", aggregationType = AggregateMetric.AggregationType.DURATION, @@ -146,7 +146,7 @@ class ActivityIntensityRecord( * the argument. */ @JvmField - val INTENSITY_MINUTES_TOTAL: AggregateMetric = + public val INTENSITY_MINUTES_TOTAL: AggregateMetric = AggregateMetric.longMetric( "ActivityIntensity", aggregationType = AggregateMetric.AggregationType.DURATION, @@ -154,14 +154,14 @@ class ActivityIntensityRecord( ) /** Moderate intensity activity */ - const val ACTIVITY_INTENSITY_TYPE_MODERATE = 0 + public const val ACTIVITY_INTENSITY_TYPE_MODERATE: Int = 0 /** Vigorous intensity activity. */ - const val ACTIVITY_INTENSITY_TYPE_VIGOROUS = 1 + public const val ACTIVITY_INTENSITY_TYPE_VIGOROUS: Int = 1 @RestrictTo(RestrictTo.Scope.LIBRARY) @JvmField - val ACTIVITY_INTENSITY_TYPE_STRING_TO_INT_MAP = + public val ACTIVITY_INTENSITY_TYPE_STRING_TO_INT_MAP: Map = mapOf( "moderate" to ACTIVITY_INTENSITY_TYPE_MODERATE, "vigorous" to ACTIVITY_INTENSITY_TYPE_VIGOROUS, @@ -169,7 +169,7 @@ class ActivityIntensityRecord( @RestrictTo(RestrictTo.Scope.LIBRARY) @JvmField - val ACTIVITY_INTENSITY_TYPE_INT_TO_STRING_MAP = + public val ACTIVITY_INTENSITY_TYPE_INT_TO_STRING_MAP: Map = ACTIVITY_INTENSITY_TYPE_STRING_TO_INT_MAP.reverse() } @@ -177,5 +177,5 @@ class ActivityIntensityRecord( @Retention(AnnotationRetention.SOURCE) @RestrictTo(RestrictTo.Scope.LIBRARY) @IntDef(value = [ACTIVITY_INTENSITY_TYPE_MODERATE, ACTIVITY_INTENSITY_TYPE_VIGOROUS]) - annotation class ActivityIntensityTypes + public annotation class ActivityIntensityTypes } diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/BasalMetabolicRateRecord.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/BasalMetabolicRateRecord.kt index a2ddc1565259d..60bb22cf67f5f 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/BasalMetabolicRateRecord.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/BasalMetabolicRateRecord.kt @@ -64,7 +64,7 @@ public class BasalMetabolicRateRecord( return "BasalMetabolicRateRecord(time=$time, zoneOffset=$zoneOffset, basalMetabolicRate=$basalMetabolicRate, metadata=$metadata)" } - companion object { + public companion object { private const val BASAL_CALORIES_TYPE_NAME = "BasalCaloriesBurned" private const val ENERGY_FIELD_NAME = "energy" private val MAX_BASAL_METABLOIC_RATE = 10_000.kilocaloriesPerDay @@ -74,7 +74,7 @@ public class BasalMetabolicRateRecord( * [androidx.health.connect.client.aggregate.AggregationResult]. */ @JvmField - val BASAL_CALORIES_TOTAL: AggregateMetric = + public val BASAL_CALORIES_TOTAL: AggregateMetric = AggregateMetric.doubleMetric( dataTypeName = BASAL_CALORIES_TYPE_NAME, aggregationType = AggregateMetric.AggregationType.TOTAL, diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/BloodGlucoseRecord.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/BloodGlucoseRecord.kt index 38038547e3dce..ab7228fdb82ef 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/BloodGlucoseRecord.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/BloodGlucoseRecord.kt @@ -86,26 +86,26 @@ public class BloodGlucoseRecord( const val AFTER_MEAL = "after_meal" } - companion object { + public companion object { private val MAX_BLOOD_GLUCOSE_LEVEL = BloodGlucose.millimolesPerLiter(50.0) - const val RELATION_TO_MEAL_UNKNOWN = 0 - const val RELATION_TO_MEAL_GENERAL = 1 - const val RELATION_TO_MEAL_FASTING = 2 - const val RELATION_TO_MEAL_BEFORE_MEAL = 3 - const val RELATION_TO_MEAL_AFTER_MEAL = 4 + public const val RELATION_TO_MEAL_UNKNOWN: Int = 0 + public const val RELATION_TO_MEAL_GENERAL: Int = 1 + public const val RELATION_TO_MEAL_FASTING: Int = 2 + public const val RELATION_TO_MEAL_BEFORE_MEAL: Int = 3 + public const val RELATION_TO_MEAL_AFTER_MEAL: Int = 4 - const val SPECIMEN_SOURCE_UNKNOWN = 0 - const val SPECIMEN_SOURCE_INTERSTITIAL_FLUID = 1 - const val SPECIMEN_SOURCE_CAPILLARY_BLOOD = 2 - const val SPECIMEN_SOURCE_PLASMA = 3 - const val SPECIMEN_SOURCE_SERUM = 4 - const val SPECIMEN_SOURCE_TEARS = 5 - const val SPECIMEN_SOURCE_WHOLE_BLOOD = 6 + public const val SPECIMEN_SOURCE_UNKNOWN: Int = 0 + public const val SPECIMEN_SOURCE_INTERSTITIAL_FLUID: Int = 1 + public const val SPECIMEN_SOURCE_CAPILLARY_BLOOD: Int = 2 + public const val SPECIMEN_SOURCE_PLASMA: Int = 3 + public const val SPECIMEN_SOURCE_SERUM: Int = 4 + public const val SPECIMEN_SOURCE_TEARS: Int = 5 + public const val SPECIMEN_SOURCE_WHOLE_BLOOD: Int = 6 @RestrictTo(RestrictTo.Scope.LIBRARY) @JvmField - val RELATION_TO_MEAL_STRING_TO_INT_MAP: Map = + public val RELATION_TO_MEAL_STRING_TO_INT_MAP: Map = mapOf( RelationToMeal.GENERAL to RELATION_TO_MEAL_GENERAL, RelationToMeal.AFTER_MEAL to RELATION_TO_MEAL_AFTER_MEAL, @@ -115,11 +115,12 @@ public class BloodGlucoseRecord( @RestrictTo(RestrictTo.Scope.LIBRARY) @JvmField - val RELATION_TO_MEAL_INT_TO_STRING_MAP = RELATION_TO_MEAL_STRING_TO_INT_MAP.reverse() + public val RELATION_TO_MEAL_INT_TO_STRING_MAP: Map = + RELATION_TO_MEAL_STRING_TO_INT_MAP.reverse() @RestrictTo(RestrictTo.Scope.LIBRARY) @JvmField - val SPECIMEN_SOURCE_STRING_TO_INT_MAP: Map = + public val SPECIMEN_SOURCE_STRING_TO_INT_MAP: Map = mapOf( SpecimenSource.INTERSTITIAL_FLUID to SPECIMEN_SOURCE_INTERSTITIAL_FLUID, SpecimenSource.CAPILLARY_BLOOD to SPECIMEN_SOURCE_CAPILLARY_BLOOD, @@ -131,7 +132,8 @@ public class BloodGlucoseRecord( @RestrictTo(RestrictTo.Scope.LIBRARY) @JvmField - val SPECIMEN_SOURCE_INT_TO_STRING_MAP = SPECIMEN_SOURCE_STRING_TO_INT_MAP.reverse() + public val SPECIMEN_SOURCE_INT_TO_STRING_MAP: Map = + SPECIMEN_SOURCE_STRING_TO_INT_MAP.reverse() } /** @@ -151,7 +153,7 @@ public class BloodGlucoseRecord( ] ) @RestrictTo(RestrictTo.Scope.LIBRARY) - annotation class SpecimenSources + public annotation class SpecimenSources /** Temporal relationship of measurement time to a meal. */ @RestrictTo(RestrictTo.Scope.LIBRARY) @@ -165,7 +167,7 @@ public class BloodGlucoseRecord( RELATION_TO_MEAL_AFTER_MEAL, ] ) - annotation class RelationToMeals + public annotation class RelationToMeals /* * Generated by the IDE: Code -> Generate -> "equals() and hashCode()". diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/BloodPressureRecord.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/BloodPressureRecord.kt index 389458968bbdb..b4a248ec09fe3 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/BloodPressureRecord.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/BloodPressureRecord.kt @@ -144,7 +144,7 @@ public class BloodPressureRecord( MEASUREMENT_LOCATION_RIGHT_UPPER_ARM, ] ) - annotation class MeasurementLocations + public annotation class MeasurementLocations /** The user's body position when a health measurement is taken. */ @Retention(AnnotationRetention.SOURCE) @@ -159,25 +159,25 @@ public class BloodPressureRecord( ] ) @RestrictTo(RestrictTo.Scope.LIBRARY) - annotation class BodyPositions + public annotation class BodyPositions - companion object { + public companion object { - const val MEASUREMENT_LOCATION_UNKNOWN = 0 - const val MEASUREMENT_LOCATION_LEFT_WRIST = 1 - const val MEASUREMENT_LOCATION_RIGHT_WRIST = 2 - const val MEASUREMENT_LOCATION_LEFT_UPPER_ARM = 3 - const val MEASUREMENT_LOCATION_RIGHT_UPPER_ARM = 4 + public const val MEASUREMENT_LOCATION_UNKNOWN: Int = 0 + public const val MEASUREMENT_LOCATION_LEFT_WRIST: Int = 1 + public const val MEASUREMENT_LOCATION_RIGHT_WRIST: Int = 2 + public const val MEASUREMENT_LOCATION_LEFT_UPPER_ARM: Int = 3 + public const val MEASUREMENT_LOCATION_RIGHT_UPPER_ARM: Int = 4 - const val BODY_POSITION_UNKNOWN = 0 - const val BODY_POSITION_STANDING_UP = 1 - const val BODY_POSITION_SITTING_DOWN = 2 - const val BODY_POSITION_LYING_DOWN = 3 - const val BODY_POSITION_RECLINING = 4 + public const val BODY_POSITION_UNKNOWN: Int = 0 + public const val BODY_POSITION_STANDING_UP: Int = 1 + public const val BODY_POSITION_SITTING_DOWN: Int = 2 + public const val BODY_POSITION_LYING_DOWN: Int = 3 + public const val BODY_POSITION_RECLINING: Int = 4 @RestrictTo(RestrictTo.Scope.LIBRARY) @JvmField - val MEASUREMENT_LOCATION_STRING_TO_INT_MAP: Map = + public val MEASUREMENT_LOCATION_STRING_TO_INT_MAP: Map = mapOf( MeasurementLocation.LEFT_UPPER_ARM to MEASUREMENT_LOCATION_LEFT_UPPER_ARM, MeasurementLocation.LEFT_WRIST to MEASUREMENT_LOCATION_LEFT_WRIST, @@ -187,12 +187,12 @@ public class BloodPressureRecord( @RestrictTo(RestrictTo.Scope.LIBRARY) @JvmField - val MEASUREMENT_LOCATION_INT_TO_STRING_MAP = + public val MEASUREMENT_LOCATION_INT_TO_STRING_MAP: Map = MEASUREMENT_LOCATION_STRING_TO_INT_MAP.reverse() @RestrictTo(RestrictTo.Scope.LIBRARY) @JvmField - val BODY_POSITION_STRING_TO_INT_MAP: Map = + public val BODY_POSITION_STRING_TO_INT_MAP: Map = mapOf( BodyPosition.LYING_DOWN to BODY_POSITION_LYING_DOWN, BodyPosition.RECLINING to BODY_POSITION_RECLINING, @@ -202,7 +202,8 @@ public class BloodPressureRecord( @RestrictTo(RestrictTo.Scope.LIBRARY) @JvmField - val BODY_POSITION_INT_TO_STRING_MAP = BODY_POSITION_STRING_TO_INT_MAP.reverse() + public val BODY_POSITION_INT_TO_STRING_MAP: Map = + BODY_POSITION_STRING_TO_INT_MAP.reverse() private const val BLOOD_PRESSURE_NAME = "BloodPressure" private const val SYSTOLIC_FIELD_NAME = "systolic" @@ -217,7 +218,7 @@ public class BloodPressureRecord( * [androidx.health.connect.client.aggregate.AggregationResult]. */ @JvmField - val SYSTOLIC_AVG: AggregateMetric = + public val SYSTOLIC_AVG: AggregateMetric = AggregateMetric.doubleMetric( dataTypeName = BLOOD_PRESSURE_NAME, aggregationType = AggregateMetric.AggregationType.AVERAGE, @@ -230,7 +231,7 @@ public class BloodPressureRecord( * [androidx.health.connect.client.aggregate.AggregationResult]. */ @JvmField - val SYSTOLIC_MIN: AggregateMetric = + public val SYSTOLIC_MIN: AggregateMetric = AggregateMetric.doubleMetric( dataTypeName = BLOOD_PRESSURE_NAME, aggregationType = AggregateMetric.AggregationType.MINIMUM, @@ -243,7 +244,7 @@ public class BloodPressureRecord( * [androidx.health.connect.client.aggregate.AggregationResult]. */ @JvmField - val SYSTOLIC_MAX: AggregateMetric = + public val SYSTOLIC_MAX: AggregateMetric = AggregateMetric.doubleMetric( dataTypeName = BLOOD_PRESSURE_NAME, aggregationType = AggregateMetric.AggregationType.MAXIMUM, @@ -256,7 +257,7 @@ public class BloodPressureRecord( * [androidx.health.connect.client.aggregate.AggregationResult]. */ @JvmField - val DIASTOLIC_AVG: AggregateMetric = + public val DIASTOLIC_AVG: AggregateMetric = AggregateMetric.doubleMetric( dataTypeName = BLOOD_PRESSURE_NAME, aggregationType = AggregateMetric.AggregationType.AVERAGE, @@ -269,7 +270,7 @@ public class BloodPressureRecord( * [androidx.health.connect.client.aggregate.AggregationResult]. */ @JvmField - val DIASTOLIC_MIN: AggregateMetric = + public val DIASTOLIC_MIN: AggregateMetric = AggregateMetric.doubleMetric( dataTypeName = BLOOD_PRESSURE_NAME, aggregationType = AggregateMetric.AggregationType.MINIMUM, @@ -282,7 +283,7 @@ public class BloodPressureRecord( * [androidx.health.connect.client.aggregate.AggregationResult]. */ @JvmField - val DIASTOLIC_MAX: AggregateMetric = + public val DIASTOLIC_MAX: AggregateMetric = AggregateMetric.doubleMetric( dataTypeName = BLOOD_PRESSURE_NAME, aggregationType = AggregateMetric.AggregationType.MAXIMUM, diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/BodyTemperatureMeasurementLocation.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/BodyTemperatureMeasurementLocation.kt index 46370c9635574..ed7e9581cd33d 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/BodyTemperatureMeasurementLocation.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/BodyTemperatureMeasurementLocation.kt @@ -20,17 +20,17 @@ import androidx.annotation.RestrictTo /** Where on the user's body a temperature measurement was taken from. */ public object BodyTemperatureMeasurementLocation { - const val MEASUREMENT_LOCATION_UNKNOWN = 0 - const val MEASUREMENT_LOCATION_ARMPIT = 1 - const val MEASUREMENT_LOCATION_FINGER = 2 - const val MEASUREMENT_LOCATION_FOREHEAD = 3 - const val MEASUREMENT_LOCATION_MOUTH = 4 - const val MEASUREMENT_LOCATION_RECTUM = 5 - const val MEASUREMENT_LOCATION_TEMPORAL_ARTERY = 6 - const val MEASUREMENT_LOCATION_TOE = 7 - const val MEASUREMENT_LOCATION_EAR = 8 - const val MEASUREMENT_LOCATION_WRIST = 9 - const val MEASUREMENT_LOCATION_VAGINA = 10 + public const val MEASUREMENT_LOCATION_UNKNOWN: Int = 0 + public const val MEASUREMENT_LOCATION_ARMPIT: Int = 1 + public const val MEASUREMENT_LOCATION_FINGER: Int = 2 + public const val MEASUREMENT_LOCATION_FOREHEAD: Int = 3 + public const val MEASUREMENT_LOCATION_MOUTH: Int = 4 + public const val MEASUREMENT_LOCATION_RECTUM: Int = 5 + public const val MEASUREMENT_LOCATION_TEMPORAL_ARTERY: Int = 6 + public const val MEASUREMENT_LOCATION_TOE: Int = 7 + public const val MEASUREMENT_LOCATION_EAR: Int = 8 + public const val MEASUREMENT_LOCATION_WRIST: Int = 9 + public const val MEASUREMENT_LOCATION_VAGINA: Int = 10 internal const val ARMPIT = "armpit" internal const val FINGER = "finger" @@ -46,7 +46,7 @@ public object BodyTemperatureMeasurementLocation { /** Internal mappings useful for interoperability between integers and strings. */ @RestrictTo(RestrictTo.Scope.LIBRARY) @JvmField - val MEASUREMENT_LOCATION_STRING_TO_INT_MAP: Map = + public val MEASUREMENT_LOCATION_STRING_TO_INT_MAP: Map = mapOf( ARMPIT to MEASUREMENT_LOCATION_ARMPIT, FINGER to MEASUREMENT_LOCATION_FINGER, @@ -62,7 +62,8 @@ public object BodyTemperatureMeasurementLocation { @RestrictTo(RestrictTo.Scope.LIBRARY) @JvmField - val MEASUREMENT_LOCATION_INT_TO_STRING_MAP = MEASUREMENT_LOCATION_STRING_TO_INT_MAP.reverse() + public val MEASUREMENT_LOCATION_INT_TO_STRING_MAP: Map = + MEASUREMENT_LOCATION_STRING_TO_INT_MAP.reverse() } /** Where on the user's body a temperature measurement was taken from. */ @@ -85,4 +86,4 @@ public object BodyTemperatureMeasurementLocation { ] ) @RestrictTo(RestrictTo.Scope.LIBRARY) -annotation class BodyTemperatureMeasurementLocations +public annotation class BodyTemperatureMeasurementLocations diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/CervicalMucusRecord.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/CervicalMucusRecord.kt index 7efc5b4e2081f..ef8ab91d69e0a 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/CervicalMucusRecord.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/CervicalMucusRecord.kt @@ -38,28 +38,28 @@ public class CervicalMucusRecord( @property:Sensations public val sensation: Int = SENSATION_UNKNOWN, ) : InstantaneousRecord { - companion object { - const val APPEARANCE_UNKNOWN = 0 - const val APPEARANCE_DRY = 1 - const val APPEARANCE_STICKY = 2 - const val APPEARANCE_CREAMY = 3 - const val APPEARANCE_WATERY = 4 + public companion object { + public const val APPEARANCE_UNKNOWN: Int = 0 + public const val APPEARANCE_DRY: Int = 1 + public const val APPEARANCE_STICKY: Int = 2 + public const val APPEARANCE_CREAMY: Int = 3 + public const val APPEARANCE_WATERY: Int = 4 /** A constant describing clear or egg white like looking cervical mucus. */ - const val APPEARANCE_EGG_WHITE = 5 + public const val APPEARANCE_EGG_WHITE: Int = 5 /** A constant describing an unusual (worth attention) kind of cervical mucus. */ - const val APPEARANCE_UNUSUAL = 6 + public const val APPEARANCE_UNUSUAL: Int = 6 - const val SENSATION_UNKNOWN = 0 - const val SENSATION_LIGHT = 1 - const val SENSATION_MEDIUM = 2 - const val SENSATION_HEAVY = 3 + public const val SENSATION_UNKNOWN: Int = 0 + public const val SENSATION_LIGHT: Int = 1 + public const val SENSATION_MEDIUM: Int = 2 + public const val SENSATION_HEAVY: Int = 3 /** Internal mappings useful for interoperability between integers and strings. */ @RestrictTo(RestrictTo.Scope.LIBRARY) @JvmField - val APPEARANCE_STRING_TO_INT_MAP: Map = + public val APPEARANCE_STRING_TO_INT_MAP: Map = mapOf( Appearance.CLEAR to APPEARANCE_EGG_WHITE, Appearance.CREAMY to APPEARANCE_CREAMY, @@ -71,11 +71,12 @@ public class CervicalMucusRecord( @RestrictTo(RestrictTo.Scope.LIBRARY) @JvmField - val APPEARANCE_INT_TO_STRING_MAP = APPEARANCE_STRING_TO_INT_MAP.reverse() + public val APPEARANCE_INT_TO_STRING_MAP: Map = + APPEARANCE_STRING_TO_INT_MAP.reverse() @RestrictTo(RestrictTo.Scope.LIBRARY) @JvmField - val SENSATION_STRING_TO_INT_MAP: Map = + public val SENSATION_STRING_TO_INT_MAP: Map = mapOf( Sensation.LIGHT to SENSATION_LIGHT, Sensation.MEDIUM to SENSATION_MEDIUM, @@ -84,7 +85,8 @@ public class CervicalMucusRecord( @RestrictTo(RestrictTo.Scope.LIBRARY) @JvmField - val SENSATION_INT_TO_STRING_MAP = SENSATION_STRING_TO_INT_MAP.reverse() + public val SENSATION_INT_TO_STRING_MAP: Map = + SENSATION_STRING_TO_INT_MAP.reverse() } /** List of supported Cervical Mucus Sensation types on Health Platform. */ @@ -98,7 +100,7 @@ public class CervicalMucusRecord( @Retention(AnnotationRetention.SOURCE) @IntDef(value = [SENSATION_UNKNOWN, SENSATION_LIGHT, SENSATION_MEDIUM, SENSATION_HEAVY]) @RestrictTo(RestrictTo.Scope.LIBRARY) - annotation class Sensations + public annotation class Sensations /** The consistency or appearance of the user's cervical mucus. */ internal object Appearance { @@ -125,7 +127,7 @@ public class CervicalMucusRecord( ] ) @RestrictTo(RestrictTo.Scope.LIBRARY) - annotation class Appearances + public annotation class Appearances override fun equals(other: Any?): Boolean { if (this === other) return true diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/CyclingPedalingCadenceRecord.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/CyclingPedalingCadenceRecord.kt index bc33a8f89236d..d57622def561d 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/CyclingPedalingCadenceRecord.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/CyclingPedalingCadenceRecord.kt @@ -75,7 +75,7 @@ public class CyclingPedalingCadenceRecord( return "CyclingPedalingCadenceRecord(startTime=$startTime, startZoneOffset=$startZoneOffset, endTime=$endTime, endZoneOffset=$endZoneOffset, samples=$samples, metadata=$metadata)" } - companion object { + public companion object { private const val TYPE = "CyclingPedalingCadenceSeries" private const val RPM_FIELD = "rpm" private val MAX_RPM = 10_000.0 @@ -84,19 +84,22 @@ public class CyclingPedalingCadenceRecord( * Metric identifier to retrieve average cycling pedaling cadence from * [androidx.health.connect.client.aggregate.AggregationResult]. */ - @JvmField val RPM_AVG: AggregateMetric = doubleMetric(TYPE, AVERAGE, RPM_FIELD) + @JvmField + public val RPM_AVG: AggregateMetric = doubleMetric(TYPE, AVERAGE, RPM_FIELD) /** * Metric identifier to retrieve minimum cycling pedaling cadence from * [androidx.health.connect.client.aggregate.AggregationResult]. */ - @JvmField val RPM_MIN: AggregateMetric = doubleMetric(TYPE, MINIMUM, RPM_FIELD) + @JvmField + public val RPM_MIN: AggregateMetric = doubleMetric(TYPE, MINIMUM, RPM_FIELD) /** * Metric identifier to retrieve maximum cycling pedaling cadence from * [androidx.health.connect.client.aggregate.AggregationResult]. */ - @JvmField val RPM_MAX: AggregateMetric = doubleMetric(TYPE, MAXIMUM, RPM_FIELD) + @JvmField + public val RPM_MAX: AggregateMetric = doubleMetric(TYPE, MAXIMUM, RPM_FIELD) } /** @@ -107,8 +110,8 @@ public class CyclingPedalingCadenceRecord( * @see CyclingPedalingCadenceRecord */ public class Sample( - val time: Instant, - @FloatRange(from = 0.0, to = 10_000.0) val revolutionsPerMinute: Double, + public val time: Instant, + @FloatRange(from = 0.0, to = 10_000.0) public val revolutionsPerMinute: Double, ) { init { diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/DistanceRecord.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/DistanceRecord.kt index fd0773f908051..feb43f18f3a05 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/DistanceRecord.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/DistanceRecord.kt @@ -89,7 +89,7 @@ public class DistanceRecord( return "DistanceRecord(startTime=$startTime, startZoneOffset=$startZoneOffset, endTime=$endTime, endZoneOffset=$endZoneOffset, distance=$distance, metadata=$metadata)" } - companion object { + public companion object { private val MAX_DISTANCE = 1000_000.meters /** @@ -97,7 +97,7 @@ public class DistanceRecord( * [androidx.health.connect.client.aggregate.AggregationResult]. */ @JvmField - val DISTANCE_TOTAL: AggregateMetric = + public val DISTANCE_TOTAL: AggregateMetric = AggregateMetric.doubleMetric( dataTypeName = "Distance", aggregationType = AggregateMetric.AggregationType.TOTAL, diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/ElevationGainedRecord.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/ElevationGainedRecord.kt index adfa5e1e62e98..ef94d156e9f9e 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/ElevationGainedRecord.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/ElevationGainedRecord.kt @@ -82,7 +82,7 @@ public class ElevationGainedRecord( return "ElevationGainedRecord(startTime=$startTime, startZoneOffset=$startZoneOffset, endTime=$endTime, endZoneOffset=$endZoneOffset, elevation=$elevation, metadata=$metadata)" } - companion object { + public companion object { private val MAX_ELEVATION_GAIN = (1000_000).meters private val MIN_ELEVATION_GAIN = (-1000_000).meters @@ -91,7 +91,7 @@ public class ElevationGainedRecord( * [androidx.health.connect.client.aggregate.AggregationResult]. */ @JvmField - val ELEVATION_GAINED_TOTAL: AggregateMetric = + public val ELEVATION_GAINED_TOTAL: AggregateMetric = AggregateMetric.doubleMetric( dataTypeName = "ElevationGained", aggregationType = AggregateMetric.AggregationType.TOTAL, diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/ExerciseCompletionGoal.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/ExerciseCompletionGoal.kt index 363bf67eb8022..7dd4ca54b54ad 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/ExerciseCompletionGoal.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/ExerciseCompletionGoal.kt @@ -20,9 +20,9 @@ import androidx.health.connect.client.units.Length import java.time.Duration /** A goal which should be met to complete a [PlannedExerciseStep]. */ -abstract class ExerciseCompletionGoal internal constructor() { +public abstract class ExerciseCompletionGoal internal constructor() { /** An [ExerciseCompletionGoal] that requires covering a specified distance. */ - class DistanceGoal(val distance: Length) : ExerciseCompletionGoal() { + public class DistanceGoal(public val distance: Length) : ExerciseCompletionGoal() { override fun equals(other: Any?): Boolean { if (this === other) return true if (other !is DistanceGoal) return false @@ -48,8 +48,10 @@ abstract class ExerciseCompletionGoal internal constructor() { *

For example, a swimming coach may specify '100m @ 1min40s'. This implies: complete 100m * and if you manage it in 1min30s, you will have 10s of rest prior to the next set. */ - class DistanceAndDurationGoal(val distance: Length, val duration: Duration) : - ExerciseCompletionGoal() { + public class DistanceAndDurationGoal( + public val distance: Length, + public val duration: Duration, + ) : ExerciseCompletionGoal() { override fun equals(other: Any?): Boolean { if (this === other) return true if (other !is DistanceAndDurationGoal) return false @@ -69,7 +71,7 @@ abstract class ExerciseCompletionGoal internal constructor() { } /** An [ExerciseCompletionGoal] that requires completing a specified number of steps. */ - class StepsGoal(val steps: Int) : ExerciseCompletionGoal() { + public class StepsGoal(public val steps: Int) : ExerciseCompletionGoal() { override fun equals(other: Any?): Boolean { if (this === other) return true if (other !is StepsGoal) return false @@ -87,7 +89,7 @@ abstract class ExerciseCompletionGoal internal constructor() { } /** An [ExerciseCompletionGoal] that requires a specified duration to elapse. */ - class DurationGoal(val duration: Duration) : ExerciseCompletionGoal() { + public class DurationGoal(public val duration: Duration) : ExerciseCompletionGoal() { override fun equals(other: Any?): Boolean { if (this === other) return true if (other !is DurationGoal) return false @@ -107,7 +109,7 @@ abstract class ExerciseCompletionGoal internal constructor() { /** * An [ExerciseCompletionGoal] that requires a specified number of repetitions to be completed. */ - class RepetitionsGoal(val repetitions: Int) : ExerciseCompletionGoal() { + public class RepetitionsGoal(public val repetitions: Int) : ExerciseCompletionGoal() { override fun equals(other: Any?): Boolean { if (this === other) return true if (other !is RepetitionsGoal) return false @@ -127,7 +129,8 @@ abstract class ExerciseCompletionGoal internal constructor() { /** * An [ExerciseCompletionGoal] that requires a specified number of total calories to be burned. */ - class TotalCaloriesBurnedGoal(val totalCalories: Energy) : ExerciseCompletionGoal() { + public class TotalCaloriesBurnedGoal(public val totalCalories: Energy) : + ExerciseCompletionGoal() { override fun equals(other: Any?): Boolean { if (this === other) return true if (other !is TotalCaloriesBurnedGoal) return false @@ -147,7 +150,8 @@ abstract class ExerciseCompletionGoal internal constructor() { /** * An [ExerciseCompletionGoal] that requires a specified number of active calories to be burned. */ - class ActiveCaloriesBurnedGoal(val activeCalories: Energy) : ExerciseCompletionGoal() { + public class ActiveCaloriesBurnedGoal(public val activeCalories: Energy) : + ExerciseCompletionGoal() { override fun equals(other: Any?): Boolean { if (this === other) return true if (other !is ActiveCaloriesBurnedGoal) return false @@ -165,7 +169,7 @@ abstract class ExerciseCompletionGoal internal constructor() { } /** An [ExerciseCompletionGoal] that is unknown. */ - object UnknownGoal : ExerciseCompletionGoal() { + public object UnknownGoal : ExerciseCompletionGoal() { override fun toString(): String { return "UnknownGoal()" } @@ -176,7 +180,7 @@ abstract class ExerciseCompletionGoal internal constructor() { * determine when the associated [PlannedExerciseStep] is complete, typically based upon some * instruction in the [PlannedExerciseStep.description] field. */ - object ManualCompletion : ExerciseCompletionGoal() { + public object ManualCompletion : ExerciseCompletionGoal() { override fun toString(): String { return "ManualCompletion()" } diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/ExercisePerformanceTarget.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/ExercisePerformanceTarget.kt index 2439fbff190f2..3dd0642dabd6f 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/ExercisePerformanceTarget.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/ExercisePerformanceTarget.kt @@ -20,12 +20,13 @@ import androidx.health.connect.client.units.Power import androidx.health.connect.client.units.Velocity /** An ongoing target that should be met during a [PlannedExerciseStep]. */ -abstract class ExercisePerformanceTarget internal constructor() { +public abstract class ExercisePerformanceTarget internal constructor() { /** * An [ExercisePerformanceTarget] that requires a target power range to be met during the * associated [PlannedExerciseStep]. */ - class PowerTarget(val minPower: Power, val maxPower: Power) : ExercisePerformanceTarget() { + public class PowerTarget(public val minPower: Power, public val maxPower: Power) : + ExercisePerformanceTarget() { override fun equals(other: Any?): Boolean { if (this === other) return true if (other !is PowerTarget) return false @@ -51,7 +52,7 @@ abstract class ExercisePerformanceTarget internal constructor() { * An [ExercisePerformanceTarget] that requires a target speed range to be met during the * associated [PlannedExerciseStep]. */ - class SpeedTarget(val minSpeed: Velocity, val maxSpeed: Velocity) : + public class SpeedTarget(public val minSpeed: Velocity, public val maxSpeed: Velocity) : ExercisePerformanceTarget() { override fun equals(other: Any?): Boolean { if (this === other) return true @@ -79,7 +80,7 @@ abstract class ExercisePerformanceTarget internal constructor() { * associated [PlannedExerciseStep].The value may be interpreted as RPM for e.g. cycling * activities, or as steps per minute for e.g. walking/running activities. */ - class CadenceTarget(val minCadence: Double, val maxCadence: Double) : + public class CadenceTarget(public val minCadence: Double, public val maxCadence: Double) : ExercisePerformanceTarget() { override fun equals(other: Any?): Boolean { if (this === other) return true @@ -106,7 +107,7 @@ abstract class ExercisePerformanceTarget internal constructor() { * An [ExercisePerformanceTarget] that requires a target heart rate range, in BPM, to be met * during the associated {@link PlannedExerciseStep}. */ - class HeartRateTarget(val minHeartRate: Double, val maxHeartRate: Double) : + public class HeartRateTarget(public val minHeartRate: Double, public val maxHeartRate: Double) : ExercisePerformanceTarget() { override fun equals(other: Any?): Boolean { if (this === other) return true @@ -133,7 +134,7 @@ abstract class ExercisePerformanceTarget internal constructor() { * An [ExercisePerformanceTarget] that requires a target weight to be lifted during the * associated [PlannedExerciseStep]. */ - class WeightTarget(val mass: Mass) : ExercisePerformanceTarget() { + public class WeightTarget(public val mass: Mass) : ExercisePerformanceTarget() { override fun equals(other: Any?): Boolean { if (this === other) return true if (other !is WeightTarget) return false @@ -158,7 +159,7 @@ abstract class ExercisePerformanceTarget internal constructor() { * 0: No exertion (at rest) 1: Very light 2-3: Light 4-5: Moderate 6-7: Hard 8-9: Very hard 10: * Maximum effort */ - class RateOfPerceivedExertionTarget(val rpe: Int) : ExercisePerformanceTarget() { + public class RateOfPerceivedExertionTarget(public val rpe: Int) : ExercisePerformanceTarget() { init { require(rpe in 0..10) { "RPE value must be between 0 and 10, inclusive." } } @@ -184,14 +185,14 @@ abstract class ExercisePerformanceTarget internal constructor() { * AMRAP (as many reps as possible) sets are often used in conjunction with a duration based * completion goal. */ - object AmrapTarget : ExercisePerformanceTarget() { + public object AmrapTarget : ExercisePerformanceTarget() { override fun toString(): String { return "AmrapTarget()" } } /** An [ExercisePerformanceTarget] that is unknown. */ - object UnknownTarget : ExercisePerformanceTarget() { + public object UnknownTarget : ExercisePerformanceTarget() { override fun toString(): String { return "UnknownTarget()" } diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/ExerciseRoute.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/ExerciseRoute.kt index 2133fc65b1ba3..aea3604086bb4 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/ExerciseRoute.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/ExerciseRoute.kt @@ -27,7 +27,7 @@ import java.time.Instant * Location points contain a timestamp, longitude, latitude, and optionally altitude, horizontal and * vertical accuracy. */ -class ExerciseRoute constructor(val route: List) { +public class ExerciseRoute constructor(public val route: List) { init { val sortedRoute: List = route.sortedBy { it.time } for (i in 0 until sortedRoute.lastIndex) { @@ -62,16 +62,16 @@ class ExerciseRoute constructor(val route: List) { * @param verticalAccuracy in [Length] unit. Optional field. Valid range: non-negative numbers. * @see ExerciseRouteResult */ - class Location( - val time: Instant, - val latitude: Double, - val longitude: Double, - val horizontalAccuracy: Length? = null, - val verticalAccuracy: Length? = null, - val altitude: Length? = null, + public class Location( + public val time: Instant, + public val latitude: Double, + public val longitude: Double, + public val horizontalAccuracy: Length? = null, + public val verticalAccuracy: Length? = null, + public val altitude: Length? = null, ) { - companion object { + public companion object { private const val MIN_LONGITUDE = -180.0 private const val MAX_LONGITUDE = 180.0 private const val MIN_LATITUDE = -90.0 diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/ExerciseRouteResult.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/ExerciseRouteResult.kt index 80098e1307e11..10d0b122d144e 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/ExerciseRouteResult.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/ExerciseRouteResult.kt @@ -17,10 +17,10 @@ package androidx.health.connect.client.records /** Result of the route associated with an exercise session a user does. */ -abstract class ExerciseRouteResult internal constructor() { +public abstract class ExerciseRouteResult internal constructor() { /** Class containing data for an [ExerciseRoute]. */ - class Data(val exerciseRoute: ExerciseRoute) : ExerciseRouteResult() { + public class Data(public val exerciseRoute: ExerciseRoute) : ExerciseRouteResult() { override fun equals(other: Any?): Boolean { if (other !is Data) { @@ -39,7 +39,7 @@ abstract class ExerciseRouteResult internal constructor() { } /** Class indicating that a permission hasn't been granted and a value couldn't be returned. */ - class ConsentRequired : ExerciseRouteResult() { + public class ConsentRequired : ExerciseRouteResult() { override fun equals(other: Any?): Boolean { return other is ConsentRequired } @@ -54,7 +54,7 @@ abstract class ExerciseRouteResult internal constructor() { } /** Class indicating that there's no data to request permissions for. */ - class NoData : ExerciseRouteResult() { + public class NoData : ExerciseRouteResult() { override fun equals(other: Any?): Boolean { return other is NoData } diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/ExerciseSegment.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/ExerciseSegment.kt index c3ba47fe8ec05..62c6d7247d3e6 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/ExerciseSegment.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/ExerciseSegment.kt @@ -136,7 +136,7 @@ constructor( return "ExerciseSegment(startTime=$startTime, endTime=$endTime, segmentType=$segmentType, repetitions=$repetitions, weight=$weight, setIndex=$setIndex, rateOfPerceivedExertion=$rateOfPerceivedExertion)" } - companion object { + public companion object { /** * Is a segment type compatible with a session type. * @@ -148,7 +148,7 @@ constructor( * @return True, if [sessionType] can contain the provided segment, otherwise false. */ @JvmStatic - fun isSegmentTypeCompatibleWithSessionType( + public fun isSegmentTypeCompatibleWithSessionType( @ExerciseSegmentTypes segmentType: Int, @ExerciseTypes sessionType: Int, ): Boolean { @@ -164,205 +164,205 @@ constructor( /** Next Id: 68. */ /** Use this type if the type of the exercise segment is not known. */ - const val EXERCISE_SEGMENT_TYPE_UNKNOWN = 0 + public const val EXERCISE_SEGMENT_TYPE_UNKNOWN: Int = 0 /** Use this type for arm curls. */ - const val EXERCISE_SEGMENT_TYPE_ARM_CURL = 1 + public const val EXERCISE_SEGMENT_TYPE_ARM_CURL: Int = 1 /** Use this type for back extensions. */ - const val EXERCISE_SEGMENT_TYPE_BACK_EXTENSION = 2 + public const val EXERCISE_SEGMENT_TYPE_BACK_EXTENSION: Int = 2 /** Use this type for ball slams. */ - const val EXERCISE_SEGMENT_TYPE_BALL_SLAM = 3 + public const val EXERCISE_SEGMENT_TYPE_BALL_SLAM: Int = 3 /** Use this type for barbel shoulder press. */ - const val EXERCISE_SEGMENT_TYPE_BARBELL_SHOULDER_PRESS = 4 + public const val EXERCISE_SEGMENT_TYPE_BARBELL_SHOULDER_PRESS: Int = 4 /** Use this type for bench presses. */ - const val EXERCISE_SEGMENT_TYPE_BENCH_PRESS = 5 + public const val EXERCISE_SEGMENT_TYPE_BENCH_PRESS: Int = 5 /** Use this type for bench sit up. */ - const val EXERCISE_SEGMENT_TYPE_BENCH_SIT_UP = 6 + public const val EXERCISE_SEGMENT_TYPE_BENCH_SIT_UP: Int = 6 /** Use this type for biking. */ - const val EXERCISE_SEGMENT_TYPE_BIKING = 7 + public const val EXERCISE_SEGMENT_TYPE_BIKING: Int = 7 /** Use this type for stationary biking. */ - const val EXERCISE_SEGMENT_TYPE_BIKING_STATIONARY = 8 + public const val EXERCISE_SEGMENT_TYPE_BIKING_STATIONARY: Int = 8 /** Use this type for burpees. */ - const val EXERCISE_SEGMENT_TYPE_BURPEE = 9 + public const val EXERCISE_SEGMENT_TYPE_BURPEE: Int = 9 /** Use this type for crunches. */ - const val EXERCISE_SEGMENT_TYPE_CRUNCH = 10 + public const val EXERCISE_SEGMENT_TYPE_CRUNCH: Int = 10 /** Use this type for deadlifts. */ - const val EXERCISE_SEGMENT_TYPE_DEADLIFT = 11 + public const val EXERCISE_SEGMENT_TYPE_DEADLIFT: Int = 11 /** Use this type for double arms triceps extensions. */ - const val EXERCISE_SEGMENT_TYPE_DOUBLE_ARM_TRICEPS_EXTENSION = 12 + public const val EXERCISE_SEGMENT_TYPE_DOUBLE_ARM_TRICEPS_EXTENSION: Int = 12 /** Use this type for left arm dumbbell curl. */ - const val EXERCISE_SEGMENT_TYPE_DUMBBELL_CURL_LEFT_ARM = 13 + public const val EXERCISE_SEGMENT_TYPE_DUMBBELL_CURL_LEFT_ARM: Int = 13 - const val EXERCISE_SEGMENT_TYPE_DUMBBELL_CURL_RIGHT_ARM = 14 + public const val EXERCISE_SEGMENT_TYPE_DUMBBELL_CURL_RIGHT_ARM: Int = 14 /** Use this type for right arm dumbbell curl. */ - const val EXERCISE_SEGMENT_TYPE_DUMBBELL_FRONT_RAISE = 15 + public const val EXERCISE_SEGMENT_TYPE_DUMBBELL_FRONT_RAISE: Int = 15 /** Use this type for dumbbell lateral raises. */ - const val EXERCISE_SEGMENT_TYPE_DUMBBELL_LATERAL_RAISE = 16 + public const val EXERCISE_SEGMENT_TYPE_DUMBBELL_LATERAL_RAISE: Int = 16 /** Use this type for dumbbells rows. */ - const val EXERCISE_SEGMENT_TYPE_DUMBBELL_ROW = 17 + public const val EXERCISE_SEGMENT_TYPE_DUMBBELL_ROW: Int = 17 /** Use this type for left arm triceps extensions. */ - const val EXERCISE_SEGMENT_TYPE_DUMBBELL_TRICEPS_EXTENSION_LEFT_ARM = 18 + public const val EXERCISE_SEGMENT_TYPE_DUMBBELL_TRICEPS_EXTENSION_LEFT_ARM: Int = 18 /** Use this type for right arm triceps extensions. */ - const val EXERCISE_SEGMENT_TYPE_DUMBBELL_TRICEPS_EXTENSION_RIGHT_ARM = 19 + public const val EXERCISE_SEGMENT_TYPE_DUMBBELL_TRICEPS_EXTENSION_RIGHT_ARM: Int = 19 /** Use this type for two arms triceps extensions. */ - const val EXERCISE_SEGMENT_TYPE_DUMBBELL_TRICEPS_EXTENSION_TWO_ARM = 20 + public const val EXERCISE_SEGMENT_TYPE_DUMBBELL_TRICEPS_EXTENSION_TWO_ARM: Int = 20 /** Use this type for elliptical workout. */ - const val EXERCISE_SEGMENT_TYPE_ELLIPTICAL = 21 + public const val EXERCISE_SEGMENT_TYPE_ELLIPTICAL: Int = 21 /** Use this type for forward twists. */ - const val EXERCISE_SEGMENT_TYPE_FORWARD_TWIST = 22 + public const val EXERCISE_SEGMENT_TYPE_FORWARD_TWIST: Int = 22 /** Use this type for front raises. */ - const val EXERCISE_SEGMENT_TYPE_FRONT_RAISE = 23 + public const val EXERCISE_SEGMENT_TYPE_FRONT_RAISE: Int = 23 /** Use this type for high intensity training. */ - const val EXERCISE_SEGMENT_TYPE_HIGH_INTENSITY_INTERVAL_TRAINING = 24 + public const val EXERCISE_SEGMENT_TYPE_HIGH_INTENSITY_INTERVAL_TRAINING: Int = 24 /** Use this type for hip thrusts. */ - const val EXERCISE_SEGMENT_TYPE_HIP_THRUST = 25 + public const val EXERCISE_SEGMENT_TYPE_HIP_THRUST: Int = 25 /** Use this type for hula-hoops. */ - const val EXERCISE_SEGMENT_TYPE_HULA_HOOP = 26 + public const val EXERCISE_SEGMENT_TYPE_HULA_HOOP: Int = 26 /** Use this type for jumping jacks. */ - const val EXERCISE_SEGMENT_TYPE_JUMPING_JACK = 27 + public const val EXERCISE_SEGMENT_TYPE_JUMPING_JACK: Int = 27 /** Use this type for jump rope. */ - const val EXERCISE_SEGMENT_TYPE_JUMP_ROPE = 28 + public const val EXERCISE_SEGMENT_TYPE_JUMP_ROPE: Int = 28 /** Use this type for kettlebell swings. */ - const val EXERCISE_SEGMENT_TYPE_KETTLEBELL_SWING = 29 + public const val EXERCISE_SEGMENT_TYPE_KETTLEBELL_SWING: Int = 29 /** Use this type for lateral raises. */ - const val EXERCISE_SEGMENT_TYPE_LATERAL_RAISE = 30 + public const val EXERCISE_SEGMENT_TYPE_LATERAL_RAISE: Int = 30 /** Use this type for lat pull-downs. */ - const val EXERCISE_SEGMENT_TYPE_LAT_PULL_DOWN = 31 + public const val EXERCISE_SEGMENT_TYPE_LAT_PULL_DOWN: Int = 31 /** Use this type for leg curls. */ - const val EXERCISE_SEGMENT_TYPE_LEG_CURL = 32 + public const val EXERCISE_SEGMENT_TYPE_LEG_CURL: Int = 32 /** Use this type for leg extensions. */ - const val EXERCISE_SEGMENT_TYPE_LEG_EXTENSION = 33 + public const val EXERCISE_SEGMENT_TYPE_LEG_EXTENSION: Int = 33 /** Use this type for leg presses. */ - const val EXERCISE_SEGMENT_TYPE_LEG_PRESS = 34 + public const val EXERCISE_SEGMENT_TYPE_LEG_PRESS: Int = 34 /** Use this type for leg raises. */ - const val EXERCISE_SEGMENT_TYPE_LEG_RAISE = 35 + public const val EXERCISE_SEGMENT_TYPE_LEG_RAISE: Int = 35 /** Use this type for lunges. */ - const val EXERCISE_SEGMENT_TYPE_LUNGE = 36 + public const val EXERCISE_SEGMENT_TYPE_LUNGE: Int = 36 /** Use this type for mountain climber. */ - const val EXERCISE_SEGMENT_TYPE_MOUNTAIN_CLIMBER = 37 + public const val EXERCISE_SEGMENT_TYPE_MOUNTAIN_CLIMBER: Int = 37 /** Use this type for other workout. */ - const val EXERCISE_SEGMENT_TYPE_OTHER_WORKOUT = 38 + public const val EXERCISE_SEGMENT_TYPE_OTHER_WORKOUT: Int = 38 /** Use this type for the pause. */ - const val EXERCISE_SEGMENT_TYPE_PAUSE = 39 + public const val EXERCISE_SEGMENT_TYPE_PAUSE: Int = 39 /** Use this type for pilates. */ - const val EXERCISE_SEGMENT_TYPE_PILATES = 40 + public const val EXERCISE_SEGMENT_TYPE_PILATES: Int = 40 /** Use this type for plank. */ - const val EXERCISE_SEGMENT_TYPE_PLANK = 41 + public const val EXERCISE_SEGMENT_TYPE_PLANK: Int = 41 /** Use this type for pull-ups. */ - const val EXERCISE_SEGMENT_TYPE_PULL_UP = 42 + public const val EXERCISE_SEGMENT_TYPE_PULL_UP: Int = 42 /** Use this type for punches. */ - const val EXERCISE_SEGMENT_TYPE_PUNCH = 43 + public const val EXERCISE_SEGMENT_TYPE_PUNCH: Int = 43 /** Use this type for the rest. */ - const val EXERCISE_SEGMENT_TYPE_REST = 44 + public const val EXERCISE_SEGMENT_TYPE_REST: Int = 44 /** Use this type for rowing machine workout. */ - const val EXERCISE_SEGMENT_TYPE_ROWING_MACHINE = 45 + public const val EXERCISE_SEGMENT_TYPE_ROWING_MACHINE: Int = 45 /** Use this type for running. */ - const val EXERCISE_SEGMENT_TYPE_RUNNING = 46 + public const val EXERCISE_SEGMENT_TYPE_RUNNING: Int = 46 /** Use this type for treadmill running. */ - const val EXERCISE_SEGMENT_TYPE_RUNNING_TREADMILL = 47 + public const val EXERCISE_SEGMENT_TYPE_RUNNING_TREADMILL: Int = 47 - const val EXERCISE_SEGMENT_TYPE_SHOULDER_PRESS = 48 + public const val EXERCISE_SEGMENT_TYPE_SHOULDER_PRESS: Int = 48 /** Use this type for shoulder press. */ - const val EXERCISE_SEGMENT_TYPE_SINGLE_ARM_TRICEPS_EXTENSION = 49 + public const val EXERCISE_SEGMENT_TYPE_SINGLE_ARM_TRICEPS_EXTENSION: Int = 49 /** Use this type for sit-ups. */ - const val EXERCISE_SEGMENT_TYPE_SIT_UP = 50 + public const val EXERCISE_SEGMENT_TYPE_SIT_UP: Int = 50 /** Use this type for squats. */ - const val EXERCISE_SEGMENT_TYPE_SQUAT = 51 + public const val EXERCISE_SEGMENT_TYPE_SQUAT: Int = 51 /** Use this type for stair climbing. */ - const val EXERCISE_SEGMENT_TYPE_STAIR_CLIMBING = 52 + public const val EXERCISE_SEGMENT_TYPE_STAIR_CLIMBING: Int = 52 /** Use this type for stair climbing machine. */ - const val EXERCISE_SEGMENT_TYPE_STAIR_CLIMBING_MACHINE = 53 + public const val EXERCISE_SEGMENT_TYPE_STAIR_CLIMBING_MACHINE: Int = 53 /** Use this type for stretching. */ - const val EXERCISE_SEGMENT_TYPE_STRETCHING = 54 + public const val EXERCISE_SEGMENT_TYPE_STRETCHING: Int = 54 /** Use this type for backstroke swimming. */ - const val EXERCISE_SEGMENT_TYPE_SWIMMING_BACKSTROKE = 55 + public const val EXERCISE_SEGMENT_TYPE_SWIMMING_BACKSTROKE: Int = 55 /** Use this type for breaststroke swimming. */ - const val EXERCISE_SEGMENT_TYPE_SWIMMING_BREASTSTROKE = 56 + public const val EXERCISE_SEGMENT_TYPE_SWIMMING_BREASTSTROKE: Int = 56 /** Use this type for butterfly swimming. */ - const val EXERCISE_SEGMENT_TYPE_SWIMMING_BUTTERFLY = 57 + public const val EXERCISE_SEGMENT_TYPE_SWIMMING_BUTTERFLY: Int = 57 - const val EXERCISE_SEGMENT_TYPE_SWIMMING_FREESTYLE = 58 + public const val EXERCISE_SEGMENT_TYPE_SWIMMING_FREESTYLE: Int = 58 /** Use this type for mixed swimming. */ - const val EXERCISE_SEGMENT_TYPE_SWIMMING_MIXED = 59 + public const val EXERCISE_SEGMENT_TYPE_SWIMMING_MIXED: Int = 59 /** Use this type for swimming in open water. */ - const val EXERCISE_SEGMENT_TYPE_SWIMMING_OPEN_WATER = 60 + public const val EXERCISE_SEGMENT_TYPE_SWIMMING_OPEN_WATER: Int = 60 /** Use this type if other swimming styles are not suitable. */ - const val EXERCISE_SEGMENT_TYPE_SWIMMING_OTHER = 61 + public const val EXERCISE_SEGMENT_TYPE_SWIMMING_OTHER: Int = 61 /** Use this type for swimming in the pool. */ - const val EXERCISE_SEGMENT_TYPE_SWIMMING_POOL = 62 + public const val EXERCISE_SEGMENT_TYPE_SWIMMING_POOL: Int = 62 /** Use this type for upper twists. */ - const val EXERCISE_SEGMENT_TYPE_UPPER_TWIST = 63 + public const val EXERCISE_SEGMENT_TYPE_UPPER_TWIST: Int = 63 /** Use this type for walking. */ - const val EXERCISE_SEGMENT_TYPE_WALKING = 64 + public const val EXERCISE_SEGMENT_TYPE_WALKING: Int = 64 /** Use this type for weightlifting. */ - const val EXERCISE_SEGMENT_TYPE_WEIGHTLIFTING = 65 + public const val EXERCISE_SEGMENT_TYPE_WEIGHTLIFTING: Int = 65 /** Use this type for wheelchair. */ - const val EXERCISE_SEGMENT_TYPE_WHEELCHAIR = 66 + public const val EXERCISE_SEGMENT_TYPE_WHEELCHAIR: Int = 66 /** Use this type for yoga. */ - const val EXERCISE_SEGMENT_TYPE_YOGA = 67 + public const val EXERCISE_SEGMENT_TYPE_YOGA: Int = 67 internal val UNIVERSAL_SESSION_TYPES = setOf( @@ -558,6 +558,6 @@ constructor( EXERCISE_SEGMENT_TYPE_PAUSE, ] ) - annotation class ExerciseSegmentTypes + public annotation class ExerciseSegmentTypes } } diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/ExerciseSessionRecord.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/ExerciseSessionRecord.kt index 1ed60cafdbec1..7004c91e057a1 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/ExerciseSessionRecord.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/ExerciseSessionRecord.kt @@ -39,7 +39,7 @@ import java.time.ZoneOffset * * @sample androidx.health.connect.client.samples.ReadExerciseSessions */ -class ExerciseSessionRecord +public class ExerciseSessionRecord internal constructor( override val startTime: Instant, override val startZoneOffset: ZoneOffset?, @@ -47,29 +47,29 @@ internal constructor( override val endZoneOffset: ZoneOffset?, override val metadata: Metadata, /** Type of exercise (e.g. walking, swimming). Required field. */ - @property:ExerciseTypes val exerciseType: Int, + @property:ExerciseTypes public val exerciseType: Int, /** Title of the session. Optional field. */ - val title: String? = null, + public val title: String? = null, /** Additional notes for the session. Optional field. */ - val notes: String? = null, + public val notes: String? = null, /** * [ExerciseSegment]s of the session. Optional field. Time in segments should be within the * parent session, and should not overlap with each other. */ - val segments: List = emptyList(), + public val segments: List = emptyList(), /** * [ExerciseLap]s of the session. Optional field. Time in laps should be within the parent * session, and should not overlap with each other. */ - val laps: List = emptyList(), + public val laps: List = emptyList(), /** * [ExerciseRouteResult] [ExerciseRouteResult] of the session. Location data points of * [ExerciseRoute] should be within the parent session, and should be before the end time of the * session. */ - val exerciseRouteResult: ExerciseRouteResult = ExerciseRouteResult.NoData(), - val plannedExerciseSessionId: String? = null, + public val exerciseRouteResult: ExerciseRouteResult = ExerciseRouteResult.NoData(), + public val plannedExerciseSessionId: String? = null, @Suppress("AutoBoxing") @get:Suppress("AutoBoxing") /** @@ -79,11 +79,11 @@ internal constructor( */ @FloatRange(from = 0.0, to = 10.0) @get:FloatRange(from = 0.0, to = 10.0) - val rateOfPerceivedExertion: Float? = null, + public val rateOfPerceivedExertion: Float? = null, ) : IntervalRecord { @JvmOverloads - constructor( + public constructor( startTime: Instant, startZoneOffset: ZoneOffset?, endTime: Instant, @@ -224,13 +224,13 @@ internal constructor( return "ExerciseSessionRecord(startTime=$startTime, startZoneOffset=$startZoneOffset, endTime=$endTime, endZoneOffset=$endZoneOffset, exerciseType=$exerciseType, title=$title, notes=$notes, metadata=$metadata, segments=$segments, laps=$laps, exerciseRouteResult=$exerciseRouteResult, rateOfPerceivedExertion=$rateOfPerceivedExertion)" } - companion object { + public companion object { /** * Metric identifier to retrieve the total exercise time from * [androidx.health.connect.client.aggregate.AggregationResult]. */ @JvmField - val EXERCISE_DURATION_TOTAL: AggregateMetric = + public val EXERCISE_DURATION_TOTAL: AggregateMetric = AggregateMetric.durationMetric( dataTypeName = "ActiveTime", aggregationType = AggregateMetric.AggregationType.TOTAL, @@ -246,71 +246,71 @@ internal constructor( * * Next Id: 84. */ - const val EXERCISE_TYPE_OTHER_WORKOUT = 0 - const val EXERCISE_TYPE_BADMINTON = 2 - const val EXERCISE_TYPE_BASEBALL = 4 - const val EXERCISE_TYPE_BASKETBALL = 5 - const val EXERCISE_TYPE_BIKING = 8 - const val EXERCISE_TYPE_BIKING_STATIONARY = 9 - const val EXERCISE_TYPE_BOOT_CAMP = 10 - const val EXERCISE_TYPE_BOXING = 11 - const val EXERCISE_TYPE_CALISTHENICS = 13 - const val EXERCISE_TYPE_CRICKET = 14 - const val EXERCISE_TYPE_DANCING = 16 - const val EXERCISE_TYPE_ELLIPTICAL = 25 - const val EXERCISE_TYPE_EXERCISE_CLASS = 26 - const val EXERCISE_TYPE_FENCING = 27 - const val EXERCISE_TYPE_FOOTBALL_AMERICAN = 28 - const val EXERCISE_TYPE_FOOTBALL_AUSTRALIAN = 29 - const val EXERCISE_TYPE_FRISBEE_DISC = 31 - const val EXERCISE_TYPE_GOLF = 32 - const val EXERCISE_TYPE_GUIDED_BREATHING = 33 - const val EXERCISE_TYPE_GYMNASTICS = 34 - const val EXERCISE_TYPE_HANDBALL = 35 - const val EXERCISE_TYPE_HIGH_INTENSITY_INTERVAL_TRAINING = 36 - const val EXERCISE_TYPE_HIKING = 37 - const val EXERCISE_TYPE_ICE_HOCKEY = 38 - const val EXERCISE_TYPE_ICE_SKATING = 39 - const val EXERCISE_TYPE_MARTIAL_ARTS = 44 - const val EXERCISE_TYPE_PADDLING = 46 - const val EXERCISE_TYPE_PARAGLIDING = 47 - const val EXERCISE_TYPE_PILATES = 48 - const val EXERCISE_TYPE_RACQUETBALL = 50 - const val EXERCISE_TYPE_ROCK_CLIMBING = 51 - const val EXERCISE_TYPE_ROLLER_HOCKEY = 52 - const val EXERCISE_TYPE_ROWING = 53 - const val EXERCISE_TYPE_ROWING_MACHINE = 54 - const val EXERCISE_TYPE_RUGBY = 55 - const val EXERCISE_TYPE_RUNNING = 56 - const val EXERCISE_TYPE_RUNNING_TREADMILL = 57 - const val EXERCISE_TYPE_SAILING = 58 - const val EXERCISE_TYPE_SCUBA_DIVING = 59 - const val EXERCISE_TYPE_SKATING = 60 - const val EXERCISE_TYPE_SKIING = 61 - const val EXERCISE_TYPE_SNOWBOARDING = 62 - const val EXERCISE_TYPE_SNOWSHOEING = 63 - const val EXERCISE_TYPE_SOCCER = 64 - const val EXERCISE_TYPE_SOFTBALL = 65 - const val EXERCISE_TYPE_SQUASH = 66 - const val EXERCISE_TYPE_STAIR_CLIMBING = 68 - const val EXERCISE_TYPE_STAIR_CLIMBING_MACHINE = 69 - const val EXERCISE_TYPE_STRENGTH_TRAINING = 70 - const val EXERCISE_TYPE_STRETCHING = 71 - const val EXERCISE_TYPE_SURFING = 72 - const val EXERCISE_TYPE_SWIMMING_OPEN_WATER = 73 - const val EXERCISE_TYPE_SWIMMING_POOL = 74 - const val EXERCISE_TYPE_TABLE_TENNIS = 75 - const val EXERCISE_TYPE_TENNIS = 76 - const val EXERCISE_TYPE_VOLLEYBALL = 78 - const val EXERCISE_TYPE_WALKING = 79 - const val EXERCISE_TYPE_WATER_POLO = 80 - const val EXERCISE_TYPE_WEIGHTLIFTING = 81 - const val EXERCISE_TYPE_WHEELCHAIR = 82 - const val EXERCISE_TYPE_YOGA = 83 + public const val EXERCISE_TYPE_OTHER_WORKOUT: Int = 0 + public const val EXERCISE_TYPE_BADMINTON: Int = 2 + public const val EXERCISE_TYPE_BASEBALL: Int = 4 + public const val EXERCISE_TYPE_BASKETBALL: Int = 5 + public const val EXERCISE_TYPE_BIKING: Int = 8 + public const val EXERCISE_TYPE_BIKING_STATIONARY: Int = 9 + public const val EXERCISE_TYPE_BOOT_CAMP: Int = 10 + public const val EXERCISE_TYPE_BOXING: Int = 11 + public const val EXERCISE_TYPE_CALISTHENICS: Int = 13 + public const val EXERCISE_TYPE_CRICKET: Int = 14 + public const val EXERCISE_TYPE_DANCING: Int = 16 + public const val EXERCISE_TYPE_ELLIPTICAL: Int = 25 + public const val EXERCISE_TYPE_EXERCISE_CLASS: Int = 26 + public const val EXERCISE_TYPE_FENCING: Int = 27 + public const val EXERCISE_TYPE_FOOTBALL_AMERICAN: Int = 28 + public const val EXERCISE_TYPE_FOOTBALL_AUSTRALIAN: Int = 29 + public const val EXERCISE_TYPE_FRISBEE_DISC: Int = 31 + public const val EXERCISE_TYPE_GOLF: Int = 32 + public const val EXERCISE_TYPE_GUIDED_BREATHING: Int = 33 + public const val EXERCISE_TYPE_GYMNASTICS: Int = 34 + public const val EXERCISE_TYPE_HANDBALL: Int = 35 + public const val EXERCISE_TYPE_HIGH_INTENSITY_INTERVAL_TRAINING: Int = 36 + public const val EXERCISE_TYPE_HIKING: Int = 37 + public const val EXERCISE_TYPE_ICE_HOCKEY: Int = 38 + public const val EXERCISE_TYPE_ICE_SKATING: Int = 39 + public const val EXERCISE_TYPE_MARTIAL_ARTS: Int = 44 + public const val EXERCISE_TYPE_PADDLING: Int = 46 + public const val EXERCISE_TYPE_PARAGLIDING: Int = 47 + public const val EXERCISE_TYPE_PILATES: Int = 48 + public const val EXERCISE_TYPE_RACQUETBALL: Int = 50 + public const val EXERCISE_TYPE_ROCK_CLIMBING: Int = 51 + public const val EXERCISE_TYPE_ROLLER_HOCKEY: Int = 52 + public const val EXERCISE_TYPE_ROWING: Int = 53 + public const val EXERCISE_TYPE_ROWING_MACHINE: Int = 54 + public const val EXERCISE_TYPE_RUGBY: Int = 55 + public const val EXERCISE_TYPE_RUNNING: Int = 56 + public const val EXERCISE_TYPE_RUNNING_TREADMILL: Int = 57 + public const val EXERCISE_TYPE_SAILING: Int = 58 + public const val EXERCISE_TYPE_SCUBA_DIVING: Int = 59 + public const val EXERCISE_TYPE_SKATING: Int = 60 + public const val EXERCISE_TYPE_SKIING: Int = 61 + public const val EXERCISE_TYPE_SNOWBOARDING: Int = 62 + public const val EXERCISE_TYPE_SNOWSHOEING: Int = 63 + public const val EXERCISE_TYPE_SOCCER: Int = 64 + public const val EXERCISE_TYPE_SOFTBALL: Int = 65 + public const val EXERCISE_TYPE_SQUASH: Int = 66 + public const val EXERCISE_TYPE_STAIR_CLIMBING: Int = 68 + public const val EXERCISE_TYPE_STAIR_CLIMBING_MACHINE: Int = 69 + public const val EXERCISE_TYPE_STRENGTH_TRAINING: Int = 70 + public const val EXERCISE_TYPE_STRETCHING: Int = 71 + public const val EXERCISE_TYPE_SURFING: Int = 72 + public const val EXERCISE_TYPE_SWIMMING_OPEN_WATER: Int = 73 + public const val EXERCISE_TYPE_SWIMMING_POOL: Int = 74 + public const val EXERCISE_TYPE_TABLE_TENNIS: Int = 75 + public const val EXERCISE_TYPE_TENNIS: Int = 76 + public const val EXERCISE_TYPE_VOLLEYBALL: Int = 78 + public const val EXERCISE_TYPE_WALKING: Int = 79 + public const val EXERCISE_TYPE_WATER_POLO: Int = 80 + public const val EXERCISE_TYPE_WEIGHTLIFTING: Int = 81 + public const val EXERCISE_TYPE_WHEELCHAIR: Int = 82 + public const val EXERCISE_TYPE_YOGA: Int = 83 @RestrictTo(RestrictTo.Scope.LIBRARY) @JvmField - val EXERCISE_TYPE_STRING_TO_INT_MAP: Map = + public val EXERCISE_TYPE_STRING_TO_INT_MAP: Map = mapOf( "back_extension" to EXERCISE_TYPE_CALISTHENICS, "badminton" to EXERCISE_TYPE_BADMINTON, @@ -403,7 +403,7 @@ internal constructor( @RestrictTo(RestrictTo.Scope.LIBRARY) @JvmField - val EXERCISE_TYPE_INT_TO_STRING_MAP = + public val EXERCISE_TYPE_INT_TO_STRING_MAP: Map = EXERCISE_TYPE_STRING_TO_INT_MAP.entries.associateBy({ it.value }, { it.key }) } @@ -476,5 +476,5 @@ internal constructor( EXERCISE_TYPE_YOGA, ] ) - annotation class ExerciseTypes + public annotation class ExerciseTypes } diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/FhirResource.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/FhirResource.kt index 4359e60e97657..4019b81449856 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/FhirResource.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/FhirResource.kt @@ -48,14 +48,19 @@ import androidx.health.connect.client.impl.platform.records.toPlatformFhirResour * @property data The FHIR resource data in JSON representation. */ @ExperimentalPersonalHealthRecordApi -class FhirResource(@FhirResourceType val type: Int, val id: String, val data: String) { +public class FhirResource( + @FhirResourceType public val type: Int, + public val id: String, + public val data: String, +) { @SuppressLint("NewApi") // already checked with a feature availability check internal val platformFhirResource: PlatformFhirResource = withPhrFeatureCheck(this::class) { PlatformFhirResourceBuilder(type.toPlatformFhirResourceType(), id, data).build() } - override fun toString() = toString(this, mapOf("type" to type, "id" to id, "data" to data)) + override fun toString(): String = + toString(this, mapOf("type" to type, "id" to id, "data" to data)) override fun equals(other: Any?): Boolean { if (this === other) return true @@ -75,66 +80,66 @@ class FhirResource(@FhirResourceType val type: Int, val id: String, val data: St return result } - companion object { + public companion object { /** FHIR resource type for [Immunization](https://www.hl7.org/fhir/immunization.html). */ - const val FHIR_RESOURCE_TYPE_IMMUNIZATION = 1 + public const val FHIR_RESOURCE_TYPE_IMMUNIZATION: Int = 1 /** * FHIR resource type for * [AllergyIntolerance](https://www.hl7.org/fhir/allergyintolerance.html). */ - const val FHIR_RESOURCE_TYPE_ALLERGY_INTOLERANCE = 2 + public const val FHIR_RESOURCE_TYPE_ALLERGY_INTOLERANCE: Int = 2 /** * FHIR resource type for a [FHIR Observation](https://www.hl7.org/fhir/observation.html). */ - const val FHIR_RESOURCE_TYPE_OBSERVATION = 3 + public const val FHIR_RESOURCE_TYPE_OBSERVATION: Int = 3 /** FHIR resource type for a [FHIR Condition](https://www.hl7.org/fhir/condition.html). */ - const val FHIR_RESOURCE_TYPE_CONDITION = 4 + public const val FHIR_RESOURCE_TYPE_CONDITION: Int = 4 /** FHIR resource type for a [FHIR Procedure](https://www.hl7.org/fhir/procedure.html). */ - const val FHIR_RESOURCE_TYPE_PROCEDURE = 5 + public const val FHIR_RESOURCE_TYPE_PROCEDURE: Int = 5 /** FHIR resource type for a [FHIR Medication](https://www.hl7.org/fhir/medication.html). */ - const val FHIR_RESOURCE_TYPE_MEDICATION = 6 + public const val FHIR_RESOURCE_TYPE_MEDICATION: Int = 6 /** * FHIR resource type for a * [FHIR MedicationRequest](https://www.hl7.org/fhir/medicationrequest.html). */ - const val FHIR_RESOURCE_TYPE_MEDICATION_REQUEST = 7 + public const val FHIR_RESOURCE_TYPE_MEDICATION_REQUEST: Int = 7 /** * FHIR resource type for a * [FHIR MedicationStatement](https://www.hl7.org/fhir/medicationstatement.html). */ - const val FHIR_RESOURCE_TYPE_MEDICATION_STATEMENT = 8 + public const val FHIR_RESOURCE_TYPE_MEDICATION_STATEMENT: Int = 8 /** FHIR resource type for a [FHIR Patient](https://www.hl7.org/fhir/patient.html). */ - const val FHIR_RESOURCE_TYPE_PATIENT = 9 + public const val FHIR_RESOURCE_TYPE_PATIENT: Int = 9 /** * FHIR resource type for a [FHIR Practitioner](https://www.hl7.org/fhir/practitioner.html). */ - const val FHIR_RESOURCE_TYPE_PRACTITIONER = 10 + public const val FHIR_RESOURCE_TYPE_PRACTITIONER: Int = 10 /** * FHIR resource type for a * [FHIR PractitionerRole](https://www.hl7.org/fhir/practitionerrole.html). */ - const val FHIR_RESOURCE_TYPE_PRACTITIONER_ROLE = 11 + public const val FHIR_RESOURCE_TYPE_PRACTITIONER_ROLE: Int = 11 /** FHIR resource type for a [FHIR Encounter](https://www.hl7.org/fhir/encounter.html). */ - const val FHIR_RESOURCE_TYPE_ENCOUNTER = 12 + public const val FHIR_RESOURCE_TYPE_ENCOUNTER: Int = 12 /** FHIR resource type for a [FHIR Location](https://www.hl7.org/fhir/location.html). */ - const val FHIR_RESOURCE_TYPE_LOCATION = 13 + public const val FHIR_RESOURCE_TYPE_LOCATION: Int = 13 /** * FHIR resource type for a [FHIR Organization](https://www.hl7.org/fhir/organization.html). */ - const val FHIR_RESOURCE_TYPE_ORGANIZATION = 14 + public const val FHIR_RESOURCE_TYPE_ORGANIZATION: Int = 14 /** List of possible FHIR resource types. */ @RestrictTo(RestrictTo.Scope.LIBRARY) @@ -155,6 +160,6 @@ class FhirResource(@FhirResourceType val type: Int, val id: String, val data: St FHIR_RESOURCE_TYPE_ORGANIZATION, ) @Retention(AnnotationRetention.SOURCE) - annotation class FhirResourceType + public annotation class FhirResourceType } } diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/FhirVersion.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/FhirVersion.kt index cf59176f00dc4..10b5f41050f23 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/FhirVersion.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/FhirVersion.kt @@ -36,7 +36,8 @@ import androidx.health.connect.client.impl.platform.records.PlatformFhirVersion * [UnsupportedOperationException] would be thrown if the feature is not available. */ @ExperimentalPersonalHealthRecordApi -class FhirVersion(val major: Int, val minor: Int, val patch: Int) : Comparable { +public class FhirVersion(public val major: Int, public val minor: Int, public val patch: Int) : + Comparable { @SuppressLint("NewApi") // already checked with a feature availability check internal val platformFhirVersion: PlatformFhirVersion = withPhrFeatureCheck(this::class) { @@ -86,12 +87,12 @@ class FhirVersion(val major: Int, val minor: Int, val patch: Int) : Comparable = + public val FLOORS_CLIMBED_TOTAL: AggregateMetric = AggregateMetric.doubleMetric( "FloorsClimbed", AggregateMetric.AggregationType.TOTAL, diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/HeartRateRecord.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/HeartRateRecord.kt index a9cdcb869e316..c01abb8d35103 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/HeartRateRecord.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/HeartRateRecord.kt @@ -69,13 +69,13 @@ public class HeartRateRecord( return "HeartRateRecord(startTime=$startTime, startZoneOffset=$startZoneOffset, endTime=$endTime, endZoneOffset=$endZoneOffset, samples=$samples, metadata=$metadata)" } - companion object { + public companion object { private const val HEART_RATE_TYPE_NAME = "HeartRateSeries" private const val BPM_FIELD_NAME = "bpm" /** Metric identifier to retrieve the average heart rate from [AggregationResult]. */ @JvmField - val BPM_AVG: AggregateMetric = + public val BPM_AVG: AggregateMetric = AggregateMetric.longMetric( HEART_RATE_TYPE_NAME, AggregateMetric.AggregationType.AVERAGE, @@ -84,7 +84,7 @@ public class HeartRateRecord( /** Metric identifier to retrieve the minimum heart rate from [AggregationResult]. */ @JvmField - val BPM_MIN: AggregateMetric = + public val BPM_MIN: AggregateMetric = AggregateMetric.longMetric( HEART_RATE_TYPE_NAME, AggregateMetric.AggregationType.MINIMUM, @@ -93,7 +93,7 @@ public class HeartRateRecord( /** Metric identifier to retrieve the maximum heart rate from [AggregationResult]. */ @JvmField - val BPM_MAX: AggregateMetric = + public val BPM_MAX: AggregateMetric = AggregateMetric.longMetric( HEART_RATE_TYPE_NAME, AggregateMetric.AggregationType.MAXIMUM, @@ -105,7 +105,7 @@ public class HeartRateRecord( * [AggregationResult]. */ @JvmField - val MEASUREMENTS_COUNT: AggregateMetric = + public val MEASUREMENTS_COUNT: AggregateMetric = AggregateMetric.countMetric(HEART_RATE_TYPE_NAME) } @@ -117,8 +117,8 @@ public class HeartRateRecord( * @see HeartRateRecord */ public class Sample( - val time: Instant, - @androidx.annotation.IntRange(from = 1, to = 300) val beatsPerMinute: Long, + public val time: Instant, + @androidx.annotation.IntRange(from = 1, to = 300) public val beatsPerMinute: Long, ) { init { diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/HeightRecord.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/HeightRecord.kt index e795c04100fbc..699e952c8c0a1 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/HeightRecord.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/HeightRecord.kt @@ -76,7 +76,7 @@ public class HeightRecord( return "HeightRecord(time=$time, zoneOffset=$zoneOffset, height=$height, metadata=$metadata)" } - companion object { + public companion object { private const val HEIGHT_NAME = "Height" private const val HEIGHT_FIELD_NAME = "height" private val MAX_HEIGHT = 3.meters @@ -86,7 +86,7 @@ public class HeightRecord( * [androidx.health.connect.client.aggregate.AggregationResult]. */ @JvmField - val HEIGHT_AVG: AggregateMetric = + public val HEIGHT_AVG: AggregateMetric = AggregateMetric.doubleMetric( dataTypeName = HEIGHT_NAME, aggregationType = AggregateMetric.AggregationType.AVERAGE, @@ -99,7 +99,7 @@ public class HeightRecord( * [androidx.health.connect.client.aggregate.AggregationResult]. */ @JvmField - val HEIGHT_MIN: AggregateMetric = + public val HEIGHT_MIN: AggregateMetric = AggregateMetric.doubleMetric( dataTypeName = HEIGHT_NAME, aggregationType = AggregateMetric.AggregationType.MINIMUM, @@ -112,7 +112,7 @@ public class HeightRecord( * [androidx.health.connect.client.aggregate.AggregationResult]. */ @JvmField - val HEIGHT_MAX: AggregateMetric = + public val HEIGHT_MAX: AggregateMetric = AggregateMetric.doubleMetric( dataTypeName = HEIGHT_NAME, aggregationType = AggregateMetric.AggregationType.MAXIMUM, diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/HydrationRecord.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/HydrationRecord.kt index b76101df518a4..f99ef3496f9af 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/HydrationRecord.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/HydrationRecord.kt @@ -77,7 +77,7 @@ public class HydrationRecord( return "HydrationRecord(startTime=$startTime, startZoneOffset=$startZoneOffset, endTime=$endTime, endZoneOffset=$endZoneOffset, volume=$volume, metadata=$metadata)" } - companion object { + public companion object { private val MAX_VOLUME = 100.liters /** @@ -85,7 +85,7 @@ public class HydrationRecord( * [androidx.health.connect.client.aggregate.AggregationResult]. */ @JvmField - val VOLUME_TOTAL: AggregateMetric = + public val VOLUME_TOTAL: AggregateMetric = AggregateMetric.doubleMetric( dataTypeName = "Hydration", aggregationType = AggregateMetric.AggregationType.TOTAL, diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/IntermenstrualBleedingRecord.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/IntermenstrualBleedingRecord.kt index 16e9bc8ba1b4e..a18d6288fb7ce 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/IntermenstrualBleedingRecord.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/IntermenstrualBleedingRecord.kt @@ -21,7 +21,7 @@ import java.time.Instant import java.time.ZoneOffset /** Captures an instance of user's intermenstrual bleeding, also known as spotting. */ -class IntermenstrualBleedingRecord( +public class IntermenstrualBleedingRecord( override val time: Instant, override val zoneOffset: ZoneOffset?, override val metadata: Metadata, diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/MealType.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/MealType.kt index 54999a8c08600..d8f49fdd12bee 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/MealType.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/MealType.kt @@ -31,23 +31,23 @@ public object MealType { internal const val DINNER = "dinner" internal const val SNACK = "snack" - const val MEAL_TYPE_UNKNOWN = 0 + public const val MEAL_TYPE_UNKNOWN: Int = 0 /** Use this for the first meal of the day, usually the morning meal. */ - const val MEAL_TYPE_BREAKFAST = 1 + public const val MEAL_TYPE_BREAKFAST: Int = 1 /** Use this for the noon meal. */ - const val MEAL_TYPE_LUNCH = 2 + public const val MEAL_TYPE_LUNCH: Int = 2 /** Use this for last meal of the day, usually the evening meal. */ - const val MEAL_TYPE_DINNER = 3 + public const val MEAL_TYPE_DINNER: Int = 3 /** Any meal outside of the usual three meals per day. */ - const val MEAL_TYPE_SNACK = 4 + public const val MEAL_TYPE_SNACK: Int = 4 @RestrictTo(RestrictTo.Scope.LIBRARY) @JvmField - val MEAL_TYPE_STRING_TO_INT_MAP: Map = + public val MEAL_TYPE_STRING_TO_INT_MAP: Map = mapOf( UNKNOWN to MEAL_TYPE_UNKNOWN, BREAKFAST to MEAL_TYPE_BREAKFAST, @@ -58,7 +58,7 @@ public object MealType { @RestrictTo(RestrictTo.Scope.LIBRARY) @JvmField - val MEAL_TYPE_INT_TO_STRING_MAP = MEAL_TYPE_STRING_TO_INT_MAP.reverse() + public val MEAL_TYPE_INT_TO_STRING_MAP: Map = MEAL_TYPE_STRING_TO_INT_MAP.reverse() } /** Type of meal. */ @@ -68,4 +68,4 @@ public object MealType { value = [MEAL_TYPE_UNKNOWN, MEAL_TYPE_BREAKFAST, MEAL_TYPE_LUNCH, MEAL_TYPE_DINNER, MEAL_TYPE_SNACK] ) -annotation class MealTypes +public annotation class MealTypes diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/MedicalDataSource.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/MedicalDataSource.kt index f6b6e6de7e33c..751743c51e0c0 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/MedicalDataSource.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/MedicalDataSource.kt @@ -50,13 +50,13 @@ import java.time.Instant * has never happened or no data is linked to this `MedicalDataSource`. */ @ExperimentalPersonalHealthRecordApi -class MedicalDataSource( - val id: String, - val packageName: String, - val fhirBaseUri: Uri, - val displayName: String, - val fhirVersion: FhirVersion, - val lastDataUpdateTime: Instant?, +public class MedicalDataSource( + public val id: String, + public val packageName: String, + public val fhirBaseUri: Uri, + public val displayName: String, + public val fhirVersion: FhirVersion, + public val lastDataUpdateTime: Instant?, ) { @SuppressLint("NewApi") // already checked with a feature availability check internal val platformMedicalDataSource: PlatformMedicalDataSource = @@ -72,7 +72,7 @@ class MedicalDataSource( .build() } - override fun toString() = + override fun toString(): String = toString( this, mapOf( diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/MedicalResource.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/MedicalResource.kt index c24ca97a0c3ca..541a83d5861ec 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/MedicalResource.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/MedicalResource.kt @@ -57,12 +57,12 @@ import androidx.health.connect.client.records.MedicalResource.Companion.MEDICAL_ * @property fhirResource The [FhirResource] that this `MedicalResource` represents. */ @ExperimentalPersonalHealthRecordApi -class MedicalResource( - @MedicalResourceType val type: Int, - val id: MedicalResourceId, - val dataSourceId: String, - val fhirVersion: FhirVersion, - val fhirResource: FhirResource, +public class MedicalResource( + @MedicalResourceType public val type: Int, + public val id: MedicalResourceId, + public val dataSourceId: String, + public val fhirVersion: FhirVersion, + public val fhirResource: FhirResource, ) { @SuppressLint("NewApi") // already checked with a feature availability check internal val platformMedicalResource: PlatformMedicalResource = @@ -109,51 +109,51 @@ class MedicalResource( return result } - companion object { + public companion object { /** Medical resource type that labels data as vaccines. */ - const val MEDICAL_RESOURCE_TYPE_VACCINES = 1 + public const val MEDICAL_RESOURCE_TYPE_VACCINES: Int = 1 /** Medical resource type that labels data as allergies or intolerances. */ - const val MEDICAL_RESOURCE_TYPE_ALLERGIES_INTOLERANCES = 2 + public const val MEDICAL_RESOURCE_TYPE_ALLERGIES_INTOLERANCES: Int = 2 /** Medical resource type that labels data as to do with pregnancy. */ - const val MEDICAL_RESOURCE_TYPE_PREGNANCY = 3 + public const val MEDICAL_RESOURCE_TYPE_PREGNANCY: Int = 3 /** Medical resource type that labels data as social history. */ - const val MEDICAL_RESOURCE_TYPE_SOCIAL_HISTORY = 4 + public const val MEDICAL_RESOURCE_TYPE_SOCIAL_HISTORY: Int = 4 /** Medical resource type that labels data as vital signs. */ - const val MEDICAL_RESOURCE_TYPE_VITAL_SIGNS = 5 + public const val MEDICAL_RESOURCE_TYPE_VITAL_SIGNS: Int = 5 /** Medical resource type that labels data as results (Laboratory or pathology). */ - const val MEDICAL_RESOURCE_TYPE_LABORATORY_RESULTS = 6 + public const val MEDICAL_RESOURCE_TYPE_LABORATORY_RESULTS: Int = 6 /** * Medical resource type that labels data as medical conditions (clinical condition, * problem, diagnosis etc). */ - const val MEDICAL_RESOURCE_TYPE_CONDITIONS = 7 + public const val MEDICAL_RESOURCE_TYPE_CONDITIONS: Int = 7 /** * Medical resource type that labels data as procedures (actions taken on or for a patient). */ - const val MEDICAL_RESOURCE_TYPE_PROCEDURES = 8 + public const val MEDICAL_RESOURCE_TYPE_PROCEDURES: Int = 8 /** Medical resource type that labels data as medication related. */ - const val MEDICAL_RESOURCE_TYPE_MEDICATIONS = 9 + public const val MEDICAL_RESOURCE_TYPE_MEDICATIONS: Int = 9 /** * Medical resource type that labels data as related to personal details, including * demographic information such as name, date of birth, and contact details such as address * or telephone numbers. */ - const val MEDICAL_RESOURCE_TYPE_PERSONAL_DETAILS = 10 + public const val MEDICAL_RESOURCE_TYPE_PERSONAL_DETAILS: Int = 10 /** * Medical resource type that labels data as related to practitioners. This is information * about the doctors, nurses, masseurs, physios, etc who have been involved with the user. */ - const val MEDICAL_RESOURCE_TYPE_PRACTITIONER_DETAILS = 11 + public const val MEDICAL_RESOURCE_TYPE_PRACTITIONER_DETAILS: Int = 11 /** * Medical resource type that labels data as related to an encounter with a practitioner. @@ -161,7 +161,7 @@ class MedicalResource( * videoconference appointments, and information about the time, location and organization * who is being met. */ - const val MEDICAL_RESOURCE_TYPE_VISITS = 12 + public const val MEDICAL_RESOURCE_TYPE_VISITS: Int = 12 @RestrictTo(RestrictTo.Scope.LIBRARY) @IntDef( @@ -179,6 +179,6 @@ class MedicalResource( MEDICAL_RESOURCE_TYPE_VITAL_SIGNS, ) @Retention(AnnotationRetention.SOURCE) - annotation class MedicalResourceType + public annotation class MedicalResourceType } } diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/MedicalResourceId.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/MedicalResourceId.kt index 970a957b69cc7..7b857627d072d 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/MedicalResourceId.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/MedicalResourceId.kt @@ -45,10 +45,10 @@ import androidx.health.connect.client.records.FhirResource.Companion.FhirResourc * [MedicalDataSource]. */ @ExperimentalPersonalHealthRecordApi -class MedicalResourceId( - val dataSourceId: String, - @FhirResourceType val fhirResourceType: Int, - val fhirResourceId: String, +public class MedicalResourceId( + public val dataSourceId: String, + @FhirResourceType public val fhirResourceType: Int, + public val fhirResourceId: String, ) { @SuppressLint("NewApi") // already checked with a feature availability check internal val platformMedicalResourceId: PlatformMedicalResourceId = @@ -78,7 +78,7 @@ class MedicalResourceId( return result } - override fun toString() = + override fun toString(): String = toString( this, mapOf( @@ -88,7 +88,7 @@ class MedicalResourceId( ), ) - companion object { + public companion object { /** * Creates a [MedicalResourceId] instance from `dataSourceId` and `fhirReference`. * @@ -111,7 +111,10 @@ class MedicalResourceId( */ @SuppressLint("NewApi") // checked with feature availability @JvmStatic - fun fromFhirReference(dataSourceId: String, fhirReference: String): MedicalResourceId = + public fun fromFhirReference( + dataSourceId: String, + fhirReference: String, + ): MedicalResourceId = withPhrFeatureCheck(this::class, "fromFhirReference") { PlatformMedicalResourceId.fromFhirReference(dataSourceId, fhirReference) .toSdkMedicalResourceId() diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/MenstruationFlowRecord.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/MenstruationFlowRecord.kt index 9d796b2c5adcb..312df86da31be 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/MenstruationFlowRecord.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/MenstruationFlowRecord.kt @@ -56,20 +56,20 @@ public class MenstruationFlowRecord( return "MenstruationFlowRecord(time=$time, zoneOffset=$zoneOffset, flow=$flow, metadata=$metadata)" } - companion object { - const val FLOW_UNKNOWN = 0 - const val FLOW_LIGHT = 1 - const val FLOW_MEDIUM = 2 - const val FLOW_HEAVY = 3 + public companion object { + public const val FLOW_UNKNOWN: Int = 0 + public const val FLOW_LIGHT: Int = 1 + public const val FLOW_MEDIUM: Int = 2 + public const val FLOW_HEAVY: Int = 3 @RestrictTo(RestrictTo.Scope.LIBRARY) @JvmField - val FLOW_TYPE_STRING_TO_INT_MAP: Map = + public val FLOW_TYPE_STRING_TO_INT_MAP: Map = mapOf("light" to FLOW_LIGHT, "medium" to FLOW_MEDIUM, "heavy" to FLOW_HEAVY) @RestrictTo(RestrictTo.Scope.LIBRARY) @JvmField - val FLOW_TYPE_INT_TO_STRING_MAP: Map = + public val FLOW_TYPE_INT_TO_STRING_MAP: Map = FLOW_TYPE_STRING_TO_INT_MAP.entries.associateBy({ it.value }, { it.key }) } @@ -77,5 +77,5 @@ public class MenstruationFlowRecord( @Retention(AnnotationRetention.SOURCE) @IntDef(value = [FLOW_UNKNOWN, FLOW_LIGHT, FLOW_MEDIUM, FLOW_HEAVY]) @RestrictTo(RestrictTo.Scope.LIBRARY) - annotation class Flows + public annotation class Flows } diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/MenstruationPeriodRecord.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/MenstruationPeriodRecord.kt index baa7ed150f263..1f3e1d2e4d358 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/MenstruationPeriodRecord.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/MenstruationPeriodRecord.kt @@ -24,7 +24,7 @@ import java.time.Instant import java.time.ZoneOffset /** Captures user's menstruation periods. */ -class MenstruationPeriodRecord( +public class MenstruationPeriodRecord( override val startTime: Instant, override val startZoneOffset: ZoneOffset?, override val endTime: Instant, diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/MindfulnessSessionRecord.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/MindfulnessSessionRecord.kt index 746b3b647f4df..9a7b4508e2d47 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/MindfulnessSessionRecord.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/MindfulnessSessionRecord.kt @@ -38,18 +38,18 @@ import java.time.ZoneOffset * installed on the device. To check if available: call [HealthConnectFeatures.getFeatureStatus] and * pass [HealthConnectFeatures.FEATURE_MINDFULNESS_SESSION] as an argument. */ -class MindfulnessSessionRecord( +public class MindfulnessSessionRecord( override val startTime: Instant, override val startZoneOffset: ZoneOffset?, override val endTime: Instant, override val endZoneOffset: ZoneOffset?, override val metadata: Metadata, /** Type of mindfulness session (e.g. meditation, breathing, including unknown type). */ - @property:MindfulnessSessionTypes val mindfulnessSessionType: Int, + @property:MindfulnessSessionTypes public val mindfulnessSessionType: Int, /** Title of the session. */ - val title: String? = null, + public val title: String? = null, /** Additional notes for the session. */ - val notes: String? = null, + public val notes: String? = null, ) : IntervalRecord { init { @@ -94,7 +94,7 @@ class MindfulnessSessionRecord( return "MindfulnessSessionRecord(startTime=$startTime, startZoneOffset=$startZoneOffset, endTime=$endTime, endZoneOffset=$endZoneOffset, mindfulnessSessionType=$mindfulnessSessionType, title=$title, notes=$notes, metadata=$metadata)" } - companion object { + public companion object { /** * Metric identifier to retrieve the total mindfulness session duration from * [androidx.health.connect.client.aggregate.AggregationResult]. To check if this metric is @@ -102,7 +102,7 @@ class MindfulnessSessionRecord( * [HealthConnectFeatures.FEATURE_MINDFULNESS_SESSION] as the argument. */ @JvmField - val MINDFULNESS_DURATION_TOTAL: AggregateMetric = + public val MINDFULNESS_DURATION_TOTAL: AggregateMetric = AggregateMetric.durationMetric("MindfulnessSession") /** @@ -112,26 +112,26 @@ class MindfulnessSessionRecord( * * Use this type if the mindfulness session type is unknown. */ - const val MINDFULNESS_SESSION_TYPE_UNKNOWN = 0 + public const val MINDFULNESS_SESSION_TYPE_UNKNOWN: Int = 0 /** Meditation mindfulness session. */ - const val MINDFULNESS_SESSION_TYPE_MEDITATION = 1 + public const val MINDFULNESS_SESSION_TYPE_MEDITATION: Int = 1 /** Guided breathing mindfulness session. */ - const val MINDFULNESS_SESSION_TYPE_BREATHING = 2 + public const val MINDFULNESS_SESSION_TYPE_BREATHING: Int = 2 /** Music/soundscapes mindfulness session. */ - const val MINDFULNESS_SESSION_TYPE_MUSIC = 3 + public const val MINDFULNESS_SESSION_TYPE_MUSIC: Int = 3 /** Stretches/movement mindfulness session. */ - const val MINDFULNESS_SESSION_TYPE_MOVEMENT = 4 + public const val MINDFULNESS_SESSION_TYPE_MOVEMENT: Int = 4 /** Unguided mindfulness session. */ - const val MINDFULNESS_SESSION_TYPE_UNGUIDED = 5 + public const val MINDFULNESS_SESSION_TYPE_UNGUIDED: Int = 5 @RestrictTo(RestrictTo.Scope.LIBRARY) @JvmField - val MINDFULNESS_SESSION_TYPE_STRING_TO_INT_MAP = + public val MINDFULNESS_SESSION_TYPE_STRING_TO_INT_MAP: Map = mapOf( "breathing" to MINDFULNESS_SESSION_TYPE_BREATHING, "meditation" to MINDFULNESS_SESSION_TYPE_MEDITATION, @@ -143,7 +143,7 @@ class MindfulnessSessionRecord( @RestrictTo(RestrictTo.Scope.LIBRARY) @JvmField - val MINDFULNESS_SESSION_TYPE_INT_TO_STRING_MAP = + public val MINDFULNESS_SESSION_TYPE_INT_TO_STRING_MAP: Map = MINDFULNESS_SESSION_TYPE_STRING_TO_INT_MAP.reverse() } @@ -161,5 +161,5 @@ class MindfulnessSessionRecord( MINDFULNESS_SESSION_TYPE_UNKNOWN, ] ) - annotation class MindfulnessSessionTypes + public annotation class MindfulnessSessionTypes } diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/NutritionRecord.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/NutritionRecord.kt index 23d534a715c83..eabcaf07ae48f 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/NutritionRecord.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/NutritionRecord.kt @@ -304,7 +304,7 @@ public class NutritionRecord( return "NutritionRecord(startTime=$startTime, startZoneOffset=$startZoneOffset, endTime=$endTime, endZoneOffset=$endZoneOffset, biotin=$biotin, caffeine=$caffeine, calcium=$calcium, energy=$energy, energyFromFat=$energyFromFat, chloride=$chloride, cholesterol=$cholesterol, chromium=$chromium, copper=$copper, dietaryFiber=$dietaryFiber, folate=$folate, folicAcid=$folicAcid, iodine=$iodine, iron=$iron, magnesium=$magnesium, manganese=$manganese, molybdenum=$molybdenum, monounsaturatedFat=$monounsaturatedFat, niacin=$niacin, pantothenicAcid=$pantothenicAcid, phosphorus=$phosphorus, polyunsaturatedFat=$polyunsaturatedFat, potassium=$potassium, protein=$protein, riboflavin=$riboflavin, saturatedFat=$saturatedFat, selenium=$selenium, sodium=$sodium, sugar=$sugar, thiamin=$thiamin, totalCarbohydrate=$totalCarbohydrate, totalFat=$totalFat, transFat=$transFat, unsaturatedFat=$unsaturatedFat, vitaminA=$vitaminA, vitaminB12=$vitaminB12, vitaminB6=$vitaminB6, vitaminC=$vitaminC, vitaminD=$vitaminD, vitaminE=$vitaminE, vitaminK=$vitaminK, zinc=$zinc, name=$name, mealType=$mealType, metadata=$metadata)" } - companion object { + public companion object { private const val TYPE_NAME = "Nutrition" private val MIN_MASS = 0.grams @@ -319,7 +319,7 @@ public class NutritionRecord( * [androidx.health.connect.client.aggregate.AggregationResult]. */ @JvmField - val BIOTIN_TOTAL: AggregateMetric = + public val BIOTIN_TOTAL: AggregateMetric = doubleMetric(TYPE_NAME, AggregationType.TOTAL, "biotin", Mass::grams) /** @@ -327,7 +327,7 @@ public class NutritionRecord( * [androidx.health.connect.client.aggregate.AggregationResult]. */ @JvmField - val CAFFEINE_TOTAL: AggregateMetric = + public val CAFFEINE_TOTAL: AggregateMetric = doubleMetric(TYPE_NAME, AggregationType.TOTAL, "caffeine", Mass::grams) /** @@ -335,7 +335,7 @@ public class NutritionRecord( * [androidx.health.connect.client.aggregate.AggregationResult]. */ @JvmField - val CALCIUM_TOTAL: AggregateMetric = + public val CALCIUM_TOTAL: AggregateMetric = doubleMetric(TYPE_NAME, AggregationType.TOTAL, "calcium", Mass::grams) /** @@ -343,7 +343,7 @@ public class NutritionRecord( * [androidx.health.connect.client.aggregate.AggregationResult]. */ @JvmField - val ENERGY_TOTAL: AggregateMetric = + public val ENERGY_TOTAL: AggregateMetric = doubleMetric(TYPE_NAME, AggregationType.TOTAL, "calories", Energy::kilocalories) /** @@ -351,7 +351,7 @@ public class NutritionRecord( * [androidx.health.connect.client.aggregate.AggregationResult]. */ @JvmField - val ENERGY_FROM_FAT_TOTAL: AggregateMetric = + public val ENERGY_FROM_FAT_TOTAL: AggregateMetric = doubleMetric(TYPE_NAME, AggregationType.TOTAL, "caloriesFromFat", Energy::kilocalories) /** @@ -359,7 +359,7 @@ public class NutritionRecord( * [androidx.health.connect.client.aggregate.AggregationResult]. */ @JvmField - val CHLORIDE_TOTAL: AggregateMetric = + public val CHLORIDE_TOTAL: AggregateMetric = doubleMetric(TYPE_NAME, AggregationType.TOTAL, "chloride", Mass::grams) /** @@ -367,7 +367,7 @@ public class NutritionRecord( * [androidx.health.connect.client.aggregate.AggregationResult]. */ @JvmField - val CHOLESTEROL_TOTAL: AggregateMetric = + public val CHOLESTEROL_TOTAL: AggregateMetric = doubleMetric(TYPE_NAME, AggregationType.TOTAL, "cholesterol", Mass::grams) /** @@ -375,7 +375,7 @@ public class NutritionRecord( * [androidx.health.connect.client.aggregate.AggregationResult]. */ @JvmField - val CHROMIUM_TOTAL: AggregateMetric = + public val CHROMIUM_TOTAL: AggregateMetric = doubleMetric(TYPE_NAME, AggregationType.TOTAL, "chromium", Mass::grams) /** @@ -383,7 +383,7 @@ public class NutritionRecord( * [androidx.health.connect.client.aggregate.AggregationResult]. */ @JvmField - val COPPER_TOTAL: AggregateMetric = + public val COPPER_TOTAL: AggregateMetric = doubleMetric(TYPE_NAME, AggregationType.TOTAL, "copper", Mass::grams) /** @@ -391,7 +391,7 @@ public class NutritionRecord( * [androidx.health.connect.client.aggregate.AggregationResult]. */ @JvmField - val DIETARY_FIBER_TOTAL: AggregateMetric = + public val DIETARY_FIBER_TOTAL: AggregateMetric = doubleMetric(TYPE_NAME, AggregationType.TOTAL, "dietaryFiber", Mass::grams) /** @@ -399,7 +399,7 @@ public class NutritionRecord( * [androidx.health.connect.client.aggregate.AggregationResult]. */ @JvmField - val FOLATE_TOTAL: AggregateMetric = + public val FOLATE_TOTAL: AggregateMetric = doubleMetric(TYPE_NAME, AggregationType.TOTAL, "folate", Mass::grams) /** @@ -407,7 +407,7 @@ public class NutritionRecord( * [androidx.health.connect.client.aggregate.AggregationResult]. */ @JvmField - val FOLIC_ACID_TOTAL: AggregateMetric = + public val FOLIC_ACID_TOTAL: AggregateMetric = doubleMetric(TYPE_NAME, AggregationType.TOTAL, "folicAcid", Mass::grams) /** @@ -415,7 +415,7 @@ public class NutritionRecord( * [androidx.health.connect.client.aggregate.AggregationResult]. */ @JvmField - val IODINE_TOTAL: AggregateMetric = + public val IODINE_TOTAL: AggregateMetric = doubleMetric(TYPE_NAME, AggregationType.TOTAL, "iodine", Mass::grams) /** @@ -423,7 +423,7 @@ public class NutritionRecord( * [androidx.health.connect.client.aggregate.AggregationResult]. */ @JvmField - val IRON_TOTAL: AggregateMetric = + public val IRON_TOTAL: AggregateMetric = doubleMetric(TYPE_NAME, AggregationType.TOTAL, "iron", Mass::grams) /** @@ -431,7 +431,7 @@ public class NutritionRecord( * [androidx.health.connect.client.aggregate.AggregationResult]. */ @JvmField - val MAGNESIUM_TOTAL: AggregateMetric = + public val MAGNESIUM_TOTAL: AggregateMetric = doubleMetric(TYPE_NAME, AggregationType.TOTAL, "magnesium", Mass::grams) /** @@ -439,7 +439,7 @@ public class NutritionRecord( * [androidx.health.connect.client.aggregate.AggregationResult]. */ @JvmField - val MANGANESE_TOTAL: AggregateMetric = + public val MANGANESE_TOTAL: AggregateMetric = doubleMetric(TYPE_NAME, AggregationType.TOTAL, "manganese", Mass::grams) /** @@ -447,7 +447,7 @@ public class NutritionRecord( * [androidx.health.connect.client.aggregate.AggregationResult]. */ @JvmField - val MOLYBDENUM_TOTAL: AggregateMetric = + public val MOLYBDENUM_TOTAL: AggregateMetric = doubleMetric(TYPE_NAME, AggregationType.TOTAL, "molybdenum", Mass::grams) /** @@ -455,7 +455,7 @@ public class NutritionRecord( * [androidx.health.connect.client.aggregate.AggregationResult]. */ @JvmField - val MONOUNSATURATED_FAT_TOTAL: AggregateMetric = + public val MONOUNSATURATED_FAT_TOTAL: AggregateMetric = doubleMetric(TYPE_NAME, AggregationType.TOTAL, "monounsaturatedFat", Mass::grams) /** @@ -463,7 +463,7 @@ public class NutritionRecord( * [androidx.health.connect.client.aggregate.AggregationResult]. */ @JvmField - val NIACIN_TOTAL: AggregateMetric = + public val NIACIN_TOTAL: AggregateMetric = doubleMetric(TYPE_NAME, AggregationType.TOTAL, "niacin", Mass::grams) /** @@ -471,7 +471,7 @@ public class NutritionRecord( * [androidx.health.connect.client.aggregate.AggregationResult]. */ @JvmField - val PANTOTHENIC_ACID_TOTAL: AggregateMetric = + public val PANTOTHENIC_ACID_TOTAL: AggregateMetric = doubleMetric(TYPE_NAME, AggregationType.TOTAL, "pantothenicAcid", Mass::grams) /** @@ -479,7 +479,7 @@ public class NutritionRecord( * [androidx.health.connect.client.aggregate.AggregationResult]. */ @JvmField - val PHOSPHORUS_TOTAL: AggregateMetric = + public val PHOSPHORUS_TOTAL: AggregateMetric = doubleMetric(TYPE_NAME, AggregationType.TOTAL, "phosphorus", Mass::grams) /** @@ -487,7 +487,7 @@ public class NutritionRecord( * [androidx.health.connect.client.aggregate.AggregationResult]. */ @JvmField - val POLYUNSATURATED_FAT_TOTAL: AggregateMetric = + public val POLYUNSATURATED_FAT_TOTAL: AggregateMetric = doubleMetric(TYPE_NAME, AggregationType.TOTAL, "polyunsaturatedFat", Mass::grams) /** @@ -495,7 +495,7 @@ public class NutritionRecord( * [androidx.health.connect.client.aggregate.AggregationResult]. */ @JvmField - val POTASSIUM_TOTAL: AggregateMetric = + public val POTASSIUM_TOTAL: AggregateMetric = doubleMetric(TYPE_NAME, AggregationType.TOTAL, "potassium", Mass::grams) /** @@ -503,7 +503,7 @@ public class NutritionRecord( * [androidx.health.connect.client.aggregate.AggregationResult]. */ @JvmField - val PROTEIN_TOTAL: AggregateMetric = + public val PROTEIN_TOTAL: AggregateMetric = doubleMetric(TYPE_NAME, AggregationType.TOTAL, "protein", Mass::grams) /** @@ -511,7 +511,7 @@ public class NutritionRecord( * [androidx.health.connect.client.aggregate.AggregationResult]. */ @JvmField - val RIBOFLAVIN_TOTAL: AggregateMetric = + public val RIBOFLAVIN_TOTAL: AggregateMetric = doubleMetric(TYPE_NAME, AggregationType.TOTAL, "riboflavin", Mass::grams) /** @@ -519,7 +519,7 @@ public class NutritionRecord( * [androidx.health.connect.client.aggregate.AggregationResult]. */ @JvmField - val SATURATED_FAT_TOTAL: AggregateMetric = + public val SATURATED_FAT_TOTAL: AggregateMetric = doubleMetric(TYPE_NAME, AggregationType.TOTAL, "saturatedFat", Mass::grams) /** @@ -527,7 +527,7 @@ public class NutritionRecord( * [androidx.health.connect.client.aggregate.AggregationResult]. */ @JvmField - val SELENIUM_TOTAL: AggregateMetric = + public val SELENIUM_TOTAL: AggregateMetric = doubleMetric(TYPE_NAME, AggregationType.TOTAL, "selenium", Mass::grams) /** @@ -535,7 +535,7 @@ public class NutritionRecord( * [androidx.health.connect.client.aggregate.AggregationResult]. */ @JvmField - val SODIUM_TOTAL: AggregateMetric = + public val SODIUM_TOTAL: AggregateMetric = doubleMetric(TYPE_NAME, AggregationType.TOTAL, "sodium", Mass::grams) /** @@ -543,7 +543,7 @@ public class NutritionRecord( * [androidx.health.connect.client.aggregate.AggregationResult]. */ @JvmField - val SUGAR_TOTAL: AggregateMetric = + public val SUGAR_TOTAL: AggregateMetric = doubleMetric(TYPE_NAME, AggregationType.TOTAL, "sugar", Mass::grams) /** @@ -551,7 +551,7 @@ public class NutritionRecord( * [androidx.health.connect.client.aggregate.AggregationResult]. */ @JvmField - val THIAMIN_TOTAL: AggregateMetric = + public val THIAMIN_TOTAL: AggregateMetric = doubleMetric(TYPE_NAME, AggregationType.TOTAL, "thiamin", Mass::grams) /** @@ -559,7 +559,7 @@ public class NutritionRecord( * [androidx.health.connect.client.aggregate.AggregationResult]. */ @JvmField - val TOTAL_CARBOHYDRATE_TOTAL: AggregateMetric = + public val TOTAL_CARBOHYDRATE_TOTAL: AggregateMetric = doubleMetric(TYPE_NAME, AggregationType.TOTAL, "totalCarbohydrate", Mass::grams) /** @@ -567,7 +567,7 @@ public class NutritionRecord( * [androidx.health.connect.client.aggregate.AggregationResult]. */ @JvmField - val TOTAL_FAT_TOTAL: AggregateMetric = + public val TOTAL_FAT_TOTAL: AggregateMetric = doubleMetric(TYPE_NAME, AggregationType.TOTAL, "totalFat", Mass::grams) /** @@ -575,7 +575,7 @@ public class NutritionRecord( * [androidx.health.connect.client.aggregate.AggregationResult]. */ @JvmField - val TRANS_FAT_TOTAL: AggregateMetric = + public val TRANS_FAT_TOTAL: AggregateMetric = doubleMetric(TYPE_NAME, AggregationType.TOTAL, "transFat", Mass::grams) /** @@ -583,7 +583,7 @@ public class NutritionRecord( * [androidx.health.connect.client.aggregate.AggregationResult]. */ @JvmField - val UNSATURATED_FAT_TOTAL: AggregateMetric = + public val UNSATURATED_FAT_TOTAL: AggregateMetric = doubleMetric(TYPE_NAME, AggregationType.TOTAL, "unsaturatedFat", Mass::grams) /** @@ -591,7 +591,7 @@ public class NutritionRecord( * [androidx.health.connect.client.aggregate.AggregationResult]. */ @JvmField - val VITAMIN_A_TOTAL: AggregateMetric = + public val VITAMIN_A_TOTAL: AggregateMetric = doubleMetric(TYPE_NAME, AggregationType.TOTAL, "vitaminA", Mass::grams) /** @@ -599,7 +599,7 @@ public class NutritionRecord( * [androidx.health.connect.client.aggregate.AggregationResult]. */ @JvmField - val VITAMIN_B12_TOTAL: AggregateMetric = + public val VITAMIN_B12_TOTAL: AggregateMetric = doubleMetric(TYPE_NAME, AggregationType.TOTAL, "vitaminB12", Mass::grams) /** @@ -607,7 +607,7 @@ public class NutritionRecord( * [androidx.health.connect.client.aggregate.AggregationResult]. */ @JvmField - val VITAMIN_B6_TOTAL: AggregateMetric = + public val VITAMIN_B6_TOTAL: AggregateMetric = doubleMetric(TYPE_NAME, AggregationType.TOTAL, "vitaminB6", Mass::grams) /** @@ -615,7 +615,7 @@ public class NutritionRecord( * [androidx.health.connect.client.aggregate.AggregationResult]. */ @JvmField - val VITAMIN_C_TOTAL: AggregateMetric = + public val VITAMIN_C_TOTAL: AggregateMetric = doubleMetric(TYPE_NAME, AggregationType.TOTAL, "vitaminC", Mass::grams) /** @@ -623,7 +623,7 @@ public class NutritionRecord( * [androidx.health.connect.client.aggregate.AggregationResult]. */ @JvmField - val VITAMIN_D_TOTAL: AggregateMetric = + public val VITAMIN_D_TOTAL: AggregateMetric = doubleMetric(TYPE_NAME, AggregationType.TOTAL, "vitaminD", Mass::grams) /** @@ -631,7 +631,7 @@ public class NutritionRecord( * [androidx.health.connect.client.aggregate.AggregationResult]. */ @JvmField - val VITAMIN_E_TOTAL: AggregateMetric = + public val VITAMIN_E_TOTAL: AggregateMetric = doubleMetric(TYPE_NAME, AggregationType.TOTAL, "vitaminE", Mass::grams) /** @@ -639,7 +639,7 @@ public class NutritionRecord( * [androidx.health.connect.client.aggregate.AggregationResult]. */ @JvmField - val VITAMIN_K_TOTAL: AggregateMetric = + public val VITAMIN_K_TOTAL: AggregateMetric = doubleMetric(TYPE_NAME, AggregationType.TOTAL, "vitaminK", Mass::grams) /** @@ -647,7 +647,7 @@ public class NutritionRecord( * [androidx.health.connect.client.aggregate.AggregationResult]. */ @JvmField - val ZINC_TOTAL: AggregateMetric = + public val ZINC_TOTAL: AggregateMetric = doubleMetric(TYPE_NAME, AggregationType.TOTAL, "zinc", Mass::grams) } } diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/OvulationTestRecord.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/OvulationTestRecord.kt index cf3fbeb68f63f..ac42e0e3a9e47 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/OvulationTestRecord.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/OvulationTestRecord.kt @@ -64,35 +64,35 @@ public class OvulationTestRecord( const val INCONCLUSIVE = "inconclusive" } - companion object { + public companion object { /** * Inconclusive result. Refers to ovulation test results that are indeterminate (e.g. may be * testing malfunction, user error, etc.). ". Any unknown value will also be returned as * [RESULT_INCONCLUSIVE]. */ - const val RESULT_INCONCLUSIVE = 0 + public const val RESULT_INCONCLUSIVE: Int = 0 /** * Positive fertility (may also be referred as "peak" fertility). Refers to the peak of the * luteinizing hormone (LH) surge and ovulation is expected to occur in 10-36 hours. */ - const val RESULT_POSITIVE = 1 + public const val RESULT_POSITIVE: Int = 1 /** * High fertility. Refers to a rise in estrogen or luteinizing hormone that may signal the * fertile window (time in the menstrual cycle when conception is likely to occur). */ - const val RESULT_HIGH = 2 + public const val RESULT_HIGH: Int = 2 /** * Negative fertility (may also be referred as "low" fertility). Refers to the time in the * cycle where fertility/conception is expected to be low. */ - const val RESULT_NEGATIVE = 3 + public const val RESULT_NEGATIVE: Int = 3 @RestrictTo(RestrictTo.Scope.LIBRARY) @JvmField - val RESULT_STRING_TO_INT_MAP: Map = + public val RESULT_STRING_TO_INT_MAP: Map = mapOf( Result.INCONCLUSIVE to RESULT_INCONCLUSIVE, Result.POSITIVE to RESULT_POSITIVE, @@ -102,12 +102,12 @@ public class OvulationTestRecord( @RestrictTo(RestrictTo.Scope.LIBRARY) @JvmField - val RESULT_INT_TO_STRING_MAP = RESULT_STRING_TO_INT_MAP.reverse() + public val RESULT_INT_TO_STRING_MAP: Map = RESULT_STRING_TO_INT_MAP.reverse() } /** The result of a user's ovulation test. */ @Retention(AnnotationRetention.SOURCE) @IntDef(value = [RESULT_INCONCLUSIVE, RESULT_POSITIVE, RESULT_HIGH, RESULT_NEGATIVE]) @RestrictTo(RestrictTo.Scope.LIBRARY) - annotation class Results + public annotation class Results } diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/PlannedExerciseBlock.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/PlannedExerciseBlock.kt index 555506c7284ec..6cd2cf5f3f666 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/PlannedExerciseBlock.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/PlannedExerciseBlock.kt @@ -15,10 +15,10 @@ */ package androidx.health.connect.client.records /** Represents a series of [PlannedExerciseStep]s. Part of a [PlannedExerciseSessionRecord]. */ -class PlannedExerciseBlock( - val repetitions: Int, - val steps: List, - val description: String? = null, +public class PlannedExerciseBlock( + public val repetitions: Int, + public val steps: List, + public val description: String? = null, ) { override fun equals(other: Any?): Boolean { if (this === other) return true diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/PlannedExerciseSessionRecord.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/PlannedExerciseSessionRecord.kt index a28ecc257682e..0b2a8d5aa31f0 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/PlannedExerciseSessionRecord.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/PlannedExerciseSessionRecord.kt @@ -35,23 +35,23 @@ import java.time.ZoneOffset * * Requires [androidx.health.connect.client.HealthConnectFeatures.FEATURE_PLANNED_EXERCISE]. */ -class PlannedExerciseSessionRecord +public class PlannedExerciseSessionRecord internal constructor( override val startTime: Instant, override val startZoneOffset: ZoneOffset?, override val endTime: Instant, override val endZoneOffset: ZoneOffset?, override val metadata: Metadata, - @get:JvmName("hasExplicitTime") val hasExplicitTime: Boolean, + @get:JvmName("hasExplicitTime") public val hasExplicitTime: Boolean, /** Type of exercise (e.g. walking, swimming). Required field. */ - @property:ExerciseSessionRecord.ExerciseTypes val exerciseType: Int, + @property:ExerciseSessionRecord.ExerciseTypes public val exerciseType: Int, /** The exercise session that completed this planned session. */ - val completedExerciseSessionId: String?, - val blocks: List, + public val completedExerciseSessionId: String?, + public val blocks: List, /** Title of the session. Optional field. */ - val title: String? = null, + public val title: String? = null, /** Additional notes for the session. Optional field. */ - val notes: String? = null, + public val notes: String? = null, ) : IntervalRecord { /** * Constructor that accepts a physical time and zone offset. @@ -69,7 +69,7 @@ internal constructor( * @param metadata Metadata for this session. */ @JvmOverloads - constructor( + public constructor( startTime: Instant, startZoneOffset: ZoneOffset?, endTime: Instant, @@ -110,7 +110,7 @@ internal constructor( * @param metadata Metadata for this session. */ @JvmOverloads - constructor( + public constructor( metadata: Metadata, startDate: LocalDate, duration: Duration, @@ -183,7 +183,7 @@ internal constructor( return "PlannedExerciseSessionRecord(startTime=$startTime, startZoneOffset=$startZoneOffset, endTime=$endTime, endZoneOffset=$endZoneOffset, hasExplicitTime=$hasExplicitTime, title=$title, notes=$notes, exerciseType=$exerciseType, completedExerciseSessionId=$completedExerciseSessionId, metadata=$metadata, blocks=$blocks)" } - companion object { + public companion object { /** * Converts a local date to a physical timestamp by assuming a fixed time at noon and the * current system time zone. diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/PlannedExerciseStep.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/PlannedExerciseStep.kt index a927b31c13323..194a6d6ae580a 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/PlannedExerciseStep.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/PlannedExerciseStep.kt @@ -27,27 +27,27 @@ import androidx.annotation.RestrictTo * @param completionGoal The goal that must be completed to finish this step. * @param performanceTargets Performance related targets that should be met during this step. */ -class PlannedExerciseStep( - @property:ExerciseSegment.Companion.ExerciseSegmentTypes val exerciseType: Int, - @property:ExercisePhase val exercisePhase: Int, - val completionGoal: ExerciseCompletionGoal, - val performanceTargets: List, - val description: String? = null, +public class PlannedExerciseStep( + @property:ExerciseSegment.Companion.ExerciseSegmentTypes public val exerciseType: Int, + @property:ExercisePhase public val exercisePhase: Int, + public val completionGoal: ExerciseCompletionGoal, + public val performanceTargets: List, + public val description: String? = null, ) { - companion object { + public companion object { /* Next Id: 6. */ /** An unknown phase of exercise. */ - const val EXERCISE_PHASE_UNKNOWN = 0 + public const val EXERCISE_PHASE_UNKNOWN: Int = 0 /** A warmup. */ - const val EXERCISE_PHASE_WARMUP = 1 + public const val EXERCISE_PHASE_WARMUP: Int = 1 /** A rest. */ - const val EXERCISE_PHASE_REST = 2 + public const val EXERCISE_PHASE_REST: Int = 2 /** Active exercise. */ - const val EXERCISE_PHASE_ACTIVE = 3 + public const val EXERCISE_PHASE_ACTIVE: Int = 3 /** Cooldown exercise, typically at the end of a workout. */ - const val EXERCISE_PHASE_COOLDOWN = 4 + public const val EXERCISE_PHASE_COOLDOWN: Int = 4 /** Lower intensity, active exercise. */ - const val EXERCISE_PHASE_RECOVERY = 5 + public const val EXERCISE_PHASE_RECOVERY: Int = 5 /** List of supported exercise phase types. */ @Retention(AnnotationRetention.SOURCE) @@ -63,7 +63,7 @@ class PlannedExerciseStep( EXERCISE_PHASE_RECOVERY, ] ) - annotation class ExercisePhase + public annotation class ExercisePhase } override fun equals(other: Any?): Boolean { diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/PowerRecord.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/PowerRecord.kt index 8b3505fbe3926..9ff0c4ce5dbbf 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/PowerRecord.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/PowerRecord.kt @@ -77,7 +77,7 @@ public class PowerRecord( return "PowerRecord(startTime=$startTime, startZoneOffset=$startZoneOffset, endTime=$endTime, endZoneOffset=$endZoneOffset, samples=$samples, metadata=$metadata)" } - companion object { + public companion object { private const val TYPE = "PowerSeries" private const val POWER_FIELD = "power" private val MAX_POWER = 100_000.watts @@ -87,7 +87,7 @@ public class PowerRecord( * [androidx.health.connect.client.aggregate.AggregationResult]. */ @JvmField - val POWER_AVG: AggregateMetric = + public val POWER_AVG: AggregateMetric = doubleMetric( dataTypeName = TYPE, aggregationType = AVERAGE, @@ -100,7 +100,7 @@ public class PowerRecord( * [androidx.health.connect.client.aggregate.AggregationResult]. */ @JvmField - val POWER_MIN: AggregateMetric = + public val POWER_MIN: AggregateMetric = doubleMetric( dataTypeName = TYPE, aggregationType = MINIMUM, @@ -113,7 +113,7 @@ public class PowerRecord( * [androidx.health.connect.client.aggregate.AggregationResult]. */ @JvmField - val POWER_MAX: AggregateMetric = + public val POWER_MAX: AggregateMetric = doubleMetric( dataTypeName = TYPE, aggregationType = MAXIMUM, @@ -130,7 +130,7 @@ public class PowerRecord( * @param power Power generated, in [Power] unit. Valid range: 0-100000 Watts. * @see PowerRecord */ - public class Sample(val time: Instant, val power: Power) { + public class Sample(public val time: Instant, public val power: Power) { init { power.requireNotLess(other = power.zero(), name = "power") diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/RestingHeartRateRecord.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/RestingHeartRateRecord.kt index e050e201c1ec6..688ca3c8a9427 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/RestingHeartRateRecord.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/RestingHeartRateRecord.kt @@ -72,7 +72,7 @@ public class RestingHeartRateRecord( return "RestingHeartRateRecord(time=$time, zoneOffset=$zoneOffset, beatsPerMinute=$beatsPerMinute, metadata=$metadata)" } - companion object { + public companion object { private const val REST_HEART_RATE_TYPE_NAME = "RestingHeartRate" private const val BPM_FIELD_NAME = "bpm" @@ -80,7 +80,7 @@ public class RestingHeartRateRecord( * Metric identifier to retrieve the average resting heart rate from [AggregationResult]. */ @JvmField - val BPM_AVG: AggregateMetric = + public val BPM_AVG: AggregateMetric = AggregateMetric.longMetric( REST_HEART_RATE_TYPE_NAME, AggregateMetric.AggregationType.AVERAGE, @@ -91,7 +91,7 @@ public class RestingHeartRateRecord( * Metric identifier to retrieve the minimum resting heart rate from [AggregationResult]. */ @JvmField - val BPM_MIN: AggregateMetric = + public val BPM_MIN: AggregateMetric = AggregateMetric.longMetric( REST_HEART_RATE_TYPE_NAME, AggregateMetric.AggregationType.MINIMUM, @@ -102,7 +102,7 @@ public class RestingHeartRateRecord( * Metric identifier to retrieve the maximum resting heart rate from [AggregationResult]. */ @JvmField - val BPM_MAX: AggregateMetric = + public val BPM_MAX: AggregateMetric = AggregateMetric.longMetric( REST_HEART_RATE_TYPE_NAME, AggregateMetric.AggregationType.MAXIMUM, diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/SexualActivityRecord.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/SexualActivityRecord.kt index 40d55a7f43747..25a8599c32e3c 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/SexualActivityRecord.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/SexualActivityRecord.kt @@ -61,15 +61,15 @@ public class SexualActivityRecord( return "SexualActivityRecord(time=$time, zoneOffset=$zoneOffset, protectionUsed=$protectionUsed, metadata=$metadata)" } - companion object { - const val PROTECTION_USED_UNKNOWN = 0 - const val PROTECTION_USED_PROTECTED = 1 - const val PROTECTION_USED_UNPROTECTED = 2 + public companion object { + public const val PROTECTION_USED_UNKNOWN: Int = 0 + public const val PROTECTION_USED_PROTECTED: Int = 1 + public const val PROTECTION_USED_UNPROTECTED: Int = 2 /** Internal mappings useful for interoperability between integers and strings. */ @RestrictTo(RestrictTo.Scope.LIBRARY) @JvmField - val PROTECTION_USED_STRING_TO_INT_MAP: Map = + public val PROTECTION_USED_STRING_TO_INT_MAP: Map = mapOf( Protection.PROTECTED to PROTECTION_USED_PROTECTED, Protection.UNPROTECTED to PROTECTION_USED_UNPROTECTED, @@ -77,7 +77,8 @@ public class SexualActivityRecord( @RestrictTo(RestrictTo.Scope.LIBRARY) @JvmField - val PROTECTION_USED_INT_TO_STRING_MAP = PROTECTION_USED_STRING_TO_INT_MAP.reverse() + public val PROTECTION_USED_INT_TO_STRING_MAP: Map = + PROTECTION_USED_STRING_TO_INT_MAP.reverse() } /** Whether protection was used during sexual activity. */ @@ -90,5 +91,5 @@ public class SexualActivityRecord( @Retention(AnnotationRetention.SOURCE) @IntDef(value = [PROTECTION_USED_PROTECTED, PROTECTION_USED_UNPROTECTED]) @RestrictTo(RestrictTo.Scope.LIBRARY) - annotation class Protections + public annotation class Protections } diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/SkinTemperatureRecord.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/SkinTemperatureRecord.kt index b83152a2f245e..928aabf87085d 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/SkinTemperatureRecord.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/SkinTemperatureRecord.kt @@ -63,15 +63,16 @@ import java.time.ZoneOffset * time range or baseline is not within [MIN_TEMPERATURE], [MAX_TEMPERATURE]. * @sample androidx.health.connect.client.samples.ReadSkinTemperatureRecord */ -class SkinTemperatureRecord( +public class SkinTemperatureRecord( override val startTime: Instant, override val startZoneOffset: ZoneOffset?, override val endTime: Instant, override val endZoneOffset: ZoneOffset?, override val metadata: Metadata, - val deltas: List, - val baseline: Temperature? = null, - @SkinTemperatureMeasurementLocation val measurementLocation: Int = MEASUREMENT_LOCATION_UNKNOWN, + public val deltas: List, + public val baseline: Temperature? = null, + @SkinTemperatureMeasurementLocation + public val measurementLocation: Int = MEASUREMENT_LOCATION_UNKNOWN, ) : IntervalRecord { init { @@ -131,7 +132,7 @@ class SkinTemperatureRecord( return "SkinTemperatureRecord(startTime=$startTime, startZoneOffset=$startZoneOffset, endTime=$endTime, endZoneOffset=$endZoneOffset, deltas=$deltas, baseline=$baseline, measurementLocation=$measurementLocation, metadata=$metadata)" } - companion object { + public companion object { private const val SKIN_TEMPERATURE_TYPE_NAME = "SkinTemperature" private const val TEMPERATURE_DELTA_FIELD_NAME = "temperatureDelta" @@ -145,7 +146,7 @@ class SkinTemperatureRecord( * [HealthConnectFeatures.FEATURE_SKIN_TEMPERATURE] as the argument. */ @JvmField - val TEMPERATURE_DELTA_AVG: AggregateMetric = + public val TEMPERATURE_DELTA_AVG: AggregateMetric = doubleMetric( SKIN_TEMPERATURE_TYPE_NAME, AVERAGE, @@ -160,7 +161,7 @@ class SkinTemperatureRecord( * [HealthConnectFeatures.FEATURE_SKIN_TEMPERATURE] as the argument. */ @JvmField - val TEMPERATURE_DELTA_MIN: AggregateMetric = + public val TEMPERATURE_DELTA_MIN: AggregateMetric = doubleMetric( SKIN_TEMPERATURE_TYPE_NAME, MINIMUM, @@ -175,7 +176,7 @@ class SkinTemperatureRecord( * [HealthConnectFeatures.FEATURE_SKIN_TEMPERATURE] as the argument. */ @JvmField - val TEMPERATURE_DELTA_MAX: AggregateMetric = + public val TEMPERATURE_DELTA_MAX: AggregateMetric = doubleMetric( SKIN_TEMPERATURE_TYPE_NAME, MAXIMUM, @@ -184,18 +185,18 @@ class SkinTemperatureRecord( ) /** Use this if the location is unknown. */ - const val MEASUREMENT_LOCATION_UNKNOWN: Int = 0 + public const val MEASUREMENT_LOCATION_UNKNOWN: Int = 0 /** Skin temperature measurement was taken from finger. */ - const val MEASUREMENT_LOCATION_FINGER: Int = 1 + public const val MEASUREMENT_LOCATION_FINGER: Int = 1 /** Skin temperature measurement was taken from toe. */ - const val MEASUREMENT_LOCATION_TOE: Int = 2 + public const val MEASUREMENT_LOCATION_TOE: Int = 2 /** Skin temperature measurement was taken from wrist. */ - const val MEASUREMENT_LOCATION_WRIST: Int = 3 + public const val MEASUREMENT_LOCATION_WRIST: Int = 3 /** Internal mappings useful for interoperability between integers and strings. */ @RestrictTo(RestrictTo.Scope.LIBRARY) @JvmField - val MEASUREMENT_LOCATION_STRING_TO_INT_MAP: Map = + public val MEASUREMENT_LOCATION_STRING_TO_INT_MAP: Map = mapOf( "finger" to MEASUREMENT_LOCATION_FINGER, "toe" to MEASUREMENT_LOCATION_TOE, @@ -204,7 +205,7 @@ class SkinTemperatureRecord( @RestrictTo(RestrictTo.Scope.LIBRARY) @JvmField - val MEASUREMENT_LOCATION_INT_TO_STRING_MAP = + public val MEASUREMENT_LOCATION_INT_TO_STRING_MAP: Map = MEASUREMENT_LOCATION_STRING_TO_INT_MAP.reverse() /** Measurement location of the skin temperature. */ @@ -219,7 +220,7 @@ class SkinTemperatureRecord( ] ) @RestrictTo(RestrictTo.Scope.LIBRARY) - annotation class SkinTemperatureMeasurementLocation + public annotation class SkinTemperatureMeasurementLocation } /** @@ -232,7 +233,7 @@ class SkinTemperatureRecord( * @see SkinTemperatureRecord * @see TemperatureDelta */ - public class Delta(val time: Instant, val delta: TemperatureDelta) { + public class Delta(public val time: Instant, public val delta: TemperatureDelta) { init { delta.requireNotLess(other = MIN_DELTA_TEMPERATURE, "delta") diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/SleepSessionRecord.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/SleepSessionRecord.kt index eafe95d149273..94e8ab7ffc33a 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/SleepSessionRecord.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/SleepSessionRecord.kt @@ -36,17 +36,17 @@ import java.time.ZoneOffset * * @sample androidx.health.connect.client.samples.ReadSleepSessions */ -class SleepSessionRecord( +public class SleepSessionRecord( override val startTime: Instant, override val startZoneOffset: ZoneOffset?, override val endTime: Instant, override val endZoneOffset: ZoneOffset?, override val metadata: Metadata, /** Title of the session. Optional field. */ - val title: String? = null, + public val title: String? = null, /** Additional notes for the session. Optional field. */ - val notes: String? = null, - val stages: List = emptyList(), + public val notes: String? = null, + public val stages: List = emptyList(), ) : IntervalRecord { init { @@ -104,45 +104,45 @@ class SleepSessionRecord( return "SleepSessionRecord(startTime=$startTime, startZoneOffset=$startZoneOffset, endTime=$endTime, endZoneOffset=$endZoneOffset, title=$title, notes=$notes, stages=$stages, metadata=$metadata)" } - companion object { + public companion object { /** * Metric identifier to retrieve the total sleep session duration from * [androidx.health.connect.client.aggregate.AggregationResult]. */ @JvmField - val SLEEP_DURATION_TOTAL: AggregateMetric = + public val SLEEP_DURATION_TOTAL: AggregateMetric = AggregateMetric.durationMetric("SleepSession") /** Use this type if the stage of sleep is unknown. */ - const val STAGE_TYPE_UNKNOWN = 0 + public const val STAGE_TYPE_UNKNOWN: Int = 0 /** * The user is awake and either known to be in bed, or it is unknown whether they are in bed * or not. */ - const val STAGE_TYPE_AWAKE = 1 + public const val STAGE_TYPE_AWAKE: Int = 1 /** The user is asleep but the particular stage of sleep (light, deep or REM) is unknown. */ - const val STAGE_TYPE_SLEEPING = 2 + public const val STAGE_TYPE_SLEEPING: Int = 2 /** The user is out of bed and assumed to be awake. */ - const val STAGE_TYPE_OUT_OF_BED = 3 + public const val STAGE_TYPE_OUT_OF_BED: Int = 3 /** The user is in a light sleep stage. */ - const val STAGE_TYPE_LIGHT = 4 + public const val STAGE_TYPE_LIGHT: Int = 4 /** The user is in a deep sleep stage. */ - const val STAGE_TYPE_DEEP = 5 + public const val STAGE_TYPE_DEEP: Int = 5 /** The user is in a REM sleep stage. */ - const val STAGE_TYPE_REM = 6 + public const val STAGE_TYPE_REM: Int = 6 /** The user is awake and in bed. */ - const val STAGE_TYPE_AWAKE_IN_BED = 7 + public const val STAGE_TYPE_AWAKE_IN_BED: Int = 7 @RestrictTo(RestrictTo.Scope.LIBRARY) @JvmField - val STAGE_TYPE_STRING_TO_INT_MAP: Map = + public val STAGE_TYPE_STRING_TO_INT_MAP: Map = mapOf( "awake" to STAGE_TYPE_AWAKE, "sleeping" to STAGE_TYPE_SLEEPING, @@ -156,7 +156,7 @@ class SleepSessionRecord( @RestrictTo(RestrictTo.Scope.LIBRARY) @JvmField - val STAGE_TYPE_INT_TO_STRING_MAP = + public val STAGE_TYPE_INT_TO_STRING_MAP: Map = STAGE_TYPE_STRING_TO_INT_MAP.entries.associateBy({ it.value }, { it.key }) } @@ -176,14 +176,18 @@ class SleepSessionRecord( ] ) @RestrictTo(RestrictTo.Scope.LIBRARY) - annotation class StageTypes + public annotation class StageTypes /** * Captures the sleep stage the user entered during a sleep session. * * @see SleepSessionRecord */ - class Stage(val startTime: Instant, val endTime: Instant, @property:StageTypes val stage: Int) { + public class Stage( + public val startTime: Instant, + public val endTime: Instant, + @property:StageTypes public val stage: Int, + ) { init { require(startTime.isBefore(endTime)) { "startTime must be before endTime." } } diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/SpeedRecord.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/SpeedRecord.kt index 56c8a7a78960d..6dc6e7dfa4bc7 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/SpeedRecord.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/SpeedRecord.kt @@ -73,7 +73,7 @@ public class SpeedRecord( return "SpeedRecord(startTime=$startTime, startZoneOffset=$startZoneOffset, endTime=$endTime, endZoneOffset=$endZoneOffset, samples=$samples, metadata=$metadata)" } - companion object { + public companion object { private const val SPEED_TYPE_NAME = "SpeedSeries" private const val SPEED_FIELD_NAME = "speed" private val MAX_SPEED = 1000_000.metersPerSecond @@ -83,7 +83,7 @@ public class SpeedRecord( * [androidx.health.connect.client.aggregate.AggregationResult]. */ @JvmField - val SPEED_AVG: AggregateMetric = + public val SPEED_AVG: AggregateMetric = AggregateMetric.doubleMetric( dataTypeName = SPEED_TYPE_NAME, aggregationType = AggregateMetric.AggregationType.AVERAGE, @@ -96,7 +96,7 @@ public class SpeedRecord( * [androidx.health.connect.client.aggregate.AggregationResult]. */ @JvmField - val SPEED_MIN: AggregateMetric = + public val SPEED_MIN: AggregateMetric = AggregateMetric.doubleMetric( dataTypeName = SPEED_TYPE_NAME, aggregationType = AggregateMetric.AggregationType.MINIMUM, @@ -109,7 +109,7 @@ public class SpeedRecord( * [androidx.health.connect.client.aggregate.AggregationResult]. */ @JvmField - val SPEED_MAX: AggregateMetric = + public val SPEED_MAX: AggregateMetric = AggregateMetric.doubleMetric( dataTypeName = SPEED_TYPE_NAME, aggregationType = AggregateMetric.AggregationType.MAXIMUM, @@ -125,7 +125,7 @@ public class SpeedRecord( * @param speed Speed in [Velocity] unit. Valid range: 0-1000000 meters/sec. * @see SpeedRecord */ - public class Sample(val time: Instant, val speed: Velocity) { + public class Sample(public val time: Instant, public val speed: Velocity) { init { speed.requireNotLess(other = speed.zero(), name = "speed") diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/StepsCadenceRecord.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/StepsCadenceRecord.kt index be5609d6fe101..56e68fc54d284 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/StepsCadenceRecord.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/StepsCadenceRecord.kt @@ -26,7 +26,7 @@ import java.time.Instant import java.time.ZoneOffset /** Captures the user's steps cadence. Each record represents a series of measurements. */ -class StepsCadenceRecord( +public class StepsCadenceRecord( override val startTime: Instant, override val startZoneOffset: ZoneOffset?, override val endTime: Instant, @@ -73,7 +73,7 @@ class StepsCadenceRecord( return "StepsCadenceRecord(startTime=$startTime, startZoneOffset=$startZoneOffset, endTime=$endTime, endZoneOffset=$endZoneOffset, samples=$samples, metadata=$metadata)" } - companion object { + public companion object { private const val TYPE = "StepsCadenceSeries" private const val RATE_FIELD = "rate" @@ -81,19 +81,22 @@ class StepsCadenceRecord( * Metric identifier to retrieve average steps cadence from * [androidx.health.connect.client.aggregate.AggregationResult]. */ - @JvmField val RATE_AVG: AggregateMetric = doubleMetric(TYPE, AVERAGE, RATE_FIELD) + @JvmField + public val RATE_AVG: AggregateMetric = doubleMetric(TYPE, AVERAGE, RATE_FIELD) /** * Metric identifier to retrieve minimum steps cadence from * [androidx.health.connect.client.aggregate.AggregationResult]. */ - @JvmField val RATE_MIN: AggregateMetric = doubleMetric(TYPE, MINIMUM, RATE_FIELD) + @JvmField + public val RATE_MIN: AggregateMetric = doubleMetric(TYPE, MINIMUM, RATE_FIELD) /** * Metric identifier to retrieve maximum steps cadence from * [androidx.health.connect.client.aggregate.AggregationResult]. */ - @JvmField val RATE_MAX: AggregateMetric = doubleMetric(TYPE, MAXIMUM, RATE_FIELD) + @JvmField + public val RATE_MAX: AggregateMetric = doubleMetric(TYPE, MAXIMUM, RATE_FIELD) } /** @@ -102,7 +105,10 @@ class StepsCadenceRecord( * @param time The point in time when the measurement was taken. * @param rate Rate in steps per minute. Valid range: 0-10000. */ - class Sample(val time: Instant, @FloatRange(from = 0.0, to = 10_000.0) val rate: Double) { + public class Sample( + public val time: Instant, + @FloatRange(from = 0.0, to = 10_000.0) public val rate: Double, + ) { init { requireNonNegative(value = rate, name = "rate") diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/StepsRecord.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/StepsRecord.kt index ab1bf48bd8c97..b3fd7974de209 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/StepsRecord.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/StepsRecord.kt @@ -83,13 +83,13 @@ public class StepsRecord( return "StepsRecord(startTime=$startTime, startZoneOffset=$startZoneOffset, endTime=$endTime, endZoneOffset=$endZoneOffset, count=$count, metadata=$metadata)" } - companion object { + public companion object { /** * Metric identifier to retrieve the total steps count from * [androidx.health.connect.client.aggregate.AggregationResult]. */ @JvmField - val COUNT_TOTAL: AggregateMetric = + public val COUNT_TOTAL: AggregateMetric = AggregateMetric.longMetric("Steps", AggregateMetric.AggregationType.TOTAL, "count") } } diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/TotalCaloriesBurnedRecord.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/TotalCaloriesBurnedRecord.kt index 0609c42bea08e..db5e8b89e104c 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/TotalCaloriesBurnedRecord.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/TotalCaloriesBurnedRecord.kt @@ -86,7 +86,7 @@ public class TotalCaloriesBurnedRecord( return "TotalCaloriesBurnedRecord(startTime=$startTime, startZoneOffset=$startZoneOffset, endTime=$endTime, endZoneOffset=$endZoneOffset, energy=$energy, metadata=$metadata)" } - companion object { + public companion object { private val MAX_ENERGY = 1000_000.kilocalories /** @@ -94,7 +94,7 @@ public class TotalCaloriesBurnedRecord( * [androidx.health.connect.client.aggregate.AggregationResult]. */ @JvmField - val ENERGY_TOTAL: AggregateMetric = + public val ENERGY_TOTAL: AggregateMetric = AggregateMetric.doubleMetric( dataTypeName = "TotalCaloriesBurned", aggregationType = AggregateMetric.AggregationType.TOTAL, diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/Vo2MaxRecord.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/Vo2MaxRecord.kt index b2a7b35e53070..42ae415ab88ea 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/Vo2MaxRecord.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/Vo2MaxRecord.kt @@ -83,18 +83,18 @@ public class Vo2MaxRecord( return "Vo2MaxRecord(time=$time, zoneOffset=$zoneOffset, vo2MillilitersPerMinuteKilogram=$vo2MillilitersPerMinuteKilogram, measurementMethod=$measurementMethod, metadata=$metadata)" } - companion object { - const val MEASUREMENT_METHOD_OTHER = 0 - const val MEASUREMENT_METHOD_METABOLIC_CART = 1 - const val MEASUREMENT_METHOD_HEART_RATE_RATIO = 2 - const val MEASUREMENT_METHOD_COOPER_TEST = 3 - const val MEASUREMENT_METHOD_MULTISTAGE_FITNESS_TEST = 4 - const val MEASUREMENT_METHOD_ROCKPORT_FITNESS_TEST = 5 + public companion object { + public const val MEASUREMENT_METHOD_OTHER: Int = 0 + public const val MEASUREMENT_METHOD_METABOLIC_CART: Int = 1 + public const val MEASUREMENT_METHOD_HEART_RATE_RATIO: Int = 2 + public const val MEASUREMENT_METHOD_COOPER_TEST: Int = 3 + public const val MEASUREMENT_METHOD_MULTISTAGE_FITNESS_TEST: Int = 4 + public const val MEASUREMENT_METHOD_ROCKPORT_FITNESS_TEST: Int = 5 /** Internal mappings useful for interoperability between integers and strings. */ @RestrictTo(RestrictTo.Scope.LIBRARY) @JvmField - val MEASUREMENT_METHOD_STRING_TO_INT_MAP: Map = + public val MEASUREMENT_METHOD_STRING_TO_INT_MAP: Map = mapOf( MeasurementMethod.OTHER to MEASUREMENT_METHOD_OTHER, MeasurementMethod.METABOLIC_CART to MEASUREMENT_METHOD_METABOLIC_CART, @@ -107,7 +107,8 @@ public class Vo2MaxRecord( @RestrictTo(RestrictTo.Scope.LIBRARY) @JvmField - val MEASUREMENT_METHOD_INT_TO_STRING_MAP = MEASUREMENT_METHOD_STRING_TO_INT_MAP.reverse() + public val MEASUREMENT_METHOD_INT_TO_STRING_MAP: Map = + MEASUREMENT_METHOD_STRING_TO_INT_MAP.reverse() } /** VO2 max (maximal aerobic capacity) measurement method. */ @@ -134,5 +135,5 @@ public class Vo2MaxRecord( ] ) @RestrictTo(RestrictTo.Scope.LIBRARY) - annotation class MeasurementMethods + public annotation class MeasurementMethods } diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/WeightRecord.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/WeightRecord.kt index 4c6489c9f3dbd..a31a99b1a0eeb 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/WeightRecord.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/WeightRecord.kt @@ -80,7 +80,7 @@ public class WeightRecord( /* * Generated by the IDE: Code -> Generate -> "equals() and hashCode()". */ - companion object { + public companion object { private const val WEIGHT_NAME = "Weight" private const val WEIGHT_FIELD = "weight" private val MAX_WEIGHT = 1000.kilograms @@ -90,7 +90,7 @@ public class WeightRecord( * [androidx.health.connect.client.aggregate.AggregationResult]. */ @JvmField - val WEIGHT_AVG: AggregateMetric = + public val WEIGHT_AVG: AggregateMetric = AggregateMetric.doubleMetric( dataTypeName = WEIGHT_NAME, aggregationType = AggregateMetric.AggregationType.AVERAGE, @@ -103,7 +103,7 @@ public class WeightRecord( * [androidx.health.connect.client.aggregate.AggregationResult]. */ @JvmField - val WEIGHT_MIN: AggregateMetric = + public val WEIGHT_MIN: AggregateMetric = AggregateMetric.doubleMetric( dataTypeName = WEIGHT_NAME, aggregationType = AggregateMetric.AggregationType.MINIMUM, @@ -116,7 +116,7 @@ public class WeightRecord( * [androidx.health.connect.client.aggregate.AggregationResult]. */ @JvmField - val WEIGHT_MAX: AggregateMetric = + public val WEIGHT_MAX: AggregateMetric = AggregateMetric.doubleMetric( dataTypeName = WEIGHT_NAME, aggregationType = AggregateMetric.AggregationType.MAXIMUM, diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/WheelchairPushesRecord.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/WheelchairPushesRecord.kt index d4a72d2e687bc..35fe778bcc40c 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/WheelchairPushesRecord.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/WheelchairPushesRecord.kt @@ -79,13 +79,13 @@ public class WheelchairPushesRecord( return "WheelchairPushesRecord(startTime=$startTime, startZoneOffset=$startZoneOffset, endTime=$endTime, endZoneOffset=$endZoneOffset, count=$count, metadata=$metadata)" } - companion object { + public companion object { /** * Metric identifier to retrieve the total wheelchair push count from * [androidx.health.connect.client.aggregate.AggregationResult]. */ @JvmField - val COUNT_TOTAL: AggregateMetric = + public val COUNT_TOTAL: AggregateMetric = AggregateMetric.longMetric( "WheelchairPushes", AggregateMetric.AggregationType.TOTAL, diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/metadata/Device.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/metadata/Device.kt index a056610f572b1..ca15e61130f0e 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/metadata/Device.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/metadata/Device.kt @@ -62,59 +62,59 @@ public class Device( return "Device(type=$type, manufacturer=$manufacturer, model=$model)" } - companion object { - const val TYPE_UNKNOWN = 0 - const val TYPE_WATCH = 1 - const val TYPE_PHONE = 2 - const val TYPE_SCALE = 3 - const val TYPE_RING = 4 - const val TYPE_HEAD_MOUNTED = 5 - const val TYPE_FITNESS_BAND = 6 - const val TYPE_CHEST_STRAP = 7 - const val TYPE_SMART_DISPLAY = 8 + public companion object { + public const val TYPE_UNKNOWN: Int = 0 + public const val TYPE_WATCH: Int = 1 + public const val TYPE_PHONE: Int = 2 + public const val TYPE_SCALE: Int = 3 + public const val TYPE_RING: Int = 4 + public const val TYPE_HEAD_MOUNTED: Int = 5 + public const val TYPE_FITNESS_BAND: Int = 6 + public const val TYPE_CHEST_STRAP: Int = 7 + public const val TYPE_SMART_DISPLAY: Int = 8 /** * Requires * `androidx.health.connect.client.HealthConnectFeatures.FEATURE_EXTENDED_DEVICE_TYPES`. If * the feature is not available, this device type will be treated as [TYPE_UNKNOWN]. */ - const val TYPE_CONSUMER_MEDICAL_DEVICE = 9 + public const val TYPE_CONSUMER_MEDICAL_DEVICE: Int = 9 /** * Requires * `androidx.health.connect.client.HealthConnectFeatures.FEATURE_EXTENDED_DEVICE_TYPES`. If * the feature is not available, this device type will be treated as [TYPE_UNKNOWN]. */ - const val TYPE_GLASSES = 10 + public const val TYPE_GLASSES: Int = 10 /** * Requires * `androidx.health.connect.client.HealthConnectFeatures.FEATURE_EXTENDED_DEVICE_TYPES`. If * the feature is not available, this device type will be treated as [TYPE_UNKNOWN]. */ - const val TYPE_HEARABLE = 11 + public const val TYPE_HEARABLE: Int = 11 /** * Requires * `androidx.health.connect.client.HealthConnectFeatures.FEATURE_EXTENDED_DEVICE_TYPES`. If * the feature is not available, this device type will be treated as [TYPE_UNKNOWN]. */ - const val TYPE_FITNESS_MACHINE = 12 + public const val TYPE_FITNESS_MACHINE: Int = 12 /** * Requires * `androidx.health.connect.client.HealthConnectFeatures.FEATURE_EXTENDED_DEVICE_TYPES`. If * the feature is not available, this device type will be treated as [TYPE_UNKNOWN]. */ - const val TYPE_FITNESS_EQUIPMENT = 13 + public const val TYPE_FITNESS_EQUIPMENT: Int = 13 /** * Requires * `androidx.health.connect.client.HealthConnectFeatures.FEATURE_EXTENDED_DEVICE_TYPES`. If * the feature is not available, this device type will be treated as [TYPE_UNKNOWN]. */ - const val TYPE_PORTABLE_COMPUTER = 14 + public const val TYPE_PORTABLE_COMPUTER: Int = 14 /** * Requires * `androidx.health.connect.client.HealthConnectFeatures.FEATURE_EXTENDED_DEVICE_TYPES`. If * the feature is not available, this device type will be treated as [TYPE_UNKNOWN]. */ - const val TYPE_METER = 15 + public const val TYPE_METER: Int = 15 } /** List of supported device types on Health Platform. */ @@ -141,5 +141,5 @@ public class Device( ] ) @RestrictTo(RestrictTo.Scope.LIBRARY) - annotation class DeviceType + public annotation class DeviceType } diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/metadata/DeviceTypes.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/metadata/DeviceTypes.kt index 92c034ba7c62c..8d96c0d69ac9a 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/metadata/DeviceTypes.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/metadata/DeviceTypes.kt @@ -21,14 +21,14 @@ import androidx.annotation.RestrictTo /** List of supported device types on Health Platform. */ @RestrictTo(RestrictTo.Scope.LIBRARY) -object DeviceTypes { - const val UNKNOWN = "UNKNOWN" - const val WATCH = "WATCH" - const val PHONE = "PHONE" - const val SCALE = "SCALE" - const val RING = "RING" - const val HEAD_MOUNTED = "HEAD_MOUNTED" - const val FITNESS_BAND = "FITNESS_BAND" - const val CHEST_STRAP = "CHEST_STRAP" - const val SMART_DISPLAY = "SMART_DISPLAY" +public object DeviceTypes { + public const val UNKNOWN: String = "UNKNOWN" + public const val WATCH: String = "WATCH" + public const val PHONE: String = "PHONE" + public const val SCALE: String = "SCALE" + public const val RING: String = "RING" + public const val HEAD_MOUNTED: String = "HEAD_MOUNTED" + public const val FITNESS_BAND: String = "FITNESS_BAND" + public const val CHEST_STRAP: String = "CHEST_STRAP" + public const val SMART_DISPLAY: String = "SMART_DISPLAY" } diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/metadata/Metadata.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/metadata/Metadata.kt index c81a22151fa54..f9b742a42addf 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/metadata/Metadata.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/records/metadata/Metadata.kt @@ -31,7 +31,10 @@ internal constructor( * [RECORDING_METHOD_ACTIVELY_RECORDED], [RECORDING_METHOD_AUTOMATICALLY_RECORDED] and * [RECORDING_METHOD_MANUAL_ENTRY]. */ - @param:RecordingMethod @property:RecordingMethod @get:RecordingMethod val recordingMethod: Int, + @param:RecordingMethod + @property:RecordingMethod + @get:RecordingMethod + public val recordingMethod: Int, /** * Unique identifier of this data, assigned by Health Connect at insertion time. When [Record] @@ -108,11 +111,11 @@ internal constructor( return "Metadata(id='$id', dataOrigin=$dataOrigin, lastModifiedTime=$lastModifiedTime, clientRecordId=$clientRecordId, clientRecordVersion=$clientRecordVersion, device=$device, recordingMethod=$recordingMethod)" } - companion object { + public companion object { internal const val EMPTY_ID: String = "" /** Unknown recording method. */ - const val RECORDING_METHOD_UNKNOWN = 0 + public const val RECORDING_METHOD_UNKNOWN: Int = 0 /** * For data actively recorded by the user. @@ -122,7 +125,7 @@ internal constructor( * * [device] must be specified when using this recording method. */ - const val RECORDING_METHOD_ACTIVELY_RECORDED = 1 + public const val RECORDING_METHOD_ACTIVELY_RECORDED: Int = 1 /** * For data recorded passively by a device without user explicitly initiating the recording, @@ -132,14 +135,14 @@ internal constructor( * * [device] must be specified when using this recording method. */ - const val RECORDING_METHOD_AUTOMATICALLY_RECORDED = 2 + public const val RECORDING_METHOD_AUTOMATICALLY_RECORDED: Int = 2 /** * For data manually entered by the user. * * For e.g. Nutrition or weight data entered by the user. */ - const val RECORDING_METHOD_MANUAL_ENTRY = 3 + public const val RECORDING_METHOD_MANUAL_ENTRY: Int = 3 /** List of possible Recording method for the [Record]. */ @RestrictTo(RestrictTo.Scope.LIBRARY) @@ -150,7 +153,7 @@ internal constructor( RECORDING_METHOD_MANUAL_ENTRY, ) @Retention(AnnotationRetention.SOURCE) - annotation class RecordingMethod + public annotation class RecordingMethod /** * Creates Metadata for an actively recorded record. @@ -160,7 +163,7 @@ internal constructor( * @param device The [Device] associated with the record. */ @JvmStatic - fun activelyRecorded(device: Device): Metadata = + public fun activelyRecorded(device: Device): Metadata = Metadata(recordingMethod = RECORDING_METHOD_ACTIVELY_RECORDED, device = device) /** @@ -174,7 +177,7 @@ internal constructor( */ @JvmStatic @JvmOverloads - fun activelyRecorded( + public fun activelyRecorded( device: Device, clientRecordId: String, clientRecordVersion: Long = 0, @@ -197,7 +200,7 @@ internal constructor( * @param device The [Device] associated with the record. */ @JvmStatic - fun activelyRecordedWithId(id: String, device: Device): Metadata = + public fun activelyRecordedWithId(id: String, device: Device): Metadata = Metadata(recordingMethod = RECORDING_METHOD_ACTIVELY_RECORDED, id = id, device = device) /** @@ -208,7 +211,7 @@ internal constructor( * @param device The [Device] associated with the record. */ @JvmStatic - fun autoRecorded(device: Device): Metadata = + public fun autoRecorded(device: Device): Metadata = Metadata(recordingMethod = RECORDING_METHOD_AUTOMATICALLY_RECORDED, device = device) /** @@ -222,7 +225,7 @@ internal constructor( */ @JvmStatic @JvmOverloads - fun autoRecorded( + public fun autoRecorded( device: Device, clientRecordId: String, clientRecordVersion: Long = 0, @@ -245,7 +248,7 @@ internal constructor( * @param device The [Device] associated with the record. */ @JvmStatic - fun autoRecordedWithId(id: String, device: Device): Metadata = + public fun autoRecordedWithId(id: String, device: Device): Metadata = Metadata( recordingMethod = RECORDING_METHOD_AUTOMATICALLY_RECORDED, id = id, @@ -262,7 +265,7 @@ internal constructor( */ @JvmStatic @JvmOverloads - fun manualEntry(device: Device? = null): Metadata = + public fun manualEntry(device: Device? = null): Metadata = Metadata(recordingMethod = RECORDING_METHOD_MANUAL_ENTRY, device = device) /** @@ -277,7 +280,7 @@ internal constructor( */ @JvmStatic @JvmOverloads - fun manualEntry( + public fun manualEntry( clientRecordId: String, clientRecordVersion: Long = 0, device: Device? = null, @@ -301,7 +304,7 @@ internal constructor( */ @JvmStatic @JvmOverloads - fun manualEntryWithId(id: String, device: Device? = null): Metadata = + public fun manualEntryWithId(id: String, device: Device? = null): Metadata = Metadata(recordingMethod = RECORDING_METHOD_MANUAL_ENTRY, id = id, device = device) /** @@ -315,7 +318,7 @@ internal constructor( */ @JvmStatic @JvmOverloads - fun unknownRecordingMethod(device: Device? = null): Metadata = + public fun unknownRecordingMethod(device: Device? = null): Metadata = Metadata(recordingMethod = RECORDING_METHOD_UNKNOWN, device = device) /** @@ -331,7 +334,7 @@ internal constructor( */ @JvmStatic @JvmOverloads - fun unknownRecordingMethod( + public fun unknownRecordingMethod( clientRecordId: String, clientRecordVersion: Long = 0, device: Device? = null, @@ -355,7 +358,7 @@ internal constructor( */ @JvmStatic @JvmOverloads - fun unknownRecordingMethodWithId(id: String, device: Device? = null): Metadata = + public fun unknownRecordingMethodWithId(id: String, device: Device? = null): Metadata = Metadata(recordingMethod = RECORDING_METHOD_UNKNOWN, id = id, device = device) } } diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/request/AggregateGroupByDurationRequest.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/request/AggregateGroupByDurationRequest.kt index 0121f009f9ece..300528db73d20 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/request/AggregateGroupByDurationRequest.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/request/AggregateGroupByDurationRequest.kt @@ -34,7 +34,7 @@ import java.time.Duration * sliced into several equal-sized time buckets (except for the last one). * @param dataOriginFilter Set of [DataOrigin]s to read from, or empty for no filter. */ -class AggregateGroupByDurationRequest( +public class AggregateGroupByDurationRequest( internal val metrics: Set>, internal val timeRangeFilter: TimeRangeFilter, internal val timeRangeSlicer: Duration, diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/request/AggregateGroupByPeriodRequest.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/request/AggregateGroupByPeriodRequest.kt index e5f2ae1f171ce..daa63185bd2a4 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/request/AggregateGroupByPeriodRequest.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/request/AggregateGroupByPeriodRequest.kt @@ -34,7 +34,7 @@ import java.time.Period * sliced into several equal-sized time buckets (except for the last one). * @param dataOriginFilter Set of [DataOrigin]s to read from, or empty for no filter. */ -class AggregateGroupByPeriodRequest( +public class AggregateGroupByPeriodRequest( internal val metrics: Set>, internal val timeRangeFilter: TimeRangeFilter, internal val timeRangeSlicer: Period, diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/request/AggregateRequest.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/request/AggregateRequest.kt index bba3fedf8a0d6..4e9bb0877c277 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/request/AggregateRequest.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/request/AggregateRequest.kt @@ -28,7 +28,7 @@ import androidx.health.connect.client.time.TimeRangeFilter * @param dataOriginFilter Set of [DataOrigin]s to read from, or empty for no filter. * @see HealthConnectClient.aggregate */ -class AggregateRequest( +public class AggregateRequest( internal val metrics: Set>, internal val timeRangeFilter: TimeRangeFilter, internal val dataOriginFilter: Set = emptySet(), diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/request/ChangesTokenRequest.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/request/ChangesTokenRequest.kt index b6e4b15c004b6..602c6ebcb7100 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/request/ChangesTokenRequest.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/request/ChangesTokenRequest.kt @@ -27,10 +27,10 @@ import kotlin.reflect.KClass * @param dataOriginFilters Optional set of [DataOrigin] filters, default is empty set for no * filter. */ -class ChangesTokenRequest( - @get:RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) val recordTypes: Set>, +public class ChangesTokenRequest( + @get:RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) public val recordTypes: Set>, @get:RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) - val dataOriginFilters: Set = setOf(), + public val dataOriginFilters: Set = setOf(), ) { /* * Generated by the IDE: Code -> Generate -> "equals() and hashCode()". diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/request/CreateMedicalDataSourceRequest.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/request/CreateMedicalDataSourceRequest.kt index 52c345a87b0df..96b19a8724a71 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/request/CreateMedicalDataSourceRequest.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/request/CreateMedicalDataSourceRequest.kt @@ -54,10 +54,10 @@ import kotlin.String * [FhirVersion]. */ @ExperimentalPersonalHealthRecordApi -class CreateMedicalDataSourceRequest( - val fhirBaseUri: Uri, - val displayName: String, - val fhirVersion: FhirVersion, +public class CreateMedicalDataSourceRequest( + public val fhirBaseUri: Uri, + public val displayName: String, + public val fhirVersion: FhirVersion, ) { @SuppressLint("NewApi") // already checked with a feature availability check internal val platformCreateMedicalDataSourceRequest: PlatformCreateMedicalDataSourceRequest = @@ -70,7 +70,7 @@ class CreateMedicalDataSourceRequest( .build() } - override fun toString() = + override fun toString(): String = toString( this, mapOf( diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/request/DeleteMedicalResourcesRequest.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/request/DeleteMedicalResourcesRequest.kt index 0e3ada6f3b69d..6f5275c97ad45 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/request/DeleteMedicalResourcesRequest.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/request/DeleteMedicalResourcesRequest.kt @@ -47,9 +47,9 @@ import androidx.health.connect.client.records.toString * @see [HealthConnectClient.deleteMedicalResources] */ @ExperimentalPersonalHealthRecordApi -class DeleteMedicalResourcesRequest( - val dataSourceIds: Set = emptySet(), - val medicalResourceTypes: Set = emptySet(), +public class DeleteMedicalResourcesRequest( + public val dataSourceIds: Set = emptySet(), + public val medicalResourceTypes: Set = emptySet(), ) { @SuppressLint("NewApi") // already checked with a feature availability check internal val platformReadMedicalResourcesRequest: PlatformDeleteMedicalResourcesRequest = @@ -62,7 +62,7 @@ class DeleteMedicalResourcesRequest( .build() } - override fun toString() = + override fun toString(): String = toString( this, mapOf("dataSourceIds" to dataSourceIds, "medicalResourceTypes" to medicalResourceTypes), diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/request/GetMedicalDataSourcesRequest.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/request/GetMedicalDataSourcesRequest.kt index 3da55802bf810..3bae39ee835d1 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/request/GetMedicalDataSourcesRequest.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/request/GetMedicalDataSourcesRequest.kt @@ -43,7 +43,7 @@ import androidx.health.connect.client.records.toString * will be returned. */ @ExperimentalPersonalHealthRecordApi -class GetMedicalDataSourcesRequest(val packageNames: List) { +public class GetMedicalDataSourcesRequest(public val packageNames: List) { @SuppressLint("NewApi") // already checked with a feature availability check internal val platformGetMedicalDataSourcesRequest: PlatformGetMedicalDataSourcesRequest = @@ -53,7 +53,7 @@ class GetMedicalDataSourcesRequest(val packageNames: List) { .build() } - override fun toString() = toString(this, mapOf("packageNames" to packageNames)) + override fun toString(): String = toString(this, mapOf("packageNames" to packageNames)) override fun equals(other: Any?): Boolean { if (this === other) return true diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/request/ReadMedicalResourcesInitialRequest.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/request/ReadMedicalResourcesInitialRequest.kt index 5e4533f744111..b01298d8947da 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/request/ReadMedicalResourcesInitialRequest.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/request/ReadMedicalResourcesInitialRequest.kt @@ -53,9 +53,9 @@ import androidx.health.connect.client.request.ReadMedicalResourcesRequest.Compan * @see [HealthConnectClient.readMedicalResources] */ @ExperimentalPersonalHealthRecordApi -class ReadMedicalResourcesInitialRequest( - @MedicalResourceType val medicalResourceType: Int, - val medicalDataSourceIds: Set, +public class ReadMedicalResourcesInitialRequest( + @MedicalResourceType public val medicalResourceType: Int, + public val medicalDataSourceIds: Set, pageSize: Int = DEFAULT_PAGE_SIZE, ) : ReadMedicalResourcesRequest(pageSize) { @SuppressLint("NewApi") // already checked with a feature availability check diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/request/ReadMedicalResourcesPageRequest.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/request/ReadMedicalResourcesPageRequest.kt index 131ad0440c4db..11833ee274996 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/request/ReadMedicalResourcesPageRequest.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/request/ReadMedicalResourcesPageRequest.kt @@ -49,8 +49,10 @@ import androidx.health.connect.client.response.ReadMedicalResourcesResponse * @see [HealthConnectClient.readMedicalResources] */ @ExperimentalPersonalHealthRecordApi -class ReadMedicalResourcesPageRequest(val pageToken: String, pageSize: Int = DEFAULT_PAGE_SIZE) : - ReadMedicalResourcesRequest(pageSize) { +public class ReadMedicalResourcesPageRequest( + public val pageToken: String, + pageSize: Int = DEFAULT_PAGE_SIZE, +) : ReadMedicalResourcesRequest(pageSize) { @SuppressLint("NewApi") // already checked with a feature availability check override val platformReadMedicalResourcesRequest: PlatformReadMedicalResourcesRequest = diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/request/ReadMedicalResourcesRequest.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/request/ReadMedicalResourcesRequest.kt index cbfb4be715887..fbb8d080dc9ad 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/request/ReadMedicalResourcesRequest.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/request/ReadMedicalResourcesRequest.kt @@ -35,7 +35,7 @@ import androidx.health.connect.client.records.MedicalResource * @see [HealthConnectClient.readMedicalResources] */ @ExperimentalPersonalHealthRecordApi -abstract class ReadMedicalResourcesRequest internal constructor(val pageSize: Int) { +public abstract class ReadMedicalResourcesRequest internal constructor(public val pageSize: Int) { internal abstract val platformReadMedicalResourcesRequest: PlatformReadMedicalResourcesRequest override fun equals(other: Any?): Boolean { @@ -51,8 +51,8 @@ abstract class ReadMedicalResourcesRequest internal constructor(val pageSize: In return pageSize } - companion object { + public companion object { /** Default value for [ReadMedicalResourcesRequest.pageSize]. */ - const val DEFAULT_PAGE_SIZE = 1000 + public const val DEFAULT_PAGE_SIZE: Int = 1000 } } diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/request/ReadRecordsRequest.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/request/ReadRecordsRequest.kt index f1a8d5c9c553a..b825c2d7e897a 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/request/ReadRecordsRequest.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/request/ReadRecordsRequest.kt @@ -28,7 +28,7 @@ import kotlin.reflect.KClass * * @see [ReadRecordsRequest] for more information. */ -inline fun ReadRecordsRequest( +public inline fun ReadRecordsRequest( timeRangeFilter: TimeRangeFilter, dataOriginFilter: Set = emptySet(), ascendingOrder: Boolean = true, @@ -70,19 +70,19 @@ public class ReadRecordsRequest @RestrictTo(RestrictTo.Scope.LIBRARY) @ExperimentalDeduplicationApi constructor( - @get:RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) val recordType: KClass, - @get:RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) val timeRangeFilter: TimeRangeFilter, + @get:RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) public val recordType: KClass, + @get:RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) public val timeRangeFilter: TimeRangeFilter, @get:RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) - val dataOriginFilter: Set = emptySet(), - @get:RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) val ascendingOrder: Boolean = true, - @get:RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) val pageSize: Int = 1000, - @get:RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) val pageToken: String? = null, + public val dataOriginFilter: Set = emptySet(), + @get:RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) public val ascendingOrder: Boolean = true, + @get:RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) public val pageSize: Int = 1000, + @get:RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) public val pageToken: String? = null, @DeduplicationStrategy @get:RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) - val deduplicateStrategy: Int = DEDUPLICATION_STRATEGY_ENABLED_DEFAULT, + public val deduplicateStrategy: Int = DEDUPLICATION_STRATEGY_ENABLED_DEFAULT, ) { @OptIn(ExperimentalDeduplicationApi::class) - constructor( + public constructor( recordType: KClass, timeRangeFilter: TimeRangeFilter, dataOriginFilter: Set = emptySet(), @@ -159,7 +159,7 @@ constructor( ) @OptIn(ExperimentalDeduplicationApi::class) @RestrictTo(RestrictTo.Scope.LIBRARY) - annotation class DeduplicationStrategy + public annotation class DeduplicationStrategy @ExperimentalDeduplicationApi internal companion object { diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/request/UpsertMedicalResourceRequest.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/request/UpsertMedicalResourceRequest.kt index 57f81d4ea0801..e9938758c5aaf 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/request/UpsertMedicalResourceRequest.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/request/UpsertMedicalResourceRequest.kt @@ -50,10 +50,10 @@ import androidx.health.connect.client.records.toString * @property data The FHIR resource data in JSON representation. */ @ExperimentalPersonalHealthRecordApi -class UpsertMedicalResourceRequest( - val dataSourceId: String, - val fhirVersion: FhirVersion, - val data: String, +public class UpsertMedicalResourceRequest( + public val dataSourceId: String, + public val fhirVersion: FhirVersion, + public val data: String, ) { @SuppressLint("NewApi") // already checked with a feature availability check internal val platformUpsertMedicalResourceRequest: PlatformUpsertMedicalResourceRequest = diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/response/ChangesResponse.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/response/ChangesResponse.kt index 0bfdf5230255d..ec9ba404f9d70 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/response/ChangesResponse.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/response/ChangesResponse.kt @@ -30,7 +30,7 @@ import androidx.health.connect.client.changes.Change * @property changesTokenExpired Whether requested Changes-Token has expired. * @see [androidx.health.connect.client.HealthConnectClient.getChanges] */ -class ChangesResponse +public class ChangesResponse @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) constructor( public val changes: List, diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/response/InsertRecordsResponse.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/response/InsertRecordsResponse.kt index 52655879b8c75..25dbee0903c1c 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/response/InsertRecordsResponse.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/response/InsertRecordsResponse.kt @@ -30,5 +30,5 @@ constructor( * [androidx.health.connect.client.metadata.Metadata.recordId] of inserted [Record] in same order as * passed to [androidx.health.connect.client.HealthDataClient.insertRecords]. */ - val recordIdsList: List + public val recordIdsList: List ) diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/response/ReadMedicalResourcesResponse.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/response/ReadMedicalResourcesResponse.kt index ae7bb8385e24a..0b8abe3674566 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/response/ReadMedicalResourcesResponse.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/response/ReadMedicalResourcesResponse.kt @@ -40,10 +40,10 @@ import androidx.health.connect.client.request.ReadMedicalResourcesPageRequest * @see [HealthConnectClient.readMedicalResources] */ @ExperimentalPersonalHealthRecordApi -class ReadMedicalResourcesResponse( - val medicalResources: List, - val nextPageToken: String?, - val remainingCount: Int, +public class ReadMedicalResourcesResponse( + public val medicalResources: List, + public val nextPageToken: String?, + public val remainingCount: Int, ) { override fun toString(): String = toString( diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/response/ReadRecordResponse.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/response/ReadRecordResponse.kt index 375fc0d89e88b..9bb513d39b57b 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/response/ReadRecordResponse.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/response/ReadRecordResponse.kt @@ -23,6 +23,6 @@ import androidx.health.connect.client.records.Record * * @see [androidx.health.connect.client.HealthConnectClient.readRecord] */ -class ReadRecordResponse +public class ReadRecordResponse @RestrictTo(RestrictTo.Scope.LIBRARY) -constructor(val record: T) +constructor(public val record: T) diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/response/ReadRecordsResponse.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/response/ReadRecordsResponse.kt index 6f516944e67c5..3c769429e6618 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/response/ReadRecordsResponse.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/response/ReadRecordsResponse.kt @@ -28,6 +28,6 @@ import androidx.health.connect.client.records.Record * more records can be fetched; contains value `null` if no more pages. * @see androidx.health.connect.client.HealthConnectClient.readRecords */ -class ReadRecordsResponse +public class ReadRecordsResponse @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) -constructor(val records: List, val pageToken: String?) +constructor(public val records: List, public val pageToken: String?) diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/time/TimeRangeFilter.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/time/TimeRangeFilter.kt index 84a375a9aa8cf..da54b9d413187 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/time/TimeRangeFilter.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/time/TimeRangeFilter.kt @@ -34,15 +34,16 @@ import java.time.LocalDateTime * without knowing which time zone the user was at that time. [Record] without specifying * zoneOffset will assume the current system zone offset at query time. */ -class TimeRangeFilter +public class TimeRangeFilter @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) constructor( - @get:RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) val startTime: Instant? = null, - @get:RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) val endTime: Instant? = null, - @get:RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) val localStartTime: LocalDateTime? = null, - @get:RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) val localEndTime: LocalDateTime? = null, + @get:RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) public val startTime: Instant? = null, + @get:RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) public val endTime: Instant? = null, + @get:RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) + public val localStartTime: LocalDateTime? = null, + @get:RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) public val localEndTime: LocalDateTime? = null, ) { - companion object { + public companion object { /** * Creates a [TimeRangeFilter] for a time range within the [Instant] time range [startTime, * endTime). @@ -58,7 +59,7 @@ constructor( * @see after for time range with open-ended [endTime]. */ @JvmStatic - fun between(startTime: Instant, endTime: Instant): TimeRangeFilter { + public fun between(startTime: Instant, endTime: Instant): TimeRangeFilter { require(startTime.isBefore(endTime)) { "end time needs be after start time" } return TimeRangeFilter(startTime = startTime, endTime = endTime) } @@ -74,7 +75,7 @@ constructor( * @see after for time range with open-ended [endTime]. */ @JvmStatic - fun between(startTime: LocalDateTime, endTime: LocalDateTime): TimeRangeFilter { + public fun between(startTime: LocalDateTime, endTime: LocalDateTime): TimeRangeFilter { require(startTime.isBefore(endTime)) { "end time needs be after start time" } return TimeRangeFilter( startTime = null, @@ -93,7 +94,8 @@ constructor( * @see after for time range with open-ended [endTime] */ @JvmStatic - fun before(endTime: Instant) = TimeRangeFilter(startTime = null, endTime = endTime) + public fun before(endTime: Instant): TimeRangeFilter = + TimeRangeFilter(startTime = null, endTime = endTime) /** * Creates a [TimeRangeFilter] for a time range until the given [endTime]. @@ -104,7 +106,7 @@ constructor( * @see after for time range with open-ended [endTime] */ @JvmStatic - fun before(endTime: LocalDateTime) = + public fun before(endTime: LocalDateTime): TimeRangeFilter = TimeRangeFilter( startTime = null, endTime = null, @@ -120,7 +122,9 @@ constructor( * @see between for closed-ended time range. * @see after for time range with open-ended [startTime] */ - @JvmStatic fun after(startTime: Instant) = TimeRangeFilter(startTime = startTime) + @JvmStatic + public fun after(startTime: Instant): TimeRangeFilter = + TimeRangeFilter(startTime = startTime) /** * Creates a [TimeRangeFilter] for a time range after the given [startTime]. @@ -131,7 +135,7 @@ constructor( * @see after for time range with open-ended [startTime] */ @JvmStatic - fun after(startTime: LocalDateTime) = + public fun after(startTime: LocalDateTime): TimeRangeFilter = TimeRangeFilter(startTime = null, endTime = null, localStartTime = startTime) } diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/units/BloodGlucose.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/units/BloodGlucose.kt index b07eb2bf642ad..f03e814cc0909 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/units/BloodGlucose.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/units/BloodGlucose.kt @@ -21,17 +21,17 @@ package androidx.health.connect.client.units * - mmol/L - see [BloodGlucose.millimolesPerLiter] * - mg/dL - see [BloodGlucose.milligramsPerDeciliter] */ -class BloodGlucose private constructor(private val value: Double, private val type: Type) : +public class BloodGlucose private constructor(private val value: Double, private val type: Type) : Comparable { /** Returns the blood glucose level in mmol/L. */ @get:JvmName("getMillimolesPerLiter") - val inMillimolesPerLiter: Double + public val inMillimolesPerLiter: Double get() = value * type.millimolesPerLiterPerUnit /** Returns the blood glucose level concentration in mg/dL. */ @get:JvmName("getMilligramsPerDeciliter") - val inMilligramsPerDeciliter: Double + public val inMilligramsPerDeciliter: Double get() = get(type = Type.MILLIGRAMS_PER_DECILITER) private fun get(type: Type): Double = @@ -62,17 +62,17 @@ class BloodGlucose private constructor(private val value: Double, private val ty override fun toString(): String = "$value ${type.title}" - companion object { + public companion object { private val ZEROS = Type.values().associateWith { BloodGlucose(value = 0.0, type = it) } /** Creates [BloodGlucose] with the specified value in mmol/L. */ @JvmStatic - fun millimolesPerLiter(value: Double): BloodGlucose = + public fun millimolesPerLiter(value: Double): BloodGlucose = BloodGlucose(value, Type.MILLIMOLES_PER_LITER) /** Creates [BloodGlucose] with the specified value in mg/dL. */ @JvmStatic - fun milligramsPerDeciliter(value: Double): BloodGlucose = + public fun milligramsPerDeciliter(value: Double): BloodGlucose = BloodGlucose(value, Type.MILLIGRAMS_PER_DECILITER) } diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/units/Energy.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/units/Energy.kt index cd95380270e0e..ab1bbc8b878fd 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/units/Energy.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/units/Energy.kt @@ -23,27 +23,27 @@ package androidx.health.connect.client.units * - joules - see [Energy.joules], [Double.joules] * - kilojoules - see [Energy.kilojoules], [Double.kilojoules] */ -class Energy private constructor(private val value: Double, private val type: Type) : +public class Energy private constructor(private val value: Double, private val type: Type) : Comparable { /** Returns the energy in calories. */ @get:JvmName("getCalories") - val inCalories: Double + public val inCalories: Double get() = value * type.caloriesPerUnit /** Returns the energy in kilocalories. */ @get:JvmName("getKilocalories") - val inKilocalories: Double + public val inKilocalories: Double get() = get(type = Type.KILOCALORIES) /** Returns the energy in joules. */ @get:JvmName("getJoules") - val inJoules: Double + public val inJoules: Double get() = get(type = Type.JOULES) /** Returns the energy in kilojoules. */ @get:JvmName("getKilojoules") - val inKilojoules: Double + public val inKilojoules: Double get() = get(type = Type.KILOJOULES) private fun get(type: Type): Double = @@ -74,20 +74,20 @@ class Energy private constructor(private val value: Double, private val type: Ty override fun toString(): String = "$value ${type.title}" - companion object { + public companion object { private val ZEROS = Type.values().associateWith { Energy(value = 0.0, type = it) } /** Creates [Energy] with the specified value in calories. */ - @JvmStatic fun calories(value: Double): Energy = Energy(value, Type.CALORIES) + @JvmStatic public fun calories(value: Double): Energy = Energy(value, Type.CALORIES) /** Creates [Energy] with the specified value in kilocalories. */ - @JvmStatic fun kilocalories(value: Double): Energy = Energy(value, Type.KILOCALORIES) + @JvmStatic public fun kilocalories(value: Double): Energy = Energy(value, Type.KILOCALORIES) /** Creates [Energy] with the specified value in joules. */ - @JvmStatic fun joules(value: Double): Energy = Energy(value, Type.JOULES) + @JvmStatic public fun joules(value: Double): Energy = Energy(value, Type.JOULES) /** Creates [Energy] with the specified value in kilojoules. */ - @JvmStatic fun kilojoules(value: Double): Energy = Energy(value, Type.KILOJOULES) + @JvmStatic public fun kilojoules(value: Double): Energy = Energy(value, Type.KILOJOULES) } private enum class Type { @@ -115,80 +115,80 @@ class Energy private constructor(private val value: Double, private val type: Ty /** Creates [Energy] with the specified value in calories. */ @get:JvmSynthetic -val Double.calories: Energy +public val Double.calories: Energy get() = Energy.calories(value = this) /** Creates [Energy] with the specified value in calories. */ @get:JvmSynthetic -val Long.calories: Energy +public val Long.calories: Energy get() = toDouble().calories /** Creates [Energy] with the specified value in calories. */ @get:JvmSynthetic -val Float.calories: Energy +public val Float.calories: Energy get() = toDouble().calories /** Creates [Energy] with the specified value in calories. */ @get:JvmSynthetic -val Int.calories: Energy +public val Int.calories: Energy get() = toDouble().calories /** Creates [Energy] with the specified value in kilocalories. */ @get:JvmSynthetic -val Double.kilocalories: Energy +public val Double.kilocalories: Energy get() = Energy.kilocalories(value = this) /** Creates [Energy] with the specified value in kilocalories. */ @get:JvmSynthetic -val Long.kilocalories: Energy +public val Long.kilocalories: Energy get() = toDouble().kilocalories /** Creates [Energy] with the specified value in kilocalories. */ @get:JvmSynthetic -val Float.kilocalories: Energy +public val Float.kilocalories: Energy get() = toDouble().kilocalories /** Creates [Energy] with the specified value in kilocalories. */ @get:JvmSynthetic -val Int.kilocalories: Energy +public val Int.kilocalories: Energy get() = toDouble().kilocalories /** Creates [Energy] with the specified value in joules. */ @get:JvmSynthetic -val Double.joules: Energy +public val Double.joules: Energy get() = Energy.joules(value = this) /** Creates [Energy] with the specified value in joules. */ @get:JvmSynthetic -val Long.joules: Energy +public val Long.joules: Energy get() = toDouble().joules /** Creates [Energy] with the specified value in joules. */ @get:JvmSynthetic -val Float.joules: Energy +public val Float.joules: Energy get() = toDouble().joules /** Creates [Energy] with the specified value in joules. */ @get:JvmSynthetic -val Int.joules: Energy +public val Int.joules: Energy get() = toDouble().joules /** Creates [Energy] with the specified value in kilojoules. */ @get:JvmSynthetic -val Double.kilojoules: Energy +public val Double.kilojoules: Energy get() = Energy.kilojoules(value = this) /** Creates [Energy] with the specified value in kilojoules. */ @get:JvmSynthetic -val Long.kilojoules: Energy +public val Long.kilojoules: Energy get() = toDouble().kilojoules /** Creates [Energy] with the specified value in kilojoules. */ @get:JvmSynthetic -val Float.kilojoules: Energy +public val Float.kilojoules: Energy get() = toDouble().kilojoules /** Creates [Energy] with the specified value in kilojoules. */ @get:JvmSynthetic -val Int.kilojoules: Energy +public val Int.kilojoules: Energy get() = toDouble().kilojoules diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/units/Length.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/units/Length.kt index 2d971970d773a..ff329f0d80191 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/units/Length.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/units/Length.kt @@ -17,32 +17,32 @@ package androidx.health.connect.client.units /** Represents a unit of length. Supported units: meters, kilometers, miles, inches and feet. */ -class Length private constructor(private val value: Double, private val type: Type) : +public class Length private constructor(private val value: Double, private val type: Type) : Comparable { /** Returns the length in meters. */ @get:JvmName("getMeters") - val inMeters: Double + public val inMeters: Double get() = value * type.metersPerUnit /** Returns the length in kilometers. */ @get:JvmName("getKilometers") - val inKilometers: Double + public val inKilometers: Double get() = get(type = Type.KILOMETERS) /** Returns the length in miles. */ @get:JvmName("getMiles") - val inMiles: Double + public val inMiles: Double get() = get(type = Type.MILES) /** Returns the length in inches. */ @get:JvmName("getInches") - val inInches: Double + public val inInches: Double get() = get(type = Type.INCHES) /** Returns the length in feet. */ @get:JvmName("getFeet") - val inFeet: Double + public val inFeet: Double get() = get(type = Type.FEET) private fun get(type: Type): Double = @@ -73,23 +73,23 @@ class Length private constructor(private val value: Double, private val type: Ty override fun toString(): String = "$value ${type.name.lowercase()}" - companion object { + public companion object { private val ZEROS = Type.values().associateWith { Length(value = 0.0, type = it) } /** Creates [Length] with the specified value in meters. */ - @JvmStatic fun meters(value: Double): Length = Length(value, Type.METERS) + @JvmStatic public fun meters(value: Double): Length = Length(value, Type.METERS) /** Creates [Length] with the specified value in kilometers. */ - @JvmStatic fun kilometers(value: Double): Length = Length(value, Type.KILOMETERS) + @JvmStatic public fun kilometers(value: Double): Length = Length(value, Type.KILOMETERS) /** Creates [Length] with the specified value in miles. */ - @JvmStatic fun miles(value: Double): Length = Length(value, Type.MILES) + @JvmStatic public fun miles(value: Double): Length = Length(value, Type.MILES) /** Creates [Length] with the specified value in inches. */ - @JvmStatic fun inches(value: Double): Length = Length(value, Type.INCHES) + @JvmStatic public fun inches(value: Double): Length = Length(value, Type.INCHES) /** Creates [Length] with the specified value in feet. */ - @JvmStatic fun feet(value: Double): Length = Length(value, Type.FEET) + @JvmStatic public fun feet(value: Double): Length = Length(value, Type.FEET) } private enum class Type { @@ -115,100 +115,100 @@ class Length private constructor(private val value: Double, private val type: Ty /** Creates [Length] with the specified value in meters. */ @get:JvmSynthetic -val Double.meters: Length +public val Double.meters: Length get() = Length.meters(value = this) /** Creates [Length] with the specified value in meters. */ @get:JvmSynthetic -val Long.meters: Length +public val Long.meters: Length get() = toDouble().meters /** Creates [Length] with the specified value in meters. */ @get:JvmSynthetic -val Float.meters: Length +public val Float.meters: Length get() = toDouble().meters /** Creates [Length] with the specified value in meters. */ @get:JvmSynthetic -val Int.meters: Length +public val Int.meters: Length get() = toDouble().meters /** Creates [Length] with the specified value in kilometers. */ @get:JvmSynthetic -val Double.kilometers: Length +public val Double.kilometers: Length get() = Length.kilometers(value = this) /** Creates [Length] with the specified value in kilometers. */ @get:JvmSynthetic -val Float.kilometers: Length +public val Float.kilometers: Length get() = toDouble().kilometers /** Creates [Length] with the specified value in kilometers. */ @get:JvmSynthetic -val Long.kilometers: Length +public val Long.kilometers: Length get() = toDouble().kilometers /** Creates [Length] with the specified value in kilometers. */ @get:JvmSynthetic -val Int.kilometers: Length +public val Int.kilometers: Length get() = toDouble().kilometers /** Creates [Length] with the specified value in miles. */ @get:JvmSynthetic -val Double.miles: Length +public val Double.miles: Length get() = Length.miles(value = this) /** Creates [Length] with the specified value in miles. */ @get:JvmSynthetic -val Float.miles: Length +public val Float.miles: Length get() = toDouble().miles /** Creates [Length] with the specified value in miles. */ @get:JvmSynthetic -val Long.miles: Length +public val Long.miles: Length get() = toDouble().miles /** Creates [Length] with the specified value in miles. */ @get:JvmSynthetic -val Int.miles: Length +public val Int.miles: Length get() = toDouble().miles /** Creates [Length] with the specified value in inches. */ @get:JvmSynthetic -val Double.inches: Length +public val Double.inches: Length get() = Length.inches(value = this) /** Creates [Length] with the specified value in inches. */ @get:JvmSynthetic -val Float.inches: Length +public val Float.inches: Length get() = toDouble().inches /** Creates [Length] with the specified value in inches. */ @get:JvmSynthetic -val Long.inches: Length +public val Long.inches: Length get() = toDouble().inches /** Creates [Length] with the specified value in inches. */ @get:JvmSynthetic -val Int.inches: Length +public val Int.inches: Length get() = toDouble().inches /** Creates [Length] with the specified value in feet. */ @get:JvmSynthetic -val Double.feet: Length +public val Double.feet: Length get() = Length.feet(value = this) /** Creates [Length] with the specified value in feet. */ @get:JvmSynthetic -val Float.feet: Length +public val Float.feet: Length get() = toDouble().feet /** Creates [Length] with the specified value in feet. */ @get:JvmSynthetic -val Long.feet: Length +public val Long.feet: Length get() = toDouble().feet /** Creates [Length] with the specified value in feet. */ @get:JvmSynthetic -val Int.feet: Length +public val Int.feet: Length get() = toDouble().feet diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/units/Mass.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/units/Mass.kt index 7778f9bc3769e..f5baa43899cc3 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/units/Mass.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/units/Mass.kt @@ -25,37 +25,37 @@ package androidx.health.connect.client.units * - ounces - see [Mass.ounces], [Double.ounces] * - pounds - see [Mass.pounds], [Double.pounds] */ -class Mass private constructor(private val value: Double, private val type: Type) : +public class Mass private constructor(private val value: Double, private val type: Type) : Comparable { /** Returns the mass in grams. */ @get:JvmName("getGrams") - val inGrams: Double + public val inGrams: Double get() = value * type.gramsPerUnit /** Returns the mass in kilograms. */ @get:JvmName("getKilograms") - val inKilograms: Double + public val inKilograms: Double get() = get(type = Type.KILOGRAMS) /** Returns the mass in milligrams. */ @get:JvmName("getMilligrams") - val inMilligrams: Double + public val inMilligrams: Double get() = get(type = Type.MILLIGRAMS) /** Returns the mass in micrograms. */ @get:JvmName("getMicrograms") - val inMicrograms: Double + public val inMicrograms: Double get() = get(type = Type.MICROGRAMS) /** Returns the mass in ounces. */ @get:JvmName("getOunces") - val inOunces: Double + public val inOunces: Double get() = get(type = Type.OUNCES) /** Returns the mass in pounds. */ @get:JvmName("getPounds") - val inPounds: Double + public val inPounds: Double get() = get(type = Type.POUNDS) private fun get(type: Type): Double = @@ -86,26 +86,26 @@ class Mass private constructor(private val value: Double, private val type: Type override fun toString(): String = "$value ${type.name.lowercase()}" - companion object { + public companion object { private val ZEROS = Type.values().associateWith { Mass(value = 0.0, type = it) } /** Creates [Mass] with the specified value in grams. */ - @JvmStatic fun grams(value: Double): Mass = Mass(value, Type.GRAMS) + @JvmStatic public fun grams(value: Double): Mass = Mass(value, Type.GRAMS) /** Creates [Mass] with the specified value in kilograms. */ - @JvmStatic fun kilograms(value: Double): Mass = Mass(value, Type.KILOGRAMS) + @JvmStatic public fun kilograms(value: Double): Mass = Mass(value, Type.KILOGRAMS) /** Creates [Mass] with the specified value in milligrams. */ - @JvmStatic fun milligrams(value: Double): Mass = Mass(value, Type.MILLIGRAMS) + @JvmStatic public fun milligrams(value: Double): Mass = Mass(value, Type.MILLIGRAMS) /** Creates [Mass] with the specified value in micrograms. */ - @JvmStatic fun micrograms(value: Double): Mass = Mass(value, Type.MICROGRAMS) + @JvmStatic public fun micrograms(value: Double): Mass = Mass(value, Type.MICROGRAMS) /** Creates [Mass] with the specified value in ounces. */ - @JvmStatic fun ounces(value: Double): Mass = Mass(value, Type.OUNCES) + @JvmStatic public fun ounces(value: Double): Mass = Mass(value, Type.OUNCES) /** Creates [Mass] with the specified value in pounds. */ - @JvmStatic fun pounds(value: Double): Mass = Mass(value, Type.POUNDS) + @JvmStatic public fun pounds(value: Double): Mass = Mass(value, Type.POUNDS) } private enum class Type { @@ -134,120 +134,120 @@ class Mass private constructor(private val value: Double, private val type: Type /** Creates [Mass] with the specified value in grams. */ @get:JvmSynthetic -val Double.grams: Mass +public val Double.grams: Mass get() = Mass.grams(value = this) /** Creates [Mass] with the specified value in grams. */ @get:JvmSynthetic -val Float.grams: Mass +public val Float.grams: Mass get() = toDouble().grams /** Creates [Mass] with the specified value in grams. */ @get:JvmSynthetic -val Long.grams: Mass +public val Long.grams: Mass get() = toDouble().grams /** Creates [Mass] with the specified value in grams. */ @get:JvmSynthetic -val Int.grams: Mass +public val Int.grams: Mass get() = toDouble().grams /** Creates [Mass] with the specified value in kilograms. */ @get:JvmSynthetic -val Double.kilograms: Mass +public val Double.kilograms: Mass get() = Mass.kilograms(value = this) /** Creates [Mass] with the specified value in kilograms. */ @get:JvmSynthetic -val Float.kilograms: Mass +public val Float.kilograms: Mass get() = toDouble().kilograms /** Creates [Mass] with the specified value in kilograms. */ @get:JvmSynthetic -val Long.kilograms: Mass +public val Long.kilograms: Mass get() = toDouble().kilograms /** Creates [Mass] with the specified value in kilograms. */ @get:JvmSynthetic -val Int.kilograms: Mass +public val Int.kilograms: Mass get() = toDouble().kilograms /** Creates [Mass] with the specified value in milligrams. */ @get:JvmSynthetic -val Double.milligrams: Mass +public val Double.milligrams: Mass get() = Mass.milligrams(value = this) /** Creates [Mass] with the specified value in milligrams. */ @get:JvmSynthetic -val Float.milligrams: Mass +public val Float.milligrams: Mass get() = toDouble().milligrams /** Creates [Mass] with the specified value in milligrams. */ @get:JvmSynthetic -val Long.milligrams: Mass +public val Long.milligrams: Mass get() = toDouble().milligrams /** Creates [Mass] with the specified value in milligrams. */ @get:JvmSynthetic -val Int.milligrams: Mass +public val Int.milligrams: Mass get() = toDouble().milligrams /** Creates [Mass] with the specified value in micrograms. */ @get:JvmSynthetic -val Double.micrograms: Mass +public val Double.micrograms: Mass get() = Mass.micrograms(value = this) /** Creates [Mass] with the specified value in micrograms. */ @get:JvmSynthetic -val Float.micrograms: Mass +public val Float.micrograms: Mass get() = toDouble().micrograms /** Creates [Mass] with the specified value in micrograms. */ @get:JvmSynthetic -val Long.micrograms: Mass +public val Long.micrograms: Mass get() = toDouble().micrograms /** Creates [Mass] with the specified value in micrograms. */ @get:JvmSynthetic -val Int.micrograms: Mass +public val Int.micrograms: Mass get() = toDouble().micrograms /** Creates [Mass] with the specified value in ounces. */ @get:JvmSynthetic -val Double.ounces: Mass +public val Double.ounces: Mass get() = Mass.ounces(value = this) /** Creates [Mass] with the specified value in ounces. */ @get:JvmSynthetic -val Float.ounces: Mass +public val Float.ounces: Mass get() = toDouble().ounces /** Creates [Mass] with the specified value in ounces. */ @get:JvmSynthetic -val Long.ounces: Mass +public val Long.ounces: Mass get() = toDouble().ounces /** Creates [Mass] with the specified value in ounces. */ @get:JvmSynthetic -val Int.ounces: Mass +public val Int.ounces: Mass get() = toDouble().ounces /** Creates [Mass] with the specified value in pounds. */ @get:JvmSynthetic -val Double.pounds: Mass +public val Double.pounds: Mass get() = Mass.pounds(value = this) /** Creates [Mass] with the specified value in pounds. */ @get:JvmSynthetic -val Float.pounds: Mass +public val Float.pounds: Mass get() = toDouble().pounds /** Creates [Mass] with the specified value in pounds. */ @get:JvmSynthetic -val Long.pounds: Mass +public val Long.pounds: Mass get() = toDouble().pounds /** Creates [Mass] with the specified value in pounds. */ @get:JvmSynthetic -val Int.pounds: Mass +public val Int.pounds: Mass get() = toDouble().pounds diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/units/Percentage.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/units/Percentage.kt index 34ac2c31d3d77..32895cc4f06e4 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/units/Percentage.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/units/Percentage.kt @@ -17,7 +17,7 @@ package androidx.health.connect.client.units /** Represents a value as a percentage, not a fraction - for example 100%, 89.62%, etc. */ -class Percentage(val value: Double) : Comparable { +public class Percentage(public val value: Double) : Comparable { override fun compareTo(other: Percentage): Int = value.compareTo(other.value) @@ -35,20 +35,20 @@ class Percentage(val value: Double) : Comparable { /** Creates [Percentage] with the specified percentage value, not a fraction. */ @get:JvmSynthetic -val Double.percent: Percentage +public val Double.percent: Percentage get() = Percentage(value = this) /** Creates [Percentage] with the specified percentage value, not a fraction. */ @get:JvmSynthetic -val Long.percent: Percentage +public val Long.percent: Percentage get() = toDouble().percent /** Creates [Percentage] with the specified percentage value, not a fraction. */ @get:JvmSynthetic -val Float.percent: Percentage +public val Float.percent: Percentage get() = toDouble().percent /** Creates [Percentage] with the specified percentage value, not a fraction. */ @get:JvmSynthetic -val Int.percent: Percentage +public val Int.percent: Percentage get() = toDouble().percent diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/units/Power.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/units/Power.kt index 26ffb0cc23ad4..93bd55b0fcee0 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/units/Power.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/units/Power.kt @@ -21,17 +21,17 @@ package androidx.health.connect.client.units * - watts - see [Power.watts], [Double.watts] * - kilocalories/day - see [Power.kilocaloriesPerDay], [Double.kilocaloriesPerDay] */ -class Power private constructor(private val value: Double, private val type: Type) : +public class Power private constructor(private val value: Double, private val type: Type) : Comparable { /** Returns the power in Watts. */ @get:JvmName("getWatts") - val inWatts: Double + public val inWatts: Double get() = value * type.wattsPerUnit /** Returns the power in kilocalories/day. */ @get:JvmName("getKilocaloriesPerDay") - val inKilocaloriesPerDay: Double + public val inKilocaloriesPerDay: Double get() = get(type = Type.KILOCALORIES_PER_DAY) private fun get(type: Type): Double = @@ -62,15 +62,16 @@ class Power private constructor(private val value: Double, private val type: Typ override fun toString(): String = "$value ${type.title}" - companion object { + public companion object { private val ZEROS = Type.values().associateWith { Power(value = 0.0, type = it) } /** Creates [Power] with the specified value in Watts. */ - @JvmStatic fun watts(value: Double): Power = Power(value, Type.WATTS) + @JvmStatic public fun watts(value: Double): Power = Power(value, Type.WATTS) /** Creates [Power] with the specified value in kilocalories/day. */ @JvmStatic - fun kilocaloriesPerDay(value: Double): Power = Power(value, Type.KILOCALORIES_PER_DAY) + public fun kilocaloriesPerDay(value: Double): Power = + Power(value, Type.KILOCALORIES_PER_DAY) } private enum class Type { @@ -90,40 +91,40 @@ class Power private constructor(private val value: Double, private val type: Typ /** Creates [Power] with the specified value in Watts. */ @get:JvmSynthetic -val Double.watts: Power +public val Double.watts: Power get() = Power.watts(value = this) /** Creates [Power] with the specified value in Watts. */ @get:JvmSynthetic -val Long.watts: Power +public val Long.watts: Power get() = toDouble().watts /** Creates [Power] with the specified value in Watts. */ @get:JvmSynthetic -val Float.watts: Power +public val Float.watts: Power get() = toDouble().watts /** Creates [Power] with the specified value in Watts. */ @get:JvmSynthetic -val Int.watts: Power +public val Int.watts: Power get() = toDouble().watts /** Creates [Power] with the specified value in kilocalories/day. */ @get:JvmSynthetic -val Double.kilocaloriesPerDay: Power +public val Double.kilocaloriesPerDay: Power get() = Power.kilocaloriesPerDay(value = this) /** Creates [Power] with the specified value in kilocalories/day. */ @get:JvmSynthetic -val Long.kilocaloriesPerDay: Power +public val Long.kilocaloriesPerDay: Power get() = toDouble().kilocaloriesPerDay /** Creates [Power] with the specified value in kilocalories/day. */ @get:JvmSynthetic -val Float.kilocaloriesPerDay: Power +public val Float.kilocaloriesPerDay: Power get() = toDouble().kilocaloriesPerDay /** Creates [Power] with the specified value in kilocalories/day. */ @get:JvmSynthetic -val Int.kilocaloriesPerDay: Power +public val Int.kilocaloriesPerDay: Power get() = toDouble().kilocaloriesPerDay diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/units/Pressure.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/units/Pressure.kt index 0a732f07b6a80..c088f5409ac52 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/units/Pressure.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/units/Pressure.kt @@ -21,11 +21,11 @@ package androidx.health.connect.client.units * - millimeters of Mercury (mmHg) - see [Pressure.millimetersOfMercury], * [Double.millimetersOfMercury]. */ -class Pressure private constructor(private val value: Double) : Comparable { +public class Pressure private constructor(private val value: Double) : Comparable { /** Returns the pressure in millimeters of Mercury (mmHg). */ @get:JvmName("getMillimetersOfMercury") - val inMillimetersOfMercury: Double + public val inMillimetersOfMercury: Double get() = value /** Returns zero [Pressure] of the same type (currently there is only one type - mmHg). */ @@ -44,30 +44,30 @@ class Pressure private constructor(private val value: Double) : Comparable { /** Returns the temperature in Celsius degrees. */ @get:JvmName("getCelsius") - val inCelsius: Double + public val inCelsius: Double get() = when (type) { Type.CELSIUS -> value @@ -35,7 +35,7 @@ class Temperature private constructor(private val value: Double, private val typ /** Returns the temperature in Fahrenheit degrees. */ @get:JvmName("getFahrenheit") - val inFahrenheit: Double + public val inFahrenheit: Double get() = when (type) { Type.CELSIUS -> value * 1.8 + 32.0 @@ -64,12 +64,13 @@ class Temperature private constructor(private val value: Double, private val typ override fun toString(): String = "$value ${type.title}" - companion object { + public companion object { /** Creates [Temperature] with the specified value in Celsius degrees. */ - @JvmStatic fun celsius(value: Double): Temperature = Temperature(value, Type.CELSIUS) + @JvmStatic public fun celsius(value: Double): Temperature = Temperature(value, Type.CELSIUS) /** Creates [Temperature] with the specified value in Fahrenheit degrees. */ - @JvmStatic fun fahrenheit(value: Double): Temperature = Temperature(value, Type.FAHRENHEIT) + @JvmStatic + public fun fahrenheit(value: Double): Temperature = Temperature(value, Type.FAHRENHEIT) } private enum class Type { @@ -86,40 +87,40 @@ class Temperature private constructor(private val value: Double, private val typ /** Creates [Temperature] with the specified value in Celsius degrees. */ @get:JvmSynthetic -val Double.celsius: Temperature +public val Double.celsius: Temperature get() = Temperature.celsius(value = this) /** Creates [Temperature] with the specified value in Celsius degrees. */ @get:JvmSynthetic -val Long.celsius: Temperature +public val Long.celsius: Temperature get() = toDouble().celsius /** Creates [Temperature] with the specified value in Celsius degrees. */ @get:JvmSynthetic -val Float.celsius: Temperature +public val Float.celsius: Temperature get() = toDouble().celsius /** Creates [Temperature] with the specified value in Celsius degrees. */ @get:JvmSynthetic -val Int.celsius: Temperature +public val Int.celsius: Temperature get() = toDouble().celsius /** Creates [Temperature] with the specified value in Fahrenheit degrees. */ @get:JvmSynthetic -val Double.fahrenheit: Temperature +public val Double.fahrenheit: Temperature get() = Temperature.fahrenheit(value = this) /** Creates [Temperature] with the specified value in Fahrenheit degrees. */ @get:JvmSynthetic -val Long.fahrenheit: Temperature +public val Long.fahrenheit: Temperature get() = toDouble().fahrenheit /** Creates [Temperature] with the specified value in Fahrenheit degrees. */ @get:JvmSynthetic -val Float.fahrenheit: Temperature +public val Float.fahrenheit: Temperature get() = toDouble().fahrenheit /** Creates [Temperature] with the specified value in Fahrenheit degrees. */ @get:JvmSynthetic -val Int.fahrenheit: Temperature +public val Int.fahrenheit: Temperature get() = toDouble().fahrenheit diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/units/TemperatureDelta.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/units/TemperatureDelta.kt index a28fdad0bfbe7..1857095842ff7 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/units/TemperatureDelta.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/units/TemperatureDelta.kt @@ -21,13 +21,13 @@ package androidx.health.connect.client.units * - Celsius - see [TemperatureDelta.celsius] * - Fahrenheit - see [TemperatureDelta.fahrenheit] */ -class TemperatureDelta +public class TemperatureDelta private constructor(private val value: Double, private val temperatureUnit: TemperatureUnit) : Comparable { /** Returns the TemperatureDelta in Celsius degrees. */ @get:JvmName("getCelsius") - val inCelsius: Double + public val inCelsius: Double get() = when (temperatureUnit) { TemperatureUnit.CELSIUS -> value @@ -36,7 +36,7 @@ private constructor(private val value: Double, private val temperatureUnit: Temp /** Returns the TemperatureDelta in Fahrenheit degrees. */ @get:JvmName("getFahrenheit") - val inFahrenheit: Double + public val inFahrenheit: Double get() = when (temperatureUnit) { TemperatureUnit.CELSIUS -> value * 1.8 @@ -65,15 +65,15 @@ private constructor(private val value: Double, private val temperatureUnit: Temp override fun toString(): String = "$value ${temperatureUnit.title}" - companion object { + public companion object { /** Creates [TemperatureDelta] with the specified value in Celsius degrees. */ @JvmStatic - fun celsius(value: Double): TemperatureDelta = + public fun celsius(value: Double): TemperatureDelta = TemperatureDelta(value, TemperatureUnit.CELSIUS) /** Creates [TemperatureDelta] with the specified value in Fahrenheit degrees. */ @JvmStatic - fun fahrenheit(value: Double): TemperatureDelta = + public fun fahrenheit(value: Double): TemperatureDelta = TemperatureDelta(value, TemperatureUnit.FAHRENHEIT) } diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/units/Velocity.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/units/Velocity.kt index 0de56b1c711b5..c2cfd0c3eddcd 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/units/Velocity.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/units/Velocity.kt @@ -22,22 +22,22 @@ package androidx.health.connect.client.units * - kilometersPerHour - see [Velocity.kilometersPerHour], [Double.kilometersPerHour] * - milesPerHour - see [Velocity.milesPerHour], [Double.milesPerHour] */ -class Velocity private constructor(private val value: Double, private val type: Type) : +public class Velocity private constructor(private val value: Double, private val type: Type) : Comparable { /** Returns the velocity in meters per second. */ @get:JvmName("getMetersPerSecond") - val inMetersPerSecond: Double + public val inMetersPerSecond: Double get() = value * type.metersPerSecondPerUnit /** Returns the velocity in kilometers per hour. */ @get:JvmName("getKilometersPerHour") - val inKilometersPerHour: Double + public val inKilometersPerHour: Double get() = get(type = Type.KILOMETERS_PER_HOUR) /** Returns the velocity in miles per hour. */ @get:JvmName("getMilesPerHour") - val inMilesPerHour: Double + public val inMilesPerHour: Double get() = get(type = Type.MILES_PER_HOUR) private fun get(type: Type): Double = @@ -68,19 +68,22 @@ class Velocity private constructor(private val value: Double, private val type: override fun toString(): String = "$value ${type.title}" - companion object { + public companion object { private val ZEROS = Type.values().associateWith { Velocity(value = 0.0, type = it) } /** Creates [Velocity] with the specified value in meters per second. */ @JvmStatic - fun metersPerSecond(value: Double): Velocity = Velocity(value, Type.METERS_PER_SECOND) + public fun metersPerSecond(value: Double): Velocity = + Velocity(value, Type.METERS_PER_SECOND) /** Creates [Velocity] with the specified value in kilometers per hour. */ @JvmStatic - fun kilometersPerHour(value: Double): Velocity = Velocity(value, Type.KILOMETERS_PER_HOUR) + public fun kilometersPerHour(value: Double): Velocity = + Velocity(value, Type.KILOMETERS_PER_HOUR) /** Creates [Velocity] with the specified value in miles per hour. */ - @JvmStatic fun milesPerHour(value: Double): Velocity = Velocity(value, Type.MILES_PER_HOUR) + @JvmStatic + public fun milesPerHour(value: Double): Velocity = Velocity(value, Type.MILES_PER_HOUR) } private enum class Type { @@ -104,60 +107,60 @@ class Velocity private constructor(private val value: Double, private val type: /** Creates [Velocity] with the specified value in meters per second. */ @get:JvmSynthetic -val Double.metersPerSecond: Velocity +public val Double.metersPerSecond: Velocity get() = Velocity.metersPerSecond(value = this) /** Creates [Velocity] with the specified value in meters per second. */ @get:JvmSynthetic -val Long.metersPerSecond: Velocity +public val Long.metersPerSecond: Velocity get() = toDouble().metersPerSecond /** Creates [Velocity] with the specified value in meters per second. */ @get:JvmSynthetic -val Float.metersPerSecond: Velocity +public val Float.metersPerSecond: Velocity get() = toDouble().metersPerSecond /** Creates [Velocity] with the specified value in meters per second. */ @get:JvmSynthetic -val Int.metersPerSecond: Velocity +public val Int.metersPerSecond: Velocity get() = toDouble().metersPerSecond /** Creates [Velocity] with the specified value in kilometers per hour. */ @get:JvmSynthetic -val Double.kilometersPerHour: Velocity +public val Double.kilometersPerHour: Velocity get() = Velocity.kilometersPerHour(value = this) /** Creates [Velocity] with the specified value in kilometers per hour. */ @get:JvmSynthetic -val Long.kilometersPerHour: Velocity +public val Long.kilometersPerHour: Velocity get() = toDouble().kilometersPerHour /** Creates [Velocity] with the specified value in kilometers per hour. */ @get:JvmSynthetic -val Float.kilometersPerHour: Velocity +public val Float.kilometersPerHour: Velocity get() = toDouble().kilometersPerHour /** Creates [Velocity] with the specified value in kilometers per hour. */ @get:JvmSynthetic -val Int.kilometersPerHour: Velocity +public val Int.kilometersPerHour: Velocity get() = toDouble().kilometersPerHour /** Creates [Velocity] with the specified value in miles per hour. */ @get:JvmSynthetic -val Double.milesPerHour: Velocity +public val Double.milesPerHour: Velocity get() = Velocity.milesPerHour(value = this) /** Creates [Velocity] with the specified value in miles per hour. */ @get:JvmSynthetic -val Long.milesPerHour: Velocity +public val Long.milesPerHour: Velocity get() = toDouble().milesPerHour /** Creates [Velocity] with the specified value in miles per hour. */ @get:JvmSynthetic -val Float.milesPerHour: Velocity +public val Float.milesPerHour: Velocity get() = toDouble().milesPerHour /** Creates [Velocity] with the specified value in miles per hour. */ @get:JvmSynthetic -val Int.milesPerHour: Velocity +public val Int.milesPerHour: Velocity get() = toDouble().milesPerHour diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/units/Volume.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/units/Volume.kt index 508d70f03d556..d27bff6ceeef7 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/units/Volume.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/units/Volume.kt @@ -22,22 +22,22 @@ package androidx.health.connect.client.units * - milliliters - see [Volume.milliliters], [Double.milliliters] * - US fluid ounces - see [Volume.fluidOuncesUs], [Double.fluidOuncesUs] */ -class Volume private constructor(private val value: Double, private val type: Type) : +public class Volume private constructor(private val value: Double, private val type: Type) : Comparable { /** Returns the volume in liters. */ @get:JvmName("getLiters") - val inLiters: Double + public val inLiters: Double get() = value * type.litersPerUnit /** Returns the volume in milliliters. */ @get:JvmName("getMilliliters") - val inMilliliters: Double + public val inMilliliters: Double get() = get(type = Type.MILLILITERS) /** Returns the volume in US fluid ounces. */ @get:JvmName("getFluidOuncesUs") - val inFluidOuncesUs: Double + public val inFluidOuncesUs: Double get() = get(type = Type.FLUID_OUNCES_US) private fun get(type: Type): Double = @@ -68,17 +68,18 @@ class Volume private constructor(private val value: Double, private val type: Ty override fun toString(): String = "$value ${type.title}" - companion object { + public companion object { private val ZEROS = Type.values().associateWith { Volume(value = 0.0, type = it) } /** Creates [Volume] with the specified value in liters. */ - @JvmStatic fun liters(value: Double): Volume = Volume(value, Type.LITERS) + @JvmStatic public fun liters(value: Double): Volume = Volume(value, Type.LITERS) /** Creates [Volume] with the specified value in milliliters. */ - @JvmStatic fun milliliters(value: Double): Volume = Volume(value, Type.MILLILITERS) + @JvmStatic public fun milliliters(value: Double): Volume = Volume(value, Type.MILLILITERS) /** Creates [Volume] with the specified value in US fluid ounces. */ - @JvmStatic fun fluidOuncesUs(value: Double): Volume = Volume(value, Type.FLUID_OUNCES_US) + @JvmStatic + public fun fluidOuncesUs(value: Double): Volume = Volume(value, Type.FLUID_OUNCES_US) } private enum class Type { @@ -102,60 +103,60 @@ class Volume private constructor(private val value: Double, private val type: Ty /** Creates [Volume] with the specified value in liters. */ @get:JvmSynthetic -val Double.liters: Volume +public val Double.liters: Volume get() = Volume.liters(value = this) /** Creates [Volume] with the specified value in liters. */ @get:JvmSynthetic -val Long.liters: Volume +public val Long.liters: Volume get() = toDouble().liters /** Creates [Volume] with the specified value in liters. */ @get:JvmSynthetic -val Float.liters: Volume +public val Float.liters: Volume get() = toDouble().liters /** Creates [Volume] with the specified value in liters. */ @get:JvmSynthetic -val Int.liters: Volume +public val Int.liters: Volume get() = toDouble().liters /** Creates [Volume] with the specified value in milliliters. */ @get:JvmSynthetic -val Double.milliliters: Volume +public val Double.milliliters: Volume get() = Volume.milliliters(value = this) /** Creates [Volume] with the specified value in milliliters. */ @get:JvmSynthetic -val Long.milliliters: Volume +public val Long.milliliters: Volume get() = toDouble().milliliters /** Creates [Volume] with the specified value in milliliters. */ @get:JvmSynthetic -val Float.milliliters: Volume +public val Float.milliliters: Volume get() = toDouble().milliliters /** Creates [Volume] with the specified value in milliliters. */ @get:JvmSynthetic -val Int.milliliters: Volume +public val Int.milliliters: Volume get() = toDouble().milliliters /** Creates [Volume] with the specified value in US fluid ounces. */ @get:JvmSynthetic -val Double.fluidOuncesUs: Volume +public val Double.fluidOuncesUs: Volume get() = Volume.fluidOuncesUs(value = this) /** Creates [Volume] with the specified value in US fluid ounces. */ @get:JvmSynthetic -val Long.fluidOuncesUs: Volume +public val Long.fluidOuncesUs: Volume get() = toDouble().fluidOuncesUs /** Creates [Volume] with the specified value in US fluid ounces. */ @get:JvmSynthetic -val Float.fluidOuncesUs: Volume +public val Float.fluidOuncesUs: Volume get() = toDouble().fluidOuncesUs /** Creates [Volume] with the specified value in US fluid ounces. */ @get:JvmSynthetic -val Int.fluidOuncesUs: Volume +public val Int.fluidOuncesUs: Volume get() = toDouble().fluidOuncesUs diff --git a/health/connect/connect-client/src/main/java/androidx/health/platform/client/changes/ChangesEvent.kt b/health/connect/connect-client/src/main/java/androidx/health/platform/client/changes/ChangesEvent.kt index c2387316cd89a..e0b4d84e782e3 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/platform/client/changes/ChangesEvent.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/platform/client/changes/ChangesEvent.kt @@ -23,11 +23,11 @@ import androidx.health.platform.client.proto.ChangeProto /** Returned via [OnChangesListenerProxy]. */ @RestrictTo(RestrictTo.Scope.LIBRARY) -class ChangesEvent(override val proto: ChangeProto.ChangesEvent) : +public class ChangesEvent(override val proto: ChangeProto.ChangesEvent) : ProtoParcelable() { - companion object { + public companion object { @JvmField - val CREATOR: Parcelable.Creator = newCreator { + public val CREATOR: Parcelable.Creator = newCreator { val proto = ChangeProto.ChangesEvent.parseFrom(it) ChangesEvent(proto) } diff --git a/health/connect/connect-client/src/main/java/androidx/health/platform/client/error/ErrorCode.kt b/health/connect/connect-client/src/main/java/androidx/health/platform/client/error/ErrorCode.kt index 111d549859114..8ce51c1a90d12 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/platform/client/error/ErrorCode.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/platform/client/error/ErrorCode.kt @@ -37,60 +37,60 @@ import androidx.annotation.RestrictTo ) @Retention(AnnotationRetention.SOURCE) @RestrictTo(RestrictTo.Scope.LIBRARY) -annotation class ErrorCode { - companion object { +public annotation class ErrorCode { + public companion object { /** Health Platform is not installed. */ - const val PROVIDER_NOT_INSTALLED = 1 + public const val PROVIDER_NOT_INSTALLED: Int = 1 /** Health Platform is installed, but disabled. */ - const val PROVIDER_NOT_ENABLED = 2 + public const val PROVIDER_NOT_ENABLED: Int = 2 /** * Health Platform needs to be updated (client requires newer version of a particular API * method). */ - const val PROVIDER_NEEDS_UPDATE = 3 + public const val PROVIDER_NEEDS_UPDATE: Int = 3 /** The calling application is trying to access data without required authorization. */ - const val NO_PERMISSION = 4 + public const val NO_PERMISSION: Int = 4 /** * Calling application is trying to modify data it doesn't own, i.e. the data was inserted * by another app into Health Platform. */ - const val INVALID_OWNERSHIP = 10000 + public const val INVALID_OWNERSHIP: Int = 10000 /** Calling application is not allowed to access Health Platform. */ - const val NOT_ALLOWED = 10001 + public const val NOT_ALLOWED: Int = 10001 /** Requested permission list can't be empty. */ - const val EMPTY_PERMISSION_LIST = 10002 + public const val EMPTY_PERMISSION_LIST: Int = 10002 /** Calling application is trying to request a permission it has not declared. */ - const val PERMISSION_NOT_DECLARED = 10003 + public const val PERMISSION_NOT_DECLARED: Int = 10003 /** * Calling application is trying to request permissions without having a valid rationale * Activity declared to explain the use of permissions. */ - const val INVALID_PERMISSION_RATIONALE_DECLARATION = 10004 + public const val INVALID_PERMISSION_RATIONALE_DECLARATION: Int = 10004 /** Requested data UID is invalid and could not be found. */ - const val INVALID_UID = 10005 + public const val INVALID_UID: Int = 10005 /** Internal database error in Health Platform. */ - const val DATABASE_ERROR = 10006 + public const val DATABASE_ERROR: Int = 10006 /** Some Internal error which will not get resolved even when client retry. */ - const val INTERNAL_ERROR = 10007 + public const val INTERNAL_ERROR: Int = 10007 /** * Calling application is using a changes token that indicates some changes were cleaned * after its last sync and before this call. */ - const val CHANGES_TOKEN_OUTDATED = 10008 + public const val CHANGES_TOKEN_OUTDATED: Int = 10008 /** Remote end failed to deliver response, likely due to parcel too large. */ - const val TRANSACTION_TOO_LARGE = 10010 + public const val TRANSACTION_TOO_LARGE: Int = 10010 } } diff --git a/health/connect/connect-client/src/main/java/androidx/health/platform/client/error/ErrorStatus.kt b/health/connect/connect-client/src/main/java/androidx/health/platform/client/error/ErrorStatus.kt index 0e66316afabb4..9a1c05b62a2d1 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/platform/client/error/ErrorStatus.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/platform/client/error/ErrorStatus.kt @@ -23,7 +23,8 @@ import java.lang.reflect.Field /** Data object holding error state for IPC method calls. */ @RestrictTo(RestrictTo.Scope.LIBRARY) -class ErrorStatus constructor(@ErrorCode val errorCode: Int, val errorMessage: String? = null) : +public class ErrorStatus +constructor(@ErrorCode public val errorCode: Int, public val errorMessage: String? = null) : ProtoParcelable() { override val proto: ErrorProto.ErrorStatus by lazy { @@ -32,15 +33,15 @@ class ErrorStatus constructor(@ErrorCode val errorCode: Int, val errorMessage: S builder.build() } - companion object { + public companion object { @JvmStatic @JvmOverloads - fun create(errorCode: Int, errorMessage: String? = null): ErrorStatus { + public fun create(errorCode: Int, errorMessage: String? = null): ErrorStatus { return ErrorStatus(safeErrorCode(errorCode), errorMessage) } @ErrorCode - fun safeErrorCode(errorCode: Int): Int { + public fun safeErrorCode(errorCode: Int): Int { return ErrorCode::class .java .declaredFields @@ -56,7 +57,7 @@ class ErrorStatus constructor(@ErrorCode val errorCode: Int, val errorMessage: S } @JvmField - val CREATOR: Parcelable.Creator = newCreator { + public val CREATOR: Parcelable.Creator = newCreator { val proto = ErrorProto.ErrorStatus.parseFrom(it) create(proto.code, if (proto.hasMessage()) proto.message else null) } diff --git a/health/connect/connect-client/src/main/java/androidx/health/platform/client/exerciseroute/ExerciseRoute.kt b/health/connect/connect-client/src/main/java/androidx/health/platform/client/exerciseroute/ExerciseRoute.kt index 3b107b078d8b3..a97f352f23db0 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/platform/client/exerciseroute/ExerciseRoute.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/platform/client/exerciseroute/ExerciseRoute.kt @@ -23,16 +23,16 @@ import androidx.health.platform.client.proto.DataProto /** Internal parcelable wrapper over proto object. */ @RestrictTo(RestrictTo.Scope.LIBRARY) -class ExerciseRoute(override val proto: DataProto.DataPoint.SubTypeDataList) : +public class ExerciseRoute(override val proto: DataProto.DataPoint.SubTypeDataList) : ProtoParcelable() { // ExerciseRoute is passed as an Intent extra, where shared memory isn't supported. See // b/442348082 - override fun shouldStoreInPlace() = true + override fun shouldStoreInPlace(): Boolean = true - companion object { + public companion object { @JvmField - val CREATOR: Parcelable.Creator = newCreator { + public val CREATOR: Parcelable.Creator = newCreator { val proto = DataProto.DataPoint.SubTypeDataList.parseFrom(it) ExerciseRoute(proto) } diff --git a/health/connect/connect-client/src/main/java/androidx/health/platform/client/impl/ServiceBackedHealthDataClient.kt b/health/connect/connect-client/src/main/java/androidx/health/platform/client/impl/ServiceBackedHealthDataClient.kt index f3abd69c8e940..d4bae2b59c5a1 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/platform/client/impl/ServiceBackedHealthDataClient.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/platform/client/impl/ServiceBackedHealthDataClient.kt @@ -48,7 +48,7 @@ import kotlin.math.min /** An IPC backed HealthDataClient implementation. */ @RestrictTo(RestrictTo.Scope.LIBRARY) -class ServiceBackedHealthDataClient( +public class ServiceBackedHealthDataClient( private val context: Context, clientConfiguration: ClientConfiguration, connectionManager: ConnectionManager, @@ -72,7 +72,7 @@ class ServiceBackedHealthDataClient( ) } - constructor( + public constructor( context: Context, clientConfiguration: ClientConfiguration, ) : this(context, clientConfiguration, ProviderConnectionManager.getInstance(context)) diff --git a/health/connect/connect-client/src/main/java/androidx/health/platform/client/impl/data/ProtoData.kt b/health/connect/connect-client/src/main/java/androidx/health/platform/client/impl/data/ProtoData.kt index 62a1c5732c157..fedee9f3b7bc4 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/platform/client/impl/data/ProtoData.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/platform/client/impl/data/ProtoData.kt @@ -20,9 +20,9 @@ import androidx.health.platform.client.proto.MessageLite /** Base class for data objects backed by protos. */ @RestrictTo(RestrictTo.Scope.LIBRARY) -abstract class ProtoData { +public abstract class ProtoData { /** Proto representation of this object. */ - abstract val proto: T + public abstract val proto: T override fun equals(other: Any?): Boolean { if (this === other) { diff --git a/health/connect/connect-client/src/main/java/androidx/health/platform/client/impl/data/ProtoParcelable.kt b/health/connect/connect-client/src/main/java/androidx/health/platform/client/impl/data/ProtoParcelable.kt index 3fabe30ffa4e4..04a969538d1ec 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/platform/client/impl/data/ProtoParcelable.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/platform/client/impl/data/ProtoParcelable.kt @@ -31,7 +31,7 @@ import androidx.health.platform.client.proto.MessageLite */ @Suppress("ParcelCreator", "ParcelNotFinal") @RestrictTo(RestrictTo.Scope.LIBRARY) -abstract class ProtoParcelable : ProtoData(), Parcelable { +public abstract class ProtoParcelable : ProtoData(), Parcelable { /** Serialized representation of this object. */ private val bytes: ByteArray by lazy { proto.toByteArray() } @@ -61,7 +61,7 @@ abstract class ProtoParcelable : ProtoData(), Parcelable { return bytes.size <= MAX_IN_PLACE_SIZE } - companion object { + public companion object { /** * Constructs and returns a [Creator] based on the provided [parser] accepting a [ByteArray] * . diff --git a/health/connect/connect-client/src/main/java/androidx/health/platform/client/permission/Permission.kt b/health/connect/connect-client/src/main/java/androidx/health/platform/client/permission/Permission.kt index abfb5b95a88b4..e0c58f8cd9f96 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/platform/client/permission/Permission.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/platform/client/permission/Permission.kt @@ -22,12 +22,12 @@ import androidx.health.platform.client.proto.PermissionProto /** Internal parcelable wrapper over proto object. */ @RestrictTo(RestrictTo.Scope.LIBRARY) -class Permission(override val proto: PermissionProto.Permission) : +public class Permission(override val proto: PermissionProto.Permission) : ProtoParcelable() { - companion object { + public companion object { @JvmField - val CREATOR: Parcelable.Creator = newCreator { + public val CREATOR: Parcelable.Creator = newCreator { val proto = PermissionProto.Permission.parseFrom(it) Permission(proto) } diff --git a/health/connect/connect-client/src/main/java/androidx/health/platform/client/request/AggregateDataRequest.kt b/health/connect/connect-client/src/main/java/androidx/health/platform/client/request/AggregateDataRequest.kt index eac6b2dd22541..34d3e96750d36 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/platform/client/request/AggregateDataRequest.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/platform/client/request/AggregateDataRequest.kt @@ -23,12 +23,12 @@ import androidx.health.platform.client.proto.RequestProto /** Internal wrapper to help transfer protos over ipc. */ @RestrictTo(RestrictTo.Scope.LIBRARY) -class AggregateDataRequest(override val proto: RequestProto.AggregateDataRequest) : +public class AggregateDataRequest(override val proto: RequestProto.AggregateDataRequest) : ProtoParcelable() { - companion object { + public companion object { @JvmField - val CREATOR: Parcelable.Creator = newCreator { + public val CREATOR: Parcelable.Creator = newCreator { val proto = RequestProto.AggregateDataRequest.parseFrom(it) AggregateDataRequest(proto) } diff --git a/health/connect/connect-client/src/main/java/androidx/health/platform/client/request/DeleteDataRangeRequest.kt b/health/connect/connect-client/src/main/java/androidx/health/platform/client/request/DeleteDataRangeRequest.kt index 5e5487a963ffd..5031c99b3e619 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/platform/client/request/DeleteDataRangeRequest.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/platform/client/request/DeleteDataRangeRequest.kt @@ -22,14 +22,15 @@ import androidx.health.platform.client.proto.RequestProto /** Internal parcelable for IPC calls. */ @RestrictTo(RestrictTo.Scope.LIBRARY) -class DeleteDataRangeRequest(override val proto: RequestProto.DeleteDataRangeRequest) : +public class DeleteDataRangeRequest(override val proto: RequestProto.DeleteDataRangeRequest) : ProtoParcelable() { - companion object { + public companion object { @JvmField - val CREATOR: Parcelable.Creator = ProtoParcelable.newCreator { - val proto = RequestProto.DeleteDataRangeRequest.parseFrom(it) - DeleteDataRangeRequest(proto) - } + public val CREATOR: Parcelable.Creator = + ProtoParcelable.newCreator { + val proto = RequestProto.DeleteDataRangeRequest.parseFrom(it) + DeleteDataRangeRequest(proto) + } } } diff --git a/health/connect/connect-client/src/main/java/androidx/health/platform/client/request/DeleteDataRequest.kt b/health/connect/connect-client/src/main/java/androidx/health/platform/client/request/DeleteDataRequest.kt index ac1fddf9891b0..6e198077ca8cc 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/platform/client/request/DeleteDataRequest.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/platform/client/request/DeleteDataRequest.kt @@ -23,9 +23,9 @@ import androidx.health.platform.client.proto.RequestProto /** Internal parcelable for IPC calls. */ @RestrictTo(RestrictTo.Scope.LIBRARY) -class DeleteDataRequest( - val uids: List, - val clientIds: List, +public class DeleteDataRequest( + public val uids: List, + public val clientIds: List, ) : ProtoParcelable() { override val proto: RequestProto.DeleteDataRequest get() { @@ -36,9 +36,9 @@ class DeleteDataRequest( .build() } - companion object { + public companion object { @JvmField - val CREATOR: Parcelable.Creator = ProtoParcelable.newCreator { + public val CREATOR: Parcelable.Creator = ProtoParcelable.newCreator { val proto = RequestProto.DeleteDataRequest.parseFrom(it) fromProto(proto) } diff --git a/health/connect/connect-client/src/main/java/androidx/health/platform/client/request/GetChangesRequest.kt b/health/connect/connect-client/src/main/java/androidx/health/platform/client/request/GetChangesRequest.kt index c07e0440be426..41b315b7cee2c 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/platform/client/request/GetChangesRequest.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/platform/client/request/GetChangesRequest.kt @@ -21,12 +21,12 @@ import androidx.health.platform.client.impl.data.ProtoParcelable import androidx.health.platform.client.proto.RequestProto @RestrictTo(RestrictTo.Scope.LIBRARY) -class GetChangesRequest(override val proto: RequestProto.GetChangesRequest) : +public class GetChangesRequest(override val proto: RequestProto.GetChangesRequest) : ProtoParcelable() { - companion object { + public companion object { @JvmField - val CREATOR: Parcelable.Creator = ProtoParcelable.newCreator { + public val CREATOR: Parcelable.Creator = ProtoParcelable.newCreator { val proto = RequestProto.GetChangesRequest.parseFrom(it) GetChangesRequest(proto) } diff --git a/health/connect/connect-client/src/main/java/androidx/health/platform/client/request/GetChangesTokenRequest.kt b/health/connect/connect-client/src/main/java/androidx/health/platform/client/request/GetChangesTokenRequest.kt index f227d2da5e05e..4232d58e3605f 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/platform/client/request/GetChangesTokenRequest.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/platform/client/request/GetChangesTokenRequest.kt @@ -22,14 +22,15 @@ import androidx.health.platform.client.impl.data.ProtoParcelable import androidx.health.platform.client.proto.RequestProto @RestrictTo(RestrictTo.Scope.LIBRARY) -class GetChangesTokenRequest(override val proto: RequestProto.GetChangesTokenRequest) : +public class GetChangesTokenRequest(override val proto: RequestProto.GetChangesTokenRequest) : ProtoParcelable() { - companion object { + public companion object { @JvmField - val CREATOR: Parcelable.Creator = ProtoParcelable.newCreator { - val proto = RequestProto.GetChangesTokenRequest.parseFrom(it) - GetChangesTokenRequest(proto) - } + public val CREATOR: Parcelable.Creator = + ProtoParcelable.newCreator { + val proto = RequestProto.GetChangesTokenRequest.parseFrom(it) + GetChangesTokenRequest(proto) + } } } diff --git a/health/connect/connect-client/src/main/java/androidx/health/platform/client/request/ReadDataRangeRequest.kt b/health/connect/connect-client/src/main/java/androidx/health/platform/client/request/ReadDataRangeRequest.kt index 161ad326edba6..4502b059c67c0 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/platform/client/request/ReadDataRangeRequest.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/platform/client/request/ReadDataRangeRequest.kt @@ -22,12 +22,12 @@ import androidx.health.platform.client.impl.data.ProtoParcelable import androidx.health.platform.client.proto.RequestProto @RestrictTo(RestrictTo.Scope.LIBRARY) -class ReadDataRangeRequest(override val proto: RequestProto.ReadDataRangeRequest) : +public class ReadDataRangeRequest(override val proto: RequestProto.ReadDataRangeRequest) : ProtoParcelable() { - companion object { + public companion object { @JvmField - val CREATOR: Parcelable.Creator = ProtoParcelable.newCreator { + public val CREATOR: Parcelable.Creator = ProtoParcelable.newCreator { val proto = RequestProto.ReadDataRangeRequest.parseFrom(it) ReadDataRangeRequest(proto) } diff --git a/health/connect/connect-client/src/main/java/androidx/health/platform/client/request/ReadDataRequest.kt b/health/connect/connect-client/src/main/java/androidx/health/platform/client/request/ReadDataRequest.kt index dbfc6d712bb6a..3983a1b044463 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/platform/client/request/ReadDataRequest.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/platform/client/request/ReadDataRequest.kt @@ -23,12 +23,12 @@ import androidx.health.platform.client.proto.RequestProto /** Internal parcelable for IPC calls. */ @RestrictTo(RestrictTo.Scope.LIBRARY) -class ReadDataRequest(override val proto: RequestProto.ReadDataRequest) : +public class ReadDataRequest(override val proto: RequestProto.ReadDataRequest) : ProtoParcelable() { - companion object { + public companion object { @JvmField - val CREATOR: Parcelable.Creator = ProtoParcelable.newCreator { + public val CREATOR: Parcelable.Creator = ProtoParcelable.newCreator { val proto = RequestProto.ReadDataRequest.parseFrom(it) ReadDataRequest(proto) } diff --git a/health/connect/connect-client/src/main/java/androidx/health/platform/client/request/ReadExerciseRouteRequest.kt b/health/connect/connect-client/src/main/java/androidx/health/platform/client/request/ReadExerciseRouteRequest.kt index 721713b679de7..1d219fbd1e002 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/platform/client/request/ReadExerciseRouteRequest.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/platform/client/request/ReadExerciseRouteRequest.kt @@ -23,14 +23,15 @@ import androidx.health.platform.client.proto.RequestProto /** Internal parcelable for IPC calls. */ @RestrictTo(RestrictTo.Scope.LIBRARY) -class ReadExerciseRouteRequest(override val proto: RequestProto.ReadExerciseRouteRequest) : +public class ReadExerciseRouteRequest(override val proto: RequestProto.ReadExerciseRouteRequest) : ProtoParcelable() { - companion object { + public companion object { @JvmField - val CREATOR: Parcelable.Creator = ProtoParcelable.newCreator { - val proto = RequestProto.ReadExerciseRouteRequest.parseFrom(it) - ReadExerciseRouteRequest(proto) - } + public val CREATOR: Parcelable.Creator = + ProtoParcelable.newCreator { + val proto = RequestProto.ReadExerciseRouteRequest.parseFrom(it) + ReadExerciseRouteRequest(proto) + } } } diff --git a/health/connect/connect-client/src/main/java/androidx/health/platform/client/request/RegisterForDataNotificationsRequest.kt b/health/connect/connect-client/src/main/java/androidx/health/platform/client/request/RegisterForDataNotificationsRequest.kt index dcd174a4914a7..b9c50e929c03d 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/platform/client/request/RegisterForDataNotificationsRequest.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/platform/client/request/RegisterForDataNotificationsRequest.kt @@ -22,13 +22,13 @@ import androidx.health.platform.client.impl.data.ProtoParcelable import androidx.health.platform.client.proto.RequestProto @RestrictTo(RestrictTo.Scope.LIBRARY) -class RegisterForDataNotificationsRequest( +public class RegisterForDataNotificationsRequest( override val proto: RequestProto.RegisterForDataNotificationsRequest ) : ProtoParcelable() { - companion object { + public companion object { @JvmField - val CREATOR: Parcelable.Creator = newCreator { + public val CREATOR: Parcelable.Creator = newCreator { RegisterForDataNotificationsRequest( RequestProto.RegisterForDataNotificationsRequest.parseFrom(it) ) diff --git a/health/connect/connect-client/src/main/java/androidx/health/platform/client/request/RequestContext.kt b/health/connect/connect-client/src/main/java/androidx/health/platform/client/request/RequestContext.kt index e6146787af508..5d593de561f29 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/platform/client/request/RequestContext.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/platform/client/request/RequestContext.kt @@ -23,11 +23,11 @@ import androidx.health.platform.client.proto.RequestProto /** Data object holding context data for IPC calls. */ @RestrictTo(RestrictTo.Scope.LIBRARY) -class RequestContext( - val callingPackage: String, - val sdkVersion: Int, - val permissionToken: String?, - val isInForeground: Boolean, +public class RequestContext( + public val callingPackage: String, + public val sdkVersion: Int, + public val permissionToken: String?, + public val isInForeground: Boolean, ) : ProtoParcelable() { @Suppress("CheckResult") @@ -41,9 +41,9 @@ class RequestContext( .build() } - companion object { + public companion object { @JvmField - val CREATOR: Parcelable.Creator = newCreator { + public val CREATOR: Parcelable.Creator = newCreator { RequestProto.RequestContext.parseFrom(it).run { RequestContext(callingPackage, sdkVersion, permissionToken, isInForeground) } diff --git a/health/connect/connect-client/src/main/java/androidx/health/platform/client/request/UnregisterFromDataNotificationsRequest.kt b/health/connect/connect-client/src/main/java/androidx/health/platform/client/request/UnregisterFromDataNotificationsRequest.kt index 9f7fa1a3c9a75..141af40b90cdd 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/platform/client/request/UnregisterFromDataNotificationsRequest.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/platform/client/request/UnregisterFromDataNotificationsRequest.kt @@ -22,16 +22,17 @@ import androidx.health.platform.client.impl.data.ProtoParcelable import androidx.health.platform.client.proto.RequestProto @RestrictTo(RestrictTo.Scope.LIBRARY) -class UnregisterFromDataNotificationsRequest( +public class UnregisterFromDataNotificationsRequest( override val proto: RequestProto.UnregisterFromDataNotificationsRequest ) : ProtoParcelable() { - companion object { + public companion object { @JvmField - val CREATOR: Parcelable.Creator = newCreator { - UnregisterFromDataNotificationsRequest( - RequestProto.UnregisterFromDataNotificationsRequest.parseFrom(it) - ) - } + public val CREATOR: Parcelable.Creator = + newCreator { + UnregisterFromDataNotificationsRequest( + RequestProto.UnregisterFromDataNotificationsRequest.parseFrom(it) + ) + } } } diff --git a/health/connect/connect-client/src/main/java/androidx/health/platform/client/request/UpsertDataRequest.kt b/health/connect/connect-client/src/main/java/androidx/health/platform/client/request/UpsertDataRequest.kt index b0fad4d0bab4a..920d73d12afa9 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/platform/client/request/UpsertDataRequest.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/platform/client/request/UpsertDataRequest.kt @@ -24,7 +24,7 @@ import androidx.health.platform.client.proto.RequestProto /** Internal parcelable for IPC calls. */ @RestrictTo(RestrictTo.Scope.LIBRARY) -class UpsertDataRequest(val dataPoints: List) : +public class UpsertDataRequest(public val dataPoints: List) : ProtoParcelable() { override val proto: RequestProto.UpsertDataRequest get() { @@ -34,9 +34,9 @@ class UpsertDataRequest(val dataPoints: List) : .build() } - companion object { + public companion object { @JvmField - val CREATOR: Parcelable.Creator = ProtoParcelable.newCreator { + public val CREATOR: Parcelable.Creator = ProtoParcelable.newCreator { val proto = RequestProto.UpsertDataRequest.parseFrom(it) fromProto(proto) } diff --git a/health/connect/connect-client/src/main/java/androidx/health/platform/client/request/UpsertExerciseRouteRequest.kt b/health/connect/connect-client/src/main/java/androidx/health/platform/client/request/UpsertExerciseRouteRequest.kt index 3870e12775ada..8bcf7b48e8728 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/platform/client/request/UpsertExerciseRouteRequest.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/platform/client/request/UpsertExerciseRouteRequest.kt @@ -24,8 +24,10 @@ import androidx.health.platform.client.proto.RequestProto /** Internal parcelable for IPC calls. */ @RestrictTo(RestrictTo.Scope.LIBRARY) -class UpsertExerciseRouteRequest(val sessionUid: String, val route: DataProto.DataPoint) : - ProtoParcelable() { +public class UpsertExerciseRouteRequest( + public val sessionUid: String, + public val route: DataProto.DataPoint, +) : ProtoParcelable() { override val proto: RequestProto.UpsertExerciseRouteRequest get() { val obj = this @@ -35,12 +37,13 @@ class UpsertExerciseRouteRequest(val sessionUid: String, val route: DataProto.Da .build() } - companion object { + public companion object { @JvmField - val CREATOR: Parcelable.Creator = ProtoParcelable.newCreator { - val proto = RequestProto.UpsertExerciseRouteRequest.parseFrom(it) - fromProto(proto) - } + public val CREATOR: Parcelable.Creator = + ProtoParcelable.newCreator { + val proto = RequestProto.UpsertExerciseRouteRequest.parseFrom(it) + fromProto(proto) + } internal fun fromProto( proto: RequestProto.UpsertExerciseRouteRequest diff --git a/health/connect/connect-client/src/main/java/androidx/health/platform/client/response/AggregateDataResponse.kt b/health/connect/connect-client/src/main/java/androidx/health/platform/client/response/AggregateDataResponse.kt index e804ffc0137c0..c467d97e3e6c6 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/platform/client/response/AggregateDataResponse.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/platform/client/response/AggregateDataResponse.kt @@ -23,12 +23,12 @@ import androidx.health.platform.client.proto.ResponseProto /** Internal wrapper to help transfer protos over ipc. */ @RestrictTo(RestrictTo.Scope.LIBRARY) -class AggregateDataResponse(override val proto: ResponseProto.AggregateDataResponse) : +public class AggregateDataResponse(override val proto: ResponseProto.AggregateDataResponse) : ProtoParcelable() { - companion object { + public companion object { @JvmField - val CREATOR: Parcelable.Creator = newCreator { + public val CREATOR: Parcelable.Creator = newCreator { val proto = ResponseProto.AggregateDataResponse.parseFrom(it) AggregateDataResponse(proto) } diff --git a/health/connect/connect-client/src/main/java/androidx/health/platform/client/response/GetChangesResponse.kt b/health/connect/connect-client/src/main/java/androidx/health/platform/client/response/GetChangesResponse.kt index 87e412b54be7d..81032aebe4fd9 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/platform/client/response/GetChangesResponse.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/platform/client/response/GetChangesResponse.kt @@ -22,12 +22,12 @@ import androidx.health.platform.client.impl.data.ProtoParcelable import androidx.health.platform.client.proto.ResponseProto @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) -class GetChangesResponse(override val proto: ResponseProto.GetChangesResponse) : +public class GetChangesResponse(override val proto: ResponseProto.GetChangesResponse) : ProtoParcelable() { - companion object { + public companion object { @JvmField - val CREATOR: Parcelable.Creator = newCreator { + public val CREATOR: Parcelable.Creator = newCreator { val proto = ResponseProto.GetChangesResponse.parseFrom(it) GetChangesResponse(proto) } diff --git a/health/connect/connect-client/src/main/java/androidx/health/platform/client/response/GetChangesTokenResponse.kt b/health/connect/connect-client/src/main/java/androidx/health/platform/client/response/GetChangesTokenResponse.kt index fe462bed0cf7a..1a7bbddb5ba9e 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/platform/client/response/GetChangesTokenResponse.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/platform/client/response/GetChangesTokenResponse.kt @@ -22,12 +22,12 @@ import androidx.health.platform.client.impl.data.ProtoParcelable import androidx.health.platform.client.proto.ResponseProto @RestrictTo(RestrictTo.Scope.LIBRARY) -class GetChangesTokenResponse(override val proto: ResponseProto.GetChangesTokenResponse) : +public class GetChangesTokenResponse(override val proto: ResponseProto.GetChangesTokenResponse) : ProtoParcelable() { - companion object { + public companion object { @JvmField - val CREATOR: Parcelable.Creator = newCreator { + public val CREATOR: Parcelable.Creator = newCreator { val proto = ResponseProto.GetChangesTokenResponse.parseFrom(it) GetChangesTokenResponse(proto) } diff --git a/health/connect/connect-client/src/main/java/androidx/health/platform/client/response/InsertDataResponse.kt b/health/connect/connect-client/src/main/java/androidx/health/platform/client/response/InsertDataResponse.kt index 2833b728017d8..904c690dcf936 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/platform/client/response/InsertDataResponse.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/platform/client/response/InsertDataResponse.kt @@ -22,7 +22,7 @@ import androidx.health.platform.client.impl.data.ProtoParcelable import androidx.health.platform.client.proto.ResponseProto @RestrictTo(RestrictTo.Scope.LIBRARY) -class InsertDataResponse(val dataPointUids: List) : +public class InsertDataResponse(public val dataPointUids: List) : ProtoParcelable() { override val proto: ResponseProto.InsertDataResponse get() { @@ -32,9 +32,9 @@ class InsertDataResponse(val dataPointUids: List) : .build() } - companion object { + public companion object { @JvmField - val CREATOR: Parcelable.Creator = ProtoParcelable.newCreator { + public val CREATOR: Parcelable.Creator = ProtoParcelable.newCreator { val proto = ResponseProto.InsertDataResponse.parseFrom(it) fromProto(proto) } diff --git a/health/connect/connect-client/src/main/java/androidx/health/platform/client/response/ReadDataRangeResponse.kt b/health/connect/connect-client/src/main/java/androidx/health/platform/client/response/ReadDataRangeResponse.kt index 386568ee86d36..264e172eccb42 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/platform/client/response/ReadDataRangeResponse.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/platform/client/response/ReadDataRangeResponse.kt @@ -22,12 +22,12 @@ import androidx.health.platform.client.impl.data.ProtoParcelable import androidx.health.platform.client.proto.ResponseProto @RestrictTo(RestrictTo.Scope.LIBRARY) -class ReadDataRangeResponse(override val proto: ResponseProto.ReadDataRangeResponse) : +public class ReadDataRangeResponse(override val proto: ResponseProto.ReadDataRangeResponse) : ProtoParcelable() { - companion object { + public companion object { @JvmField - val CREATOR: Parcelable.Creator = ProtoParcelable.newCreator { + public val CREATOR: Parcelable.Creator = ProtoParcelable.newCreator { val proto = ResponseProto.ReadDataRangeResponse.parseFrom(it) ReadDataRangeResponse(proto) } diff --git a/health/connect/connect-client/src/main/java/androidx/health/platform/client/response/ReadDataResponse.kt b/health/connect/connect-client/src/main/java/androidx/health/platform/client/response/ReadDataResponse.kt index de966e3e8710d..3454eaadc2192 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/platform/client/response/ReadDataResponse.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/platform/client/response/ReadDataResponse.kt @@ -21,12 +21,12 @@ import androidx.health.platform.client.impl.data.ProtoParcelable import androidx.health.platform.client.proto.ResponseProto @RestrictTo(RestrictTo.Scope.LIBRARY) -class ReadDataResponse(override val proto: ResponseProto.ReadDataResponse) : +public class ReadDataResponse(override val proto: ResponseProto.ReadDataResponse) : ProtoParcelable() { - companion object { + public companion object { @JvmField - val CREATOR: Parcelable.Creator = ProtoParcelable.newCreator { + public val CREATOR: Parcelable.Creator = ProtoParcelable.newCreator { val proto = ResponseProto.ReadDataResponse.parseFrom(it) ReadDataResponse(proto) } diff --git a/health/connect/connect-client/src/main/java/androidx/health/platform/client/response/ReadExerciseRouteResponse.kt b/health/connect/connect-client/src/main/java/androidx/health/platform/client/response/ReadExerciseRouteResponse.kt index f35b9fdf11543..0d6d795bd1bdf 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/platform/client/response/ReadExerciseRouteResponse.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/platform/client/response/ReadExerciseRouteResponse.kt @@ -21,14 +21,16 @@ import androidx.health.platform.client.impl.data.ProtoParcelable import androidx.health.platform.client.proto.ResponseProto @RestrictTo(RestrictTo.Scope.LIBRARY) -class ReadExerciseRouteResponse(override val proto: ResponseProto.ReadExerciseRouteResponse) : - ProtoParcelable() { +public class ReadExerciseRouteResponse( + override val proto: ResponseProto.ReadExerciseRouteResponse +) : ProtoParcelable() { - companion object { + public companion object { @JvmField - val CREATOR: Parcelable.Creator = ProtoParcelable.newCreator { - val proto = ResponseProto.ReadExerciseRouteResponse.parseFrom(it) - ReadExerciseRouteResponse(proto) - } + public val CREATOR: Parcelable.Creator = + ProtoParcelable.newCreator { + val proto = ResponseProto.ReadExerciseRouteResponse.parseFrom(it) + ReadExerciseRouteResponse(proto) + } } } diff --git a/health/connect/connect-client/src/main/java/androidx/health/platform/client/utils/IntentExt.kt b/health/connect/connect-client/src/main/java/androidx/health/platform/client/utils/IntentExt.kt index 51719eafa891e..a12ce0960df0b 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/platform/client/utils/IntentExt.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/platform/client/utils/IntentExt.kt @@ -23,10 +23,12 @@ import android.os.Bundle import androidx.annotation.RestrictTo import androidx.health.platform.client.proto.AbstractMessageLite -fun Intent.putProtoMessages(name: String, messages: Collection>): Intent = - putByteArraysExtra(name = name, byteArrays = messages.map { it.toByteArray() }) +public fun Intent.putProtoMessages( + name: String, + messages: Collection>, +): Intent = putByteArraysExtra(name = name, byteArrays = messages.map { it.toByteArray() }) -fun Intent.putByteArraysExtra(name: String, byteArrays: Collection): Intent = +public fun Intent.putByteArraysExtra(name: String, byteArrays: Collection): Intent = putExtra( name, Bundle(byteArrays.size).apply { @@ -34,12 +36,12 @@ fun Intent.putByteArraysExtra(name: String, byteArrays: Collection): }, ) -fun > Intent.getProtoMessages( +public fun > Intent.getProtoMessages( name: String, parser: (ByteArray) -> T, ): List? = getByteArraysExtra(name = name)?.map(parser) -fun Intent.getByteArraysExtra(name: String): List? = +public fun Intent.getByteArraysExtra(name: String): List? = getBundleExtra(name)?.let { bundle -> List(bundle.size()) { index -> requireNotNull(bundle.getByteArray(index.toString())) } } diff --git a/health/connect/connect-client/src/main/java/androidx/health/platform/client/utils/SignatureVerification.kt b/health/connect/connect-client/src/main/java/androidx/health/platform/client/utils/SignatureVerification.kt index 1dcd3a2d24e73..e34b7a4e20add 100644 --- a/health/connect/connect-client/src/main/java/androidx/health/platform/client/utils/SignatureVerification.kt +++ b/health/connect/connect-client/src/main/java/androidx/health/platform/client/utils/SignatureVerification.kt @@ -28,10 +28,10 @@ import androidx.health.platform.client.service.HealthDataServiceConstants.DEFAUL import androidx.health.platform.client.service.HealthDataServiceConstants.DEFAULT_PROVIDER_PACKAGE_NAME import androidx.health.platform.client.service.HealthDataServiceConstants.DEFAULT_PROVIDER_RELEASE_CERT_SHA256 -@VisibleForTesting @JvmField var sBypassSignatureCheckForTesting = false +@VisibleForTesting @JvmField public var sBypassSignatureCheckForTesting: Boolean = false /** Returns whether the target package's signature is valid. */ -fun isTargetSignatureValid(packageManager: PackageManager, packageName: String): Boolean { +public fun isTargetSignatureValid(packageManager: PackageManager, packageName: String): Boolean { if (sBypassSignatureCheckForTesting) { return true } diff --git a/health/health-services-client/build.gradle b/health/health-services-client/build.gradle index c5799a0e0ad52..01f1a8d3c3a7c 100644 --- a/health/health-services-client/build.gradle +++ b/health/health-services-client/build.gradle @@ -68,6 +68,5 @@ androidx { mavenVersion = LibraryVersions.HEALTH_SERVICES_CLIENT inceptionYear = "2021" description = "This library helps developers create performant health applications in a platform agnostic way" - legacyDisableKotlinStrictApiMode = true enableRobolectric() } diff --git a/health/health-services-client/src/main/java/androidx/health/services/client/ExerciseClientExtension.kt b/health/health-services-client/src/main/java/androidx/health/services/client/ExerciseClientExtension.kt index 9236bbf0dc083..b587812072d6a 100644 --- a/health/health-services-client/src/main/java/androidx/health/services/client/ExerciseClientExtension.kt +++ b/health/health-services-client/src/main/java/androidx/health/services/client/ExerciseClientExtension.kt @@ -116,7 +116,7 @@ public suspend fun ExerciseClient.startExercise(configuration: ExerciseConfig) { * the call */ @kotlin.jvm.Throws(HealthServicesException::class) -public suspend fun ExerciseClient.pauseExercise() = pauseExerciseAsync().awaitWithException() +public suspend fun ExerciseClient.pauseExercise(): Void = pauseExerciseAsync().awaitWithException() /** * Resumes the current exercise, if it is currently paused. @@ -130,7 +130,8 @@ public suspend fun ExerciseClient.pauseExercise() = pauseExerciseAsync().awaitWi * the call */ @kotlin.jvm.Throws(HealthServicesException::class) -public suspend fun ExerciseClient.resumeExercise() = resumeExerciseAsync().awaitWithException() +public suspend fun ExerciseClient.resumeExercise(): Void = + resumeExerciseAsync().awaitWithException() /** * Ends the current exercise, if it has been started. @@ -147,7 +148,7 @@ public suspend fun ExerciseClient.resumeExercise() = resumeExerciseAsync().await * process the call */ @kotlin.jvm.Throws(HealthServicesException::class) -public suspend fun ExerciseClient.endExercise() = endExerciseAsync().awaitWithException() +public suspend fun ExerciseClient.endExercise(): Void = endExerciseAsync().awaitWithException() /** * Flushes the sensors for the active exercise. This call should be used sparingly and will be @@ -156,7 +157,7 @@ public suspend fun ExerciseClient.endExercise() = endExerciseAsync().awaitWithEx * @throws HealthServicesException if the Health Service fails to process the request */ @kotlin.jvm.Throws(HealthServicesException::class) -public suspend fun ExerciseClient.flush() = flushAsync().awaitWithException() +public suspend fun ExerciseClient.flush(): Void = flushAsync().awaitWithException() /** * Ends the current lap, calls [ExerciseUpdateCallback.onLapSummaryReceived] with data spanning the @@ -171,7 +172,7 @@ public suspend fun ExerciseClient.flush() = flushAsync().awaitWithException() * to process the call */ @kotlin.jvm.Throws(HealthServicesException::class) -public suspend fun ExerciseClient.markLap() = markLapAsync().awaitWithException() +public suspend fun ExerciseClient.markLap(): Void = markLapAsync().awaitWithException() /** * Returns the current [ExerciseInfo]. @@ -185,7 +186,7 @@ public suspend fun ExerciseClient.markLap() = markLapAsync().awaitWithException( * @throws HealthServicesException if Health Service fails to process the call */ @kotlin.jvm.Throws(HealthServicesException::class) -public suspend fun ExerciseClient.getCurrentExerciseInfo() = +public suspend fun ExerciseClient.getCurrentExerciseInfo(): ExerciseInfo = getCurrentExerciseInfoAsync().awaitWithException() /** @@ -198,7 +199,7 @@ public suspend fun ExerciseClient.getCurrentExerciseInfo() = */ @Suppress("ExecutorRegistration") @kotlin.jvm.Throws(HealthServicesException::class) -public suspend fun ExerciseClient.clearUpdateCallback(callback: ExerciseUpdateCallback) = +public suspend fun ExerciseClient.clearUpdateCallback(callback: ExerciseUpdateCallback): Void = clearUpdateCallbackAsync(callback).awaitWithException() /** @@ -211,7 +212,7 @@ public suspend fun ExerciseClient.clearUpdateCallback(callback: ExerciseUpdateCa * @throws HealthServicesException if Health Service fails to process the call */ @kotlin.jvm.Throws(HealthServicesException::class) -public suspend fun ExerciseClient.addGoalToActiveExercise(exerciseGoal: ExerciseGoal<*>) = +public suspend fun ExerciseClient.addGoalToActiveExercise(exerciseGoal: ExerciseGoal<*>): Void = addGoalToActiveExerciseAsync(exerciseGoal).awaitWithException() /** @@ -225,8 +226,9 @@ public suspend fun ExerciseClient.addGoalToActiveExercise(exerciseGoal: Exercise * @throws HealthServicesException if Health Service fails to process the call */ @kotlin.jvm.Throws(HealthServicesException::class) -public suspend fun ExerciseClient.removeGoalFromActiveExercise(exerciseGoal: ExerciseGoal<*>) = - removeGoalFromActiveExerciseAsync(exerciseGoal).awaitWithException() +public suspend fun ExerciseClient.removeGoalFromActiveExercise( + exerciseGoal: ExerciseGoal<*> +): Void = removeGoalFromActiveExerciseAsync(exerciseGoal).awaitWithException() /** * Enables or disables auto pause/resume for the current exercise. @@ -235,8 +237,9 @@ public suspend fun ExerciseClient.removeGoalFromActiveExercise(exerciseGoal: Exe * @throws HealthServicesException if Health Service fails to process the call */ @kotlin.jvm.Throws(HealthServicesException::class) -public suspend fun ExerciseClient.overrideAutoPauseAndResumeForActiveExercise(enabled: Boolean) = - overrideAutoPauseAndResumeForActiveExerciseAsync(enabled).awaitWithException() +public suspend fun ExerciseClient.overrideAutoPauseAndResumeForActiveExercise( + enabled: Boolean +): Void = overrideAutoPauseAndResumeForActiveExerciseAsync(enabled).awaitWithException() /** * Sets the batching mode for the current exercise synchronously. @@ -249,7 +252,7 @@ public suspend fun ExerciseClient.overrideAutoPauseAndResumeForActiveExercise(en @kotlin.jvm.Throws(HealthServicesException::class) public suspend fun ExerciseClient.overrideBatchingModesForActiveExercise( batchingModes: Set -) = overrideBatchingModesForActiveExerciseAsync(batchingModes).awaitWithException() +): Void = overrideBatchingModesForActiveExerciseAsync(batchingModes).awaitWithException() /** * Returns the [ExerciseCapabilities] of this client for the device. @@ -263,7 +266,8 @@ public suspend fun ExerciseClient.overrideBatchingModesForActiveExercise( * @throws HealthServicesException if Health Service fails to process the call */ @kotlin.jvm.Throws(HealthServicesException::class) -public suspend fun ExerciseClient.getCapabilities() = getCapabilitiesAsync().awaitWithException() +public suspend fun ExerciseClient.getCapabilities(): ExerciseCapabilities = + getCapabilitiesAsync().awaitWithException() /** * Updates the configurable exercise type attributes for the current exercise. @@ -275,8 +279,9 @@ public suspend fun ExerciseClient.getCapabilities() = getCapabilitiesAsync().awa * @throws HealthServicesException if Health Service fails to process the call */ @kotlin.jvm.Throws(HealthServicesException::class) -public suspend fun ExerciseClient.updateExerciseTypeConfig(exerciseTypeConfig: ExerciseTypeConfig) = - updateExerciseTypeConfigAsync(exerciseTypeConfig).awaitWithException() +public suspend fun ExerciseClient.updateExerciseTypeConfig( + exerciseTypeConfig: ExerciseTypeConfig +): Void = updateExerciseTypeConfigAsync(exerciseTypeConfig).awaitWithException() /** * Adds a [DebouncedGoal] for an active exercise. @@ -297,7 +302,7 @@ public suspend fun ExerciseClient.updateExerciseTypeConfig(exerciseTypeConfig: E @kotlin.jvm.Throws(HealthServicesException::class) public suspend fun ExerciseClient.addDebouncedGoalToActiveExercise( debouncedGoal: DebouncedGoal<*> -) = addDebouncedGoalToActiveExerciseAsync(debouncedGoal).awaitWithException() +): Void = addDebouncedGoalToActiveExerciseAsync(debouncedGoal).awaitWithException() /** * Removes a debounced goal from an active exercise. @@ -308,4 +313,4 @@ public suspend fun ExerciseClient.addDebouncedGoalToActiveExercise( @kotlin.jvm.Throws(HealthServicesException::class) public suspend fun ExerciseClient.removeDebouncedGoalFromActiveExercise( debouncedGoal: DebouncedGoal<*> -) = removeDebouncedGoalFromActiveExerciseAsync(debouncedGoal).awaitWithException() +): Void = removeDebouncedGoalFromActiveExerciseAsync(debouncedGoal).awaitWithException() diff --git a/health/health-services-client/src/main/java/androidx/health/services/client/HealthServicesException.kt b/health/health-services-client/src/main/java/androidx/health/services/client/HealthServicesException.kt index fda2b61d7c00c..71c0cc1e2e42a 100644 --- a/health/health-services-client/src/main/java/androidx/health/services/client/HealthServicesException.kt +++ b/health/health-services-client/src/main/java/androidx/health/services/client/HealthServicesException.kt @@ -17,4 +17,4 @@ package androidx.health.services.client /** Exception class for all the Health Services errors. */ -class HealthServicesException(message: String) : Exception(message) +public class HealthServicesException(message: String) : Exception(message) diff --git a/health/health-services-client/src/main/java/androidx/health/services/client/ListenableFutureExtension.kt b/health/health-services-client/src/main/java/androidx/health/services/client/ListenableFutureExtension.kt index f0863a9b4d251..a140bed6ceb14 100644 --- a/health/health-services-client/src/main/java/androidx/health/services/client/ListenableFutureExtension.kt +++ b/health/health-services-client/src/main/java/androidx/health/services/client/ListenableFutureExtension.kt @@ -29,7 +29,7 @@ import kotlin.jvm.Throws * @throws HealthServicesException if remote operation fails */ @Throws(HealthServicesException::class) -suspend fun ListenableFuture.awaitWithException(): T { +public suspend fun ListenableFuture.awaitWithException(): T { val t: T = try { await() diff --git a/health/health-services-client/src/main/java/androidx/health/services/client/MeasureClientExtension.kt b/health/health-services-client/src/main/java/androidx/health/services/client/MeasureClientExtension.kt index 021d96ab1f66a..44a1f023c938e 100644 --- a/health/health-services-client/src/main/java/androidx/health/services/client/MeasureClientExtension.kt +++ b/health/health-services-client/src/main/java/androidx/health/services/client/MeasureClientExtension.kt @@ -30,7 +30,7 @@ import androidx.health.services.client.data.MeasureCapabilities public suspend fun MeasureClient.unregisterMeasureCallback( dataType: DeltaDataType<*, *>, callback: MeasureCallback, -) = unregisterMeasureCallbackAsync(dataType, callback).awaitWithException() +): Void = unregisterMeasureCallbackAsync(dataType, callback).awaitWithException() /** * Returns the [MeasureCapabilities] of this client for the device. @@ -43,4 +43,5 @@ public suspend fun MeasureClient.unregisterMeasureCallback( * @throws HealthServicesException if Health Service fails to process the call */ @kotlin.jvm.Throws(HealthServicesException::class) -public suspend fun MeasureClient.getCapabilities() = getCapabilitiesAsync().awaitWithException() +public suspend fun MeasureClient.getCapabilities(): MeasureCapabilities = + getCapabilitiesAsync().awaitWithException() diff --git a/health/health-services-client/src/main/java/androidx/health/services/client/PassiveMonitoringClientExtension.kt b/health/health-services-client/src/main/java/androidx/health/services/client/PassiveMonitoringClientExtension.kt index 6a7e16757296e..2fac0b5c35102 100644 --- a/health/health-services-client/src/main/java/androidx/health/services/client/PassiveMonitoringClientExtension.kt +++ b/health/health-services-client/src/main/java/androidx/health/services/client/PassiveMonitoringClientExtension.kt @@ -49,7 +49,7 @@ import androidx.health.services.client.data.PassiveMonitoringCapabilities public suspend fun PassiveMonitoringClient.setPassiveListenerService( service: Class, config: PassiveListenerConfig, -) = setPassiveListenerServiceAsync(service, config).awaitWithException() +): Void = setPassiveListenerServiceAsync(service, config).awaitWithException() /** * Unregisters the subscription made by [setPassiveListenerService]. @@ -60,7 +60,7 @@ public suspend fun PassiveMonitoringClient.setPassiveListenerService( * @throws HealthServicesException if Health Service fails to process the call */ @kotlin.jvm.Throws(HealthServicesException::class) -public suspend fun PassiveMonitoringClient.clearPassiveListenerService() = +public suspend fun PassiveMonitoringClient.clearPassiveListenerService(): Void = clearPassiveListenerServiceAsync().awaitWithException() /** @@ -72,7 +72,7 @@ public suspend fun PassiveMonitoringClient.clearPassiveListenerService() = * @throws HealthServicesException if Health Service fails to process the call */ @kotlin.jvm.Throws(HealthServicesException::class) -public suspend fun PassiveMonitoringClient.clearPassiveListenerCallback() = +public suspend fun PassiveMonitoringClient.clearPassiveListenerCallback(): Void = clearPassiveListenerCallbackAsync().awaitWithException() /** @@ -84,7 +84,7 @@ public suspend fun PassiveMonitoringClient.clearPassiveListenerCallback() = * @throws HealthServicesException if Health Service fails to process the call */ @kotlin.jvm.Throws(HealthServicesException::class) -public suspend fun PassiveMonitoringClient.flush() = flushAsync().awaitWithException() +public suspend fun PassiveMonitoringClient.flush(): Void = flushAsync().awaitWithException() /** * Returns the [PassiveMonitoringCapabilities] of this client for this device. @@ -97,5 +97,5 @@ public suspend fun PassiveMonitoringClient.flush() = flushAsync().awaitWithExcep * @throws HealthServicesException if Health Service fails to process the call */ @kotlin.jvm.Throws(HealthServicesException::class) -public suspend fun PassiveMonitoringClient.getCapabilities() = +public suspend fun PassiveMonitoringClient.getCapabilities(): PassiveMonitoringCapabilities = getCapabilitiesAsync().awaitWithException() diff --git a/health/health-services-client/src/main/java/androidx/health/services/client/data/CumulativeDataPoint.kt b/health/health-services-client/src/main/java/androidx/health/services/client/data/CumulativeDataPoint.kt index f993b41ae0fbf..d9693990f4834 100644 --- a/health/health-services-client/src/main/java/androidx/health/services/client/data/CumulativeDataPoint.kt +++ b/health/health-services-client/src/main/java/androidx/health/services/client/data/CumulativeDataPoint.kt @@ -24,15 +24,15 @@ import java.time.Instant * Unlike [IntervalDataPoint], this is guaranteed to increase over time (assuming the same [start] * value.) For example, an [IntervalDataPoint] for [DataType.STEPS] */ -class CumulativeDataPoint( +public class CumulativeDataPoint( /** The [DataType] this [DataPoint] represents. */ dataType: AggregateDataType>, /** The accumulated value between [start] and [end]. */ - val total: T, + public val total: T, /** The beginning of the time period this [DataPoint] represents. */ - val start: Instant, + public val start: Instant, /** The end of the time period this [DataPoint] represents. */ - val end: Instant, + public val end: Instant, ) : DataPoint(dataType) { internal val proto: DataProto.AggregateDataPoint = diff --git a/health/health-services-client/src/main/java/androidx/health/services/client/data/DataPointContainer.kt b/health/health-services-client/src/main/java/androidx/health/services/client/data/DataPointContainer.kt index 3e2c3d62e3389..18836ae871c7e 100644 --- a/health/health-services-client/src/main/java/androidx/health/services/client/data/DataPointContainer.kt +++ b/health/health-services-client/src/main/java/androidx/health/services/client/data/DataPointContainer.kt @@ -26,16 +26,18 @@ package androidx.health.services.client.data * } * ``` */ -class DataPointContainer(internal val dataPoints: Map, List>>) { +public class DataPointContainer(internal val dataPoints: Map, List>>) { /** Constructs a [DataPointContainer] using a list of [DataPoint]s. */ - constructor(dataPointList: List>) : this(dataPointList.groupBy { it.dataType }) + public constructor( + dataPointList: List> + ) : this(dataPointList.groupBy { it.dataType }) /** Set of [DataType]s contained within this [DataPointContainer]. */ - val dataTypes: Set> = dataPoints.keys + public val dataTypes: Set> = dataPoints.keys /** Returns all [SampleDataPoint]s contained in this update. */ - val sampleDataPoints: List> + public val sampleDataPoints: List> get() { return dataPoints .flatMap { it.value } @@ -44,7 +46,7 @@ class DataPointContainer(internal val dataPoints: Map, List> + public val intervalDataPoints: List> get() { return dataPoints .flatMap { it.value } @@ -53,7 +55,7 @@ class DataPointContainer(internal val dataPoints: Map, List> + public val cumulativeDataPoints: List> get() { return dataPoints .flatMap { it.value } @@ -62,7 +64,7 @@ class DataPointContainer(internal val dataPoints: Map, List> + public val statisticalDataPoints: List> get() { return dataPoints .flatMap { it.value } @@ -72,7 +74,7 @@ class DataPointContainer(internal val dataPoints: Map, List> getData(type: DeltaDataType): List { + public fun > getData(type: DeltaDataType): List { return dataPoints[type] as? List ?: emptyList() } @@ -81,7 +83,7 @@ class DataPointContainer(internal val dataPoints: Map, List> getData(type: AggregateDataType): D? { + public fun > getData(type: AggregateDataType): D? { return (dataPoints[type] as? List)?.lastOrNull() } } diff --git a/health/health-services-client/src/main/java/androidx/health/services/client/data/DataType.kt b/health/health-services-client/src/main/java/androidx/health/services/client/data/DataType.kt index 046081ced774a..ae99842bf191e 100644 --- a/health/health-services-client/src/main/java/androidx/health/services/client/data/DataType.kt +++ b/health/health-services-client/src/main/java/androidx/health/services/client/data/DataType.kt @@ -29,7 +29,7 @@ import androidx.health.services.client.proto.DataProto.DataType.TimeType.TIME_TY * [DataType] that represents a granular, non-aggregated point in time. This will map to * [IntervalDataPoint]s and [SampleDataPoint]s. */ -class DeltaDataType>( +public class DeltaDataType>( name: String, timeType: TimeType, valueClass: Class, @@ -39,7 +39,7 @@ class DeltaDataType>( * [DataType] that represents aggregated data. This will map to [CumulativeDataPoint]s and * [StatisticalDataPoint]s. */ -class AggregateDataType>( +public class AggregateDataType>( name: String, timeType: TimeType, valueClass: Class, @@ -61,15 +61,15 @@ class AggregateDataType>( * [DISTANCE] may come from GPS location if available, or steps if not available. */ @Suppress("ParcelCreator") -abstract class DataType>( +public abstract class DataType>( /** Returns the name of this [DataType], e.g. `"Steps"`. */ - val name: String, + public val name: String, /** Returns the [TimeType] of this [DataType]. */ internal val timeType: TimeType, /** Returns the underlying [Class] of this [DataType]. */ - val valueClass: Class, + public val valueClass: Class, /** * Returns `true` if this will be represented by [StatisticalDataPoint] or @@ -103,21 +103,21 @@ abstract class DataType>( else -> TIME_TYPE_UNKNOWN } - companion object { + public companion object { /** The [TimeType] is unknown or this library is too old to know about it. */ - @JvmField val UNKNOWN: TimeType = TimeType(0, "UNKNOWN") + @JvmField public val UNKNOWN: TimeType = TimeType(0, "UNKNOWN") /** * TimeType that indicates the DataType has a value that represents an interval of time * with a beginning and end. For example, number of steps taken over a span of time. */ - @JvmField val INTERVAL: TimeType = TimeType(1, "INTERVAL") + @JvmField public val INTERVAL: TimeType = TimeType(1, "INTERVAL") /** * TimeType that indicates the DataType has a value that represents a single point in * time. For example, heart rate reading at a specific time. */ - @JvmField val SAMPLE: TimeType = TimeType(2, "SAMPLE") + @JvmField public val SAMPLE: TimeType = TimeType(2, "SAMPLE") internal fun fromProto(proto: DataProto.DataType.TimeType): TimeType = when (proto) { @@ -209,7 +209,7 @@ abstract class DataType>( return result } - companion object { + public companion object { private const val TAG = "DataType" private inline fun createIntervalDataType( @@ -237,7 +237,7 @@ abstract class DataType>( * losses are not counted in this metric (so it will only be positive or 0). */ @JvmField - val ELEVATION_GAIN: DeltaDataType> = + public val ELEVATION_GAIN: DeltaDataType> = createIntervalDataType("Elevation Gain") /** @@ -246,7 +246,7 @@ abstract class DataType>( * or 0). */ @JvmField - val ELEVATION_GAIN_TOTAL: AggregateDataType> = + public val ELEVATION_GAIN_TOTAL: AggregateDataType> = createCumulativeDataType("Elevation Gain") /** @@ -254,7 +254,7 @@ abstract class DataType>( * gains are not counted in this metric (so it will only be positive or 0). */ @JvmField - val ELEVATION_LOSS: DeltaDataType> = + public val ELEVATION_LOSS: DeltaDataType> = createIntervalDataType("Elevation Loss") /** @@ -263,12 +263,12 @@ abstract class DataType>( * 0). */ @JvmField - val ELEVATION_LOSS_TOTAL: AggregateDataType> = + public val ELEVATION_LOSS_TOTAL: AggregateDataType> = createCumulativeDataType("Elevation Loss") /** Absolute elevation at a specific point in time expressed in meters. */ @JvmField - val ABSOLUTE_ELEVATION: DeltaDataType> = + public val ABSOLUTE_ELEVATION: DeltaDataType> = createSampleDataType("Absolute Elevation") /** @@ -276,22 +276,23 @@ abstract class DataType>( * exercise expressed in meters. */ @JvmField - val ABSOLUTE_ELEVATION_STATS: AggregateDataType> = + public val ABSOLUTE_ELEVATION_STATS: + AggregateDataType> = createStatsDataType("Absolute Elevation") /** A distance delta between each reading expressed in meters. */ @JvmField - val DISTANCE: DeltaDataType> = + public val DISTANCE: DeltaDataType> = createIntervalDataType("Distance") /** Total distance since the start of the active exercise expressed in meters. */ @JvmField - val DISTANCE_TOTAL: AggregateDataType> = + public val DISTANCE_TOTAL: AggregateDataType> = createCumulativeDataType("Distance") /** Distance traveled over declining ground between each reading expressed in meters. */ @JvmField - val DECLINE_DISTANCE: DeltaDataType> = + public val DECLINE_DISTANCE: DeltaDataType> = createIntervalDataType("Decline Distance") /** @@ -299,7 +300,7 @@ abstract class DataType>( * the active exercise expressed in meters. */ @JvmField - val DECLINE_DISTANCE_TOTAL: AggregateDataType> = + public val DECLINE_DISTANCE_TOTAL: AggregateDataType> = createCumulativeDataType("Decline Distance") /** @@ -307,7 +308,7 @@ abstract class DataType>( * expressed in seconds. */ @JvmField - val DECLINE_DURATION: DeltaDataType> = + public val DECLINE_DURATION: DeltaDataType> = createIntervalDataType("Decline Duration") /** @@ -315,12 +316,12 @@ abstract class DataType>( * active exercise, expressed in seconds. */ @JvmField - val DECLINE_DURATION_TOTAL: AggregateDataType> = + public val DECLINE_DURATION_TOTAL: AggregateDataType> = createCumulativeDataType("Decline Duration") /** The distance traveled over flat since the last update expressed in meters. */ @JvmField - val FLAT_GROUND_DISTANCE: DeltaDataType> = + public val FLAT_GROUND_DISTANCE: DeltaDataType> = createIntervalDataType("Flat Ground Distance") /** @@ -328,7 +329,8 @@ abstract class DataType>( * expressed in meters. */ @JvmField - val FLAT_GROUND_DISTANCE_TOTAL: AggregateDataType> = + public val FLAT_GROUND_DISTANCE_TOTAL: + AggregateDataType> = createCumulativeDataType("Flat Ground Distance") /** @@ -336,7 +338,7 @@ abstract class DataType>( * expressed in seconds. */ @JvmField - val FLAT_GROUND_DURATION: DeltaDataType> = + public val FLAT_GROUND_DURATION: DeltaDataType> = createIntervalDataType("Flat Ground Duration") /** @@ -344,7 +346,7 @@ abstract class DataType>( * active exercise, expressed in seconds. */ @JvmField - val FLAT_GROUND_DURATION_TOTAL: AggregateDataType> = + public val FLAT_GROUND_DURATION_TOTAL: AggregateDataType> = createCumulativeDataType("Flat Ground Duration") /** @@ -352,7 +354,7 @@ abstract class DataType>( * swinging the club and hitting the ball. */ @JvmField - val GOLF_SHOT_COUNT: DeltaDataType> = + public val GOLF_SHOT_COUNT: DeltaDataType> = createIntervalDataType("Golf Shot Count") /** @@ -360,14 +362,14 @@ abstract class DataType>( * where a golf shot consists swinging the club and hitting the ball. */ @JvmField - val GOLF_SHOT_COUNT_TOTAL: AggregateDataType> = + public val GOLF_SHOT_COUNT_TOTAL: AggregateDataType> = createCumulativeDataType("Golf Shot Count") /** * The distance traveled over inclining ground since the last update expressed in meters. */ @JvmField - val INCLINE_DISTANCE: DeltaDataType> = + public val INCLINE_DISTANCE: DeltaDataType> = createIntervalDataType("Incline Distance") /** @@ -375,7 +377,7 @@ abstract class DataType>( * expressed in meters. */ @JvmField - val INCLINE_DISTANCE_TOTAL: AggregateDataType> = + public val INCLINE_DISTANCE_TOTAL: AggregateDataType> = createCumulativeDataType("Incline Distance") /** @@ -383,7 +385,7 @@ abstract class DataType>( * expressed in seconds. */ @JvmField - val INCLINE_DURATION: DeltaDataType> = + public val INCLINE_DURATION: DeltaDataType> = createIntervalDataType("Incline Duration") /** @@ -391,7 +393,7 @@ abstract class DataType>( * the active exercise, expressed in seconds. */ @JvmField - val INCLINE_DURATION_TOTAL: AggregateDataType> = + public val INCLINE_DURATION_TOTAL: AggregateDataType> = createCumulativeDataType("Incline Duration") /** @@ -399,7 +401,7 @@ abstract class DataType>( * so this is represented as a [Double]. */ @JvmField - val FLOORS: DeltaDataType> = + public val FLOORS: DeltaDataType> = createIntervalDataType("Floors") /** @@ -407,7 +409,7 @@ abstract class DataType>( * floors are supported, so this is represented as a [Double]. */ @JvmField - val FLOORS_TOTAL: AggregateDataType> = + public val FLOORS_TOTAL: AggregateDataType> = createCumulativeDataType("Floors") /** @@ -417,7 +419,7 @@ abstract class DataType>( * [HeartRateAccuracy]. */ @JvmField - val HEART_RATE_BPM: DeltaDataType> = + public val HEART_RATE_BPM: DeltaDataType> = createSampleDataType("HeartRate") /** @@ -425,7 +427,7 @@ abstract class DataType>( * minute. */ @JvmField - val HEART_RATE_BPM_STATS: AggregateDataType> = + public val HEART_RATE_BPM_STATS: AggregateDataType> = createStatsDataType("HeartRate") /** @@ -434,18 +436,19 @@ abstract class DataType>( * Accuracy for a [DataPoint] of type [LOCATION] is represented by [LocationAccuracy]. */ @JvmField - val LOCATION: DeltaDataType> = + public val LOCATION: DeltaDataType> = DeltaDataType("Location", TimeType.SAMPLE, LocationData::class.java) /** Speed at a specific point in time, expressed as meters/second. */ @JvmField - val SPEED: DeltaDataType> = createSampleDataType("Speed") + public val SPEED: DeltaDataType> = + createSampleDataType("Speed") /** * Statistics on speed since the start of the active exercise, expressed in meters/second. */ @JvmField - val SPEED_STATS: AggregateDataType> = + public val SPEED_STATS: AggregateDataType> = createStatsDataType("Speed") /** @@ -453,7 +456,7 @@ abstract class DataType>( * `0f` - `100f`. */ @JvmField - val VO2_MAX: DeltaDataType> = + public val VO2_MAX: DeltaDataType> = createSampleDataType("VO2 Max") /** @@ -461,43 +464,44 @@ abstract class DataType>( * Valid range `0f` - `100f`. */ @JvmField - val VO2_MAX_STATS: AggregateDataType> = + public val VO2_MAX_STATS: AggregateDataType> = createStatsDataType("VO2 Max") /** Number of steps taken since the last update. */ @JvmField - val STEPS: DeltaDataType> = createIntervalDataType("Steps") + public val STEPS: DeltaDataType> = + createIntervalDataType("Steps") /** Total steps taken since the start of the active exercise. */ @JvmField - val STEPS_TOTAL: AggregateDataType> = + public val STEPS_TOTAL: AggregateDataType> = createCumulativeDataType("Steps") /** Number of steps taken while walking since the last update. */ @JvmField - val WALKING_STEPS: DeltaDataType> = + public val WALKING_STEPS: DeltaDataType> = createIntervalDataType("Walking Steps") /** * Total number of steps taken while walking since the start of the current active exercise. */ @JvmField - val WALKING_STEPS_TOTAL: AggregateDataType> = + public val WALKING_STEPS_TOTAL: AggregateDataType> = createCumulativeDataType("Walking Steps") /** Number of steps taken while running since the last update. */ @JvmField - val RUNNING_STEPS: DeltaDataType> = + public val RUNNING_STEPS: DeltaDataType> = createIntervalDataType("Running Steps") /** Number of steps taken while running since the start of the current active exercise. */ @JvmField - val RUNNING_STEPS_TOTAL: AggregateDataType> = + public val RUNNING_STEPS_TOTAL: AggregateDataType> = createCumulativeDataType("Running Steps") /** Step rate in steps/minute at a given point in time. */ @JvmField - val STEPS_PER_MINUTE: DeltaDataType> = + public val STEPS_PER_MINUTE: DeltaDataType> = createSampleDataType("Step per minute") /** @@ -505,24 +509,24 @@ abstract class DataType>( * exercise. */ @JvmField - val STEPS_PER_MINUTE_STATS: AggregateDataType> = + public val STEPS_PER_MINUTE_STATS: AggregateDataType> = createStatsDataType("Step per minute") /** Number of swimming strokes taken since the last update. */ @JvmField - val SWIMMING_STROKES: DeltaDataType> = + public val SWIMMING_STROKES: DeltaDataType> = createIntervalDataType("Swimming Strokes") /** * Total number of swimming strokes taken since the start of the current active exercise. */ @JvmField - val SWIMMING_STROKES_TOTAL: AggregateDataType> = + public val SWIMMING_STROKES_TOTAL: AggregateDataType> = createCumulativeDataType("Swimming Strokes") /** Number of calories burned (including basal rate and activity) since the last update. */ @JvmField - val CALORIES: DeltaDataType> = + public val CALORIES: DeltaDataType> = createIntervalDataType("Calories") /** @@ -530,7 +534,7 @@ abstract class DataType>( * the current active exercise. */ @JvmField - val CALORIES_TOTAL: AggregateDataType> = + public val CALORIES_TOTAL: AggregateDataType> = createCumulativeDataType("Calories") /** @@ -538,26 +542,28 @@ abstract class DataType>( * will be in milliseconds/kilometer. */ @JvmField - val PACE: DeltaDataType> = createSampleDataType("Pace") + public val PACE: DeltaDataType> = + createSampleDataType("Pace") /** * Statistics on pace since the start of the current exercise. A value of 0 indicates the * user stopped moving, otherwise the value will be in milliseconds/kilometer. */ @JvmField - val PACE_STATS: AggregateDataType> = + public val PACE_STATS: AggregateDataType> = createStatsDataType("Pace") /** * The number of seconds the user has been resting during an exercise since the last update. */ @JvmField - val RESTING_EXERCISE_DURATION: DeltaDataType> = + public val RESTING_EXERCISE_DURATION: DeltaDataType> = createIntervalDataType("Resting Exercise Duration") /** The total number of seconds the user has been resting during the active exercise. */ @JvmField - val RESTING_EXERCISE_DURATION_TOTAL: AggregateDataType> = + public val RESTING_EXERCISE_DURATION_TOTAL: + AggregateDataType> = createCumulativeDataType("Resting Exercise Duration") /** @@ -569,22 +575,23 @@ abstract class DataType>( * every [ExerciseUpdate].** */ @JvmField - val ACTIVE_EXERCISE_DURATION_TOTAL: AggregateDataType> = + public val ACTIVE_EXERCISE_DURATION_TOTAL: + AggregateDataType> = createCumulativeDataType("Active Exercise Duration") /** Count of swimming laps since the last update. */ @JvmField - val SWIMMING_LAP_COUNT: DeltaDataType> = + public val SWIMMING_LAP_COUNT: DeltaDataType> = createIntervalDataType("Swim Lap Count") /** Count of swimming laps since the start of the current active exercise. */ @JvmField - val SWIMMING_LAP_COUNT_TOTAL: AggregateDataType> = + public val SWIMMING_LAP_COUNT_TOTAL: AggregateDataType> = createCumulativeDataType("Swim Lap Count") /** The number of repetitions of an exercise performed since the last update. */ @JvmField - val REP_COUNT: DeltaDataType> = + public val REP_COUNT: DeltaDataType> = createIntervalDataType("Rep Count") /** @@ -592,7 +599,7 @@ abstract class DataType>( * exercise. */ @JvmField - val REP_COUNT_TOTAL: AggregateDataType> = + public val REP_COUNT_TOTAL: AggregateDataType> = createCumulativeDataType("Rep Count") /** @@ -600,7 +607,7 @@ abstract class DataType>( * ground in milliseconds in `long` format. */ @JvmField - val GROUND_CONTACT_TIME: DeltaDataType> = + public val GROUND_CONTACT_TIME: DeltaDataType> = createSampleDataType("Ground Contact Time") /** @@ -608,7 +615,7 @@ abstract class DataType>( * contact with the ground in milliseconds in `long` format. */ @JvmField - val GROUND_CONTACT_TIME_STATS: AggregateDataType> = + public val GROUND_CONTACT_TIME_STATS: AggregateDataType> = createStatsDataType("Ground Contact Time") /** @@ -616,7 +623,7 @@ abstract class DataType>( * format. */ @JvmField - val VERTICAL_OSCILLATION: DeltaDataType> = + public val VERTICAL_OSCILLATION: DeltaDataType> = createSampleDataType("Vertical Oscillation") /** @@ -624,7 +631,8 @@ abstract class DataType>( * in `double` format. */ @JvmField - val VERTICAL_OSCILLATION_STATS: AggregateDataType> = + public val VERTICAL_OSCILLATION_STATS: + AggregateDataType> = createStatsDataType("Vertical Oscillation") /** @@ -634,7 +642,7 @@ abstract class DataType>( * vertical ratio of 0.625. */ @JvmField - val VERTICAL_RATIO: DeltaDataType> = + public val VERTICAL_RATIO: DeltaDataType> = createSampleDataType("Vertical Ratio") /** @@ -644,17 +652,17 @@ abstract class DataType>( * vertical ratio of 0.625. */ @JvmField - val VERTICAL_RATIO_STATS: AggregateDataType> = + public val VERTICAL_RATIO_STATS: AggregateDataType> = createStatsDataType("Vertical Ratio") /** Distance covered by a single step in meters in `double` format. */ @JvmField - val STRIDE_LENGTH: DeltaDataType> = + public val STRIDE_LENGTH: DeltaDataType> = createSampleDataType("Stride Length") /** Statistics on distance covered by a single step in meters in `double` format. */ @JvmField - val STRIDE_LENGTH_STATS: AggregateDataType> = + public val STRIDE_LENGTH_STATS: AggregateDataType> = createStatsDataType("Stride Length") /** @@ -663,7 +671,7 @@ abstract class DataType>( * of day to now. In the event of time-zone shifts, the interval may be greater than 24hrs. */ @JvmField - val STEPS_DAILY: DeltaDataType> = + public val STEPS_DAILY: DeltaDataType> = createIntervalDataType("Daily Steps") /** @@ -673,7 +681,7 @@ abstract class DataType>( * than 24hrs. */ @JvmField - val FLOORS_DAILY: DeltaDataType> = + public val FLOORS_DAILY: DeltaDataType> = createIntervalDataType("Daily Floors") /** @@ -684,7 +692,7 @@ abstract class DataType>( * the interval might be greater than 24hrs. */ @JvmField - val ELEVATION_GAIN_DAILY: DeltaDataType> = + public val ELEVATION_GAIN_DAILY: DeltaDataType> = createIntervalDataType("Daily Elevation Gain") /** @@ -694,7 +702,7 @@ abstract class DataType>( * shifts, the interval might be greater than 24hrs. */ @JvmField - val CALORIES_DAILY: DeltaDataType> = + public val CALORIES_DAILY: DeltaDataType> = createIntervalDataType("Daily Calories") /** @@ -703,7 +711,7 @@ abstract class DataType>( * to now. In the event of time-zone shifts, the interval may be greater than 24hrs. */ @JvmField - val DISTANCE_DAILY: DeltaDataType> = + public val DISTANCE_DAILY: DeltaDataType> = createIntervalDataType("Daily Distance") internal val deltaDataTypes: Set> = diff --git a/health/health-services-client/src/main/java/androidx/health/services/client/data/DebouncedDataTypeCondition.kt b/health/health-services-client/src/main/java/androidx/health/services/client/data/DebouncedDataTypeCondition.kt index 6bbf5a6786ed1..0e204e4500b69 100644 --- a/health/health-services-client/src/main/java/androidx/health/services/client/data/DebouncedDataTypeCondition.kt +++ b/health/health-services-client/src/main/java/androidx/health/services/client/data/DebouncedDataTypeCondition.kt @@ -28,13 +28,13 @@ public class DebouncedDataTypeCondition>, > createDebouncedDataTypeCondition( @@ -175,7 +175,7 @@ internal constructor( * crossed uninterruptedly for this goal to trigger. Must be greater or equal to zero */ @JvmStatic - fun < + public fun < T : Number, D : AggregateDataType>, > createDebouncedDataTypeCondition( diff --git a/health/health-services-client/src/main/java/androidx/health/services/client/data/DebouncedGoal.kt b/health/health-services-client/src/main/java/androidx/health/services/client/data/DebouncedGoal.kt index 4268840ef8c61..0a863744e1337 100644 --- a/health/health-services-client/src/main/java/androidx/health/services/client/data/DebouncedGoal.kt +++ b/health/health-services-client/src/main/java/androidx/health/services/client/data/DebouncedGoal.kt @@ -25,14 +25,14 @@ import java.util.Objects * durationAtThreshold. Only applies to sample data types(e.g. heart rate, speed) and aggregate data * type with statistical data points(e.g. pace stats). */ -class DebouncedGoal +public class DebouncedGoal private constructor( /** * The condition which specifies data type, threshold, comparison type and debounced params. The * condition must be met in order to trigger the goal. */ - val debouncedDataTypeCondition: DebouncedDataTypeCondition + public val debouncedDataTypeCondition: DebouncedDataTypeCondition ) { internal val proto: DataProto.DebouncedGoal = @@ -58,7 +58,7 @@ private constructor( override fun toString(): String = "DebouncedGoal(debouncedDataTypeCondition=$debouncedDataTypeCondition)" - companion object { + public companion object { internal fun fromProto(proto: DataProto.DebouncedGoal): DebouncedGoal { val condition = DebouncedDataTypeCondition.fromProto(proto.debouncedDataTypeCondition) @@ -74,7 +74,7 @@ private constructor( * @return a debounced goal that is triggered when the condition is met */ @JvmStatic - fun createSampleDebouncedGoal( + public fun createSampleDebouncedGoal( condition: DebouncedDataTypeCondition>> ): DebouncedGoal { return DebouncedGoal(condition) @@ -89,7 +89,7 @@ private constructor( * @return a debounced goal that is triggered when the condition is met */ @JvmStatic - fun createAggregateDebouncedGoal( + public fun createAggregateDebouncedGoal( condition: DebouncedDataTypeCondition>> ): DebouncedGoal = DebouncedGoal(condition) } diff --git a/health/health-services-client/src/main/java/androidx/health/services/client/data/ExerciseCapabilities.kt b/health/health-services-client/src/main/java/androidx/health/services/client/data/ExerciseCapabilities.kt index 350ead2b89fde..1dc210987b1fd 100644 --- a/health/health-services-client/src/main/java/androidx/health/services/client/data/ExerciseCapabilities.kt +++ b/health/health-services-client/src/main/java/androidx/health/services/client/data/ExerciseCapabilities.kt @@ -33,7 +33,7 @@ public class ExerciseCapabilities( public val supportedBatchingModeOverrides: Set = emptySet(), ) { - constructor( + public constructor( typeToCapabilities: Map ) : this(typeToCapabilities, emptySet()) diff --git a/health/health-services-client/src/main/java/androidx/health/services/client/data/ExerciseConfig.kt b/health/health-services-client/src/main/java/androidx/health/services/client/data/ExerciseConfig.kt index 91502a401e5c3..51748e4dca28e 100644 --- a/health/health-services-client/src/main/java/androidx/health/services/client/data/ExerciseConfig.kt +++ b/health/health-services-client/src/main/java/androidx/health/services/client/data/ExerciseConfig.kt @@ -46,20 +46,21 @@ import androidx.health.services.client.proto.DataProto * @constructor Creates a new ExerciseConfig for an exercise tracked using Health Services */ @Suppress("ParcelCreator") -class ExerciseConfig +public class ExerciseConfig @JvmOverloads constructor( - val exerciseType: ExerciseType, - val dataTypes: Set>, - val isAutoPauseAndResumeEnabled: Boolean, - val isGpsEnabled: Boolean, - val exerciseGoals: List> = listOf(), - val exerciseParams: Bundle = Bundle(), - @FloatRange(from = 0.0) val swimmingPoolLengthMeters: Float = SWIMMING_POOL_LENGTH_UNSPECIFIED, - val exerciseTypeConfig: ExerciseTypeConfig? = null, - val batchingModeOverrides: Set = emptySet(), - val exerciseEventTypes: Set> = emptySet(), - val debouncedGoals: List> = emptyList(), + public val exerciseType: ExerciseType, + public val dataTypes: Set>, + public val isAutoPauseAndResumeEnabled: Boolean, + public val isGpsEnabled: Boolean, + public val exerciseGoals: List> = listOf(), + public val exerciseParams: Bundle = Bundle(), + @FloatRange(from = 0.0) + public val swimmingPoolLengthMeters: Float = SWIMMING_POOL_LENGTH_UNSPECIFIED, + public val exerciseTypeConfig: ExerciseTypeConfig? = null, + public val batchingModeOverrides: Set = emptySet(), + public val exerciseEventTypes: Set> = emptySet(), + public val debouncedGoals: List> = emptyList(), ) { internal constructor( @@ -108,7 +109,7 @@ constructor( } /** Builder for [ExerciseConfig] instances. */ - class Builder( + public class Builder( /** * The active [ExerciseType] the user is performing for this exercise. * @@ -137,7 +138,7 @@ constructor( * @param dataTypes set of [DataType]s ([AggregateDataType] or [DeltaDataType]) to track * during this exercise */ - fun setDataTypes(dataTypes: Set>): Builder { + public fun setDataTypes(dataTypes: Set>): Builder { this.dataTypes = dataTypes.toSet() return this } @@ -149,7 +150,7 @@ constructor( * @param isAutoPauseAndResumeEnabled if true, exercise will automatically pause and resume */ @Suppress("MissingGetterMatchingBuilder") - fun setIsAutoPauseAndResumeEnabled(isAutoPauseAndResumeEnabled: Boolean): Builder { + public fun setIsAutoPauseAndResumeEnabled(isAutoPauseAndResumeEnabled: Boolean): Builder { this.isAutoPauseAndResumeEnabled = isAutoPauseAndResumeEnabled return this } @@ -168,7 +169,7 @@ constructor( * @param isGpsEnabled if true, GPS will be enabled for this exercise */ @Suppress("MissingGetterMatchingBuilder") - fun setIsGpsEnabled(isGpsEnabled: Boolean): Builder { + public fun setIsGpsEnabled(isGpsEnabled: Boolean): Builder { this.isGpsEnabled = isGpsEnabled return this } @@ -182,7 +183,7 @@ constructor( * * @param exerciseGoals the list of [ExerciseGoal]s to begin the exercise with */ - fun setExerciseGoals(exerciseGoals: List>): Builder { + public fun setExerciseGoals(exerciseGoals: List>): Builder { this.exerciseGoals = exerciseGoals return this } @@ -196,7 +197,7 @@ constructor( * * @param debouncedGoals the list of [DebouncedGoal]s to begin the exercise with */ - fun setDebouncedGoals(debouncedGoals: List>): Builder { + public fun setDebouncedGoals(debouncedGoals: List>): Builder { this.debouncedGoals = debouncedGoals return this } @@ -207,14 +208,14 @@ constructor( * * @param exerciseParams [Bundle] containing OEM specific parameters */ - fun setExerciseParams(exerciseParams: Bundle): Builder { + public fun setExerciseParams(exerciseParams: Bundle): Builder { this.exerciseParams = exerciseParams return this } /** Sets the swimming pool length (in m). */ @Suppress("MissingGetterMatchingBuilder") - fun setSwimmingPoolLengthMeters(swimmingPoolLength: Float): Builder { + public fun setSwimmingPoolLengthMeters(swimmingPoolLength: Float): Builder { this.swimmingPoolLength = swimmingPoolLength return this } @@ -225,7 +226,7 @@ constructor( * @param exerciseTypeConfig [ExerciseTypeConfig] specifying active exercise type * configurations */ - fun setExerciseTypeConfig(exerciseTypeConfig: ExerciseTypeConfig?): Builder { + public fun setExerciseTypeConfig(exerciseTypeConfig: ExerciseTypeConfig?): Builder { this.exerciseTypeConfig = exerciseTypeConfig return this } @@ -235,7 +236,7 @@ constructor( * * @param batchingModeOverrides [BatchingMode] overrides */ - fun setBatchingModeOverrides(batchingModeOverrides: Set): Builder { + public fun setBatchingModeOverrides(batchingModeOverrides: Set): Builder { this.batchingModeOverrides = batchingModeOverrides return this } @@ -245,13 +246,13 @@ constructor( * * @param exerciseEventTypes the set of [ExerciseEventType]s to begin the exercise with */ - fun setExerciseEventTypes(exerciseEventTypes: Set>): Builder { + public fun setExerciseEventTypes(exerciseEventTypes: Set>): Builder { this.exerciseEventTypes = exerciseEventTypes return this } /** Returns the built [ExerciseConfig]. */ - fun build(): ExerciseConfig { + public fun build(): ExerciseConfig { return ExerciseConfig( exerciseType, dataTypes, @@ -299,14 +300,14 @@ constructor( return builder.build() } - companion object { + public companion object { /** * Returns a fresh new [Builder]. * * @param exerciseType the [ExerciseType] representing this exercise */ - @JvmStatic fun builder(exerciseType: ExerciseType): Builder = Builder(exerciseType) + @JvmStatic public fun builder(exerciseType: ExerciseType): Builder = Builder(exerciseType) - public const val SWIMMING_POOL_LENGTH_UNSPECIFIED = 0.0f + public const val SWIMMING_POOL_LENGTH_UNSPECIFIED: Float = 0.0f } } diff --git a/health/health-services-client/src/main/java/androidx/health/services/client/data/ExerciseGoal.kt b/health/health-services-client/src/main/java/androidx/health/services/client/data/ExerciseGoal.kt index bf8d1f16a14dd..eaa4c1a5c7f30 100644 --- a/health/health-services-client/src/main/java/androidx/health/services/client/data/ExerciseGoal.kt +++ b/health/health-services-client/src/main/java/androidx/health/services/client/data/ExerciseGoal.kt @@ -24,15 +24,15 @@ import java.util.Objects /** Defines a goal for an exercise. */ @SuppressLint("BanParcelableUsage") // Uses proto in implementation for compat -class ExerciseGoal +public class ExerciseGoal internal constructor( /** * The type of this exercise goal ([ExerciseGoalType.ONE_TIME_GOAL] or * [ExerciseGoalType.MILESTONE].) */ - val exerciseGoalType: ExerciseGoalType, - val dataTypeCondition: DataTypeCondition>, - val period: T? = null, + public val exerciseGoalType: ExerciseGoalType, + public val dataTypeCondition: DataTypeCondition>, + public val period: T? = null, ) : Parcelable { public override fun describeContents(): Int = 0 @@ -90,9 +90,9 @@ internal constructor( "period=$period" + ")" - companion object { + public companion object { @JvmField - val CREATOR: Parcelable.Creator> = + public val CREATOR: Parcelable.Creator> = object : Parcelable.Creator> { override fun createFromParcel(source: Parcel): ExerciseGoal<*>? { val bytes: ByteArray = source.createByteArray() ?: return null @@ -121,7 +121,7 @@ internal constructor( * satisfied. */ @JvmStatic - fun createOneTimeGoal( + public fun createOneTimeGoal( condition: DataTypeCondition> ): ExerciseGoal { return ExerciseGoal(ExerciseGoalType.ONE_TIME_GOAL, condition) @@ -133,14 +133,14 @@ internal constructor( * one for every 2km. This goal will there be triggered at distances = 2km, 4km, 6km, ... */ @JvmStatic - fun createMilestone( + public fun createMilestone( condition: DataTypeCondition>, period: T, ): ExerciseGoal = ExerciseGoal(ExerciseGoalType.MILESTONE, condition, period) /** Creates a new goal that is the same as a given goal but with a new threshold value. */ @JvmStatic - fun createMilestoneGoalWithUpdatedThreshold( + public fun createMilestoneGoalWithUpdatedThreshold( goal: ExerciseGoal, newThreshold: T, ): ExerciseGoal { diff --git a/health/health-services-client/src/main/java/androidx/health/services/client/data/ExerciseLapSummary.kt b/health/health-services-client/src/main/java/androidx/health/services/client/data/ExerciseLapSummary.kt index b6bb876fd9e36..f3672cec26061 100644 --- a/health/health-services-client/src/main/java/androidx/health/services/client/data/ExerciseLapSummary.kt +++ b/health/health-services-client/src/main/java/androidx/health/services/client/data/ExerciseLapSummary.kt @@ -23,28 +23,28 @@ import java.time.Instant /** Describes a completed exercise lap. */ @Suppress("ParcelCreator") -class ExerciseLapSummary( +public class ExerciseLapSummary( /** Returns the lap count of this summary. Lap count starts at 1 for the first lap. */ - val lapCount: Int, + public val lapCount: Int, /** Returns the time at which the lap has started. */ - val startTime: Instant, + public val startTime: Instant, /** Returns the time at which the lap has ended. */ - val endTime: Instant, + public val endTime: Instant, /** * Returns the total elapsed time for which the exercise has been active during this lap, i.e. * started but not paused. */ - val activeDuration: Duration, + public val activeDuration: Duration, /** * Returns the [DataPoint]s for each metric keyed by [DataType] tracked between [startTime] and * [endTime] i.e. during the duration of this lap. This will only contain [AggregateDataType]s * calculated over the duration of the lap. */ - val lapMetrics: DataPointContainer, + public val lapMetrics: DataPointContainer, ) { internal constructor( diff --git a/health/health-services-client/src/main/java/androidx/health/services/client/data/ExerciseTypeCapabilities.kt b/health/health-services-client/src/main/java/androidx/health/services/client/data/ExerciseTypeCapabilities.kt index a92b2bf550e04..e17abef40ef6f 100644 --- a/health/health-services-client/src/main/java/androidx/health/services/client/data/ExerciseTypeCapabilities.kt +++ b/health/health-services-client/src/main/java/androidx/health/services/client/data/ExerciseTypeCapabilities.kt @@ -37,7 +37,7 @@ constructor( internal val exerciseEventCapabilities: Map, ExerciseEventCapabilities> = emptyMap(), /** Map from supported debounced goals to a set of compatible [ComparisonType]s. */ - val supportedDebouncedGoals: Map, Set> = emptyMap(), + public val supportedDebouncedGoals: Map, Set> = emptyMap(), ) { internal constructor( diff --git a/health/health-services-client/src/main/java/androidx/health/services/client/data/ExerciseTypeConfig.kt b/health/health-services-client/src/main/java/androidx/health/services/client/data/ExerciseTypeConfig.kt index a5a7fec5f5a43..032303172a80a 100644 --- a/health/health-services-client/src/main/java/androidx/health/services/client/data/ExerciseTypeConfig.kt +++ b/health/health-services-client/src/main/java/androidx/health/services/client/data/ExerciseTypeConfig.kt @@ -24,10 +24,10 @@ import androidx.health.services.client.proto.DataProto * Developers should create instances of [ExerciseTypeConfig] using the constructor of available * subclasses, depending on their needs. Currently available types are: [GolfExerciseTypeConfig]. */ -abstract class ExerciseTypeConfig internal constructor() { +public abstract class ExerciseTypeConfig internal constructor() { internal abstract fun toProto(): DataProto.ExerciseTypeConfig - companion object { + public companion object { internal fun fromProto(proto: DataProto.ExerciseTypeConfig): ExerciseTypeConfig { if (proto.hasGolfShotTrackingPlaceInfo()) { return GolfExerciseTypeConfig( diff --git a/health/health-services-client/src/main/java/androidx/health/services/client/data/GolfExerciseTypeConfig.kt b/health/health-services-client/src/main/java/androidx/health/services/client/data/GolfExerciseTypeConfig.kt index 8ab8edbf7b9a5..a22694bd0f2a3 100644 --- a/health/health-services-client/src/main/java/androidx/health/services/client/data/GolfExerciseTypeConfig.kt +++ b/health/health-services-client/src/main/java/androidx/health/services/client/data/GolfExerciseTypeConfig.kt @@ -29,8 +29,8 @@ import java.util.Objects * @property golfShotTrackingPlaceInfo location where user takes [DataType.GOLF_SHOT_COUNT] during * [ExerciseType.GOLF] activity */ -class GolfExerciseTypeConfig( - val golfShotTrackingPlaceInfo: GolfShotTrackingPlaceInfo = +public class GolfExerciseTypeConfig( + public val golfShotTrackingPlaceInfo: GolfShotTrackingPlaceInfo = GOLF_SHOT_TRACKING_PLACE_INFO_UNSPECIFIED ) : ExerciseTypeConfig() { @@ -45,7 +45,7 @@ class GolfExerciseTypeConfig( * The tracking information for a golf shot used in [GolfExerciseTypeConfig]. It is the semantic * location of a user while golfing to assist golf swing activity recognition algorithms. */ - class GolfShotTrackingPlaceInfo private constructor(val placeInfoId: Int) { + public class GolfShotTrackingPlaceInfo private constructor(public val placeInfoId: Int) { override fun equals(other: Any?): Boolean { return other is GolfShotTrackingPlaceInfo && other.placeInfoId == this.placeInfoId } @@ -65,7 +65,7 @@ class GolfExerciseTypeConfig( return "GolfShotTrackingPlaceInfo(placeInfoId=$placeInfoId):$name" } - companion object { + public companion object { internal fun GolfShotTrackingPlaceInfo.toProto(): DataProto.GolfShotTrackingPlaceInfoType = when (this) { @@ -98,16 +98,24 @@ class GolfExerciseTypeConfig( } /** The golf shot is being taken from an unspecified place. */ - @JvmField val GOLF_SHOT_TRACKING_PLACE_INFO_UNSPECIFIED = GolfShotTrackingPlaceInfo(0) + @JvmField + public val GOLF_SHOT_TRACKING_PLACE_INFO_UNSPECIFIED: GolfShotTrackingPlaceInfo = + GolfShotTrackingPlaceInfo(0) /** The golf shot is being taken from the fairway. */ - @JvmField val GOLF_SHOT_TRACKING_PLACE_INFO_FAIRWAY = GolfShotTrackingPlaceInfo(1) + @JvmField + public val GOLF_SHOT_TRACKING_PLACE_INFO_FAIRWAY: GolfShotTrackingPlaceInfo = + GolfShotTrackingPlaceInfo(1) /** The golf shot is being taken from the putting green. */ - @JvmField val GOLF_SHOT_TRACKING_PLACE_INFO_PUTTING_GREEN = GolfShotTrackingPlaceInfo(2) + @JvmField + public val GOLF_SHOT_TRACKING_PLACE_INFO_PUTTING_GREEN: GolfShotTrackingPlaceInfo = + GolfShotTrackingPlaceInfo(2) /** The golf shot is being taken from the tee box area. */ - @JvmField val GOLF_SHOT_TRACKING_PLACE_INFO_TEE_BOX = GolfShotTrackingPlaceInfo(3) + @JvmField + public val GOLF_SHOT_TRACKING_PLACE_INFO_TEE_BOX: GolfShotTrackingPlaceInfo = + GolfShotTrackingPlaceInfo(3) } } diff --git a/health/health-services-client/src/main/java/androidx/health/services/client/data/GolfShotEvent.kt b/health/health-services-client/src/main/java/androidx/health/services/client/data/GolfShotEvent.kt index e04d8c68231a2..efa8bb624e401 100644 --- a/health/health-services-client/src/main/java/androidx/health/services/client/data/GolfShotEvent.kt +++ b/health/health-services-client/src/main/java/androidx/health/services/client/data/GolfShotEvent.kt @@ -23,9 +23,9 @@ import java.util.Objects /** An [ExerciseEvent] that contains information about Golf Shot events for the current exercise. */ public class GolfShotEvent( /** [Duration] since device boot when the golf shot was detected. */ - val durationSinceBoot: Duration, + public val durationSinceBoot: Duration, /** The type of golf swing that was detected. */ - val swingType: GolfShotSwingType, + public val swingType: GolfShotSwingType, ) : ExerciseEvent() { internal constructor( @@ -62,18 +62,18 @@ public class GolfShotEvent( DataProto.GolfShotSwingType.forNumber(id) ?: DataProto.GolfShotSwingType.GOLF_SHOT_SWING_TYPE_UNKNOWN - companion object { + public companion object { /** The swing type of the received golf shot is unknown. */ - @JvmField val UNKNOWN: GolfShotSwingType = GolfShotSwingType(0) + @JvmField public val UNKNOWN: GolfShotSwingType = GolfShotSwingType(0) /** The swing type of the received golf shot is putt. */ - @JvmField val PUTT: GolfShotSwingType = GolfShotSwingType(1) + @JvmField public val PUTT: GolfShotSwingType = GolfShotSwingType(1) /** The swing type of the received golf shot is partial. */ - @JvmField val PARTIAL: GolfShotSwingType = GolfShotSwingType(2) + @JvmField public val PARTIAL: GolfShotSwingType = GolfShotSwingType(2) /** The swing type of the received golf shot is full. */ - @JvmField val FULL: GolfShotSwingType = GolfShotSwingType(3) + @JvmField public val FULL: GolfShotSwingType = GolfShotSwingType(3) internal fun fromProto(proto: DataProto.GolfShotSwingType): GolfShotSwingType = when (proto) { diff --git a/health/health-services-client/src/main/java/androidx/health/services/client/data/IntervalDataPoint.kt b/health/health-services-client/src/main/java/androidx/health/services/client/data/IntervalDataPoint.kt index 580fe5efd8f13..7740bc52f8800 100644 --- a/health/health-services-client/src/main/java/androidx/health/services/client/data/IntervalDataPoint.kt +++ b/health/health-services-client/src/main/java/androidx/health/services/client/data/IntervalDataPoint.kt @@ -22,19 +22,19 @@ import java.time.Duration import java.time.Instant /** Data point that includes just the delta from the previous data point for [dataType]. */ -class IntervalDataPoint( +public class IntervalDataPoint( /** The [DataType] this [DataPoint] represents. */ override val dataType: DataType>, /** The value of this data point. */ - val value: T, + public val value: T, /** The beginning of the time period this [DataPoint] represents. */ - val startDurationFromBoot: Duration, + public val startDurationFromBoot: Duration, /** The end of the time period this [DataPoint] represents. */ - val endDurationFromBoot: Duration, + public val endDurationFromBoot: Duration, /** OEM specific data. In general, this should not be relied upon by non-preloaded apps. */ - val metadata: Bundle = Bundle(), + public val metadata: Bundle = Bundle(), /** Accuracy of this DataPoint. */ - val accuracy: DataPointAccuracy? = null, + public val accuracy: DataPointAccuracy? = null, ) : DataPoint(dataType) { internal val proto: DataProto.DataPoint = getDataPointProto() @@ -59,7 +59,7 @@ class IntervalDataPoint( * @param bootInstant the [Instant] at which the system booted, this can be computed by * `Instant.ofEpochMilli(System.currentTimeMillis() - SystemClock.elapsedRealtime()) ` */ - fun getStartInstant(bootInstant: Instant): Instant { + public fun getStartInstant(bootInstant: Instant): Instant { return bootInstant.plus(startDurationFromBoot) } @@ -69,7 +69,7 @@ class IntervalDataPoint( * @param bootInstant the [Instant] at which the system booted, this can be computed by * `Instant.ofEpochMilli(System.currentTimeMillis() - SystemClock.elapsedRealtime())` */ - fun getEndInstant(bootInstant: Instant): Instant { + public fun getEndInstant(bootInstant: Instant): Instant { return bootInstant.plus(endDurationFromBoot) } diff --git a/health/health-services-client/src/main/java/androidx/health/services/client/data/PassiveGoal.kt b/health/health-services-client/src/main/java/androidx/health/services/client/data/PassiveGoal.kt index 3963fe6999d8c..91f148b7f30cd 100644 --- a/health/health-services-client/src/main/java/androidx/health/services/client/data/PassiveGoal.kt +++ b/health/health-services-client/src/main/java/androidx/health/services/client/data/PassiveGoal.kt @@ -26,10 +26,10 @@ import androidx.health.services.client.proto.DataProto.PassiveGoal as PassiveGoa * repeat daily. */ @Suppress("ParcelCreator") -class PassiveGoal +public class PassiveGoal private constructor( /** [DataTypeCondition] which must be met for the passive goal to be triggered. */ - val dataTypeCondition: DataTypeCondition>, + public val dataTypeCondition: DataTypeCondition>, /** Frequency this goal should trigger, which is expected to be a [TriggerFrequency]. */ @TriggerFrequency internal val triggerFrequency: Int, ) { diff --git a/health/health-services-client/src/main/java/androidx/health/services/client/data/PassiveListenerConfig.kt b/health/health-services-client/src/main/java/androidx/health/services/client/data/PassiveListenerConfig.kt index add0bc4a91d37..f2e1870aaa515 100644 --- a/health/health-services-client/src/main/java/androidx/health/services/client/data/PassiveListenerConfig.kt +++ b/health/health-services-client/src/main/java/androidx/health/services/client/data/PassiveListenerConfig.kt @@ -81,7 +81,7 @@ public class PassiveListenerConfig( * @param shouldUserActivityInfoBeRequested whether to request user activity state tracking */ @Suppress("MissingGetterMatchingBuilder") - fun setShouldUserActivityInfoBeRequested( + public fun setShouldUserActivityInfoBeRequested( shouldUserActivityInfoBeRequested: Boolean ): Builder { this.requestUserActivityState = shouldUserActivityInfoBeRequested diff --git a/health/health-services-client/src/main/java/androidx/health/services/client/data/StatisticalDataPoint.kt b/health/health-services-client/src/main/java/androidx/health/services/client/data/StatisticalDataPoint.kt index 2ba245ef3740c..b90b651373988 100644 --- a/health/health-services-client/src/main/java/androidx/health/services/client/data/StatisticalDataPoint.kt +++ b/health/health-services-client/src/main/java/androidx/health/services/client/data/StatisticalDataPoint.kt @@ -23,19 +23,19 @@ import java.time.Instant * Data point that represents statistics on [SampleDataPoint]s between [start] and [end], though it * is not required to request samples separately. */ -class StatisticalDataPoint( +public class StatisticalDataPoint( /** The [DataType] this [DataPoint] represents. */ dataType: AggregateDataType>, /** The minimum observed value between [start] and [end]. */ - val min: T, + public val min: T, /** The maximum observed value between [start] and [end]. */ - val max: T, + public val max: T, /** The average observed value between [start] and [end]. */ - val average: T, + public val average: T, /** The beginning of time this point covers. */ - val start: Instant, + public val start: Instant, /** The end time this point covers. */ - val end: Instant, + public val end: Instant, ) : DataPoint(dataType) { internal val proto: DataProto.AggregateDataPoint = @@ -51,7 +51,7 @@ class StatisticalDataPoint( ) .build() - companion object { + public companion object { @Suppress("UNCHECKED_CAST") internal fun fromProto( proto: DataProto.AggregateDataPoint.StatisticalDataPoint diff --git a/health/health-services-client/src/main/java/androidx/health/services/client/impl/request/DebouncedGoalRequest.kt b/health/health-services-client/src/main/java/androidx/health/services/client/impl/request/DebouncedGoalRequest.kt index ddb4a4661d05d..76d2b686087e3 100644 --- a/health/health-services-client/src/main/java/androidx/health/services/client/impl/request/DebouncedGoalRequest.kt +++ b/health/health-services-client/src/main/java/androidx/health/services/client/impl/request/DebouncedGoalRequest.kt @@ -24,8 +24,10 @@ import androidx.health.services.client.proto.RequestsProto /** Request for adding or removing a [DebouncedGoal] for an exercise. */ @RestrictTo(RestrictTo.Scope.LIBRARY) -data class DebouncedGoalRequest(val packageName: String, val debouncedGoal: DebouncedGoal<*>) : - ProtoParcelable() { +public data class DebouncedGoalRequest( + val packageName: String, + val debouncedGoal: DebouncedGoal<*>, +) : ProtoParcelable() { override val proto: RequestsProto.DebouncedGoalRequest get() = RequestsProto.DebouncedGoalRequest.newBuilder() @@ -33,9 +35,9 @@ data class DebouncedGoalRequest(val packageName: String, val debouncedGoal: Debo .setDebouncedGoal(debouncedGoal.proto) .build() - companion object { + public companion object { @JvmField - val CREATOR: Parcelable.Creator = newCreator { bytes -> + public val CREATOR: Parcelable.Creator = newCreator { bytes -> val proto = RequestsProto.DebouncedGoalRequest.parseFrom(bytes) DebouncedGoalRequest(proto.packageName, DebouncedGoal.fromProto(proto.debouncedGoal)) } diff --git a/health/health-services-client/src/main/java/androidx/health/services/client/impl/request/UpdateExerciseTypeConfigRequest.kt b/health/health-services-client/src/main/java/androidx/health/services/client/impl/request/UpdateExerciseTypeConfigRequest.kt index d78c46763e1a1..55074eb9eadda 100644 --- a/health/health-services-client/src/main/java/androidx/health/services/client/impl/request/UpdateExerciseTypeConfigRequest.kt +++ b/health/health-services-client/src/main/java/androidx/health/services/client/impl/request/UpdateExerciseTypeConfigRequest.kt @@ -24,9 +24,9 @@ import androidx.health.services.client.proto.RequestsProto /** Request for updating exercise type configuration in an [ExerciseTypeConfig]. */ @RestrictTo(RestrictTo.Scope.LIBRARY) -class UpdateExerciseTypeConfigRequest( - val packageName: String, - val exerciseTypeConfig: ExerciseTypeConfig, +public class UpdateExerciseTypeConfigRequest( + public val packageName: String, + public val exerciseTypeConfig: ExerciseTypeConfig, ) : ProtoParcelable() { override val proto: RequestsProto.UpdateExerciseTypeConfigRequest = RequestsProto.UpdateExerciseTypeConfigRequest.newBuilder() @@ -34,14 +34,15 @@ class UpdateExerciseTypeConfigRequest( .setConfig(exerciseTypeConfig.toProto()) .build() - companion object { + public companion object { @JvmField - val CREATOR: Parcelable.Creator = newCreator { bytes -> - val proto = RequestsProto.UpdateExerciseTypeConfigRequest.parseFrom(bytes) - UpdateExerciseTypeConfigRequest( - proto.packageName, - ExerciseTypeConfig.fromProto(proto.config), - ) - } + public val CREATOR: Parcelable.Creator = + newCreator { bytes -> + val proto = RequestsProto.UpdateExerciseTypeConfigRequest.parseFrom(bytes) + UpdateExerciseTypeConfigRequest( + proto.packageName, + ExerciseTypeConfig.fromProto(proto.config), + ) + } } } diff --git a/hilt/hilt-compiler/build.gradle b/hilt/hilt-compiler/build.gradle index d25b6251eafbb..7e0aa2cf9ca48 100644 --- a/hilt/hilt-compiler/build.gradle +++ b/hilt/hilt-compiler/build.gradle @@ -75,5 +75,4 @@ androidx { mavenVersion = LibraryVersions.HILT inceptionYear = "2020" description = "AndroidX Hilt Extension Compiler" - kotlinTarget = KotlinTarget.KOTLIN_2_2 } diff --git a/hilt/hilt-lifecycle-viewmodel-compose/build.gradle b/hilt/hilt-lifecycle-viewmodel-compose/build.gradle index 4547da8fa4aa7..d6a8352e11b93 100644 --- a/hilt/hilt-lifecycle-viewmodel-compose/build.gradle +++ b/hilt/hilt-lifecycle-viewmodel-compose/build.gradle @@ -56,7 +56,6 @@ androidx { mavenVersion = LibraryVersions.HILT inceptionYear = "2025" description = "ViewModel Compose Hilt Extension" - kotlinTarget = KotlinTarget.KOTLIN_2_2 } android { diff --git a/hilt/hilt-lifecycle-viewmodel/build.gradle b/hilt/hilt-lifecycle-viewmodel/build.gradle index 1b5ece1fa8ddc..7e8e698c501fb 100644 --- a/hilt/hilt-lifecycle-viewmodel/build.gradle +++ b/hilt/hilt-lifecycle-viewmodel/build.gradle @@ -39,7 +39,6 @@ androidx { mavenVersion = LibraryVersions.HILT inceptionYear = "2025" description = "ViewModel Hilt Extension" - kotlinTarget = KotlinTarget.KOTLIN_2_2 } android { diff --git a/hilt/hilt-navigation-compose/build.gradle b/hilt/hilt-navigation-compose/build.gradle index 80f70b1f9762c..99c2500ece7ea 100644 --- a/hilt/hilt-navigation-compose/build.gradle +++ b/hilt/hilt-navigation-compose/build.gradle @@ -80,6 +80,5 @@ androidx { description = "Navigation Compose Hilt Integration" legacyDisableKotlinStrictApiMode = true samples(project(":hilt:hilt-navigation-compose-samples")) - kotlinTarget = KotlinTarget.KOTLIN_2_2 } diff --git a/hilt/hilt-navigation-compose/samples/build.gradle b/hilt/hilt-navigation-compose/samples/build.gradle index e6fa5dc1ec5ba..a97c7c73222f7 100644 --- a/hilt/hilt-navigation-compose/samples/build.gradle +++ b/hilt/hilt-navigation-compose/samples/build.gradle @@ -42,7 +42,6 @@ androidx { mavenVersion = LibraryVersions.HILT_NAVIGATION_COMPOSE inceptionYear = "2021" description = "Samples for the Navigation Compose Hilt Integration" - kotlinTarget = KotlinTarget.KOTLIN_2_2 } android { diff --git a/hilt/hilt-navigation-fragment/build.gradle b/hilt/hilt-navigation-fragment/build.gradle index b9c21f585fa13..0e41b1b294d90 100644 --- a/hilt/hilt-navigation-fragment/build.gradle +++ b/hilt/hilt-navigation-fragment/build.gradle @@ -69,6 +69,5 @@ androidx { inceptionYear = "2021" description = "Android Navigation Fragment Hilt Extension" legacyDisableKotlinStrictApiMode = true - kotlinTarget = KotlinTarget.KOTLIN_2_2 } diff --git a/hilt/hilt-navigation/build.gradle b/hilt/hilt-navigation/build.gradle index 1549fb928ee26..30aa5ed38ee11 100644 --- a/hilt/hilt-navigation/build.gradle +++ b/hilt/hilt-navigation/build.gradle @@ -45,7 +45,6 @@ androidx { inceptionYear = "2021" description = "Android Navigation Hilt Extension" legacyDisableKotlinStrictApiMode = true - kotlinTarget = KotlinTarget.KOTLIN_2_2 } android { diff --git a/hilt/hilt-work/build.gradle b/hilt/hilt-work/build.gradle index 63689cc8e5350..29aede8cdbf14 100644 --- a/hilt/hilt-work/build.gradle +++ b/hilt/hilt-work/build.gradle @@ -48,5 +48,4 @@ androidx { mavenVersion = LibraryVersions.HILT inceptionYear = "2020" description = "Android Lifecycle WorkManager Hilt Extension" - kotlinTarget = KotlinTarget.KOTLIN_2_2 } diff --git a/ink/ink-strokes/build.gradle b/ink/ink-strokes/build.gradle index 73121daf7ae41..e724f4aa0bea7 100644 --- a/ink/ink-strokes/build.gradle +++ b/ink/ink-strokes/build.gradle @@ -35,7 +35,7 @@ androidXMultiplatform { sourceSets { commonMain.dependencies { - api("androidx.annotation:annotation:1.11.0-alpha02") + api("androidx.annotation:annotation:1.11.0") implementation(project(":ink:ink-brush")) implementation(project(":ink:ink-geometry")) implementation(project(":ink:ink-nativeloader")) diff --git a/navigationevent/navigationevent-compose/build.gradle b/navigationevent/navigationevent-compose/build.gradle index 33f8b7818f587..f24c2b0b78271 100644 --- a/navigationevent/navigationevent-compose/build.gradle +++ b/navigationevent/navigationevent-compose/build.gradle @@ -100,7 +100,7 @@ dependencies.constraints { // Prevents symbols duplication with old versions of JetBrains' fork. // Starting with Compose Multiplatform 1.11.0, this module is published as empty // artifact with dependency to this androidx module. - commonMainImplementation("org.jetbrains.androidx.navigationevent:navigationevent-compose:1.1.0-rc01") { + commonMainImplementation("org.jetbrains.androidx.navigationevent:navigationevent-compose:1.1.0") { because "prevents symbols duplication" } } diff --git a/room3/integration-tests/autovaluetestapp/build.gradle b/room3/integration-tests/autovaluetestapp/build.gradle index 9df886c973f47..a240f272a6de2 100644 --- a/room3/integration-tests/autovaluetestapp/build.gradle +++ b/room3/integration-tests/autovaluetestapp/build.gradle @@ -62,5 +62,4 @@ tasks.withType(JavaCompile) { } androidx { - kotlinTarget = KotlinTarget.KOTLIN_2_2 } diff --git a/room3/integration-tests/kotlintestapp/build.gradle b/room3/integration-tests/kotlintestapp/build.gradle index 839f19b5f0ed6..78afbc1ef6f35 100644 --- a/room3/integration-tests/kotlintestapp/build.gradle +++ b/room3/integration-tests/kotlintestapp/build.gradle @@ -109,6 +109,5 @@ room3 { } androidx { - kotlinTarget = KotlinTarget.KOTLIN_2_2 deviceTests.minSdkForFtlOverride = 25 // b/539512913 } diff --git a/room3/integration-tests/multiplatformtestapp/build.gradle b/room3/integration-tests/multiplatformtestapp/build.gradle index 1f5a2c513241a..bc1be68e02d37 100644 --- a/room3/integration-tests/multiplatformtestapp/build.gradle +++ b/room3/integration-tests/multiplatformtestapp/build.gradle @@ -154,7 +154,6 @@ room3 { } androidx { - kotlinTarget = KotlinTarget.KOTLIN_2_2 } afterEvaluate { diff --git a/room3/integration-tests/multiplatformtestapp/library/build.gradle b/room3/integration-tests/multiplatformtestapp/library/build.gradle index be7ebf04237e6..ff6e031f7a816 100644 --- a/room3/integration-tests/multiplatformtestapp/library/build.gradle +++ b/room3/integration-tests/multiplatformtestapp/library/build.gradle @@ -43,5 +43,4 @@ androidXMultiplatform { } androidx { - kotlinTarget = KotlinTarget.KOTLIN_2_2 } diff --git a/sqlite/sqlite-web-worker-test/build.gradle b/sqlite/sqlite-web-worker-test/build.gradle index 4965bd8f2502c..f2378e3a3b2ea 100644 --- a/sqlite/sqlite-web-worker-test/build.gradle +++ b/sqlite/sqlite-web-worker-test/build.gradle @@ -51,5 +51,4 @@ androidx { type = SoftwareType.INTERNAL_TEST_LIBRARY inceptionYear = "2026" description = "The Web Worker implementation of the SQLite Web driver for tests using the SQLite WASM project" - kotlinTarget = KotlinTarget.KOTLIN_2_2 } diff --git a/sqlite/sqlite-web/build.gradle b/sqlite/sqlite-web/build.gradle index 295271dd4e610..8dd29ba6d4367 100644 --- a/sqlite/sqlite-web/build.gradle +++ b/sqlite/sqlite-web/build.gradle @@ -59,5 +59,4 @@ androidx { type = SoftwareType.PUBLISHED_LIBRARY inceptionYear = "2026" description = "The implementation of SQLite Web library using a Web Worker" - kotlinTarget = KotlinTarget.KOTLIN_2_2 } diff --git a/test/backup/backup-host/build.gradle b/test/backup/backup-host/build.gradle index 8463554f104be..df327e850129c 100644 --- a/test/backup/backup-host/build.gradle +++ b/test/backup/backup-host/build.gradle @@ -42,7 +42,6 @@ dependencies { } androidx { - kotlinTarget = androidx.build.KotlinTarget.KOTLIN_2_2 name = "Backup Host" type = SoftwareType.PUBLISHED_LIBRARY inceptionYear = "2026" diff --git a/wear/compose/remote/remote-material3/api/current.txt b/wear/compose/remote/remote-material3/api/current.txt index 27a2e1cb9038f..a11a416f2a1d3 100644 --- a/wear/compose/remote/remote-material3/api/current.txt +++ b/wear/compose/remote/remote-material3/api/current.txt @@ -59,6 +59,8 @@ package androidx.wear.compose.remote.material3 { method @BytecodeOnly @androidx.compose.runtime.Composable public androidx.wear.compose.remote.material3.RemoteButtonColors buttonColors(androidx.compose.remote.creation.compose.state.RemoteColor?, androidx.compose.remote.creation.compose.state.RemoteColor?, androidx.compose.remote.creation.compose.state.RemoteColor?, androidx.compose.remote.creation.compose.state.RemoteColor?, androidx.compose.remote.creation.compose.state.RemoteColor?, androidx.compose.remote.creation.compose.state.RemoteColor?, androidx.compose.remote.creation.compose.state.RemoteColor?, androidx.compose.remote.creation.compose.state.RemoteColor?, androidx.compose.runtime.Composer?, int, int); method @BytecodeOnly @androidx.compose.runtime.Composable public androidx.wear.compose.remote.material3.RemoteButtonColors buttonColors(androidx.compose.runtime.Composer?, int); method @KotlinOnly @androidx.compose.runtime.Composable public androidx.wear.compose.remote.material3.RemoteButtonColors buttonWithContainerPainterColors(); + method @KotlinOnly @androidx.compose.runtime.Composable public androidx.wear.compose.remote.material3.RemoteButtonColors buttonWithContainerPainterColors(optional androidx.compose.remote.creation.compose.state.RemoteColor? contentColor, optional androidx.compose.remote.creation.compose.state.RemoteColor? secondaryContentColor, optional androidx.compose.remote.creation.compose.state.RemoteColor? iconColor, optional androidx.compose.remote.creation.compose.state.RemoteColor? disabledContentColor, optional androidx.compose.remote.creation.compose.state.RemoteColor? disabledSecondaryContentColor, optional androidx.compose.remote.creation.compose.state.RemoteColor? disabledIconColor); + method @BytecodeOnly @androidx.compose.runtime.Composable public androidx.wear.compose.remote.material3.RemoteButtonColors buttonWithContainerPainterColors(androidx.compose.remote.creation.compose.state.RemoteColor?, androidx.compose.remote.creation.compose.state.RemoteColor?, androidx.compose.remote.creation.compose.state.RemoteColor?, androidx.compose.remote.creation.compose.state.RemoteColor?, androidx.compose.remote.creation.compose.state.RemoteColor?, androidx.compose.remote.creation.compose.state.RemoteColor?, androidx.compose.runtime.Composer?, int, int); method @BytecodeOnly @androidx.compose.runtime.Composable public androidx.wear.compose.remote.material3.RemoteButtonColors buttonWithContainerPainterColors(androidx.compose.runtime.Composer?, int); method @KotlinOnly @androidx.compose.runtime.Composable public androidx.wear.compose.remote.material3.RemoteButtonColors childButtonColors(); method @KotlinOnly @androidx.compose.runtime.Composable public androidx.wear.compose.remote.material3.RemoteButtonColors childButtonColors(optional androidx.compose.remote.creation.compose.state.RemoteColor? contentColor, optional androidx.compose.remote.creation.compose.state.RemoteColor? secondaryContentColor, optional androidx.compose.remote.creation.compose.state.RemoteColor? iconColor, optional androidx.compose.remote.creation.compose.state.RemoteColor? disabledContentColor, optional androidx.compose.remote.creation.compose.state.RemoteColor? disabledSecondaryContentColor, optional androidx.compose.remote.creation.compose.state.RemoteColor? disabledIconColor); diff --git a/wear/compose/remote/remote-material3/api/restricted_current.txt b/wear/compose/remote/remote-material3/api/restricted_current.txt index 27a2e1cb9038f..a11a416f2a1d3 100644 --- a/wear/compose/remote/remote-material3/api/restricted_current.txt +++ b/wear/compose/remote/remote-material3/api/restricted_current.txt @@ -59,6 +59,8 @@ package androidx.wear.compose.remote.material3 { method @BytecodeOnly @androidx.compose.runtime.Composable public androidx.wear.compose.remote.material3.RemoteButtonColors buttonColors(androidx.compose.remote.creation.compose.state.RemoteColor?, androidx.compose.remote.creation.compose.state.RemoteColor?, androidx.compose.remote.creation.compose.state.RemoteColor?, androidx.compose.remote.creation.compose.state.RemoteColor?, androidx.compose.remote.creation.compose.state.RemoteColor?, androidx.compose.remote.creation.compose.state.RemoteColor?, androidx.compose.remote.creation.compose.state.RemoteColor?, androidx.compose.remote.creation.compose.state.RemoteColor?, androidx.compose.runtime.Composer?, int, int); method @BytecodeOnly @androidx.compose.runtime.Composable public androidx.wear.compose.remote.material3.RemoteButtonColors buttonColors(androidx.compose.runtime.Composer?, int); method @KotlinOnly @androidx.compose.runtime.Composable public androidx.wear.compose.remote.material3.RemoteButtonColors buttonWithContainerPainterColors(); + method @KotlinOnly @androidx.compose.runtime.Composable public androidx.wear.compose.remote.material3.RemoteButtonColors buttonWithContainerPainterColors(optional androidx.compose.remote.creation.compose.state.RemoteColor? contentColor, optional androidx.compose.remote.creation.compose.state.RemoteColor? secondaryContentColor, optional androidx.compose.remote.creation.compose.state.RemoteColor? iconColor, optional androidx.compose.remote.creation.compose.state.RemoteColor? disabledContentColor, optional androidx.compose.remote.creation.compose.state.RemoteColor? disabledSecondaryContentColor, optional androidx.compose.remote.creation.compose.state.RemoteColor? disabledIconColor); + method @BytecodeOnly @androidx.compose.runtime.Composable public androidx.wear.compose.remote.material3.RemoteButtonColors buttonWithContainerPainterColors(androidx.compose.remote.creation.compose.state.RemoteColor?, androidx.compose.remote.creation.compose.state.RemoteColor?, androidx.compose.remote.creation.compose.state.RemoteColor?, androidx.compose.remote.creation.compose.state.RemoteColor?, androidx.compose.remote.creation.compose.state.RemoteColor?, androidx.compose.remote.creation.compose.state.RemoteColor?, androidx.compose.runtime.Composer?, int, int); method @BytecodeOnly @androidx.compose.runtime.Composable public androidx.wear.compose.remote.material3.RemoteButtonColors buttonWithContainerPainterColors(androidx.compose.runtime.Composer?, int); method @KotlinOnly @androidx.compose.runtime.Composable public androidx.wear.compose.remote.material3.RemoteButtonColors childButtonColors(); method @KotlinOnly @androidx.compose.runtime.Composable public androidx.wear.compose.remote.material3.RemoteButtonColors childButtonColors(optional androidx.compose.remote.creation.compose.state.RemoteColor? contentColor, optional androidx.compose.remote.creation.compose.state.RemoteColor? secondaryContentColor, optional androidx.compose.remote.creation.compose.state.RemoteColor? iconColor, optional androidx.compose.remote.creation.compose.state.RemoteColor? disabledContentColor, optional androidx.compose.remote.creation.compose.state.RemoteColor? disabledSecondaryContentColor, optional androidx.compose.remote.creation.compose.state.RemoteColor? disabledIconColor); diff --git a/wear/compose/remote/remote-material3/src/main/java/androidx/wear/compose/remote/material3/RemoteButton.kt b/wear/compose/remote/remote-material3/src/main/java/androidx/wear/compose/remote/material3/RemoteButton.kt index 6f592ee2d784b..1bd2a3c08a823 100644 --- a/wear/compose/remote/remote-material3/src/main/java/androidx/wear/compose/remote/material3/RemoteButton.kt +++ b/wear/compose/remote/remote-material3/src/main/java/androidx/wear/compose/remote/material3/RemoteButton.kt @@ -613,13 +613,14 @@ public object RemoteButtonDefaults { * * @param containerColor The background color of this [RemoteButton] when enabled * @param contentColor The content color of this [RemoteButton] when enabled - * @param secondaryContentColor The content color of this [RemoteButton] when enabled - * @param iconColor The content color of this [RemoteButton] when enabled + * @param secondaryContentColor The secondary content color of this [RemoteButton] when enabled, + * used for secondaryLabel content + * @param iconColor The icon color of this [RemoteButton] when enabled, used for icon content * @param disabledContainerColor The background color of this [RemoteButton] when not enabled * @param disabledContentColor The content color of this [RemoteButton] when not enabled - * @param disabledSecondaryContentColor The content color of this [RemoteButton] when not - * enabled - * @param disabledIconColor The content color of this [RemoteButton] when not enabled + * @param disabledSecondaryContentColor The secondary content color of this [RemoteButton] when + * not enabled + * @param disabledIconColor The icon color of this [RemoteButton] when not enabled */ @Composable public fun buttonColors( @@ -663,6 +664,17 @@ public object RemoteButtonDefaults { /** * Creates a [RemoteButtonColors] with a muted background and contrasting content color, the * defaults for medium emphasis buttons. + * + * @param containerColor The background color of this [RemoteButton] when enabled + * @param contentColor The content color of this [RemoteButton] when enabled + * @param secondaryContentColor The secondary content color of this [RemoteButton] when enabled, + * used for secondaryLabel content + * @param iconColor The icon color of this [RemoteButton] when enabled, used for icon content + * @param disabledContainerColor The background color of this [RemoteButton] when not enabled + * @param disabledContentColor The content color of this [RemoteButton] when not enabled + * @param disabledSecondaryContentColor The secondary content color of this [RemoteButton] when + * not enabled + * @param disabledIconColor The icon color of this [RemoteButton] when not enabled */ @Composable public fun filledTonalButtonColors( @@ -694,7 +706,20 @@ public object RemoteButtonDefaults { public fun filledVariantButtonColors(): RemoteButtonColors = RemoteMaterialTheme.colorScheme.defaultFilledVariantButtonColors - /** Creates a [RemoteButtonColors] with higher chroma container colors. */ + /** + * Creates a [RemoteButtonColors] with higher chroma container colors. + * + * @param containerColor The background color of this [RemoteButton] when enabled + * @param contentColor The content color of this [RemoteButton] when enabled + * @param secondaryContentColor The secondary content color of this [RemoteButton] when enabled, + * used for secondaryLabel content + * @param iconColor The icon color of this [RemoteButton] when enabled, used for icon content + * @param disabledContainerColor The background color of this [RemoteButton] when not enabled + * @param disabledContentColor The content color of this [RemoteButton] when not enabled + * @param disabledSecondaryContentColor The secondary content color of this [RemoteButton] when + * not enabled + * @param disabledIconColor The icon color of this [RemoteButton] when not enabled + */ @Composable public fun filledVariantButtonColors( containerColor: RemoteColor? = null, @@ -725,7 +750,18 @@ public object RemoteButtonDefaults { public fun outlinedButtonColors(): RemoteButtonColors = RemoteMaterialTheme.colorScheme.defaultOutlinedButtonColors - /** Creates a [RemoteButtonColors] with a transparent background for outlined buttons. */ + /** + * Creates a [RemoteButtonColors] with a transparent background for outlined buttons. + * + * @param contentColor The content color of this [RemoteButton] when enabled + * @param secondaryContentColor The secondary content color of this [RemoteButton] when enabled, + * used for secondaryLabel content + * @param iconColor The icon color of this [RemoteButton] when enabled, used for icon content + * @param disabledContentColor The content color of this [RemoteButton] when not enabled + * @param disabledSecondaryContentColor The secondary content color of this [RemoteButton] when + * not enabled + * @param disabledIconColor The icon color of this [RemoteButton] when not enabled + */ @Composable public fun outlinedButtonColors( contentColor: RemoteColor? = null, @@ -798,6 +834,40 @@ public object RemoteButtonDefaults { public fun buttonWithContainerPainterColors(): RemoteButtonColors = RemoteMaterialTheme.colorScheme.defaultButtonWithContainerPainterColors + /** + * Creates a [RemoteButtonColors] for the content in a [RemoteButton] with an image container + * painter. + * + * @param contentColor The content color of this [RemoteButton] when enabled + * @param secondaryContentColor The secondary content color of this [RemoteButton] when enabled, + * used for secondaryLabel content + * @param iconColor The icon color of this [RemoteButton] when enabled, used for icon content + * @param disabledContentColor The content color of this [RemoteButton] when not enabled + * @param disabledSecondaryContentColor The secondary content color of this [RemoteButton] when + * not enabled + * @param disabledIconColor The icon color of this [RemoteButton] when not enabled + */ + @Composable + public fun buttonWithContainerPainterColors( + contentColor: RemoteColor? = null, + secondaryContentColor: RemoteColor? = null, + iconColor: RemoteColor? = null, + disabledContentColor: RemoteColor? = null, + disabledSecondaryContentColor: RemoteColor? = null, + disabledIconColor: RemoteColor? = null, + ): RemoteButtonColors { + val default = RemoteMaterialTheme.colorScheme.defaultButtonWithContainerPainterColors + return default.copy( + contentColor = contentColor ?: default.contentColor, + secondaryContentColor = secondaryContentColor ?: default.secondaryContentColor, + iconColor = iconColor ?: default.iconColor, + disabledContentColor = disabledContentColor ?: default.disabledContentColor, + disabledSecondaryContentColor = + disabledSecondaryContentColor ?: default.disabledSecondaryContentColor, + disabledIconColor = disabledIconColor ?: default.disabledIconColor, + ) + } + /** * Creates a [RemoteButtonColors] for the content in a [RemoteButton], returns default * [buttonColors] if painter is null, else return [defaultButtonWithContainerPainterColors] @@ -1039,6 +1109,8 @@ public object RemoteButtonDefaults { /** * Creates a [RemoteBrush] for the recommended scrim drawn on top of image container * backgrounds. + * + * @param size The size of the scrim brush gradient. */ @Composable public fun scrimBrush(size: RemoteSize): RemoteBrush { @@ -1058,13 +1130,14 @@ public object RemoteButtonDefaults { * @param containerColor The background color of this [RemoteButton] when enabled (overridden by the * containerPainter parameter on Buttons with image backgrounds). * @param contentColor The content color of this [RemoteButton] when enabled. - * @param secondaryContentColor The content color of this [RemoteButton] when enabled. - * @param iconColor The content color of this [RemoteButton] when enabled. + * @param secondaryContentColor The secondary content color of this [RemoteButton] when enabled. + * @param iconColor The icon color of this [RemoteButton] when enabled. * @param disabledContainerColor The background color of this [RemoteButton] when not enabled * (overridden by the disabledContainerPainter parameter on Buttons with image backgrounds) * @param disabledContentColor The content color of this [RemoteButton] when not enabled. - * @param disabledSecondaryContentColor The content color of this [RemoteButton] when not enabled. - * @param disabledIconColor The content color of this [RemoteButton] when not enabled. + * @param disabledSecondaryContentColor The secondary content color of this [RemoteButton] when not + * enabled. + * @param disabledIconColor The icon color of this [RemoteButton] when not enabled. */ @Immutable public class RemoteButtonColors( @@ -1095,7 +1168,19 @@ public class RemoteButtonColors( ) } - /** Returns a copy of this RemoteButtonColors optionally overriding some of the values. */ + /** + * Returns a copy of this [RemoteButtonColors], optionally overriding some of the values. + * + * @param containerColor The background color of this [RemoteButton] when enabled + * @param contentColor The content color of this [RemoteButton] when enabled + * @param secondaryContentColor The secondary content color of this [RemoteButton] when enabled + * @param iconColor The icon color of this [RemoteButton] when enabled + * @param disabledContainerColor The background color of this [RemoteButton] when not enabled + * @param disabledContentColor The content color of this [RemoteButton] when not enabled + * @param disabledSecondaryContentColor The secondary content color of this [RemoteButton] when + * not enabled + * @param disabledIconColor The icon color of this [RemoteButton] when not enabled + */ public fun copy( containerColor: RemoteColor? = this.containerColor, contentColor: RemoteColor? = this.contentColor, diff --git a/wear/compose/remote/remote-material3/src/test/java/androidx/wear/compose/remote/material3/RemoteButtonColorsTest.kt b/wear/compose/remote/remote-material3/src/test/java/androidx/wear/compose/remote/material3/RemoteButtonColorsTest.kt index 93d49f089b5f9..0ddc6847d1c49 100644 --- a/wear/compose/remote/remote-material3/src/test/java/androidx/wear/compose/remote/material3/RemoteButtonColorsTest.kt +++ b/wear/compose/remote/remote-material3/src/test/java/androidx/wear/compose/remote/material3/RemoteButtonColorsTest.kt @@ -99,15 +99,15 @@ class RemoteButtonColorsTest { @Test fun buttonWithContainerPainterColors_overridesColors() { - lateinit var base: RemoteButtonColors + lateinit var customized: RemoteButtonColors + composeTestRule.setContent { - base = RemoteButtonDefaults.buttonWithContainerPainterColors() + customized = + RemoteButtonDefaults.buttonWithContainerPainterColors( + contentColor = RemoteColor(Color.Yellow), + secondaryContentColor = RemoteColor(Color.Cyan), + ) } - val customized = - base.copy( - contentColor = RemoteColor(Color.Yellow), - secondaryContentColor = RemoteColor(Color.Cyan), - ) assertEquals(Color.Transparent, customized.containerColor.constantValue) assertEquals(Color.Transparent, customized.disabledContainerColor.constantValue) diff --git a/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/ConstrainedImageDecoder.kt b/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/ConstrainedImageDecoder.kt index 34aea846f3554..e0a0ce81a8b09 100644 --- a/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/ConstrainedImageDecoder.kt +++ b/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/ConstrainedImageDecoder.kt @@ -135,7 +135,9 @@ internal object ConstrainedImageDecoder { private fun checkSize(imageSize: Size) { if ( - imageSize.width > DEFAULT_DECODE_HARD_LIMIT_PX || + imageSize.width <= 0 || + imageSize.height <= 0 || + imageSize.width > DEFAULT_DECODE_HARD_LIMIT_PX || imageSize.height > DEFAULT_DECODE_HARD_LIMIT_PX ) { throw IllegalArgumentException( diff --git a/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/DefaultInlineImageResourceResolver.java b/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/DefaultInlineImageResourceResolver.java index c613a4009d09a..573cecd9746d9 100644 --- a/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/DefaultInlineImageResourceResolver.java +++ b/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/DefaultInlineImageResourceResolver.java @@ -148,14 +148,34 @@ private int getBytesPerPixel(Config config) { inlineImage.getWidthPx(), inlineImage.getHeightPx()); } - Bitmap bitmap = - BitmapFactory.decodeByteArray( - inlineImage.getData().toByteArray(), 0, inlineImage.getData().size()); + int widthPx = inlineImage.getWidthPx(); + int heightPx = inlineImage.getHeightPx(); + byte[] data = inlineImage.getData().toByteArray(); + if (mRestrictImageSize) { + if (widthPx <= 0 + || heightPx <= 0 + || widthPx > ConstrainedImageDecoder.DEFAULT_DECODE_HARD_LIMIT_PX + || heightPx > ConstrainedImageDecoder.DEFAULT_DECODE_HARD_LIMIT_PX) { + throw new IllegalArgumentException( + "InlineImage target size out of bounds: " + widthPx + "x" + heightPx); + } + BitmapFactory.Options options = new BitmapFactory.Options(); + options.inJustDecodeBounds = true; + BitmapFactory.decodeByteArray(data, 0, data.length, options); + if (options.outWidth > ConstrainedImageDecoder.DEFAULT_DECODE_HARD_LIMIT_PX + || options.outHeight > ConstrainedImageDecoder.DEFAULT_DECODE_HARD_LIMIT_PX) { + throw new IllegalArgumentException( + "InlineImage decoded size out of bounds: " + + options.outWidth + + "x" + + options.outHeight); + } + } + Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, data.length); if (bitmap == null) { Log.e(TAG, "Unable to load structured bitmap."); return null; } - return Bitmap.createScaledBitmap( - bitmap, inlineImage.getWidthPx(), inlineImage.getHeightPx(), /* filter= */ true); + return Bitmap.createScaledBitmap(bitmap, widthPx, heightPx, /* filter= */ true); } } diff --git a/wear/protolayout/protolayout-renderer/src/test/java/androidx/wear/protolayout/renderer/inflater/ConstrainedImageDecoderTest.kt b/wear/protolayout/protolayout-renderer/src/test/java/androidx/wear/protolayout/renderer/inflater/ConstrainedImageDecoderTest.kt index dde0de1026b8e..f780115dcf476 100644 --- a/wear/protolayout/protolayout-renderer/src/test/java/androidx/wear/protolayout/renderer/inflater/ConstrainedImageDecoderTest.kt +++ b/wear/protolayout/protolayout-renderer/src/test/java/androidx/wear/protolayout/renderer/inflater/ConstrainedImageDecoderTest.kt @@ -298,6 +298,17 @@ class ConstrainedImageDecoderTest { } } + @Test + fun decodeBitmap_imageResource_nonPositiveTargetSize_throws() { + assertFailsWith { + ConstrainedImageDecoder.decodeBitmap( + getBytes(R.drawable.filled_image), + targetWidthPx = 0, + targetHeightPx = REASONABLE_SIZE_PX, + ) + } + } + @Test fun decodeBitmap_largeImageResource_throws() { assertFailsWith { diff --git a/wear/protolayout/protolayout-renderer/src/test/java/androidx/wear/protolayout/renderer/inflater/DefaultInlineImageResourceResolverTest.java b/wear/protolayout/protolayout-renderer/src/test/java/androidx/wear/protolayout/renderer/inflater/DefaultInlineImageResourceResolverTest.java index cfadaeaf1a26f..9f9c1d3c8df3e 100644 --- a/wear/protolayout/protolayout-renderer/src/test/java/androidx/wear/protolayout/renderer/inflater/DefaultInlineImageResourceResolverTest.java +++ b/wear/protolayout/protolayout-renderer/src/test/java/androidx/wear/protolayout/renderer/inflater/DefaultInlineImageResourceResolverTest.java @@ -21,13 +21,17 @@ import static org.junit.Assert.assertThrows; import android.graphics.Bitmap; +import android.os.Build.VERSION_CODES; import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.wear.protolayout.proto.ResourceProto.ImageFormat; import androidx.wear.protolayout.proto.ResourceProto.InlineImageResource; import androidx.wear.protolayout.protobuf.ByteString; import androidx.wear.protolayout.renderer.inflater.ResourceResolvers.ResourceAccessException; +import androidx.wear.protolayout.renderer.test.R; +import java.io.IOException; import org.junit.Test; import org.junit.runner.RunWith; +import org.robolectric.annotation.Config; @RunWith(AndroidJUnit4.class) public class DefaultInlineImageResourceResolverTest { @@ -134,6 +138,93 @@ public void loadStructuredBitmap_linearDimensionTooLarge_throws() { assertThrows(IllegalArgumentException.class, () -> mResolver.loadStructuredBitmap(resource)); } + @Test + public void loadStructuredBitmap_nonPositiveDimension_throws() { + byte[] minPng = getMinPng(); + + InlineImageResource resource = + InlineImageResource.newBuilder() + .setWidthPx(0) + .setHeightPx(10) + .setFormat(ImageFormat.IMAGE_FORMAT_UNDEFINED) + .setData(ByteString.copyFrom(minPng)) + .build(); + + assertThrows(IllegalArgumentException.class, () -> mResolver.loadStructuredBitmap(resource)); + } + + @Test + @Config(sdk = VERSION_CODES.R) + public void loadStructuredBitmap_sdk30_validImage_succeeds() { + byte[] minPng = getMinPng(); + int width = 10; + int height = 10; + + InlineImageResource resource = + InlineImageResource.newBuilder() + .setWidthPx(width) + .setHeightPx(height) + .setFormat(ImageFormat.IMAGE_FORMAT_UNDEFINED) + .setData(ByteString.copyFrom(minPng)) + .build(); + + Bitmap bitmap = mResolver.loadStructuredBitmap(resource); + + assertThat(bitmap).isNotNull(); + assertThat(bitmap.getWidth()).isEqualTo(width); + assertThat(bitmap.getHeight()).isEqualTo(height); + } + + @Test + @Config(sdk = VERSION_CODES.R) + public void loadStructuredBitmap_sdk30_linearDimensionTooLarge_throws() { + byte[] minPng = getMinPng(); + + InlineImageResource resource = + InlineImageResource.newBuilder() + .setWidthPx(2049) // Exceeds the 2048px limit + .setHeightPx(1) + .setFormat(ImageFormat.IMAGE_FORMAT_UNDEFINED) + .setData(ByteString.copyFrom(minPng)) + .build(); + + assertThrows(IllegalArgumentException.class, () -> mResolver.loadStructuredBitmap(resource)); + } + + @Test + @Config(sdk = VERSION_CODES.R) + public void loadStructuredBitmap_sdk30_nonPositiveDimension_throws() { + byte[] minPng = getMinPng(); + + InlineImageResource resource = + InlineImageResource.newBuilder() + .setWidthPx(0) + .setHeightPx(10) + .setFormat(ImageFormat.IMAGE_FORMAT_UNDEFINED) + .setData(ByteString.copyFrom(minPng)) + .build(); + + assertThrows(IllegalArgumentException.class, () -> mResolver.loadStructuredBitmap(resource)); + } + + @Test + @Config(sdk = VERSION_CODES.R) + public void loadStructuredBitmap_sdk30_encodedDimensionTooLarge_throws() throws IOException { + ByteString largeImageBytes = + ByteString.readFrom( + getApplicationContext().getResources().openRawResource(R.drawable.test2049x2049)); + + InlineImageResource resource = + InlineImageResource.newBuilder() + .setWidthPx(10) + .setHeightPx(10) + .setFormat(ImageFormat.IMAGE_FORMAT_UNDEFINED) + .setData(largeImageBytes) + .build(); + + assertThrows(IllegalArgumentException.class, () -> mResolver.loadStructuredBitmap(resource)); + } + private static byte[] getMinPng() { return new byte[] { (byte) 0x89, diff --git a/window/window-core/build.gradle b/window/window-core/build.gradle index d20fbb8e4e673..75d8c6ba89ece 100644 --- a/window/window-core/build.gradle +++ b/window/window-core/build.gradle @@ -64,10 +64,9 @@ androidXMultiplatform { dependencies { constraints { // Prevents symbols duplication with old versions of JetBrains' fork. - // Starting with version 1.5.0-beta01, this module is published as empty artifact with dependency + // Starting with version 1.5.0, this module is published as empty artifact with dependency // to this androidx module. - // TODO: update this stable version once out - commonMainImplementation("org.jetbrains.androidx.window:window-core:1.5.0-beta01") { + commonMainImplementation("org.jetbrains.androidx.window:window-core:1.5.0") { because "prevents symbols duplication" } } diff --git a/xr/glimmer/glimmer-google-fonts/build.gradle b/xr/glimmer/glimmer-google-fonts/build.gradle index 9642bd649dfea..3daafe32a7c11 100644 --- a/xr/glimmer/glimmer-google-fonts/build.gradle +++ b/xr/glimmer/glimmer-google-fonts/build.gradle @@ -24,7 +24,7 @@ plugins { dependencies { api(project(":xr:glimmer:glimmer")) - implementation("androidx.compose.ui:ui-text-google-fonts:1.12.0-beta02") + implementation("androidx.compose.ui:ui-text-google-fonts:1.12.0") androidTestImplementation(project(":compose:ui:ui-test")) androidTestImplementation(project(":compose:ui:ui-test-junit4"))