fix(templates): remove unnecessary theme declaration from no-AndroidX template (fixes #1623)

This commit is contained in:
Akash Yadav
2024-01-11 19:01:48 +05:30
parent 51ef3b115c
commit eebec3ea46
3 changed files with 12 additions and 36 deletions
@@ -179,7 +179,11 @@ class AndroidManifestBuilder {
androidAttr("roundIcon", (roundIcon ?: icon).value())
androidAttr("label", "@string/${appLabelRes}")
androidAttr("supportsRtl", rtl.toString())
androidAttr("theme", "@style/${themeRes}")
if (themeRes.isNotBlank()) {
androidAttr("theme", "@style/${themeRes}")
}
configurators[APPLICATION_ATTR]?.forEach { configurator -> configurator() }
closeStartElement()
@@ -24,7 +24,6 @@ import com.itsaky.androidide.templates.base.util.AndroidModuleResManager.Resourc
import com.itsaky.androidide.templates.base.util.AndroidModuleResManager.ResourceType.VALUES
import com.itsaky.androidide.templates.impl.R
import com.itsaky.androidide.templates.impl.base.createRecipe
import com.itsaky.androidide.templates.impl.base.emptyThemesAndColors
import com.itsaky.androidide.templates.impl.base.emptyValuesFile
import com.itsaky.androidide.templates.impl.base.writeMainActivity
import com.itsaky.androidide.templates.impl.baseProjectImpl
@@ -36,17 +35,21 @@ fun noAndroidXActivityProject() = baseProjectImpl {
uiMode = ResTableConfig.UI_MODE.NIGHT_YES
}
defaultAppModule(addAndroidX = false) {
// do not set a theme resource to the application
manifest.themeRes = ""
recipe = createRecipe {
res {
// values
writeXmlResource("colors", VALUES, source = emptyValuesFile())
writeXmlResource("themes", VALUES, source = noAndroidXTheme("Light"))
writeXmlResource("themes", VALUES, source = emptyValuesFile())
// values-night
writeXmlResource("colors", VALUES, config = configNight,
source = emptyValuesFile())
source = emptyValuesFile())
writeXmlResource("themes", VALUES, config = configNight,
source = noAndroidXTheme("Dark"))
source = emptyValuesFile())
writeXmlResource("activity_main", LAYOUT,
source = noAndroidXActivityLayout())
@@ -1,31 +0,0 @@
/*
* This file is part of AndroidIDE.
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* AndroidIDE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*/
package com.itsaky.androidide.templates.impl.noAndroidXActivity
import com.itsaky.androidide.templates.base.AndroidModuleTemplateBuilder
internal fun AndroidModuleTemplateBuilder.noAndroidXTheme(themeMode: String) = """
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Base.${manifest.themeRes}" parent="android:Theme.Material.$themeMode.DarkActionBar">
<!-- Customize your theme here. -->
</style>
<style name="${manifest.themeRes}" parent="Base.${manifest.themeRes}" />
</resources>
""".trim()