fix: 一次性优化(时钟去秒+备注修复+按钮放大+切换取消)
1. 首页时钟 HH:mm:ss → HH:mm 2. TTS 备注优先读 taskRequire(和页面显示一致) 3. TTS 按钮 48dp → 56dp,背景透明度 50% → 30% 4. 切换任务时取消进行中的 TTS 合成请求 安装后请重启手表。 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -80,6 +80,9 @@ class EdgeTtsManager @Inject constructor(
|
|||||||
/** 当前 MediaPlayer */
|
/** 当前 MediaPlayer */
|
||||||
private var mediaPlayer: MediaPlayer? = null
|
private var mediaPlayer: MediaPlayer? = null
|
||||||
|
|
||||||
|
/** 当前合成协程 Job(用于取消进行中的请求) */
|
||||||
|
private var synthesizeJob: kotlinx.coroutines.Job? = null
|
||||||
|
|
||||||
/** 是否正在播放 */
|
/** 是否正在播放 */
|
||||||
var isPlaying: Boolean = false
|
var isPlaying: Boolean = false
|
||||||
private set
|
private set
|
||||||
@@ -99,10 +102,10 @@ class EdgeTtsManager @Inject constructor(
|
|||||||
fun speak(text: String, voice: String = VOICE_XIAOXIAO, onError: ((String) -> Unit)? = null) {
|
fun speak(text: String, voice: String = VOICE_XIAOXIAO, onError: ((String) -> Unit)? = null) {
|
||||||
if (text.isBlank()) return
|
if (text.isBlank()) return
|
||||||
|
|
||||||
// 停止当前播放
|
// 停止当前播放和进行中的请求
|
||||||
stop()
|
stop()
|
||||||
|
|
||||||
CoroutineScope(Dispatchers.IO).launch {
|
synthesizeJob = CoroutineScope(Dispatchers.IO).launch {
|
||||||
try {
|
try {
|
||||||
// 检查缓存
|
// 检查缓存
|
||||||
val cacheFile = getCacheFile(text, voice)
|
val cacheFile = getCacheFile(text, voice)
|
||||||
@@ -129,8 +132,10 @@ class EdgeTtsManager @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 停止播放 */
|
/** 停止播放和进行中的合成请求 */
|
||||||
fun stop() {
|
fun stop() {
|
||||||
|
synthesizeJob?.cancel()
|
||||||
|
synthesizeJob = null
|
||||||
try {
|
try {
|
||||||
mediaPlayer?.apply {
|
mediaPlayer?.apply {
|
||||||
if (isPlaying) stop()
|
if (isPlaying) stop()
|
||||||
|
|||||||
@@ -367,7 +367,7 @@ class HomeFragment : BaseFragment<FragmentHomeBinding>() {
|
|||||||
/** 更新时钟和日期 */
|
/** 更新时钟和日期 */
|
||||||
private fun updateClock() {
|
private fun updateClock() {
|
||||||
val info = DateUtil.getDateInfo()
|
val info = DateUtil.getDateInfo()
|
||||||
tvClock.text = DateUtil.formatTime()
|
tvClock.text = DateUtil.formatTimeShort()
|
||||||
tvDate.text = "${info.month}月${info.day}日 ${info.week}"
|
tvDate.text = "${info.month}月${info.day}日 ${info.week}"
|
||||||
// 同步更新打卡面板时钟
|
// 同步更新打卡面板时钟
|
||||||
if (punchPanel.isShowing) {
|
if (punchPanel.isShowing) {
|
||||||
|
|||||||
@@ -1042,7 +1042,13 @@ class TaskListFragment : BaseFragment<FragmentTaskListBinding>() {
|
|||||||
!detail.expireTime.isNullOrEmpty() -> parts.add("截止时间:${formatTimeForTts(detail.expireTime!!)}")
|
!detail.expireTime.isNullOrEmpty() -> parts.add("截止时间:${formatTimeForTts(detail.expireTime!!)}")
|
||||||
}
|
}
|
||||||
if (detail.point > 0) parts.add("积分:${detail.point.toInt()}分")
|
if (detail.point > 0) parts.add("积分:${detail.point.toInt()}分")
|
||||||
if (detail.content.isNotBlank()) parts.add("备注:${detail.content}")
|
// 备注:优先 taskRequire,没有则用 content(和页面显示逻辑一致)
|
||||||
|
val note = when {
|
||||||
|
!detail.taskRequire.isNullOrEmpty() -> detail.taskRequire
|
||||||
|
detail.content.isNotEmpty() -> detail.content
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
|
if (!note.isNullOrBlank()) parts.add("备注:$note")
|
||||||
|
|
||||||
if (parts.isEmpty()) return
|
if (parts.isEmpty()) return
|
||||||
|
|
||||||
|
|||||||
@@ -2,5 +2,5 @@
|
|||||||
<!-- TTS 悬浮按钮背景:半透明圆形 -->
|
<!-- TTS 悬浮按钮背景:半透明圆形 -->
|
||||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:shape="oval">
|
android:shape="oval">
|
||||||
<solid android:color="#80FFFFFF" />
|
<solid android:color="#4DFFFFFF" />
|
||||||
</shape>
|
</shape>
|
||||||
|
|||||||
@@ -365,14 +365,14 @@
|
|||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|
||||||
<!-- TTS 语音播报悬浮按钮:右侧垂直居中,48dp 触摸区 -->
|
<!-- TTS 语音播报悬浮按钮:右侧垂直居中,56dp 触摸区 -->
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/btnTts"
|
android:id="@+id/btnTts"
|
||||||
android:layout_width="48dp"
|
android:layout_width="56dp"
|
||||||
android:layout_height="48dp"
|
android:layout_height="56dp"
|
||||||
android:layout_gravity="center_vertical|end"
|
android:layout_gravity="center_vertical|end"
|
||||||
android:layout_marginEnd="4dp"
|
android:layout_marginEnd="4dp"
|
||||||
android:padding="8dp"
|
android:padding="10dp"
|
||||||
android:src="@drawable/ic_speaker"
|
android:src="@drawable/ic_speaker"
|
||||||
android:background="@drawable/bg_tts_button"
|
android:background="@drawable/bg_tts_button"
|
||||||
android:contentDescription="语音播报" />
|
android:contentDescription="语音播报" />
|
||||||
|
|||||||
Reference in New Issue
Block a user