Commit 1e82cae4 authored by Meilin Wang's avatar Meilin Wang Committed by Commit Bot

[CrOS PhoneHub] Add Bluetooth disabled UI.

This CL adds the Bluetooth disabled UI which will pop up when the Phone
Hub feature is not available because Bluetooth is turned off on this
device. Remaining work includes implementing button click handlers.

Sreenshot: https://screenshot.googleplex.com/65m7heuR4rJrK4e.png

BUG=1106937,1126208

Change-Id: I884d0ef250ceb5d283c69c555726abd0b0d80a81
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2417542
Commit-Queue: Meilin Wang <meilinw@chromium.org>
Reviewed-by: default avatarTim Song <tengs@chromium.org>
Reviewed-by: default avatarKyle Horimoto <khorimoto@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#809045}
parent 63539a76
......@@ -1098,6 +1098,8 @@ component("ash") {
"system/palette/tools/magnifier_mode.h",
"system/palette/tools/metalayer_mode.cc",
"system/palette/tools/metalayer_mode.h",
"system/phonehub/bluetooth_disabled_view.cc",
"system/phonehub/bluetooth_disabled_view.h",
"system/phonehub/connection_error_view.cc",
"system/phonehub/connection_error_view.h",
"system/phonehub/continue_browsing_chip.cc",
......
......@@ -1020,6 +1020,18 @@ This file contains the strings for ash.
<message name="IDS_ASH_PHONE_HUB_CONNECTION_ERROR_DIALOG_LEARN_MORE_BUTTON" desc="Learn more button on the connection error dialog to show more related information.">
Learn more
</message>
<message name="IDS_ASH_PHONE_HUB_BLUETOOTH_DISABLED_DIALOG_TITLE" desc="The title of the dialog that pops up when the phone hub feature is not available because Bluetooth is disabled on this device.">
Uh Oh! Check your connection
</message>
<message name="IDS_ASH_PHONE_HUB_BLUETOOTH_DISABLED_DIALOG_DESCRIPTION" desc="The description of the dialog that pops up when the phone hub feature is not available because Bluetooth is disabled on this device.">
Looks like your Bluetooth or Wi-Fi is turned off on your Chromebook. Please check your connection to use Phone Hub.
</message>
<message name="IDS_ASH_PHONE_HUB_BLUETOOTH_DISABLED_DIALOG_OK_BUTTON" desc="Confirm button on the bluetooth disabled dialog to acknowledge.">
Ok, got it
</message>
<message name="IDS_ASH_PHONE_HUB_BLUETOOTH_DISABLED_DIALOG_LEARN_MORE_BUTTON" desc="Learn more button on the bluetooth disabled dialog to show more related information.">
Learn more
</message>
<message name="IDS_ASH_PHONE_HUB_NOTIFICATION_INLINE_REPLY_BUTTON" desc="Label for the inline reply button inside a PhoneHub notification.">
Reply
</message>
......
17de05a6cb257232bfafaf3b29b6bc674ab83a4a
\ No newline at end of file
5462038ba050e40c9720b32d4c28db9147718663
\ No newline at end of file
7f929b6d2a52948689f337fae1f43d26610cb34a
\ No newline at end of file
582e2049918105497eaef5e364fd6089b483e156
\ No newline at end of file
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/system/phonehub/bluetooth_disabled_view.h"
#include "ash/public/cpp/resources/grit/ash_public_unscaled_resources.h"
#include "ash/strings/grit/ash_strings.h"
#include "ash/style/ash_color_provider.h"
#include "ash/system/phonehub/phone_hub_interstitial_view.h"
#include "ash/system/unified/rounded_label_button.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/views/layout/fill_layout.h"
namespace ash {
namespace {
// Tag value used to uniquely identify the "Learn More" and "Ok, got it"
// buttons.
constexpr int kLearnMoreButtonTag = 1;
constexpr int kOkButtonTag = 2;
} // namespace
BluetoothDisabledView::BluetoothDisabledView() {
SetLayoutManager(std::make_unique<views::FillLayout>());
content_view_ = AddChildView(
std::make_unique<PhoneHubInterstitialView>(/*show_progress=*/false));
// TODO(crbug.com/1127996): Replace PNG file with vector icon.
gfx::ImageSkia* image =
ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
IDR_PHONE_HUB_ERROR_STATE_IMAGE);
content_view_->SetImage(*image);
content_view_->SetTitle(l10n_util::GetStringUTF16(
IDS_ASH_PHONE_HUB_BLUETOOTH_DISABLED_DIALOG_TITLE));
content_view_->SetDescription(l10n_util::GetStringUTF16(
IDS_ASH_PHONE_HUB_BLUETOOTH_DISABLED_DIALOG_DESCRIPTION));
// Add "Learn more" and "Ok, got it" buttons.
auto learn_more = std::make_unique<views::LabelButton>(
this, l10n_util::GetStringUTF16(
IDS_ASH_PHONE_HUB_BLUETOOTH_DISABLED_DIALOG_LEARN_MORE_BUTTON));
learn_more->SetEnabledTextColors(
AshColorProvider::Get()->GetContentLayerColor(
AshColorProvider::ContentLayerType::kTextColorPrimary));
learn_more->set_tag(kLearnMoreButtonTag);
content_view_->AddButton(std::move(learn_more));
auto refresh = std::make_unique<RoundedLabelButton>(
this, l10n_util::GetStringUTF16(
IDS_ASH_PHONE_HUB_BLUETOOTH_DISABLED_DIALOG_OK_BUTTON));
refresh->set_tag(kOkButtonTag);
content_view_->AddButton(std::move(refresh));
}
BluetoothDisabledView::~BluetoothDisabledView() = default;
void BluetoothDisabledView::ButtonPressed(views::Button* sender,
const ui::Event& event) {
// TODO(crbug.com/1126208): implement button pressed actions.
}
BEGIN_METADATA(BluetoothDisabledView, views::View)
END_METADATA
} // namespace ash
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_SYSTEM_PHONEHUB_BLUETOOTH_DISABLED_VIEW_H_
#define ASH_SYSTEM_PHONEHUB_BLUETOOTH_DISABLED_VIEW_H_
#include "ash/ash_export.h"
#include "ash/system/phonehub/phone_hub_interstitial_view.h"
#include "ui/views/controls/button/button.h"
namespace ash {
class PhoneHubInterstitialView;
// An interstitial view representing an error state where the Phone Hub
// feature is not available because Bluetooth is turned off on this device.
class ASH_EXPORT BluetoothDisabledView : public views::View,
public views::ButtonListener {
public:
METADATA_HEADER(BluetoothDisabledView);
BluetoothDisabledView();
BluetoothDisabledView(const BluetoothDisabledView&) = delete;
BluetoothDisabledView& operator=(const BluetoothDisabledView&) = delete;
~BluetoothDisabledView() override;
// views::ButtonListener:
void ButtonPressed(views::Button* sender, const ui::Event& event) override;
private:
PhoneHubInterstitialView* content_view_ = nullptr;
};
} // namespace ash
#endif // ASH_SYSTEM_PHONEHUB_BLUETOOTH_DISABLED_VIEW_H_
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