Index: ash/common/system/chromeos/ime_menu/ime_menu_tray.cc |
diff --git a/ash/common/system/chromeos/ime_menu/ime_menu_tray.cc b/ash/common/system/chromeos/ime_menu/ime_menu_tray.cc |
index 6defd83cdc7e06b58e5413e14f2ea3480baf0199..8c9e4306dcc7a25b3ba1412b924db61fc9c3d1c2 100644 |
--- a/ash/common/system/chromeos/ime_menu/ime_menu_tray.cc |
+++ b/ash/common/system/chromeos/ime_menu/ime_menu_tray.cc |
@@ -23,6 +23,7 @@ |
#include "base/strings/utf_string_conversions.h" |
#include "grit/ash_resources.h" |
#include "grit/ash_strings.h" |
+#include "ui/base/ime/chromeos/input_method_manager.h" |
#include "ui/base/l10n/l10n_util.h" |
#include "ui/base/resource/resource_bundle.h" |
#include "ui/views/controls/label.h" |
@@ -32,6 +33,8 @@ namespace ash { |
namespace { |
+const int button_right_border = 1; |
James Cook
2016/09/12 17:05:56
nit: kButtonRightBorder and comment
Azure Wei
2016/09/14 06:53:28
Done.
|
+ |
// Returns the max height of ImeListView. |
int GetImeListViewMaxHeight() { |
const int max_items = 7; |
@@ -83,10 +86,14 @@ class ImeButtonsView : public views::View, |
public views::ButtonListener, |
public ViewClickListener { |
public: |
- ImeButtonsView(bool show_emoji_button, |
+ ImeButtonsView(ImeMenuTray* ime_menu_tray, |
+ bool show_emoji_button, |
bool show_voice_button, |
bool show_handwriting_button, |
- bool show_settings_button) { |
+ bool show_settings_button) |
+ : ime_menu_tray_(ime_menu_tray) { |
+ DCHECK(ime_menu_tray_); |
+ |
SetBorder( |
views::Border::CreateSolidSidedBorder(1, 0, 0, 0, kBorderDarkColor)); |
@@ -116,20 +123,31 @@ class ImeButtonsView : public views::View, |
// views::ButtonListener: |
void ButtonPressed(views::Button* sender, const ui::Event& event) override { |
- if (emoji_button_ && sender == emoji_button_) { |
- // TODO(azurewei): Opens emoji palette. |
- } else if (voice_button_ && sender == voice_button_) { |
- // TODO(azurewei): Brings virtual keyboard for emoji input. |
- } else if (handwriting_button_ && sender == handwriting_button_) { |
- // TODO(azurewei): Brings virtual keyboard for handwriting input. |
- } else if (settings_button_ && sender == settings_button_) { |
+ if (settings_button_ && sender == settings_button_) { |
James Cook
2016/09/12 17:05:56
you don't need "settings_button_ &&"
Azure Wei
2016/09/14 06:53:28
Done.
|
+ ime_menu_tray_->HideImeMenuBubble(); |
ShowIMESettings(); |
+ return; |
} |
+ |
+ std::string keyset; |
+ if (sender == emoji_button_) |
+ keyset = "emoji"; |
+ else if (sender == voice_button_) |
+ keyset = "voice"; |
+ else if (sender == handwriting_button_) |
+ keyset = "handwriting"; |
+ else |
+ NOTREACHED(); |
+ |
+ ime_menu_tray_->HideImeMenuBubble(); |
+ chromeos::input_method::InputMethodManager::Get()->ShowInputViewWithKeyset( |
+ keyset); |
} |
// ViewClickListener: |
void OnViewClicked(views::View* sender) override { |
if (one_settings_button_view_ && sender == one_settings_button_view_) { |
+ ime_menu_tray_->HideImeMenuBubble(); |
ShowIMESettings(); |
} |
} |
@@ -164,14 +182,32 @@ class ImeButtonsView : public views::View, |
if (show_emoji_button) { |
// TODO(azurewei): Creates the proper button with icons. |
+ emoji_button_ = CreateImeMenuButton( |
+ this, IDR_AURA_UBER_TRAY_SETTINGS, IDR_AURA_UBER_TRAY_SETTINGS, |
+ IDR_AURA_UBER_TRAY_SETTINGS, IDR_AURA_UBER_TRAY_SETTINGS, |
+ IDS_ASH_STATUS_TRAY_SETTINGS, IDS_ASH_STATUS_TRAY_SETTINGS, |
+ button_right_border); |
+ AddChildView(emoji_button_); |
} |
if (show_voice_button) { |
// TODO(azurewei): Creates the proper button with icons. |
+ voice_button_ = CreateImeMenuButton( |
+ this, IDR_AURA_UBER_TRAY_SETTINGS, IDR_AURA_UBER_TRAY_SETTINGS, |
+ IDR_AURA_UBER_TRAY_SETTINGS, IDR_AURA_UBER_TRAY_SETTINGS, |
+ IDS_ASH_STATUS_TRAY_SETTINGS, IDS_ASH_STATUS_TRAY_SETTINGS, |
+ button_right_border); |
+ AddChildView(voice_button_); |
} |
if (show_handwriting_button) { |
// TODO(azurewei): Creates the proper button with icons. |
+ handwriting_button_ = CreateImeMenuButton( |
+ this, IDR_AURA_UBER_TRAY_SETTINGS, IDR_AURA_UBER_TRAY_SETTINGS, |
+ IDR_AURA_UBER_TRAY_SETTINGS, IDR_AURA_UBER_TRAY_SETTINGS, |
+ IDS_ASH_STATUS_TRAY_SETTINGS, IDS_ASH_STATUS_TRAY_SETTINGS, |
+ button_right_border); |
+ AddChildView(handwriting_button_); |
} |
if (show_settings_button) { |
@@ -183,6 +219,7 @@ class ImeButtonsView : public views::View, |
} |
} |
+ ImeMenuTray* ime_menu_tray_; |
TrayPopupHeaderButton* emoji_button_; |
TrayPopupHeaderButton* voice_button_; |
TrayPopupHeaderButton* handwriting_button_; |
@@ -234,13 +271,29 @@ void ImeMenuTray::ShowImeMenuBubble() { |
LoginStatus login = |
WmShell::Get()->system_tray_delegate()->GetUserLoginStatus(); |
if (login != LoginStatus::NOT_LOGGED_IN && login != LoginStatus::LOCKED && |
- !WmShell::Get()->GetSessionStateDelegate()->IsInSecondaryLoginScreen()) |
- bubble_view->AddChildView(new ImeButtonsView(false, false, false, true)); |
+ !WmShell::Get()->GetSessionStateDelegate()->IsInSecondaryLoginScreen()) { |
+ if (chromeos::input_method::InputMethodManager::Get() && |
James Cook
2016/09/12 17:05:56
optional: "using chromeos::input_method::InputMeth
Azure Wei
2016/09/14 06:53:28
Done.
|
+ chromeos::input_method::InputMethodManager::Get() |
+ ->IsEHVInputOnImeMenuEnabled() && |
+ !current_ime_.third_party) { |
+ bubble_view->AddChildView( |
+ new ImeButtonsView(this, true, true, true, true)); |
+ } else { |
+ bubble_view->AddChildView( |
+ new ImeButtonsView(this, false, false, false, true)); |
+ } |
+ } |
bubble_.reset(new TrayBubbleWrapper(this, bubble_view)); |
SetDrawBackgroundAsActive(true); |
} |
+void ImeMenuTray::HideImeMenuBubble() { |
+ bubble_.reset(); |
+ ime_list_view_ = nullptr; |
+ SetDrawBackgroundAsActive(false); |
+} |
+ |
bool ImeMenuTray::IsImeMenuBubbleShown() { |
return !!bubble_; |
} |
@@ -350,10 +403,4 @@ void ImeMenuTray::UpdateTrayLabel() { |
label_->SetText(current_ime_.short_name); |
} |
-void ImeMenuTray::HideImeMenuBubble() { |
- bubble_.reset(); |
- ime_list_view_ = nullptr; |
- SetDrawBackgroundAsActive(false); |
-} |
- |
} // namespace ash |