Skip to content

Commit e17f577

Browse files
Add files via upload
1 parent 2927d63 commit e17f577

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -187,15 +187,15 @@ class PhotoReasoningViewModel(
187187
*/
188188
private fun saveChatHistory(context: Context?) {
189189
if (context != null) {
190-
ChatHistoryPreferences.saveChatHistory(context, chatMessages)
190+
ChatHistoryPreferences.saveChatMessages(context, chatMessages)
191191
}
192192
}
193193

194194
/**
195195
* Load chat history from SharedPreferences
196196
*/
197197
fun loadChatHistory(context: Context) {
198-
val history = ChatHistoryPreferences.loadChatHistory(context)
198+
val history = ChatHistoryPreferences.loadChatMessages(context)
199199
chatMessages.clear()
200200
chatMessages.addAll(history)
201201
_chatMessagesFlow.value = chatMessages.toList()
@@ -207,7 +207,7 @@ class PhotoReasoningViewModel(
207207
fun clearChatHistory(context: Context) {
208208
chatMessages.clear()
209209
_chatMessagesFlow.value = emptyList()
210-
ChatHistoryPreferences.clearChatHistory(context)
210+
ChatHistoryPreferences.clearChatMessages(context)
211211
}
212212

213213
/**
@@ -360,13 +360,13 @@ class PhotoReasoningViewModel(
360360
/**
361361
* Add a screenshot to the conversation
362362
*/
363-
fun addScreenshotToConversation(screenshotUri: Uri) {
363+
fun addScreenshotToConversation(screenshotUri: Uri, context: Context, screenInfo: String) {
364364
// Store the latest screenshot URI
365365
latestScreenshotUri = screenshotUri
366366

367367
// Add a user message with the screenshot
368368
val userMessage = PhotoReasoningMessage(
369-
text = "Screenshot aufgenommen",
369+
text = "Screenshot aufgenommen\n\nBildschirminformationen:\n$screenInfo",
370370
participant = PhotoParticipant.USER,
371371
isPending = false,
372372
imageUris = listOf(screenshotUri.toString())
@@ -375,6 +375,6 @@ class PhotoReasoningViewModel(
375375
_chatMessagesFlow.value = chatMessages.toList()
376376

377377
// Save chat history
378-
saveChatHistory(MainActivity.getInstance()?.applicationContext)
378+
saveChatHistory(context)
379379
}
380380
}

0 commit comments

Comments
 (0)