Skip to content

Commit 9849192

Browse files
authored
Merge branch 'stage' into feat/ADFA-3125-filetree-drag-and-drop
2 parents 65a14f3 + 6771bbc commit 9849192

File tree

6 files changed

+20
-6
lines changed

6 files changed

+20
-6
lines changed

app/src/main/java/com/itsaky/androidide/assets/AssetsInstallationHelper.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import org.adfa.constants.LOCAL_MAVEN_REPO_ARCHIVE_ZIP_NAME
2323
import org.adfa.constants.TEMPLATE_CORE_ARCHIVE
2424
import org.slf4j.LoggerFactory
2525
import com.itsaky.androidide.resources.R
26+
import com.itsaky.androidide.utils.flashError
2627
import java.io.File
2728
import java.io.FileNotFoundException
2829
import java.io.IOException
@@ -131,7 +132,7 @@ object AssetsInstallationHelper {
131132
true
132133
} catch (e: FileNotFoundException) {
133134
logger.error("ZIP file not found: {}", e.message)
134-
onProgress(Progress("${e.message}"))
135+
flashError("File not found - ${e.message}")
135136
false
136137
} catch (e: ZipException) {
137138
logger.error("Invalid ZIP format: {}", e.message)

app/src/main/java/com/itsaky/androidide/assets/SplitAssetsInstaller.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ data object SplitAssetsInstaller : BaseAssetsInstaller() {
3737
): Unit =
3838
withContext(Dispatchers.IO) {
3939
if (!Environment.SPLIT_ASSETS_ZIP.exists()) {
40-
throw FileNotFoundException("Assets zip file not found at path: ${Environment.SPLIT_ASSETS_ZIP.path}")
40+
throw FileNotFoundException("Assets zip file not found at path: ${Environment.SPLIT_ASSETS_ZIP.path}." +
41+
" Please check Slack #qa-testing-builds channel for the latest version.")
4142
}
4243

4344
zipFile = ZipFile(Environment.SPLIT_ASSETS_ZIP)

templates-impl/src/main/java/com/itsaky/androidide/templates/impl/zip/ZipJson.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ data class TemplateJson(
1010
val version: String?,
1111
val tooltipTag: String = "",
1212
val defaultSaveLocation: String? = null,
13+
val defaultAppName: String? = null,
1314
val parameters: ParametersJson? = null,
1415
val system: SystemParametersJson? = null
1516
)

templates-impl/src/main/java/com/itsaky/androidide/templates/impl/zip/ZipRecipeExecutor.kt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class ZipRecipeExecutor(
3737

3838
companion object {
3939
private val log = LoggerFactory.getLogger(ZipRecipeExecutor::class.java)
40+
private val CLASS_NAME_PATTERN = Regex("[^a-zA-Z0-9]")
4041
}
4142

4243
override fun execute(
@@ -73,7 +74,10 @@ class ZipRecipeExecutor(
7374
.syntax(customSyntax)
7475
.build()
7576

76-
val (identifiers, warnings) = metaJson.pebbleParams(data, defModule, params)
77+
val className = data.name.replace(CLASS_NAME_PATTERN, "")
78+
val (baseIdentifiers, warnings) = metaJson.pebbleParams(data, defModule, params)
79+
val identifiers = baseIdentifiers + (KEY_CLASS_NAME to className)
80+
7781
if (warnings.isNotEmpty()) {
7882
warn("Identifier warnings: ${warnings.joinToString(System.lineSeparator())}")
7983
}
@@ -98,6 +102,7 @@ class ZipRecipeExecutor(
98102

99103
val relativePath = normalized.removePrefix("$basePath/")
100104
.replace(packageName.value, defModule.packageName.replace(".", "/"))
105+
.replace(KEY_CLASS_NAME, className)
101106

102107
val outFile = File(projectDir, relativePath.removeSuffix(TEMPLATE_EXTENSION)).canonicalFile
103108

@@ -223,10 +228,8 @@ class ZipRecipeExecutor(
223228
if (saveLocation.usedDefault) warnings += "Missing 'saveLocation', defaulted to $KEY_SAVE_LOCATION"
224229

225230
val language = resolveString(parameters?.optional?.language?.identifier, KEY_LANGUAGE)
226-
if (language.usedDefault) warnings += "Missing 'language', defaulted to $KEY_LANGUAGE"
227231

228232
val minSdk = resolveString(parameters?.optional?.minsdk?.identifier, KEY_MIN_SDK)
229-
if (minSdk.usedDefault) warnings += "Missing 'minsdk', defaulted to $KEY_MIN_SDK"
230233

231234
val agpVersion = resolveString(system?.agpVersion?.identifier, KEY_AGP_VERSION)
232235
if (agpVersion.usedDefault) warnings += "Missing 'agpVersion', defaulted to $KEY_AGP_VERSION"

templates-impl/src/main/java/com/itsaky/androidide/templates/impl/zip/ZipTemplateConstants.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const val DELIM_COMMENT_CLOSE = "#}"
1717

1818
const val KEY_PACKAGE_NAME = "PACKAGE_NAME"
1919
const val KEY_APP_NAME = "APP_NAME"
20+
const val KEY_CLASS_NAME = "CLASS_NAME"
2021
const val KEY_SAVE_LOCATION = "SAVE_LOCATION"
2122
const val KEY_AGP_VERSION = "AGP_VERSION"
2223
const val KEY_KOTLIN_VERSION = "KOTLIN_VERSION"

templates-impl/src/main/java/com/itsaky/androidide/templates/impl/zip/ZipTemplateReader.kt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import com.itsaky.androidide.templates.TextFieldWidget
1313
import com.itsaky.androidide.templates.Widget
1414
import com.itsaky.androidide.templates.base.baseZipProject
1515
import com.itsaky.androidide.templates.booleanParameter
16+
import com.itsaky.androidide.templates.projectNameParameter
1617
import com.itsaky.androidide.templates.stringParameter
1718
import com.itsaky.androidide.utils.FeatureFlags
1819
import org.slf4j.LoggerFactory
@@ -35,7 +36,10 @@ object ZipTemplateReader {
3536
try {
3637
ZipFile(zipFile).use { zip ->
3738

38-
val indexEntry = zip.getEntry(ARCHIVE_JSON) ?: return emptyList()
39+
val indexEntry = requireNotNull(zip.getEntry(ARCHIVE_JSON)) {
40+
"${zip.name} does not contain $ARCHIVE_JSON"
41+
}
42+
3943
val indexJson = zip.getInputStream(indexEntry).bufferedReader().use {
4044
gson.fromJson(it, TemplatesIndex::class.java)
4145
}
@@ -86,6 +90,9 @@ object ZipTemplateReader {
8690
}
8791

8892
val project = baseZipProject(
93+
projectName = projectNameParameter {
94+
metaJson.defaultAppName?.let { default = it }
95+
},
8996
showLanguage = (metaJson.parameters?.optional?.language != null),
9097
showMinSdk = (metaJson.parameters?.optional?.minsdk != null),
9198
showPackageName = (metaJson.parameters?.required?.packageName != null),

0 commit comments

Comments
 (0)