Skip to content

Commit eb74abc

Browse files
Apply spotless (#47)
* Add spotless config * Apply spotless
1 parent e71196d commit eb74abc

File tree

44 files changed

+627
-500
lines changed

Some content is hidden

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

44 files changed

+627
-500
lines changed

ai-catalog/.editorconfig

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# When authoring changes in .editorconfig, run ./gradlew spotlessApply --no-daemon
2+
# Reference: https://github.com/diffplug/spotless/issues/1924
3+
[*.{kt,kts}]
4+
ktlint_code_style = android_studio
5+
ij_kotlin_allow_trailing_comma = true
6+
ij_kotlin_allow_trailing_comma_on_call_site = true
7+
max_line_length = 140 # ktlint official
8+
ktlint_class_signature_rule_force_multiline_when_parameter_count_greater_or_equal_than = 2
9+
ktlint_function_naming_ignore_when_annotated_with = Composable, Test
10+
ktlint_standard_filename = disabled
11+
ktlint_standard_package-name = disabled
12+
ktlint_standard_property-naming = disabled
13+
ktlint_standard_backing-property-naming = disabled
14+
ktlint_standard_argument-list-wrapping = disabled
15+
ktlint_standard_parameter-list-wrapping = disabled
16+
ktlint_standard_double-colon-spacing = disabled
17+
ktlint_standard_enum-entry-name-case = disabled
18+
ktlint_standard_multiline-if-else = disabled
19+
ktlint_standard_no-empty-first-line-in-method-block = disabled
20+
ktlint_standard_package-name = disabled
21+
ktlint_standard_trailing-comma = disabled
22+
ktlint_standard_spacing-around-angle-brackets = disabled
23+
ktlint_standard_spacing-between-declarations-with-annotations = disabled
24+
ktlint_standard_spacing-between-declarations-with-comments = disabled
25+
ktlint_standard_unary-op-spacing = disabled
26+
ktlint_standard_function-expression-body = disabled
27+
ktlint_standard_value-parameter-comment = disabled

ai-catalog/app/build.gradle.kts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,13 @@
55
* you may not use this file except in compliance with the License.
66
* You may obtain a copy of the License at
77
*
8-
* https://www.apache.org/licenses/LICENSE-2.0
8+
* https://www.apache.org/licenses/LICENSE-2.0
99
*
1010
* Unless required by applicable law or agreed to in writing, software
1111
* distributed under the License is distributed on an "AS IS" BASIS,
1212
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
15-
*
1615
*/
1716
plugins {
1817
alias(libs.plugins.android.application)
@@ -46,7 +45,7 @@ android {
4645
isMinifyEnabled = false
4746
proguardFiles(
4847
getDefaultProguardFile("proguard-android-optimize.txt"),
49-
"proguard-rules.pro"
48+
"proguard-rules.pro",
5049
)
5150
}
5251
}
@@ -97,4 +96,4 @@ dependencies {
9796
androidTestImplementation(libs.androidx.ui.test.junit4)
9897
debugImplementation(libs.androidx.ui.tooling)
9998
debugImplementation(libs.androidx.ui.test.manifest)
100-
}
99+
}

ai-catalog/app/src/main/java/com/android/ai/catalog/CatalogApplication.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ import android.app.Application
1919
import dagger.hilt.android.HiltAndroidApp
2020

2121
@HiltAndroidApp
22-
class CatalogApplication: Application()
22+
class CatalogApplication : Application()

ai-catalog/app/src/main/java/com/android/ai/catalog/MainActivity.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,14 @@
55
* you may not use this file except in compliance with the License.
66
* You may obtain a copy of the License at
77
*
8-
* https://www.apache.org/licenses/LICENSE-2.0
8+
* https://www.apache.org/licenses/LICENSE-2.0
99
*
1010
* Unless required by applicable law or agreed to in writing, software
1111
* distributed under the License is distributed on an "AS IS" BASIS,
1212
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
15-
*
1615
*/
17-
1816
package com.android.ai.catalog
1917

2018
import android.os.Bundle
@@ -38,4 +36,4 @@ class MainActivity : ComponentActivity() {
3836
}
3937
}
4038
}
41-
}
39+
}

ai-catalog/app/src/main/java/com/android/ai/catalog/ui/CatalogApp.kt

Lines changed: 46 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,17 @@
55
* you may not use this file except in compliance with the License.
66
* You may obtain a copy of the License at
77
*
8-
* https://www.apache.org/licenses/LICENSE-2.0
8+
* https://www.apache.org/licenses/LICENSE-2.0
99
*
1010
* Unless required by applicable law or agreed to in writing, software
1111
* distributed under the License is distributed on an "AS IS" BASIS,
1212
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
15-
*
1615
*/
17-
1816
package com.android.ai.catalog.ui
1917

2018
import android.content.Intent
21-
import android.net.Uri
2219
import android.util.Log
2320
import androidx.compose.foundation.background
2421
import androidx.compose.foundation.layout.Box
@@ -51,15 +48,15 @@ import androidx.compose.ui.res.stringResource
5148
import androidx.compose.ui.text.font.FontWeight
5249
import androidx.compose.ui.unit.dp
5350
import androidx.compose.ui.unit.sp
51+
import androidx.core.net.toUri
5452
import androidx.navigation.compose.NavHost
5553
import androidx.navigation.compose.composable
5654
import androidx.navigation.compose.rememberNavController
5755
import com.android.ai.catalog.R
5856
import com.android.ai.catalog.ui.domain.SampleCatalogItem
57+
import com.android.ai.catalog.ui.domain.sampleCatalog
5958
import com.google.firebase.FirebaseApp
6059
import kotlinx.serialization.Serializable
61-
import androidx.core.net.toUri
62-
import com.android.ai.catalog.ui.domain.sampleCatalog
6360

6461
@OptIn(ExperimentalMaterial3Api::class)
6562
@Composable
@@ -83,12 +80,12 @@ fun CatalogApp(modifier: Modifier = Modifier) {
8380
),
8481
title = {
8582
Text(text = stringResource(id = R.string.top_bar_title))
86-
}
83+
},
8784
)
8885
},
8986
) { innerPadding ->
9087
LazyColumn(
91-
contentPadding = innerPadding
88+
contentPadding = innerPadding,
9289
) {
9390
items(sampleCatalog) {
9491
CatalogListItem(catalogItem = it) {
@@ -111,42 +108,40 @@ fun CatalogApp(modifier: Modifier = Modifier) {
111108
}
112109
}
113110

114-
115111
if (isDialogOpened) {
116112
FirebaseRequiredAlert(
117113
onDismiss = { isDialogOpened = false },
118114
onOpenFirebaseDocClick = {
119115
isDialogOpened = false
120-
val intent = Intent(Intent.ACTION_VIEW,
121-
"https://firebase.google.com/docs/vertex-ai/get-started#no-existing-firebase".toUri())
116+
val intent = Intent(
117+
Intent.ACTION_VIEW,
118+
"https://firebase.google.com/docs/vertex-ai/get-started#no-existing-firebase".toUri(),
119+
)
122120
context.startActivity(intent)
123-
}
121+
},
124122
)
125123
}
126124
}
127125

128126
@Composable
129-
fun CatalogListItem(
130-
catalogItem: SampleCatalogItem,
131-
onButtonClick: () -> Unit
132-
) {
127+
fun CatalogListItem(catalogItem: SampleCatalogItem, onButtonClick: () -> Unit) {
133128
val context = LocalContext.current
134129
ElevatedCard(
135130
modifier = Modifier.padding(18.dp),
136131
onClick = {
137132
onButtonClick()
138-
}
133+
},
139134
) {
140135
Column(
141-
Modifier.padding(15.dp)
136+
Modifier.padding(15.dp),
142137
) {
143138
Text(
144139
modifier = Modifier
145140
.fillMaxWidth()
146141
.padding(bottom = 8.dp),
147142
fontSize = 20.sp,
148143
fontWeight = FontWeight.Bold,
149-
text = context.getString(catalogItem.title)
144+
text = context.getString(catalogItem.title),
150145
)
151146
Text(
152147
modifier = Modifier.padding(bottom = 8.dp),
@@ -161,10 +156,10 @@ fun CatalogListItem(
161156
.background(
162157
color = it.backgroundColor,
163158
shape = RoundedCornerShape(
164-
8.dp
165-
)
159+
8.dp,
160+
),
166161
)
167-
.padding(start = 4.dp, end = 4.dp)
162+
.padding(start = 4.dp, end = 4.dp),
168163
) {
169164
Text(
170165
fontSize = 9.sp,
@@ -182,42 +177,38 @@ fun CatalogListItem(
182177
object HomeScreen
183178

184179
@Composable
185-
fun FirebaseRequiredAlert(
186-
onDismiss: () -> Unit = {},
187-
onOpenFirebaseDocClick: () -> Unit = {}
188-
) {
180+
fun FirebaseRequiredAlert(onDismiss: () -> Unit = {}, onOpenFirebaseDocClick: () -> Unit = {}) {
189181
AlertDialog(
190-
onDismissRequest = {
191-
onDismiss()
192-
},
193-
title = {
194-
Text(text = stringResource(R.string.firebase_required))
195-
},
196-
text = {
197-
Text(stringResource(R.string.firebase_required_description))
198-
},
199-
dismissButton = {
200-
TextButton(
201-
onClick = {
202-
onDismiss()
203-
}
204-
) {
205-
Text(stringResource(R.string.close))
206-
}
207-
},
208-
confirmButton = {
209-
TextButton(
210-
onClick = {
211-
onOpenFirebaseDocClick()
212-
}
213-
) {
214-
Text(stringResource(R.string.firebase_doc_button))
215-
}
182+
onDismissRequest = {
183+
onDismiss()
184+
},
185+
title = {
186+
Text(text = stringResource(R.string.firebase_required))
187+
},
188+
text = {
189+
Text(stringResource(R.string.firebase_required_description))
190+
},
191+
dismissButton = {
192+
TextButton(
193+
onClick = {
194+
onDismiss()
195+
},
196+
) {
197+
Text(stringResource(R.string.close))
216198
}
217-
)
199+
},
200+
confirmButton = {
201+
TextButton(
202+
onClick = {
203+
onOpenFirebaseDocClick()
204+
},
205+
) {
206+
Text(stringResource(R.string.firebase_doc_button))
207+
}
208+
},
209+
)
218210
}
219211

220-
221212
fun isFirebaseInitialized(): Boolean {
222213
return try {
223214
val firebaseApp = FirebaseApp.getInstance()
@@ -226,4 +217,4 @@ fun isFirebaseInitialized(): Boolean {
226217
Log.e("CatalogScreen", "Firebase is not initialized")
227218
return false
228219
}
229-
}
220+
}

0 commit comments

Comments
 (0)