Skip to content

Commit

Permalink
PrivacyIndicators: Not showing icons in idle state.
Browse files Browse the repository at this point in the history
In idle mode, only the green dot should be showing and all the icons
should be hidden. This is to ensure that no glitches of icons will
appear in the green dot during state changes.

Change-Id: I4378792488828bf827e5ed95ee1f822d0fb15c62
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4021257
Commit-Queue: Andre Le <leandre@chromium.org>
Reviewed-by: Alex Newcomer <newcomer@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1070589}
  • Loading branch information
Andre Le authored and Chromium LUCI CQ committed Nov 12, 2022
1 parent af82a2c commit b15be00
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
14 changes: 10 additions & 4 deletions ash/system/privacy/privacy_indicators_tray_item_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "ash/style/ash_color_provider.h"
#include "ash/system/tray/tray_item_view.h"
#include "base/check.h"
#include "base/check_op.h"
#include "base/containers/flat_set.h"
#include "base/metrics/histogram_functions.h"
#include "base/time/time.h"
Expand Down Expand Up @@ -186,8 +187,11 @@ void PrivacyIndicatorsTrayItemView::Update(const std::string& app_id,
if (!GetVisible())
return;

camera_icon_->SetVisible(IsCameraUsed());
microphone_icon_->SetVisible(IsMicrophoneUsed());
camera_icon_->SetVisible(animation_state_ != AnimationState::kIdle &&
IsCameraUsed());
microphone_icon_->SetVisible(animation_state_ != AnimationState::kIdle &&
IsMicrophoneUsed());

TooltipTextChanged();
RecordPrivacyIndicatorsType();
}
Expand All @@ -202,7 +206,8 @@ void PrivacyIndicatorsTrayItemView::UpdateScreenShareStatus(
if (!GetVisible())
return;

screen_share_icon_->SetVisible(is_screen_sharing_);
screen_share_icon_->SetVisible(animation_state_ != AnimationState::kIdle &&
is_screen_sharing_);
TooltipTextChanged();
RecordPrivacyIndicatorsType();
}
Expand Down Expand Up @@ -257,6 +262,7 @@ void PrivacyIndicatorsTrayItemView::PerformVisibilityAnimation(bool visible) {
// 4. kBothSideShrink: Before the long side shrinks completely, collapses the
// short side to the final size (a green dot).
expand_animation_->Start();
animation_state_ = AnimationState::kExpand;
StartRecordAnimationSmoothness(GetWidget(), throughput_tracker_);

// At the same time, fade in icons.
Expand Down Expand Up @@ -341,7 +347,7 @@ const char* PrivacyIndicatorsTrayItemView::GetClassName() const {
void PrivacyIndicatorsTrayItemView::AnimationProgressed(
const gfx::Animation* animation) {
if (animation == expand_animation_.get()) {
animation_state_ = AnimationState::kExpand;
DCHECK_EQ(animation_state_, AnimationState::kExpand);
} else if (animation == longer_side_shrink_animation_.get() &&
!shorter_side_shrink_animation_->is_animating()) {
animation_state_ = AnimationState::kOnlyLongerSideShrink;
Expand Down
13 changes: 13 additions & 0 deletions ash/system/privacy/privacy_indicators_tray_item_view_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ class PrivacyIndicatorsTrayItemViewTest : public AshTestBase {
PrivacyIndicatorsTrayItemView::AnimationState animation_state() {
return privacy_indicators_view_->animation_state_;
}
void set_animation_state(
PrivacyIndicatorsTrayItemView::AnimationState state) {
privacy_indicators_view_->animation_state_ = state;
}

gfx::LinearAnimation* longer_side_shrink_animation() {
return privacy_indicators_view_->longer_side_shrink_animation_.get();
Expand All @@ -146,6 +150,9 @@ class PrivacyIndicatorsTrayItemViewTest : public AshTestBase {
TEST_F(PrivacyIndicatorsTrayItemViewTest, IconsVisibility) {
EXPECT_FALSE(privacy_indicators_view()->GetVisible());

// Set animation to expand to allow showing icons.
set_animation_state(PrivacyIndicatorsTrayItemView::AnimationState::kExpand);

privacy_indicators_view()->Update(/*app_id=*/"app_id",
/*is_camera_used=*/true,
/*is_microphone_used=*/false);
Expand Down Expand Up @@ -176,6 +183,9 @@ TEST_F(PrivacyIndicatorsTrayItemViewTest, IconsVisibility) {
TEST_F(PrivacyIndicatorsTrayItemViewTest, ScreenShareIconsVisibility) {
EXPECT_FALSE(privacy_indicators_view()->GetVisible());

// Set animation to expand to allow showing icons.
set_animation_state(PrivacyIndicatorsTrayItemView::AnimationState::kExpand);

privacy_indicators_view()->UpdateScreenShareStatus(
/*is_screen_sharing=*/true);
EXPECT_TRUE(privacy_indicators_view()->GetVisible());
Expand Down Expand Up @@ -458,6 +468,9 @@ TEST_F(PrivacyIndicatorsTrayItemViewTest, StateChangeDuringAnimation) {
TEST_F(PrivacyIndicatorsTrayItemViewTest, MultipleAppsAccess) {
EXPECT_FALSE(privacy_indicators_view()->GetVisible());

// Set animation to expand to allow showing icons.
set_animation_state(PrivacyIndicatorsTrayItemView::AnimationState::kExpand);

privacy_indicators_view()->Update(/*app_id=*/"app_id1",
/*is_camera_used=*/true,
/*is_microphone_used=*/false);
Expand Down

0 comments on commit b15be00

Please sign in to comment.