Skip to content

Commit b2d19b2

Browse files
committed
Add a feature toggle for background vibes
1 parent a008553 commit b2d19b2

5 files changed

Lines changed: 45 additions & 11 deletions

File tree

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/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
@@ -30,6 +30,10 @@ class TestRemoteConfigDataSource(private val useGeminiNano: Boolean) : RemoteCon
3030
TODO("Not yet implemented")
3131
}
3232

33+
override fun isBackgroundVibesFeatureEnabled(): Boolean {
34+
return true
35+
}
36+
3337
override fun promptTextVerify(): String {
3438
TODO("Not yet implemented")
3539
}

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: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,7 @@ data class BackgroundToolState(
6060
BackgroundOption.None,
6161
BackgroundOption.Plain,
6262
BackgroundOption.Lightspeed,
63-
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,
63+
BackgroundOption.IO
7464
),
7565
) : ToolState
7666

0 commit comments

Comments
 (0)