Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true

[*.{kt,kts}]
ij_kotlin_code_style_defaults = KOTLIN_OFFICIAL
ktlint_code_style = intellij_idea
62 changes: 62 additions & 0 deletions .github/workflows/build-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Build Check

on:
push:
branches: ["*"]
paths-ignore:
- "**.md"
- "**.txt"
- "docs/**"
- ".gitignore"
- "LICENSE"
pull_request:
types:
- opened
- reopened
- synchronize

concurrency:
group: build-check
cancel-in-progress: true

jobs:
build:
name: Build Check
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Java 21
uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: "21"
cache: "gradle"

- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v2

- name: Set up Gradle
uses: gradle/actions/setup-gradle@v3

- name: Check code style
run: |
./gradlew --no-daemon ktlintCheck

- name: Set up Android SDK
uses: android-actions/setup-android@v3
with:
api-level: 34
build-tools: 34.0.0

- name: Build Debug APK
run: |
./gradlew --no-daemon clean assembleDebug

- name: Upload Debug APK
uses: actions/upload-artifact@v4
with:
name: debug-apk
path: app/build/outputs/apk/debug/*.apk
retention-days: 7
12 changes: 7 additions & 5 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
id("org.jetbrains.kotlin.plugin.serialization") version "2.2.20"
id("org.jlleitschuh.gradle.ktlint")
}

android {
Expand Down Expand Up @@ -31,7 +32,8 @@ android {
signingConfigs {
create("release") {
// 从环境变量读取签名配置
storeFile = System.getenv("KEYSTORE_FILE")?.let { file(it) }
val keystoreFile = System.getenv("KEYSTORE_FILE")
storeFile = keystoreFile?.takeIf { it.isNotBlank() }?.let { file(it) }
storePassword = System.getenv("KEYSTORE_PASSWORD")
keyAlias = System.getenv("KEY_ALIAS")
keyPassword = System.getenv("KEY_PASSWORD")
Expand All @@ -46,7 +48,7 @@ android {

proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
"proguard-rules.pro",
)

signingConfig = signingConfigs.findByName("release")?.takeIf {
Expand Down Expand Up @@ -86,14 +88,14 @@ android {
excludes += listOf(
"**/libonnxruntime4j_jni.so",
"**/libsherpa-onnx-c-api.so",
"**/libsherpa-onnx-cxx-api.so"
"**/libsherpa-onnx-cxx-api.so",
)
}
resources {
excludes += listOf(
"META-INF/services/lombok.*",
"README.md",
"META-INF/README.md"
"META-INF/README.md",
)
}
}
Expand All @@ -113,7 +115,7 @@ tasks.withType(JavaCompile::class.java).configureEach {
javaCompiler.set(
toolchainService.compilerFor {
languageVersion.set(JavaLanguageVersion.of(21))
}
},
)
}

Expand Down
12 changes: 6 additions & 6 deletions app/src/main/java/com/brycewg/asrkb/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@
*/
package com.brycewg.asrkb

import android.app.Application
import android.app.Activity
import android.app.ActivityManager
import android.os.Bundle
import android.app.Application
import android.content.Intent
import android.os.Bundle
import android.provider.Settings
import android.util.Log
import com.google.android.material.color.DynamicColors
import com.brycewg.asrkb.store.Prefs
import androidx.appcompat.app.AppCompatDelegate
import androidx.core.os.LocaleListCompat
import com.brycewg.asrkb.analytics.AnalyticsManager
import com.brycewg.asrkb.asr.VadDetector
import com.brycewg.asrkb.store.Prefs
import com.brycewg.asrkb.ui.floating.FloatingAsrService
import com.brycewg.asrkb.ui.floating.FloatingKeepAliveService
import com.brycewg.asrkb.ui.floating.PrivilegedKeepAliveScheduler
import com.brycewg.asrkb.ui.floating.PrivilegedKeepAliveStarter
import com.brycewg.asrkb.asr.VadDetector
import com.brycewg.asrkb.analytics.AnalyticsManager
import com.google.android.material.color.DynamicColors
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.SupervisorJob
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/brycewg/asrkb/BootReceiver.kt
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class BootReceiver : BroadcastReceiver() {
context,
"keepalive",
"boot_start_result",
mapOf("ok" to false, "method" to result.method.name.lowercase(), "exit" to result.exitCode)
mapOf("ok" to false, "method" to result.method.name.lowercase(), "exit" to result.exitCode),
)
}
} catch (t: Throwable) {
Expand Down
34 changes: 17 additions & 17 deletions app/src/main/java/com/brycewg/asrkb/LocaleHelper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@ import androidx.core.os.LocaleListCompat
import java.util.Locale

object LocaleHelper {
fun wrap(newBase: Context): Context {
val locales = AppCompatDelegate.getApplicationLocales()
if (locales.isEmpty) return newBase
val config = Configuration(newBase.resources.configuration)
applyLocales(config, locales)
return newBase.createConfigurationContext(config)
}
fun wrap(newBase: Context): Context {
val locales = AppCompatDelegate.getApplicationLocales()
if (locales.isEmpty) return newBase
val config = Configuration(newBase.resources.configuration)
applyLocales(config, locales)
return newBase.createConfigurationContext(config)
}

private fun applyLocales(config: Configuration, locales: LocaleListCompat) {
if (locales.isEmpty) return
val tags = locales.toLanguageTags()
if (tags.isEmpty()) return
val localeList = LocaleList.forLanguageTags(tags)
if (localeList.isEmpty) return
config.setLocales(localeList)
LocaleList.setDefault(localeList)
Locale.setDefault(localeList[0])
}
private fun applyLocales(config: Configuration, locales: LocaleListCompat) {
if (locales.isEmpty) return
val tags = locales.toLanguageTags()
if (tags.isEmpty()) return
val localeList = LocaleList.forLanguageTags(tags)
if (localeList.isEmpty) return
config.setLocales(localeList)
LocaleList.setDefault(localeList)
Locale.setDefault(localeList[0])
}
}
6 changes: 0 additions & 6 deletions app/src/main/java/com/brycewg/asrkb/UiColorTokens.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ object UiColorTokens {
/** 容器前景色 */
val containerFg = com.google.android.material.R.attr.colorOnSurfaceVariant


// ==================== 键盘相关 ====================

/** 键盘按键背景 */
Expand All @@ -37,7 +36,6 @@ object UiColorTokens {
/** 键盘容器背景 */
val kbdContainerBg = com.google.android.material.R.attr.colorSurfaceVariant


// ==================== 强调与状态色 ====================

/** 主强调色(主要操作按钮等) */
Expand Down Expand Up @@ -76,7 +74,6 @@ object UiColorTokens {
/** 错误容器前景色 */
val onErrorContainer = com.google.android.material.R.attr.colorOnErrorContainer


// ==================== 选中与高亮 ====================

/** 选中项背景色 */
Expand All @@ -91,7 +88,6 @@ object UiColorTokens {
/** 遮罩色(用于暗化/系统栏对齐等) */
val scrim = R.attr.asrScrimColor


// ==================== 边框与分割线 ====================

/** 主要边框色 */
Expand All @@ -100,7 +96,6 @@ object UiColorTokens {
/** 次要边框色(更淡) */
val outlineVariant = com.google.android.material.R.attr.colorOutlineVariant


// ==================== 悬浮球相关 ====================

/** 悬浮球容器背景 */
Expand All @@ -112,7 +107,6 @@ object UiColorTokens {
/** 悬浮球错误状态色 */
val floatingError = android.R.attr.colorError


// ==================== 状态芯片 ====================

/** 芯片背景色 */
Expand Down
16 changes: 10 additions & 6 deletions app/src/main/java/com/brycewg/asrkb/aidl/SpeechConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,16 @@ import android.os.Parcelable
* 为保持向后兼容,新增字段请保持可空并提供合理默认。
*/
data class SpeechConfig(
val vendorId: String? = null, // 供应商ID(如 "volc"、"soniox");为空则按应用内设置
val streamingPreferred: Boolean = true,// 调用方偏好流式(若供应商/设置不支持则回落)
val punctuationEnabled: Boolean? = null,// 标点开关(部分供应商有效);null=按应用设置
val autoStopOnSilence: Boolean? = null,// 静音自动判停(null=按应用设置)
val sessionTag: String? = null // 调用方自定义标记,用于打点/排障
// 供应商ID(如 "volc"、"soniox");为空则按应用内设置
val vendorId: String? = null,
// 调用方偏好流式(若供应商/设置不支持则回落)
val streamingPreferred: Boolean = true,
// 标点开关(部分供应商有效);null=按应用设置
val punctuationEnabled: Boolean? = null,
// 静音自动判停(null=按应用设置)
val autoStopOnSilence: Boolean? = null,
// 调用方自定义标记,用于打点/排障
val sessionTag: String? = null,
) : Parcelable {
override fun writeToParcel(dest: Parcel, flags: Int) {
dest.writeString(vendorId)
Expand Down Expand Up @@ -51,4 +56,3 @@ data class SpeechConfig(
}
}
}

Loading