feat(task): 添加任务详情页跳转和ASR语音控制功能
- 在AsrHelper中新增onOpenTaskDetail回调处理openTaskDetail语音命令 - 实现TaskListActivity中的routeToTask方法,根据任务类型跳转到对应详情页 - 添加FoActivity页面接收aiDescription和taskType参数并显示任务头部标题 - 集成ASR语音识别功能,支持通过语音命令打开指定任务详情页 - 在FoActivity布局中添加底部提示文本显示返回操作说明 - 清理废弃的IntentRecognizeHelper依赖和相关代码逻辑
这个提交包含在:
父节点
efa48f0094
当前提交
1207cfd177
@ -68,6 +68,9 @@ object AsrHelper : OfflineCmdListener {
|
||||
/** list 场景下由 TaskListActivity 注册,返回当前列表数据作为 extra 传给服务端 */
|
||||
var extraProvider: (() -> List<Any>)? = null
|
||||
|
||||
/** openTaskDetail 命中时的回调,由 TaskListActivity 在 onResume/onPause 中注册/清空 */
|
||||
var onOpenTaskDetail: ((action: RecognizeAction) -> Unit)? = null
|
||||
|
||||
/** scene == "decision" 时直接用 ASR 文本发起对话,由 ChatActivity 注册 */
|
||||
var onDirectChat: ((text: String) -> Unit)? = null
|
||||
|
||||
@ -208,6 +211,7 @@ object AsrHelper : OfflineCmdListener {
|
||||
when (action.name) {
|
||||
"goToDecisionCenter" -> onGoToDecisionCenter?.invoke(action)
|
||||
"goToTaskCenter" -> onGoToTaskCenter?.invoke(action)
|
||||
"openTaskDetail" -> onOpenTaskDetail?.invoke(action)
|
||||
else -> Log.d(TAG, "unhandled action: $action")
|
||||
}
|
||||
},
|
||||
|
||||
@ -24,7 +24,9 @@ class FoActivity : BaseActivity<ActivityFoBinding>() {
|
||||
}
|
||||
override fun initData() {
|
||||
super.initData()
|
||||
val html = ""
|
||||
val html = intent.getStringExtra("aiDescription") ?: ""
|
||||
val taskType = intent.getStringExtra("taskType") ?: ""
|
||||
binding.tvTaskHeader.text = taskType
|
||||
val styledHtml = """<html><head><style>
|
||||
* { color: #40FF5E !important; }
|
||||
body { margin: 0; padding: 0; background: transparent; }
|
||||
@ -37,7 +39,6 @@ class FoActivity : BaseActivity<ActivityFoBinding>() {
|
||||
setBackgroundColor(android.graphics.Color.TRANSPARENT)
|
||||
loadDataWithBaseURL(null, styledHtml, "text/html", "UTF-8", null)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
|
||||
@ -8,7 +8,6 @@ import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.nova.brain.glass.R
|
||||
import com.nova.brain.glass.databinding.ActivityTaskListBinding
|
||||
import com.nova.brain.glass.helper.AsrHelper
|
||||
import com.nova.brain.glass.helper.IntentRecognizeHelper
|
||||
import com.nova.brain.glass.helper.OfflineCmdListener
|
||||
import com.nova.brain.glass.helper.OfflineCmdServiceHelper
|
||||
import com.nova.brain.glass.model.TaskItem
|
||||
@ -108,27 +107,23 @@ class TaskListActivity :
|
||||
|
||||
private fun openTask(position: Int) {
|
||||
val item = viewModel.currentItems.getOrNull(position) ?: return
|
||||
Log.d("TaskListActivity", "openTask position=$position item=$item")
|
||||
// TODO: 根据 item.taskType / item.params 路由到对应 Activity
|
||||
routeToTask(item)
|
||||
}
|
||||
|
||||
IntentRecognizeHelper.recognize(
|
||||
text = "查看第三条任务",
|
||||
scence="list",
|
||||
actions = listOf("openTaskDetail", "openTaskDetailWithFilter"),
|
||||
extra = viewModel.currentItems.mapIndexed { i, item ->
|
||||
TaskExtraItem(
|
||||
index = i + 1,
|
||||
id = item.id,
|
||||
taskType = item.taskType,
|
||||
processStatus = item.processStatus,
|
||||
aiDescription = item.aiDescription
|
||||
)
|
||||
},
|
||||
onSuccess = { action ->
|
||||
},
|
||||
onComplete = {
|
||||
}
|
||||
)
|
||||
private fun routeToTask(item: TaskItem) {
|
||||
when (item.taskType) {
|
||||
"复材MES任务" -> startActivity(
|
||||
Intent(this, FoActivity::class.java)
|
||||
.putExtra("aiDescription", item.aiDescription)
|
||||
.putExtra("taskType", item.taskType)
|
||||
)
|
||||
"审核任务" -> startActivity(
|
||||
Intent(this, ReviewActivity::class.java)
|
||||
.putExtra("taskId", item.id)
|
||||
.putExtra("taskType", item.taskType)
|
||||
)
|
||||
else -> Log.d("TaskListActivity", "unknown taskType: ${item.taskType}")
|
||||
}
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
@ -148,9 +143,17 @@ class TaskListActivity :
|
||||
}
|
||||
}
|
||||
AsrHelper.onGoToDecisionCenter = { action ->
|
||||
// 暂只打日志,等确认返回结构后处理
|
||||
Log.d("TaskListActivity", "recognize result: $action")
|
||||
}
|
||||
AsrHelper.onOpenTaskDetail = { action ->
|
||||
val taskId = action.params.taskId
|
||||
val item = if (taskId.isNullOrEmpty()) {
|
||||
viewModel.currentItems.firstOrNull()
|
||||
} else {
|
||||
viewModel.currentItems.firstOrNull { it.id == taskId }
|
||||
}
|
||||
item?.let { routeToTask(it) }
|
||||
}
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
@ -160,6 +163,7 @@ class TaskListActivity :
|
||||
AsrHelper.scene = "home"
|
||||
AsrHelper.extraProvider = null
|
||||
AsrHelper.onGoToDecisionCenter = null
|
||||
AsrHelper.onOpenTaskDetail = null
|
||||
}
|
||||
|
||||
private val adapter = object : CommonPagedAdapter<TaskItem>(R.layout.item_task_list) {
|
||||
|
||||
@ -22,11 +22,26 @@
|
||||
android:id="@+id/content"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginTop="10dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
android:layout_marginVertical="10dp"
|
||||
app:layout_constraintBottom_toTopOf="@+id/hint"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tvTaskHeader" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/hint"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="28dp"
|
||||
android:layout_marginEnd="28dp"
|
||||
android:layout_marginBottom="56dp"
|
||||
android:gravity="center"
|
||||
android:lineSpacingExtra="6dp"
|
||||
android:text="双击或语音输入“返回”返回上级页面"
|
||||
android:textColor="#4AFE59"
|
||||
android:textSize="14sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</layout>
|
||||
正在加载...
在新工单中引用
屏蔽一个用户