Skip to content

Conversation

lethargicpanda
Copy link
Collaborator

@lethargicpanda lethargicpanda commented Jul 24, 2025

Address Gemini Live API sample compose comments

@lethargicpanda lethargicpanda changed the title Address Live sample compose comments Address Gemini Live API sample compose comments Jul 24, 2025
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary of Changes

Hello @lethargicpanda, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refactors the Gemini Live sample application to improve audio recording permission handling and enhance the composable UI components. It addresses previous feedback by ensuring a better user experience when interacting with the live session features, specifically by moving permission logic to the UI layer and providing clearer user feedback.

Highlights

  • Permission Handling Refactor: Moved audio recording permission checks and requests from the TodoScreenViewModel to the TodoScreen Composable. This ensures that UI-related concerns, such as requesting permissions and displaying user feedback (like Toast messages), are handled directly within the UI layer, improving separation of concerns.
  • Pre-session Permission Check: Implemented an explicit check for RECORD_AUDIO permission within the MicButton's onToggle action. If the permission is not granted, a user-friendly Toast message is displayed, preventing attempts to start a live session without the necessary audio recording capabilities.
  • Composable API Improvement: Added modifier: Modifier parameters to the MicButton and TodoInput composable functions. This adheres to Jetpack Compose best practices, making these UI components more flexible and reusable by allowing callers to customize their layout and behavior.
  • New String Resource: Introduced a new string resource (error_permission) in strings.xml to provide a clear and localized message to the user when audio recording permission is missing, enhancing the user experience.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments or fill out our survey to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the audio permission handling to be more self-contained within the UI layer and makes some UI components more reusable by adding modifier parameters. The separation of concerns by moving permission logic out of the ViewModel is a great improvement. The review focuses on improving permission handling using rememberLauncherForActivityResult and correcting the implementation of composable modifiers.

@@ -86,11 +91,21 @@ import kotlin.collections.reversed
fun TodoScreen(viewModel: TodoScreenViewModel = hiltViewModel()) {
val uiState by viewModel.uiState.collectAsStateWithLifecycle()
var text by remember { mutableStateOf("") }
val context = LocalContext.current
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional but there is a library you could use which would be slightly less code and not use Context here

https://github.com/google/accompanist/tree/main/permissions

if (isGranted) {
viewModel.toggleLiveSession()
} else {
Toast.makeText(context, R.string.error_permission, Toast.LENGTH_SHORT).show()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

optional, but consider using Snackbar here instead of Toast. I think material design guidelines recommend snackbars instead

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For a permission error, the best Material 3 UI component depends on the severity and context of the error. Critical, blocking errors that require immediate action should use a dialog, while less severe or temporary issues are best handled with a snackbar or banner.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants