Skip to content

Commit b87c68d

Browse files
yschimkeGerrit Code Review
authored andcommitted
Merge "Expose Remote Composable and Modifier types" into androidx-main
2 parents 2061d4f + c6ddcca commit b87c68d

56 files changed

Lines changed: 858 additions & 252 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎compose/remote/remote-creation-compose/api/current.txt‎

Lines changed: 189 additions & 6 deletions
Large diffs are not rendered by default.

‎compose/remote/remote-creation-compose/api/restricted_current.txt‎

Lines changed: 189 additions & 6 deletions
Large diffs are not rendered by default.

‎compose/remote/remote-creation-compose/src/androidTest/java/androidx/compose/remote/creation/compose/modifier/PaddingModifierTest.kt‎

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@ import android.graphics.Bitmap
2020
import android.graphics.Canvas
2121
import androidx.compose.remote.core.CoreDocument
2222
import androidx.compose.remote.creation.compose.capture.RemoteComposeCreationState
23+
import androidx.compose.remote.creation.compose.state.rdp
24+
import androidx.compose.remote.creation.compose.state.rf
2325
import androidx.compose.remote.creation.platform.AndroidxRcPlatformServices
2426
import androidx.compose.remote.player.core.platform.AndroidRemoteContext
2527
import androidx.compose.ui.geometry.Size
2628
import androidx.compose.ui.test.junit4.v2.createComposeRule
27-
import androidx.compose.ui.unit.dp
2829
import androidx.test.ext.junit.runners.AndroidJUnit4
2930
import kotlin.test.assertTrue
3031
import kotlinx.coroutines.test.StandardTestDispatcher
@@ -46,44 +47,44 @@ class PaddingModifierTest {
4647

4748
/** Tests that negative start padding is not allowed. */
4849
@Test(expected = IllegalArgumentException::class)
49-
fun negativeStartPaddingDp_throws() {
50-
composeTestRule.setContent { RemoteModifier.padding(left = (-1f).dp) }
50+
fun negativeStartPaddingPx_throws() {
51+
composeTestRule.setContent { RemoteModifier.padding(left = (-1f).rf) }
5152
}
5253

5354
/** Tests that negative top padding is not allowed. */
5455
@Test(expected = IllegalArgumentException::class)
55-
fun negativeTopPaddingDp_throws() {
56-
composeTestRule.setContent { RemoteModifier.padding(top = (-1f).dp) }
56+
fun negativeTopPaddingPx_throws() {
57+
composeTestRule.setContent { RemoteModifier.padding(top = (-1f).rf) }
5758
}
5859

5960
/** Tests that negative end padding is not allowed. */
6061
@Test(expected = IllegalArgumentException::class)
61-
fun negativeEndPaddingDp_throws() {
62-
composeTestRule.setContent { RemoteModifier.padding(right = (-1f).dp) }
62+
fun negativeEndPaddingPx_throws() {
63+
composeTestRule.setContent { RemoteModifier.padding(right = (-1f).rf) }
6364
}
6465

6566
/** Tests that negative bottom padding is not allowed. */
6667
@Test(expected = IllegalArgumentException::class)
67-
fun negativeBottomPaddingDp_throws() {
68-
composeTestRule.setContent { RemoteModifier.padding(bottom = (-1f).dp) }
68+
fun negativeBottomPaddingPx_throws() {
69+
composeTestRule.setContent { RemoteModifier.padding(bottom = (-1f).rf) }
6970
}
7071

7172
/** Tests that negative all padding is not allowed. */
7273
@Test(expected = IllegalArgumentException::class)
73-
fun negativeAllPaddingDp_throws() {
74-
composeTestRule.setContent { RemoteModifier.padding(all = (-1f).dp) }
74+
fun negativeAllPaddingPx_throws() {
75+
composeTestRule.setContent { RemoteModifier.padding(all = (-1f).rf) }
7576
}
7677

7778
/** Tests that negative horizontal padding is not allowed. */
7879
@Test(expected = IllegalArgumentException::class)
79-
fun negativeHorizontalPaddingDp_throws() {
80-
composeTestRule.setContent { RemoteModifier.padding(horizontal = (-1f).dp) }
80+
fun negativeHorizontalPaddingPx_throws() {
81+
composeTestRule.setContent { RemoteModifier.padding(horizontal = (-1f).rf) }
8182
}
8283

8384
/** Tests that negative vertical padding is not allowed. */
8485
@Test(expected = IllegalArgumentException::class)
85-
fun negativeVerticalPaddingDp_throws() {
86-
composeTestRule.setContent { RemoteModifier.padding(vertical = (-1f).dp) }
86+
fun negativeVerticalPaddingPx_throws() {
87+
composeTestRule.setContent { RemoteModifier.padding(vertical = (-1f).rf) }
8788
}
8889

8990
/** Tests that the [padding]-all and [padding] factories return equivalent modifiers. */
@@ -92,8 +93,8 @@ class PaddingModifierTest {
9293
composeTestRule.setContent {
9394
assertTrue(
9495
haveSameValues(
95-
RemoteModifier.padding(10.dp, 10.dp, 10.dp, 10.dp),
96-
RemoteModifier.padding(10.dp),
96+
RemoteModifier.padding(10.rdp, 10.rdp, 10.rdp, 10.rdp),
97+
RemoteModifier.padding(10.rdp),
9798
)
9899
)
99100
}
@@ -105,8 +106,8 @@ class PaddingModifierTest {
105106
composeTestRule.setContent {
106107
assertTrue(
107108
haveSameValues(
108-
RemoteModifier.padding(10.dp, 20.dp, 10.dp, 20.dp),
109-
RemoteModifier.padding(10.dp, 20.dp),
109+
RemoteModifier.padding(10.rdp, 20.rdp, 10.rdp, 20.rdp),
110+
RemoteModifier.padding(10.rdp, 20.rdp),
110111
)
111112
)
112113
}

‎compose/remote/remote-creation-compose/src/main/java/androidx/compose/remote/creation/compose/action/Action.kt‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
@file:RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
1716

1817
package androidx.compose.remote.creation.compose.action
1918

@@ -24,8 +23,8 @@ import androidx.compose.remote.creation.compose.state.RemoteStateScope
2423
* A RemoteCompose frontend model of Actions that can be converted to either RemoteCompose
2524
* operations or a ComposeUI lambda.
2625
*/
27-
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
2826
public interface Action {
27+
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
2928
public fun RemoteStateScope.toRemoteAction(): androidx.compose.remote.creation.actions.Action
3029

3130
public companion object {

‎compose/remote/remote-creation-compose/src/main/java/androidx/compose/remote/creation/compose/action/CombinedAction.kt‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,18 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
@file:RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
1716

1817
package androidx.compose.remote.creation.compose.action
1918

2019
import androidx.annotation.RestrictTo
20+
import androidx.compose.remote.creation.actions.Action as CreationAction
2121
import androidx.compose.remote.creation.compose.state.RemoteStateScope
2222

2323
/** Creates an action that's a composite of multiple actions. */
24-
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
2524
public class CombinedAction(public vararg val actions: Action) : Action {
26-
override fun RemoteStateScope.toRemoteAction():
27-
androidx.compose.remote.creation.actions.Action {
28-
return androidx.compose.remote.creation.actions.Action { writer ->
25+
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
26+
override fun RemoteStateScope.toRemoteAction(): CreationAction {
27+
return CreationAction { writer ->
2928
for (action in actions) {
3029
with(action) { toRemoteAction().write(writer) }
3130
}

‎compose/remote/remote-creation-compose/src/main/java/androidx/compose/remote/creation/compose/action/HostAction.kt‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
@file:RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
1716

1817
package androidx.compose.remote.creation.compose.action
1918

2019
import androidx.annotation.RestrictTo
2120
import androidx.compose.remote.core.operations.layout.modifiers.HostNamedActionOperation
22-
import androidx.compose.remote.creation.actions.HostAction
21+
import androidx.compose.remote.creation.actions.Action as CreationAction
22+
import androidx.compose.remote.creation.actions.HostAction as CreationHostAction
2323
import androidx.compose.remote.creation.compose.state.RemoteFloat
2424
import androidx.compose.remote.creation.compose.state.RemoteInt
2525
import androidx.compose.remote.creation.compose.state.RemoteState
@@ -57,17 +57,17 @@ public class HostAction(
5757
value: RemoteString,
5858
) : this(name, Type.STRING, id, value)
5959

60-
override fun RemoteStateScope.toRemoteAction():
61-
androidx.compose.remote.creation.actions.Action {
60+
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
61+
override fun RemoteStateScope.toRemoteAction(): CreationAction {
6262
val valueId = value?.id ?: -1
6363
val constantValue = name.constantValueOrNull
6464
if (id != 0) {
65-
return HostAction(id, valueId)
65+
return CreationHostAction(id, valueId)
6666
}
6767
return if (constantValue != null) {
68-
HostAction(constantValue, type.ordinal, valueId)
68+
CreationHostAction(constantValue, type.ordinal, valueId)
6969
} else {
70-
HostAction(name.id, valueId)
70+
CreationHostAction(name.id, valueId)
7171
}
7272
}
7373
}

‎compose/remote/remote-creation-compose/src/main/java/androidx/compose/remote/creation/compose/action/PendingIntentAction.kt‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,35 +13,36 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
@file:RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
1716
@file:OptIn(ExperimentalRemoteCreationComposeApi::class)
1817

1918
package androidx.compose.remote.creation.compose.action
2019

2120
import android.app.PendingIntent
2221
import androidx.annotation.RestrictTo
2322
import androidx.compose.remote.core.operations.Utils
23+
import androidx.compose.remote.creation.actions.Action as CreationAction
24+
import androidx.compose.remote.creation.actions.HostAction as CreationHostAction
2425
import androidx.compose.remote.creation.compose.ExperimentalRemoteCreationComposeApi
2526
import androidx.compose.remote.creation.compose.capture.WriterEvents
2627
import androidx.compose.remote.creation.compose.state.RemoteStateScope
2728
import androidx.compose.runtime.Composable
2829

2930
/** Create a [PendingIntentAction] to send the [PendingIntent] when invoked. */
3031
@Composable
31-
public fun pendingIntentAction(pendingIntent: PendingIntent): PendingIntentAction =
32+
public fun pendingIntentAction(pendingIntent: PendingIntent): Action =
3233
PendingIntentAction(pendingIntent)
3334

3435
/** Send the [PendingIntent] when invoked. */
3536
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
3637
public class PendingIntentAction(public val pendingIntent: PendingIntent) : Action {
3738

38-
override fun RemoteStateScope.toRemoteAction():
39-
androidx.compose.remote.creation.actions.Action {
39+
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
40+
override fun RemoteStateScope.toRemoteAction(): CreationAction {
4041
val writerCallback = document.writerCallback
4142
if (writerCallback is WriterEvents) {
4243
val index = writerCallback.storePendingIntent(pendingIntent)
4344
val valueId = document.addInteger(index)
44-
return androidx.compose.remote.creation.actions.HostAction(
45+
return CreationHostAction(
4546
ACTION_NAME,
4647
HostAction.Type.INT.ordinal,
4748
Utils.idFromLong(valueId).toInt(),

‎compose/remote/remote-creation-compose/src/main/java/androidx/compose/remote/creation/compose/action/ValueChange.kt‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
@file:RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
1716

1817
package androidx.compose.remote.creation.compose.action
1918

@@ -103,7 +102,6 @@ public fun ValueChange(value: RemoteDp, updatedValue: Int): Action {
103102
* @param updatedValue The new remote state value to apply.
104103
* @return An [Action] representing the value change.
105104
*/
106-
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
107105
public fun <T> ValueChange(
108106
remoteState: MutableRemoteState<T>,
109107
updatedValue: RemoteState<T>,

‎compose/remote/remote-creation-compose/src/main/java/androidx/compose/remote/creation/compose/layout/FitBox.kt‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ import androidx.compose.ui.draw.DrawModifier
2929
import androidx.compose.ui.graphics.drawscope.ContentDrawScope
3030

3131
/** Utility modifier to record the layout information */
32-
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
33-
public class RemoteComposeFitBoxModifier(
32+
internal class RemoteComposeFitBoxModifier(
3433
private val modifier: RemoteModifier,
3534
private val horizontalAlignment: RemoteAlignment.Horizontal = RemoteAlignment.Start,
3635
private val verticalArrangement: RemoteArrangement.Vertical = RemoteArrangement.Top,
@@ -53,6 +52,7 @@ public class RemoteComposeFitBoxModifier(
5352
* FitBox to both work as a normal Box when called within a normal Compose tree, and capture the
5453
* layout information when called within a capture pass for RemoteCompose.
5554
*/
55+
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
5656
@RemoteComposable
5757
@Composable
5858
public fun FitBox(

‎compose/remote/remote-creation-compose/src/main/java/androidx/compose/remote/creation/compose/layout/RemoteAlignment.kt‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ public object RemoteAlignment {
9090

9191
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
9292
public data class RemoteHorizontalAlignment(var type: Int) : RemoteAlignment.Horizontal {
93+
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
9394
override fun toComposeUi(): androidx.compose.ui.Alignment.Horizontal {
9495
when (type) {
9596
0 -> return androidx.compose.ui.Alignment.Start
@@ -99,6 +100,7 @@ public data class RemoteHorizontalAlignment(var type: Int) : RemoteAlignment.Hor
99100
return androidx.compose.ui.Alignment.Start
100101
}
101102

103+
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
102104
override fun toRemote(): Int {
103105
when (type) {
104106
0 -> return ColumnLayout.START
@@ -111,6 +113,7 @@ public data class RemoteHorizontalAlignment(var type: Int) : RemoteAlignment.Hor
111113

112114
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
113115
public data class RemoteVerticalAlignment(var type: Int) : RemoteAlignment.Vertical {
116+
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
114117
override fun toComposeUi(): androidx.compose.ui.Alignment.Vertical {
115118
when (type) {
116119
3 -> return androidx.compose.ui.Alignment.Top
@@ -120,6 +123,7 @@ public data class RemoteVerticalAlignment(var type: Int) : RemoteAlignment.Verti
120123
return androidx.compose.ui.Alignment.Top
121124
}
122125

126+
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
123127
override fun toRemote(): Int {
124128
when (type) {
125129
3 -> return ColumnLayout.TOP

0 commit comments

Comments
 (0)