feat(voice-call): Implement direct voice call launch from assistant

This commit is contained in:
cogwheel0
2025-11-21 21:05:59 +05:30
parent daecceb342
commit 9d47c8a964
3 changed files with 73 additions and 5 deletions

View File

@@ -34,11 +34,10 @@ class ConduitVoiceInteractionSession(context: Context) : VoiceInteractionSession
launchApp()
}
// Voice button
// Voice button - opens voice call directly
val voiceButton = view.findViewById<android.view.View>(app.cogwheel.conduit.R.id.btn_voice)
voiceButton?.setOnClickListener {
// TODO: Implement voice input functionality
launchAppWithContext(includeScreenshot = false)
launchAppForVoiceCall()
}
return view
@@ -158,13 +157,32 @@ class ConduitVoiceInteractionSession(context: Context) : VoiceInteractionSession
}
}
private fun launchAppForVoiceCall() {
try {
android.util.Log.d("ConduitVoiceSession", "Attempting to launch app for voice call")
val intent = Intent(context, MainActivity::class.java)
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP)
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
intent.putExtra("start_voice_call", true)
android.util.Log.d("ConduitVoiceSession", "Voice call flag attached")
context.startActivity(intent)
android.util.Log.d("ConduitVoiceSession", "App launch requested for voice call")
finish() // Close the overlay
} catch (e: Exception) {
android.util.Log.e("ConduitVoiceSession", "Failed to launch app for voice call", e)
}
}
private fun traverseNode(node: AssistStructure.ViewNode?, builder: StringBuilder) {
if (node == null) return
if (node.text != null) {
builder.append(node.text).append("\n")
}
// Also check content description for accessibility text
if (node.contentDescription != null) {
builder.append(node.contentDescription).append("\n")

View File

@@ -50,12 +50,17 @@ class MainActivity : FlutterActivity() {
val screenContext = intent.getStringExtra("screen_context")
val screenshotPath = intent.getStringExtra("screenshot_path")
val startVoiceCall = intent.getBooleanExtra("start_voice_call", false)
android.util.Log.d("MainActivity", "screenContext: $screenContext")
android.util.Log.d("MainActivity", "screenshotPath: $screenshotPath")
android.util.Log.d("MainActivity", "startVoiceCall: $startVoiceCall")
android.util.Log.d("MainActivity", "methodChannel: $methodChannel")
if (screenContext != null) {
if (startVoiceCall) {
android.util.Log.d("MainActivity", "Invoking startVoiceCall")
methodChannel?.invokeMethod("startVoiceCall", null)
} else if (screenContext != null) {
android.util.Log.d("MainActivity", "Invoking analyzeScreen")
methodChannel?.invokeMethod("analyzeScreen", screenContext)
} else if (screenshotPath != null) {