Commit 65319733 authored by Meilin Wang's avatar Meilin Wang Committed by Commit Bot

[CrOS PhoneHub] Update onboarding dismiss prompt UI to spec.

Removes the header status view on top for the onboarding dismiss prompt
per spec.

Screenshot: https://screenshot.googleplex.com/9a6EphBjLrfBRyP

BUG=1106937

Change-Id: Icc66d781f2df91e7fb74cac1cbbd573225def2bf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2522117Reviewed-by: default avatarKyle Horimoto <khorimoto@chromium.org>
Reviewed-by: default avatarTim Song <tengs@chromium.org>
Commit-Queue: Meilin Wang <meilinw@chromium.org>
Cr-Commit-Position: refs/heads/master@{#824986}
parent 28020398
...@@ -176,9 +176,9 @@ class OnboardingDismissPromptView : public PhoneHubInterstitialView { ...@@ -176,9 +176,9 @@ class OnboardingDismissPromptView : public PhoneHubInterstitialView {
// OnboardingView ------------------------------------------------------------- // OnboardingView -------------------------------------------------------------
OnboardingView::OnboardingView( OnboardingView::OnboardingView(
chromeos::phonehub::OnboardingUiTracker* onboarding_ui_tracker, chromeos::phonehub::OnboardingUiTracker* onboarding_ui_tracker,
TrayBubbleView* bubble_view, Delegate* delegate,
OnboardingFlow onboarding_flow) OnboardingFlow onboarding_flow)
: onboarding_ui_tracker_(onboarding_ui_tracker), bubble_view_(bubble_view) { : onboarding_ui_tracker_(onboarding_ui_tracker), delegate_(delegate) {
SetID(PhoneHubViewID::kOnboardingView); SetID(PhoneHubViewID::kOnboardingView);
SetLayoutManager(std::make_unique<views::FillLayout>()); SetLayoutManager(std::make_unique<views::FillLayout>());
...@@ -207,8 +207,9 @@ void OnboardingView::ShowDismissPrompt() { ...@@ -207,8 +207,9 @@ void OnboardingView::ShowDismissPrompt() {
main_view_ = AddChildView( main_view_ = AddChildView(
std::make_unique<OnboardingDismissPromptView>(onboarding_ui_tracker_)); std::make_unique<OnboardingDismissPromptView>(onboarding_ui_tracker_));
// Updates bubble to handle size change with a different child view. // We don't show status header view on top for the dismiss prompt.
bubble_view_->UpdateBubble(); DCHECK(delegate_);
delegate_->HideStatusHeaderView();
} }
BEGIN_METADATA(OnboardingView, views::View) BEGIN_METADATA(OnboardingView, views::View)
......
...@@ -31,11 +31,16 @@ class ASH_EXPORT OnboardingView : public PhoneHubContentView { ...@@ -31,11 +31,16 @@ class ASH_EXPORT OnboardingView : public PhoneHubContentView {
public: public:
METADATA_HEADER(OnboardingView); METADATA_HEADER(OnboardingView);
class Delegate {
public:
virtual void HideStatusHeaderView() = 0;
};
// The different onboarding flows that are supported. // The different onboarding flows that are supported.
enum OnboardingFlow { kExistingMultideviceUser = 0, kNewMultideviceUser }; enum OnboardingFlow { kExistingMultideviceUser = 0, kNewMultideviceUser };
OnboardingView(chromeos::phonehub::OnboardingUiTracker* onboarding_ui_tracker, OnboardingView(chromeos::phonehub::OnboardingUiTracker* onboarding_ui_tracker,
TrayBubbleView* bubble_view, Delegate* delegate,
OnboardingFlow onboarding_flow); OnboardingFlow onboarding_flow);
OnboardingView(const OnboardingView&) = delete; OnboardingView(const OnboardingView&) = delete;
OnboardingView& operator=(const OnboardingView&) = delete; OnboardingView& operator=(const OnboardingView&) = delete;
...@@ -55,7 +60,7 @@ class ASH_EXPORT OnboardingView : public PhoneHubContentView { ...@@ -55,7 +60,7 @@ class ASH_EXPORT OnboardingView : public PhoneHubContentView {
PhoneHubInterstitialView* main_view_ = nullptr; PhoneHubInterstitialView* main_view_ = nullptr;
chromeos::phonehub::OnboardingUiTracker* onboarding_ui_tracker_ = nullptr; chromeos::phonehub::OnboardingUiTracker* onboarding_ui_tracker_ = nullptr;
TrayBubbleView* bubble_view_ = nullptr; Delegate* delegate_ = nullptr;
}; };
} // namespace ash } // namespace ash
......
...@@ -111,7 +111,7 @@ void PhoneHubTray::OnPhoneHubUiStateChanged() { ...@@ -111,7 +111,7 @@ void PhoneHubTray::OnPhoneHubUiStateChanged() {
DCHECK(ui_controller_.get()); DCHECK(ui_controller_.get());
std::unique_ptr<PhoneHubContentView> content_view = std::unique_ptr<PhoneHubContentView> content_view =
ui_controller_->CreateContentView(bubble_view); ui_controller_->CreateContentView(this);
if (!content_view.get()) { if (!content_view.get()) {
CloseBubble(); CloseBubble();
return; return;
...@@ -168,20 +168,16 @@ void PhoneHubTray::ShowBubble(bool show_by_click) { ...@@ -168,20 +168,16 @@ void PhoneHubTray::ShowBubble(bool show_by_click) {
bubble_view->set_margins(GetSecondaryBubbleInsets()); bubble_view->set_margins(GetSecondaryBubbleInsets());
bubble_view->SetBorder(views::CreateEmptyBorder(kBubblePadding)); bubble_view->SetBorder(views::CreateEmptyBorder(kBubblePadding));
// We will always have this phone status view on top of the bubble view // Creates header view on top for displaying phone status and settings icon.
// to display any available phone status and the settings icon. auto phone_status = ui_controller_->CreateStatusHeaderView(this);
std::unique_ptr<views::View> phone_status = phone_status_view_ = phone_status.get();
ui_controller_->CreateStatusHeaderView(this); DCHECK(phone_status_view_);
if (phone_status) { bubble_view->AddChildView(std::move(phone_status));
phone_status->SetPaintToLayer();
phone_status->layer()->SetFillsBoundsOpaquely(false);
bubble_view->AddChildView(std::move(phone_status));
}
// Other contents, i.e. the connected view and the interstitial views, // Other contents, i.e. the connected view and the interstitial views,
// will be positioned underneath the phone status view and updated based // will be positioned underneath the phone status view and updated based
// on the current mode. // on the current mode.
auto content_view = ui_controller_->CreateContentView(bubble_view); auto content_view = ui_controller_->CreateContentView(this);
content_view_ = content_view.get(); content_view_ = content_view.get();
DCHECK(content_view_); DCHECK(content_view_);
bubble_view->AddChildView(std::move(content_view)); bubble_view->AddChildView(std::move(content_view));
...@@ -224,6 +220,14 @@ void PhoneHubTray::OpenConnectedDevicesSettings() { ...@@ -224,6 +220,14 @@ void PhoneHubTray::OpenConnectedDevicesSettings() {
Shell::Get()->system_tray_model()->client()->ShowConnectedDevicesSettings(); Shell::Get()->system_tray_model()->client()->ShowConnectedDevicesSettings();
} }
void PhoneHubTray::HideStatusHeaderView() {
if (!phone_status_view_)
return;
phone_status_view_->SetVisible(false);
bubble_->bubble_view()->UpdateBubble();
}
void PhoneHubTray::CloseBubble() { void PhoneHubTray::CloseBubble() {
if (!bubble_) if (!bubble_)
return; return;
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#define ASH_SYSTEM_PHONEHUB_PHONE_HUB_TRAY_H_ #define ASH_SYSTEM_PHONEHUB_PHONE_HUB_TRAY_H_
#include "ash/ash_export.h" #include "ash/ash_export.h"
#include "ash/system/phonehub/onboarding_view.h"
#include "ash/system/phonehub/phone_hub_content_view.h" #include "ash/system/phonehub/phone_hub_content_view.h"
#include "ash/system/phonehub/phone_hub_ui_controller.h" #include "ash/system/phonehub/phone_hub_ui_controller.h"
#include "ash/system/phonehub/phone_status_view.h" #include "ash/system/phonehub/phone_status_view.h"
...@@ -30,6 +31,7 @@ class TrayBubbleWrapper; ...@@ -30,6 +31,7 @@ class TrayBubbleWrapper;
// This class represents the Phone Hub tray button in the status area and // This class represents the Phone Hub tray button in the status area and
// controls the bubble that is shown when the tray button is clicked. // controls the bubble that is shown when the tray button is clicked.
class ASH_EXPORT PhoneHubTray : public TrayBackgroundView, class ASH_EXPORT PhoneHubTray : public TrayBackgroundView,
public OnboardingView::Delegate,
public PhoneStatusView::Delegate, public PhoneStatusView::Delegate,
public PhoneHubUiController::Observer { public PhoneHubUiController::Observer {
public: public:
...@@ -59,6 +61,9 @@ class ASH_EXPORT PhoneHubTray : public TrayBackgroundView, ...@@ -59,6 +61,9 @@ class ASH_EXPORT PhoneHubTray : public TrayBackgroundView,
bool CanOpenConnectedDeviceSettings() override; bool CanOpenConnectedDeviceSettings() override;
void OpenConnectedDevicesSettings() override; void OpenConnectedDevicesSettings() override;
// OnboardingView::Delegate:
void HideStatusHeaderView() override;
views::View* content_view_for_testing() { return content_view_; } views::View* content_view_for_testing() { return content_view_; }
PhoneHubUiController* ui_controller_for_testing() { PhoneHubUiController* ui_controller_for_testing() {
...@@ -88,6 +93,9 @@ class ASH_EXPORT PhoneHubTray : public TrayBackgroundView, ...@@ -88,6 +93,9 @@ class ASH_EXPORT PhoneHubTray : public TrayBackgroundView,
// The bubble that appears after clicking the tray button. // The bubble that appears after clicking the tray button.
std::unique_ptr<TrayBubbleWrapper> bubble_; std::unique_ptr<TrayBubbleWrapper> bubble_;
// The header status view on top of the bubble.
views::View* phone_status_view_ = nullptr;
// The main content view of the bubble, which changes depending on the state. // The main content view of the bubble, which changes depending on the state.
// Unowned. // Unowned.
PhoneHubContentView* content_view_ = nullptr; PhoneHubContentView* content_view_ = nullptr;
......
...@@ -51,17 +51,17 @@ std::unique_ptr<views::View> PhoneHubUiController::CreateStatusHeaderView( ...@@ -51,17 +51,17 @@ std::unique_ptr<views::View> PhoneHubUiController::CreateStatusHeaderView(
} }
std::unique_ptr<PhoneHubContentView> PhoneHubUiController::CreateContentView( std::unique_ptr<PhoneHubContentView> PhoneHubUiController::CreateContentView(
TrayBubbleView* bubble_view) { OnboardingView::Delegate* delegate) {
switch (ui_state_) { switch (ui_state_) {
case UiState::kHidden: case UiState::kHidden:
return nullptr; return nullptr;
case UiState::kOnboardingWithoutPhone: case UiState::kOnboardingWithoutPhone:
return std::make_unique<OnboardingView>( return std::make_unique<OnboardingView>(
phone_hub_manager_->GetOnboardingUiTracker(), bubble_view, phone_hub_manager_->GetOnboardingUiTracker(), delegate,
OnboardingView::kNewMultideviceUser); OnboardingView::kNewMultideviceUser);
case UiState::kOnboardingWithPhone: case UiState::kOnboardingWithPhone:
return std::make_unique<OnboardingView>( return std::make_unique<OnboardingView>(
phone_hub_manager_->GetOnboardingUiTracker(), bubble_view, phone_hub_manager_->GetOnboardingUiTracker(), delegate,
OnboardingView::kExistingMultideviceUser); OnboardingView::kExistingMultideviceUser);
case UiState::kBluetoothDisabled: case UiState::kBluetoothDisabled:
return std::make_unique<BluetoothDisabledView>(); return std::make_unique<BluetoothDisabledView>();
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#define ASH_SYSTEM_PHONEHUB_PHONE_HUB_UI_CONTROLLER_H_ #define ASH_SYSTEM_PHONEHUB_PHONE_HUB_UI_CONTROLLER_H_
#include "ash/ash_export.h" #include "ash/ash_export.h"
#include "ash/system/phonehub/onboarding_view.h"
#include "ash/system/phonehub/phone_hub_content_view.h" #include "ash/system/phonehub/phone_hub_content_view.h"
#include "ash/system/phonehub/phone_status_view.h" #include "ash/system/phonehub/phone_status_view.h"
#include "base/observer_list.h" #include "base/observer_list.h"
...@@ -25,8 +26,6 @@ class View; ...@@ -25,8 +26,6 @@ class View;
namespace ash { namespace ash {
class TrayBubbleView;
// This controller translates the state received from PhoneHubManager into the // This controller translates the state received from PhoneHubManager into the
// corresponding main content view to be displayed in the tray bubble. // corresponding main content view to be displayed in the tray bubble.
class ASH_EXPORT PhoneHubUiController class ASH_EXPORT PhoneHubUiController
...@@ -65,7 +64,7 @@ class ASH_EXPORT PhoneHubUiController ...@@ -65,7 +64,7 @@ class ASH_EXPORT PhoneHubUiController
// Creates the corresponding content view for the current UI state. // Creates the corresponding content view for the current UI state.
// |bubble_view| will be the parent the created content view. // |bubble_view| will be the parent the created content view.
std::unique_ptr<PhoneHubContentView> CreateContentView( std::unique_ptr<PhoneHubContentView> CreateContentView(
TrayBubbleView* bubble_view); OnboardingView::Delegate* delegate);
// Creates the header view displaying the phone status. // Creates the header view displaying the phone status.
std::unique_ptr<views::View> CreateStatusHeaderView( std::unique_ptr<views::View> CreateStatusHeaderView(
......
...@@ -59,13 +59,13 @@ TEST_F(PhoneHubUiControllerTest, NotEligibleForFeature) { ...@@ -59,13 +59,13 @@ TEST_F(PhoneHubUiControllerTest, NotEligibleForFeature) {
GetFeatureStatusProvider()->SetStatus(FeatureStatus::kNotEligibleForFeature); GetFeatureStatusProvider()->SetStatus(FeatureStatus::kNotEligibleForFeature);
EXPECT_EQ(PhoneHubUiController::UiState::kHidden, controller_.ui_state()); EXPECT_EQ(PhoneHubUiController::UiState::kHidden, controller_.ui_state());
EXPECT_TRUE(ui_state_changed_); EXPECT_TRUE(ui_state_changed_);
EXPECT_FALSE(controller_.CreateContentView(/*bubble_view=*/nullptr).get()); EXPECT_FALSE(controller_.CreateContentView(/*delegate=*/nullptr).get());
} }
TEST_F(PhoneHubUiControllerTest, OnboardingNotEligible) { TEST_F(PhoneHubUiControllerTest, OnboardingNotEligible) {
GetFeatureStatusProvider()->SetStatus(FeatureStatus::kDisabled); GetFeatureStatusProvider()->SetStatus(FeatureStatus::kDisabled);
EXPECT_EQ(PhoneHubUiController::UiState::kHidden, controller_.ui_state()); EXPECT_EQ(PhoneHubUiController::UiState::kHidden, controller_.ui_state());
EXPECT_FALSE(controller_.CreateContentView(/*bubble_view=*/nullptr).get()); EXPECT_FALSE(controller_.CreateContentView(/*delegate=*/nullptr).get());
} }
TEST_F(PhoneHubUiControllerTest, ShowOnboardingUi_WithoutPhone) { TEST_F(PhoneHubUiControllerTest, ShowOnboardingUi_WithoutPhone) {
...@@ -78,7 +78,7 @@ TEST_F(PhoneHubUiControllerTest, ShowOnboardingUi_WithoutPhone) { ...@@ -78,7 +78,7 @@ TEST_F(PhoneHubUiControllerTest, ShowOnboardingUi_WithoutPhone) {
EXPECT_EQ(PhoneHubUiController::UiState::kOnboardingWithoutPhone, EXPECT_EQ(PhoneHubUiController::UiState::kOnboardingWithoutPhone,
controller_.ui_state()); controller_.ui_state());
auto content_view = controller_.CreateContentView(/*bubble_view=*/nullptr); auto content_view = controller_.CreateContentView(/*delegate=*/nullptr);
EXPECT_EQ(PhoneHubViewID::kOnboardingView, content_view->GetID()); EXPECT_EQ(PhoneHubViewID::kOnboardingView, content_view->GetID());
} }
...@@ -93,7 +93,7 @@ TEST_F(PhoneHubUiControllerTest, ShowOnboardingUi_WithPhone) { ...@@ -93,7 +93,7 @@ TEST_F(PhoneHubUiControllerTest, ShowOnboardingUi_WithPhone) {
EXPECT_EQ(PhoneHubUiController::UiState::kOnboardingWithPhone, EXPECT_EQ(PhoneHubUiController::UiState::kOnboardingWithPhone,
controller_.ui_state()); controller_.ui_state());
auto content_view = controller_.CreateContentView(/*bubble_view=*/nullptr); auto content_view = controller_.CreateContentView(/*delegate=*/nullptr);
EXPECT_EQ(PhoneHubViewID::kOnboardingView, content_view->GetID()); EXPECT_EQ(PhoneHubViewID::kOnboardingView, content_view->GetID());
} }
...@@ -103,7 +103,7 @@ TEST_F(PhoneHubUiControllerTest, PhoneConnectingForOnboarding) { ...@@ -103,7 +103,7 @@ TEST_F(PhoneHubUiControllerTest, PhoneConnectingForOnboarding) {
EXPECT_EQ(PhoneHubUiController::UiState::kInitialConnecting, EXPECT_EQ(PhoneHubUiController::UiState::kInitialConnecting,
controller_.ui_state()); controller_.ui_state());
auto content_view = controller_.CreateContentView(/*bubble_view=*/nullptr); auto content_view = controller_.CreateContentView(/*delegate=*/nullptr);
EXPECT_EQ(PhoneHubViewID::kInitialConnectingView, content_view->GetID()); EXPECT_EQ(PhoneHubViewID::kInitialConnectingView, content_view->GetID());
} }
...@@ -113,7 +113,7 @@ TEST_F(PhoneHubUiControllerTest, BluetoothOff) { ...@@ -113,7 +113,7 @@ TEST_F(PhoneHubUiControllerTest, BluetoothOff) {
EXPECT_EQ(PhoneHubUiController::UiState::kBluetoothDisabled, EXPECT_EQ(PhoneHubUiController::UiState::kBluetoothDisabled,
controller_.ui_state()); controller_.ui_state());
auto content_view = controller_.CreateContentView(/*bubble_view=*/nullptr); auto content_view = controller_.CreateContentView(/*delegate=*/nullptr);
EXPECT_EQ(PhoneHubViewID::kBluetoothDisabledView, content_view->GetID()); EXPECT_EQ(PhoneHubViewID::kBluetoothDisabledView, content_view->GetID());
} }
...@@ -122,7 +122,7 @@ TEST_F(PhoneHubUiControllerTest, PhoneDisconnected) { ...@@ -122,7 +122,7 @@ TEST_F(PhoneHubUiControllerTest, PhoneDisconnected) {
EXPECT_EQ(PhoneHubUiController::UiState::kConnectionError, EXPECT_EQ(PhoneHubUiController::UiState::kConnectionError,
controller_.ui_state()); controller_.ui_state());
auto content_view = controller_.CreateContentView(/*bubble_view=*/nullptr); auto content_view = controller_.CreateContentView(/*delegate=*/nullptr);
EXPECT_EQ(PhoneHubViewID::kDisconnectedView, content_view->GetID()); EXPECT_EQ(PhoneHubViewID::kDisconnectedView, content_view->GetID());
} }
...@@ -131,7 +131,7 @@ TEST_F(PhoneHubUiControllerTest, PhoneConnecting) { ...@@ -131,7 +131,7 @@ TEST_F(PhoneHubUiControllerTest, PhoneConnecting) {
EXPECT_EQ(PhoneHubUiController::UiState::kPhoneConnecting, EXPECT_EQ(PhoneHubUiController::UiState::kPhoneConnecting,
controller_.ui_state()); controller_.ui_state());
auto content_view = controller_.CreateContentView(/*bubble_view=*/nullptr); auto content_view = controller_.CreateContentView(/*delegate=*/nullptr);
EXPECT_EQ(PhoneHubViewID::kReconnectingView, content_view->GetID()); EXPECT_EQ(PhoneHubViewID::kReconnectingView, content_view->GetID());
} }
...@@ -140,7 +140,7 @@ TEST_F(PhoneHubUiControllerTest, PhoneConnected) { ...@@ -140,7 +140,7 @@ TEST_F(PhoneHubUiControllerTest, PhoneConnected) {
EXPECT_EQ(PhoneHubUiController::UiState::kPhoneConnected, EXPECT_EQ(PhoneHubUiController::UiState::kPhoneConnected,
controller_.ui_state()); controller_.ui_state());
auto content_view = controller_.CreateContentView(/*bubble_view=*/nullptr); auto content_view = controller_.CreateContentView(/*delegate=*/nullptr);
EXPECT_EQ(kPhoneConnectedView, content_view->GetID()); EXPECT_EQ(kPhoneConnectedView, content_view->GetID());
} }
......
...@@ -110,6 +110,8 @@ PhoneStatusView::PhoneStatusView(chromeos::phonehub::PhoneModel* phone_model, ...@@ -110,6 +110,8 @@ PhoneStatusView::PhoneStatusView(chromeos::phonehub::PhoneModel* phone_model,
battery_label_(new views::Label) { battery_label_(new views::Label) {
DCHECK(delegate); DCHECK(delegate);
SetPaintToLayer();
layer()->SetFillsBoundsOpaquely(false);
SetID(PhoneHubViewID::kPhoneStatusView); SetID(PhoneHubViewID::kPhoneStatusView);
SetBorder(views::CreateEmptyBorder(kBorderInsets)); SetBorder(views::CreateEmptyBorder(kBorderInsets));
......
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