Skip to content

Add Dropdown (Select) Support for HTTP TTS Configuration / 为 HTTP TTS 配置添加下拉框(select)支持#5782

Open
dallion wants to merge 1 commit into
gedoor:masterfrom
dallion:feature/tts-drop-box
Open

Add Dropdown (Select) Support for HTTP TTS Configuration / 为 HTTP TTS 配置添加下拉框(select)支持#5782
dallion wants to merge 1 commit into
gedoor:masterfrom
dallion:feature/tts-drop-box

Conversation

@dallion
Copy link
Copy Markdown

@dallion dallion commented Apr 22, 2026

Summary / 概述

This PR adds dropdown (select) UI component support to the HTTP TTS login configuration system in Legado application, allowing users to select parameters through dropdown selectors in TTS service configuration, improving configuration convenience and user experience.

本 PR 为 Legado 应用的 HTTP TTS 登录配置系统新增了下拉框(select)UI 组件支持,允许用户在 TTS 服务配置中使用下拉选择器进行参数选择,提升了配置的便捷性和用户体验。

Features / 功能变更

  • Extended RowUi data model with options field and select type constant

  • Created dedicated dropdown layout file item_source_spinner.xml

  • Implemented dynamic rendering, option binding, and data collection logic for dropdowns in SourceLoginDialog

  • Supports reading option lists from JSON configuration, automatic default value matching, and persisting user selections

  • Fully backward compatible, does not affect existing text, password, and button types

  • 扩展 RowUi 数据模型,新增 options 字段和 select 类型常量

  • 创建专用下拉框布局文件 item_source_spinner.xml

  • 在 SourceLoginDialog 中实现下拉框的动态渲染、选项绑定和数据收集逻辑

  • 支持从 JSON 配置读取选项列表、自动匹配默认值、持久化用户选择

  • 完全向后兼容,不影响现有的 text、password、button 类型

Main files / 主要涉及文件

  • app/src/main/java/io/legado/app/data/entities/rule/RowUi.kt - Data model extension / 数据模型扩展
  • app/src/main/java/io/legado/app/ui/login/SourceLoginDialog.kt - Dialog logic enhancement / 对话框逻辑增强
  • app/src/main/res/layout/item_source_spinner.xml - New layout file / 新增布局文件
  • app/src/main/assets/defaultData/httpTTS.json - Configuration example / 配置示例

Testing / 测试

  • Compilation passed without syntax errors / 编译通过,无语法错误
  • Debug APK packaged successfully (31MB) / Debug APK 打包成功(31MB)
  • Dropdown renders correctly and displays all options / 下拉框正确渲染并显示所有选项
  • Selected options are saved and restored correctly / 选项选择后数据正确保存和恢复
  • No conflicts with existing UI types / 与现有 UI 类型共存无冲突

- 扩展 RowUi 数据类: 添加 options 字段和 select 类型常量
- 创建 item_source_spinner.xml 布局文件: 使用 Android Spinner 控件实现下拉框UI
- 修改 SourceLoginDialog.kt:
  * 添加 ItemSourceSpinnerBinding 导入
  * 实现 select 类型的渲染逻辑,支持 ArrayAdapter 和默认值设置
  * 添加 select 类型的数据获取逻辑,从 Spinner 读取选中值
- 优化 httpTTS.json 配置:
  * 清理 18 个重复的 Qwen3-TTS 独立配置(id: -30 至 -47)
  * 新增通用配置(id: -48),通过下拉框选择音色(18种选项)
  * 简化 loginUrl 为纯参数验证,不进行 HTTP 请求
  * 修复 loginCheckJs 避免消费响应流导致 closed 错误

技术要点:
- loginCheckJs 直接返回 result,不调用 response.body().string() 消费流
- Spinner 使用 index + 1000 作为 view ID,便于数据获取时查找
- 动态音色通过 {{source.getLoginInfoMap().get('Voice')}} 引用
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant