Skip to content

Sync latest changes from main branch into prototype-ai-glasses#170

Closed
kathleenalexandra24 wants to merge 9 commits into
prototype-ai-glassesfrom
feature/sync-main-to-prototype
Closed

Sync latest changes from main branch into prototype-ai-glasses#170
kathleenalexandra24 wants to merge 9 commits into
prototype-ai-glassesfrom
feature/sync-main-to-prototype

Conversation

@kathleenalexandra24
Copy link
Copy Markdown

No description provided.

Copy link
Copy Markdown
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 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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

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
  1. ViewModels should be agnostic of the Android lifecycle. Avoid references to lifecycle-related types, Activities, Fragments, Context, or Resources. (link)

Comment on lines +62 to +63
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.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

There are duplicate 'Read more' links at the end of the file. Please remove the redundant line.

Suggested change
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 },
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The filterNot call is redundant here because none of the items in the hardcoded list above have an ID matching MIC_STATUS_TODO_ID (-999).

Suggested change
).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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The constant MIC_CONTROL_ID is duplicated here and in TodoScreenViewModel.kt. It is already defined as MIC_TODO_ID in Todo.kt. Please import and use the existing constant to maintain a single source of truth.

}

@Composable
private fun GlimmerScreenContent(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

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
  1. 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 ->
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The @RequiresPermission annotation is applied to a lambda expression here. This is non-standard and likely won't be correctly processed by lint tools for enforcement. Permission checks should be performed in the UI layer before calling ViewModel methods that require them.

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",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The model ID gemini-live-2.5-flash-preview-native-audio-09-2025 used here is inconsistent with the model ID mentioned in the README (gemini-2.0-flash-live-preview-04-09). Please ensure the code and documentation are synchronized.

@kathleenalexandra24 kathleenalexandra24 changed the base branch from main to prototype-ai-glasses May 8, 2026 16:04
Copy link
Copy Markdown
Collaborator

@JolandaVerhoef JolandaVerhoef left a comment

Choose a reason for hiding this comment

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

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
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

don't change the copyright header

android {
namespace = "com.android.ai.samples.geminilivetodo"
compileSdk = 35
compileSdk = 36
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

why does this need to be updated?

Comment thread samples/gemini-live-todo/README.md Outdated

```kotlin
val generativeModel = Firebase.ai(backend = GenerativeBackend.vertexAI()).liveModel(
"gemini-2.5-flash-native-audio-preview-12-2025",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This seems older?

@@ -1,13 +1,15 @@
# Gemini Live Todo Sample
# Gemini Live Todo AI Glasses Sample
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

how did the live sample not yet have a firebase import?

@JolandaVerhoef
Copy link
Copy Markdown
Collaborator

Refer to #168 instead

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.

5 participants