Commit c439739b authored by Andre Le's avatar Andre Le Committed by Commit Bot

[CrOS PhoneHub] Change text color when enable hotspot is connected.

Add a function to change sub label's text color in QuickActionItem,
which is used in enable hotspot to change the color to green when
connected.

Bug: 1106937,1126208
Change-Id: Ia892551bd7d60ea1131b6d5c84f60cd6951b8e83
Fixed: 1144843
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2512547Reviewed-by: default avatarKyle Horimoto <khorimoto@chromium.org>
Reviewed-by: default avatarTim Song <tengs@chromium.org>
Commit-Queue: Andre Le <leandre@chromium.org>
Cr-Commit-Position: refs/heads/master@{#823340}
parent 476ebf36
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "ash/resources/vector_icons/vector_icons.h" #include "ash/resources/vector_icons/vector_icons.h"
#include "ash/strings/grit/ash_strings.h" #include "ash/strings/grit/ash_strings.h"
#include "ash/style/ash_color_provider.h"
#include "ash/system/phonehub/phone_hub_metrics.h" #include "ash/system/phonehub/phone_hub_metrics.h"
#include "ash/system/phonehub/quick_action_item.h" #include "ash/system/phonehub/quick_action_item.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
...@@ -74,26 +75,34 @@ void EnableHotspotQuickActionController::SetState(ActionState state) { ...@@ -74,26 +75,34 @@ void EnableHotspotQuickActionController::SetState(ActionState state) {
bool icon_enabled; bool icon_enabled;
int state_text_id; int state_text_id;
int sub_label_text; int sub_label_text;
SkColor sub_label_color;
switch (state) { switch (state) {
case ActionState::kOff: case ActionState::kOff:
icon_enabled = false; icon_enabled = false;
state_text_id = IDS_ASH_PHONE_HUB_QUICK_ACTIONS_DISABLED_STATE_TOOLTIP; state_text_id = IDS_ASH_PHONE_HUB_QUICK_ACTIONS_DISABLED_STATE_TOOLTIP;
sub_label_text = IDS_ASH_PHONE_HUB_QUICK_ACTIONS_OFF_STATE; sub_label_text = IDS_ASH_PHONE_HUB_QUICK_ACTIONS_OFF_STATE;
sub_label_color = AshColorProvider::Get()->GetContentLayerColor(
AshColorProvider::ContentLayerType::kTextColorSecondary);
break; break;
case ActionState::kConnecting: case ActionState::kConnecting:
icon_enabled = true; icon_enabled = true;
state_text_id = IDS_ASH_PHONE_HUB_QUICK_ACTIONS_CONNECTING_STATE_TOOLTIP; state_text_id = IDS_ASH_PHONE_HUB_QUICK_ACTIONS_CONNECTING_STATE_TOOLTIP;
sub_label_text = IDS_ASH_PHONE_HUB_QUICK_ACTIONS_CONNECTING_STATE; sub_label_text = IDS_ASH_PHONE_HUB_QUICK_ACTIONS_CONNECTING_STATE;
sub_label_color = AshColorProvider::Get()->GetContentLayerColor(
AshColorProvider::ContentLayerType::kTextColorSecondary);
break; break;
case ActionState::kConnected: case ActionState::kConnected:
icon_enabled = true; icon_enabled = true;
state_text_id = IDS_ASH_PHONE_HUB_QUICK_ACTIONS_CONNECTED_STATE_TOOLTIP; state_text_id = IDS_ASH_PHONE_HUB_QUICK_ACTIONS_CONNECTED_STATE_TOOLTIP;
sub_label_text = IDS_ASH_PHONE_HUB_QUICK_ACTIONS_CONNECTED_STATE; sub_label_text = IDS_ASH_PHONE_HUB_QUICK_ACTIONS_CONNECTED_STATE;
sub_label_color = AshColorProvider::Get()->GetContentLayerColor(
AshColorProvider::ContentLayerType::kTextColorPositive);
break; break;
} }
item_->SetToggled(icon_enabled); item_->SetToggled(icon_enabled);
item_->SetSubLabel(l10n_util::GetStringUTF16(sub_label_text)); item_->SetSubLabel(l10n_util::GetStringUTF16(sub_label_text));
item_->SetSubLabelColor(sub_label_color);
base::string16 tooltip_state = base::string16 tooltip_state =
l10n_util::GetStringFUTF16(state_text_id, item_->GetItemLabel()); l10n_util::GetStringFUTF16(state_text_id, item_->GetItemLabel());
item_->SetIconTooltip( item_->SetIconTooltip(
......
...@@ -63,6 +63,9 @@ QuickActionItem::QuickActionItem(Delegate* delegate, ...@@ -63,6 +63,9 @@ QuickActionItem::QuickActionItem(Delegate* delegate,
ConfigureLabel(sub_label_, kUnifiedFeaturePodSubLabelLineHeight, ConfigureLabel(sub_label_, kUnifiedFeaturePodSubLabelLineHeight,
kUnifiedFeaturePodSubLabelFontSize); kUnifiedFeaturePodSubLabelFontSize);
sub_label_color_ = AshColorProvider::Get()->GetContentLayerColor(
AshColorProvider::ContentLayerType::kTextColorSecondary);
SetEnabled(true /* enabled */); SetEnabled(true /* enabled */);
SetPaintToLayer(); SetPaintToLayer();
...@@ -80,6 +83,13 @@ void QuickActionItem::SetSubLabel(const base::string16& sub_label) { ...@@ -80,6 +83,13 @@ void QuickActionItem::SetSubLabel(const base::string16& sub_label) {
sub_label_->SetText(sub_label); sub_label_->SetText(sub_label);
} }
void QuickActionItem::SetSubLabelColor(SkColor color) {
if (sub_label_color_ == color)
return;
sub_label_color_ = color;
sub_label_->SetEnabledColor(sub_label_color_);
}
void QuickActionItem::SetIcon(bool is_on) { void QuickActionItem::SetIcon(bool is_on) {
icon_button_->SetVectorIcon(is_on ? icon_on_ : icon_off_); icon_button_->SetVectorIcon(is_on ? icon_on_ : icon_off_);
} }
...@@ -120,8 +130,7 @@ void QuickActionItem::SetEnabled(bool enabled) { ...@@ -120,8 +130,7 @@ void QuickActionItem::SetEnabled(bool enabled) {
} else { } else {
label_->SetEnabledColor(AshColorProvider::Get()->GetContentLayerColor( label_->SetEnabledColor(AshColorProvider::Get()->GetContentLayerColor(
AshColorProvider::ContentLayerType::kTextColorPrimary)); AshColorProvider::ContentLayerType::kTextColorPrimary));
sub_label_->SetEnabledColor(AshColorProvider::Get()->GetContentLayerColor( sub_label_->SetEnabledColor(sub_label_color_);
AshColorProvider::ContentLayerType::kTextColorSecondary));
} }
} }
......
...@@ -44,6 +44,9 @@ class ASH_EXPORT QuickActionItem : public views::View, ...@@ -44,6 +44,9 @@ class ASH_EXPORT QuickActionItem : public views::View,
// Set the text of sub-label shown below the label. // Set the text of sub-label shown below the label.
void SetSubLabel(const base::string16& sub_label); void SetSubLabel(const base::string16& sub_label);
// Set the color of sub-label shown below the label.
void SetSubLabelColor(SkColor color);
// Set the icon button to be either |icon_on_| or |icon_off_|. // Set the icon button to be either |icon_on_| or |icon_off_|.
void SetIcon(bool is_on); void SetIcon(bool is_on);
...@@ -81,6 +84,9 @@ class ASH_EXPORT QuickActionItem : public views::View, ...@@ -81,6 +84,9 @@ class ASH_EXPORT QuickActionItem : public views::View,
const gfx::VectorIcon& icon_off_; const gfx::VectorIcon& icon_off_;
views::Label* label_ = nullptr; views::Label* label_ = nullptr;
views::Label* sub_label_ = nullptr; views::Label* sub_label_ = nullptr;
// Enabled color of the sub label.
SkColor sub_label_color_;
}; };
} // namespace ash } // namespace ash
......
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