From 0dada9bf47242057d292a483b59c81f78688bd71 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 3 Oct 2026 17:13:20 +0000 Subject: [PATCH] fix(import): accessible, right-to-left safe Import screen after the visual review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - The folder path is validated only while Folder is the destination (no red box under Archive) and shows faint text when unused; typing one chooses Folder, as "…" does; a path change replans only for Folder. - Session times are no longer cut: the Session column sizes to its content. - Show plan lists file names under a two-line session heading (folder below), with full paths in tooltips; header and cells line up (scroll bar reserved). - Failures say what happened in one localized sentence (source gone, disk full, access, server, other), wrap up to three lines, keep the raw text in the tooltip, and offer Retry only. - The status sentence comes with one action (Folder…, Refresh devices, Library, Choose folder, Server, Retry). - The form is locked once an import finished ("New import" plans again); the plan header drops the estimate and free space then. - A card stays "new" until it has a nickname. - Device entries show keyboard focus and a disabled state with its reason; row actions (Merge, Split here) are revealed on the row and named per row; composite buttons carry accessible names; tab order follows the layout; rows are 36 px. - Live regions announce planning status, copy progress, the result and the failure; progress bars are labelled. - Right-to-left: paths, templates, name previews and numbers stay left to right (numbers right-aligned), the session range uses its own arrow, and paths or serials inside sentences are embedded left to right. - The 56 px number boxes fit four digits despite the kit's double padding. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC --- i18n/en/Import.resx | 11 + i18n/it/Import.it.resx | 10 + src/Titano.App/Import/BidiText.cs | 17 + src/Titano.App/Import/CardActions.cs | 2 +- src/Titano.App/Import/CardPool.cs | 19 +- src/Titano.App/Import/ImportChoices.cs | 2 +- src/Titano.App/Import/ImportFailures.cs | 36 ++ src/Titano.App/Import/ImportPlans.cs | 34 +- .../Import/ImportResultViewModel.cs | 2 +- src/Titano.App/Import/ImportScenes.cs | 7 +- .../Import/ImportSessionRowViewModel.cs | 6 + src/Titano.App/Sections/ImportView.xaml | 310 +++++++++++++----- src/Titano.App/Sections/ImportView.xaml.cs | 69 +++- src/Titano.App/Sections/ImportViewModel.cs | 177 ++++++++-- 14 files changed, 568 insertions(+), 134 deletions(-) create mode 100644 src/Titano.App/Import/BidiText.cs create mode 100644 src/Titano.App/Import/ImportFailures.cs diff --git a/i18n/en/Import.resx b/i18n/en/Import.resx index 1070093f..4858fc46 100644 --- a/i18n/en/Import.resx +++ b/i18n/en/Import.resx @@ -65,6 +65,7 @@ {0:N0} files Session {0} · {1}long Split here + Split at {0} Plan Cannot read {0}: {1}long {0} · not insertedlong @@ -103,7 +104,12 @@ no longer on the card {0:N0} verified on the card {0:N0} verified on the card + Titano may not write to the destination.long + The destination is full.long + The import stopped before the end.long Retry + The server did not accept the photos.long + {0} is no longer available.long Import into folder Import from folder After import @@ -171,20 +177,25 @@ Size {0} · {1}invariant Merge + Merge session {0} New · {0}long new Server {0} · {1} → {2}invariant + {0} · {1} ← {2}invariant + Sequence of session {0} Import {0:N0} photo Import {0:N0} photos Import Import cancelled Choose a card or a folder.long Insert this card to plan its import.long + The import could not be planned.long The card could not be read: {0}long Reading the card… {0:N0} photo read {0:N0} photos read + {0} could not be read.long Importing with its saved settingslong Cancel {0} changed since it was checkedlong diff --git a/i18n/it/Import.it.resx b/i18n/it/Import.it.resx index ca5e1d47..332a1f1d 100644 --- a/i18n/it/Import.it.resx +++ b/i18n/it/Import.it.resx @@ -65,6 +65,7 @@ {0:N0} file Sessione {0} · {1} Dividi qui + Dividi a partire da {0} Piano Impossibile leggere {0}: {1} {0} · non inserita @@ -101,7 +102,12 @@ non più sulla scheda {0:N0} verificata sulla scheda {0:N0} verificate sulla scheda + Titano non può scrivere nella destinazione. + La destinazione è piena. + L'importazione si è interrotta prima della fine. Riprova + Il server non ha accettato le foto. + {0} non è più disponibile. Importa nella cartella Importa dalla cartella Dopo l'importazione @@ -166,19 +172,23 @@ Sessione Dimensione Unisci + Unisci la sessione {0} Nuova · {0} nuova Server + Sequenza della sessione {0} Importa {0:N0} foto Importa {0:N0} foto Importa Importazione annullata Scegli una scheda o una cartella. Inserisci questa scheda per pianificarne l'importazione. + Impossibile preparare il piano di importazione. Impossibile leggere la scheda: {0} Lettura della scheda… {0:N0} foto letta {0:N0} foto lette + Impossibile leggere {0}. Importazione con le impostazioni salvate Annulla {0} è cambiata dopo il controllo diff --git a/src/Titano.App/Import/BidiText.cs b/src/Titano.App/Import/BidiText.cs new file mode 100644 index 00000000..94a8a8fd --- /dev/null +++ b/src/Titano.App/Import/BidiText.cs @@ -0,0 +1,17 @@ +using Titano.Core.Localization; + +namespace Titano.App.Import; + +/// +/// Paths, volume serials and other left-to-right fragments inside a sentence of a right-to-left language (BRIEF §16): +/// without an embedding, a path that starts with a digit or ends in a separator is reordered and reads garbled. +/// +public static class BidiText +{ + private const char LeftToRightEmbedding = '‪'; + private const char PopDirectionalFormatting = '‬'; + + /// kept left to right in a right-to-left UI language; unchanged otherwise. + public static string Ltr(string text) => + Loc.IsRightToLeft && text.Length > 0 ? LeftToRightEmbedding + text + PopDirectionalFormatting : text; +} diff --git a/src/Titano.App/Import/CardActions.cs b/src/Titano.App/Import/CardActions.cs index 2fecded4..c913763a 100644 --- a/src/Titano.App/Import/CardActions.cs +++ b/src/Titano.App/Import/CardActions.cs @@ -70,7 +70,7 @@ public sealed record CardActions(ImportDestinationKind Destination, bool IsKnown /// Why each kept photo stays on the card ("IMG_0042.CR2 · the archive copy no longer matches"). public IReadOnlyList KeptReasons => - Erase is null ? [] : [.. Erase.Items.Where(i => i.Verdict != EraseVerdict.Delete).Select(i => Loc.L("Import.Erase.Reason", i.Candidate.SourcePath, Verdict(i.Verdict)))]; + Erase is null ? [] : [.. Erase.Items.Where(i => i.Verdict != EraseVerdict.Delete).Select(i => Loc.L("Import.Erase.Reason", BidiText.Ltr(i.Candidate.SourcePath), Verdict(i.Verdict)))]; public static string Verdict(EraseVerdict verdict) => Loc.L("Import.Erase.Verdict." + verdict); } diff --git a/src/Titano.App/Import/CardPool.cs b/src/Titano.App/Import/CardPool.cs index 75e4a611..8acd0b65 100644 --- a/src/Titano.App/Import/CardPool.cs +++ b/src/Titano.App/Import/CardPool.cs @@ -55,7 +55,11 @@ public sealed record ImportSource(string Key, SourceKind Kind, CardDevice? Devic { public bool IsInserted => Device is not null || FolderPath is not null; - public bool IsKnown => Card is not null; + /// + /// The card has a nickname (BRIEF §12.4: known cards show their nickname, unknown ones ask for it). A card is + /// remembered as soon as its first plan reads it, but stays new until it is named. + /// + public bool IsKnown => Card is { Nickname.Length: > 0 }; /// Where the photos are read from; null for a remembered card that is not inserted. public string? Root => Device?.Root ?? FolderPath; @@ -63,12 +67,13 @@ public sealed record ImportSource(string Key, SourceKind Kind, CardDevice? Devic /// "EOS R5 · card A", the volume label, or the drive. public string Title => Card?.Nickname is { Length: > 0 } nickname ? nickname : Device is { Label.Length: > 0 } labelled ? labelled.Label - : Device?.Root ?? FolderPath ?? Card?.Label ?? string.Empty; + : (Device?.Root ?? FolderPath) is { } path ? BidiText.Ltr(path) + : Card?.Label ?? string.Empty; /// "128 GB · 96.2 GB used · 4,812 photos", "no DCIM · 1.8 TB free", "Canon EOS R5 · not inserted". public string Subtitle => Kind switch { - SourceKind.Folder => FolderPath ?? string.Empty, + SourceKind.Folder => BidiText.Ltr(FolderPath ?? string.Empty), SourceKind.Drive => Loc.L("Import.Device.NoDcim", Formatting.Bytes(Device!.FreeBytes)), _ when Device is not null && Contents is { } contents => Loc.L("Import.Device.CardPhotos", Formatting.Bytes(Device.TotalBytes), Formatting.Bytes(Device.UsedBytes), Loc.Plural("Shell.Status.Photos", contents.Photos)), @@ -86,6 +91,12 @@ public sealed record ImportSource(string Key, SourceKind Kind, CardDevice? Devic _ => "Import.Device.State.New", }); + /// + /// "Known card · 128 GB · 96.2 GB used · 4,812 photos": the entry's tooltip, with what its subtitle may have to cut + /// (a drive's subtitle already says it has no DCIM). + /// + public string ToolTip => Kind == SourceKind.Drive ? Subtitle : string.Join(" · ", new[] { StateText, Subtitle }.Where(t => t.Length > 0)); + /// "Canon EOS R5 · 4,812 photos": the insertion toast's line; "not yet known to Titano" for a new card. public string ToastText { @@ -108,7 +119,7 @@ public sealed record ImportSource(string Key, SourceKind Kind, CardDevice? Devic var capacity = Device?.TotalBytes ?? Card?.Capacity ?? 0; if (capacity > 0) parts.Add(Formatting.Bytes(capacity)); var serial = Device?.SerialNumber ?? Card?.VolumeSerial; - if (serial is { } s && Kind != SourceKind.Folder) parts.Add(Loc.L("Import.Device.Serial", SerialText(s))); + if (serial is { } s && Kind != SourceKind.Folder) parts.Add(Loc.L("Import.Device.Serial", BidiText.Ltr(SerialText(s)))); if (CameraText(Card) is { Length: > 0 } camera) parts.Add(Card?.CameraSerial is { Length: > 0 } body ? Loc.L("Import.Device.Body", camera, body) : camera); return string.Join(" · ", parts); } diff --git a/src/Titano.App/Import/ImportChoices.cs b/src/Titano.App/Import/ImportChoices.cs index c34c7345..4edfe61e 100644 --- a/src/Titano.App/Import/ImportChoices.cs +++ b/src/Titano.App/Import/ImportChoices.cs @@ -86,7 +86,7 @@ public sealed record ImportChoices /// True when a choice changes which photos form which session or where they go, so the card must be planned again. public bool NeedsNewPlan(ImportChoices previous) => previous.Destination != Destination - || !string.Equals(previous.FolderPath, FolderPath, StringComparison.OrdinalIgnoreCase) + || (Destination == ImportDestinationKind.Folder && !string.Equals(previous.FolderPath, FolderPath, StringComparison.OrdinalIgnoreCase)) || previous.IncludeSubfolders != IncludeSubfolders || previous.SplitSessions != SplitSessions || (SplitSessions && previous.GapMinutes != GapMinutes) diff --git a/src/Titano.App/Import/ImportFailures.cs b/src/Titano.App/Import/ImportFailures.cs new file mode 100644 index 00000000..2d239d5f --- /dev/null +++ b/src/Titano.App/Import/ImportFailures.cs @@ -0,0 +1,36 @@ +using System.IO; +using System.Net.Http; +using Titano.Core.Import; +using Titano.Core.Localization; +using Titano.Protocol.Client; + +namespace Titano.App.Import; + +/// +/// What the Import screen says when an import or its plan stops (BRIEF §0.2 rule 6: one sentence saying what +/// happened): a localized sentence chosen by cause. The exception's own text, which may hold full paths or several +/// sentences, goes to the tooltip and the log only. +/// +public static class ImportFailures +{ + private const int DiskFull = unchecked((int)0x80070070); + private const int HandleDiskFull = unchecked((int)0x80070027); + + /// The card or folder as the Devices list names it. + public static string Import(Exception ex, string source) => ex switch + { + ImportSourceUnavailableException => Loc.L("Import.Failed.SourceGone", source), + IOException { HResult: DiskFull or HandleDiskFull } => Loc.L("Import.Failed.Full"), + UnauthorizedAccessException => Loc.L("Import.Failed.Access"), + TitanoApiException or HttpRequestException or UntrustedCertificateException => Loc.L("Import.Failed.Server"), + _ => Loc.L("Import.Failed.Other"), + }; + + /// Why the card or folder could not be planned. + public static string Plan(Exception ex, string source) => ex switch + { + DirectoryNotFoundException or DriveNotFoundException or ImportSourceUnavailableException => Loc.L("Import.Failed.SourceGone", source), + IOException or UnauthorizedAccessException => Loc.L("Import.Status.Unreadable", source), + _ => Loc.L("Import.Status.PlanError"), + }; +} diff --git a/src/Titano.App/Import/ImportPlans.cs b/src/Titano.App/Import/ImportPlans.cs index 06dc0eb8..a8c94da7 100644 --- a/src/Titano.App/Import/ImportPlans.cs +++ b/src/Titano.App/Import/ImportPlans.cs @@ -13,11 +13,13 @@ public sealed record PlanTotals(int Sessions, int Photos, int CopyCount, long Co public bool HasEnoughSpace => FreeAfter is not < 0; /// "3 sessions · 4,812 photos · 96.2 GB · about 12 min". - public string Text => string.Join(" · ", + public string Text => SummaryText + " · " + Loc.L("Import.Plan.About", Formatting.Duration(Estimate)); + + /// "3 sessions · 4,812 photos · 96.2 GB": the plan without its time estimate. + public string SummaryText => string.Join(" · ", Loc.Plural("Import.Plan.Sessions", Sessions), Loc.Plural("Shell.Status.Photos", Photos), - Formatting.Bytes(CopyBytes), - Loc.L("Import.Plan.About", Formatting.Duration(Estimate))); + Formatting.Bytes(CopyBytes)); /// "0 duplicates" (already in the archive by hash). public string DuplicatesText => Loc.Plural("Import.Plan.Duplicates", Duplicates); @@ -51,9 +53,21 @@ public enum PlanRowKind File, } -/// A line of "Show plan": a session heading or one file and its destination. +/// A line of "Show plan": a session heading and its folder, or one file (card path) and its destination path. /// A file that is not the first of its session: a new session can start there. -public sealed record PlanDetailRow(PlanRowKind Kind, string Source, string Destination, string ActionText, string SizeText, bool IsSkipped, bool CanSplit); +public sealed record PlanDetailRow(PlanRowKind Kind, string Source, string Destination, string ActionText, string SizeText, bool IsSkipped, bool CanSplit) +{ + /// A file's name on the card (its session heading shows the rest); the heading itself for a session. + public string SourceText => Kind == PlanRowKind.File ? NameOf(Source) : Source; + + /// The file's new name (its session shows the folder); the folder for a session. + public string DestinationText => Kind == PlanRowKind.File ? NameOf(Destination) : Destination; + + /// "Split at IMG_0042.JPG": the row's split button as screen readers announce it. + public string SplitName => Loc.L("Import.Details.SplitName", SourceText); + + private static string NameOf(string path) => path[(path.LastIndexOf('/') + 1)..]; +} /// Everything "Show plan" lists: every file to its destination, the totals and the conflicts. public sealed record PlanDetails(IReadOnlyList Rows, string TotalsText, IReadOnlyList Conflicts); @@ -154,7 +168,7 @@ public static class ImportPlans } var totals = Totals(plan, verify); var conflicts = new List(); - foreach (var problem in plan.Problems) conflicts.Add(Loc.L("Import.Details.Unreadable", problem.RelativePath, problem.Message)); + foreach (var problem in plan.Problems) conflicts.Add(Loc.L("Import.Details.Unreadable", BidiText.Ltr(problem.RelativePath), problem.Message)); if (totals.Duplicates > 0) conflicts.Add(totals.DuplicatesText); if (!totals.HasEnoughSpace) conflicts.Add(totals.SpaceText); var text = string.Join(" · ", new[] @@ -209,9 +223,13 @@ public static class ImportPlans _ => Loc.L("Import.Action.Copy"), }; - /// "28/09/2026 · 18:02 → 20:04". + /// + /// "28/09/2026 · 18:02 → 20:04". Bidi never mirrors an arrow, so a right-to-left language reads it from its own + /// resource with the arrow pointing from the start to the end in its reading order. + /// private static string TimeText(PlannedSession s) => - Loc.L("Import.Session.Time", Formatting.Date(s.Start), s.Start.ToString("t", Loc.Culture), s.End.ToString("t", Loc.Culture)); + Loc.L(Loc.IsRightToLeft ? "Import.Session.TimeRtl" : "Import.Session.Time", Formatting.Date(s.Start), s.Start.ToString("t", Loc.Culture), + s.End.ToString("t", Loc.Culture)); /// "3,600 · 2 s": photos and the median interval between them. private static string FramesText(PlannedSession s) diff --git a/src/Titano.App/Import/ImportResultViewModel.cs b/src/Titano.App/Import/ImportResultViewModel.cs index 0b3e1743..bea85506 100644 --- a/src/Titano.App/Import/ImportResultViewModel.cs +++ b/src/Titano.App/Import/ImportResultViewModel.cs @@ -46,7 +46,7 @@ public sealed class ImportResultViewModel : LocalizedViewModel _device = device; Outcome = outcome; _actions = new CardActions(choices.Destination, card is not null, device is not null, device?.IsRemovable == true, outcome, null, null); - Failures = [.. outcome.Failures.Take(ListedFailures).Select(f => Loc.L("Import.Result.Failure", f.SourcePath, f.Message))]; + Failures = [.. outcome.Failures.Take(ListedFailures).Select(f => Loc.L("Import.Result.Failure", BidiText.Ltr(f.SourcePath), f.Message))]; CheckCommand = new AsyncRelayCommand(CheckAsync, () => _actions.CanCheck && !_isBusy); DeleteCommand = new AsyncRelayCommand(DeleteAsync, () => _actions.CanDelete && !_isBusy); FormatCommand = new AsyncRelayCommand(FormatAsync, () => _actions.CanFormat && !_isBusy); diff --git a/src/Titano.App/Import/ImportScenes.cs b/src/Titano.App/Import/ImportScenes.cs index ece6b806..8c4fdc19 100644 --- a/src/Titano.App/Import/ImportScenes.cs +++ b/src/Titano.App/Import/ImportScenes.cs @@ -1,7 +1,6 @@ using Titano.App.Sections; using Titano.App.Shell; using Titano.Core.Import; -using Titano.Core.Localization; using Titano.Data; namespace Titano.App.Import; @@ -28,6 +27,8 @@ public static class ImportScenes switch (state) { case "inserted": + // Each theme pass starts as the first: the new card of "newcard" is not remembered yet. + await ForgetAsync(shell, SampleCards.NewCard(data).Identity); await ShowPlanAsync(import, SampleCards.Card(data)); await import.CardInsertedAsync(SampleCards.Card(data)); break; @@ -43,7 +44,7 @@ public static class ImportScenes import.ShowRunning(new ImportProgress(31, plan.FileCount, plan.CopyBytes * 31 / plan.FileCount, plan.CopyBytes, 31, 0, 0, null)); break; case "failed": - import.ShowFailed(Loc.L("Archive.Error.SourceGone", SampleCards.Card(data).Root)); + import.ShowFailed(new ImportSourceUnavailableException(SampleCards.Card(data).Root)); break; case "done": await ShowPlanAsync(import, SampleCards.Card(data)); @@ -83,7 +84,7 @@ public static class ImportScenes private static ImportPlan Plan(ImportViewModel import) => import.Plan ?? throw new InvalidOperationException("The sample card has no plan."); - /// The new card stays new in every theme: an earlier state registered it on its first plan. + /// The new card stays new in every theme: its first plan in an earlier pass registered it. private static async Task ForgetAsync(ShellViewModel shell, string identity) { if (shell.Services.Database is not { } db || await db.MediaCards.FindByIdentityAsync(identity) is not { } known) return; diff --git a/src/Titano.App/Import/ImportSessionRowViewModel.cs b/src/Titano.App/Import/ImportSessionRowViewModel.cs index 15c6dd08..c80da076 100644 --- a/src/Titano.App/Import/ImportSessionRowViewModel.cs +++ b/src/Titano.App/Import/ImportSessionRowViewModel.cs @@ -51,4 +51,10 @@ public sealed class ImportSessionRowViewModel : ObservableObject public string MergeToolTip => !IsEditable ? Loc.L("Import.Blocked.Copying") : Row.MergesInto is { } target ? Loc.L("Tooltips.Import.Merge", target) : string.Empty; + + /// "Sequence of session 2": the title field as screen readers announce it, one per row. + public string TitleName => Loc.L("Import.Session.TitleName", Row.Number); + + /// "Merge session 2". + public string MergeName => Loc.L("Import.Session.MergeName", Row.Number); } diff --git a/src/Titano.App/Sections/ImportView.xaml b/src/Titano.App/Sections/ImportView.xaml index 8634835a..da05b041 100644 --- a/src/Titano.App/Sections/ImportView.xaml +++ b/src/Titano.App/Sections/ImportView.xaml @@ -9,14 +9,28 @@ - + + + + @@ -68,15 +90,82 @@ + + + + + - + + + + + + + + + + + + + + + + +