diff --git a/app/build.gradle.kts b/app/build.gradle.kts index d7594e2..83e2cdb 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Balázs Püspök-Kiss (Illyan) + * Copyright (c) 2022-2024 Balázs Püspök-Kiss (Illyan) * * Jay is a driver behaviour analytics app. * @@ -16,25 +16,7 @@ * If not, see . */ -import com.google.android.libraries.mapsplatform.secrets_gradle_plugin.loadPropertiesFile - -/* - * Copyright (c) 2022-2023 Balázs Püspök-Kiss (Illyan) - * - * Jay is a driver behaviour analytics app. - * - * This file is part of Jay. - * - * Jay 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. - * Jay 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 Jay. - * If not, see . - */ +import org.jetbrains.kotlin.konan.properties.loadProperties plugins { alias(libs.plugins.android.application) @@ -52,6 +34,8 @@ plugins { alias(libs.plugins.compose.compiler) } +val localProperties = loadProperties("$projectDir/../local.properties") + android { compileSdk = 35 @@ -71,22 +55,20 @@ android { } signingConfigs { - val properties = loadPropertiesFile("../local.properties").toMap() - - val debugStorePath = properties["DEBUG_KEY_PATH"].toString() - val debugKeyAlias = properties["DEBUG_KEY_ALIAS"].toString() - val debugStorePassword = properties["DEBUG_KEYSTORE_PASSWORD"].toString() - val debugKeyPassword = properties["DEBUG_KEY_PASSWORD"].toString() + val debugStorePath = localProperties["DEBUG_KEY_PATH"].toString() + val debugKeyAlias = localProperties["DEBUG_KEY_ALIAS"].toString() + val debugStorePassword = localProperties["DEBUG_KEYSTORE_PASSWORD"].toString() + val debugKeyPassword = localProperties["DEBUG_KEY_PASSWORD"].toString() getByName("debug") { storeFile = file(debugStorePath) keyAlias = debugKeyAlias storePassword = debugStorePassword keyPassword = debugKeyPassword } - val releaseStorePath = properties["RELEASE_KEY_PATH"].toString() - val releaseKeyAlias = properties["RELEASE_KEY_ALIAS"].toString() - val releaseStorePassword = properties["RELEASE_KEYSTORE_PASSWORD"].toString() - val releaseKeyPassword = properties["RELEASE_KEY_PASSWORD"].toString() + val releaseStorePath = localProperties["RELEASE_KEY_PATH"].toString() + val releaseKeyAlias = localProperties["RELEASE_KEY_ALIAS"].toString() + val releaseStorePassword = localProperties["RELEASE_KEYSTORE_PASSWORD"].toString() + val releaseKeyPassword = localProperties["RELEASE_KEY_PASSWORD"].toString() create("release") { storeFile = file(releaseStorePath) keyAlias = releaseKeyAlias @@ -96,20 +78,23 @@ android { } buildTypes { - val mapboxAccessToken = properties["MAPBOX_ACCESS_TOKEN"].toString() - val mapboxDownloadsToken = properties["MAPBOX_DOWNLOADS_TOKEN"].toString() - val mapboxSdkRegistryToken = properties["SDK_REGISTRY_TOKEN"].toString() + val mapboxAccessToken = localProperties["MAPBOX_ACCESS_TOKEN"].toString() + val mapboxDownloadsToken = localProperties["MAPBOX_DOWNLOADS_TOKEN"].toString() + val mapboxSdkRegistryToken = localProperties["SDK_REGISTRY_TOKEN"].toString() + val admobAppId = localProperties["ADMOB_APPLICATION_ID"].toString() getByName("debug") { isDebuggable = true - buildConfigField("String", "MapboxAccessToken", "\"$mapboxAccessToken\"") - buildConfigField("String", "MapboxDownloadsToken", "\"$mapboxDownloadsToken\"") - buildConfigField("String", "MapboxSdkRegistryToken", "\"$mapboxSdkRegistryToken\"") + buildConfigField("String", "MAPBOX_ACCESS_TOKEN", "\"$mapboxAccessToken\"") + buildConfigField("String", "MAPBOX_DOWNLOADS_TOKEN", "\"$mapboxDownloadsToken\"") + buildConfigField("String", "SDK_REGISTRY_TOKEN", "\"$mapboxSdkRegistryToken\"") + buildConfigField("String", "ADMOB_APPLICATION_ID", "\"$admobAppId\"") } getByName("release") { isDebuggable = false isMinifyEnabled = true isShrinkResources = true - buildConfigField("String", "MapboxAccessToken", "\"$mapboxAccessToken\"") + buildConfigField("String", "MAPBOX_ACCESS_TOKEN", "\"$mapboxAccessToken\"") + buildConfigField("String", "ADMOB_APPLICATION_ID", "\"$admobAppId\"") proguardFiles( getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro" @@ -293,3 +278,22 @@ hilt { room { schemaDirectory("$projectDir/schemas") } + +secrets { + // Ignore everything, except ADMOB_APPLICATION_ID for AndroidManifest.xml + ignoreList.addAll( + listOf( + "RELEASE_KEYSTORE_PASSWORD*", + "RELEASE_KEY_PASSWORD*", + "RELEASE_KEY_ALIAS*", + "RELEASE_KEY_PATH*", + "DEBUG_KEYSTORE_PASSWORD*", + "DEBUG_KEY_PASSWORD*", + "DEBUG_KEY_ALIAS*", + "DEBUG_KEY_PATH*", + "MAPBOX_DOWNLOADS_TOKEN*", + "SDK_REGISTRY_TOKEN*", + "MAPBOX_ACCESS_TOKEN*" + ) + ) +} diff --git a/app/src/main/java/illyan/jay/MainApplication.kt b/app/src/main/java/illyan/jay/MainApplication.kt index 7c4d9ca..ff895ae 100644 --- a/app/src/main/java/illyan/jay/MainApplication.kt +++ b/app/src/main/java/illyan/jay/MainApplication.kt @@ -53,7 +53,7 @@ class MainApplication : Application() { override fun onCreate() { super.onCreate() - MapboxOptions.accessToken = BuildConfig.MapboxAccessToken + MapboxOptions.accessToken = BuildConfig.MAPBOX_ACCESS_TOKEN initLogging() initAds() }