mirror of
https://gitee.com/zhangsken/AndroidIDE.git
synced 2026-10-16 07:49:44 +08:00
fix(templates): remove unused 'description' from tempate models
This commit is contained in:
+1
-1
@@ -31,6 +31,6 @@ import java.io.File
|
||||
class FileTemplateBuilder<R: FileTemplateRecipeResult>(val dir: File) : TemplateBuilder<R>() {
|
||||
|
||||
override fun buildInternal(): FileTemplate<R> {
|
||||
return FileTemplate(templateName!!, thumb!!, description, widgets!!, recipe!!)
|
||||
return FileTemplate(templateName!!, thumb!!, widgets!!, recipe!!)
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -209,7 +209,7 @@ abstract class ModuleTemplateBuilder :
|
||||
abstract fun RecipeExecutor.buildGradle()
|
||||
|
||||
override fun buildInternal(): ModuleTemplate {
|
||||
return ModuleTemplate(name, templateName!!, thumb!!, description, widgets!!,
|
||||
return ModuleTemplate(name, templateName!!, thumb!!, widgets!!,
|
||||
recipe!!)
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -144,7 +144,7 @@ class ProjectTemplateBuilder :
|
||||
}
|
||||
|
||||
override fun buildInternal(): ProjectTemplate {
|
||||
return ProjectTemplate(modules, templateName!!, thumb!!, description,
|
||||
return ProjectTemplate(modules, templateName!!, thumb!!,
|
||||
widgets!!, recipe!!)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,8 +38,7 @@ sealed class TemplateData
|
||||
*/
|
||||
interface TemplateRecipeResult
|
||||
|
||||
interface TemplateRecipeResultWithData<D : TemplateData> :
|
||||
TemplateRecipeResult {
|
||||
interface TemplateRecipeResultWithData<D : TemplateData> : TemplateRecipeResult {
|
||||
|
||||
/**
|
||||
* The data used to create the template.
|
||||
@@ -50,14 +49,12 @@ interface TemplateRecipeResultWithData<D : TemplateData> :
|
||||
/**
|
||||
* Result of recipe execution for a [ProjectTemplate].
|
||||
*/
|
||||
interface ProjectTemplateRecipeResult :
|
||||
TemplateRecipeResultWithData<ProjectTemplateData>
|
||||
interface ProjectTemplateRecipeResult : TemplateRecipeResultWithData<ProjectTemplateData>
|
||||
|
||||
/**
|
||||
* Result of recipe execution for a [ModuleTemplate].
|
||||
*/
|
||||
interface ModuleTemplateRecipeResult :
|
||||
TemplateRecipeResultWithData<ModuleTemplateData>
|
||||
interface ModuleTemplateRecipeResult : TemplateRecipeResultWithData<ModuleTemplateData>
|
||||
|
||||
/**
|
||||
* Result of recipe execution for a [FileTemplate].
|
||||
@@ -100,9 +97,8 @@ typealias TemplateRecipeFinalizer = RecipeExecutor.() -> Unit
|
||||
* @property language The source language for the module.
|
||||
* @property useKts Whether to use Kotlin DSL for Gradle build scripts.
|
||||
*/
|
||||
abstract class BaseTemplateData(val name: String, val projectDir: File,
|
||||
val language: Language, val useKts: Boolean
|
||||
) : TemplateData() {
|
||||
abstract class BaseTemplateData(val name: String, val projectDir: File, val language: Language,
|
||||
val useKts: Boolean) : TemplateData() {
|
||||
|
||||
/**
|
||||
* Get the `build.gradle[.kts]` file for the project.
|
||||
@@ -117,8 +113,7 @@ abstract class BaseTemplateData(val name: String, val projectDir: File,
|
||||
*/
|
||||
enum class Language(val lang: String, val ext: String) {
|
||||
|
||||
Java("Java", "java"),
|
||||
Kotlin("Kotlin", "kt");
|
||||
Java("Java", "java"), Kotlin("Kotlin", "kt");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -128,9 +123,7 @@ enum class Language(val lang: String, val ext: String) {
|
||||
*/
|
||||
enum class ModuleType(val typeName: String) {
|
||||
|
||||
AndroidApp("Android Application"),
|
||||
AndroidLibrary("Android Library"),
|
||||
JavaLibrary("Java library")
|
||||
AndroidApp("Android Application"), AndroidLibrary("Android Library"), JavaLibrary("Java library")
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -163,11 +156,8 @@ enum class SrcSet(val folder: String) {
|
||||
* @property gradle The Gradle version.
|
||||
* @property kotlin The Kotlin Plugin version.
|
||||
*/
|
||||
data class ProjectVersionData(
|
||||
val gradlePlugin: String = ANDROID_GRADLE_PLUGIN_VERSION,
|
||||
val gradle: String = GRADLE_DISTRIBUTION_VERSION,
|
||||
val kotlin: String = KOTLIN_VERSION
|
||||
)
|
||||
data class ProjectVersionData(val gradlePlugin: String = ANDROID_GRADLE_PLUGIN_VERSION,
|
||||
val gradle: String = GRADLE_DISTRIBUTION_VERSION, val kotlin: String = KOTLIN_VERSION)
|
||||
|
||||
/**
|
||||
* Version information about a module.
|
||||
@@ -175,13 +165,9 @@ data class ProjectVersionData(
|
||||
* @property targetSdk The target SDK version for modules.
|
||||
* @property buildTools The build tools version for modules.
|
||||
*/
|
||||
data class ModuleVersionData(
|
||||
val minSdk: Sdk,
|
||||
val targetSdk: Sdk = TARGET_SDK_VERSION,
|
||||
val compileSdk: Sdk = COMPILE_SDK_VERSION,
|
||||
val javaSource: String = JAVA_SOURCE_VERSION,
|
||||
val javaTarget: String = JAVA_TARGET_VERSION
|
||||
) {
|
||||
data class ModuleVersionData(val minSdk: Sdk, val targetSdk: Sdk = TARGET_SDK_VERSION,
|
||||
val compileSdk: Sdk = COMPILE_SDK_VERSION, val javaSource: String = JAVA_SOURCE_VERSION,
|
||||
val javaTarget: String = JAVA_TARGET_VERSION) {
|
||||
|
||||
/**
|
||||
* Get the Java source version string representation in the `JavaVersion.VERSION_${version}` format.
|
||||
@@ -193,8 +179,7 @@ data class ModuleVersionData(
|
||||
*/
|
||||
fun javaTarget() = javaVersionPrefix(javaTarget)
|
||||
|
||||
private fun javaVersionPrefix(version: String): String =
|
||||
"JavaVersion.VERSION_${version}"
|
||||
private fun javaVersionPrefix(version: String): String = "JavaVersion.VERSION_${version}"
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -202,10 +187,8 @@ data class ModuleVersionData(
|
||||
*
|
||||
* @property version The version information for this project.
|
||||
*/
|
||||
class ProjectTemplateData(name: String, projectDir: File,
|
||||
val version: ProjectVersionData, language: Language,
|
||||
useKts: Boolean
|
||||
) : BaseTemplateData(name, projectDir, language, useKts)
|
||||
class ProjectTemplateData(name: String, projectDir: File, val version: ProjectVersionData,
|
||||
language: Language, useKts: Boolean) : BaseTemplateData(name, projectDir, language, useKts)
|
||||
|
||||
/**
|
||||
* Data for creating module projects.
|
||||
@@ -214,13 +197,10 @@ class ProjectTemplateData(name: String, projectDir: File,
|
||||
* @property type The type of module.
|
||||
* @property versions Version information for the module.
|
||||
*/
|
||||
open class ModuleTemplateData(name: String, val appName: String?,
|
||||
val packageName: String, projectDir: File,
|
||||
val type: ModuleType, language: Language,
|
||||
useKts: Boolean = true, minSdk: Sdk,
|
||||
val versions: ModuleVersionData = ModuleVersionData(
|
||||
minSdk)
|
||||
) : BaseTemplateData(name, projectDir, language, useKts) {
|
||||
open class ModuleTemplateData(name: String, val appName: String?, val packageName: String,
|
||||
projectDir: File, val type: ModuleType, language: Language, useKts: Boolean = true, minSdk: Sdk,
|
||||
val versions: ModuleVersionData = ModuleVersionData(minSdk)) :
|
||||
BaseTemplateData(name, projectDir, language, useKts) {
|
||||
|
||||
private val srcDirs = mutableMapOf<SrcSet, File>()
|
||||
|
||||
@@ -237,11 +217,9 @@ open class ModuleTemplateData(name: String, val appName: String?,
|
||||
* @property templateName The name of the template.
|
||||
* @property thumb The thumbnail for the template.
|
||||
*/
|
||||
open class Template<R : TemplateRecipeResult>(
|
||||
@StringRes open val templateName: Int, @DrawableRes open val thumb: Int,
|
||||
@StringRes open val description: Int?, open val widgets: List<Widget<*>>,
|
||||
open val recipe: TemplateRecipe<R>
|
||||
) {
|
||||
open class Template<R : TemplateRecipeResult>(@StringRes open val templateName: Int,
|
||||
@DrawableRes open val thumb: Int, open val widgets: List<Widget<*>>,
|
||||
open val recipe: TemplateRecipe<R>) {
|
||||
|
||||
/**
|
||||
* The ID for this template.
|
||||
@@ -260,18 +238,14 @@ open class Template<R : TemplateRecipeResult>(
|
||||
companion object {
|
||||
|
||||
@JvmStatic
|
||||
val EMPTY = Template(-1, -1, -1, emptyList(), EMPTY_RECIPE)
|
||||
val EMPTY = Template(-1, -1, emptyList(), EMPTY_RECIPE)
|
||||
}
|
||||
}
|
||||
|
||||
open class ProjectTemplate(val moduleTemplates: List<Template<*>>,
|
||||
@StringRes templateName: Int,
|
||||
@DrawableRes thumb: Int,
|
||||
@StringRes description: Int?,
|
||||
widgets: List<Widget<*>>,
|
||||
recipe: TemplateRecipe<ProjectTemplateRecipeResult>
|
||||
) : Template<ProjectTemplateRecipeResult>(templateName, thumb, description,
|
||||
widgets, recipe) {
|
||||
open class ProjectTemplate(val moduleTemplates: List<Template<*>>, @StringRes templateName: Int,
|
||||
@DrawableRes thumb: Int, widgets: List<Widget<*>>,
|
||||
recipe: TemplateRecipe<ProjectTemplateRecipeResult>) :
|
||||
Template<ProjectTemplateRecipeResult>(templateName, thumb, widgets, recipe) {
|
||||
|
||||
override val parameters: Collection<Parameter<*>>
|
||||
get() = if (moduleTemplates.isEmpty()) super.parameters else super.parameters.toMutableList()
|
||||
@@ -280,10 +254,9 @@ open class ProjectTemplate(val moduleTemplates: List<Template<*>>,
|
||||
}
|
||||
|
||||
override val widgets: List<Widget<*>>
|
||||
get() = if (moduleTemplates.isEmpty()) super.widgets else super.widgets.toMutableList()
|
||||
.apply {
|
||||
addAll(moduleTemplates.flatMap { it.widgets })
|
||||
}
|
||||
get() = if (moduleTemplates.isEmpty()) super.widgets else super.widgets.toMutableList().apply {
|
||||
addAll(moduleTemplates.flatMap { it.widgets })
|
||||
}
|
||||
|
||||
override val recipe: TemplateRecipe<ProjectTemplateRecipeResult>
|
||||
get() = if (moduleTemplates.isEmpty()) super.recipe else super.recipe.let { projectRecipe ->
|
||||
@@ -305,23 +278,16 @@ open class ProjectTemplate(val moduleTemplates: List<Template<*>>,
|
||||
*
|
||||
* @property name The mdoule name (gradle format, e.g. ':app').
|
||||
*/
|
||||
open class ModuleTemplate(val name: String, @StringRes templateName: Int,
|
||||
@DrawableRes thumb: Int, @StringRes description: Int?,
|
||||
widgets: List<Widget<*>>,
|
||||
recipe: TemplateRecipe<ModuleTemplateRecipeResult>
|
||||
) : Template<ModuleTemplateRecipeResult>(templateName, thumb, description,
|
||||
widgets, recipe)
|
||||
open class ModuleTemplate(val name: String, @StringRes templateName: Int, @DrawableRes thumb: Int,
|
||||
widgets: List<Widget<*>>,
|
||||
recipe: TemplateRecipe<ModuleTemplateRecipeResult>) :
|
||||
Template<ModuleTemplateRecipeResult>(templateName, thumb, widgets, recipe)
|
||||
|
||||
/**
|
||||
* Template for creating a file.
|
||||
*/
|
||||
open class FileTemplate<R : FileTemplateRecipeResult>(@StringRes name: Int,
|
||||
@DrawableRes thumb: Int,
|
||||
@StringRes
|
||||
description: Int?,
|
||||
widgets: List<Widget<*>>,
|
||||
recipe: TemplateRecipe<R>
|
||||
) : Template<R>(name, thumb, description, widgets, recipe)
|
||||
open class FileTemplate<R : FileTemplateRecipeResult>(@StringRes name: Int, @DrawableRes thumb: Int,
|
||||
widgets: List<Widget<*>>, recipe: TemplateRecipe<R>) : Template<R>(name, thumb, widgets, recipe)
|
||||
|
||||
/**
|
||||
* Base class for template builders.
|
||||
@@ -332,12 +298,8 @@ open class FileTemplate<R : FileTemplateRecipeResult>(@StringRes name: Int,
|
||||
* @property recipe The recipe for building the template.
|
||||
*/
|
||||
abstract class TemplateBuilder<R : TemplateRecipeResult>(
|
||||
@StringRes open var templateName: Int? = null,
|
||||
@DrawableRes open var thumb: Int? = null,
|
||||
@StringRes open var description: Int? = null,
|
||||
open var widgets: List<Widget<*>>? = null,
|
||||
open var recipe: TemplateRecipe<R>? = null
|
||||
) {
|
||||
@StringRes open var templateName: Int? = null, @DrawableRes open var thumb: Int? = null,
|
||||
open var widgets: List<Widget<*>>? = null, open var recipe: TemplateRecipe<R>? = null) {
|
||||
|
||||
/**
|
||||
* Adds the given widgets to the widgets list.
|
||||
|
||||
Reference in New Issue
Block a user