Skip to content

Commit c69f038

Browse files
committed
Add help text for screen and Java version parameters in templates
1 parent d71a749 commit c69f038

5 files changed

Lines changed: 20 additions & 45 deletions

File tree

src/main/kotlin/com/github/cnrture/quickprojectwizard/projectwizard/CMPTemplate.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ val composeMultiplatformTemplate = template {
6767
val screens = stringParameter {
6868
name = "Screens"
6969
default = ""
70+
help = "Please enter the screens you want to create. (e.g. Home, Detail, Profile)"
7071
}
7172

7273
widgets(

src/main/kotlin/com/github/cnrture/quickprojectwizard/projectwizard/ComposeTemplate.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,13 @@ val composeTemplate = template {
8383
val screens = stringParameter {
8484
name = "Screens"
8585
default = ""
86+
help = "Please enter the screens you want to create. (e.g. Home, Detail, Profile)"
8687
}
8788

8889
val javaJvmVersion = stringParameter {
8990
name = "Java & JVM Version"
9091
default = "17"
92+
help = "8 or 11 or 17 etc."
9193
}
9294

9395
widgets(

src/main/kotlin/com/github/cnrture/quickprojectwizard/projectwizard/XMLTemplate.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,13 @@ val xmlTemplate = template {
7979
val screens = stringParameter {
8080
name = "Screens"
8181
default = ""
82+
help = "Please enter the screens you want to create. (e.g. Home, Detail, Profile)"
8283
}
8384

8485
val javaJvmVersion = stringParameter {
8586
name = "Java & JVM Version"
8687
default = "17"
88+
help = "8 or 11 or 17 etc."
8789
}
8890

8991
widgets(

src/main/kotlin/com/github/cnrture/quickprojectwizard/projectwizard/recipes/ModuleTemplateDataExtensions.kt

Lines changed: 13 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -2,54 +2,23 @@ package com.github.cnrture.quickprojectwizard.projectwizard.recipes
22

33
import com.android.tools.idea.wizard.template.ModuleTemplateData
44

5-
/**
6-
* Extension function to get minimum API level from ModuleTemplateData
7-
* Uses reflection to handle different API versions and changes
8-
*/
95
fun ModuleTemplateData.getMinApiLevel(): Int {
106
return try {
11-
// Try modern API first
12-
val minApi = this.apis.minApi
7+
this.projectTemplateData.androidXSupport
8+
when {
9+
this.toString().contains("minApi") -> {
10+
val apiMatch = Regex("minApi[=:]\\s*(\\d+)").find(this.toString())
11+
apiMatch?.groupValues?.get(1)?.toIntOrNull() ?: 23
12+
}
1313

14-
// Try getApiLevel method
15-
val apiLevelMethod = minApi.javaClass.getDeclaredMethod("getApiLevel")
16-
apiLevelMethod.isAccessible = true
17-
apiLevelMethod.invoke(minApi) as Int
18-
} catch (_: Exception) {
19-
try {
20-
// Fallback to getApi method
21-
val minApi = this.apis.minApi
22-
val apiMethod = minApi.javaClass.getDeclaredMethod("getApi")
23-
apiMethod.isAccessible = true
24-
apiMethod.invoke(minApi) as Int
25-
} catch (_: Exception) {
26-
try {
27-
// Fallback to apiLevel field
28-
val minApi = this.apis.minApi
29-
val apiLevelField = minApi.javaClass.getDeclaredField("apiLevel")
30-
apiLevelField.isAccessible = true
31-
apiLevelField.get(minApi) as Int
32-
} catch (_: Exception) {
33-
try {
34-
// Fallback to api field
35-
val minApi = this.apis.minApi
36-
val apiField = minApi.javaClass.getDeclaredField("api")
37-
apiField.isAccessible = true
38-
apiField.get(minApi) as Int
39-
} catch (_: Exception) {
40-
try {
41-
// Try toString parsing as last resort
42-
val minApi = this.apis.minApi
43-
val apiString = minApi.toString()
44-
val regex = Regex("\\d+")
45-
val match = regex.find(apiString)
46-
match?.value?.toIntOrNull() ?: 23
47-
} catch (_: Exception) {
48-
// Default to API 23 (Android 6.0) as safe fallback
49-
23
50-
}
51-
}
14+
this.projectTemplateData.toString().contains("minApi") -> {
15+
val apiMatch = Regex("minApi[=:]\\s*(\\d+)").find(this.projectTemplateData.toString())
16+
apiMatch?.groupValues?.get(1)?.toIntOrNull() ?: 23
5217
}
18+
19+
else -> 23
5320
}
21+
} catch (_: Exception) {
22+
23
5423
}
5524
}

src/main/kotlin/com/github/cnrture/quickprojectwizard/toolwindow/QuickProjectWizardToolWindowFactory.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import com.intellij.ide.BrowserUtil
4242
import com.intellij.notification.NotificationType
4343
import com.intellij.openapi.fileChooser.FileChooser
4444
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory
45+
import com.intellij.openapi.project.DumbAware
4546
import com.intellij.openapi.project.Project
4647
import com.intellij.openapi.project.ProjectManager
4748
import com.intellij.openapi.wm.ToolWindow
@@ -51,7 +52,7 @@ import java.awt.BorderLayout
5152
import javax.swing.JComponent
5253
import javax.swing.JPanel
5354

54-
class QuickProjectWizardToolWindowFactory : ToolWindowFactory {
55+
class QuickProjectWizardToolWindowFactory : ToolWindowFactory, DumbAware {
5556

5657
private val settings = SettingsService.getInstance()
5758

0 commit comments

Comments
 (0)