diff --git a/android_app/app/build.gradle.kts b/android_app/app/build.gradle.kts index 827f9286..573785ea 100644 --- a/android_app/app/build.gradle.kts +++ b/android_app/app/build.gradle.kts @@ -1,3 +1,7 @@ +import java.io.FileInputStream +import java.io.FileNotFoundException +import java.util.Properties + plugins { alias(libs.plugins.android.application) alias(libs.plugins.kotlin.android) @@ -22,19 +26,86 @@ android { manifestPlaceholders["appRoundIcon"] = "@mipmap/ic_launcher_round" } + signingConfigs { + create("release") { + val keystorePropertiesFile = rootProject.file("../../openScale.keystore") + val keystoreProperties = Properties() + var propertiesLoaded : Boolean + + try { + FileInputStream(keystorePropertiesFile).use { fis -> + keystoreProperties.load(fis) + } + propertiesLoaded = true + } catch (e: FileNotFoundException) { + project.logger.warn("Keystore properties file not found: ${keystorePropertiesFile.absolutePath}. Release signing might fail if not configured via environment variables.") + propertiesLoaded = false + } + + if (propertiesLoaded && keystoreProperties.containsKey("releaseKeyStore")) { + storeFile = file(rootProject.projectDir.canonicalPath + "/" + keystoreProperties.getProperty("releaseKeyStore")) + keyAlias = keystoreProperties.getProperty("releaseKeyAlias") + keyPassword = keystoreProperties.getProperty("releaseKeyPassword") + storePassword = keystoreProperties.getProperty("releaseStorePassword") + } else { + project.logger.warn("Release signing information not fully loaded from properties. Ensure it's set via environment variables or the properties file is correct.") + } + } + + create("oss") { + val keystoreOSSPropertiesFile = rootProject.file("../../openScale_oss.keystore") + val keystoreOSSProperties = Properties() + var propertiesLoaded : Boolean + + try { + FileInputStream(keystoreOSSPropertiesFile).use { fis -> + keystoreOSSProperties.load(fis) + } + propertiesLoaded = true + } catch (e: FileNotFoundException) { + project.logger.warn("OSS Keystore properties file not found: ${keystoreOSSPropertiesFile.absolutePath}. OSS signing might fail if not configured via environment variables.") + propertiesLoaded = false + } + + if (propertiesLoaded && keystoreOSSProperties.containsKey("releaseKeyStore")) { + storeFile = file(rootProject.projectDir.canonicalPath + "/" + keystoreOSSProperties.getProperty("releaseKeyStore")) + keyAlias = keystoreOSSProperties.getProperty("releaseKeyAlias") + keyPassword = keystoreOSSProperties.getProperty("releaseKeyPassword") + storePassword = keystoreOSSProperties.getProperty("releaseStorePassword") + } else { + project.logger.warn("OSS signing information not fully loaded from properties. Ensure it's set via environment variables or the properties file is correct.") + } + } + } + buildTypes { release { - isMinifyEnabled = false + signingConfig = signingConfigs.getByName("release") + proguardFiles( + getDefaultProguardFile("proguard-android-optimize.txt"), + "proguard-rules.pro" + ) } create("beta") { - initWith(getByName("debug")) + initWith(getByName("release")) + signingConfig = signingConfigs.getByName("release") applicationIdSuffix = ".beta" versionNameSuffix = "-beta" manifestPlaceholders["appName"] = "openScale beta" manifestPlaceholders["appIcon"] = "@mipmap/ic_launcher_beta" manifestPlaceholders["appRoundIcon"] = "@mipmap/ic_launcher_beta_round" } + + create("oss") { + initWith(getByName("release")) + signingConfig = signingConfigs.getByName("oss") + applicationIdSuffix = ".oss" + versionNameSuffix = "-oss" + manifestPlaceholders["appName"] = "openScale" + manifestPlaceholders["appIcon"] = "@mipmap/ic_launcher_beta" + manifestPlaceholders["appRoundIcon"] = "@mipmap/ic_launcher_beta_round" + } } applicationVariants.all { diff --git a/android_app/app/proguard-rules.pro b/android_app/app/proguard-rules.pro new file mode 100644 index 00000000..11fece02 --- /dev/null +++ b/android_app/app/proguard-rules.pro @@ -0,0 +1,26 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile +-keepclassmembernames class io.netty.** { *; } +-keepclassmembers class org.jctools.** { *; } +-keep class * { *; } +-keep interface * { *; } +-keep enum * { *; } \ No newline at end of file diff --git a/android_app/app/src/main/java/com/health/openscale/ui/navigation/AppNavigation.kt b/android_app/app/src/main/java/com/health/openscale/ui/navigation/AppNavigation.kt index 8923e527..6a4f2fa5 100644 --- a/android_app/app/src/main/java/com/health/openscale/ui/navigation/AppNavigation.kt +++ b/android_app/app/src/main/java/com/health/openscale/ui/navigation/AppNavigation.kt @@ -236,7 +236,7 @@ fun AppNavigation(sharedViewModel: SharedViewModel) { .fillMaxWidth() ) { Image( - painter = if (BuildConfig.BUILD_TYPE == "beta") painterResource(id = R.drawable.ic_launcher_beta_foreground) else painterResource(id = R.drawable.ic_launcher_foreground) , + painter = if (BuildConfig.BUILD_TYPE == "beta" || BuildConfig.BUILD_TYPE == "oss") painterResource(id = R.drawable.ic_launcher_beta_foreground) else painterResource(id = R.drawable.ic_launcher_foreground) , contentDescription = stringResource(R.string.app_logo_content_description), modifier = Modifier.size(64.dp) ) diff --git a/android_app/app/src/main/java/com/health/openscale/ui/screen/settings/AboutScreen.kt b/android_app/app/src/main/java/com/health/openscale/ui/screen/settings/AboutScreen.kt index c37ad7f1..57dfc20a 100644 --- a/android_app/app/src/main/java/com/health/openscale/ui/screen/settings/AboutScreen.kt +++ b/android_app/app/src/main/java/com/health/openscale/ui/screen/settings/AboutScreen.kt @@ -17,6 +17,7 @@ */ package com.health.openscale.ui.screen.settings +import android.R.attr.contentDescription import androidx.compose.foundation.Image import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Column @@ -91,7 +92,7 @@ fun AboutScreen( horizontalAlignment = Alignment.CenterHorizontally ) { Image( - painter = if (BuildConfig.BUILD_TYPE == "beta") painterResource(id = R.drawable.ic_launcher_beta_foreground) else painterResource(id = R.drawable.ic_launcher_foreground) , + painter = if (BuildConfig.BUILD_TYPE == "beta" || BuildConfig.BUILD_TYPE == "oss") painterResource(id = R.drawable.ic_launcher_beta_foreground) else painterResource(id = R.drawable.ic_launcher_foreground) , contentDescription = stringResource(R.string.app_logo_content_description), modifier = Modifier .size(128.dp)