Commit 2a82e5eb authored by Ahmed Mehfooz's avatar Ahmed Mehfooz Committed by Chromium LUCI CQ

Add accessibility support for stylus battery status

Bug: 1165451
Change-Id: I8095ef53ec141ef30bee22aec6930dc12b027637
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2623171
Commit-Queue: Ahmed Mehfooz <amehfooz@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#842788}
parent 6fd38a88
...@@ -1232,6 +1232,9 @@ This file contains the strings for ash. ...@@ -1232,6 +1232,9 @@ This file contains the strings for ash.
<message name="IDS_ASH_STYLUS_BATTERY_LOW_LABEL" desc="The label next to the stylus battery indicator when the battery level is below 24%"> <message name="IDS_ASH_STYLUS_BATTERY_LOW_LABEL" desc="The label next to the stylus battery indicator when the battery level is below 24%">
Low Low
</message> </message>
<message name="IDS_ASH_STYLUS_BATTERY_PERCENT_ACCESSIBLE" desc="The message used by accessibility to show stylus battery level.">
Stylus battery at <ph name="percentage">$1<ex>56</ex></ph> percent.
</message>
<message name="IDS_ASH_STYLUS_TOOLS_CAPTURE_REGION_ACTION" desc="Title of the capture region action in the stylus tools (a pop-up panel next to the status tray). This causes a partial screenshot to be taken (the user selects an area of the screen to take a screenshot of)."> <message name="IDS_ASH_STYLUS_TOOLS_CAPTURE_REGION_ACTION" desc="Title of the capture region action in the stylus tools (a pop-up panel next to the status tray). This causes a partial screenshot to be taken (the user selects an area of the screen to take a screenshot of).">
Capture region Capture region
</message> </message>
......
00c68e1647b1b8ce844dae493475be213cdbf8e3
\ No newline at end of file
...@@ -35,6 +35,8 @@ ...@@ -35,6 +35,8 @@
#include "components/prefs/pref_change_registrar.h" #include "components/prefs/pref_change_registrar.h"
#include "components/prefs/pref_registry_simple.h" #include "components/prefs/pref_registry_simple.h"
#include "components/prefs/pref_service.h" #include "components/prefs/pref_service.h"
#include "ui/accessibility/ax_enums.mojom-shared.h"
#include "ui/accessibility/ax_node_data.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h" #include "ui/base/resource/resource_bundle.h"
#include "ui/display/display.h" #include "ui/display/display.h"
...@@ -91,10 +93,12 @@ bool ShouldShowOnDisplay(PaletteTray* palette_tray) { ...@@ -91,10 +93,12 @@ bool ShouldShowOnDisplay(PaletteTray* palette_tray) {
class BatteryView : public views::View { class BatteryView : public views::View {
public: public:
explicit BatteryView(StylusBatteryDelegate* delegate) { explicit BatteryView(StylusBatteryDelegate* delegate) : delegate_(delegate) {
SetLayoutManager(std::make_unique<views::BoxLayout>( SetLayoutManager(std::make_unique<views::BoxLayout>(
views::BoxLayout::Orientation::kHorizontal, gfx::Insets(), 4)); views::BoxLayout::Orientation::kHorizontal, gfx::Insets(), 4));
SetFocusBehavior(FocusBehavior::ACCESSIBLE_ONLY);
icon_ = AddChildView(std::make_unique<views::ImageView>()); icon_ = AddChildView(std::make_unique<views::ImageView>());
icon_->SetImage(delegate->GetBatteryImage()); icon_->SetImage(delegate->GetBatteryImage());
...@@ -107,7 +111,15 @@ class BatteryView : public views::View { ...@@ -107,7 +111,15 @@ class BatteryView : public views::View {
} }
} }
void GetAccessibleNodeData(ui::AXNodeData* node_data) override {
node_data->role = ax::mojom::Role::kLabelText;
node_data->SetName(l10n_util::GetStringFUTF16(
IDS_ASH_STYLUS_BATTERY_PERCENT_ACCESSIBLE,
base::NumberToString16(delegate_->battery_level().value_or(0))));
}
private: private:
StylusBatteryDelegate* const delegate_;
views::ImageView* icon_ = nullptr; views::ImageView* icon_ = nullptr;
views::Label* label_ = nullptr; views::Label* label_ = nullptr;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment