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
3 changes: 2 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?><!--
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2025 The Android Open Source Project

Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ fun MainNavigation() {
},
onTermsClicked = {
uriHandler.openUri("https://policies.google.com/terms")
}
},
)
}
},
Expand Down
9 changes: 3 additions & 6 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ subprojects {
apply(plugin = "com.diffplug.spotless")
extensions.configure<com.diffplug.gradle.spotless.SpotlessExtension> {
kotlin {
target("**/*.kt")
targetExclude("**/build/**/*.kt")
target("src/**/*.kt")
ktlint(libs.versions.ktlint.get()).editorConfigOverride(
mapOf(
"android" to "true",
Expand All @@ -38,14 +37,12 @@ subprojects {
licenseHeaderFile(rootProject.file("spotless/copyright.kt"))
}
kotlinGradle {
target("**/*.kts")
targetExclude("**/build/**/*.kts")
target("*.kts")
// Look for the first line that doesn't have a block comment (assumed to be the license)
licenseHeaderFile(rootProject.file("spotless/copyright.kts"), "(^(?![\\/ ]\\*).*$)")
}
format("xml") {
target("**/*.xml")
targetExclude("**/build/**/*.xml")
target("src/**/*.xml")
// Look for the first XML tag that isn't a comment (<!--) or the xml declaration (<?xml)
licenseHeaderFile(rootProject.file("spotless/copyright.xml"), "(<[^!?])")
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* Copyright 2026 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.developers.testing.data

import com.android.developers.androidify.data.GeminiNanoDownloader
Expand All @@ -6,4 +21,4 @@ class TestGeminiNanoDownloader(val modelDownloaded: Boolean) : GeminiNanoDownloa
override fun isModelDownloaded(): Boolean {
return modelDownloaded
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import com.android.developers.androidify.model.ValidatedImage

class TestGeminiNanoGenerationDataSource(
val promptOutput: String?,
val geminiNanoDownloader: GeminiNanoDownloader
val geminiNanoDownloader: GeminiNanoDownloader,
) : GeminiNanoGenerationDataSource {

override suspend fun generatePrompt(prompt: String): String? {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
/*
* Copyright 2026 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.developers.testing.network

import android.graphics.Bitmap
import com.android.developers.androidify.ondevice.LocalSegmentationDataSource
import androidx.core.graphics.createBitmap
import com.android.developers.androidify.ondevice.LocalSegmentationDataSource

class TestLocalSegmentationDataSource() : LocalSegmentationDataSource {

override suspend fun removeBackground(bitmap: Bitmap): Bitmap {
return createBitmap(100, 100)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@ package com.android.developers.androidify.theme

import androidx.compose.animation.BoundsTransform
import androidx.compose.animation.ExperimentalSharedTransitionApi
import androidx.compose.animation.core.FiniteAnimationSpec
import androidx.compose.material3.ExperimentalMaterial3ExpressiveApi
import androidx.compose.material3.MotionScheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.geometry.Rect

@OptIn(
ExperimentalMaterial3ExpressiveApi::class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@ import androidx.compose.ui.tooling.preview.Devices.PIXEL_7_PRO
import androidx.compose.ui.tooling.preview.Devices.PIXEL_FOLD
import androidx.compose.ui.tooling.preview.Devices.PIXEL_TABLET
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp

@Preview(device = PIXEL_7_PRO, name = "Phone preview")
@Preview(widthDp = 891, heightDp = 411, name = "Phone landscape preview", )
@Preview(widthDp = 891, heightDp = 411, name = "Phone landscape preview")
annotation class PhonePreview

@Preview(device = PIXEL_3A_XL, name = "Phone small preview", heightDp = 300, widthDp = 500)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ fun isWidthAtLeastMedium(): Boolean {
fun areBothWindowDimensionsAtLeastMedium(): Boolean {
val sizeClass = calculateWindowSizeClass()
return sizeClass.isHeightAtLeastBreakpoint(WindowSizeClass.HEIGHT_DP_MEDIUM_LOWER_BOUND) &&
sizeClass.isWidthAtLeastBreakpoint(WindowSizeClass.WIDTH_DP_MEDIUM_LOWER_BOUND)
sizeClass.isWidthAtLeastBreakpoint(WindowSizeClass.WIDTH_DP_MEDIUM_LOWER_BOUND)
}

/***
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
package com.android.developers.androidify.data

import android.graphics.Bitmap
import androidx.annotation.VisibleForTesting
import com.android.developers.androidify.RemoteConfigDataSource
import com.android.developers.androidify.model.ImageValidationError
import com.android.developers.androidify.model.ValidatedDescription
Expand Down Expand Up @@ -48,8 +47,7 @@ internal class GeminiNanoGenerationDataSourceImpl @Inject constructor(
override suspend fun generatePrompt(prompt: String): String? {
if (!downloader.isModelDownloaded()) return null
val response = downloader.generativeModel.generateContent(
generateContentRequest(TextPart(prompt))
{
generateContentRequest(TextPart(prompt)) {
temperature = 0.2f
topK = 16
candidateCount = 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ internal class ImageGenerationRepositoryImpl @Inject constructor(

override suspend fun addBackgroundToBot(image: Bitmap, backgroundPrompt: String): Bitmap {
val backgroundBotInstructions = remoteConfigDataSource.getBotBackgroundInstructionPrompt() +
"\"" + backgroundPrompt + "\""
"\"" + backgroundPrompt + "\""
return firebaseAiDataSource.generateImageWithEdit(image, backgroundBotInstructions)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class GeminiNanoDownloaderInitializer : Initializer<Unit> {
override fun create(context: Context) {
val hiltEntryPoint = EntryPointAccessors.fromApplication(
context,
GeminiNanoDownloaderInitializerEntryPoint::class.java
GeminiNanoDownloaderInitializerEntryPoint::class.java,
)
val remoteConfigDataSource = hiltEntryPoint.remoteConfigDataSource()
if (remoteConfigDataSource.useGeminiNano()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* Copyright 2026 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.developers.androidify.data

import com.android.developers.testing.data.TestFileProvider
Expand Down Expand Up @@ -26,7 +41,7 @@ class ImageGenerationRepositoryTest {
TestGeminiNanoGenerationDataSource("", TestGeminiNanoDownloader(false)),
TestFirebaseAiDataSource(listOf("")),
TestRemoteConfigDataSource(false),
TestLocalSegmentationDataSource()
TestLocalSegmentationDataSource(),
)

val description = repository.getDescriptionFromImage(File(""))
Expand All @@ -41,7 +56,7 @@ class ImageGenerationRepositoryTest {
TestGeminiNanoGenerationDataSource("", TestGeminiNanoDownloader(true)),
TestFirebaseAiDataSource(listOf("")),
TestRemoteConfigDataSource(true),
TestLocalSegmentationDataSource()
TestLocalSegmentationDataSource(),
)

val description = repository.getDescriptionFromImage(File(""))
Expand All @@ -56,7 +71,7 @@ class ImageGenerationRepositoryTest {
TestGeminiNanoGenerationDataSource("", TestGeminiNanoDownloader(false)),
TestFirebaseAiDataSource(listOf("")),
TestRemoteConfigDataSource(true),
TestLocalSegmentationDataSource()
TestLocalSegmentationDataSource(),
)

val description = repository.getDescriptionFromImage(File(""))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ private fun TableTopCameraLayout(
Box(
modifier = Modifier
.weight(1f)
.aspectRatio(9/16f),
.aspectRatio(9 / 16f),
) {
viewfinder(Modifier)
guide(Modifier.fillMaxSize())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.lifecycle.compose.collectAsStateWithLifecycle


@Composable
fun CreationScreen(
creationViewModel: CreationViewModel,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,15 +139,18 @@ fun PhotoPrompt(
cornerRadius = 28.dp,
)
.run {
if (externalAppCallback == null) this
else dragAndDropTarget(
shouldStartDragAndDrop = { event ->
dropBehaviourFactory.shouldStartDragAndDrop(
event,
)
},
target = externalAppCallback,
)
if (externalAppCallback == null) {
this
} else {
dragAndDropTarget(
shouldStartDragAndDrop = { event ->
dropBehaviourFactory.shouldStartDragAndDrop(
event,
)
},
target = externalAppCallback,
)
}
}
.fillMaxSize()
.padding(2.dp),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,27 +24,19 @@ package com.android.developers.androidify.creation

import android.net.Uri
import androidx.compose.animation.ExperimentalSharedTransitionApi
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.ExperimentalLayoutApi
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.pager.HorizontalPager
import androidx.compose.foundation.pager.PagerScope
import androidx.compose.foundation.pager.PagerState
import androidx.compose.foundation.pager.rememberPagerState
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.ExperimentalMaterial3ExpressiveApi
import androidx.compose.material3.FloatingToolbarColors
import androidx.compose.material3.HorizontalFloatingToolbar
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.material3.ToggleButton
import androidx.compose.material3.ToggleButtonDefaults
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.derivedStateOf
Expand All @@ -59,7 +51,6 @@ import com.android.developers.androidify.data.DropBehaviourFactory
import com.android.developers.androidify.theme.AndroidifyTheme
import com.android.developers.androidify.theme.SharedElementContextPreview
import com.android.developers.androidify.theme.components.HorizontalToolbar
import com.android.developers.androidify.util.PhonePreview
import kotlinx.coroutines.launch

@Composable
Expand Down Expand Up @@ -92,8 +83,8 @@ fun MainCreationPane(
// Workaround for https://issuetracker.google.com/432431393
val showTextPrompt by remember {
derivedStateOf {
pagerState.currentPage == PromptType.TEXT.ordinal
&& pagerState.targetPage == pagerState.currentPage
pagerState.currentPage == PromptType.TEXT.ordinal &&
pagerState.targetPage == pagerState.currentPage
}
}
if (showTextPrompt) {
Expand All @@ -113,7 +104,6 @@ fun MainCreationPane(
}
}


@Composable
private fun PromptTypePager(
modifier: Modifier = Modifier,
Expand Down Expand Up @@ -203,7 +193,7 @@ private fun PromptTypeMainPreview() {
onUndoPressed = {},
onPromptGenerationPressed = {},
onSelectedPromptOptionChanged = {},
onDropCallback = {}
onDropCallback = {},
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class CreationViewModelTest {
viewModel.uiState.value.screenState,
)
assertEquals(false, viewModel.uiState.value.promptGenerationInProgress)
assertEquals( null, viewModel.uiState.value.imageUri)
assertEquals(null, viewModel.uiState.value.imageUri)
}

@Test
Expand Down
Loading
Loading