Sync latest changes from main branch into prototype-ai-glasses#170
Sync latest changes from main branch into prototype-ai-glasses#170kathleenalexandra24 wants to merge 9 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces support for Google AI Glasses to the Gemini Live Todo sample, adding a new GlassesActivity and a dedicated UI built with Jetpack Compose Glimmer. The update includes integrating the androidx.xr libraries, updating the TodoRepository to manage microphone status as a list item, and adding a launch mechanism from the main TodoScreen. Feedback focuses on architectural improvements, such as removing Activity references from the ViewModel to adhere to style guides, eliminating redundant code and duplicate constants, and ensuring consistency between the documentation and the implementation regarding model IDs. Additionally, it was noted that some composables are missing Modifier parameters and that permission-related annotations are applied non-standardly.
| class TodoScreenViewModel @Inject constructor(private val todoRepository: TodoRepository) : ViewModel() { | ||
| private val TAG = "TodoScreenViewModel" | ||
| private var session: LiveSession? = null | ||
| private var hostActivityRef: WeakReference<Activity>? = null |
There was a problem hiding this comment.
The ViewModel is holding a WeakReference to an Activity. This violates the 'Strongly recommended' architectural guidelines (Repository Style Guide, line 58), which state that ViewModels should be agnostic of the Android lifecycle and avoid references to Activities. This can lead to memory leaks and makes the ViewModel harder to test. Consider handling permission requests and session triggers in the UI layer.
References
- ViewModels should be agnostic of the Android lifecycle. Avoid references to lifecycle-related types, Activities, Fragments, Context, or Resources. (link)
| Read more about the Gemini Live API in the Android Documentation. | ||
| Read more about the [Gemini Live API](https://developer.android.com/ai/gemini/live) in the Android Documentation. |
There was a problem hiding this comment.
There are duplicate 'Read more' links at the end of the file. Please remove the redundant line.
| Read more about the Gemini Live API in the Android Documentation. | |
| Read more about the [Gemini Live API](https://developer.android.com/ai/gemini/live) in the Android Documentation. | |
| Read more about the [Gemini Live API](https://developer.android.com/ai/gemini/live) in the Android Documentation. |
| statusText = "Mic Status", | ||
| isMicOn = false | ||
| ), | ||
| ).filterNot { it.id == MIC_STATUS_TODO_ID }, |
| private const val MaxItemsInList = 4 | ||
| private val IconSize = 30.dp | ||
| private const val TAG = "GlimmerTodoScreen" | ||
| private const val MIC_CONTROL_ID = 111 |
| } | ||
|
|
||
| @Composable | ||
| private fun GlimmerScreenContent( |
There was a problem hiding this comment.
This composable function is missing a Modifier parameter. According to the Repository Style Guide (line 50), every composable function (except top-level ones) should take a Modifier as its first optional parameter.
References
- Every composable function (except top level screen composable) should take a Modifier as a parameter with a default value. It should be positionned as the first optional parameter. (link)
| requestAudioPermissionIfNeeded(activity) | ||
|
|
||
| viewModelScope.launch { | ||
| todoRepository.todos.collect @androidx.annotation.RequiresPermission(android.Manifest.permission.RECORD_AUDIO) { todos -> |
There was a problem hiding this comment.
| val generativeModel = Firebase.ai(backend = GenerativeBackend.googleAI()).liveModel( | ||
| "gemini-2.5-flash-native-audio-preview-12-2025", | ||
| val generativeModel = Firebase.ai(backend = GenerativeBackend.vertexAI()).liveModel( | ||
| "gemini-live-2.5-flash-preview-native-audio-09-2025", |
JolandaVerhoef
left a comment
There was a problem hiding this comment.
I don't really know if these are actually the changes you meant to make for adding the audio experience? It's very confusing. I'd like to review just the audio changes, not any other AI Glasses related changes. But this pull request seems to combine them?
| * You may obtain a copy of the License at | ||
| * | ||
| * https://www.apache.org/licenses/LICENSE-2.0 | ||
| * https://www.apache.org/licenses/LICENSE-2.0 |
There was a problem hiding this comment.
don't change the copyright header
| * You may obtain a copy of the License at | ||
| * | ||
| * https://www.apache.org/licenses/LICENSE-2.0 | ||
| * https://www.apache.org/licenses/LICENSE-2.0 |
There was a problem hiding this comment.
don't change the copyright header
| android { | ||
| namespace = "com.android.ai.samples.geminilivetodo" | ||
| compileSdk = 35 | ||
| compileSdk = 36 |
There was a problem hiding this comment.
why does this need to be updated?
|
|
||
| ```kotlin | ||
| val generativeModel = Firebase.ai(backend = GenerativeBackend.vertexAI()).liveModel( | ||
| "gemini-2.5-flash-native-audio-preview-12-2025", |
| @@ -1,13 +1,15 @@ | |||
| # Gemini Live Todo Sample | |||
| # Gemini Live Todo AI Glasses Sample | |||
There was a problem hiding this comment.
do you really want to change the documentation of the whole todo app?
|
|
||
| implementation(libs.androidx.xr.glimmer) | ||
| implementation(libs.androidx.xr.projected) | ||
| implementation("com.google.firebase:firebase-ai:17.5.0") |
There was a problem hiding this comment.
how did the live sample not yet have a firebase import?
|
Refer to #168 instead |
No description provided.