Skip to content

Commit b0ffa68

Browse files
calrenlethargicpandaMayuriKhinvasara
authored
sync with internal repo (#27)
* Add AI catalog sample Move original Gemini Nano files Code cleanup - Fix modifier param delecration, - Extract hardcoded strings to xml - Misc cleanup UI updates on catalog screen Implement Ivy’s UI/UX feedback for the catalog screen. Add readme Change-Id: Iba57e6b7843098c7ec2a53c34df639ab17fe0161 * tweaks and cleanup Change-Id: Id52538a28f29629482df36784590057b16a31042 * Add blank samples for GenAI APIs: Summarization, Writing Assistance, Image Description Change-Id: I3fce89e915e1cf931246c1152086480d25d467a7 * Add Imagen sample Change-Id: Ia195fcd06063b46b467010f67af518e4d619f983 * Add magic selfie sample Change-Id: Ib2f9295a36e1cc6296c706cee67e5a4d72e9ceff * Add UI for GenAI Summarization, Writing Assistance, and Image Description samples Change-Id: Id57b8b1daea198ce6aba949ab2da9d4b74491622 * Add GenAI dependencies and logic for samples Change-Id: Ie3244259dc9976d5ed01f4b220052757abe7ef4e * Update Gemini models, UI improvement Change-Id: I6555e95733c400b2a19bec5b557f4f2bcc239230 * Add Video Summarization with Firebase sample - This commit introduces a new sample for video summarization using Firebase AI. - Adds `Video Summarization with Firebase AI` sample to the AI catalog. - Implements UI elements: video player, video selection dropdown, output text display, and text-to-speech controls. - Implements video player functionality using Media3 `ExoPlayer`. - Adds a component to select a video from a list of predefined options or add a new video URL. - Introduces `OutputTextState` for managing the output text state. - Implements `TextToSpeech` controls for listening to the summarized text. - Adds `VideoList` and `VideoItem` for managing the video options. - Adds new view model to handle the logic of video summarization - Adds the code to invoke `vertexAI` with a prompt and video content. - Adds text to speech controls to listen to AI output in different accents to create a personalized experience. Change-Id: Id2664c56279725ed6d66e2492c178c0f975e1148 * Remove local maven path Change-Id: I9be750c715832e5f1c1284a560b6d5d8171e9829 * Add README * Restore old Nano README --------- Co-authored-by: Thomas Ezan <[email protected]> Co-authored-by: Mayuri Khinvasara <[email protected]>
1 parent 446bf50 commit b0ffa68

File tree

63 files changed

+3084
-11
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+3084
-11
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
.DS_Store
21
local.properties
2+
.DS_Store
3+
build
4+
/.idea

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ http://www.apache.org/licenses/LICENSE-2.0
3333
Unless required by applicable law or agreed to in writing, software distributed
3434
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
3535
CONDITIONS OF ANY KIND, either express or implied. See the License for the
36-
specific language governing permissions and limitations under the License.
36+
specific language governing permissions and limitations under the License.

ai-catalog/app/build.gradle.kts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ android {
3030

3131
defaultConfig {
3232
applicationId = "com.android.ai.catalog"
33-
minSdk = 24
33+
minSdk = 26
3434
targetSdk = 35
3535
versionCode = 1
3636
versionName = "1.0"
@@ -81,6 +81,12 @@ dependencies {
8181

8282
implementation(project(":samples:gemini-multimodal"))
8383
implementation(project(":samples:gemini-chatbot"))
84+
implementation(project(":samples:genai-summarization"))
85+
implementation(project(":samples:genai-image-description"))
86+
implementation(project(":samples:genai-writing-assistance"))
87+
implementation(project(":samples:imagen"))
88+
implementation(project(":samples:magic-selfie"))
89+
implementation(project(":samples:gemini-video-summarization"))
8490

8591
testImplementation(libs.junit)
8692
androidTestImplementation(libs.androidx.junit)

ai-catalog/app/src/main/AndroidManifest.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
android:theme="@style/Theme.AISampleCatalog"
1313
tools:targetApi="31"
1414
android:name=".CatalogApp"
15+
android:enableOnBackInvokedCallback="true"
1516
>
1617
<activity
1718
android:name=".MainActivity"
@@ -23,6 +24,15 @@
2324
<category android:name="android.intent.category.LAUNCHER" />
2425
</intent-filter>
2526
</activity>
27+
<provider
28+
android:name="androidx.core.content.FileProvider"
29+
android:authorities="${applicationId}.provider"
30+
android:exported="false"
31+
android:grantUriPermissions="true">
32+
<meta-data
33+
android:name="android.support.FILE_PROVIDER_PATHS"
34+
android:resource="@xml/provider_paths" />
35+
</provider>
2636
</application>
2737

2838
</manifest>

ai-catalog/app/src/main/java/com/android/ai/catalog/ui/domain/SampleCatalog.kt

Lines changed: 60 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ import androidx.compose.ui.graphics.Color
2323
import com.android.ai.catalog.R
2424
import com.android.ai.samples.geminichatbot.GeminiChatbotScreen
2525
import com.android.ai.samples.geminimultimodal.GeminiMultimodalScreen
26+
import com.android.ai.samples.genai_image_description.GenAIImageDescriptionScreen
27+
import com.android.ai.samples.genai_summarization.GenAISummarizationScreen
28+
import com.android.ai.samples.genai_writing_assistance.GenAIWritingAssistanceScreen
29+
import com.android.ai.samples.imagen.ImagenScreen
30+
import com.android.ai.samples.magicselfie.MagicSelfieScreen
31+
import com.android.ai.samples.geminivideosummary.VideoSummarizationScreen
2632

2733
class SampleCatalog(
2834
context: Context
@@ -34,15 +40,58 @@ class SampleCatalog(
3440
description = context.getString(R.string.gemini_multimodal_sample_description),
3541
route = "GeminiMultimodalScreen",
3642
sampleEntryScreen = { GeminiMultimodalScreen() },
37-
tags = listOf(SampleTags.FIREBASE, SampleTags.GEMINI_1_5_FLASH)
43+
tags = listOf(SampleTags.GEMINI_1_5_FLASH, SampleTags.FIREBASE)
3844
),
3945
SampleCatalogItem(
4046
title = context.getString(R.string.gemini_chatbot_sample_title),
4147
description = context.getString(R.string.gemini_chatbot_sample_description),
4248
route = "GeminiChitchatScreen",
4349
sampleEntryScreen = { GeminiChatbotScreen() },
44-
tags = listOf(SampleTags.FIREBASE, SampleTags.GEMINI_1_5_PRO)
45-
)
50+
tags = listOf(SampleTags.GEMINI_1_5_PRO, SampleTags.FIREBASE)
51+
),
52+
SampleCatalogItem(
53+
title = context.getString(R.string.genai_summarization_sample_title),
54+
description = context.getString(R.string.genai_summarization_sample_description),
55+
route = "GenAISummarizationScreen",
56+
sampleEntryScreen = { GenAISummarizationScreen() },
57+
tags = listOf(SampleTags.GEMINI_NANO)
58+
),
59+
SampleCatalogItem(
60+
title = context.getString(R.string.genai_image_description_sample_title),
61+
description = context.getString(R.string.genai_image_description_sample_description),
62+
route = "GenAIImageDescriptionScreen",
63+
sampleEntryScreen = { GenAIImageDescriptionScreen() },
64+
tags = listOf(SampleTags.GEMINI_NANO)
65+
),
66+
SampleCatalogItem(
67+
title = context.getString(R.string.genai_writing_assistance_sample_title),
68+
description = context.getString(R.string.genai_writing_assistance_sample_description),
69+
route = "GenAIWritingAssistanceScreen",
70+
sampleEntryScreen = { GenAIWritingAssistanceScreen() },
71+
tags = listOf(SampleTags.GEMINI_NANO)
72+
),
73+
SampleCatalogItem(
74+
title = context.getString(R.string.imagen_sample_title),
75+
description = context.getString(R.string.imagen_sample_description),
76+
route = "ImagenImageGenerationScreen",
77+
sampleEntryScreen = { ImagenScreen() },
78+
tags = listOf(SampleTags.IMAGEN, SampleTags.FIREBASE)
79+
),
80+
SampleCatalogItem(
81+
title = context.getString(R.string.magic_selfie_sample_title),
82+
description = context.getString(R.string.magic_selfie_sample_description),
83+
route = "MagicSelfieScreen",
84+
sampleEntryScreen = { MagicSelfieScreen() },
85+
tags = listOf(SampleTags.IMAGEN, SampleTags.FIREBASE, SampleTags.ML_KIT)
86+
),
87+
SampleCatalogItem(
88+
title = context.getString(R.string.gemini_video_summarization_sample_title),
89+
description = context.getString(R.string.gemini_video_summarization_sample_description),
90+
route = "VideoSummarizationScreen",
91+
sampleEntryScreen = { VideoSummarizationScreen() },
92+
tags = listOf(SampleTags.GEMINI_2_0_FLASH, SampleTags.FIREBASE, SampleTags.MEDIA3)
93+
),
94+
4695
// To create a new sample entry, add a new SampleCatalogItem here.
4796
)
4897

@@ -59,10 +108,15 @@ data class SampleCatalogItem(
59108
enum class SampleTags(
60109
val label: String,
61110
val backgroundColor: Color,
62-
val textColor: Color
111+
val textColor: Color,
63112
) {
64-
FIREBASE("Firebase",Color(0xFFFF9100), Color.White),
113+
FIREBASE("Firebase", Color(0xFFFF9100), Color.White),
65114
GEMINI_1_5_PRO("Gemini 1.5 Pro", Color(0xFF4285F4), Color.White),
66-
GEMINI_1_5_FLASH("Gemini 1.5 Flash", Color(0xFF4285F4), Color.White)
115+
GEMINI_1_5_FLASH("Gemini 1.5 Flash", Color(0xFF4285F4), Color.White),
116+
GEMINI_2_0_FLASH("Gemini 2.0 Flash", Color(0xFF4285F4), Color.White),
117+
GEMINI_NANO("Gemini Nano", Color(0xFF7abafe), Color.White),
118+
IMAGEN("Imagen", Color(0xFF7CB342), Color.White),
119+
MEDIA3("Media3", Color(0xFF7CB584), Color.White),
120+
ML_KIT("ML Kit", Color.White, Color(0xFF4285F4))
67121
}
68122

ai-catalog/app/src/main/res/values/strings.xml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,19 @@
33
<string name="gemini_multimodal_sample_title">Gemini Multimodal Generation</string>
44
<string name="gemini_multimodal_sample_description">A very simple example of multimodal generation using the Gemini 2.0 Flash model.</string>
55
<string name="gemini_chatbot_sample_title">Gemini Chatbot</string>
6-
<string name="gemini_chatbot_sample_description">A simple implementation of chatbot using Gemini 2.0 Flash</string>
6+
<string name="gemini_chatbot_sample_description">A simple implementation of chatbot using Gemini 2.0 Flash model.</string>
7+
<string name="genai_summarization_sample_title">Summarization with Gemini Nano</string>
8+
<string name="genai_summarization_sample_description">Summarize articles and conversations on-device with GenAI API powered by Gemini Nano</string>
9+
<string name="genai_image_description_sample_title">Image Description with Gemini Nano</string>
10+
<string name="genai_image_description_sample_description">Generate short descriptions of images on-device with GenAI API powered by Gemini Nano</string>
11+
<string name="genai_writing_assistance_sample_title">Polish text with Gemini Nano</string>
12+
<string name="genai_writing_assistance_sample_description">Proofread and rewrite short content on-device with GenAI API powered by Gemini Nano</string>"
713
<string name="top_bar_title">Android AI Samples</string>
814
<string name="open_sample_button">Open sample</string>
15+
<string name="imagen_sample_title">Image generation with Imagen</string>
16+
<string name="imagen_sample_description">Generate images with Imagen, Google image generation model</string>
17+
<string name="magic_selfie_sample_title">Magic Selfie with Imagen and ML Kit</string>
18+
<string name="magic_selfie_sample_description">Change the background of you selfies with Imagen and the ML Kit Segmentation API</string>
19+
<string name="gemini_video_summarization_sample_title">Video Summarization with Gemini and Firebase</string>
20+
<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>
921
</resources>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="utf-8"?><!--
2+
Sample data extraction rules file; uncomment and customize as necessary.
3+
See https://developer.android.com/about/versions/12/backup-restore#xml-changes
4+
for details.
5+
-->
6+
<data-extraction-rules>
7+
<cloud-backup>
8+
<!-- TODO: Use <include> and <exclude> to control what is backed up.
9+
<include .../>
10+
<exclude .../>
11+
-->
12+
</cloud-backup>
13+
<!--
14+
<device-transfer>
15+
<include .../>
16+
<exclude .../>
17+
</device-transfer>
18+
-->
19+
</data-extraction-rules>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<paths>
3+
<cache-path name="external_files" path="."/>
4+
</paths>

ai-catalog/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,5 @@ plugins {
2323
alias(libs.plugins.google.gms.google.services) apply false
2424
alias(libs.plugins.hilt.plugin) apply false
2525
alias(libs.plugins.ksp) apply false
26+
alias(libs.plugins.compose.compiler) apply false
2627
}

ai-catalog/gradle/libs.versions.toml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
[versions]
22
agp = "8.8.0"
3-
firebaseBom = "33.10.0"
3+
coilCompose = "3.1.0"
4+
firebaseBom = "33.12.0"
5+
mlkitGenAi = "1.0.0-beta1"
46
kotlin = "2.1.0"
57
coreKtx = "1.15.0"
68
junit = "4.13.2"
79
junitVersion = "1.2.1"
810
espressoCore = "3.6.1"
11+
kotlinxCoroutinesGuava = "1.10.2"
912
kotlinxSerializationJson = "1.6.2"
1013
lifecycleRuntimeKtx = "2.8.7"
1114
activityCompose = "1.10.0"
@@ -19,11 +22,21 @@ hiltNavigationCompose = "1.2.0"
1922
ksp = "2.1.0-1.0.29"
2023
runtimeLivedata = "1.7.6"
2124
material3Android = "1.3.1"
25+
media3 = "1.6.1"
26+
material3AndroidVersion = "1.3.2"
27+
firebaseCommonKtx = "21.0.0"
28+
uiToolingPreviewAndroid = "1.8.1"
2229

2330
[libraries]
2431
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
32+
coil-compose = { module = "io.coil-kt.coil3:coil-compose", version.ref = "coilCompose" }
2533
firebase-bom = { module = "com.google.firebase:firebase-bom", version.ref = "firebaseBom" }
2634
firebase-vertexai = { group = "com.google.firebase", name = "firebase-vertexai" }
35+
firebase-common-ktx = { group = "com.google.firebase", name = "firebase-common-ktx", version.ref = "firebaseCommonKtx" }
36+
genai-image-description = { module = "com.google.mlkit:genai-image-description", version.ref = "mlkitGenAi" }
37+
genai-proofreading = { module = "com.google.mlkit:genai-proofreading", version.ref = "mlkitGenAi" }
38+
genai-rewrite = { module = "com.google.mlkit:genai-rewriting", version.ref = "mlkitGenAi" }
39+
genai-summarization = { module = "com.google.mlkit:genai-summarization", version.ref = "mlkitGenAi" }
2740
junit = { group = "junit", name = "junit", version.ref = "junit" }
2841
androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" }
2942
androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" }
@@ -40,13 +53,17 @@ androidx-material3 = { group = "androidx.compose.material3", name = "material3"
4053
androidx-material-icons-extended = { module = "androidx.compose.material:material-icons-extended" }
4154
androidx-navigation-compose = { group = "androidx.navigation", name = "navigation-compose", version.ref = "navigationCompose" }
4255
androidx-navigation-runtime-ktx = { group = "androidx.navigation", name = "navigation-runtime-ktx", version.ref = "navigationRuntimeKtx" }
56+
kotlinx-coroutines-guava = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-guava", version.ref = "kotlinxCoroutinesGuava" }
4357
kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinxSerializationJson" }
4458
androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" }
4559
hilt-android = { group = "com.google.dagger", name = "hilt-android", version.ref = "hilt"}
4660
hilt-compiler = { group = "com.google.dagger", name = "hilt-android-compiler", version.ref = "hilt"}
4761
hilt-navigation-compose = { group = "androidx.hilt", name = "hilt-navigation-compose", version.ref = "hiltNavigationCompose" }
4862
androidx-runtime-livedata = { group = "androidx.compose.runtime", name = "runtime-livedata", version.ref = "runtimeLivedata" }
4963
androidx-material3-android = { group = "androidx.compose.material3", name = "material3-android", version.ref = "material3Android" }
64+
androidx-media3-exoplayer = { module = "androidx.media3:media3-exoplayer", version.ref = "media3" }
65+
androidx-media3-ui = { module = "androidx.media3:media3-ui", version.ref = "media3" }
66+
androidx-ui-tooling-preview-android = { group = "androidx.compose.ui", name = "ui-tooling-preview-android", version.ref = "uiToolingPreviewAndroid" }
5067

5168
[plugins]
5269
android-application = { id = "com.android.application", version.ref = "agp" }

0 commit comments

Comments
 (0)