Skip to content

Commit b2f20fd

Browse files
committed
chore(snippets): Reformat code and clean up imports
1 parent 3e1f9e3 commit b2f20fd

37 files changed

Lines changed: 1458 additions & 1132 deletions

snippets/build.gradle.kts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,30 @@
1414
* limitations under the License.
1515
*/
1616

17-
// Top-level build file where you can add configuration options common to all sub-projects/modules.
1817
plugins {
1918
alias(libs.plugins.android.application) apply false
2019
alias(libs.plugins.kotlin.android) apply false
2120
alias(libs.plugins.android.library) apply false
2221
alias(libs.plugins.kotlin.compose) apply false
2322
alias(libs.plugins.secrets.gradle.plugin) apply false
23+
id("com.diffplug.spotless") version "6.25.0"
24+
}
25+
26+
subprojects {
27+
apply(plugin = "com.diffplug.spotless")
28+
configure<com.diffplug.gradle.spotless.SpotlessExtension> {
29+
java {
30+
target("**/*.java")
31+
googleJavaFormat().aosp()
32+
removeUnusedImports()
33+
trimTrailingWhitespace()
34+
endWithNewline()
35+
}
36+
kotlin {
37+
target("**/*.kt")
38+
ktlint().editorConfigOverride(mapOf("indent_size" to "4", "ktlint_function_naming_ignore_when_annotated_with" to "Composable"))
39+
trimTrailingWhitespace()
40+
endWithNewline()
41+
}
42+
}
2443
}

snippets/java-app/src/androidTest/java/com/example/snippets/java/SnippetDiscoveryTest.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,22 @@
1616

1717
package com.example.snippets.java;
1818

19-
import android.content.Context;
20-
import androidx.test.core.app.ApplicationProvider;
19+
import static org.junit.Assert.assertFalse;
20+
import static org.junit.Assert.assertNotNull;
21+
2122
import androidx.test.ext.junit.runners.AndroidJUnit4;
23+
import java.util.List;
2224
import org.junit.Test;
2325
import org.junit.runner.RunWith;
24-
import java.util.List;
25-
26-
import static org.junit.Assert.assertFalse;
27-
import static org.junit.Assert.assertNotNull;
2826

2927
@RunWith(AndroidJUnit4.class)
3028
public class SnippetDiscoveryTest {
3129

3230
@Test
3331
public void verifySnippetGroupsLoaded() {
34-
// Use the application context for scanning if needed, although scanning currently triggers from local setup
32+
// Use the application context for scanning if needed, although scanning currently triggers
33+
// from
34+
// local setup
3535
List<SnippetGroupInfo> groups = SnippetRegistry.getSnippetGroups();
3636

3737
assertNotNull("Snippet groups list should not be null", groups);
@@ -40,7 +40,8 @@ public void verifySnippetGroupsLoaded() {
4040
for (SnippetGroupInfo group : groups) {
4141
assertNotNull("Group title should not be null", group.getTitle());
4242
assertFalse("Group title should not be empty", group.getTitle().isEmpty());
43-
assertFalse("Group '" + group.getTitle() + "' must have items", group.getItems().isEmpty());
43+
assertFalse(
44+
"Group '" + group.getTitle() + "' must have items", group.getItems().isEmpty());
4445

4546
for (SnippetItemInfo item : group.getItems()) {
4647
assertNotNull("Snippet title should not be null", item.getTitle());

snippets/java-app/src/androidTest/java/com/example/snippets/java/SnippetRunTest.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,20 @@
1616

1717
package com.example.snippets.java;
1818

19+
import static org.junit.Assert.fail;
20+
1921
import android.content.Context;
2022
import android.content.Intent;
2123
import androidx.test.core.app.ActivityScenario;
2224
import androidx.test.core.app.ApplicationProvider;
2325
import androidx.test.ext.junit.runners.AndroidJUnit4;
24-
import androidx.test.platform.app.InstrumentationRegistry;
26+
import com.example.snippets.common.R;
2527
import com.google.android.gms.maps3d.Map3DView;
26-
import org.junit.Test;
27-
import org.junit.runner.RunWith;
28+
import java.util.Set;
2829
import java.util.concurrent.CountDownLatch;
2930
import java.util.concurrent.TimeUnit;
30-
import java.util.Set;
31-
32-
import static org.junit.Assert.fail;
33-
import static org.junit.Assert.assertNotNull;
31+
import org.junit.Test;
32+
import org.junit.runner.RunWith;
3433

3534
@RunWith(AndroidJUnit4.class)
3635
public class SnippetRunTest {
@@ -47,13 +46,14 @@ public void verifyAllSnippetsLaunchWithoutCrash() {
4746

4847
try (ActivityScenario<MapActivity> scenario = ActivityScenario.launch(intent)) {
4948
CountDownLatch latch = new CountDownLatch(1);
50-
scenario.onActivity(activity -> {
51-
// Verify map view exists
52-
Map3DView map = activity.findViewById(com.example.snippets.common.R.id.map);
53-
if (map != null) {
54-
latch.countDown();
55-
}
56-
});
49+
scenario.onActivity(
50+
activity -> {
51+
// Verify map view exists
52+
Map3DView map = activity.findViewById(R.id.map);
53+
if (map != null) {
54+
latch.countDown();
55+
}
56+
});
5757
if (!latch.await(5, TimeUnit.SECONDS)) {
5858
fail("Map3DView not found or activity timeout for snippet: " + snippetTitle);
5959
}

snippets/java-app/src/main/java/com/example/snippets/java/JavaSnippetsActivity.java

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,14 @@
1818

1919
import android.content.Intent;
2020
import android.os.Bundle;
21-
import androidx.appcompat.app.AppCompatActivity;
22-
import androidx.recyclerview.widget.LinearLayoutManager;
23-
import androidx.recyclerview.widget.RecyclerView;
24-
import java.util.List;
25-
2621
import androidx.activity.EdgeToEdge;
22+
import androidx.appcompat.app.AppCompatActivity;
2723
import androidx.core.graphics.Insets;
2824
import androidx.core.view.ViewCompat;
2925
import androidx.core.view.WindowInsetsCompat;
26+
import androidx.recyclerview.widget.LinearLayoutManager;
27+
import androidx.recyclerview.widget.RecyclerView;
28+
import java.util.List;
3029

3130
public class JavaSnippetsActivity extends AppCompatActivity {
3231

@@ -39,20 +38,25 @@ protected void onCreate(Bundle savedInstanceState) {
3938
RecyclerView recyclerView = findViewById(R.id.recyclerView);
4039
recyclerView.setLayoutManager(new LinearLayoutManager(this));
4140

42-
ViewCompat.setOnApplyWindowInsetsListener(recyclerView, (v, windowInsets) -> {
43-
Insets insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars());
44-
v.setPadding(insets.left, insets.top, insets.right, insets.bottom);
45-
return WindowInsetsCompat.CONSUMED;
46-
});
41+
ViewCompat.setOnApplyWindowInsetsListener(
42+
recyclerView,
43+
(v, windowInsets) -> {
44+
Insets insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars());
45+
v.setPadding(insets.left, insets.top, insets.right, insets.bottom);
46+
return WindowInsetsCompat.CONSUMED;
47+
});
4748

4849
List<SnippetGroupInfo> groups = SnippetRegistry.getSnippetGroups();
4950

50-
SnippetGroupAdapter adapter = new SnippetGroupAdapter(groups, item -> {
51-
Intent intent = new Intent(this, MapActivity.class);
52-
intent.putExtra("group_title", item.getGroupTitle());
53-
intent.putExtra(MapActivity.EXTRA_SNIPPET_TITLE, item.getTitle());
54-
startActivity(intent);
55-
});
51+
SnippetGroupAdapter adapter =
52+
new SnippetGroupAdapter(
53+
groups,
54+
item -> {
55+
Intent intent = new Intent(this, MapActivity.class);
56+
intent.putExtra("group_title", item.getGroupTitle());
57+
intent.putExtra(MapActivity.EXTRA_SNIPPET_TITLE, item.getTitle());
58+
startActivity(intent);
59+
});
5660
recyclerView.setAdapter(adapter);
5761
}
5862
}

0 commit comments

Comments
 (0)