Skip to content

armgit / andee

Public Imported from GitHub
0

Andee lives on your phone or Mac and uses any app like you do—no integrations, no root, any model; memory and passwords never leave your device | Andee 住进你的手机或 Mac,像你一样操作任何 App——无需集成、无需 Root、支持任意模型,记忆和密码绝不离开设备。

feat: setting build config

Yake63266ee378a5
diff --git a/app/build.gradle b/app/build.gradle
index a65de2a..5021118 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -3,10 +3,28 @@ plugins {
id 'org.jetbrains.kotlin.android' version '1.9.22'
}
+def localProps = new Properties()
+def localPropsFile = rootProject.file('local.properties')
+if (localPropsFile.exists()) {
+ localPropsFile.withInputStream { localProps.load(it) }
+}
+static def escapeStringLiteral(String value) {
+ if (value == null) return '""'
+ return '"' + value.replace('\\', '\\\\').replace('"', '\\"') + '"'
+}
+def buildConfigString = { String key ->
+ escapeStringLiteral(localProps.getProperty(key, ''))
+}
+
android {
namespace 'net.kuafuai.andee'
compileSdk 34
+ buildFeatures {
+ // AGP 8 默认关掉了。开出来就能用 BuildConfig.XXX。
+ buildConfig true
+ }
+
defaultConfig {
applicationId "net.kuafuai.andee"
minSdk 30
@@ -15,6 +33,11 @@ android {
versionName "1.0.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
+
+ buildConfigField "String", "ASR_ENDPOINT", buildConfigString('ASR_ENDPOINT')
+ buildConfigField "String", "TTS_ENDPOINT", buildConfigString('TTS_ENDPOINT')
+ buildConfigField "String", "API_KEY", buildConfigString('API_KEY')
+ buildConfigField "String", "LLM_BASE_URL", buildConfigString('LLM_BASE_URL')
}
buildTypes {
diff --git a/app/src/main/java/net/kuafuai/andee/config/VoiceConfig.kt b/app/src/main/java/net/kuafuai/andee/config/VoiceConfig.kt
index f52d5f5..18bfb1d 100644
--- a/app/src/main/java/net/kuafuai/andee/config/VoiceConfig.kt
+++ b/app/src/main/java/net/kuafuai/andee/config/VoiceConfig.kt
@@ -1,6 +1,7 @@
package net.kuafuai.andee.config
import android.content.Context
+import net.kuafuai.andee.BuildConfig
import java.util.UUID
@@ -134,11 +135,11 @@ data class VoiceConfig(
}
return BrainConfig(
mode = mode,
- apiKey = p.getString("llm_api_key", "").orEmpty().trim(),
+ apiKey = p.getString("llm_api_key", "").orEmpty().trim().ifEmpty { BuildConfig.API_KEY },
// trimEnd('/') because the client appends "/chat/completions"
// and a trailing slash from the settings field would produce a
// double slash, which some gateways 404 on.
- baseUrl = p.getString("llm_base_url", DEFAULT_LLM_BASE_URL)
+ baseUrl = p.getString("llm_base_url", BuildConfig.LLM_BASE_URL)
.orEmpty().trim().trimEnd('/').ifEmpty { DEFAULT_LLM_BASE_URL },
model = p.getString("llm_model", DEFAULT_LLM_MODEL)
.orEmpty().trim().ifEmpty { DEFAULT_LLM_MODEL },
@@ -205,11 +206,11 @@ data class VoiceConfig(
// Empty in prefs → [API_KEY], which is itself empty in the
// public source. Trim before the fallback so a field cleared to
// spaces behaves like a cleared field.
- apiKey = p.getString("api_key", "").orEmpty().trim().ifEmpty { API_KEY },
- asrEndpoint = p.getString("asr_endpoint", DEFAULT_ASR_ENDPOINT)!!,
+ apiKey = p.getString("api_key", "").orEmpty().trim().ifEmpty { BuildConfig.API_KEY },
+ asrEndpoint = p.getString("asr_endpoint", BuildConfig.ASR_ENDPOINT)!!,
asrResourceId = p.getString("asr_resource_id", DEFAULT_ASR_RESOURCE)!!,
asrUid = uid,
- ttsEndpoint = p.getString("tts_endpoint", DEFAULT_TTS_ENDPOINT)!!,
+ ttsEndpoint = p.getString("tts_endpoint", BuildConfig.TTS_ENDPOINT)!!,
ttsResourceId = p.getString("tts_resource_id", DEFAULT_TTS_RESOURCE)!!,
// The voice follows the ball's look; [TTS_SPEAKER] is the
// fallback for looks that don't name one.