Skip to content

Commit a11ef3b

Browse files
I will show a toast notification when I stop operating on your screen.
1 parent 5929e8b commit a11ef3b

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,17 @@ performReasoning(
620620
// Parse commands from the text
621621
val commands = CommandParser.parseCommands(text)
622622

623+
// Check if takeScreenshot() is not in the response
624+
if (!commands.any { it is Command.TakeScreenshot }) {
625+
// Show a toast message
626+
val context = MainActivity.getInstance()?.applicationContext
627+
if (context != null) {
628+
withContext(Dispatchers.Main) {
629+
Toast.makeText(context, "The AI stopped Screen Operator", Toast.LENGTH_SHORT).show()
630+
}
631+
}
632+
}
633+
623634
if (commands.isNotEmpty()) {
624635
if (commandProcessingJob?.isActive != true || stopExecutionFlag.get()) return@launch
625636
Log.d(TAG, "Found ${commands.size} commands in response")

0 commit comments

Comments
 (0)