Commit 07195a95 authored by Thomas Tellier's avatar Thomas Tellier Committed by Commit Bot

Add SystemButton class for sign-in error messages; update icon and string

Bug: 1010259
Change-Id: I1c05b5cee396cb3bfa9ecf91e5f15700958d73aa
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1900000
Commit-Queue: Thomas Tellier <tellier@google.com>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Reviewed-by: default avatarRoman Aleksandrov <raleksandrov@google.com>
Cr-Commit-Position: refs/heads/master@{#714465}
parent da0a55c8
...@@ -1817,6 +1817,9 @@ This file contains the strings for ash. ...@@ -1817,6 +1817,9 @@ This file contains the strings for ash.
<message name="IDS_ASH_LOGIN_PARENT_ACCESS_NEXT_NUMBER_PROMPT" desc="Accessible prompt read when next access code input field has been focused. Asks user to enter next piece of the access code."> <message name="IDS_ASH_LOGIN_PARENT_ACCESS_NEXT_NUMBER_PROMPT" desc="Accessible prompt read when next access code input field has been focused. Asks user to enter next piece of the access code.">
Next number Next number
</message> </message>
<message name="IDS_ASH_LOGIN_SIGN_IN_REQUIRED_MESSAGE" desc="Message shown in the login screen when online sign-in is required.">
Sign in required
</message>
<message name="IDS_ASH_LOGIN_SMART_CARD_SIGN_IN_MESSAGE" desc="Label for the button shown in the user pod that starts signing in via a smart card."> <message name="IDS_ASH_LOGIN_SMART_CARD_SIGN_IN_MESSAGE" desc="Label for the button shown in the user pod that starts signing in via a smart card.">
Sign in with smart card Sign in with smart card
</message> </message>
......
7cc1daa653d0cccf60f7d238cfe11025431c01a9
\ No newline at end of file
...@@ -50,6 +50,7 @@ ...@@ -50,6 +50,7 @@
#include "ui/views/border.h" #include "ui/views/border.h"
#include "ui/views/controls/button/label_button.h" #include "ui/views/controls/button/label_button.h"
#include "ui/views/controls/button/md_text_button.h" #include "ui/views/controls/button/md_text_button.h"
#include "ui/views/controls/highlight_path_generator.h"
#include "ui/views/layout/box_layout.h" #include "ui/views/layout/box_layout.h"
#include "ui/views/layout/fill_layout.h" #include "ui/views/layout/fill_layout.h"
#include "ui/views/layout/flex_layout.h" #include "ui/views/layout/flex_layout.h"
...@@ -80,9 +81,6 @@ constexpr SkColor kChallengeResponseArrowBackgroundColor = ...@@ -80,9 +81,6 @@ constexpr SkColor kChallengeResponseArrowBackgroundColor =
constexpr SkColor kChallengeResponseErrorColor = constexpr SkColor kChallengeResponseErrorColor =
SkColorSetRGB(0xEE, 0x67, 0x5C); SkColorSetRGB(0xEE, 0x67, 0x5C);
// The color of the online sign-in message text.
constexpr SkColor kOnlineSignInMessageColor = SkColorSetRGB(0xE6, 0x7C, 0x73);
// The color of the disabled auth message bubble when the color extracted from // The color of the disabled auth message bubble when the color extracted from
// wallpaper is transparent or invalid (i.e. color calculation fails or is // wallpaper is transparent or invalid (i.e. color calculation fails or is
// disabled). // disabled).
...@@ -121,6 +119,24 @@ constexpr int kDisabledAuthMessageRoundedCornerRadiusDp = 8; ...@@ -121,6 +119,24 @@ constexpr int kDisabledAuthMessageRoundedCornerRadiusDp = 8;
constexpr int kNonEmptyWidthDp = 1; constexpr int kNonEmptyWidthDp = 1;
// The color of the required online sign-in message text.
constexpr SkColor kSystemButtonMessageColor = SK_ColorBLACK;
// The background color of the required online sign-in button.
constexpr SkColor kSystemButtonBackgroundColor =
SkColorSetA(gfx::kGoogleRed300, SK_AlphaOPAQUE);
constexpr int kUserInfoBubbleWidth = 192;
constexpr int kUserInfoBubbleExternalPadding = 8;
constexpr int kSystemButtonIconSize = 20;
constexpr int kSystemButtonMarginTopBottomDp = 6;
constexpr int kSystemButtonMarginLeftRightDp = 16;
constexpr int kSystemButtonBorderRadius = 16;
constexpr int kSystemButtonImageLabelSpacing = 8;
constexpr int kSystemButtonMaxLabelWidthDp =
kUserInfoBubbleWidth - 2 * kUserInfoBubbleExternalPadding -
kSystemButtonIconSize - kSystemButtonImageLabelSpacing -
2 * kSystemButtonBorderRadius;
// Returns an observer that will hide |view| when it fires. The observer will // Returns an observer that will hide |view| when it fires. The observer will
// delete itself after firing (by returning true). Make sure to call // delete itself after firing (by returning true). Make sure to call
// |observer->SetActive()| after attaching it. // |observer->SetActive()| after attaching it.
...@@ -161,22 +177,69 @@ class ClearPasswordAndHideAnimationObserver ...@@ -161,22 +177,69 @@ class ClearPasswordAndHideAnimationObserver
DISALLOW_COPY_AND_ASSIGN(ClearPasswordAndHideAnimationObserver); DISALLOW_COPY_AND_ASSIGN(ClearPasswordAndHideAnimationObserver);
}; };
void DecorateOnlineSignInMessage(views::LabelButton* label_button) { SkPath GetSystemButtonHighlightPath(const views::View* view) {
label_button->SetPaintToLayer(); gfx::Rect rect(view->GetLocalBounds());
label_button->layer()->SetFillsBoundsOpaquely(false); return SkPath().addRoundRect(gfx::RectToSkRect(rect),
label_button->SetImage( kSystemButtonBorderRadius,
views::Button::STATE_NORMAL, kSystemButtonBorderRadius);
CreateVectorIcon(kLockScreenAlertIcon, kOnlineSignInMessageColor));
label_button->SetTextSubpixelRenderingEnabled(false);
label_button->SetTextColor(views::Button::STATE_NORMAL,
kOnlineSignInMessageColor);
label_button->SetTextColor(views::Button::STATE_HOVERED,
kOnlineSignInMessageColor);
label_button->SetTextColor(views::Button::STATE_PRESSED,
kOnlineSignInMessageColor);
label_button->SetBorder(views::CreateEmptyBorder(gfx::Insets(9, 0)));
} }
class SystemButtonHighlightPathGenerator
: public views::HighlightPathGenerator {
public:
SystemButtonHighlightPathGenerator() = default;
SystemButtonHighlightPathGenerator(
const SystemButtonHighlightPathGenerator&) = delete;
SystemButtonHighlightPathGenerator& operator=(
const SystemButtonHighlightPathGenerator&) = delete;
// views::HighlightPathGenerator:
SkPath GetHighlightPath(const views::View* view) override {
return GetSystemButtonHighlightPath(view);
}
};
class SystemButton : public views::LabelButton {
public:
SystemButton(views::ButtonListener* listener, const base::string16& text)
: LabelButton(listener, text) {
SetImageLabelSpacing(kSystemButtonImageLabelSpacing);
label()->SetMultiLine(true);
label()->SetMaximumWidth(kSystemButtonMaxLabelWidthDp);
label()->SetFontList(
gfx::FontList().DeriveWithWeight(gfx::Font::Weight::MEDIUM));
SetPaintToLayer();
layer()->SetFillsBoundsOpaquely(false);
SetImage(views::Button::STATE_NORMAL,
CreateVectorIcon(kLockScreenAlertIcon, kSystemButtonMessageColor));
SetTextSubpixelRenderingEnabled(false);
SetTextColor(views::Button::STATE_NORMAL, kSystemButtonMessageColor);
SetTextColor(views::Button::STATE_HOVERED, kSystemButtonMessageColor);
SetTextColor(views::Button::STATE_PRESSED, kSystemButtonMessageColor);
views::HighlightPathGenerator::Install(
this, std::make_unique<SystemButtonHighlightPathGenerator>());
}
SystemButton(const SystemButton&) = delete;
SystemButton& operator=(const SystemButton&) = delete;
~SystemButton() override = default;
// views::LabelButton:
void PaintButtonContents(gfx::Canvas* canvas) override {
cc::PaintFlags flags;
flags.setAntiAlias(true);
flags.setColor(kSystemButtonBackgroundColor);
flags.setStyle(cc::PaintFlags::kFill_Style);
canvas->DrawPath(GetSystemButtonHighlightPath(this), flags);
}
gfx::Insets GetInsets() const override {
return gfx::Insets(
kSystemButtonMarginTopBottomDp, kSystemButtonMarginLeftRightDp,
kSystemButtonMarginTopBottomDp, kSystemButtonMarginLeftRightDp);
}
};
// The label shown below the fingerprint icon. // The label shown below the fingerprint icon.
class FingerprintLabel : public views::Label { class FingerprintLabel : public views::Label {
public: public:
...@@ -775,10 +838,9 @@ LoginAuthUserView::LoginAuthUserView(const LoginUserInfo& user, ...@@ -775,10 +838,9 @@ LoginAuthUserView::LoginAuthUserView(const LoginUserInfo& user,
callbacks.on_easy_unlock_icon_hovered, callbacks.on_easy_unlock_icon_hovered,
callbacks.on_easy_unlock_icon_tapped); callbacks.on_easy_unlock_icon_tapped);
auto online_sign_in_message = std::make_unique<views::LabelButton>( auto online_sign_in_message = std::make_unique<SystemButton>(
this, base::UTF8ToUTF16(user.basic_user_info.display_name)); this, l10n_util::GetStringUTF16(IDS_ASH_LOGIN_SIGN_IN_REQUIRED_MESSAGE));
online_sign_in_message_ = online_sign_in_message.get(); online_sign_in_message_ = online_sign_in_message.get();
DecorateOnlineSignInMessage(online_sign_in_message_);
auto disabled_auth_message = std::make_unique<DisabledAuthMessageView>(); auto disabled_auth_message = std::make_unique<DisabledAuthMessageView>();
disabled_auth_message_ = disabled_auth_message.get(); disabled_auth_message_ = disabled_auth_message.get();
...@@ -1172,7 +1234,7 @@ void LoginAuthUserView::UpdateForUser(const LoginUserInfo& user) { ...@@ -1172,7 +1234,7 @@ void LoginAuthUserView::UpdateForUser(const LoginUserInfo& user) {
if (user_changed) if (user_changed)
password_view_->Clear(); password_view_->Clear();
online_sign_in_message_->SetText( online_sign_in_message_->SetText(
base::UTF8ToUTF16(user.basic_user_info.display_name)); l10n_util::GetStringUTF16(IDS_ASH_LOGIN_SIGN_IN_REQUIRED_MESSAGE));
} }
void LoginAuthUserView::SetFingerprintState(FingerprintState state) { void LoginAuthUserView::SetFingerprintState(FingerprintState state) {
......
...@@ -2,40 +2,26 @@ ...@@ -2,40 +2,26 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
CANVAS_DIMENSIONS, 40,
MOVE_TO, 1.67f, 35,
LINE_TO, 38.33f, 35,
LINE_TO, 20, 3.33f,
LINE_TO, 1.67f, 35,
CLOSE,
MOVE_TO, 22, 30,
LINE_TO, 18, 30,
LINE_TO, 18, 26,
LINE_TO, 22, 26,
LINE_TO, 22, 30,
CLOSE,
MOVE_TO, 22, 23,
LINE_TO, 18, 23,
LINE_TO, 18, 16,
LINE_TO, 22, 16,
LINE_TO, 22, 23,
CLOSE
CANVAS_DIMENSIONS, 20, CANVAS_DIMENSIONS, 20,
MOVE_TO, 0.83f, 17.5f, MOVE_TO, 10.87f, 2.5f,
LINE_TO, 19.17f, 17.5f, R_LINE_TO, 8, 14,
LINE_TO, 10, 1.67f, ARC_TO, 1, 1, 0, 0, 1, 18, 18,
LINE_TO, 0.83f, 17.5f, H_LINE_TO, 2,
R_ARC_TO, 1, 1, 0, 0, 1, -0.87f, -1.5f,
R_LINE_TO, 8, -14,
R_ARC_TO, 1, 1, 0, 0, 1, 1.74f, 0,
CLOSE,
MOVE_TO, 10, 5.02f,
LINE_TO, 3.72f, 16,
R_H_LINE_TO, 12.55f,
CLOSE, CLOSE,
MOVE_TO, 10.83f, 15, MOVE_TO, 11, 13,
LINE_TO, 9.17f, 15, R_V_LINE_TO, 2,
LINE_TO, 9.17f, 13.33f, H_LINE_TO, 9,
LINE_TO, 10.83f, 13.33f, R_V_LINE_TO, -2,
LINE_TO, 10.83f, 15,
CLOSE, CLOSE,
MOVE_TO, 10.83f, 11.67f, R_MOVE_TO, 0, -5,
LINE_TO, 9.17f, 11.67f, R_V_LINE_TO, 4,
LINE_TO, 9.17f, 8.33f, H_LINE_TO, 9,
LINE_TO, 10.83f, 8.33f, V_LINE_TO, 8,
LINE_TO, 10.83f, 11.67f,
CLOSE CLOSE
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