Skip to content

Commit c4e6d07

Browse files
author
Bianca Marina Stana
committed
Minor improvements
# Conflicts: # Assets/Scripts/Screen Reader/UITk/VisualTreeAccessibilityUpdater.cs
1 parent 0267b85 commit c4e6d07

File tree

6 files changed

+22
-26
lines changed

6 files changed

+22
-26
lines changed

Assets/Scripts/Gameplay/GameViewController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ void MoveCard(bool shouldMoveLeft, int count)
304304

305305
// Make the letter uppercase to ensure correct phonetic pronunciation.
306306
// TODO: This should be localized.
307-
var announcement = $"Moved {draggable.name.ToUpper()} {(shouldMoveLeft ? "before" : "after")} {otherSibling.name.ToUpper()}";
307+
var announcement = $"Moved \"{draggable.name.ToUpper()}\" {(shouldMoveLeft ? "before" : "after")} \"{otherSibling.name.ToUpper()}\"";
308308

309309
// Announce that the card was moved.
310310
AssistiveSupport.notificationDispatcher.SendAnnouncement(announcement);

Assets/Scripts/Screen Reader/AccessibilityManager.cs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ void OnDisable()
215215

216216
void OnSceneLoaded(Scene scene, LoadSceneMode mode)
217217
{
218-
StartCoroutine(DelayRebuildHierarchy(scene));
218+
RebuildHierarchyForScene(scene);
219219
}
220220

221221
void OnSceneUnloaded(Scene scene)
@@ -274,20 +274,17 @@ public static void RebuildHierarchy(AccessibilityService service)
274274

275275
if (lastLoadedScene.IsValid())
276276
{
277-
s_Instance.StartCoroutine(s_Instance.DelayRebuildHierarchy(lastLoadedScene, service));
277+
s_Instance.RebuildHierarchyForScene(lastLoadedScene, service);
278278
}
279279
}
280280

281-
IEnumerator DelayRebuildHierarchy(Scene scene, AccessibilityService service = null)
281+
void RebuildHierarchyForScene(Scene scene, AccessibilityService service = null)
282282
{
283283
if (!Application.isEditor && !AssistiveSupport.isScreenReaderEnabled)
284284
{
285-
yield break;
285+
return;
286286
}
287287

288-
// Wait for the end frame before generating the hierarchy to make sure the layout has been computed.
289-
yield return new WaitForEndOfFrame();
290-
291288
if (service == null)
292289
{
293290
// Rebuild the whole hierarchy (for all registered services).

Assets/Scripts/Screen Reader/UGUI/AccessibleScrollview.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ void Start()
2727
label ??= "Scroll View";
2828

2929
#if UNITY_6000_3_OR_NEWER
30-
role = AccessibilityRole.Container;
30+
role = AccessibilityRole.ScrollView;
3131
#else // UNITY_6000_3_OR_NEWER
3232
// The scroll view should not be accessible (i.e. focusable with the screen reader) on mobile platforms.
3333
// The purpose of this component is to automatically scroll to the focused node inside the scroll view if

Assets/Scripts/Screen Reader/UITk/VisualTreeAccessibilityUpdater.cs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -187,19 +187,19 @@ VisualElementAccessibilityHandler CreateHandler(VisualElement element)
187187

188188
void InsertNode(VisualElementAccessibilityHandler parentHandler, VisualElementAccessibilityHandler accHandler)
189189
{
190-
var p = parentHandler;
191-
var parentNode = p?.node;
192-
193-
// Keep track of insertion index for each parent node.
194-
var index = p?.nextInsertionIndex ?? m_RootNextInsertionIndex;
195-
var node = hierarchy.InsertNode(index, accHandler.ownerElement.name, parentNode);
190+
// Keep track of the insertion index for each parent node.
191+
var index = parentHandler?.nextInsertionIndex ?? m_RootNextInsertionIndex;
192+
var label = accHandler.ownerElement.name;
193+
var parentNode = parentHandler?.node;
196194

197-
accHandler.node = node;
198-
accHandler.change = VisualElementAccessibilityHandler.k_AccessibilityChange;
195+
var node = hierarchy.InsertNode(index, label, parentNode);
199196

200197
node.label = accHandler.label;
201198
node.role = accHandler.role;
202199

200+
accHandler.node = node;
201+
accHandler.change = VisualElementAccessibilityHandler.k_AccessibilityChange;
202+
203203
m_HandlersForNodes[node] = accHandler;
204204

205205
if (p != null)
@@ -573,8 +573,6 @@ void Update(VisualElement visualTree)
573573
shouldSendNotification = true;
574574
}
575575

576-
AssistiveSupport.activeHierarchy ??= m_AccessibilityService.hierarchy.mainHierarchy;
577-
578576
m_Notification = NotificationType.None;
579577
ResetAllInsertionIndex();
580578

Assets/Scripts/UITk/Card.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,7 @@ void MoveCard(bool shouldMoveLeft)
705705
var otherSibling = this[otherSiblingIndex];
706706

707707
// TODO: This should be localized.
708-
var message = $"Moved {draggable.name} {(shouldMoveLeft ? "before" : "after")} {otherSibling.name}";
708+
var message = $"Moved \"{draggable.name}\" {(shouldMoveLeft ? "before" : "after")} \"{otherSibling.name}\"";
709709

710710
// Announce that the card was moved.
711711
AssistiveSupport.notificationDispatcher.SendAnnouncement(message);

Assets/Scripts/UITk/MainView.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ void ShowResults(int orderedWordCount, int totalWordCount)
601601
// m_ClueLabel.style.display = DisplayStyle.None;
602602

603603
// Ensure the clue label always the same space in the view so do not hide it.
604-
m_ClueLabel.text = " ";
604+
m_ClueLabel.text = "";
605605
m_ClueLabel.style.visibility = Visibility.Hidden;
606606
}
607607

@@ -679,7 +679,7 @@ void OnLetterCardsChanged()
679679
{
680680
var card = new UITkLetterCard();
681681
m_LetterCardContainer.Add(card);
682-
card.text = letterCard.letter.ToString();
682+
card.text = letterCard.letter.ToString().ToUpper();
683683
card.name = letterCard.letter.ToString();
684684
card.GetOrCreateAccessibleProperties().label = card.text;
685685
card.dropped += (oldIndex, newIndex) =>
@@ -698,7 +698,7 @@ void StateTheLetters()
698698
{
699699
// TODO: This should be localized.
700700
var listCardMessage = "The letters are now " + string.Join(", ",
701-
m_Model.letterCards.Select(c => c.letter).ToArray());
701+
m_Model.letterCards.Select(c => "\"" + c.letter + "\"").ToArray());
702702
AssistiveSupport.notificationDispatcher.SendAnnouncement(listCardMessage);
703703
Debug.Log(listCardMessage);
704704
}
@@ -824,13 +824,14 @@ void MoveCard(bool shouldMoveLeft, int count = 1)
824824
if (moved)
825825
{
826826
// TODO: This should be localized.
827-
var message = $"Moved {selectedCardText} {(shouldMoveLeft ? "before" : "after")} {otherCardText}";
827+
var message = $"Moved \"{selectedCardText}\" {(shouldMoveLeft ? "before" : "after")} " +
828+
$"\"{otherCardText}\"";
828829

829830
// Announce that the card was moved. Give a bit of time for the layout change notification to be
830831
// processed first so that the announcement is not interrupted by the focus change.
831832
m_MainView.schedule.Execute(() =>
832833
AssistiveSupport.notificationDispatcher.SendAnnouncement(message)
833-
).ExecuteLater(200);
834+
).ExecuteLater(200);
834835
}
835836

836837
/*var accElement = draggable.transform.GetComponent<AccessibleElement>();
@@ -840,7 +841,7 @@ void MoveCard(bool shouldMoveLeft, int count = 1)
840841
var index = draggable.transform.GetSiblingIndex();
841842
var otherSiblingIndex = shouldMoveLeft ? index + 1 : index - 1;
842843
var otherSibling = draggable.transform.parent.GetChild(otherSiblingIndex);
843-
var message = $"Moved {draggable.name} {(shouldMoveLeft ? "before" : "after")} {otherSibling.name}";
844+
var message = $"Moved \"{draggable.name}\" {(shouldMoveLeft ? "before" : "after")} \"{otherSibling.name}\"";
844845
845846
// Announce that the card was moved.
846847
AssistiveSupport.notificationDispatcher.SendAnnouncement(message);

0 commit comments

Comments
 (0)