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
2 changes: 0 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ android {
initWith(buildTypes.getByName("release"))
matchingFallbacks += listOf("release")
isDebuggable = false
baselineProfile.automaticGenerationDuringBuild = false
}
release {
isShrinkResources = true
Expand All @@ -52,7 +51,6 @@ android {
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro",
)
baselineProfile.automaticGenerationDuringBuild = false
configure<CrashlyticsExtension> {
mappingFileUploadEnabled = true
}
Expand Down
14 changes: 14 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,17 @@

# Ignore SAX parser warning
-dontwarn org.xml.sax.**

# WorkManager / Room R8 Full Mode keep rules
-keep class androidx.work.impl.WorkDatabase_Impl { *; }
-keep class androidx.work.impl.** { *; }
-dontwarn androidx.work.impl.**

# Keep list of constructors used by reflection (Workers)
-keep class * extends androidx.work.ListenableWorker {
<init>(android.content.Context, androidx.work.WorkerParameters);
}
-keep class * extends androidx.work.Worker {
<init>(android.content.Context, androidx.work.WorkerParameters);
}

6 changes: 3 additions & 3 deletions build_presubmit_mobile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ set -e
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
echo DIR
# Define the Android SDK version you want to target.
ANDROID_SDK_VERSION="36"
ANDROID_BUILD_TOOLS_VERSION="36.0.0"
ANDROID_SDK_VERSION="37.0"
ANDROID_BUILD_TOOLS_VERSION="37.0.0"

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

# --- Environment Setup ---
Expand Down
6 changes: 3 additions & 3 deletions build_presubmit_wear.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ set -e
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
echo DIR
# Define the Android SDK version you want to target.
ANDROID_SDK_VERSION="36"
ANDROID_BUILD_TOOLS_VERSION="36.0.0"
ANDROID_SDK_VERSION="37.0"
ANDROID_BUILD_TOOLS_VERSION="37.0.0"

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

# --- Environment Setup ---
Expand Down
6 changes: 3 additions & 3 deletions build_release_mobile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ set -e
# Get the script's directory.
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# Define the Android SDK version you want to target.
ANDROID_SDK_VERSION="36"
ANDROID_BUILD_TOOLS_VERSION="36.0.0"
ANDROID_SDK_VERSION="37.0"
ANDROID_BUILD_TOOLS_VERSION="37.0.0"

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

# --- Environment Setup ---
Expand Down
6 changes: 3 additions & 3 deletions build_release_wear.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ set -e
# Get the script's directory.
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# Define the Android SDK version you want to target.
ANDROID_SDK_VERSION="36"
ANDROID_BUILD_TOOLS_VERSION="36.0.0"
ANDROID_SDK_VERSION="37.0"
ANDROID_BUILD_TOOLS_VERSION="37.0.0"

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

# --- Environment Setup ---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,10 @@ import com.android.developers.androidify.model.ValidatedDescription
import com.android.developers.androidify.model.ValidatedImage
import com.google.firebase.Firebase
import com.google.firebase.ai.GenerativeModel
import com.google.firebase.ai.ImagenModel
import com.google.firebase.ai.ai
import com.google.firebase.ai.type.GenerativeBackend
import com.google.firebase.ai.type.HarmBlockThreshold
import com.google.firebase.ai.type.HarmCategory
import com.google.firebase.ai.type.ImagenPersonFilterLevel
import com.google.firebase.ai.type.ImagenSafetyFilterLevel
import com.google.firebase.ai.type.ImagenSafetySettings
import com.google.firebase.ai.type.PublicPreviewAPI
import com.google.firebase.ai.type.ResponseModality
import com.google.firebase.ai.type.SafetySetting
Expand Down Expand Up @@ -81,15 +77,20 @@ class FirebaseAiDataSourceImpl @Inject constructor(
)
}

private fun createGenerativeImageModel(): ImagenModel {
return Firebase.ai(backend = GenerativeBackend.vertexAI()).imagenModel(
remoteConfigDataSource.imageModelName(),
safetySettings =
ImagenSafetySettings(
safetyFilterLevel = ImagenSafetyFilterLevel.BLOCK_LOW_AND_ABOVE,
// Uses `ALLOW_ADULT` filter since `ALLOW_ALL` requires a special approval
// See https://cloud.google.com/vertex-ai/generative-ai/docs/image/responsible-ai-imagen#person-face-gen
personFilterLevel = ImagenPersonFilterLevel.ALLOW_ADULT,
private fun createGenerativeImageModel(): GenerativeModel {
return Firebase.ai(backend = GenerativeBackend.vertexAI()).generativeModel(
modelName = remoteConfigDataSource.imageModelName(),
generationConfig = generationConfig {
responseModalities = listOf(
ResponseModality.IMAGE,
)
},
safetySettings = listOf(
SafetySetting(HarmCategory.HARASSMENT, HarmBlockThreshold.LOW_AND_ABOVE),
SafetySetting(HarmCategory.HATE_SPEECH, HarmBlockThreshold.LOW_AND_ABOVE),
SafetySetting(HarmCategory.SEXUALLY_EXPLICIT, HarmBlockThreshold.LOW_AND_ABOVE),
SafetySetting(HarmCategory.DANGEROUS_CONTENT, HarmBlockThreshold.LOW_AND_ABOVE),
SafetySetting(HarmCategory.CIVIC_INTEGRITY, HarmBlockThreshold.LOW_AND_ABOVE),
),
)
}
Expand Down Expand Up @@ -227,11 +228,13 @@ class FirebaseAiDataSourceImpl @Inject constructor(
}

private suspend fun executeImageGeneration(
generativeModel: ImagenModel,
generativeModel: GenerativeModel,
prompt: String,
): Bitmap {
val response = generativeModel.generateImages(prompt)
return response.images.first().asBitmap()
val response = generativeModel.generateContent(prompt)
val image = response.candidates.firstOrNull()
?.content?.parts?.firstNotNullOfOrNull { it.asImageOrNull() }
return image ?: throw IllegalStateException("Could not extract image from model response")
}

override suspend fun generatePrompt(prompt: String): GeneratedPrompt {
Expand Down
1 change: 1 addition & 0 deletions core/theme/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ android {
dependencies {
implementation(libs.androidx.ui.text.google.fonts)
implementation(platform(libs.androidx.compose.bom))
implementation(libs.androidx.compose.foundation)
implementation(libs.androidx.ui.tooling.preview)
implementation(libs.androidx.material3)
implementation(projects.core.util)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.assertIsEnabled
import androidx.compose.ui.test.assertIsNotDisplayed
import androidx.compose.ui.test.assertIsNotEnabled
import androidx.compose.ui.test.junit4.createAndroidComposeRule
import androidx.compose.ui.test.junit4.v2.createAndroidComposeRule
import androidx.compose.ui.test.onNodeWithContentDescription
import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performClick
Expand Down
3 changes: 3 additions & 0 deletions feature/creation/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ dependencies {
implementation(libs.hilt.android)
implementation(libs.timber)
implementation(libs.androidx.hilt.navigation.compose)
implementation(libs.androidx.lifecycle.runtime.ktx)
implementation(libs.androidx.lifecycle.viewmodel.ktx)
implementation(libs.androidx.lifecycle.viewmodel.compose)
implementation(libs.androidx.adaptive)
implementation(libs.androidx.adaptive.layout)
implementation(libs.androidx.window)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import androidx.compose.material3.SnackbarHostState
import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.assertIsOff
import androidx.compose.ui.test.assertIsOn
import androidx.compose.ui.test.junit4.createAndroidComposeRule
import androidx.compose.ui.test.junit4.v2.createAndroidComposeRule
import androidx.compose.ui.test.onNodeWithContentDescription
import androidx.compose.ui.test.onNodeWithText
import androidx.test.ext.junit.runners.AndroidJUnit4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import kotlinx.coroutines.Job
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.update
import kotlinx.coroutines.isActive
import kotlinx.coroutines.launch
import timber.log.Timber

Expand Down Expand Up @@ -77,6 +78,7 @@ class CreationViewModel @AssistedInject constructor(
private var imageGenerationJob: Job? = null

init {
Timber.d("CreationViewModel init. hashCode: ${hashCode()}")
onImageSelected(originalImageUrl)
}

Expand All @@ -103,6 +105,7 @@ class CreationViewModel @AssistedInject constructor(

fun onPromptGenerationClicked() {
promptGenerationJob?.cancel()
Timber.d("CreationViewModel onPrompt. hashCode: ${hashCode()} ${viewModelScope.isActive}")
promptGenerationJob = viewModelScope.launch {
Timber.d("Generating prompt...")
_uiState.update {
Expand Down Expand Up @@ -238,6 +241,11 @@ class CreationViewModel @AssistedInject constructor(
it.copy(resultBitmapUri = null)
}
}

override fun onCleared() {
super.onCleared()
Timber.d("CreationViewModel onCleared. hashCode: ${hashCode()}")
}
}

data class CreationState(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ import androidx.compose.ui.unit.dp
import androidx.xr.compose.spatial.ContentEdge
import androidx.xr.compose.spatial.Orbiter
import androidx.xr.compose.subspace.SpatialColumn
import androidx.xr.compose.subspace.SpatialLayoutSpacer
import androidx.xr.compose.subspace.SpatialPanel
import androidx.xr.compose.subspace.SpatialRow
import androidx.xr.compose.subspace.SpatialSpacer
import androidx.xr.compose.subspace.layout.SubspaceModifier
import androidx.xr.compose.subspace.layout.fillMaxHeight
import androidx.xr.compose.subspace.layout.fillMaxWidth
Expand Down Expand Up @@ -142,7 +142,7 @@ fun EditScreenSpatial(
}
}
}
SpatialLayoutSpacer(SubspaceModifier.width(48.dp))
SpatialSpacer(SubspaceModifier.width(48.dp))
SpatialPanel(
modifier = SubspaceModifier
.offset(z = 10.dp)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@
package com.android.developers.androidify.home

import androidx.activity.ComponentActivity
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.ui.platform.LocalInspectionMode
import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.assertIsNotDisplayed
import androidx.compose.ui.test.junit4.createAndroidComposeRule
import androidx.compose.ui.test.junit4.v2.createAndroidComposeRule
import androidx.compose.ui.test.onNodeWithContentDescription
import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performClick
Expand Down Expand Up @@ -47,15 +49,17 @@ class HomeScreenTest {
// Directly render HomeScreenContents, passing a lambda to track the click

SharedElementContextPreview {
HomeScreenContents(
layoutType = HomeScreenLayoutType.Compact, // Provide a default or mock value
onClickLetsGo = { offset: IntOffset -> // Match the lambda signature
wasClicked = true
},
onAboutClicked = {}, // Provide a default or mock value,
videoLink = "",
dancingBotLink = "",
)
CompositionLocalProvider(LocalInspectionMode provides true) {
HomeScreenContents(
layoutType = HomeScreenLayoutType.Compact, // Provide a default or mock value
onClickLetsGo = { offset: IntOffset -> // Match the lambda signature
wasClicked = true
},
onAboutClicked = {}, // Provide a default or mock value,
videoLink = "",
dancingBotLink = "",
)
}
}
}

Expand All @@ -73,13 +77,15 @@ class HomeScreenTest {

composeTestRule.setContent {
SharedElementContextPreview {
HomeScreenContents(
layoutType = HomeScreenLayoutType.Compact, // Ensure compact mode for pager
onClickLetsGo = { },
onAboutClicked = {},
videoLink = "",
dancingBotLink = "",
)
CompositionLocalProvider(LocalInspectionMode provides true) {
HomeScreenContents(
layoutType = HomeScreenLayoutType.Compact, // Ensure compact mode for pager
onClickLetsGo = { },
onAboutClicked = {},
videoLink = "",
dancingBotLink = "",
)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import androidx.compose.ui.platform.LocalInspectionMode
import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.assertIsOff
import androidx.compose.ui.test.assertIsOn
import androidx.compose.ui.test.junit4.createAndroidComposeRule
import androidx.compose.ui.test.junit4.v2.createAndroidComposeRule
import androidx.compose.ui.test.onNodeWithContentDescription
import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performClick
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ import androidx.xr.compose.spatial.Orbiter
import androidx.xr.compose.spatial.OrbiterOffsetType
import androidx.xr.compose.subspace.SpatialBox
import androidx.xr.compose.subspace.SpatialColumn
import androidx.xr.compose.subspace.SpatialLayoutSpacer
import androidx.xr.compose.subspace.SpatialPanel
import androidx.xr.compose.subspace.SpatialRow
import androidx.xr.compose.subspace.SpatialSpacer
import androidx.xr.compose.subspace.layout.SubspaceModifier
import androidx.xr.compose.subspace.layout.fillMaxHeight
import androidx.xr.compose.subspace.layout.fillMaxWidth
Expand Down Expand Up @@ -109,7 +109,7 @@ fun CustomizeExportLayoutSpatial(
}
}
}
SpatialLayoutSpacer(SubspaceModifier.width(48.dp))
SpatialSpacer(SubspaceModifier.width(48.dp))
SpatialBox(SubspaceModifier.fillMaxHeight(0.7f)) {
SpatialPanel(
modifier = SubspaceModifier.offset(z = 10.dp).fillMaxWidth(0.3f),
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# The setting is particularly useful for tweaking memory settings.
org.gradle.caching=true
org.gradle.parallel=true
org.gradle.jvmargs=-Dfile.encoding=UTF-8 -XX:+UseG1GC -XX:SoftRefLRUPolicyMSPerMB=1 -XX:ReservedCodeCacheSize=256m -XX:+HeapDumpOnOutOfMemoryError -Xmx4g -Xms4g
org.gradle.jvmargs=-Dfile.encoding=UTF-8 -XX:+UseG1GC -XX:SoftRefLRUPolicyMSPerMB=1 -XX:ReservedCodeCacheSize=256m -XX:+HeapDumpOnOutOfMemoryError -Xmx6g -Xms6g
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. For more details, visit
# https://developer.android.com/r/tools/gradle-multi-project-decoupled-projects
Expand Down
Loading
Loading