Commit b3f1a19a authored by Darwin Huang's avatar Darwin Huang Committed by Commit Bot

Revert "ambient: Show lockscreen contents on detecting user interaction."

This reverts commit 660c9cef.

Reason for revert: AmbientContainerViewTest.MouseClickClosesWidgetAndStopsTimer failing deterministically on several linux-chromeos bots. Please see https://crbug.com/1068745 for more information.

Original change's description:
> ambient: Show lockscreen contents on detecting user interaction.
> 
> In ambient mode, when user interacting with the background image by
> mouse or gesture, lock screen contents (login pod and media control
> view) need be shown on top for users to either do re-authentication,
> or media control.
> 
> This CL implements a prototype of this view transaction by:
> 1. Show the lock screen contents, and
> 2. Fade-out the current shown image.
> 
> Bug: b/149246238
> Test: manually.
> Change-Id: Ie31c666cdfaddefc863ff8173dc185d73ef19178
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2110689
> Commit-Queue: Meilin Wang <meilinw@chromium.org>
> Reviewed-by: Xiaohui Chen <xiaohuic@chromium.org>
> Reviewed-by: Xiyuan Xia <xiyuan@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#757120}

TBR=xiyuan@chromium.org,xiaohuic@chromium.org,wutao@chromium.org,meilinw@chromium.org

Change-Id: I395a7c02c6aa292f66ca5d9b4aefa9156e057773
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: b/149246238, 1068745
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2139369Reviewed-by: default avatarDarwin Huang <huangdarwin@chromium.org>
Commit-Queue: Darwin Huang <huangdarwin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#757223}
parent 5684371f
......@@ -11,7 +11,6 @@
#include "ash/ambient/ui/ambient_container_view.h"
#include "ash/ambient/util/ambient_util.h"
#include "ash/assistant/assistant_controller.h"
#include "ash/assistant/util/animation_util.h"
#include "ash/login/ui/lock_screen.h"
#include "ash/public/cpp/ambient/ambient_mode_state.h"
#include "ash/public/cpp/ambient/ambient_prefs.h"
......@@ -94,17 +93,20 @@ void AmbientController::OnAmbientModeEnabled(bool enabled) {
}
void AmbientController::OnLockStateChanged(bool locked) {
if (locked) {
// Show ambient mode when entering lock screen.
if (!locked) {
// We should already exit ambient mode at this time, as the ambient
// container needs to be closed to uncover the login port for
// re-authentication.
DCHECK(!container_view_);
Show();
} else {
// Destroy ambient mode after user re-login.
Destroy();
return;
}
// Show the ambient container on top of the lock screen.
DCHECK(!container_view_);
Start();
}
void AmbientController::Show() {
void AmbientController::Start() {
if (!CanStartAmbientMode()) {
// TODO(wutao): Show a toast to indicate that Ambient mode is not ready.
return;
......@@ -119,34 +121,14 @@ void AmbientController::Show() {
ambient_state_.SetAmbientModeEnabled(true);
}
void AmbientController::Destroy() {
void AmbientController::Stop() {
ambient_state_.SetAmbientModeEnabled(false);
}
void AmbientController::Toggle() {
if (container_view_)
Destroy();
Stop();
else
Show();
}
void AmbientController::OnBackgroundPhotoEvents() {
refresh_timer_.Stop();
// Move the |AmbientModeContainer| beneath the |LockScreenWidget| to show the
// lock screen contents on top before the fade-out animation.
auto* ambient_window = container_view_->GetWidget()->GetNativeWindow();
ambient_window->parent()->StackChildAtBottom(ambient_window);
// Start fading out the current background photo.
StartFadeOutAnimation();
}
void AmbientController::StartFadeOutAnimation() {
// We fade out the |PhotoView| on its own layer instead of using the general
// layer of the widget, otherwise it will reveal the color of the lockscreen
// wallpaper beneath.
container_view_->FadeOutPhotoView();
Start();
}
void AmbientController::CreateContainerView() {
......@@ -164,6 +146,9 @@ void AmbientController::DestroyContainerView() {
}
void AmbientController::RefreshImage() {
if (!PhotoController::Get())
return;
if (photo_model_.ShouldFetchImmediately()) {
// TODO(b/140032139): Defer downloading image if it is animating.
base::SequencedTaskRunnerHandle::Get()->PostDelayedTask(
......
......@@ -45,21 +45,12 @@ class ASH_EXPORT AmbientController : public views::WidgetObserver,
// SessionObserver:
void OnLockStateChanged(bool locked) override;
// Creates and displays the ambient mode screen on top of the lock screen.
void Show();
// Destroys the ambient mode screen widget.
void Destroy();
// Toggle between show and destroy the ambient mode screen.
// Should be removed once we delete the shortcut entry point.
void Start();
void Stop();
void Toggle();
PhotoModel* photo_model() { return &photo_model_; }
// Handles user interactions on the background photo. For now the behavior
// is showing lock screen contents (login pod and media control view) on top
// while fading-out the current shown image.
void OnBackgroundPhotoEvents();
AmbientContainerView* get_container_view_for_testing() {
return container_view_;
}
......@@ -78,8 +69,6 @@ class ASH_EXPORT AmbientController : public views::WidgetObserver,
void GetNextImage();
void OnPhotoDownloaded(bool success, const gfx::ImageSkia& image);
void StartFadeOutAnimation();
AmbientViewDelegateImpl delegate_{this};
AmbientContainerView* container_view_ = nullptr; // Owned by view hierarchy.
PhotoModel photo_model_;
......
......@@ -21,7 +21,18 @@ PhotoModel* AmbientViewDelegateImpl::GetPhotoModel() {
}
void AmbientViewDelegateImpl::OnBackgroundPhotoEvents() {
ambient_controller_->OnBackgroundPhotoEvents();
// Exit ambient mode by closing the widget when user interacts with the
// background photo using mouse or gestures. We do this asynchronously to
// ensure that for a mouse moved event, the widget will be destroyed *after*
// its cursor has been updated in |RootView::OnMouseMoved|.
base::SequencedTaskRunnerHandle::Get()->PostTask(
FROM_HERE,
base::BindOnce(
[](const base::WeakPtr<AmbientViewDelegateImpl>& weak_ptr) {
if (weak_ptr)
weak_ptr->ambient_controller_->Stop();
},
weak_factory_.GetWeakPtr()));
}
} // namespace ash
......@@ -12,7 +12,6 @@
#include "ash/ambient/ui/photo_view.h"
#include "ash/ambient/util/ambient_util.h"
#include "ash/assistant/assistant_controller.h"
#include "ash/assistant/util/animation_util.h"
#include "ash/login/ui/lock_screen.h"
#include "ash/public/cpp/shell_window_ids.h"
#include "ash/shell.h"
......@@ -28,12 +27,6 @@ namespace {
// Ambient Assistant container view appearance.
constexpr int kAmbientAssistantContainerViewPreferredHeightDip = 128;
// TODO(meilinw): temporary values for dev purpose, need to be updated with the
// final spec.
constexpr float kBackgroundPhotoOpacity = 0.5f;
constexpr base::TimeDelta kBackgroundPhotoFadeOutAnimationDuration =
base::TimeDelta::FromMilliseconds(500);
aura::Window* GetContainer() {
aura::Window* container = nullptr;
if (ambient::util::IsShowing(LockScreen::ScreenType::kLock))
......@@ -48,7 +41,7 @@ void CreateWidget(AmbientContainerView* view) {
params.parent = GetContainer();
params.type = views::Widget::InitParams::TYPE_WINDOW_FRAMELESS;
params.delegate = view;
params.name = "AmbientModeContainer";
params.name = view->GetClassName();
views::Widget* widget = new views::Widget;
widget->Init(std::move(params));
......@@ -83,16 +76,6 @@ void AmbientContainerView::Layout() {
kAmbientAssistantContainerViewPreferredHeightDip));
}
void AmbientContainerView::FadeOutPhotoView() {
DCHECK(photo_view_);
photo_view_->layer()->GetAnimator()->StartAnimation(
assistant::util::CreateLayerAnimationSequence(
assistant::util::CreateOpacityElement(
kBackgroundPhotoOpacity,
kBackgroundPhotoFadeOutAnimationDuration)));
}
void AmbientContainerView::Init() {
CreateWidget(this);
// TODO(b/139954108): Choose a better dark mode theme color.
......
......@@ -26,9 +26,6 @@ class ASH_EXPORT AmbientContainerView : public views::WidgetDelegateView {
gfx::Size CalculatePreferredSize() const override;
void Layout() override;
// Fade out the background photo.
void FadeOutPhotoView();
private:
void Init();
......
......@@ -17,7 +17,7 @@ class ASH_EXPORT AmbientViewDelegate {
virtual PhotoModel* GetPhotoModel() = 0;
// Invoked when user interacting with the background photo using mouse,
// Invoked when user interacts with the background photo using mouse,
// touchpad, or touchscreen.
virtual void OnBackgroundPhotoEvents() = 0;
};
......
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