Skip to content

Commit be4d76b

Browse files
authored
Merge pull request #113 from android/feature/toggle-background-vibes
Add a feature toggle for background vibes
2 parents 94fafe3 + 909703e commit be4d76b

File tree

12 files changed

+78
-28
lines changed

12 files changed

+78
-28
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ interface RemoteConfigDataSource {
2424
fun isAppInactive(): Boolean
2525
fun textModelName(): String
2626
fun imageModelName(): String
27+
fun isBackgroundVibesFeatureEnabled(): Boolean
2728
fun promptTextVerify(): String
2829
fun promptImageValidation(): String
2930
fun promptImageDescription(): String
@@ -60,6 +61,10 @@ class RemoteConfigDataSourceImpl @Inject constructor() : RemoteConfigDataSource
6061
return remoteConfig.getString("image_model_name")
6162
}
6263

64+
override fun isBackgroundVibesFeatureEnabled(): Boolean {
65+
return remoteConfig.getBoolean("background_vibes_feature_enabled")
66+
}
67+
6368
override fun promptTextVerify(): String {
6469
return remoteConfig.getString("prompt_text_verify")
6570
}

core/network/src/main/java/com/android/developers/androidify/startup/FirebaseAppCheckInitializer.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ class FirebaseAppCheckInitializer : Initializer<FirebaseAppCheck> {
3636
if (BuildConfig.DEBUG) {
3737
Log.i("AndroidifyAppCheck", "Firebase debug")
3838
installAppCheckProviderFactory(
39-
DebugAppCheckProviderFactory.getInstance()
39+
DebugAppCheckProviderFactory.getInstance(),
4040
)
4141
} else {
4242
Log.i("AndroidifyAppCheck", "Play integrity")
4343
installAppCheckProviderFactory(
4444
PlayIntegrityAppCheckProviderFactory.getInstance(),
45-
)
45+
)
4646
}
4747
}
4848
}

core/network/src/main/res/xml/remote_config_defaults.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
limitations under the License.
1616
-->
1717
<defaults>
18+
<entry>
19+
<key>background_vibes_feature_enabled</key>
20+
<value>false</value>
21+
</entry>
1822
<entry>
1923
<key>bot_background_instruction_prompt</key>
2024
<value>Add the input image android bot as the main subject to the result,

core/testing/src/main/java/com/android/developers/testing/network/TestRemoteConfigDataSource.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ class TestRemoteConfigDataSource(private val useGeminiNano: Boolean) : RemoteCon
2929
override fun imageModelName(): String {
3030
TODO("Not yet implemented")
3131
}
32+
var backgroundVibeEnabled: Boolean = true
33+
override fun isBackgroundVibesFeatureEnabled(): Boolean {
34+
return backgroundVibeEnabled
35+
}
3236

3337
override fun promptTextVerify(): String {
3438
TODO("Not yet implemented")

feature/creation/src/main/java/com/android/developers/androidify/creation/CreationScreen.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -493,8 +493,8 @@ private fun MainCreationPane(
493493
// Workaround for https://issuetracker.google.com/432431393
494494
val showTextPrompt by remember {
495495
derivedStateOf {
496-
pagerState.currentPage == PromptType.TEXT.ordinal
497-
&& pagerState.targetPage == pagerState.currentPage
496+
pagerState.currentPage == PromptType.TEXT.ordinal &&
497+
pagerState.targetPage == pagerState.currentPage
498498
}
499499
}
500500
if (showTextPrompt) {

feature/creation/src/test/kotlin/com/android/developers/androidify/creation/CreationViewModelTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class CreationViewModelTest {
7272
viewModel.uiState.value.screenState,
7373
)
7474
assertEquals(false, viewModel.uiState.value.promptGenerationInProgress)
75-
assertEquals( fakeUri, viewModel.uiState.value.imageUri)
75+
assertEquals(fakeUri, viewModel.uiState.value.imageUri)
7676
}
7777

7878
@Test
@@ -91,7 +91,7 @@ class CreationViewModelTest {
9191
viewModel.uiState.value.screenState,
9292
)
9393
assertEquals(false, viewModel.uiState.value.promptGenerationInProgress)
94-
assertEquals( null, viewModel.uiState.value.imageUri)
94+
assertEquals(null, viewModel.uiState.value.imageUri)
9595
}
9696

9797
@Test

feature/results/src/main/java/com/android/developers/androidify/customize/ComposableBitmapRendererImpl.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import android.content.Context.DISPLAY_SERVICE
2222
import android.graphics.Bitmap
2323
import android.graphics.SurfaceTexture
2424
import android.hardware.display.DisplayManager
25-
import android.hardware.display.VirtualDisplay
2625
import android.view.Display
2726
import android.view.Surface
2827
import android.view.ViewGroup

feature/results/src/main/java/com/android/developers/androidify/customize/CustomizeExportViewModel.kt

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import androidx.compose.material3.SnackbarHostState
2424
import androidx.compose.ui.Modifier
2525
import androidx.lifecycle.AndroidViewModel
2626
import androidx.lifecycle.viewModelScope
27+
import com.android.developers.androidify.RemoteConfigDataSource
2728
import com.android.developers.androidify.data.ImageGenerationRepository
2829
import com.android.developers.androidify.util.LocalFileProvider
2930
import dagger.assisted.Assisted
@@ -43,6 +44,7 @@ class CustomizeExportViewModel @AssistedInject constructor(
4344
val imageGenerationRepository: ImageGenerationRepository,
4445
val composableBitmapRenderer: ComposableBitmapRenderer,
4546
val localFileProvider: LocalFileProvider,
47+
val remoteConfigDataSource: RemoteConfigDataSource,
4648
application: Application,
4749
) : AndroidViewModel(application) {
4850

@@ -63,10 +65,39 @@ class CustomizeExportViewModel @AssistedInject constructor(
6365
get() = _snackbarHostState
6466

6567
init {
68+
val enableBackgroundVibes = remoteConfigDataSource.isBackgroundVibesFeatureEnabled()
69+
var backgrounds = mutableListOf(
70+
BackgroundOption.None,
71+
BackgroundOption.Plain,
72+
BackgroundOption.Lightspeed,
73+
BackgroundOption.IO,
74+
)
75+
if (enableBackgroundVibes) {
76+
val backgroundVibes = listOf(
77+
BackgroundOption.MusicLover,
78+
BackgroundOption.PoolMaven,
79+
BackgroundOption.SoccerFanatic,
80+
BackgroundOption.StarGazer,
81+
BackgroundOption.FitnessBuff,
82+
BackgroundOption.Fandroid,
83+
BackgroundOption.GreenThumb,
84+
BackgroundOption.Gamer,
85+
BackgroundOption.Jetsetter,
86+
BackgroundOption.Chef,
87+
)
88+
backgrounds.addAll(backgroundVibes)
89+
}
90+
6691
_state.update {
6792
it.copy(
6893
originalImageUrl = originalImageUrl,
6994
exportImageCanvas = it.exportImageCanvas.copy(imageUri = resultImageUrl),
95+
toolState = mapOf(
96+
CustomizeTool.Size to AspectRatioToolState(),
97+
CustomizeTool.Background to BackgroundToolState(
98+
options = backgrounds,
99+
),
100+
),
70101
)
71102
}
72103
loadInitialBitmap(resultImageUrl)

feature/results/src/main/java/com/android/developers/androidify/customize/CustomizeState.kt

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,6 @@ data class BackgroundToolState(
6161
BackgroundOption.Plain,
6262
BackgroundOption.Lightspeed,
6363
BackgroundOption.IO,
64-
BackgroundOption.MusicLover,
65-
BackgroundOption.PoolMaven,
66-
BackgroundOption.SoccerFanatic,
67-
BackgroundOption.StarGazer,
68-
BackgroundOption.FitnessBuff,
69-
BackgroundOption.Fandroid,
70-
BackgroundOption.GreenThumb,
71-
BackgroundOption.Gamer,
72-
BackgroundOption.Jetsetter,
73-
BackgroundOption.Chef,
7464
),
7565
) : ToolState
7666

feature/results/src/test/kotlin/com/android/developers/androidify/customize/CustomizeStateTest.kt

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,6 @@ class CustomizeStateTest {
6969
BackgroundOption.Plain,
7070
BackgroundOption.Lightspeed,
7171
BackgroundOption.IO,
72-
BackgroundOption.MusicLover,
73-
BackgroundOption.PoolMaven,
74-
BackgroundOption.SoccerFanatic,
75-
BackgroundOption.StarGazer,
76-
BackgroundOption.FitnessBuff,
77-
BackgroundOption.Fandroid,
78-
BackgroundOption.GreenThumb,
79-
BackgroundOption.Gamer,
80-
BackgroundOption.Jetsetter,
81-
BackgroundOption.Chef,
8272
),
8373
state.options,
8474
)

0 commit comments

Comments
 (0)