1
0
mirror of https://github.com/oliexdev/openScale.git synced 2025-08-12 11:44:19 +02:00

Add ProGuard rules and OSS build type

This commit is contained in:
oliexdev
2025-08-06 10:25:34 +02:00
parent 5a87f1452b
commit 9e045553ef
4 changed files with 102 additions and 4 deletions

View File

@@ -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 {

26
android_app/app/proguard-rules.pro vendored Normal file
View File

@@ -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 * { *; }

View File

@@ -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)
)

View File

@@ -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)