Refactor naming according to convention

Change-Id: Id74e2495d5909e4978247e0d7edfb5621b2064ff
pull/458/head
mlykotom 2 years ago
parent 9c22af19eb
commit 7db33aa041

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
import com.google.samples.apps.nowinandroid.FlavorDimension import com.google.samples.apps.nowinandroid.FlavorDimension
import com.google.samples.apps.nowinandroid.NiAFlavor import com.google.samples.apps.nowinandroid.NiaFlavor
/* /*
* Copyright 2022 The Android Open Source Project * Copyright 2022 The Android Open Source Project
@ -44,7 +44,7 @@ android {
// The UI catalog does not depend on content from the app, however, it depends on modules // The UI catalog does not depend on content from the app, however, it depends on modules
// which do, so we must specify a default value for the contentType dimension. // which do, so we must specify a default value for the contentType dimension.
missingDimensionStrategy(FlavorDimension.contentType.name, NiAFlavor.demo.name) missingDimensionStrategy(FlavorDimension.contentType.name, NiaFlavor.demo.name)
} }
packagingOptions { packagingOptions {

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import com.google.samples.apps.nowinandroid.NiABuildType import com.google.samples.apps.nowinandroid.NiaBuildType
plugins { plugins {
id("nowinandroid.android.application") id("nowinandroid.android.application")
@ -39,11 +39,11 @@ android {
buildTypes { buildTypes {
val debug by getting { val debug by getting {
applicationIdSuffix = NiABuildType.DEBUG.applicationIdSuffix applicationIdSuffix = NiaBuildType.DEBUG.applicationIdSuffix
} }
val release by getting { val release by getting {
isMinifyEnabled = true isMinifyEnabled = true
applicationIdSuffix = NiABuildType.RELEASE.applicationIdSuffix applicationIdSuffix = NiaBuildType.RELEASE.applicationIdSuffix
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
// To publish on the Play store a private signing key is required, but to allow anyone // To publish on the Play store a private signing key is required, but to allow anyone
@ -60,7 +60,7 @@ android {
// Only use benchmark proguard rules // Only use benchmark proguard rules
proguardFiles("benchmark-rules.pro") proguardFiles("benchmark-rules.pro")
isMinifyEnabled = true isMinifyEnabled = true
applicationIdSuffix = NiABuildType.BENCHMARK.applicationIdSuffix applicationIdSuffix = NiaBuildType.BENCHMARK.applicationIdSuffix
} }
} }

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
import com.android.build.api.dsl.ManagedVirtualDevice import com.android.build.api.dsl.ManagedVirtualDevice
import com.google.samples.apps.nowinandroid.NiABuildType import com.google.samples.apps.nowinandroid.NiaBuildType
import com.google.samples.apps.nowinandroid.configureFlavors import com.google.samples.apps.nowinandroid.configureFlavors
plugins { plugins {
@ -47,7 +47,7 @@ android {
buildConfigField( buildConfigField(
"String", "String",
"APP_BUILD_TYPE_SUFFIX", "APP_BUILD_TYPE_SUFFIX",
"\"${NiABuildType.BENCHMARK.applicationIdSuffix ?: ""}\"" "\"${NiaBuildType.BENCHMARK.applicationIdSuffix ?: ""}\""
) )
} }
} }

@ -20,7 +20,7 @@ package com.google.samples.apps.nowinandroid
* This is shared between :app and :benchmarks module to provide configurations type safety. * This is shared between :app and :benchmarks module to provide configurations type safety.
*/ */
@Suppress("unused") @Suppress("unused")
enum class NiABuildType(val applicationIdSuffix: String? = null) { enum class NiaBuildType(val applicationIdSuffix: String? = null) {
DEBUG(".debug"), DEBUG(".debug"),
RELEASE, RELEASE,
BENCHMARK(".benchmark") BENCHMARK(".benchmark")

@ -15,19 +15,19 @@ enum class FlavorDimension {
// purposes, or from a production backend server which supplies up-to-date, real content. // purposes, or from a production backend server which supplies up-to-date, real content.
// These two product flavors reflect this behaviour. // These two product flavors reflect this behaviour.
@Suppress("EnumEntryName") @Suppress("EnumEntryName")
enum class NiAFlavor(val dimension: FlavorDimension, val applicationIdSuffix: String? = null) { enum class NiaFlavor(val dimension: FlavorDimension, val applicationIdSuffix: String? = null) {
demo(FlavorDimension.contentType), demo(FlavorDimension.contentType),
prod(FlavorDimension.contentType, ".prod") prod(FlavorDimension.contentType, ".prod")
} }
fun Project.configureFlavors( fun Project.configureFlavors(
commonExtension: CommonExtension<*, *, *, *>, commonExtension: CommonExtension<*, *, *, *>,
flavorConfigurationBlock: ProductFlavor.(flavor: NiAFlavor) -> Unit = {} flavorConfigurationBlock: ProductFlavor.(flavor: NiaFlavor) -> Unit = {}
) { ) {
commonExtension.apply { commonExtension.apply {
flavorDimensions += FlavorDimension.contentType.name flavorDimensions += FlavorDimension.contentType.name
productFlavors { productFlavors {
NiAFlavor.values().forEach { NiaFlavor.values().forEach {
create(it.name) { create(it.name) {
dimension = it.dimension.name dimension = it.dimension.name
flavorConfigurationBlock(this, it) flavorConfigurationBlock(this, it)
Loading…
Cancel
Save