Commit a4ae295a authored by Regan Hsu's avatar Regan Hsu Committed by Chromium LUCI CQ

[CrOS PhoneHub] Show enabled background color for disabled DND button.

If the "Silence phone" button is disabled, but the phone is silenced,
change the background color of the disabled button to enabled background
color with the same disabled background opacity.

Screenshots:
Disabled and off - https://screenshot.googleplex.com/8iXioEXF9H6osoP
Disabled and on - https://screenshot.googleplex.com/6q7mkrQLPUk4zQr

Fixed: 1155784
Bug: 1106937
Change-Id: I26ac0ab132115f7e91efcece422945991fbdd09d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2605224Reviewed-by: default avatarJenny Zhang <jennyz@chromium.org>
Reviewed-by: default avatarKyle Horimoto <khorimoto@chromium.org>
Commit-Queue: Regan Hsu <hsuregan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#840564}
parent b47eea78
......@@ -45,6 +45,9 @@ QuickActionItem* SilencePhoneQuickActionController::CreateItem() {
item_ = new QuickActionItem(this, IDS_ASH_PHONE_HUB_SILENCE_PHONE_TITLE,
kPhoneHubSilencePhoneOnIcon,
kPhoneHubSilencePhoneOffIcon);
item_->icon_button()->set_button_behavior(
FeaturePodIconButton::DisabledButtonBehavior::
kCanDisplayDisabledToggleValue);
OnDndStateChanged();
return item_;
}
......@@ -106,7 +109,6 @@ void SilencePhoneQuickActionController::SetItemState(ActionState state) {
sub_label_text = IDS_ASH_PHONE_HUB_QUICK_ACTIONS_ON_STATE;
break;
case ActionState::kDisabled:
// TODO(1155784): Update disabled view with matching toggle-state colors.
icon_enabled = dnd_controller_->IsDndEnabled();
button_enabled = false;
state_text_id = IDS_ASH_PHONE_HUB_SILENCE_BUTTON_NOT_AVAILABLE_TOOLTIP;
......
......@@ -92,14 +92,20 @@ void FeaturePodIconButton::PaintButtonContents(gfx::Canvas* canvas) {
const AshColorProvider* color_provider = AshColorProvider::Get();
SkColor color = color_provider->GetControlsLayerColor(
ControlsLayerType::kControlBackgroundColorInactive);
if (GetEnabled()) {
if (toggled_) {
color = color_provider->GetControlsLayerColor(
ControlsLayerType::kControlBackgroundColorActive);
}
} else {
color = AshColorProvider::GetDisabledColor(color);
bool should_show_button_toggled_on =
toggled_ && (GetEnabled() ||
button_behavior_ ==
DisabledButtonBehavior::kCanDisplayDisabledToggleValue);
if (should_show_button_toggled_on) {
color = color_provider->GetControlsLayerColor(
ControlsLayerType::kControlBackgroundColorActive);
}
// If the button is disabled, apply opacity filter to the color.
if (!GetEnabled())
color = AshColorProvider::GetDisabledColor(color);
flags.setColor(color);
flags.setStyle(cc::PaintFlags::kFill_Style);
......
......@@ -23,6 +23,15 @@ class FeaturePodControllerBase;
// A toggle button with an icon used by feature pods and in other places.
class FeaturePodIconButton : public views::ImageButton {
public:
// Used to determine how the button will behave when disabled.
enum class DisabledButtonBehavior {
// The button will display toggle button as off.
kNone = 0,
// The button will display on/off status of toggle.
kCanDisplayDisabledToggleValue = 1,
};
FeaturePodIconButton(PressedCallback callback, bool is_togglable);
~FeaturePodIconButton() override;
......@@ -32,6 +41,10 @@ class FeaturePodIconButton : public views::ImageButton {
// Sets the button's icon.
void SetVectorIcon(const gfx::VectorIcon& icon);
void set_button_behavior(DisabledButtonBehavior button_behavior) {
button_behavior_ = button_behavior;
}
// views::ImageButton:
void PaintButtonContents(gfx::Canvas* canvas) override;
std::unique_ptr<views::InkDrop> CreateInkDrop() override;
......@@ -55,6 +68,8 @@ class FeaturePodIconButton : public views::ImageButton {
// True if the button is currently toggled.
bool toggled_ = false;
DisabledButtonBehavior button_behavior_ = DisabledButtonBehavior::kNone;
const gfx::VectorIcon* icon_ = nullptr;
DISALLOW_COPY_AND_ASSIGN(FeaturePodIconButton);
......
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