|
|
@ -181,8 +181,20 @@ class MainActivity : AppCompatActivity() { |
|
|
vibrate(100) |
|
|
vibrate(100) |
|
|
if (finalText.isNotEmpty()) { |
|
|
if (finalText.isNotEmpty()) { |
|
|
updateLiveSpeechAtCursor(finalText, "") |
|
|
updateLiveSpeechAtCursor(finalText, "") |
|
|
binding.tvInstruction.text = getString(R.string.status_ready) |
|
|
|
|
|
|
|
|
val currentFullText = binding.etTranscript.text?.toString() ?: "" |
|
|
|
|
|
val cur = binding.etTranscript.selectionStart.coerceIn(0, currentFullText.length) |
|
|
|
|
|
AppLogger.log("Main", "🚀 ارسال خودکار متن به مک: '$finalText'") |
|
|
|
|
|
|
|
|
|
|
|
binding.tvInstruction.text = "✨ ارسال شد به مک" |
|
|
binding.tvInstruction.setTextColor(ContextCompat.getColor(this, R.color.accent_green)) |
|
|
binding.tvInstruction.setTextColor(ContextCompat.getColor(this, R.color.accent_green)) |
|
|
|
|
|
|
|
|
|
|
|
// Dual transport guarantee: |
|
|
|
|
|
// 1. WebSocket sync_state |
|
|
|
|
|
streamDictationClient?.sendLocalSyncState(currentFullText, cur) |
|
|
|
|
|
// 2. HTTP POST direct paste fallback |
|
|
|
|
|
lifecycleScope.launch { |
|
|
|
|
|
sendDirectPaste(currentFullText, cur) |
|
|
|
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
binding.tvInstruction.text = getString(R.string.status_ready) |
|
|
binding.tvInstruction.text = getString(R.string.status_ready) |
|
|
binding.tvInstruction.setTextColor(ContextCompat.getColor(this, R.color.text_secondary)) |
|
|
binding.tvInstruction.setTextColor(ContextCompat.getColor(this, R.color.text_secondary)) |
|
|
|