Update a11y description of GlanceablesClassroomItemView
Bug: b/294681832 Change-Id: I91aef648af3a8575fc283ba1ae7e98cc00c6fa91 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4778088 Reviewed-by: Matthew Mourgos <mmourgos@chromium.org> Commit-Queue: Artsiom Mitrokhin <amitrokhin@chromium.org> Cr-Commit-Position: refs/heads/main@{#1183603}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
dbb1bec7da
commit
ac970a94fd
@ -6911,6 +6911,12 @@ New install
|
||||
<message name="IDS_GLANCEABLES_CLASSROOM_STUDENT_DONE_LIST_NAME" desc="The glanceable displays classroom items fetched from Google Classroom API. This is the name of the list that contains completed student assignments.">
|
||||
Done
|
||||
</message>
|
||||
<message name="IDS_GLANCEABLES_CLASSROOM_ASSIGNMENT_DUE_ACCESSIBLE_DESCRIPTION" desc="The classroom glanceable displays classroom items for student and/or teachers fetched from Google Classroom API. This text is the part of a11y description to announce that an assignment has a due date and/or time.">
|
||||
due <ph name="DUE_DATE_AND_TIME">$1<ex>Wed, Aug 23</ex></ph>
|
||||
</message>
|
||||
<message name="IDS_GLANCEABLES_CLASSROOM_ASSIGNMENT_SUBMISSIONS_STATE_ACCESSIBLE_DESCRIPTION" desc="The teacher classroom glanceable shows upcoming/missed/completed assignments from Google Classroom. For each assignment item, this text displays the number of submissions turned in along side the total number of sumbissions. Then this text also displays the number of submissions currently graded.">
|
||||
<ph name="NUM_TURNED_IN">$1<ex>8</ex></ph> of <ph name="TOTAL_NUM_OF_SUBMISSIONS">$2<ex>22</ex></ph> turned in, <ph name="NUM_GRADED">$3<ex>5</ex></ph> graded
|
||||
</message>
|
||||
|
||||
<!-- Do Not Disturb notification -->
|
||||
<message name="IDS_ASH_DO_NOT_DISTURB_NOTIFICATION_TITLE" desc="Label used for the notification that shows up when the 'Do Not Disturb' feature is enabled.">
|
||||
|
1
ash/ash_strings_grd/IDS_GLANCEABLES_CLASSROOM_ASSIGNMENT_DUE_ACCESSIBLE_DESCRIPTION.png.sha1
Normal file
1
ash/ash_strings_grd/IDS_GLANCEABLES_CLASSROOM_ASSIGNMENT_DUE_ACCESSIBLE_DESCRIPTION.png.sha1
Normal file
@ -0,0 +1 @@
|
||||
68674ed67d495b2b7b33dca4f2e9fb9597313ae3
|
1
ash/ash_strings_grd/IDS_GLANCEABLES_CLASSROOM_ASSIGNMENT_SUBMISSIONS_STATE_ACCESSIBLE_DESCRIPTION.png.sha1
Normal file
1
ash/ash_strings_grd/IDS_GLANCEABLES_CLASSROOM_ASSIGNMENT_SUBMISSIONS_STATE_ACCESSIBLE_DESCRIPTION.png.sha1
Normal file
@ -0,0 +1 @@
|
||||
6d14355dc822f1e645d334a15e14b7d458a1bb5e
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "ash/glanceables/classroom/glanceables_classroom_client.h"
|
||||
@ -24,7 +25,6 @@
|
||||
#include "base/i18n/time_formatting.h"
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "base/time/time.h"
|
||||
#include "base/types/cxx23_to_underlying.h"
|
||||
@ -131,27 +131,6 @@ std::unique_ptr<views::View> BuildIcon() {
|
||||
.Build();
|
||||
}
|
||||
|
||||
std::u16string GetAssignmentAccessibleDescription(
|
||||
const GlanceablesClassroomAssignment* assignment) {
|
||||
// TODO(b/294681832): Finalize, and then localize strings.
|
||||
std::vector<std::u16string> components;
|
||||
components.push_back(base::UTF8ToUTF16(assignment->course_title));
|
||||
|
||||
if (assignment->due) {
|
||||
components.push_back(u"Due: " + GetFormattedDueDate(*assignment->due) +
|
||||
u", " + GetFormattedDueTime(*assignment->due));
|
||||
}
|
||||
|
||||
if (assignment->submissions_state.has_value()) {
|
||||
components.push_back(base::UTF8ToUTF16(
|
||||
base::StringPrintf("%d of %d turned in, %d graded",
|
||||
assignment->submissions_state->number_turned_in,
|
||||
assignment->submissions_state->total_count,
|
||||
assignment->submissions_state->number_graded)));
|
||||
}
|
||||
return base::JoinString(components, u", ");
|
||||
}
|
||||
|
||||
std::unique_ptr<views::BoxLayoutView> BuildAssignmentTitleLabels(
|
||||
const GlanceablesClassroomAssignment* assignment) {
|
||||
const auto* const typography_provider = TypographyProvider::Get();
|
||||
@ -205,7 +184,8 @@ std::unique_ptr<views::BoxLayoutView> BuildAssignmentTitleLabels(
|
||||
}
|
||||
|
||||
std::unique_ptr<views::BoxLayoutView> BuildDueLabels(
|
||||
const GlanceablesClassroomAssignment* assignment) {
|
||||
const std::u16string& due_date,
|
||||
const std::u16string& due_time) {
|
||||
const auto* const typography_provider = TypographyProvider::Get();
|
||||
|
||||
return views::Builder<views::BoxLayoutView>()
|
||||
@ -214,7 +194,7 @@ std::unique_ptr<views::BoxLayoutView> BuildDueLabels(
|
||||
.SetCrossAxisAlignment(views::BoxLayout::CrossAxisAlignment::kEnd)
|
||||
.SetProperty(views::kMarginsKey, kDueLabelsMargin)
|
||||
.AddChild(views::Builder<views::Label>()
|
||||
.SetText(GetFormattedDueDate(assignment->due.value()))
|
||||
.SetText(due_date)
|
||||
.SetID(base::to_underlying(
|
||||
GlanceablesViewId::kClassroomItemDueDateLabel))
|
||||
.SetEnabledColorId(cros_tokens::kCrosSysOnSurfaceVariant)
|
||||
@ -223,7 +203,7 @@ std::unique_ptr<views::BoxLayoutView> BuildDueLabels(
|
||||
.SetLineHeight(typography_provider->ResolveLineHeight(
|
||||
TypographyToken::kCrosAnnotation1)))
|
||||
.AddChild(views::Builder<views::Label>()
|
||||
.SetText(GetFormattedDueTime(assignment->due.value()))
|
||||
.SetText(due_time)
|
||||
.SetID(base::to_underlying(
|
||||
GlanceablesViewId::kClassroomItemDueTimeLabel))
|
||||
.SetEnabledColorId(cros_tokens::kCrosSysOnSurfaceVariant)
|
||||
@ -265,16 +245,34 @@ GlanceablesClassroomItemView::GlanceablesClassroomItemView(
|
||||
cros_tokens::kCrosSysSystemOnBase, corner_radii,
|
||||
/*for_border_thickness=*/0));
|
||||
|
||||
std::vector<std::u16string> a11y_description_parts{
|
||||
base::UTF8ToUTF16(assignment->course_title)};
|
||||
|
||||
AddChildView(BuildIcon());
|
||||
AddChildView(BuildAssignmentTitleLabels(assignment));
|
||||
if (assignment->due.has_value()) {
|
||||
AddChildView(BuildDueLabels(assignment));
|
||||
const auto due_date = GetFormattedDueDate(assignment->due.value());
|
||||
const auto due_time = GetFormattedDueTime(assignment->due.value());
|
||||
AddChildView(BuildDueLabels(due_date, due_time));
|
||||
|
||||
a11y_description_parts.push_back(l10n_util::GetStringFUTF16(
|
||||
IDS_GLANCEABLES_CLASSROOM_ASSIGNMENT_DUE_ACCESSIBLE_DESCRIPTION,
|
||||
due_time.empty() ? due_date
|
||||
: base::JoinString({due_date, due_time}, u", ")));
|
||||
}
|
||||
|
||||
if (assignment->submissions_state.has_value()) {
|
||||
a11y_description_parts.push_back(l10n_util::GetStringFUTF16(
|
||||
IDS_GLANCEABLES_CLASSROOM_ASSIGNMENT_SUBMISSIONS_STATE_ACCESSIBLE_DESCRIPTION,
|
||||
base::NumberToString16(assignment->submissions_state->number_turned_in),
|
||||
base::NumberToString16(assignment->submissions_state->total_count),
|
||||
base::NumberToString16(assignment->submissions_state->number_graded)));
|
||||
}
|
||||
|
||||
SetAccessibleRole(ax::mojom::Role::kListItem);
|
||||
GetViewAccessibility().OverrideIsLeaf(true);
|
||||
SetAccessibleName(base::UTF8ToUTF16(assignment->course_work_title));
|
||||
SetAccessibleDescription(GetAssignmentAccessibleDescription(assignment));
|
||||
SetAccessibleDescription(base::JoinString(a11y_description_parts, u", "));
|
||||
|
||||
views::FocusRing::Install(this);
|
||||
views::FocusRing* const focus_ring = views::FocusRing::Get(this);
|
||||
|
Reference in New Issue
Block a user