Skip to content
This repository was archived by the owner on Dec 27, 2024. It is now read-only.

Commit b8993a3

Browse files
jswong65jafu888
authored andcommitted
Fix presubmit issues
1 parent 981d408 commit b8993a3

File tree

12 files changed

+67
-41
lines changed

12 files changed

+67
-41
lines changed

constraintlayout/compose/src/androidTest/java/androidx/constraintlayout/compose/FlowTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ private fun FlowComposableTest(
239239
constraintSet = ConstraintSet(
240240
"""
241241
{
242-
flow1: {
242+
flow1: {
243243
width: $width,
244244
height: $height,
245245
type: '$type',

constraintlayout/compose/src/androidTest/java/androidx/constraintlayout/compose/MotionFlowTest.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class MotionFlowTest {
7373
{
7474
ConstraintSets: {
7575
start: {
76-
flow1: {
76+
flow1: {
7777
width: 'parent',
7878
height: 'parent',
7979
type: 'hFlow',
@@ -83,9 +83,8 @@ class MotionFlowTest {
8383
contains: ['1', '2', '3', '4'],
8484
}
8585
},
86-
8786
end: {
88-
flow2: {
87+
flow2: {
8988
width: 'parent',
9089
height: 'parent',
9190
type: 'vFlow',
@@ -96,7 +95,6 @@ class MotionFlowTest {
9695
}
9796
}
9897
},
99-
10098
Transitions: {
10199
default: {
102100
from: 'start', to: 'end',

constraintlayout/compose/src/main/java/androidx/constraintlayout/compose/Motion.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ import kotlinx.coroutines.launch
6868
* Use [rememberMotionContent] and [MotionScope.motion] to animate layout changes caused by changing
6969
* the Composable's Layout parent on state changes.
7070
*
71-
* E.g:
71+
* E.g.:
7272
*
7373
* ```
7474
* var vertOrHor by remember { mutableStateOf(false) }
@@ -225,7 +225,7 @@ class MotionScope(
225225
update(endWidget, 1)
226226
}
227227
}
228-
// TODO: Optimize all animated items at a time under a single Animatable. E.g: If after
228+
// TODO: Optimize all animated items at a time under a single Animatable. E.g.: If after
229229
// a state change, 10 different items changed, animate them using one Animatable
230230
// object, as opposed to running 10 separate Animatables doing the same thing,
231231
// measure/layout calls in the LookAheadLayout MeasurePolicy might provide the clue to

constraintlayout/compose/src/main/java/androidx/constraintlayout/compose/MotionCarousel.kt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,9 @@ import androidx.constraintlayout.compose.carousel.carouselSwipeable
151151
*/
152152
@OptIn(ExperimentalMotionApi::class)
153153
@Composable
154+
@Suppress("UnavailableSymbol")
154155
fun MotionCarousel(
156+
@Suppress("HiddenTypeParameter")
155157
motionScene: MotionScene,
156158
initialSlotIndex: Int,
157159
numSlots: Int,
@@ -238,7 +240,7 @@ fun MotionCarousel(
238240
MotionLayout(motionScene = motionScene,
239241
transitionName = transitionName.value,
240242
progress = mprogress,
241-
motionLayoutFlags = MotionLayoutFlags.FullMeasure, // TODO: only apply as needed
243+
motionLayoutFlags = setOf(MotionLayoutFlag.FullMeasure), // TODO: only apply as needed
242244
modifier = Modifier
243245
.fillMaxSize()
244246
.background(Color.White)
@@ -319,8 +321,10 @@ interface MotionCarouselScope {
319321
)
320322

321323
@OptIn(ExperimentalMotionApi::class)
324+
@Suppress("UnavailableSymbol")
322325
fun itemsWithProperties(
323326
count: Int,
327+
@Suppress("HiddenTypeParameter")
324328
itemContent: @Composable (
325329
index: Int,
326330
properties: androidx.compose.runtime.State<MotionProperties>
@@ -329,8 +333,10 @@ interface MotionCarouselScope {
329333
}
330334

331335
@OptIn(ExperimentalMotionApi::class)
336+
@Suppress("UnavailableSymbol")
332337
inline fun <T> MotionCarouselScope.itemsWithProperties(
333338
items: List<T>,
339+
@Suppress("HiddenTypeParameter")
334340
crossinline itemContent: @Composable (
335341
item: T,
336342
properties: androidx.compose.runtime.State<MotionProperties>
@@ -351,9 +357,12 @@ private fun rememberStateOfItemsProvider(
351357

352358
@OptIn(ExperimentalMotionApi::class)
353359
interface MotionItemsProvider {
360+
@SuppressWarnings("UnavailableSymbol")
354361
fun getContent(index: Int): @Composable() () -> Unit
362+
@SuppressWarnings("UnavailableSymbol")
355363
fun getContent(
356364
index: Int,
365+
@SuppressWarnings("HiddenTypeParameter")
357366
properties: androidx.compose.runtime.State<MotionProperties>
358367
): @Composable() () -> Unit
359368

constraintlayout/compose/src/main/java/androidx/constraintlayout/compose/MotionLayout.kt

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ import kotlinx.coroutines.launch
5151
/**
5252
* Measure flags for MotionLayout
5353
*/
54-
enum class MotionLayoutFlags(value: Long) {
54+
enum class MotionLayoutFlag(@Suppress("UNUSED_PARAMETER") value: Long) {
5555
Default(0),
5656
FullMeasure(1)
5757
}
@@ -71,7 +71,7 @@ inline fun MotionLayout(
7171
progress: Float,
7272
debug: EnumSet<MotionLayoutDebugFlags> = EnumSet.of(MotionLayoutDebugFlags.NONE),
7373
optimizationLevel: Int = Optimizer.OPTIMIZATION_STANDARD,
74-
motionLayoutFlags: MotionLayoutFlags = MotionLayoutFlags.Default,
74+
motionLayoutFlags: Set<MotionLayoutFlag> = setOf<MotionLayoutFlag>(),
7575
crossinline content: @Composable MotionLayoutScope.() -> Unit
7676
) {
7777
val motionProgress = createAndUpdateMotionProgress(progress = progress)
@@ -103,7 +103,7 @@ inline fun MotionLayout(
103103
transitionName: String = "default",
104104
debug: EnumSet<MotionLayoutDebugFlags> = EnumSet.of(MotionLayoutDebugFlags.NONE),
105105
optimizationLevel: Int = Optimizer.OPTIMIZATION_STANDARD,
106-
motionLayoutFlags: MotionLayoutFlags = MotionLayoutFlags.Default,
106+
motionLayoutFlags: Set<MotionLayoutFlag> = setOf<MotionLayoutFlag>(),
107107
crossinline content: @Composable (MotionLayoutScope.() -> Unit),
108108
) {
109109
MotionLayoutCore(
@@ -139,7 +139,7 @@ inline fun MotionLayout(
139139
animationSpec: AnimationSpec<Float> = tween(),
140140
debug: EnumSet<MotionLayoutDebugFlags> = EnumSet.of(MotionLayoutDebugFlags.NONE),
141141
optimizationLevel: Int = Optimizer.OPTIMIZATION_STANDARD,
142-
motionLayoutFlags: MotionLayoutFlags = MotionLayoutFlags.Default,
142+
motionLayoutFlags: Set<MotionLayoutFlag> = setOf<MotionLayoutFlag>(),
143143
noinline finishedAnimationListener: (() -> Unit)? = null,
144144
crossinline content: @Composable (MotionLayoutScope.() -> Unit)
145145
) {
@@ -168,7 +168,7 @@ inline fun MotionLayout(
168168
debug: EnumSet<MotionLayoutDebugFlags> = EnumSet.of(MotionLayoutDebugFlags.NONE),
169169
informationReceiver: LayoutInformationReceiver? = null,
170170
optimizationLevel: Int = Optimizer.OPTIMIZATION_STANDARD,
171-
motionLayoutFlags: MotionLayoutFlags = MotionLayoutFlags.Default,
171+
motionLayoutFlags: Set<MotionLayoutFlag> = setOf<MotionLayoutFlag>(),
172172
crossinline content: @Composable (MotionLayoutScope.() -> Unit)
173173
) {
174174
val motionProgress = createAndUpdateMotionProgress(progress = progress)
@@ -189,15 +189,18 @@ inline fun MotionLayout(
189189
@ExperimentalMotionApi
190190
@PublishedApi
191191
@Composable
192+
@Suppress("UnavailableSymbol")
192193
internal inline fun MotionLayoutCore(
194+
@Suppress("HiddenTypeParameter")
193195
motionScene: MotionScene,
194196
modifier: Modifier = Modifier,
195197
constraintSetName: String? = null,
196198
animationSpec: AnimationSpec<Float> = tween(),
197199
debugFlag: MotionLayoutDebugFlags = MotionLayoutDebugFlags.NONE,
198200
optimizationLevel: Int = Optimizer.OPTIMIZATION_STANDARD,
199-
motionLayoutFlags: MotionLayoutFlags = MotionLayoutFlags.Default,
201+
motionLayoutFlags: Set<MotionLayoutFlag> = setOf<MotionLayoutFlag>(),
200202
noinline finishedAnimationListener: (() -> Unit)? = null,
203+
@Suppress("HiddenTypeParameter")
201204
crossinline content: @Composable (MotionLayoutScope.() -> Unit)
202205
) {
203206
val needsUpdate = remember {
@@ -285,14 +288,17 @@ internal inline fun MotionLayoutCore(
285288
@ExperimentalMotionApi
286289
@PublishedApi
287290
@Composable
291+
@Suppress("UnavailableSymbol")
288292
internal inline fun MotionLayoutCore(
293+
@Suppress("HiddenTypeParameter")
289294
motionScene: MotionScene,
290295
progress: Float,
291296
modifier: Modifier = Modifier,
292297
debug: EnumSet<MotionLayoutDebugFlags> = EnumSet.of(MotionLayoutDebugFlags.NONE),
293298
optimizationLevel: Int = Optimizer.OPTIMIZATION_STANDARD,
294299
transitionName: String,
295-
motionLayoutFlags: MotionLayoutFlags = MotionLayoutFlags.Default,
300+
motionLayoutFlags: Set<MotionLayoutFlag> = setOf<MotionLayoutFlag>(),
301+
@Suppress("HiddenTypeParameter")
296302
crossinline content: @Composable MotionLayoutScope.() -> Unit,
297303
) {
298304
val transition = remember(motionScene, transitionName) {
@@ -328,6 +334,7 @@ internal inline fun MotionLayoutCore(
328334
@ExperimentalMotionApi
329335
@PublishedApi
330336
@Composable
337+
@Suppress("UnavailableSymbol")
331338
internal inline fun MotionLayoutCore(
332339
start: ConstraintSet,
333340
end: ConstraintSet,
@@ -337,7 +344,8 @@ internal inline fun MotionLayoutCore(
337344
debugFlag: MotionLayoutDebugFlags = MotionLayoutDebugFlags.NONE,
338345
informationReceiver: LayoutInformationReceiver? = null,
339346
optimizationLevel: Int = Optimizer.OPTIMIZATION_STANDARD,
340-
motionLayoutFlags: MotionLayoutFlags = MotionLayoutFlags.Default,
347+
motionLayoutFlags: Set<MotionLayoutFlag> = setOf<MotionLayoutFlag>(),
348+
@Suppress("HiddenTypeParameter")
341349
crossinline content: @Composable MotionLayoutScope.() -> Unit
342350
) {
343351
// TODO: Merge this snippet with UpdateWithForcedIfNoUserChange
@@ -422,12 +430,15 @@ inline fun MotionLayout(
422430
@PublishedApi
423431
@ExperimentalMotionApi
424432
@Composable
433+
@Suppress("UnavailableSymbol")
425434
internal inline fun MotionLayoutCore(
426435
modifier: Modifier = Modifier,
427436
optimizationLevel: Int = Optimizer.OPTIMIZATION_STANDARD,
428437
motionLayoutState: MotionLayoutStateImpl,
438+
@Suppress("HiddenTypeParameter")
429439
motionScene: MotionScene,
430440
transitionName: String = "default",
441+
@Suppress("HiddenTypeParameter")
431442
crossinline content: @Composable MotionLayoutScope.() -> Unit
432443
) {
433444
val transition = remember(motionScene, transitionName) {
@@ -460,10 +471,10 @@ internal inline fun MotionLayoutCore(
460471
)
461472
}
462473

463-
@Suppress("unused")
464474
@LayoutScopeMarker
465475
@ExperimentalMotionApi
466-
class MotionLayoutScope @PublishedApi internal constructor(
476+
class MotionLayoutScope @Suppress("ShowingMemberInHiddenClass")
477+
@PublishedApi internal constructor(
467478
private val measurer: MotionMeasurer,
468479
private val motionProgress: MotionProgress
469480
) {
@@ -554,7 +565,7 @@ internal fun rememberMotionLayoutMeasurePolicy(
554565
constraintSetEnd: ConstraintSet,
555566
@SuppressWarnings("HiddenTypeParameter") transition: TransitionImpl?,
556567
motionProgress: MotionProgress,
557-
motionLayoutFlags: MotionLayoutFlags = MotionLayoutFlags.Default,
568+
motionLayoutFlags: Set<MotionLayoutFlag> = setOf<MotionLayoutFlag>(),
558569
measurer: MotionMeasurer
559570
): MeasurePolicy {
560571
val density = LocalDensity.current

constraintlayout/compose/src/main/java/androidx/constraintlayout/compose/MotionMeasurer.kt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ internal class MotionMeasurer : Measurer() {
7777
root.measure(Optimizer.OPTIMIZATION_NONE, 0, 0, 0, 0, 0, 0, 0, 0)
7878
}
7979

80+
@Suppress("UnavailableSymbol")
8081
fun performInterpolationMeasure(
8182
constraints: Constraints,
8283
layoutDirection: LayoutDirection,
@@ -86,16 +87,17 @@ internal class MotionMeasurer : Measurer() {
8687
measurables: List<Measurable>,
8788
optimizationLevel: Int,
8889
progress: Float,
89-
motionLayoutFlags: MotionLayoutFlags = MotionLayoutFlags.Default,
90+
motionLayoutFlags: Set<MotionLayoutFlag> = setOf<MotionLayoutFlag>(),
9091
measureScope: MeasureScope
9192
): IntSize {
9293
this.density = measureScope
9394
this.measureScope = measureScope
9495

9596
var needsRemeasure = false
96-
if (motionLayoutFlags == MotionLayoutFlags.Default) {
97+
var flag = motionLayoutFlags.firstOrNull()
98+
if (flag == MotionLayoutFlag.Default || flag == null) {
9799
needsRemeasure = needsRemeasure(constraints)
98-
} else if (motionLayoutFlags == MotionLayoutFlags.FullMeasure) {
100+
} else if (flag == MotionLayoutFlag.FullMeasure) {
99101
needsRemeasure = true
100102
}
101103

@@ -511,6 +513,7 @@ internal class MotionMeasurer : Measurer() {
511513
frameCache.clear()
512514
}
513515

516+
@Suppress("UnavailableSymbol")
514517
fun initWith(
515518
start: ConstraintSet,
516519
end: ConstraintSet,

constraintlayout/compose/src/main/java/androidx/constraintlayout/compose/MotionSceneScope.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,15 @@ internal class MotionSceneDslImpl(
9797
/**
9898
* Scope used by the MotionScene DSL.
9999
*
100-
* &nbsp
100+
* &nbsp;
101101
*
102102
* Define new [ConstraintSet]s and [Transition]s within this scope using [constraintSet] and
103103
* [transition] respectively.
104104
*
105105
* Alternatively, you may add existing objects to this scope using [addConstraintSet] and
106106
* [addTransition].
107107
*
108-
* &nbsp
108+
* &nbsp;
109109
*
110110
* The [defaultTransition] **should always be set**. It defines the initial state of the layout and
111111
* works as a fallback for undefined `from -> to` transitions.

constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/widget/ConstraintLayoutStatistics.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ public void reset() {
9595
* Create a copy of the statistics
9696
* @return a copy
9797
*/
98+
@Override
9899
public ConstraintLayoutStatistics clone() {
99100
return new ConstraintLayoutStatistics(this);
100101
}
@@ -122,10 +123,10 @@ public void logSummary(String tag) {
122123

123124
@SuppressLint({"LogConditional"})
124125
private void log(String tag) {
125-
String value;
126126
StackTraceElement s = new Throwable().getStackTrace()[2];
127127

128-
Log.v(tag, "CL Perf: -------- Performance .(" + s.getFileName() + ":" + s.getLineNumber() + ") ------ ");
128+
Log.v(tag, "CL Perf: -------- Performance .(" +
129+
s.getFileName() + ":" + s.getLineNumber() + ") ------ ");
129130

130131
DecimalFormat df = new DecimalFormat("###.000");
131132

@@ -172,7 +173,8 @@ private String log(int param) {
172173
}
173174

174175
/**
175-
* Generate a float formatted String for the parameter comparing current value with value in relative
176+
* Generate a float formatted String for the parameter comparing
177+
* current value with value in relative
176178
* @param df Format the float using this
177179
* @param relative compare against
178180
* @param param the parameter to compare
@@ -218,7 +220,8 @@ public void logSummary(String tag, ConstraintLayoutStatistics prev) {
218220
DecimalFormat df = new DecimalFormat("###.000");
219221
StackTraceElement s = new Throwable().getStackTrace()[1];
220222

221-
Log.v(tag, "CL Perf: -= Performance .(" + s.getFileName() + ":" + s.getLineNumber() + ") =- ");
223+
Log.v(tag, "CL Perf: -= Performance .(" +
224+
s.getFileName() + ":" + s.getLineNumber() + ") =- ");
222225
Log.v(tag, compare(df, prev, DURATION_OF_CHILD_MEASURES));
223226
Log.v(tag, compare(df, prev, DURATION_OF_LAYOUT));
224227
Log.v(tag, compare(df, prev, DURATION_OF_MEASURES));

constraintlayout/core/src/main/java/androidx/constraintlayout/core/Metrics.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,5 +171,4 @@ public void copy(Metrics metrics) {
171171
resolvedWidgets = metrics.resolvedWidgets;
172172
nonresolvedWidgets = metrics.nonresolvedWidgets;
173173
}
174-
175174
}

constraintlayout/core/src/main/java/androidx/constraintlayout/core/state/ConstraintSetParser.java

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,13 +1099,14 @@ private static void parseFlowType(String flowType,
10991099
vStyleValueStr = vStyleObject.content();
11001100
}
11011101

1102-
if (vStyleValueStr != "") {
1102+
if (!vStyleValueStr.equals("")) {
11031103
flow.setVerticalStyle(State.Chain.getValueByString(vStyleValueStr));
11041104
}
1105-
if (vFirstStyleValueStr != "") {
1106-
flow.setFirstVerticalStyle(State.Chain.getValueByString(vFirstStyleValueStr));
1105+
if (!vFirstStyleValueStr.equals("")) {
1106+
flow.setFirstVerticalStyle(
1107+
State.Chain.getValueByString(vFirstStyleValueStr));
11071108
}
1108-
if (vLastStyleValueStr != "") {
1109+
if (!vLastStyleValueStr.equals("")) {
11091110
flow.setLastVerticalStyle(State.Chain.getValueByString(vLastStyleValueStr));
11101111
}
11111112
break;
@@ -1124,14 +1125,16 @@ private static void parseFlowType(String flowType,
11241125
hStyleValueStr = hStyleObject.content();
11251126
}
11261127

1127-
if (hStyleValueStr != "") {
1128+
if (!hStyleValueStr.equals("")) {
11281129
flow.setHorizontalStyle(State.Chain.getValueByString(hStyleValueStr));
11291130
}
1130-
if (hFirstStyleValueStr != "") {
1131-
flow.setFirstHorizontalStyle(State.Chain.getValueByString(hFirstStyleValueStr));
1131+
if (!hFirstStyleValueStr.equals("")) {
1132+
flow.setFirstHorizontalStyle(
1133+
State.Chain.getValueByString(hFirstStyleValueStr));
11321134
}
1133-
if (hLastStyleValueStr != "") {
1134-
flow.setLastHorizontalStyle(State.Chain.getValueByString(hLastStyleValueStr));
1135+
if (!hLastStyleValueStr.equals("")) {
1136+
flow.setLastHorizontalStyle(
1137+
State.Chain.getValueByString(hLastStyleValueStr));
11351138
}
11361139
break;
11371140
default:
@@ -1408,7 +1411,6 @@ static void parseWidget(
14081411
ConstraintReference reference,
14091412
CLObject element
14101413
) throws CLParsingException {
1411-
float value;
14121414
if (reference.getWidth() == null) {
14131415
// Default to Wrap when the Dimension has not been assigned
14141416
reference.setWidth(Dimension.createWrap());

0 commit comments

Comments
 (0)