Skip to content

Commit 3f1660d

Browse files
committed
Enforce ktlint max-line-length with Spotless gradle/init.gradle.kts
1 parent 49323f3 commit 3f1660d

File tree

61 files changed

+742
-305
lines changed

Some content is hidden

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

61 files changed

+742
-305
lines changed

build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ allprojects {
4242
"spacing-between-declarations-with-comments",
4343
"unary-op-spacing",
4444
"no-trailing-spaces",
45-
"max-line-length",
4645
// Disabled rules that were introduced or changed between 0.46.0 ~ 1.50.0
4746
"class-signature",
4847
"trailing-comma-on-call-site",

compose/recomposehighlighter/src/main/java/com/example/android/compose/recomposehighlighter/RecomposeHighlighter.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ private class RecomposeHighlighterModifier : Modifier.Node(), DrawModifierNode {
115115
// Draw actual content.
116116
drawContent()
117117

118-
// Below is to draw the highlight, if necessary. A lot of the logic is copied from Modifier.border
118+
// Below is to draw the highlight, if necessary.
119+
// A lot of the logic is copied from Modifier.border
119120

120121
val hasValidBorderParams = size.minDimension > 0f
121122
if (!hasValidBorderParams || totalCompositions <= 0) {

compose/snippets/src/main/java/com/example/compose/snippets/SnippetsActivity.kt

Lines changed: 63 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ import androidx.compose.foundation.layout.fillMaxSize
2525
import androidx.compose.material3.MaterialTheme
2626
import androidx.compose.material3.Surface
2727
import androidx.compose.ui.Modifier
28+
import androidx.navigation.NavGraphBuilder
29+
import androidx.navigation.NavHostController
2830
import androidx.navigation.compose.NavHost
2931
import androidx.navigation.compose.composable
3032
import androidx.navigation.compose.rememberNavController
@@ -79,58 +81,70 @@ class SnippetsActivity : ComponentActivity() {
7981
composable("LandingScreen") {
8082
LandingScreen { navController.navigate(it.route) }
8183
}
82-
Destination.entries.forEach { destination ->
83-
composable(destination.route) {
84-
when (destination) {
85-
Destination.BrushExamples -> BrushExamplesScreen()
86-
Destination.ImageExamples -> ImageExamplesScreen()
87-
Destination.AnimationQuickGuideExamples -> AnimationExamplesScreen()
88-
Destination.ScreenshotExample -> BitmapFromComposableFullSnippet()
89-
Destination.ComponentsExamples -> ComponentsScreen {
90-
navController.navigate(
91-
it.route
92-
)
93-
}
94-
Destination.ShapesExamples -> ApplyPolygonAsClipImage()
95-
Destination.SharedElementExamples -> PlaceholderSizeAnimated_Demo()
96-
Destination.PagerExamples -> PagerExamples()
97-
}
98-
}
99-
}
100-
TopComponentsDestination.entries.forEach { destination ->
101-
composable(destination.route) {
102-
when (destination) {
103-
TopComponentsDestination.CardExamples -> CardExamples()
104-
TopComponentsDestination.SwitchExamples -> SwitchExamples()
105-
TopComponentsDestination.SliderExamples -> SliderExamples()
106-
TopComponentsDestination.DialogExamples -> DialogExamples()
107-
TopComponentsDestination.ChipExamples -> ChipExamples()
108-
TopComponentsDestination.FloatingActionButtonExamples -> FloatingActionButtonExamples()
109-
TopComponentsDestination.ButtonExamples -> ButtonExamples()
110-
TopComponentsDestination.ProgressIndicatorExamples -> ProgressIndicatorExamples()
111-
TopComponentsDestination.ScaffoldExample -> ScaffoldExample()
112-
TopComponentsDestination.AppBarExamples -> AppBarExamples {
113-
navController.popBackStack()
114-
}
115-
TopComponentsDestination.CheckboxExamples -> CheckboxExamples()
116-
TopComponentsDestination.DividerExamples -> DividerExamples()
117-
TopComponentsDestination.BadgeExamples -> BadgeExamples()
118-
TopComponentsDestination.PartialBottomSheet -> PartialBottomSheet()
119-
TopComponentsDestination.TimePickerExamples -> TimePickerExamples()
120-
TopComponentsDestination.DatePickerExamples -> DatePickerExamples()
121-
TopComponentsDestination.CarouselExamples -> CarouselExamples()
122-
TopComponentsDestination.MenusExample -> MenusExamples()
123-
TopComponentsDestination.TooltipExamples -> TooltipExamples()
124-
TopComponentsDestination.NavigationDrawerExamples -> NavigationDrawerExamples()
125-
TopComponentsDestination.SegmentedButtonExamples -> SegmentedButtonExamples()
126-
TopComponentsDestination.SwipeToDismissBoxExamples -> SwipeToDismissBoxExamples()
127-
TopComponentsDestination.SearchBarExamples -> SearchBarExamples()
128-
}
129-
}
130-
}
84+
destinations(navController)
85+
topComponentsDestinations(navController)
13186
}
13287
}
13388
}
13489
}
13590
}
13691
}
92+
93+
private fun NavGraphBuilder.destinations(navController: NavHostController) {
94+
Destination.entries.forEach { destination ->
95+
composable(destination.route) {
96+
when (destination) {
97+
Destination.BrushExamples -> BrushExamplesScreen()
98+
Destination.ImageExamples -> ImageExamplesScreen()
99+
Destination.AnimationQuickGuideExamples -> AnimationExamplesScreen()
100+
Destination.ScreenshotExample -> BitmapFromComposableFullSnippet()
101+
Destination.ComponentsExamples -> ComponentsScreen {
102+
navController.navigate(
103+
it.route
104+
)
105+
}
106+
107+
Destination.ShapesExamples -> ApplyPolygonAsClipImage()
108+
Destination.SharedElementExamples -> PlaceholderSizeAnimated_Demo()
109+
Destination.PagerExamples -> PagerExamples()
110+
}
111+
}
112+
}
113+
}
114+
115+
private fun NavGraphBuilder.topComponentsDestinations(navController: NavHostController) {
116+
TopComponentsDestination.entries.forEach { destination ->
117+
composable(destination.route) {
118+
when (destination) {
119+
TopComponentsDestination.CardExamples -> CardExamples()
120+
TopComponentsDestination.SwitchExamples -> SwitchExamples()
121+
TopComponentsDestination.SliderExamples -> SliderExamples()
122+
TopComponentsDestination.DialogExamples -> DialogExamples()
123+
TopComponentsDestination.ChipExamples -> ChipExamples()
124+
TopComponentsDestination.FloatingActionButtonExamples ->
125+
FloatingActionButtonExamples()
126+
127+
TopComponentsDestination.ButtonExamples -> ButtonExamples()
128+
TopComponentsDestination.ProgressIndicatorExamples -> ProgressIndicatorExamples()
129+
TopComponentsDestination.ScaffoldExample -> ScaffoldExample()
130+
TopComponentsDestination.AppBarExamples -> AppBarExamples {
131+
navController.popBackStack()
132+
}
133+
134+
TopComponentsDestination.CheckboxExamples -> CheckboxExamples()
135+
TopComponentsDestination.DividerExamples -> DividerExamples()
136+
TopComponentsDestination.BadgeExamples -> BadgeExamples()
137+
TopComponentsDestination.PartialBottomSheet -> PartialBottomSheet()
138+
TopComponentsDestination.TimePickerExamples -> TimePickerExamples()
139+
TopComponentsDestination.DatePickerExamples -> DatePickerExamples()
140+
TopComponentsDestination.CarouselExamples -> CarouselExamples()
141+
TopComponentsDestination.MenusExample -> MenusExamples()
142+
TopComponentsDestination.TooltipExamples -> TooltipExamples()
143+
TopComponentsDestination.NavigationDrawerExamples -> NavigationDrawerExamples()
144+
TopComponentsDestination.SegmentedButtonExamples -> SegmentedButtonExamples()
145+
TopComponentsDestination.SwipeToDismissBoxExamples -> SwipeToDismissBoxExamples()
146+
TopComponentsDestination.SearchBarExamples -> SearchBarExamples()
147+
}
148+
}
149+
}
150+
}

compose/snippets/src/main/java/com/example/compose/snippets/adaptivelayouts/SampleListDetailPaneScaffold.kt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,12 +190,15 @@ fun SampleListDetailPaneScaffoldWithPredictiveBackFull() {
190190
)
191191
}
192192

193-
fun customPaneScaffoldDirective(currentWindowAdaptiveInfo: WindowAdaptiveInfo): PaneScaffoldDirective {
193+
fun customPaneScaffoldDirective(
194+
currentWindowAdaptiveInfo: WindowAdaptiveInfo,
195+
): PaneScaffoldDirective {
196+
val windowSizeClass = currentWindowAdaptiveInfo.windowSizeClass
194197
val horizontalPartitions = when {
195-
currentWindowAdaptiveInfo.windowSizeClass.isWidthAtLeastBreakpoint(
198+
windowSizeClass.isWidthAtLeastBreakpoint(
196199
WIDTH_DP_EXPANDED_LOWER_BOUND
197200
) -> 3
198-
currentWindowAdaptiveInfo.windowSizeClass.isWidthAtLeastBreakpoint(
201+
windowSizeClass.isWidthAtLeastBreakpoint(
199202
WIDTH_DP_MEDIUM_LOWER_BOUND
200203
) -> 2
201204
else -> 1

compose/snippets/src/main/java/com/example/compose/snippets/adaptivelayouts/SampleSupportingPaneScaffold.kt

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,18 @@ fun SampleNavigableSupportingPaneScaffoldFull() {
9090
.safeContentPadding()
9191
.background(Color.Red)
9292
) {
93-
if (scaffoldNavigator.scaffoldValue[SupportingPaneScaffoldRole.Supporting] == PaneAdaptedValue.Hidden) {
93+
val shouldShowSupportingPane =
94+
scaffoldNavigator.scaffoldValue[SupportingPaneScaffoldRole.Supporting] ==
95+
PaneAdaptedValue.Hidden
96+
if (shouldShowSupportingPane) {
9497
Button(
9598
modifier = Modifier
9699
.wrapContentSize(),
97100
onClick = {
98101
scope.launch {
99-
scaffoldNavigator.navigateTo(SupportingPaneScaffoldRole.Supporting)
102+
scaffoldNavigator.navigateTo(
103+
pane = SupportingPaneScaffoldRole.Supporting,
104+
)
100105
}
101106
}
102107
) {
@@ -201,7 +206,8 @@ fun SampleNavigableSupportingPaneScaffoldSimplified() {
201206
navigator = scaffoldNavigator,
202207
mainPane = {
203208
MainPane(
204-
shouldShowSupportingPaneButton = scaffoldNavigator.scaffoldValue.secondary == PaneAdaptedValue.Hidden,
209+
shouldShowSupportingPaneButton =
210+
scaffoldNavigator.scaffoldValue.secondary == PaneAdaptedValue.Hidden,
205211
onNavigateToSupportingPane = {
206212
scope.launch {
207213
scaffoldNavigator.navigateTo(ThreePaneScaffoldRole.Secondary)
@@ -214,6 +220,7 @@ fun SampleNavigableSupportingPaneScaffoldSimplified() {
214220
// [END android_compose_adaptivelayouts_sample_supporting_pane_scaffold_simplified]
215221
}
216222

223+
/* ktlint-disable standard:max-line-length */
217224
@OptIn(ExperimentalMaterial3AdaptiveApi::class)
218225
@Composable
219226
fun SampleSupportingPaneScaffoldSimplifiedWithPredictiveBackHandler() {
@@ -230,8 +237,10 @@ fun SampleSupportingPaneScaffoldSimplifiedWithPredictiveBackHandler() {
230237
directive = scaffoldNavigator.scaffoldDirective,
231238
scaffoldState = scaffoldNavigator.scaffoldState,
232239
mainPane = {
240+
val shouldShowSupportingPaneButton =
241+
scaffoldNavigator.scaffoldValue.secondary == PaneAdaptedValue.Hidden
233242
MainPane(
234-
shouldShowSupportingPaneButton = scaffoldNavigator.scaffoldValue.secondary == PaneAdaptedValue.Hidden,
243+
shouldShowSupportingPaneButton = shouldShowSupportingPaneButton,
235244
onNavigateToSupportingPane = {
236245
scope.launch {
237246
scaffoldNavigator.navigateTo(ThreePaneScaffoldRole.Secondary)

compose/snippets/src/main/java/com/example/compose/snippets/animations/AnimationQuickGuide.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,8 @@ fun AnimatedVisibilityCookbook() {
132132
var visible by remember {
133133
mutableStateOf(true)
134134
}
135-
// Animated visibility will eventually remove the item from the composition once the animation has finished.
135+
// Animated visibility will eventually remove the item from the composition once the
136+
// animation has finished.
136137
AnimatedVisibility(visible) {
137138
// your composable here
138139
// [START_EXCLUDE]

compose/snippets/src/main/java/com/example/compose/snippets/animations/AnimationSnippets.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -938,7 +938,10 @@ private fun ContentIcon() {
938938
// [START android_compose_animations_char_by_char]
939939
@Composable
940940
private fun AnimatedText() {
941-
val text = "This text animates as though it is being typed \uD83E\uDDDE\u200D\uFE0F \uD83D\uDD10 \uD83D\uDC69\u200D\uFE0F\u200D\uD83D\uDC68 \uD83D\uDC74\uD83C\uDFFD"
941+
val text = "This text animates as though it is being typed" +
942+
" \uD83E\uDDDE\u200D\uFE0F \uD83D\uDD10" +
943+
" \uD83D\uDC69\u200D\uFE0F\u200D\uD83D\uDC68" +
944+
" \uD83D\uDC74\uD83C\uDFFD"
942945

943946
// Use BreakIterator as it correctly iterates over characters regardless of how they are
944947
// stored, for example, some emojis are made up of multiple characters.

compose/snippets/src/main/java/com/example/compose/snippets/animations/sharedelement/AnimatedVisibilitySharedElementSnippets.kt

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@
1414
* limitations under the License.
1515
*/
1616

17-
@file:OptIn(ExperimentalSharedTransitionApi::class, ExperimentalSharedTransitionApi::class)
17+
@file:OptIn(
18+
ExperimentalSharedTransitionApi::class,
19+
ExperimentalSharedTransitionApi::class,
20+
)
1821

1922
package com.example.compose.snippets.animations.sharedelement
2023

@@ -87,26 +90,30 @@ private fun AnimatedVisibilitySharedElementShortenedExample() {
8790
.fillMaxSize()
8891
.background(Color.LightGray.copy(alpha = 0.5f))
8992
.padding(16.dp),
90-
verticalArrangement = Arrangement.spacedBy(8.dp)
93+
verticalArrangement = Arrangement.spacedBy(8.dp),
9194
// [END_EXCLUDE]
9295
) {
9396
items(listSnacks) { snack ->
9497
AnimatedVisibility(
9598
visible = snack != selectedSnack,
9699
enter = fadeIn() + scaleIn(),
97100
exit = fadeOut() + scaleOut(),
98-
modifier = Modifier.animateItem()
101+
modifier = Modifier.animateItem(),
99102
) {
100103
Box(
101104
modifier = Modifier
102105
.sharedBounds(
103-
sharedContentState = rememberSharedContentState(key = "${snack.name}-bounds"),
106+
sharedContentState = rememberSharedContentState(
107+
key = "${snack.name}-bounds"
108+
),
104109
// Using the scope provided by AnimatedVisibility
105110
animatedVisibilityScope = this,
106-
clipInOverlayDuringTransition = OverlayClip(shapeForSharedElement)
111+
clipInOverlayDuringTransition = OverlayClip(
112+
clipShape = shapeForSharedElement,
113+
)
107114
)
108-
.background(Color.White, shapeForSharedElement)
109-
.clip(shapeForSharedElement)
115+
.background(Color.White, shape = shapeForSharedElement)
116+
.clip(shape = shapeForSharedElement),
110117
) {
111118
SnackContents(
112119
snack = snack,
@@ -116,7 +123,7 @@ private fun AnimatedVisibilitySharedElementShortenedExample() {
116123
),
117124
onClick = {
118125
selectedSnack = snack
119-
}
126+
},
120127
)
121128
}
122129
}
@@ -127,7 +134,7 @@ private fun AnimatedVisibilitySharedElementShortenedExample() {
127134
snack = selectedSnack,
128135
onConfirmClick = {
129136
selectedSnack = null
130-
}
137+
},
131138
)
132139
}
133140
// [END android_compose_shared_elements_animated_visibility]
@@ -137,19 +144,19 @@ private fun AnimatedVisibilitySharedElementShortenedExample() {
137144
fun SharedTransitionScope.SnackEditDetails(
138145
snack: Snack?,
139146
modifier: Modifier = Modifier,
140-
onConfirmClick: () -> Unit
147+
onConfirmClick: () -> Unit,
141148
) {
142149
AnimatedContent(
143150
modifier = modifier,
144151
targetState = snack,
145152
transitionSpec = {
146153
fadeIn() togetherWith fadeOut()
147154
},
148-
label = "SnackEditDetails"
155+
label = "SnackEditDetails",
149156
) { targetSnack ->
150157
Box(
151158
modifier = Modifier.fillMaxSize(),
152-
contentAlignment = Alignment.Center
159+
contentAlignment = Alignment.Center,
153160
) {
154161
if (targetSnack != null) {
155162
Box(
@@ -158,18 +165,21 @@ fun SharedTransitionScope.SnackEditDetails(
158165
.clickable {
159166
onConfirmClick()
160167
}
161-
.background(Color.Black.copy(alpha = 0.5f))
168+
.background(Color.Black.copy(alpha = 0.5f)),
162169
)
163170
Column(
164171
modifier = Modifier
165172
.padding(horizontal = 16.dp)
166173
.sharedBounds(
167-
sharedContentState = rememberSharedContentState(key = "${targetSnack.name}-bounds"),
174+
sharedContentState = rememberSharedContentState(
175+
key = "${targetSnack.name}-bounds",
176+
),
168177
animatedVisibilityScope = this@AnimatedContent,
169-
clipInOverlayDuringTransition = OverlayClip(shapeForSharedElement)
178+
clipInOverlayDuringTransition =
179+
OverlayClip(shapeForSharedElement),
170180
)
171181
.background(Color.White, shapeForSharedElement)
172-
.clip(shapeForSharedElement)
182+
.clip(shapeForSharedElement),
173183
) {
174184

175185
SnackContents(
@@ -186,7 +196,7 @@ fun SharedTransitionScope.SnackEditDetails(
186196
Modifier
187197
.fillMaxWidth()
188198
.padding(bottom = 8.dp, end = 8.dp),
189-
horizontalArrangement = Arrangement.End
199+
horizontalArrangement = Arrangement.End,
190200
) {
191201
TextButton(onClick = { onConfirmClick() }) {
192202
Text(text = "Save changes")
@@ -202,7 +212,7 @@ fun SharedTransitionScope.SnackEditDetails(
202212
fun SnackContents(
203213
snack: Snack,
204214
modifier: Modifier = Modifier,
205-
onClick: () -> Unit
215+
onClick: () -> Unit,
206216
) {
207217
Column(
208218
modifier = modifier
@@ -211,22 +221,22 @@ fun SnackContents(
211221
indication = null
212222
) {
213223
onClick()
214-
}
224+
},
215225
) {
216226
Image(
217227
painter = painterResource(id = snack.image),
218228
modifier = Modifier
219229
.fillMaxWidth()
220230
.aspectRatio(20f / 9f),
221231
contentScale = ContentScale.Crop,
222-
contentDescription = null
232+
contentDescription = null,
223233
)
224234
Text(
225235
text = snack.name,
226236
modifier = Modifier
227237
.wrapContentWidth()
228238
.padding(8.dp),
229-
style = MaterialTheme.typography.titleSmall
239+
style = MaterialTheme.typography.titleSmall,
230240
)
231241
}
232242
}

0 commit comments

Comments
 (0)