Skip to content

Commit 6e3f7de

Browse files
authored
Merge branch 'main' into wear-tlc-16
2 parents 8c5c58d + 93ca444 commit 6e3f7de

20 files changed

Lines changed: 136 additions & 102 deletions

File tree

app/build.gradle.kts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ android {
4343
initWith(buildTypes.getByName("release"))
4444
matchingFallbacks += listOf("release")
4545
isDebuggable = false
46-
baselineProfile.automaticGenerationDuringBuild = false
4746
}
4847
release {
4948
isShrinkResources = true
@@ -52,7 +51,6 @@ android {
5251
getDefaultProguardFile("proguard-android-optimize.txt"),
5352
"proguard-rules.pro",
5453
)
55-
baselineProfile.automaticGenerationDuringBuild = false
5654
configure<CrashlyticsExtension> {
5755
mappingFileUploadEnabled = true
5856
}

app/proguard-rules.pro

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,17 @@
5151

5252
# Ignore SAX parser warning
5353
-dontwarn org.xml.sax.**
54+
55+
# WorkManager / Room R8 Full Mode keep rules
56+
-keep class androidx.work.impl.WorkDatabase_Impl { *; }
57+
-keep class androidx.work.impl.** { *; }
58+
-dontwarn androidx.work.impl.**
59+
60+
# Keep list of constructors used by reflection (Workers)
61+
-keep class * extends androidx.work.ListenableWorker {
62+
<init>(android.content.Context, androidx.work.WorkerParameters);
63+
}
64+
-keep class * extends androidx.work.Worker {
65+
<init>(android.content.Context, androidx.work.WorkerParameters);
66+
}
67+

build_presubmit_mobile.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ set -e
2424
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
2525
echo DIR
2626
# Define the Android SDK version you want to target.
27-
ANDROID_SDK_VERSION="36"
28-
ANDROID_BUILD_TOOLS_VERSION="36.0.0"
27+
ANDROID_SDK_VERSION="37.0"
28+
ANDROID_BUILD_TOOLS_VERSION="37.0.0"
2929

3030
# Switched from 'google_apis' to 'google_atd' (Google Automated Test Device).
3131
# This system image is designed for headless, automated testing in CI environments
3232
# and is more compatible with software rendering. It will be installed but may not
3333
# be used by the new build command.
34-
# 36 not available yet as per b/432143095
34+
# 37 not available yet as per b/432143095
3535
EMULATOR_IMAGE="system-images;android-35;google_atd;x86_64"
3636

3737
# --- Environment Setup ---

build_presubmit_wear.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ set -e
2424
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
2525
echo DIR
2626
# Define the Android SDK version you want to target.
27-
ANDROID_SDK_VERSION="36"
28-
ANDROID_BUILD_TOOLS_VERSION="36.0.0"
27+
ANDROID_SDK_VERSION="37.0"
28+
ANDROID_BUILD_TOOLS_VERSION="37.0.0"
2929

3030
# Switched from 'google_apis' to 'google_atd' (Google Automated Test Device).
3131
# This system image is designed for headless, automated testing in CI environments
3232
# and is more compatible with software rendering. It will be installed but may not
3333
# be used by the new build command.
34-
# 36 not available yet as per b/432143095
34+
# 37 not available yet as per b/432143095
3535
EMULATOR_IMAGE="system-images;android-35;google_atd;x86_64"
3636

3737
# --- Environment Setup ---

build_release_mobile.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ set -e
2323
# Get the script's directory.
2424
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
2525
# Define the Android SDK version you want to target.
26-
ANDROID_SDK_VERSION="36"
27-
ANDROID_BUILD_TOOLS_VERSION="36.0.0"
26+
ANDROID_SDK_VERSION="37.0"
27+
ANDROID_BUILD_TOOLS_VERSION="37.0.0"
2828

2929
# Switched from 'google_apis' to 'google_atd' (Google Automated Test Device).
3030
# This system image is designed for headless, automated testing in CI environments
3131
# and is more compatible with software rendering. It will be installed but may not
3232
# be used by the new build command.
33-
# 36 not available yet as per b/432143095
33+
# 37 not available yet as per b/432143095
3434
EMULATOR_IMAGE="system-images;android-35;google_atd;x86_64"
3535

3636
# --- Environment Setup ---

build_release_wear.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ set -e
2323
# Get the script's directory.
2424
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
2525
# Define the Android SDK version you want to target.
26-
ANDROID_SDK_VERSION="36"
27-
ANDROID_BUILD_TOOLS_VERSION="36.0.0"
26+
ANDROID_SDK_VERSION="37.0"
27+
ANDROID_BUILD_TOOLS_VERSION="37.0.0"
2828

2929
# Switched from 'google_apis' to 'google_atd' (Google Automated Test Device).
3030
# This system image is designed for headless, automated testing in CI environments
3131
# and is more compatible with software rendering. It will be installed but may not
3232
# be used by the new build command.
33-
# 36 not available yet as per b/432143095
33+
# 37 not available yet as per b/432143095
3434
EMULATOR_IMAGE="system-images;android-35;google_atd;x86_64"
3535

3636
# --- Environment Setup ---

core/network/src/main/java/com/android/developers/androidify/vertexai/FirebaseAiDataSource.kt

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,10 @@ import com.android.developers.androidify.model.ValidatedDescription
2323
import com.android.developers.androidify.model.ValidatedImage
2424
import com.google.firebase.Firebase
2525
import com.google.firebase.ai.GenerativeModel
26-
import com.google.firebase.ai.ImagenModel
2726
import com.google.firebase.ai.ai
2827
import com.google.firebase.ai.type.GenerativeBackend
2928
import com.google.firebase.ai.type.HarmBlockThreshold
3029
import com.google.firebase.ai.type.HarmCategory
31-
import com.google.firebase.ai.type.ImagenPersonFilterLevel
32-
import com.google.firebase.ai.type.ImagenSafetyFilterLevel
33-
import com.google.firebase.ai.type.ImagenSafetySettings
3430
import com.google.firebase.ai.type.PublicPreviewAPI
3531
import com.google.firebase.ai.type.ResponseModality
3632
import com.google.firebase.ai.type.SafetySetting
@@ -81,15 +77,20 @@ class FirebaseAiDataSourceImpl @Inject constructor(
8177
)
8278
}
8379

84-
private fun createGenerativeImageModel(): ImagenModel {
85-
return Firebase.ai(backend = GenerativeBackend.vertexAI()).imagenModel(
86-
remoteConfigDataSource.imageModelName(),
87-
safetySettings =
88-
ImagenSafetySettings(
89-
safetyFilterLevel = ImagenSafetyFilterLevel.BLOCK_LOW_AND_ABOVE,
90-
// Uses `ALLOW_ADULT` filter since `ALLOW_ALL` requires a special approval
91-
// See https://cloud.google.com/vertex-ai/generative-ai/docs/image/responsible-ai-imagen#person-face-gen
92-
personFilterLevel = ImagenPersonFilterLevel.ALLOW_ADULT,
80+
private fun createGenerativeImageModel(): GenerativeModel {
81+
return Firebase.ai(backend = GenerativeBackend.vertexAI()).generativeModel(
82+
modelName = remoteConfigDataSource.imageModelName(),
83+
generationConfig = generationConfig {
84+
responseModalities = listOf(
85+
ResponseModality.IMAGE,
86+
)
87+
},
88+
safetySettings = listOf(
89+
SafetySetting(HarmCategory.HARASSMENT, HarmBlockThreshold.LOW_AND_ABOVE),
90+
SafetySetting(HarmCategory.HATE_SPEECH, HarmBlockThreshold.LOW_AND_ABOVE),
91+
SafetySetting(HarmCategory.SEXUALLY_EXPLICIT, HarmBlockThreshold.LOW_AND_ABOVE),
92+
SafetySetting(HarmCategory.DANGEROUS_CONTENT, HarmBlockThreshold.LOW_AND_ABOVE),
93+
SafetySetting(HarmCategory.CIVIC_INTEGRITY, HarmBlockThreshold.LOW_AND_ABOVE),
9394
),
9495
)
9596
}
@@ -227,11 +228,13 @@ class FirebaseAiDataSourceImpl @Inject constructor(
227228
}
228229

229230
private suspend fun executeImageGeneration(
230-
generativeModel: ImagenModel,
231+
generativeModel: GenerativeModel,
231232
prompt: String,
232233
): Bitmap {
233-
val response = generativeModel.generateImages(prompt)
234-
return response.images.first().asBitmap()
234+
val response = generativeModel.generateContent(prompt)
235+
val image = response.candidates.firstOrNull()
236+
?.content?.parts?.firstNotNullOfOrNull { it.asImageOrNull() }
237+
return image ?: throw IllegalStateException("Could not extract image from model response")
235238
}
236239

237240
override suspend fun generatePrompt(prompt: String): GeneratedPrompt {

core/theme/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ android {
4242
dependencies {
4343
implementation(libs.androidx.ui.text.google.fonts)
4444
implementation(platform(libs.androidx.compose.bom))
45+
implementation(libs.androidx.compose.foundation)
4546
implementation(libs.androidx.ui.tooling.preview)
4647
implementation(libs.androidx.material3)
4748
implementation(projects.core.util)

feature/camera/src/androidTest/java/com/android/developers/androidify/camera/CameraScreenTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import androidx.compose.ui.test.assertIsDisplayed
2626
import androidx.compose.ui.test.assertIsEnabled
2727
import androidx.compose.ui.test.assertIsNotDisplayed
2828
import androidx.compose.ui.test.assertIsNotEnabled
29-
import androidx.compose.ui.test.junit4.createAndroidComposeRule
29+
import androidx.compose.ui.test.junit4.v2.createAndroidComposeRule
3030
import androidx.compose.ui.test.onNodeWithContentDescription
3131
import androidx.compose.ui.test.onNodeWithText
3232
import androidx.compose.ui.test.performClick

feature/creation/build.gradle.kts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ dependencies {
4343
implementation(libs.hilt.android)
4444
implementation(libs.timber)
4545
implementation(libs.androidx.hilt.navigation.compose)
46+
implementation(libs.androidx.lifecycle.runtime.ktx)
47+
implementation(libs.androidx.lifecycle.viewmodel.ktx)
48+
implementation(libs.androidx.lifecycle.viewmodel.compose)
4649
implementation(libs.androidx.adaptive)
4750
implementation(libs.androidx.adaptive.layout)
4851
implementation(libs.androidx.window)

0 commit comments

Comments
 (0)