fix(app): announce job and transfer states, not progress ticks; smoke tests for the screens
- Jobs and sync rows announce a new state with their job or sequence; the update check announces each state, not each download percent. Live regions stay quiet when a recycled row shows another item or a language switch relabels them. - The first-run dialog keeps its chosen card as the window's focused element, so focus starts inside it even before the window is active. - Known-server addresses read left to right in the menu. - Smoke tests: row names and states, row buttons, radio chips, header and cell columns, Workers readout, badge and strip counts, Settings values set elsewhere, German labels never cut, the cache row at 1200 px, no Reset on Advanced, Forget asks first, first-run focus and the RTL window direction. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
18 files changed
+398
-8
No files matched your search
@@ -1,7 +1,9 @@
|
||||
using System.Globalization;
|
||||
using System.Windows;
|
||||
using System.Windows.Automation;
|
||||
using System.Windows.Automation.Peers;
|
||||
using System.Windows.Threading;
|
||||
using Titano.Core.Localization;
|
||||
|
||||
namespace Titano.App.Infrastructure;
|
||||
|
||||
@@ -15,6 +17,13 @@ public static class LiveRegion
|
||||
public static readonly DependencyProperty TextProperty = DependencyProperty.RegisterAttached(
|
||||
"Text", typeof(string), typeof(LiveRegion), new PropertyMetadata(null, OnTextChanged));
|
||||
|
||||
/// <summary>
|
||||
/// The data and language the last text came from: a recycled list row showing another item, or every status
|
||||
/// relabelled by a language switch, is not news.
|
||||
/// </summary>
|
||||
private static readonly DependencyProperty SourceProperty = DependencyProperty.RegisterAttached(
|
||||
"Source", typeof(Origin), typeof(LiveRegion), new PropertyMetadata(null));
|
||||
|
||||
public static string? GetText(DependencyObject element) => (string?)element.GetValue(TextProperty);
|
||||
|
||||
public static void SetText(DependencyObject element, string? value) => element.SetValue(TextProperty, value);
|
||||
@@ -23,10 +32,15 @@ public static class LiveRegion
|
||||
{
|
||||
if (d is not FrameworkElement element) return;
|
||||
AutomationProperties.SetName(element, (string?)e.NewValue ?? string.Empty);
|
||||
var origin = new Origin(element.DataContext, Loc.Culture);
|
||||
var sameSource = element.GetValue(SourceProperty) is Origin last && ReferenceEquals(last.Data, origin.Data) && last.Culture.Equals(origin.Culture);
|
||||
element.SetValue(SourceProperty, origin);
|
||||
// The first value arrives with the screen: only what changes while it is shown is announced, once layout has shown
|
||||
// it (a status that appears with its text is still collapsed when the text arrives).
|
||||
if (!element.IsLoaded || e.NewValue is null || !AutomationPeer.ListenerExists(AutomationEvents.LiveRegionChanged)) return;
|
||||
if (!sameSource || !element.IsLoaded || e.NewValue is null || !AutomationPeer.ListenerExists(AutomationEvents.LiveRegionChanged)) return;
|
||||
element.Dispatcher.InvokeAsync(() => UIElementAutomationPeer.CreatePeerForElement(element)?.RaiseAutomationEvent(AutomationEvents.LiveRegionChanged),
|
||||
DispatcherPriority.Background);
|
||||
}
|
||||
|
||||
private sealed record Origin(object? Data, CultureInfo Culture);
|
||||
}
|
||||
@@ -53,6 +53,9 @@ public sealed class JobRowViewModel : ObservableObject
|
||||
|
||||
public string StateText => JobText.State(_entry);
|
||||
|
||||
/// <summary>"Render · Harbour sunset: done · 3:00": what a screen reader announces when the state changes (not progress).</summary>
|
||||
public string StateAnnouncement => Loc.L("Jobs.Row.State", AccessibleName, StateText);
|
||||
|
||||
/// <summary>Glyph and colour of the state (paired with the word, never colour alone).</summary>
|
||||
public StatusKind StateKind => _entry.State switch
|
||||
{
|
||||
@@ -131,6 +134,7 @@ public sealed class JobRowViewModel : ObservableObject
|
||||
OnPropertyChanged(nameof(LeftText));
|
||||
OnPropertyChanged(nameof(WhereText));
|
||||
OnPropertyChanged(nameof(StateText));
|
||||
OnPropertyChanged(nameof(StateAnnouncement));
|
||||
if (_isExpanded) OnPropertyChanged(nameof(LogText));
|
||||
}
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
<StackPanel Grid.Row="7" Grid.Column="1" Orientation="Horizontal">
|
||||
<ui:StatusGlyph Kind="{Binding UpdateKind}" Text="{Binding UpdateText}" FontSize="13" VerticalAlignment="Center"
|
||||
Visibility="{Binding HasUpdateText, Converter={StaticResource BoolToVisibility}}"
|
||||
AutomationProperties.LiveSetting="Polite" infra:LiveRegion.Text="{Binding UpdateText}" />
|
||||
AutomationProperties.LiveSetting="Polite" infra:LiveRegion.Text="{Binding UpdateAnnouncement}" />
|
||||
<Button Style="{StaticResource Button.Link}" FontSize="13" Margin="12,0,0,0" VerticalAlignment="Center" Content="{l:Loc About.Update.Download}"
|
||||
Command="{Binding DownloadCommand}" ToolTip="{Binding DownloadToolTip}"
|
||||
Visibility="{Binding IsUpdateAvailable, Converter={StaticResource BoolToVisibility}}" />
|
||||
|
||||
@@ -81,6 +81,9 @@ public sealed class AboutViewModel : SectionViewModel
|
||||
_ => null,
|
||||
};
|
||||
|
||||
/// <summary>What screen readers announce: each new state, not each percent of a download.</summary>
|
||||
public string? UpdateAnnouncement => _update.State == UpdateState.Downloading ? Loc.L("About.Update.InProgress") : UpdateText;
|
||||
|
||||
public StatusKind UpdateKind => _update.State switch
|
||||
{
|
||||
UpdateState.Checking or UpdateState.Downloading => StatusKind.Running,
|
||||
@@ -137,6 +140,7 @@ public sealed class AboutViewModel : SectionViewModel
|
||||
private void RaiseUpdate()
|
||||
{
|
||||
OnPropertyChanged(nameof(UpdateText));
|
||||
OnPropertyChanged(nameof(UpdateAnnouncement));
|
||||
OnPropertyChanged(nameof(UpdateKind));
|
||||
OnPropertyChanged(nameof(HasUpdateText));
|
||||
OnPropertyChanged(nameof(IsUpdateAvailable));
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
xmlns:ui="clr-namespace:Titano.Ui.Controls;assembly=Titano.Ui"
|
||||
xmlns:l="clr-namespace:Titano.Ui.Localization;assembly=Titano.Ui"
|
||||
xmlns:s="clr-namespace:Titano.App.Sections"
|
||||
xmlns:infra="clr-namespace:Titano.App.Infrastructure"
|
||||
xmlns:j="clr-namespace:Titano.App.Jobs">
|
||||
<UserControl.Resources>
|
||||
<Style x:Key="Text.Muted" TargetType="TextBlock" BasedOn="{StaticResource Text.Cell}">
|
||||
@@ -167,8 +168,10 @@
|
||||
<TextBlock Grid.Column="4" Style="{StaticResource Text.MutedNumber}" Text="{Binding SpeedText}" Margin="10,0,0,0" />
|
||||
<TextBlock Grid.Column="5" Style="{StaticResource Text.MutedNumber}" Text="{Binding LeftText}" Margin="10,0,0,0" />
|
||||
<TextBlock Grid.Column="6" Style="{StaticResource Text.Muted}" Text="{Binding WhereText}" Margin="16,0,0,0" />
|
||||
<!-- A new state is announced with its job; progress ticks are not. -->
|
||||
<ui:StatusGlyph Grid.Column="7" Kind="{Binding StateKind}" Text="{Binding StateText}" ToolTip="{Binding StateToolTip}"
|
||||
FontSize="13" VerticalAlignment="Center" Margin="10,0,0,0" />
|
||||
FontSize="13" VerticalAlignment="Center" Margin="10,0,0,0"
|
||||
AutomationProperties.LiveSetting="Polite" infra:LiveRegion.Text="{Binding StateAnnouncement}" />
|
||||
<ItemsControl Grid.Column="8" ItemsSource="{Binding Actions}" ItemsPanel="{StaticResource Panel.Row}" Focusable="False"
|
||||
VerticalAlignment="Center" Margin="10,0,0,0">
|
||||
<ItemsControl.ItemTemplate>
|
||||
|
||||
@@ -84,6 +84,14 @@
|
||||
<ContextMenu.ItemContainerStyle>
|
||||
<Style TargetType="MenuItem" BasedOn="{StaticResource {x:Type MenuItem}}">
|
||||
<Setter Property="Header" Value="{Binding Address}" />
|
||||
<!-- An address reads left to right in every language. -->
|
||||
<Setter Property="HeaderTemplate">
|
||||
<Setter.Value>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding}" FlowDirection="LeftToRight" />
|
||||
</DataTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Setter Property="InputGestureText" Value="{Binding Name}" />
|
||||
<Setter Property="Command" Value="{Binding DataContext.UseServerCommand, RelativeSource={RelativeSource AncestorType=ContextMenu}}" />
|
||||
<Setter Property="CommandParameter" Value="{Binding}" />
|
||||
@@ -244,8 +252,10 @@
|
||||
<TextBlock Style="{StaticResource Text.Cell}" Text="{Binding Title}" ToolTip="{Binding Title}" />
|
||||
<TextBlock Grid.Column="1" Style="{StaticResource Text.Cell}" Text="{Binding LocalText}" ToolTip="{Binding LocalText}" Margin="10,0,0,0" />
|
||||
<TextBlock Grid.Column="2" Style="{StaticResource Text.Cell}" Text="{Binding ServerText}" ToolTip="{Binding ServerText}" Margin="10,0,0,0" />
|
||||
<!-- A new state (uploading, in sync, failed) is announced with its sequence; progress ticks are not. -->
|
||||
<ui:StatusGlyph Grid.Column="3" Kind="{Binding StateKind}" Text="{Binding StateText}" ToolTip="{Binding StateToolTip}"
|
||||
FontSize="13" VerticalAlignment="Center" Margin="10,0,0,0" />
|
||||
FontSize="13" VerticalAlignment="Center" Margin="10,0,0,0"
|
||||
AutomationProperties.LiveSetting="Polite" infra:LiveRegion.Text="{Binding StateAnnouncement}" />
|
||||
<ItemsControl Grid.Column="4" ItemsSource="{Binding Actions}" ItemsPanel="{StaticResource Panel.Wrap}" Focusable="False" VerticalAlignment="Center" Margin="10,4,0,4">
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate DataType="{x:Type srv:SyncRowAction}">
|
||||
|
||||
@@ -383,7 +383,7 @@
|
||||
<Button Content="{l:Loc About.Update.Check}" Command="{Binding Shell.About.CheckCommand}" ToolTip="{l:Loc Tooltips.About.Check}" />
|
||||
<ui:StatusGlyph Kind="{Binding Shell.About.UpdateKind}" Text="{Binding Shell.About.UpdateText}" FontSize="13" VerticalAlignment="Center" Margin="12,0,0,0"
|
||||
Visibility="{Binding Shell.About.HasUpdateText, Converter={StaticResource BoolToVisibility}}"
|
||||
AutomationProperties.LiveSetting="Polite" infra:LiveRegion.Text="{Binding Shell.About.UpdateText}" />
|
||||
AutomationProperties.LiveSetting="Polite" infra:LiveRegion.Text="{Binding Shell.About.UpdateAnnouncement}" />
|
||||
<Button Style="{StaticResource Button.Link}" Content="{l:Loc About.Update.Download}" Command="{Binding Shell.About.DownloadCommand}" ToolTip="{Binding Shell.About.DownloadToolTip}"
|
||||
VerticalAlignment="Center" Margin="12,0,0,0" FontSize="13"
|
||||
Visibility="{Binding Shell.About.IsUpdateAvailable, Converter={StaticResource BoolToVisibility}}" />
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Threading;
|
||||
@@ -16,10 +15,14 @@ public partial class WelcomeView : UserControl
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>The dialog opens with keyboard focus on the chosen card, so the keyboard starts inside it.</summary>
|
||||
/// <summary>
|
||||
/// The dialog opens with focus on the chosen card, so the keyboard starts inside it; the window keeps it as its focused
|
||||
/// element, so a window not active yet gives the card keyboard focus when activated.
|
||||
/// </summary>
|
||||
private void FocusChoice()
|
||||
{
|
||||
var chosen = new[] { LocalChoice, AdoptChoice, ServerChoice }.FirstOrDefault(c => c.IsChecked == true) ?? LocalChoice;
|
||||
FocusManager.SetFocusedElement(FocusManager.GetFocusScope(chosen), chosen);
|
||||
Keyboard.Focus(chosen);
|
||||
}
|
||||
}
|
||||
@@ -65,9 +65,13 @@ public sealed class SyncRow : ObservableObject
|
||||
public string ServerText => SyncText.Server(_entry);
|
||||
public StatusKind StateKind => SyncText.State(_entry).Kind;
|
||||
public string StateText => SyncText.State(_entry).Text;
|
||||
|
||||
/// <summary>"Clouds over the Langhe: In sync": what a screen reader announces when the state changes (not progress).</summary>
|
||||
public string StateAnnouncement => Loc.L("Server.Sync.Row.State", Title, StateText);
|
||||
|
||||
public string StateToolTip => SyncText.State(_entry).ToolTip;
|
||||
|
||||
/// <summary>Settings differ on both sides: the row is drawn on the card colour, as in Server.html.</summary>
|
||||
/// <summary>Settings differ on both sides: the row is drawn on the warning tint (the word in the State column says it too).</summary>
|
||||
public bool IsConflict => _entry.Status == SyncStatus.Conflict && _entry.Transfer is null;
|
||||
|
||||
public IReadOnlyList<SyncRowAction> Actions
|
||||
@@ -125,6 +129,7 @@ public sealed class SyncRow : ObservableObject
|
||||
OnPropertyChanged(nameof(ServerText));
|
||||
OnPropertyChanged(nameof(StateKind));
|
||||
OnPropertyChanged(nameof(StateText));
|
||||
OnPropertyChanged(nameof(StateAnnouncement));
|
||||
OnPropertyChanged(nameof(StateToolTip));
|
||||
OnPropertyChanged(nameof(IsConflict));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user