Skip to content
This repository has been archived by the owner on Oct 4, 2021. It is now read-only.

Commit

Permalink
Merge pull request #9167 from mono/fix753572-a11y-connected-services
Browse files Browse the repository at this point in the history
[ConnectedServices] Add accessibility support to the connected services view
  • Loading branch information
slluis authored Oct 31, 2019
2 parents 853f0aa + fdcd668 commit 8c555df
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public ConfigurationSectionWidget (IConfigurationSection section)
statusLabel.TextColor = Styles.SecondaryTextColor;

statusImage = new ImageView (ImageService.GetIcon ("md-checkmark").WithSize (IconSize.Small));
statusImage.Accessible.LabelWidget = statusLabel;

statusBox = new HBox ();
statusBox.MarginLeft = 10;
Expand All @@ -94,6 +95,10 @@ public ConfigurationSectionWidget (IConfigurationSection section)
headerTitle.PackStart (titleLabel);
headerTitle.PackStart (statusBox);

headerTitle.Accessible.Role = Xwt.Accessibility.Role.Disclosure;
headerTitle.Accessible.IsAccessible = true;
headerTitle.Accessible.LabelWidget = titleLabel;

header.PackStart (headerTitle);

addBtn = new Button (GettextCatalog.GetString ("Add to the project"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,13 @@ public DependenciesSectionWidget (IConfigurationSection section)
}

bool firstCategory = true;
widget.Accessible.Role = Xwt.Accessibility.Role.Group;
widget.Accessible.Label = GettextCatalog.GetString ("Dependencies");
widget.Accessible.IsAccessible = true;

foreach (var category in this.section.Service.Dependencies.Select (d => d.Category).Distinct ()) {
var categoryIcon = new ImageView (category.Icon.WithSize (IconSize.Small));
categoryIcon.Accessible.Label = GettextCatalog.GetString ("Category");
var categoryLabel = new Label (category.Name);
var categoryBox = new HBox ();

Expand All @@ -48,10 +52,16 @@ public DependenciesSectionWidget (IConfigurationSection section)
categoryBox.PackStart (categoryLabel);
widget.PackStart (categoryBox);

var dependenciesGroup = new VBox () {
MarginLeft = category.Icon.Size.Width / 2
};
dependenciesGroup.Accessible.Role = Xwt.Accessibility.Role.Group;
dependenciesGroup.Accessible.LabelWidget = categoryLabel;
dependenciesGroup.Accessible.IsAccessible = true;
widget.PackStart (dependenciesGroup);

foreach (var dependency in this.section.Service.Dependencies.Where (d => d.Category == category)) {
widget.PackStart (new DependencyWidget (section.Service, dependency) {
MarginLeft = category.Icon.Size.Width / 2
});
dependenciesGroup.PackStart (new DependencyWidget (section.Service, dependency));
}

if (firstCategory)
Expand Down Expand Up @@ -93,13 +103,23 @@ public DependencyWidget (IConnectedService service, IConnectedServiceDependency
container.PackStart (statusIconView);
container.PackStart (statusLabel);

Accessible.Role = Xwt.Accessibility.Role.Group;
Accessible.IsAccessible = true;
Accessible.LabelWidget = nameLabel;

Content = container;
Update ();

dependency.StatusChanged += HandleDependencyStatusChange;
service.StatusChanged += HandleServiceStatusChanged;
}

void UpdateAccessibility ()
{
iconView.Accessible.LabelWidget = nameLabel;
statusIconView.Accessible.Label = GettextCatalog.GetString ("Status");
}

void SetStatusIcon (IconId stockId, double alpha = 1.0)
{
animatedStatusIcon = null;
Expand Down Expand Up @@ -148,6 +168,7 @@ void Update ()
else
SetStatusIcon (IconId.Null);
}
UpdateAccessibility ();
}

void HandleDependencyStatusChange (object sender, StatusChangedEventArgs e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ public ServiceDetailsWidget ()

var container = new VBox ();

Accessible.Role = Xwt.Accessibility.Role.Group;
Accessible.IsAccessible = true;

details = new ServiceWidget (true);
details.BorderWidth = 1;
details.CornerRadius = new Components.RoundedFrameBox.BorderCornerRadius (6, 6, 0, 0);
Expand Down Expand Up @@ -80,6 +83,8 @@ public void LoadService (IConnectedService service)
if (service.Status == Status.Added) {
ExpandFirstOrUnconfiguredSection ();
}

Accessible.Label = service.DisplayName;
}

void HandleServiceStatusChanged (object sender, StatusChangedEventArgs e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public IConnectedService Service {
service.StatusChanged += HandleServiceStatusChanged;

UpdateServiceStatus ();
UpdateAccessibility ();
}
}

Expand Down Expand Up @@ -151,6 +152,19 @@ public ServiceWidget (bool showDetails = false)

Content = container;
ShowDetails = showDetails;

UpdateAccessibility ();
}

void UpdateAccessibility ()
{
Accessible.IsAccessible = true;
Accessible.Role = ShowDetails ? Xwt.Accessibility.Role.Group : Xwt.Accessibility.Role.Button;
Accessible.LabelWidget = title;

addButton.Accessible.LabelWidget = title;

image.Accessible.Label = GettextCatalog.GetString ("Service Icon");
}

void HandleAddButtonClicked (object sender, EventArgs e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ public string BackButtonTooltip {
backButtonTooltip = value;
if (BackButtonVisible)
backButton.TooltipText = value;
backButton.Accessible.Title = value;
}
}

Expand Down Expand Up @@ -190,6 +191,7 @@ public ExtendedHeaderBox (string title, string subtitle = null, Image image = nu
TextColor = Styles.SecondaryTextColor,
Font = font.WithSize (14),
};
headerSeparator.Accessible.IsAccessible = false;

headerSubtitle = new Label {
TextColor = Styles.SecondaryTextColor,
Expand Down

0 comments on commit 8c555df

Please sign in to comment.