Skip to content

Commit 789d04b

Browse files
Add files via upload
1 parent 1024ff5 commit 789d04b

File tree

1 file changed

+3
-25
lines changed

1 file changed

+3
-25
lines changed

app/src/main/kotlin/com/google/ai/sample/feature/multimodal/PhotoReasoningViewModel.kt

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -317,16 +317,8 @@ class PhotoReasoningViewModel(
317317

318318
/**
319319
* Add a screenshot to the conversation
320-
*
321-
* @param screenshotUri URI of the screenshot
322-
* @param context Application context
323-
* @param screenInfo Optional information about screen elements (null if not available)
324320
*/
325-
fun addScreenshotToConversation(
326-
screenshotUri: Uri,
327-
context: android.content.Context,
328-
screenInfo: String? = null
329-
) {
321+
fun addScreenshotToConversation(screenshotUri: Uri, context: android.content.Context) {
330322
viewModelScope.launch(Dispatchers.Main) {
331323
try {
332324
Log.d(TAG, "Adding screenshot to conversation: $screenshotUri")
@@ -348,16 +340,9 @@ class PhotoReasoningViewModel(
348340
// Show toast
349341
Toast.makeText(context, "Verarbeite Screenshot...", Toast.LENGTH_SHORT).show()
350342

351-
// Create message text with screen information if available
352-
val messageText = if (screenInfo != null) {
353-
"Screenshot aufgenommen\n\n$screenInfo"
354-
} else {
355-
"Screenshot aufgenommen"
356-
}
357-
358343
// Add screenshot message to chat history
359344
val screenshotMessage = PhotoReasoningMessage(
360-
text = messageText,
345+
text = "Screenshot aufgenommen",
361346
participant = PhotoParticipant.USER,
362347
imageUris = listOf(screenshotUri.toString())
363348
)
@@ -392,15 +377,8 @@ class PhotoReasoningViewModel(
392377
// Show toast
393378
Toast.makeText(context, "Screenshot hinzugefügt, sende an KI...", Toast.LENGTH_SHORT).show()
394379

395-
// Create prompt with screen information if available
396-
val prompt = if (screenInfo != null) {
397-
"Analysiere diesen Screenshot. Hier sind die verfügbaren Bildschirmelemente: $screenInfo"
398-
} else {
399-
"Analysiere diesen Screenshot"
400-
}
401-
402380
// Re-send the query with the updated images
403-
reason(prompt, listOf(bitmap))
381+
reason("Analysiere diesen Screenshot", listOf(bitmap))
404382

405383
// Show a toast to indicate the screenshot was added
406384
Toast.makeText(context, "Screenshot zur Konversation hinzugefügt", Toast.LENGTH_SHORT).show()

0 commit comments

Comments
 (0)