Skip to content
Closed
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 @@ -13,6 +13,7 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import dev.opencode.mobile.ui.components.OpenCodeChoiceBadge
import dev.opencode.mobile.ui.components.OpenCodeSessionConnectionStatus
Expand Down Expand Up @@ -177,7 +178,7 @@ fun TopBarGalleryScreen(modifier: Modifier = Modifier) {
ControlGroup(title = "Connection") {
OpenCodeSessionConnectionStatus.entries.forEach { option ->
OpenCodeChoiceBadge(
label = option.label,
label = stringResource(option.label),
selected = option == connectionStatus,
onClick = { statusName = option.name },
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,8 @@ private fun HidePartsBody(
remember(screenshot.jpeg) {
BitmapFactory.decodeByteArray(screenshot.jpeg, 0, screenshot.jpeg.size)?.asImageBitmap()
} ?: return
val imageLabel = stringResource(R.string.feedback_hide_parts_image_label)
val hidden = screenshot.hiddenRects.size
val imageLabel = pluralStringResource(R.plurals.feedback_hide_parts_image_hidden, hidden, hidden)
Column(
modifier = Modifier.fillMaxWidth().padding(horizontal = 16.dp, vertical = 8.dp),
horizontalAlignment = Alignment.CenterHorizontally,
Expand Down Expand Up @@ -628,7 +629,12 @@ private fun LogPreviewBody(state: FeedbackUiState) {
text =
when {
lines == null -> stringResource(R.string.feedback_log_preview_loading)
lines.isEmpty() -> stringResource(R.string.feedback_log_preview_empty)
lines.isEmpty() ->
pluralStringResource(
R.plurals.feedback_log_preview_empty_message,
state.logWindow.minutes,
state.logWindow.minutes,
)
// Redacted log lines are log content, shown as is.
else -> lines.joinToString("\n")
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ internal fun FilesViewerPane(
listOf(
OpenCodeTopBarAction.Icon(
imageVector = OpenCodeIcons.MoreVert,
contentDescription = stringResource(R.string.file_viewer_options),
contentDescription = stringResource(R.string.files_more_options),
onClick = { menuExpanded = true },
),
),
Expand Down Expand Up @@ -159,7 +159,7 @@ private fun FilesViewerBody(
when (val content = viewer.content) {
FilesViewerContent.Loading ->
Box(Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
OpenCodeStatusStack(title = stringResource(R.string.file_viewer_opening), style = OpenCodeStatusStackStyle.Spinner)
OpenCodeStatusStack(title = stringResource(R.string.file_viewer_loading), style = OpenCodeStatusStackStyle.Spinner)
}
is FilesViewerContent.Text -> TextContent(viewer, content, wrapLines, onToggleMarkdownSource, onVisibleLinesChange)
is FilesViewerContent.Image -> ImageContent(content)
Expand Down Expand Up @@ -301,7 +301,7 @@ private fun ImageContent(content: FilesViewerContent.Image) {
when (val image = decoded) {
DecodedImage.Decoding ->
Box(Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
OpenCodeStatusStack(title = stringResource(R.string.file_viewer_opening_image), style = OpenCodeStatusStackStyle.Spinner)
OpenCodeStatusStack(title = stringResource(R.string.file_viewer_loading_image), style = OpenCodeStatusStackStyle.Spinner)
}
is DecodedImage.Ready ->
Image(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ data class AddProjectSheetUi(
val PATH_NOT_FOUND: UiText = UiText.resource(R.string.add_project_path_not_found)
val NO_SUBFOLDERS: UiText = UiText.resource(R.string.add_project_no_subfolders)
val TRUNCATION_HINT: UiText =
UiText.resource(R.string.add_project_truncation_hint, DirectoryListingPolicy.MAX_VISIBLE_DIRECTORIES)
UiText.plural(R.plurals.add_project_truncation_hint, DirectoryListingPolicy.MAX_VISIBLE_DIRECTORIES)

/** Listing failures never show server text, which can carry paths or HTML. */
val LIST_ERROR_MESSAGE: UiText = UiText.resource(R.string.add_project_list_error_message)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,19 +310,19 @@ internal object SessionChatActivityPillCopy {
return UiText.resource(R.string.session_chat_activity_status_action, statusText, UiText.resource(tapAction))
}

/** The round pill that stands for [count] items: its primary's state plus what a tap does. */
/** The round pill that stands for [count] items: its primary's state, then that a tap shows or hides them. */
fun collapsedAccessibilityLabel(
primary: SessionChatActivityItem,
count: Int,
stackOpen: Boolean,
): UiText {
val lead = status(primary)
return when {
count > 1 && stackOpen -> UiText.resource(R.string.session_chat_activity_collapsed_count_hide_activity, lead, count)
count > 1 -> UiText.resource(R.string.session_chat_activity_collapsed_count_show_activity, lead, count)
stackOpen -> UiText.resource(R.string.session_chat_activity_collapsed_hide_activity, lead)
else -> UiText.resource(R.string.session_chat_activity_collapsed_show_activity, lead)
}
val toggle =
if (stackOpen) {
UiText.plural(R.plurals.session_chat_activity_collapsed_hide_count, count)
} else {
UiText.plural(R.plurals.session_chat_activity_collapsed_show_count, count)
}
return UiText.resource(R.string.session_chat_activity_status_action, status(primary), toggle)
}

/** The item's state, as read aloud. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ private fun TerminalErrorContent(
) {
OpenCodeEmptyState(
title = title,
message = message.ifBlank { stringResource(R.string.terminal_error_fallback) },
message = message,
primaryAction = OpenCodeEmptyStateAction(title = stringResource(R.string.terminal_retry), onClick = onRetry),
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ object WorktreeName {
return when {
trimmed.isEmpty() -> UiText.resource(R.string.worktree_name_empty)
!allowed.matches(trimmed) -> UiText.resource(R.string.worktree_name_chars)
trimmed.length > MAX_LENGTH -> UiText.resource(R.string.worktree_name_long, MAX_LENGTH)
trimmed.length > MAX_LENGTH -> UiText.plural(R.plurals.worktree_name_long, MAX_LENGTH)
else -> null
}
}
Expand Down
57 changes: 28 additions & 29 deletions android/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,10 @@
</plurals>
<string name="add_project_no_subfolders">No subfolders</string>
<string name="add_project_nothing_starts_with">Nothing in %1$s starts with “%2$s”</string>
<string name="add_project_truncation_hint">Showing the first %1$d folders. Type more of the name to narrow the list.</string>
<plurals name="add_project_truncation_hint">
<item quantity="one">Showing the first %1$d folder. Type more of the name to narrow the list.</item>
<item quantity="other">Showing the first %1$d folders. Type more of the name to narrow the list.</item>
</plurals>
<string name="add_project_in_folder">In %1$s</string>
<string name="add_project_root_home">Home</string>
<string name="add_project_error_add_failed">Unable to add this directory</string>
Expand All @@ -272,7 +275,10 @@
<string name="worktree_base_failed">Couldn\'t load branches</string>
<string name="worktree_name_empty">Enter a name</string>
<string name="worktree_name_chars">Use letters, numbers, dots, dashes or underscores</string>
<string name="worktree_name_long">Use at most %1$d characters</string>
<plurals name="worktree_name_long">
<item quantity="one">Use at most %1$d character</item>
<item quantity="other">Use at most %1$d characters</item>
</plurals>
<string name="worktree_submit_run_in">Create and start</string>
<string name="worktree_submit_move">Create and move</string>
<string name="worktree_submitting">Creating…</string>
Expand All @@ -297,19 +303,15 @@
<string name="files_find_error">Couldn\'t search files</string>
<string name="files_find_no_match">No files match “%1$s”</string>
<string name="files_find_no_match_detail">Server search skips ignored folders.</string>
<string name="files_error_check_connection">Check the connection and try again.</string>
<string name="files_error_check_server_connection">Check the connection to the server and try again.</string>
<string name="files_no_file_title">Open a file from the tree</string>
<string name="files_no_file_message">Opened files stay as tabs</string>
<string name="files_path_copied">Path copied</string>
<string name="file_viewer_options">File options</string>
<string name="file_viewer_copy_path">Copy path</string>
<string name="file_viewer_wrap_lines">Wrap lines</string>
<string name="file_viewer_wrap_lines_on">Wrap lines, on</string>
<string name="file_viewer_wrap_lines_off">Wrap lines, off</string>
<string name="file_viewer_opening">Opening file</string>
<string name="file_viewer_loading">Loading file</string>
<string name="file_viewer_opening_image">Opening image</string>
<string name="file_viewer_loading_image">Loading image</string>
<string name="file_viewer_rendering_preview">Rendering preview</string>
<string name="file_viewer_image_preview">Image preview</string>
Expand Down Expand Up @@ -354,7 +356,6 @@
<string name="terminal_connect_failed_title">Connect failed</string>
<string name="terminal_connect_failed_message">Could not start a shell for this project.</string>
<string name="terminal_exited">Shell ended</string>
<string name="terminal_error_fallback">The terminal didn\'t open.</string>
<string name="terminal_retry">Retry</string>
<string name="terminal_key_ctrl_c">Ctrl-C</string>
<string name="terminal_key_esc">Esc</string>
Expand Down Expand Up @@ -387,10 +388,8 @@
<string name="session_chat_fork_dialog_error_failed">Couldn\'t fork session.</string>
<string name="session_chat_fork_result_title">Session forked</string>
<string name="session_chat_fork_result_message_ready">“%1$s” is ready.</string>
<string name="session_chat_fork_result_message_forked_as">Forked as “%1$s”.</string>
<string name="session_chat_fork_result_open">Open</string>
<string name="session_chat_fork_result_stay_here">Stay here</string>
<string name="session_chat_fork_result_stay">Stay</string>
<string name="session_chat_attachment_source_title">Add attachment</string>
<string name="session_chat_attachment_source_photos">Photos</string>
<string name="session_chat_attachment_source_files">Files</string>
Expand Down Expand Up @@ -461,12 +460,14 @@
<string name="session_chat_activity_action_retry">Retry</string>
<string name="session_chat_activity_action_open">Open</string>
<string name="session_chat_activity_action_open_up_next">Open Up next</string>
<string name="session_chat_activity_collapsed_show_activity">%1$s. Show activity</string>
<string name="session_chat_activity_collapsed_hide_activity">%1$s. Hide activity</string>
<string name="session_chat_activity_collapsed_count_show_activity">%1$s, %2$d activities. Show activity</string>
<string name="session_chat_activity_collapsed_count_hide_activity">%1$s, %2$d activities. Hide activity</string>
<string name="session_chat_activity_collapsed_show_count">Show %1$d activities. %2$s</string>
<string name="session_chat_activity_collapsed_hide_count">Hide %1$d activities</string>
<plurals name="session_chat_activity_collapsed_show_count">
<item quantity="one">Show %1$d activity</item>
<item quantity="other">Show %1$d activities</item>
</plurals>
<plurals name="session_chat_activity_collapsed_hide_count">
<item quantity="one">Hide %1$d activity</item>
<item quantity="other">Hide %1$d activities</item>
</plurals>
<string name="session_chat_activity_show_more">Show %1$d more</string>
<string name="session_chat_activity_hide_more">Hide %1$d more</string>
<string name="session_chat_navigation_scroll_to_end">Scroll to end</string>
Expand Down Expand Up @@ -822,15 +823,15 @@
<!-- Process exit code of a tool command. -->
<string name="session_chat_sheet_tool_result_exit_code">exit %1$d</string>
<plurals name="session_chat_sheet_tool_result_matches">
<item quantity="one">%1$d matches</item>
<item quantity="one">%1$d match</item>
<item quantity="other">%1$d matches</item>
</plurals>
<plurals name="session_chat_sheet_tool_result_files">
<item quantity="one">%1$d files</item>
<item quantity="one">%1$d file</item>
<item quantity="other">%1$d files</item>
</plurals>
<plurals name="session_chat_sheet_tool_result_lines">
<item quantity="one">%1$d lines</item>
<item quantity="one">%1$d line</item>
<item quantity="other">%1$d lines</item>
</plurals>
<!-- Android accessibility label. %1$s is a pull request URL. -->
Expand Down Expand Up @@ -961,8 +962,8 @@
<string name="settings_clear_session_cache_dialog_message">Removes cached sessions and messages. Your connection and credentials stay.</string>
<string name="settings_clear">Clear</string>
<string name="settings_app_lock_title">App Lock</string>
<string name="settings_app_lock_subtitle_available">Require your fingerprint, face or device PIN when the app returns from the background</string>
<string name="settings_app_lock_subtitle_unavailable">Set a screen lock on this device to use App Lock</string>
<string name="settings_app_lock_subtitle_available">Require your face, fingerprint or device passcode when the app returns from the background</string>
<string name="settings_app_lock_subtitle_unavailable">Set a device passcode to use App Lock</string>
<string name="settings_privacy_policy_title">Privacy Policy</string>
<string name="settings_privacy_policy_subtitle">How the apps handle data</string>
<string name="settings_analytics_title">Analytics &amp; crash reports</string>
Expand All @@ -981,13 +982,13 @@
<string name="diagnostics_loading">Loading diagnostic logs</string>
<string name="diagnostics_entries_title">Entries</string>
<plurals name="diagnostics_entries_count">
<item quantity="one">%1$d redacted lines in the kept window</item>
<item quantity="one">%1$d redacted line in the kept window</item>
<item quantity="other">%1$d redacted lines in the kept window</item>
</plurals>
<string name="diagnostics_entries_empty">No entries in the kept window yet</string>
<string name="diagnostics_kept_title">Kept</string>
<plurals name="diagnostics_last_minutes">
<item quantity="one">Last %1$d minutes</item>
<item quantity="one">Last %1$d minute</item>
<item quantity="other">Last %1$d minutes</item>
</plurals>
<string name="diagnostics_export_title">Export</string>
Expand Down Expand Up @@ -1053,8 +1054,8 @@
<string name="feedback_done">Done</string>
<string name="feedback_add_attachment">Add attachment</string>
<string name="feedback_dictate">Dictate</string>
<string name="feedback_send">Send</string>
<string name="feedback_sending">Sending</string>
<string name="feedback_send">Send report</string>
<string name="feedback_sending">Sending report</string>
<string name="feedback_attachment_screenshot">Screenshot</string>
<plurals name="feedback_attachment_screenshot_hidden">
<item quantity="one">Screenshot · %1$d hidden</item>
Expand All @@ -1076,20 +1077,18 @@
<item quantity="other">%1$d min</item>
</plurals>
<string name="feedback_hide_parts_instructions">Tap an area to cover it.</string>
<string name="feedback_hide_parts_image_label">Screenshot. Tap an area to cover it.</string>
<plurals name="feedback_hide_parts_image_hidden">
<item quantity="one">Screenshot, %1$d areas hidden</item>
<item quantity="one">Screenshot, %1$d area hidden</item>
<item quantity="other">Screenshot, %1$d areas hidden</item>
</plurals>
<plurals name="feedback_log_preview_summary">
<item quantity="one">Last %1$d minutes · gzipped on upload. Redacted on this phone.</item>
<item quantity="one">Last %1$d minute · gzipped on upload. Redacted on this phone.</item>
<item quantity="other">Last %1$d minutes · gzipped on upload. Redacted on this phone.</item>
</plurals>
<string name="feedback_log_preview_loading">Loading…</string>
<string name="feedback_log_preview_empty">No log lines in this window.</string>
<string name="feedback_log_preview_empty_title">No log lines</string>
<plurals name="feedback_log_preview_empty_message">
<item quantity="one">Nothing was logged in the last %1$d minutes.</item>
<item quantity="one">Nothing was logged in the last %1$d minute.</item>
<item quantity="other">Nothing was logged in the last %1$d minutes.</item>
</plurals>
<string name="feedback_sent_title">Thanks — report sent</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -397,13 +397,13 @@ class SessionChatPillSlotsTest {
assertEquals("2 side questions failed. Retry", SessionChatActivityPillCopy.accessibilityLabel(failedTwice).english())
assertEquals("1 queued prompt. Open Up next", SessionChatActivityPillCopy.accessibilityLabel(queuedOne).english())
assertEquals(
"Request failed, 3 activities. Hide activity",
"Request failed. Hide 3 activities",
SessionChatActivityPillCopy
.collapsedAccessibilityLabel(SessionChatActivityItem.RequestFailed("m1", "m1:failure"), count = 3, stackOpen = true)
.english(),
)
assertEquals(
"Review permission request. Show activity",
"Review permission request. Show 1 activity",
SessionChatActivityPillCopy.collapsedAccessibilityLabel(SessionChatActivityItem.ReviewPermission, count = 1, stackOpen = false).english(),
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package dev.opencode.mobile.ui.sessionchat

import dev.opencode.mobile.ui.text.english
import org.junit.Assert.assertEquals
import org.junit.Test

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,14 @@ class SettingsTextTest {
assertEquals("2 hours", recentWindowHoursLabel(1).english())
assertEquals("1 hour", UiText.plural(R.plurals.settings_recent_window_hours, 1).english())
}

@Test
fun diagnosticsCounts_useSingularForOne() {
assertEquals("Last 1 minute", UiText.plural(R.plurals.diagnostics_last_minutes, 1).english())
assertEquals("Last 15 minutes", UiText.plural(R.plurals.diagnostics_last_minutes, 15).english())
assertEquals(
"1 redacted line in the kept window",
UiText.plural(R.plurals.diagnostics_entries_count, 1).english(),
)
}
}
Loading