 Chromium Code Reviews
 Chromium Code Reviews Issue 2381493005:
  Add bluetooth device type icons on MD system tray.  (Closed)
    
  
    Issue 2381493005:
  Add bluetooth device type icons on MD system tray.  (Closed) 
  | Index: ash/common/system/chromeos/bluetooth/tray_bluetooth.cc | 
| diff --git a/ash/common/system/chromeos/bluetooth/tray_bluetooth.cc b/ash/common/system/chromeos/bluetooth/tray_bluetooth.cc | 
| index c3cd91d650e401804fb35d316d98df250546cc4d..deb0c789a8c17eb986d988070c928adc72eecf46 100644 | 
| --- a/ash/common/system/chromeos/bluetooth/tray_bluetooth.cc | 
| +++ b/ash/common/system/chromeos/bluetooth/tray_bluetooth.cc | 
| @@ -23,8 +23,10 @@ | 
| #include "grit/ash_strings.h" | 
| #include "ui/base/l10n/l10n_util.h" | 
| #include "ui/base/resource/resource_bundle.h" | 
| +#include "ui/gfx/color_palette.h" | 
| #include "ui/gfx/image/image.h" | 
| #include "ui/gfx/paint_vector_icon.h" | 
| +#include "ui/gfx/vector_icons/vector_icons.h" | 
| 
tdanderson
2016/09/29 18:54:39
is this #include needed?
 
fukino
2016/09/30 02:43:49
Removed. Thanks!
 | 
| #include "ui/views/controls/button/toggle_button.h" | 
| #include "ui/views/controls/image_view.h" | 
| #include "ui/views/controls/label.h" | 
| @@ -230,10 +232,12 @@ class BluetoothDetailedView : public TrayDetailsView { | 
| } | 
| void UpdateHeaderEntry() { | 
| - if (toggle_bluetooth_) { | 
| - toggle_bluetooth_->SetToggled( | 
| - !WmShell::Get()->system_tray_delegate()->GetBluetoothEnabled()); | 
| - } | 
| + bool isBluetoothEnabled = | 
| + WmShell::Get()->system_tray_delegate()->GetBluetoothEnabled(); | 
| + if (toggle_) | 
| + toggle_->SetIsOn(isBluetoothEnabled, false); | 
| + if (toggle_bluetooth_) | 
| 
tdanderson
2016/09/29 18:54:39
nit: else if (since you'll never have both visible
 
fukino
2016/09/30 02:43:49
Done.
 | 
| + toggle_bluetooth_->SetToggled(!isBluetoothEnabled); | 
| } | 
| void UpdateDeviceScrollList() { | 
| @@ -279,9 +283,16 @@ class BluetoothDetailedView : public TrayDetailsView { | 
| bool checked, | 
| bool enabled) { | 
| for (size_t i = 0; i < list.size(); ++i) { | 
| - HoverHighlightView* container = | 
| - AddScrollListItem(list[i].display_name, highlight, checked, enabled); | 
| - device_map_[container] = list[i].address; | 
| + if (MaterialDesignController::IsSystemTrayMenuMaterial()) { | 
| + HoverHighlightView* container = | 
| + AddScrollListItemWithIcon(list[i].display_name, highlight, checked, | 
| + enabled, list[i].icon_image); | 
| + device_map_[container] = list[i].address; | 
| 
tdanderson
2016/09/29 18:54:39
nit: factor out lines 290 and 294 to after the if-
 
fukino
2016/09/30 02:43:49
Done. I used "md ? ... : ...";
 | 
| + } else { | 
| + HoverHighlightView* container = AddScrollListItem( | 
| + list[i].display_name, highlight, checked, enabled); | 
| + device_map_[container] = list[i].address; | 
| + } | 
| } | 
| } | 
| @@ -297,6 +308,25 @@ class BluetoothDetailedView : public TrayDetailsView { | 
| return container; | 
| } | 
| + HoverHighlightView* AddScrollListItemWithIcon(const base::string16& text, | 
| + bool highlight, | 
| + bool checked, | 
| + bool enabled, | 
| + const gfx::ImageSkia& image) { | 
| + HoverHighlightView* container = new HoverHighlightView(this); | 
| 
fukino
2016/09/29 16:27:36
This implementation to place icons/labels/etc... i
 
tdanderson
2016/09/29 18:54:39
Acknowledged. Whatever you do here is probably wha
 
fukino
2016/09/30 02:43:49
Thanks. I'll update this design next, and I'll mak
 | 
| + const int padding = (kMenuButtonSize - image.width()) / 2; | 
| + container->AddIconAndLabelCustomSize( | 
| + image, text, highlight, | 
| + image.width() + kMenuSeparatorVerticalPadding * 2, padding, padding); | 
| + gfx::ImageSkia check_mark = | 
| + CreateVectorIcon(gfx::VectorIconId::CHECK_CIRCLE, gfx::kGoogleGreen700); | 
| + container->AddRightIcon(check_mark, check_mark.width()); | 
| + container->SetRightIconVisible(checked); | 
| + container->text_label()->SetEnabled(enabled); | 
| + scroll_content()->AddChildView(container); | 
| + return container; | 
| + } | 
| + | 
| // Add settings entries. | 
| void AppendSettingsEntries() { | 
| if (!WmShell::Get()->system_tray_delegate()->ShouldShowSettings()) | 
| @@ -389,9 +419,10 @@ class BluetoothDetailedView : public TrayDetailsView { | 
| void HandleButtonPressed(views::Button* sender, | 
| const ui::Event& event) override { | 
| if (MaterialDesignController::IsSystemTrayMenuMaterial()) { | 
| - // TODO(fukino): Make the toggle button functional. | 
| if (sender == toggle_) | 
| - toggle_->SetIsOn(toggle_->is_on(), true); | 
| + WmShell::Get()->system_tray_delegate()->ToggleBluetooth(); | 
| + else | 
| + NOTREACHED(); | 
| return; | 
| } |