Commit 648d1f25 authored by Tatsuhisa Yamaguchi's avatar Tatsuhisa Yamaguchi Committed by Commit Bot

Add tooltip and accessible node data for IME indicator icon.

Add the full name of current IME as the tooltip and the accessible name
for the IME indicator icon. This change also revises the TrayItemView
by extending the views::Label class. We are using some text like "US"
or "あ" (the first hiragana alphabet of Japanese language) as the icon,
but those should not be read literally like a normal label.

Bug: 888072
Change-Id: I2295a15f6891731487f17dac29c8b9886b6c0b4b
Reviewed-on: https://chromium-review.googlesource.com/c/1317299Reviewed-by: default avatarTetsui Ohkubo <tetsui@chromium.org>
Commit-Queue: Tatsuhisa Yamaguchi <yamaguchi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#605279}
parent 5e85624f
......@@ -279,6 +279,9 @@ This file contains the strings for ash.
<message name="IDS_ASH_STATUS_TRAY_QUIET_MODE_TOOLTIP" desc="The tooltip text for the status area icon to tell do-not-disturb mode is currently on.">
Do Not Disturb is on
</message>
<message name="IDS_ASH_STATUS_TRAY_INDICATOR_IME_TOOLTIP" desc="The tooltip text for the status area icon to tell the type of keyboard or input method engine.">
Using <ph name="IME_NAME">$1<ex>US keyboard</ex></ph>
</message>
<message name="IDS_ASH_STATUS_TRAY_NOTIFICATIONS_COUNT_TOOLTIP" desc="The tooltip text for a status area icon to describe number of notifications. [ICU Syntax]">
{NUM_NOTIFICATIONS, plural,
=1 {1 notification}
......
......@@ -7,6 +7,7 @@
#include "ash/public/cpp/shelf_types.h"
#include "ash/shelf/shelf.h"
#include "ash/system/tray/tray_constants.h"
#include "ui/accessibility/ax_node_data.h"
#include "ui/compositor/layer.h"
#include "ui/compositor/scoped_animation_duration_scale_mode.h"
#include "ui/gfx/animation/slide_animation.h"
......@@ -23,6 +24,14 @@ const int kTrayItemAnimationDurationMS = 200;
} // namespace
void IconizedLabel::GetAccessibleNodeData(ui::AXNodeData* node_data) {
if (custom_accessible_name_.empty())
return Label::GetAccessibleNodeData(node_data);
node_data->role = ax::mojom::Role::kStaticText;
node_data->SetName(custom_accessible_name_);
}
TrayItemView::TrayItemView(Shelf* shelf)
: shelf_(shelf), label_(NULL), image_view_(NULL) {
DCHECK(shelf_);
......@@ -34,7 +43,7 @@ TrayItemView::TrayItemView(Shelf* shelf)
TrayItemView::~TrayItemView() = default;
void TrayItemView::CreateLabel() {
label_ = new views::Label;
label_ = new IconizedLabel;
AddChildView(label_);
PreferredSizeChanged();
}
......
......@@ -10,6 +10,7 @@
#include "ash/ash_export.h"
#include "base/macros.h"
#include "ui/gfx/animation/animation_delegate.h"
#include "ui/views/controls/label.h"
#include "ui/views/view.h"
namespace gfx {
......@@ -18,12 +19,28 @@ class SlideAnimation;
namespace views {
class ImageView;
class Label;
}
namespace ash {
class Shelf;
// Lable view which can be given a different data from the visible label.
// IME icons like "US" (US keyboard) or "あ(Google Japanese Input)" are
// rendered as a label, but reading such text literally will not always be
// understandable.
class IconizedLabel : public views::Label {
public:
void SetCustomAccessibleName(const base::string16& name) {
custom_accessible_name_ = name;
}
// views::Label:
void GetAccessibleNodeData(ui::AXNodeData* node_data) override;
private:
base::string16 custom_accessible_name_;
};
// Base-class for items in the tray. It makes sure the widget is updated
// correctly when the visibility/size of the tray item changes. It also adds
// animation when showing/hiding the item in the tray.
......@@ -38,7 +55,7 @@ class ASH_EXPORT TrayItemView : public views::View,
void CreateLabel();
void CreateImageView();
views::Label* label() const { return label_; }
IconizedLabel* label() const { return label_; }
views::ImageView* image_view() const { return image_view_; }
// Overridden from views::View.
......@@ -62,7 +79,7 @@ class ASH_EXPORT TrayItemView : public views::View,
Shelf* const shelf_;
std::unique_ptr<gfx::SlideAnimation> animation_;
// Only one of |label_| and |image_view_| should be non-null.
views::Label* label_;
IconizedLabel* label_;
views::ImageView* image_view_;
DISALLOW_COPY_AND_ASSIGN(TrayItemView);
......
......@@ -7,10 +7,12 @@
#include "ash/ime/ime_controller.h"
#include "ash/session/session_controller.h"
#include "ash/shell.h"
#include "ash/strings/grit/ash_strings.h"
#include "ash/system/tray/system_tray_notifier.h"
#include "ash/system/tray/tray_constants.h"
#include "ash/system/tray/tray_utils.h"
#include "ash/wm/tablet_mode/tablet_mode_controller.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/views/controls/label.h"
namespace ash {
......@@ -71,6 +73,12 @@ void ImeModeView::Update() {
label()->SetText(ime_controller->current_ime().short_name);
label()->SetEnabledColor(
TrayIconColor(Shell::Get()->session_controller()->GetSessionState()));
base::string16 description =
l10n_util::GetStringFUTF16(IDS_ASH_STATUS_TRAY_INDICATOR_IME_TOOLTIP,
ime_controller->current_ime().name);
label()->SetTooltipText(description);
label()->SetCustomAccessibleName(description);
Layout();
}
......
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