Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ai-catalog/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Browse the samples inside the `/samples` folder:
- **imagen**: an image generation sample using Imagen
- **magic-selfie**: an sample using ML Kit subject segmentation and Imagen for image generation
- **gemini-video-summarization**: a video summarization sample using Gemini 2.0 Flash
- **gemini-live-todo**: a todo list app using Gemini Live
- More to come...

> **Requires Firebase setup** the samples relying on Google Cloud models (Gemini Pro, Gemini Flash, etc...)
Expand Down
1 change: 1 addition & 0 deletions ai-catalog/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ dependencies {
implementation(project(":samples:imagen"))
implementation(project(":samples:magic-selfie"))
implementation(project(":samples:gemini-video-summarization"))
implementation(project(":samples:gemini-live-todo"))

testImplementation(libs.junit)
androidTestImplementation(libs.androidx.junit)
Expand Down
2 changes: 2 additions & 0 deletions ai-catalog/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.RECORD_AUDIO" />

<application
android:allowBackup="true"
android:fullBackupContent="@xml/backup_rules"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.Color
import com.android.ai.catalog.R
import com.android.ai.samples.geminichatbot.GeminiChatbotScreen
import com.android.ai.samples.geminilivetodo.ui.TodoScreen
import com.android.ai.samples.geminimultimodal.ui.GeminiMultimodalScreen
import com.android.ai.samples.geminivideosummary.VideoSummarizationScreen
import com.android.ai.samples.genai_image_description.GenAIImageDescriptionScreen
Expand All @@ -28,7 +29,8 @@ import com.android.ai.samples.genai_writing_assistance.GenAIWritingAssistanceScr
import com.android.ai.samples.imagen.ui.ImagenScreen
import com.android.ai.samples.magicselfie.ui.MagicSelfieScreen

val sampleCatalog = listOf<SampleCatalogItem>(
@androidx.annotation.RequiresPermission(android.Manifest.permission.RECORD_AUDIO)
val sampleCatalog = listOf(
SampleCatalogItem(
title = R.string.gemini_multimodal_sample_title,
description = R.string.gemini_multimodal_sample_description,
Expand Down Expand Up @@ -90,6 +92,14 @@ val sampleCatalog = listOf<SampleCatalogItem>(
tags = listOf(SampleTags.GEMINI_2_0_FLASH, SampleTags.FIREBASE, SampleTags.MEDIA3),
needsFirebase = true,
),
SampleCatalogItem(
title = R.string.gemini_live_todo_title,
description = R.string.gemini_live_todo_description,
route = "GeminiLiveTodoScreen",
sampleEntryScreen = { TodoScreen() },
tags = listOf(SampleTags.GEMINI_2_0_FLASH, SampleTags.FIREBASE),
needsFirebase = true,
),

// To create a new sample entry, add a new SampleCatalogItem here.
)
Expand Down
2 changes: 2 additions & 0 deletions ai-catalog/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
<string name="magic_selfie_sample_description">Change the background of your selfies with Imagen and the ML Kit Segmentation API</string>
<string name="gemini_video_summarization_sample_title">Video Summarization with Gemini and Firebase</string>
<string name="gemini_video_summarization_sample_description">"Generate a summary of a video (from a cloud URL or Youtube) with Gemini API powered by Firebase"</string>
<string name="gemini_live_todo_title">Gemini Live Todo</string>
<string name="gemini_live_todo_description">"Simple Todo app using the Gemini Live API to interact with the items in the list"</string>
<string name="firebase_required">Firebase Required</string>
<string name="firebase_required_description">This feature requires Firebase to be initialized.</string>
<string name="close">Close</string>
Expand Down
9 changes: 8 additions & 1 deletion ai-catalog/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ uiToolingPreviewAndroid = "1.8.1"
spotless = "7.0.4"
uiToolingPreview = "1.8.3"
uiTooling = "1.8.3"
material = "1.10.0"
firebaseAi = "16.2.0"
lifecycleViewmodelAndroid = "2.8.7"
material3 = "1.3.2"

[libraries]
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
Expand All @@ -54,6 +58,7 @@ androidx-ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-toolin
androidx-ui-test-manifest = { group = "androidx.compose.ui", name = "ui-test-manifest" }
androidx-ui-test-junit4 = { group = "androidx.compose.ui", name = "ui-test-junit4" }
androidx-material3 = { group = "androidx.compose.material3", name = "material3" }
androidx-material3-android = { group = "androidx.compose.material3", name = "material3-android", version.ref = "material3Android" }
androidx-material-icons-extended = { module = "androidx.compose.material:material-icons-extended" }
androidx-navigation-compose = { group = "androidx.navigation", name = "navigation-compose", version.ref = "navigationCompose" }
androidx-navigation-runtime-ktx = { group = "androidx.navigation", name = "navigation-runtime-ktx", version.ref = "navigationRuntimeKtx" }
Expand All @@ -64,12 +69,14 @@ hilt-android = { group = "com.google.dagger", name = "hilt-android", version.ref
hilt-compiler = { group = "com.google.dagger", name = "hilt-android-compiler", version.ref = "hilt"}
hilt-navigation-compose = { group = "androidx.hilt", name = "hilt-navigation-compose", version.ref = "hiltNavigationCompose" }
androidx-runtime-livedata = { group = "androidx.compose.runtime", name = "runtime-livedata", version.ref = "runtimeLivedata" }
androidx-material3-android = { group = "androidx.compose.material3", name = "material3-android", version.ref = "material3Android" }
androidx-media3-exoplayer = { module = "androidx.media3:media3-exoplayer", version.ref = "media3" }
androidx-media3-ui = { module = "androidx.media3:media3-ui", version.ref = "media3" }
androidx-ui-tooling-preview-android = { group = "androidx.compose.ui", name = "ui-tooling-preview-android", version.ref = "uiToolingPreviewAndroid" }
ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-tooling-preview", version.ref = "uiToolingPreview" }
ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling", version.ref = "uiTooling" }
google-firebase-ai = { group = "com.google.firebase", name = "firebase-ai", version.ref = "firebaseAi" }
androidx-lifecycle-viewmodel-android = { group = "androidx.lifecycle", name = "lifecycle-viewmodel-android", version.ref = "lifecycleViewmodelAndroid" }
material3 = { group = "androidx.compose.material3", name = "material3", version.ref = "material3" }

[plugins]
android-application = { id = "com.android.application", version.ref = "agp" }
Expand Down
1 change: 1 addition & 0 deletions ai-catalog/samples/gemini-live-todo/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
71 changes: 71 additions & 0 deletions ai-catalog/samples/gemini-live-todo/build.gradle.kts
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 {
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.
21 changes: 21 additions & 0 deletions ai-catalog/samples/gemini-live-todo/proguard-rules.pro
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
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,
val task: String,
val isCompleted: Boolean = false,
)
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
}
}
}
}
}
Loading
Loading