fix: 修复SLMS特色功能构建错误 - SmartReminderService使用ic_notifications替代ic_launcher_foreground - ImmersiveReadingActivity修复TTS服务调用方式 - TranslationActivity修复TTS服务调用方式

main
SLMS Development Team 4 months ago
parent ab33cd53fe
commit 87f168cc2f

@ -272,7 +272,7 @@ public class SmartReminderService {
*/
private void sendNotification(int notificationId, String channelId, String title, String content, int priority) {
NotificationCompat.Builder builder = new NotificationCompat.Builder(context, channelId)
.setSmallIcon(R.drawable.ic_launcher_foreground)
.setSmallIcon(R.drawable.ic_notifications)
.setContentTitle(title)
.setContentText(content)
.setStyle(new NotificationCompat.BigTextStyle().bigText(content))

@ -65,7 +65,8 @@ public class ImmersiveReadingActivity extends AppCompatActivity {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
immersiveService = ImmersiveReadingService.getInstance(this);
ttsService = TextToSpeechService.getInstance(this);
ttsService = TextToSpeechService.getInstance();
ttsService.initialize(this);
initViews();
applyCurrentTheme();
@ -241,9 +242,32 @@ public class ImmersiveReadingActivity extends AppCompatActivity {
Toast.makeText(this, "已停止朗读", Toast.LENGTH_SHORT).show();
} else {
String content = tvContent.getText().toString();
ttsService.speak(content);
isSpeaking = true;
btnSpeak.setText("⏹️ 停止");
ttsService.speak(content, new TextToSpeechService.TTSCallback() {
@Override
public void onStart() {
runOnUiThread(() -> {
isSpeaking = true;
btnSpeak.setText("⏹️ 停止");
});
}
@Override
public void onComplete() {
runOnUiThread(() -> {
isSpeaking = false;
btnSpeak.setText("🔊 朗读");
});
}
@Override
public void onError(String error) {
runOnUiThread(() -> {
isSpeaking = false;
btnSpeak.setText("🔊 朗读");
Toast.makeText(ImmersiveReadingActivity.this, "朗读失败: " + error, Toast.LENGTH_SHORT).show();
});
}
});
Toast.makeText(this, "开始朗读...", Toast.LENGTH_SHORT).show();
}
}

@ -71,7 +71,8 @@ public class TranslationActivity extends AppCompatActivity {
setContentView(R.layout.activity_translation);
translationService = TranslationService.getInstance(this);
ttsService = TextToSpeechService.getInstance(this);
ttsService = TextToSpeechService.getInstance();
ttsService.initialize(this);
initViews();
setupLanguageSpinners();
@ -244,7 +245,25 @@ public class TranslationActivity extends AppCompatActivity {
return;
}
ttsService.speak(text);
ttsService.speak(text, new TextToSpeechService.TTSCallback() {
@Override
public void onStart() {
runOnUiThread(() -> btnSpeak.setText("🔊 朗读中..."));
}
@Override
public void onComplete() {
runOnUiThread(() -> btnSpeak.setText("🔊 朗读"));
}
@Override
public void onError(String error) {
runOnUiThread(() -> {
btnSpeak.setText("🔊 朗读");
Toast.makeText(TranslationActivity.this, "朗读失败: " + error, Toast.LENGTH_SHORT).show();
});
}
});
}
@Override

Loading…
Cancel
Save