Skip to content

Commit b873d37

Browse files
Google AI Edge Gallerycopybara-github
authored andcommitted
internal changes
PiperOrigin-RevId: 892451439
1 parent 886a727 commit b873d37

File tree

3 files changed

+37
-15
lines changed

3 files changed

+37
-15
lines changed

Android/src/app/src/main/java/com/google/ai/edge/gallery/ui/common/DownloadAndTryButton.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ import kotlinx.coroutines.withContext
9393
private const val TAG = "AGDownloadAndTryButton"
9494
private const val SYSTEM_RESERVED_MEMORY_IN_BYTES = 3 * (1L shl 30)
9595

96+
private val MODEL_NAMES_TO_SHOW_GEMMA_LICENSES =
97+
setOf("Gemma-3n-E2B-it", "Gemma-3n-E4B-it", "Gemma3-1B-IT")
98+
9699
/**
97100
* Handles the "Download & Try it" button click, managing the model download process based on
98101
* various conditions.
@@ -372,6 +375,7 @@ fun DownloadAndTryButton(
372375
// Check TOS before downloading.
373376
if (
374377
model.url.startsWith("https://dl.google.com/google-ai-edge-gallery/") &&
378+
MODEL_NAMES_TO_SHOW_GEMMA_LICENSES.contains(model.name) &&
375379
!tosViewModel.getIsGemmaTermsOfUseAccepted()
376380
) {
377381
showGemmaTermsOfUseDialog = true

Android/src/app/src/main/java/com/google/ai/edge/gallery/ui/common/chat/ChatPanel.kt

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ import androidx.compose.animation.core.VisibilityThreshold
2323
import androidx.compose.animation.core.spring
2424
import androidx.compose.animation.fadeIn
2525
import androidx.compose.animation.fadeOut
26+
import androidx.compose.animation.scaleIn
27+
import androidx.compose.animation.scaleOut
2628
import androidx.compose.animation.slideInVertically
2729
import androidx.compose.foundation.background
2830
import androidx.compose.foundation.layout.Arrangement
@@ -78,21 +80,22 @@ import androidx.compose.ui.res.dimensionResource
7880
import androidx.compose.ui.res.stringResource
7981
import androidx.compose.ui.semantics.contentDescription
8082
import androidx.compose.ui.semantics.semantics
83+
import androidx.compose.ui.text.font.FontWeight
8184
import androidx.compose.ui.text.style.TextAlign
8285
import androidx.compose.ui.unit.IntOffset
8386
import androidx.compose.ui.unit.dp
87+
import androidx.compose.ui.unit.sp
8488
import com.google.ai.edge.gallery.R
8589
import com.google.ai.edge.gallery.data.BuiltInTaskId
8690
import com.google.ai.edge.gallery.data.Model
8791
import com.google.ai.edge.gallery.data.Task
8892
import com.google.ai.edge.gallery.ui.common.AudioAnimation
8993
import com.google.ai.edge.gallery.ui.common.ErrorDialog
9094
import com.google.ai.edge.gallery.ui.common.FloatingBanner
95+
import com.google.ai.edge.gallery.ui.common.RotationalLoader
9196
import com.google.ai.edge.gallery.ui.modelmanager.ModelInitializationStatusType
9297
import com.google.ai.edge.gallery.ui.modelmanager.ModelManagerViewModel
9398
import com.google.ai.edge.gallery.ui.theme.customColors
94-
import com.google.ai.edge.gallery.ui.theme.emptyStateContent
95-
import com.google.ai.edge.gallery.ui.theme.emptyStateTitle
9699
import kotlinx.coroutines.delay
97100

98101
/** Composable function for the main chat panel, displaying messages and handling user input. */
@@ -483,30 +486,44 @@ fun ChatPanel(
483486

484487
// Show empty state.
485488
if (messages.isEmpty() && pickedImagesCount == 0 && pickedAudioClipsCount == 0) {
486-
if (
487-
modelInitializationStatus?.status == ModelInitializationStatusType.INITIALIZING &&
488-
modelInitializationStatus.isFirstInitialization(selectedModel)
489+
emptyStateComposable(selectedModel)
490+
}
491+
// Loading screen when model is initialized for that first time.
492+
val isFirstInitializing =
493+
modelInitializationStatus?.status == ModelInitializationStatusType.INITIALIZING &&
494+
modelInitializationStatus.isFirstInitialization(selectedModel)
495+
Column(
496+
horizontalAlignment = Alignment.CenterHorizontally,
497+
verticalArrangement = Arrangement.Center,
498+
) {
499+
AnimatedVisibility(
500+
isFirstInitializing,
501+
enter = fadeIn() + scaleIn(initialScale = 0.9f),
502+
exit = fadeOut() + scaleOut(targetScale = 0.9f),
489503
) {
490-
Box(modifier = Modifier.fillMaxSize()) {
504+
Box(modifier = Modifier.background(MaterialTheme.colorScheme.surface).fillMaxSize()) {
491505
Column(
492-
modifier =
493-
Modifier.align(Alignment.Center)
494-
.padding(horizontal = 48.dp)
495-
.padding(bottom = 48.dp),
506+
modifier = Modifier.align(Alignment.Center),
496507
horizontalAlignment = Alignment.CenterHorizontally,
497-
verticalArrangement = Arrangement.spacedBy(12.dp),
508+
verticalArrangement = Arrangement.spacedBy(8.dp),
498509
) {
499-
Text(stringResource(R.string.aichat_initializing_title), style = emptyStateTitle)
510+
RotationalLoader(size = 32.dp)
511+
Text(
512+
stringResource(R.string.aichat_initializing_title),
513+
style =
514+
MaterialTheme.typography.headlineLarge.copy(
515+
fontSize = 24.sp,
516+
fontWeight = FontWeight.Bold,
517+
),
518+
)
500519
Text(
501520
stringResource(R.string.aichat_initializing_content),
502-
style = emptyStateContent,
521+
style = MaterialTheme.typography.bodyMedium,
503522
color = MaterialTheme.colorScheme.onSurfaceVariant,
504523
textAlign = TextAlign.Center,
505524
)
506525
}
507526
}
508-
} else {
509-
emptyStateComposable(selectedModel)
510527
}
511528
}
512529
}

Android/src/app/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<!-- TODO(jingjin): Add translation support when i18n is ready. -->
1919
<string name="all" translatable="false">All</string>
2020
<string name="add" translatable="false">Add</string>
21+
<string name="added" translatable="false">Added</string>
2122
<string name="add_audio" translatable="false">+Audio</string>
2223
<string name="aichat_emptystate_title" translatable="false">AI Chat</string>
2324
<string name="aichat_emptystate_content" translatable="false">Chat with on-device large language models</string>

0 commit comments

Comments
 (0)