From b2c78d6b763aba19840803b4d4963cd9d305260e Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 17 Jul 2026 17:46:33 +0000 Subject: [PATCH] refactor(commons): extract GitDiffView renderer to commons MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Third batch of the note-ui-commons extraction. GitDiffView is a pure presentation composable — it takes a quartz ParsedPatch + a Modifier, with no AccountViewModel/INav/Note — and its syntax-highlighting helper (CodeHighlighter) already lives in commons, so it moves wholesale. - commons/ui/note/GitDiffView.kt: the GitHub-style file-by-file diff view (stat summary, per-file collapsible cards, +/- line coloring, intraline emphasis, syntax highlighting). Labels resolve via commons Res. - Migrated git_diff_binary (string) and git_diff_files_changed (plural, all quantity forms across 11 locales) from amethyst/res into commons/composeResources; deleted the amethyst copies. This exercises the now-wired commons Crowdin pipeline for a plural resource. - Callers (Git.kt, GitPullRequestChanges.kt, GitCommitLog.kt) re-point the import to commons; the call sites are unchanged. Verified: :commons:compileKotlinJvm (plural accessor generation) and :amethyst:compileFdroidDebugKotlin both pass; every touched strings.xml is well-formed. Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_01Gmrt3jwYPDJ38MJGJ6GaNr --- .../vitorpamplona/amethyst/ui/note/types/Git.kt | 1 + .../ui/note/types/GitPullRequestChanges.kt | 1 + .../screen/loggedIn/gitRepo/code/GitCommitLog.kt | 2 +- amethyst/src/main/res/values-cs/strings.xml | 7 ------- amethyst/src/main/res/values-de-rDE/strings.xml | 5 ----- amethyst/src/main/res/values-hi-rIN/strings.xml | 5 ----- amethyst/src/main/res/values-hu-rHU/strings.xml | 5 ----- amethyst/src/main/res/values-nl-rNL/strings.xml | 5 ----- amethyst/src/main/res/values-pl-rPL/strings.xml | 7 ------- amethyst/src/main/res/values-pt-rBR/strings.xml | 5 ----- amethyst/src/main/res/values-sl-rSI/strings.xml | 7 ------- amethyst/src/main/res/values-sv-rSE/strings.xml | 5 ----- amethyst/src/main/res/values-zh-rCN/strings.xml | 4 ---- amethyst/src/main/res/values/strings.xml | 5 ----- .../composeResources/values-cs/strings.xml | 7 +++++++ .../composeResources/values-de-rDE/strings.xml | 5 +++++ .../composeResources/values-hi-rIN/strings.xml | 5 +++++ .../composeResources/values-hu-rHU/strings.xml | 5 +++++ .../composeResources/values-nl-rNL/strings.xml | 5 +++++ .../composeResources/values-pl-rPL/strings.xml | 7 +++++++ .../composeResources/values-pt-rBR/strings.xml | 5 +++++ .../composeResources/values-sl-rSI/strings.xml | 7 +++++++ .../composeResources/values-sv-rSE/strings.xml | 5 +++++ .../composeResources/values-zh-rCN/strings.xml | 4 ++++ .../commonMain/composeResources/values/strings.xml | 5 +++++ .../amethyst/commons/ui/note}/GitDiffView.kt | 14 ++++++++------ 26 files changed, 71 insertions(+), 67 deletions(-) rename {amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types => commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/ui/note}/GitDiffView.kt (96%) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/Git.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/Git.kt index be5287f719..a8d2125162 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/Git.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/Git.kt @@ -60,6 +60,7 @@ import com.vitorpamplona.amethyst.commons.model.toImmutableListOfLists import com.vitorpamplona.amethyst.commons.nip34Git.GitBrowseState import com.vitorpamplona.amethyst.commons.nip34Git.GitRepoSnapshotCache import com.vitorpamplona.amethyst.commons.nip34Git.GitRepositoryBrowserViewModel +import com.vitorpamplona.amethyst.commons.ui.note.GitDiffView import com.vitorpamplona.amethyst.commons.ui.note.StatusKind import com.vitorpamplona.amethyst.model.AddressableNote import com.vitorpamplona.amethyst.model.GitPullRequestUpdateIndex diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/GitPullRequestChanges.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/GitPullRequestChanges.kt index 71148c1c5d..ee8c9f0ff4 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/GitPullRequestChanges.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/GitPullRequestChanges.kt @@ -42,6 +42,7 @@ import androidx.compose.ui.unit.dp import com.vitorpamplona.amethyst.R import com.vitorpamplona.amethyst.commons.icons.symbols.Icon import com.vitorpamplona.amethyst.commons.icons.symbols.MaterialSymbols +import com.vitorpamplona.amethyst.commons.ui.note.GitDiffView import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.amethyst.ui.stringRes import com.vitorpamplona.quartz.nip34Git.git.GitHttpClient diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/gitRepo/code/GitCommitLog.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/gitRepo/code/GitCommitLog.kt index f818bb51c1..3599ec8fb7 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/gitRepo/code/GitCommitLog.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/gitRepo/code/GitCommitLog.kt @@ -58,8 +58,8 @@ import com.vitorpamplona.amethyst.R import com.vitorpamplona.amethyst.commons.icons.symbols.Icon import com.vitorpamplona.amethyst.commons.icons.symbols.MaterialSymbols import com.vitorpamplona.amethyst.commons.nip34Git.GitRepositoryBrowserViewModel +import com.vitorpamplona.amethyst.commons.ui.note.GitDiffView import com.vitorpamplona.amethyst.ui.note.ArrowBackIcon -import com.vitorpamplona.amethyst.ui.note.types.GitDiffView import com.vitorpamplona.amethyst.ui.stringRes import com.vitorpamplona.quartz.nip34Git.git.GitCommit import com.vitorpamplona.quartz.nip34Git.git.GitRepoSnapshot diff --git a/amethyst/src/main/res/values-cs/strings.xml b/amethyst/src/main/res/values-cs/strings.xml index 14fd3808de..fc0f84d2a5 100644 --- a/amethyst/src/main/res/values-cs/strings.xml +++ b/amethyst/src/main/res/values-cs/strings.xml @@ -3075,13 +3075,6 @@ %1$d položky %1$d položek - - %1$d soubor změněn - %1$d soubory změněny - %1$d souboru změněno - %1$d souborů změněno - - Binární soubor se nezobrazuje. Nový Nový problém Název diff --git a/amethyst/src/main/res/values-de-rDE/strings.xml b/amethyst/src/main/res/values-de-rDE/strings.xml index 1191b8d866..695227a396 100644 --- a/amethyst/src/main/res/values-de-rDE/strings.xml +++ b/amethyst/src/main/res/values-de-rDE/strings.xml @@ -2991,11 +2991,6 @@ %1$d Element %1$d Elemente - - Datei geändert - Dateien geändert - - Binärdatei wird nicht angezeigt. Neu Neues Issue Titel diff --git a/amethyst/src/main/res/values-hi-rIN/strings.xml b/amethyst/src/main/res/values-hi-rIN/strings.xml index 00f43a46a7..c589ab37a0 100644 --- a/amethyst/src/main/res/values-hi-rIN/strings.xml +++ b/amethyst/src/main/res/values-hi-rIN/strings.xml @@ -2905,11 +2905,6 @@ %1$d वस्तु %1$d वस्तुएँ - - %1$d अभिलेख परिवर्तित - %1$d अभिलेख परिवर्तित - - अंकीय अभिलेख नहीं दर्शाया गया। नव्य नया विषय शीर्षक diff --git a/amethyst/src/main/res/values-hu-rHU/strings.xml b/amethyst/src/main/res/values-hu-rHU/strings.xml index f1b981da43..8c22bf0667 100644 --- a/amethyst/src/main/res/values-hu-rHU/strings.xml +++ b/amethyst/src/main/res/values-hu-rHU/strings.xml @@ -2877,11 +2877,6 @@ %1$d elem %1$d elem - - %1$d fájl módosult - %1$d fájl módosult - - Nem jeleníthető meg a bináris fájl tartalma. Új Új hibajegy Cím diff --git a/amethyst/src/main/res/values-nl-rNL/strings.xml b/amethyst/src/main/res/values-nl-rNL/strings.xml index 16a96b4dae..c9432c516f 100644 --- a/amethyst/src/main/res/values-nl-rNL/strings.xml +++ b/amethyst/src/main/res/values-nl-rNL/strings.xml @@ -2532,11 +2532,6 @@ %1$d item %1$d items - - %1$d bestand gewijzigd - %1$d bestanden gewijzigd - - Binair bestand niet getoond. Nieuw Nieuw issue Titel diff --git a/amethyst/src/main/res/values-pl-rPL/strings.xml b/amethyst/src/main/res/values-pl-rPL/strings.xml index 5a7354f0dd..d892336f6e 100644 --- a/amethyst/src/main/res/values-pl-rPL/strings.xml +++ b/amethyst/src/main/res/values-pl-rPL/strings.xml @@ -3076,13 +3076,6 @@ Zaplanowane posty z innych kont nie zostaną opublikowane, dopóki to konto jest %1$d elementów %1$d elementy - - Plik %1$d zmieniony - Plików %1$d zmienionych - Plików %1$d zmienionych - %1$d pliki zostały zmienione - - Plik binarny nie jest wyświetlany. Nowy Nowy problem Tytuł diff --git a/amethyst/src/main/res/values-pt-rBR/strings.xml b/amethyst/src/main/res/values-pt-rBR/strings.xml index bb1e58c636..905cbb2f4d 100644 --- a/amethyst/src/main/res/values-pt-rBR/strings.xml +++ b/amethyst/src/main/res/values-pt-rBR/strings.xml @@ -2989,11 +2989,6 @@ %1$d iten %1$d itens - - %1$d arquivo alterado - %1$d arquivos alterados - - Arquivo binário não exibido. Nova Nova issue Título diff --git a/amethyst/src/main/res/values-sl-rSI/strings.xml b/amethyst/src/main/res/values-sl-rSI/strings.xml index 1f1650424b..e50d41f3bb 100644 --- a/amethyst/src/main/res/values-sl-rSI/strings.xml +++ b/amethyst/src/main/res/values-sl-rSI/strings.xml @@ -2777,13 +2777,6 @@ Za ohranitev zasebnosti to denarnico polni in prazni prek ne-zasebnih računov, %1$d elementi %1$d elementov - - %1$d datoteka spremenjena - %1$d datoteki spremenjeni - %1$d datoteke spremenjene - %1$d datotek spremenjenih - - Binarna datoteka ni prikazana. Nov Prijavi težavo Naslov diff --git a/amethyst/src/main/res/values-sv-rSE/strings.xml b/amethyst/src/main/res/values-sv-rSE/strings.xml index f859fb4db5..a49fc3ef1d 100644 --- a/amethyst/src/main/res/values-sv-rSE/strings.xml +++ b/amethyst/src/main/res/values-sv-rSE/strings.xml @@ -2989,11 +2989,6 @@ %1$d objekt %1$d objekt - - %1$d fil ändrad - %1$d filer ändrade - - Binär fil visas inte. Ny Nytt ärende Titel diff --git a/amethyst/src/main/res/values-zh-rCN/strings.xml b/amethyst/src/main/res/values-zh-rCN/strings.xml index 700d4f96e2..6e99dc283d 100644 --- a/amethyst/src/main/res/values-zh-rCN/strings.xml +++ b/amethyst/src/main/res/values-zh-rCN/strings.xml @@ -2867,10 +2867,6 @@ %1$d 个项目 - - %1$d 个文件已更改 - - 二进制文件未显示。 新建 新工单 标题 diff --git a/amethyst/src/main/res/values/strings.xml b/amethyst/src/main/res/values/strings.xml index 3e18eeec62..c0179a8821 100644 --- a/amethyst/src/main/res/values/strings.xml +++ b/amethyst/src/main/res/values/strings.xml @@ -3311,11 +3311,6 @@ %1$d item %1$d items - - %1$d file changed - %1$d files changed - - Binary file not shown. New New issue Title diff --git a/commons/src/commonMain/composeResources/values-cs/strings.xml b/commons/src/commonMain/composeResources/values-cs/strings.xml index b690a79c15..e7f32bd1e3 100644 --- a/commons/src/commonMain/composeResources/values-cs/strings.xml +++ b/commons/src/commonMain/composeResources/values-cs/strings.xml @@ -4,4 +4,11 @@ Sloučeno Uzavřeno Koncept + Binární soubor se nezobrazuje. + + %1$d soubor změněn + %1$d soubory změněny + %1$d souboru změněno + %1$d souborů změněno + diff --git a/commons/src/commonMain/composeResources/values-de-rDE/strings.xml b/commons/src/commonMain/composeResources/values-de-rDE/strings.xml index b0cb49c7fe..743ff81945 100644 --- a/commons/src/commonMain/composeResources/values-de-rDE/strings.xml +++ b/commons/src/commonMain/composeResources/values-de-rDE/strings.xml @@ -4,4 +4,9 @@ Zusammengeführt Geschlossen Entwurf + Binärdatei wird nicht angezeigt. + + Datei geändert + Dateien geändert + diff --git a/commons/src/commonMain/composeResources/values-hi-rIN/strings.xml b/commons/src/commonMain/composeResources/values-hi-rIN/strings.xml index db6c5211be..c89acb6149 100644 --- a/commons/src/commonMain/composeResources/values-hi-rIN/strings.xml +++ b/commons/src/commonMain/composeResources/values-hi-rIN/strings.xml @@ -4,4 +4,9 @@ विलीन आवृत पाण्डुलिपि + अंकीय अभिलेख नहीं दर्शाया गया। + + %1$d अभिलेख परिवर्तित + %1$d अभिलेख परिवर्तित + diff --git a/commons/src/commonMain/composeResources/values-hu-rHU/strings.xml b/commons/src/commonMain/composeResources/values-hu-rHU/strings.xml index b11e462ab6..8c633a49fb 100644 --- a/commons/src/commonMain/composeResources/values-hu-rHU/strings.xml +++ b/commons/src/commonMain/composeResources/values-hu-rHU/strings.xml @@ -4,4 +4,9 @@ Beolvasztva Lezárva Vázlat + Nem jeleníthető meg a bináris fájl tartalma. + + %1$d fájl módosult + %1$d fájl módosult + diff --git a/commons/src/commonMain/composeResources/values-nl-rNL/strings.xml b/commons/src/commonMain/composeResources/values-nl-rNL/strings.xml index ca95a6505b..1687933c99 100644 --- a/commons/src/commonMain/composeResources/values-nl-rNL/strings.xml +++ b/commons/src/commonMain/composeResources/values-nl-rNL/strings.xml @@ -4,4 +4,9 @@ Samengevoegd Gesloten Concept + Binair bestand niet getoond. + + %1$d bestand gewijzigd + %1$d bestanden gewijzigd + diff --git a/commons/src/commonMain/composeResources/values-pl-rPL/strings.xml b/commons/src/commonMain/composeResources/values-pl-rPL/strings.xml index d1ea195c45..511f84779b 100644 --- a/commons/src/commonMain/composeResources/values-pl-rPL/strings.xml +++ b/commons/src/commonMain/composeResources/values-pl-rPL/strings.xml @@ -4,4 +4,11 @@ Połączone Zamknięte Szkic + Plik binarny nie jest wyświetlany. + + Plik %1$d zmieniony + Plików %1$d zmienionych + Plików %1$d zmienionych + %1$d pliki zostały zmienione + diff --git a/commons/src/commonMain/composeResources/values-pt-rBR/strings.xml b/commons/src/commonMain/composeResources/values-pt-rBR/strings.xml index b96ac87c78..ed010b9076 100644 --- a/commons/src/commonMain/composeResources/values-pt-rBR/strings.xml +++ b/commons/src/commonMain/composeResources/values-pt-rBR/strings.xml @@ -4,4 +4,9 @@ Mesclado Fechado Rascunho + Arquivo binário não exibido. + + %1$d arquivo alterado + %1$d arquivos alterados + diff --git a/commons/src/commonMain/composeResources/values-sl-rSI/strings.xml b/commons/src/commonMain/composeResources/values-sl-rSI/strings.xml index d20fe94c47..fd816da6d4 100644 --- a/commons/src/commonMain/composeResources/values-sl-rSI/strings.xml +++ b/commons/src/commonMain/composeResources/values-sl-rSI/strings.xml @@ -4,4 +4,11 @@ Združeno Zaključeno Osnutek + Binarna datoteka ni prikazana. + + %1$d datoteka spremenjena + %1$d datoteki spremenjeni + %1$d datoteke spremenjene + %1$d datotek spremenjenih + diff --git a/commons/src/commonMain/composeResources/values-sv-rSE/strings.xml b/commons/src/commonMain/composeResources/values-sv-rSE/strings.xml index a67d5eaf3e..a63ec0461a 100644 --- a/commons/src/commonMain/composeResources/values-sv-rSE/strings.xml +++ b/commons/src/commonMain/composeResources/values-sv-rSE/strings.xml @@ -4,4 +4,9 @@ Sammanfogad Stängd Utkast + Binär fil visas inte. + + %1$d fil ändrad + %1$d filer ändrade + diff --git a/commons/src/commonMain/composeResources/values-zh-rCN/strings.xml b/commons/src/commonMain/composeResources/values-zh-rCN/strings.xml index 99aa70ec8b..e3af404d54 100644 --- a/commons/src/commonMain/composeResources/values-zh-rCN/strings.xml +++ b/commons/src/commonMain/composeResources/values-zh-rCN/strings.xml @@ -4,4 +4,8 @@ 已合并 已关闭 草稿 + 二进制文件未显示。 + + %1$d 个文件已更改 + diff --git a/commons/src/commonMain/composeResources/values/strings.xml b/commons/src/commonMain/composeResources/values/strings.xml index 83a2053295..ad9b6f87f7 100644 --- a/commons/src/commonMain/composeResources/values/strings.xml +++ b/commons/src/commonMain/composeResources/values/strings.xml @@ -105,4 +105,9 @@ Merged Closed Draft + Binary file not shown. + + %1$d file changed + %1$d files changed + diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/GitDiffView.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/ui/note/GitDiffView.kt similarity index 96% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/GitDiffView.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/ui/note/GitDiffView.kt index e612e7bbef..2c6f426ffc 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/GitDiffView.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/ui/note/GitDiffView.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.note.types +package com.vitorpamplona.amethyst.commons.ui.note import androidx.compose.foundation.background import androidx.compose.foundation.clickable @@ -45,7 +45,6 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.graphics.Color -import androidx.compose.ui.res.pluralStringResource import androidx.compose.ui.text.AnnotatedString import androidx.compose.ui.text.SpanStyle import androidx.compose.ui.text.buildAnnotatedString @@ -56,12 +55,13 @@ import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp -import com.vitorpamplona.amethyst.R import com.vitorpamplona.amethyst.commons.icons.symbols.Icon import com.vitorpamplona.amethyst.commons.icons.symbols.MaterialSymbol import com.vitorpamplona.amethyst.commons.icons.symbols.MaterialSymbols import com.vitorpamplona.amethyst.commons.nip34Git.ui.CodeHighlighter -import com.vitorpamplona.amethyst.ui.stringRes +import com.vitorpamplona.amethyst.commons.resources.Res +import com.vitorpamplona.amethyst.commons.resources.git_diff_binary +import com.vitorpamplona.amethyst.commons.resources.git_diff_files_changed import com.vitorpamplona.quartz.nip34Git.patch.CharSpan import com.vitorpamplona.quartz.nip34Git.patch.GitDiffFile import com.vitorpamplona.quartz.nip34Git.patch.GitDiffLine @@ -70,6 +70,8 @@ import com.vitorpamplona.quartz.nip34Git.patch.GitFileChange import com.vitorpamplona.quartz.nip34Git.patch.IntralineDiff import com.vitorpamplona.quartz.nip34Git.patch.ParsedPatch import dev.snipme.highlights.model.SyntaxLanguage +import org.jetbrains.compose.resources.pluralStringResource +import org.jetbrains.compose.resources.stringResource private val AddColor = Color(0xFF1F883D) private val DeleteColor = Color(0xFFCF222E) @@ -110,7 +112,7 @@ private fun DiffStatSummary(parsed: ParsedPatch) { ) { val fileCount = parsed.files.size Text( - text = pluralStringResource(R.plurals.git_diff_files_changed, fileCount, fileCount), + text = pluralStringResource(Res.plurals.git_diff_files_changed, fileCount, fileCount), style = MaterialTheme.typography.labelMedium, fontWeight = FontWeight.Medium, color = MaterialTheme.colorScheme.onSurface, @@ -171,7 +173,7 @@ private fun DiffFileCard( if (expanded) { if (file.isBinary) { Text( - text = stringRes(R.string.git_diff_binary), + text = stringResource(Res.string.git_diff_binary), style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.onSurfaceVariant, modifier = Modifier.padding(12.dp),