顶部 推荐 agent 列表实现

This commit is contained in:
2025-10-17 17:21:52 +08:00
parent 4bdbbb0231
commit 28fb94a824
3 changed files with 145 additions and 16 deletions

View File

@@ -63,6 +63,23 @@ object Utils {
return Locale.getDefault().language
}
/**
* 获取完整的语言标记,如 "zh-CN", "en-US"
* 优先使用完整的 BCP-47 语言标记,提升与后端 translations 键的匹配率
*/
fun getPreferredLanguageTag(): String {
val locale = Locale.getDefault()
val language = locale.language
val country = locale.country
// 如果有国家/地区代码,返回完整的语言标记
return if (country.isNotEmpty()) {
"$language-$country"
} else {
language
}
}
fun compressImage(context: Context, uri: Uri, maxSize: Int = 512, quality: Int = 85): File {
val inputStream = context.contentResolver.openInputStream(uri)
val originalBitmap = BitmapFactory.decodeStream(inputStream)