-
Notifications
You must be signed in to change notification settings - Fork 89
Address Gemini Live API sample compose comments #63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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 theTodoScreen
Composable. This ensures that UI-related concerns, such as requesting permissions and displaying user feedback (likeToast
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 theMicButton
'sonToggle
action. If the permission is not granted, a user-friendlyToast
message is displayed, preventing attempts to start a live session without the necessary audio recording capabilities. - Composable API Improvement: Added
modifier: Modifier
parameters to theMicButton
andTodoInput
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
) instrings.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
-
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. ↩
There was a problem hiding this 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.
...amples/gemini-live-todo/src/main/java/com/android/ai/samples/geminilivetodo/ui/TodoScreen.kt
Outdated
Show resolved
Hide resolved
...amples/gemini-live-todo/src/main/java/com/android/ai/samples/geminilivetodo/ui/TodoScreen.kt
Outdated
Show resolved
Hide resolved
...amples/gemini-live-todo/src/main/java/com/android/ai/samples/geminilivetodo/ui/TodoScreen.kt
Outdated
Show resolved
Hide resolved
5766d13
to
e7adebe
Compare
@@ -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 |
There was a problem hiding this comment.
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
if (isGranted) { | ||
viewModel.toggleLiveSession() | ||
} else { | ||
Toast.makeText(context, R.string.error_permission, Toast.LENGTH_SHORT).show() |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
Address Gemini Live API sample compose comments