-
Notifications
You must be signed in to change notification settings - Fork 97
Gemini Live sample #53
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
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
1fe118e
Add Gemini live todo sample
lethargicpanda 0f0d40b
Refactoring
lethargicpanda db4f399
🤖 Apply Spotless formatting
lethargicpanda b6629ce
Address Gemini in Github feedback
lethargicpanda 26aeb16
🤖 Apply Spotless formatting
lethargicpanda 5ca376e
Add UiState.Error for connection error
lethargicpanda a5bab17
🤖 Apply Spotless formatting
lethargicpanda 9a1c018
Address comments
lethargicpanda 8a49cd6
🤖 Apply Spotless formatting
lethargicpanda e0768ee
Add permission runtime
lethargicpanda 8c7ee46
🤖 Apply Spotless formatting
lethargicpanda b0101fe
Add premission checks
lethargicpanda 1cc4753
🤖 Apply Spotless formatting
lethargicpanda 1bd8c72
Supress lint warning
lethargicpanda 6f6173e
🤖 Apply Spotless formatting
lethargicpanda 9175077
Address comments
lethargicpanda a0ed509
🤖 Apply Spotless formatting
lethargicpanda 29da049
Introduce liveSessionState
lethargicpanda 32712ff
🤖 Apply Spotless formatting
lethargicpanda File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* Copyright 2025 The Android Open Source Project | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
plugins { | ||
alias(libs.plugins.android.library) | ||
alias(libs.plugins.jetbrains.kotlin.android) | ||
alias(libs.plugins.ksp) | ||
alias(libs.plugins.compose.compiler) | ||
} | ||
|
||
android { | ||
namespace = "com.android.ai.samples.geminilivetodo" | ||
compileSdk = 35 | ||
|
||
defaultConfig { | ||
minSdk = 24 | ||
|
||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" | ||
consumerProguardFiles("consumer-rules.pro") | ||
} | ||
|
||
buildTypes { | ||
lethargicpanda marked this conversation as resolved.
Show resolved
Hide resolved
|
||
release { | ||
isMinifyEnabled = false | ||
proguardFiles( | ||
getDefaultProguardFile("proguard-android-optimize.txt"), | ||
"proguard-rules.pro", | ||
) | ||
} | ||
} | ||
compileOptions { | ||
sourceCompatibility = JavaVersion.VERSION_17 | ||
targetCompatibility = JavaVersion.VERSION_17 | ||
} | ||
kotlinOptions { | ||
jvmTarget = "17" | ||
} | ||
} | ||
|
||
dependencies { | ||
|
||
implementation(libs.androidx.core.ktx) | ||
implementation(libs.androidx.appcompat) | ||
implementation(platform(libs.androidx.compose.bom)) | ||
implementation(libs.androidx.material.icons.extended) | ||
implementation(platform(libs.firebase.bom)) | ||
implementation(libs.google.firebase.ai) | ||
implementation(libs.androidx.lifecycle.viewmodel.android) | ||
implementation(libs.material3) | ||
implementation(libs.hilt.android) | ||
ksp(libs.hilt.compiler) | ||
implementation(libs.hilt.navigation.compose) | ||
implementation(libs.androidx.activity.compose) | ||
implementation(libs.androidx.material3.android) | ||
implementation(libs.kotlinx.serialization.json) | ||
testImplementation(libs.junit) | ||
androidTestImplementation(libs.androidx.junit) | ||
androidTestImplementation(libs.androidx.espresso.core) | ||
} |
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
24 changes: 24 additions & 0 deletions
24
...samples/gemini-live-todo/src/main/java/com/android/ai/samples/geminilivetodo/data/Todo.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright 2025 The Android Open Source Project | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.android.ai.samples.geminilivetodo.data | ||
|
||
import java.util.UUID.randomUUID | ||
|
||
data class Todo( | ||
val id: Long = randomUUID().mostSignificantBits, | ||
lethargicpanda marked this conversation as resolved.
Show resolved
Hide resolved
|
||
val task: String, | ||
val isCompleted: Boolean = false, | ||
lethargicpanda marked this conversation as resolved.
Show resolved
Hide resolved
|
||
) |
70 changes: 70 additions & 0 deletions
70
...mini-live-todo/src/main/java/com/android/ai/samples/geminilivetodo/data/TodoRepository.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
* Copyright 2025 The Android Open Source Project | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.android.ai.samples.geminilivetodo.data | ||
|
||
import javax.inject.Inject | ||
import javax.inject.Singleton | ||
import kotlin.collections.filterNot | ||
import kotlin.collections.map | ||
import kotlin.collections.plus | ||
import kotlin.text.isNotBlank | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.MutableStateFlow | ||
import kotlinx.coroutines.flow.asStateFlow | ||
import kotlinx.coroutines.flow.update | ||
|
||
@Singleton | ||
class TodoRepository @Inject constructor() { | ||
|
||
private val _todos = MutableStateFlow<List<Todo>>( | ||
listOf( | ||
Todo(1234, "buy bread", false), | ||
Todo(1235, "do the dishes", false), | ||
Todo(1236, "buy eggs", false), | ||
Todo(1237, "read a book", false), | ||
), | ||
) | ||
val todos: Flow<List<Todo>> = _todos.asStateFlow() | ||
|
||
fun getTodoList(): List<Todo> = _todos.value | ||
|
||
fun addTodo(taskDescription: String) { | ||
if (taskDescription.isNotBlank()) { | ||
val newTodo = Todo(task = taskDescription) | ||
_todos.update { currentList -> | ||
currentList + newTodo | ||
} | ||
} | ||
} | ||
|
||
fun removeTodo(todoId: Long) { | ||
_todos.update { currentList -> | ||
currentList.filterNot { it.id == todoId } | ||
} | ||
} | ||
|
||
fun toggleTodoStatus(todoId: Long) { | ||
_todos.update { currentList -> | ||
currentList.map { todo -> | ||
if (todo.id == todoId) { | ||
todo.copy(isCompleted = !todo.isCompleted) | ||
} else { | ||
todo | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.