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

Commit 0e86c59

Browse files
authored
Merge pull request #79 from android/json-cleaning
Json format cleaning
2 parents 86694a6 + 385f0ee commit 0e86c59

File tree

4 files changed

+50
-53
lines changed

4 files changed

+50
-53
lines changed

ConfigCompact.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"projectName": "GeneratedASProject",
3+
"root": "./../",
4+
"gradleVersion": "4.3.1",
5+
"androidGradlePluginVersion": "3.0.1",
6+
"kotlinVersion": "1.1.60",
7+
"numModules": "2",
8+
"allMethods": "40",
9+
"javaPackageCount": "1",
10+
"javaClassCount": "4",
11+
"javaMethodCount": "20",
12+
"kotlinPackageCount": "1",
13+
"kotlinClassCount": "4",
14+
"androidModules": "2",
15+
"numActivitiesPerAndroidModule": "2",
16+
"productFlavors": [
17+
2, 3
18+
],
19+
"topologies": [
20+
{"type": "star", "seed": "2"}
21+
],
22+
"dependencies": [
23+
{"from": "module1", "to": "module0"}
24+
],
25+
"buildTypes": 2,
26+
"generateTests": true
27+
}
File renamed without changes.

SampleConfig.json

Lines changed: 0 additions & 30 deletions
This file was deleted.

src/main/kotlin/com/google/androidstudiopoet/AndroidStudioPoet.kt

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,14 @@ import com.google.gson.JsonObject
2525
import com.google.gson.JsonParser
2626
import com.google.gson.JsonSyntaxException
2727
import org.intellij.lang.annotations.Language
28-
import java.awt.BorderLayout
29-
import java.awt.Color
30-
import java.awt.EventQueue
31-
import java.awt.Font
28+
import java.awt.*
3229
import java.io.File
3330
import javax.swing.*
3431
import javax.swing.JFrame.EXIT_ON_CLOSE
3532
import javax.swing.border.EmptyBorder
3633
import kotlin.system.measureTimeMillis
3734

35+
3836
class AndroidStudioPoet(private val modulesWriter: SourceModuleWriter, private val filename: String?,
3937
private val configPojoToProjectConfigConverter: ConfigPojoToProjectConfigConverter,
4038
private val dependencyValidator: DependencyValidator, private val gson: Gson) {
@@ -48,34 +46,32 @@ class AndroidStudioPoet(private val modulesWriter: SourceModuleWriter, private v
4846
}
4947

5048
@Language("JSON")
51-
val SAMPLE_CONFIG = """
49+
val CONFIG_COMPACT = """
5250
{
53-
"projectName": "genny",
54-
"root": "./modules/",
51+
"projectName": "GeneratedASProject",
52+
"root": "./../",
5553
"gradleVersion": "4.3.1",
5654
"androidGradlePluginVersion": "3.0.1",
5755
"kotlinVersion": "1.1.60",
58-
"numModules": "5",
59-
"allMethods": "4000",
60-
"javaPackageCount": "20",
61-
"javaClassCount": "8",
62-
"javaMethodCount": "2000",
63-
"kotlinPackageCount": "20",
64-
"kotlinClassCount": "8",
56+
"numModules": "2",
57+
"allMethods": "40",
58+
"javaPackageCount": "1",
59+
"javaClassCount": "4",
60+
"javaMethodCount": "20",
61+
"kotlinPackageCount": "1",
62+
"kotlinClassCount": "4",
6563
"androidModules": "2",
66-
"numActivitiesPerAndroidModule": "8",
64+
"numActivitiesPerAndroidModule": "2",
6765
"productFlavors": [
6866
2, 3
6967
],
7068
"topologies": [
71-
{"type": "random_connected", "seed": "2"}
69+
{"type": "star", "seed": "2"}
7270
],
7371
"dependencies": [
74-
{"from": "module2", "to": "module3"},
75-
{"from": "module2", "to": "module4"},
76-
{"from": "module3", "to": "module4"}
72+
{"from": "module1", "to": "module0"}
7773
],
78-
"buildTypes": 6,
74+
"buildTypes": 2,
7975
"generateTests": true
8076
}
8177
""".trimIndent()
@@ -84,7 +80,7 @@ class AndroidStudioPoet(private val modulesWriter: SourceModuleWriter, private v
8480
fun run() {
8581
when {
8682
filename != null -> processFile(filename)
87-
else -> showUI(SAMPLE_CONFIG)
83+
else -> showUI(CONFIG_COMPACT)
8884
}
8985
}
9086

@@ -127,11 +123,15 @@ class AndroidStudioPoet(private val modulesWriter: SourceModuleWriter, private v
127123
add(btnGenerate, BorderLayout.SOUTH)
128124
}
129125

130-
frame.defaultCloseOperation = EXIT_ON_CLOSE
126+
val dim = Toolkit.getDefaultToolkit().screenSize
131127

132-
frame.contentPane = contentPane
128+
frame.setLocation((dim.width - frame.size.width)/3,
129+
(dim.height - frame.height)/5 )
133130

131+
frame.defaultCloseOperation = EXIT_ON_CLOSE
132+
frame.contentPane = contentPane
134133
frame.pack()
134+
135135
return frame
136136
}
137137

0 commit comments

Comments
 (0)