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
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ import com.google.ai.edge.gallery.ui.common.tos.TosViewModel
import com.google.ai.edge.gallery.ui.modelmanager.ModelManagerViewModel
import com.google.ai.edge.gallery.ui.theme.bodyMediumMedium
import com.google.ai.edge.gallery.ui.theme.customColors
import kotlin.text.toFloat

/**
* Composable function to display a model item in the model manager list.
Expand Down Expand Up @@ -148,13 +147,16 @@ fun ModelItem(
)
// Model action menu (benchmark, delete), and button to expand/collapse button at the right.
Row(verticalAlignment = Alignment.Top, modifier = Modifier.align(Alignment.TopEnd)) {
val isWebImport = model.imported && model.url.isNotEmpty()
if (
modelVariants.isEmpty() && downloadStatus?.status == ModelDownloadStatusType.SUCCEEDED
modelVariants.isEmpty() &&
(downloadStatus?.status == ModelDownloadStatusType.SUCCEEDED || isWebImport)
) {
ModelItemActionMenu(
model = model,
modelManagerViewModel = modelManagerViewModel,
showBenchmarkButton = showBenchmarkButton,
showBenchmarkButton =
showBenchmarkButton && downloadStatus?.status == ModelDownloadStatusType.SUCCEEDED,
showDeleteButton =
showDeleteButton && model.localFileRelativeDirPathOverride.isEmpty() && !isAicore,
onBenchmarkClicked = { onBenchmarkClicked(model) },
Expand Down Expand Up @@ -387,11 +389,13 @@ fun ModelVariantHeader(
)
}
// Model action menu (benchmark, delete)
if (downloadStatus?.status == ModelDownloadStatusType.SUCCEEDED) {
val isWebImport = variantModel.imported && variantModel.url.isNotEmpty()
if (downloadStatus?.status == ModelDownloadStatusType.SUCCEEDED || isWebImport) {
ModelItemActionMenu(
model = variantModel,
modelManagerViewModel = modelManagerViewModel,
showBenchmarkButton = showBenchmarkButton,
showBenchmarkButton =
showBenchmarkButton && downloadStatus?.status == ModelDownloadStatusType.SUCCEEDED,
showDeleteButton =
showDeleteButton &&
variantModel.localFileRelativeDirPathOverride.isEmpty() &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ import androidx.compose.ui.semantics.clearAndSetSemantics
import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.semantics.role
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.text.buildAnnotatedString
import androidx.compose.ui.unit.dp
import androidx.core.net.toUri
import com.google.ai.edge.gallery.R
Expand All @@ -96,6 +97,7 @@ import com.google.ai.edge.gallery.data.RuntimeType
import com.google.ai.edge.gallery.data.Task
import com.google.ai.edge.gallery.proto.ImportedModel
import com.google.ai.edge.gallery.ui.common.TaskIcon
import com.google.ai.edge.gallery.ui.common.buildTrackableUrlAnnotatedString
import com.google.ai.edge.gallery.ui.common.modelitem.ModelItem
import com.google.ai.edge.gallery.ui.common.tos.TosViewModel
import kotlin.text.endsWith
Expand Down Expand Up @@ -412,6 +414,12 @@ fun GlobalModelManager(
style = MaterialTheme.typography.titleLarge,
modifier = Modifier.padding(vertical = 4.dp, horizontal = 16.dp),
)
Text(
stringResource(R.string.import_model_terms_subtitle),
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onSurfaceVariant,
modifier = Modifier.padding(start = 16.dp, end = 16.dp, bottom = 12.dp),
)
val cbImportFromLocalFile = stringResource(R.string.cd_import_model_from_local_file_button)
Box(
modifier =
Expand Down Expand Up @@ -538,7 +546,17 @@ fun GlobalModelManager(
title = { Text(stringResource(R.string.import_from_hugging_face_title)) },
text = {
Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
Text(stringResource(R.string.enter_hugging_face_url))
Text(
buildAnnotatedString {
append(stringResource(R.string.enter_hugging_face_url))
append(
buildTrackableUrlAnnotatedString(
url = stringResource(R.string.enter_hugging_face_url_example_link),
linkText = stringResource(R.string.enter_hugging_face_url_example_link),
)
)
}
)
OutlinedTextField(
value = huggingFaceUrlInput,
onValueChange = { huggingFaceUrlInput = it },
Expand Down
4 changes: 3 additions & 1 deletion Android/src/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -385,10 +385,12 @@
<string name="clear_history_dialog_content" translatable="true">Are you sure you want to clear the history? This action cannot be undone.</string>

<!-- Strings for model import dialog [CHAR LIMIT=NONE] -->
<string name="import_model_terms_subtitle" translatable="true" description="Subtitle in the import model bottom sheet reminding users to adhere to separate model terms.">You are responsible for adhering to any separate terms applicable to models.</string>
<string name="cd_import_model_from_hugging_face" translatable="true" description="Content description spoken when the import model from hugging face button is focused.">Import model from Hugging Face</string>
<string name="import_model_from_hugging_face" translatable="true" description="Text label on the button/option to import a model from Hugging Face.">From Hugging Face</string>
<string name="import_from_hugging_face_title" translatable="true" description="Title of the dialog box for importing a model from Hugging Face.">Import from Hugging Face</string>
<string name="enter_hugging_face_url" translatable="true" description="Prompt text to guide the user to enter a Hugging Face model URL.">Enter the Hugging Face model URL:</string>
<string name="enter_hugging_face_url" translatable="true" description="Prompt text to guide the user to enter a Hugging Face model URL.">"Enter the Hugging Face model file URL, for example: "</string>
<string name="enter_hugging_face_url_example_link" translatable="false">https://huggingface.co/litert-community/gemma-4-E2B-it-litert-lm/resolve/main/gemma-4-E2B-it.litertlm</string>
<string name="hugging_face_url_placeholder" description="Placeholder text shown inside the text field where the user enters the URL.">https://huggingface.co/…</string>
<string name="next" translatable="true" description="Button text to navigate to the next step.">Next</string>
<string name="unsupported_model_title" translatable="true" description="Title of the dialog showing that the imported model type is unsupported.">Unsupported model type</string>
Expand Down
Loading