gd: show toast when entering the tablet mode
This CL shows toast when entering the tablet mode with at least one gaming app launched. Bug: b/316036118 Test: ash_unittests --gtest_filter="*GameDashboardContext*" Test: manual test Change-Id: Ie93ab3099dd8f7bf7b92c135a9da7cc0b1d57cd8 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5371917 Reviewed-by: Michele Fan <michelefan@chromium.org> Commit-Queue: Cici Ruan <cuicuiruan@google.com> Reviewed-by: Ahmed Fakhry <afakhry@chromium.org> Reviewed-by: Jiaming Cheng <jiamingc@chromium.org> Cr-Commit-Position: refs/heads/main@{#1273216}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
55a848101e
commit
cc12fee27e
ash
ash_strings.grd
ash_strings_grd
IDS_ASH_GAME_DASHBOARD_TABLET_STOP_RECORDING_TOAST.png.sha1IDS_ASH_GAME_DASHBOARD_TABLET_TOAST.png.sha1
constants
game_dashboard
tools/metrics/histograms/metadata/ash
@ -7589,6 +7589,12 @@ To shut down the device, press and hold the power button on the device again.
|
||||
<message name="IDS_ASH_GAME_DASHBOARD_WELCOME_DIALOG_SUB_LABEL" translateable="false" desc="The additional context added to the welcome dialog about the Game Dashboard.">
|
||||
Customize your gaming experience
|
||||
</message>
|
||||
<message name="IDS_ASH_GAME_DASHBOARD_TABLET_TOAST" translateable="false" desc="The toast text when entering the tablet mode.">
|
||||
Tablet mode is on. Game dashboard is unavailable.
|
||||
</message>
|
||||
<message name="IDS_ASH_GAME_DASHBOARD_TABLET_STOP_RECORDING_TOAST" translateable="false" desc="The toast text when entering the tablet mode with recording in progress.">
|
||||
Recording stopped. Can't use Game dashboard in tablet mode.
|
||||
</message>
|
||||
|
||||
<!-- Game Dashboard / Game Controls strings -->
|
||||
<message name="IDS_ASH_GAME_DASHBOARD_GC_CONTROLS_DETAILS_BUTTON_TOOLTIP" desc="Tooltip for the game controls details row.">
|
||||
|
@ -0,0 +1 @@
|
||||
7ec41062c0fdc69cf091070c8f223ecda6c108d2
|
@ -0,0 +1 @@
|
||||
c07bd3db101b956dcdcd7628fceecdebd70a548b
|
@ -238,7 +238,7 @@ enum class NudgeCatalogName {
|
||||
|
||||
// A living catalog that registers toasts.
|
||||
// Current values should not be renumbered or removed. Please keep in sync with
|
||||
// "ToastCatalogName" in tools/metrics/histograms/enums.xml.
|
||||
// "ToastCatalogName" in tools/metrics/histograms/metadata/ash/enums.xml
|
||||
// To deprecate comment out the entry.
|
||||
enum class ToastCatalogName {
|
||||
kVirtualDesksLimitMax = 0,
|
||||
@ -291,7 +291,8 @@ enum class ToastCatalogName {
|
||||
kDictationMicMuted = 47,
|
||||
kVideoConferenceTraySpeakOnMuteOptInConfirmation = 48,
|
||||
kAppNotClosable = 49,
|
||||
kMaxValue = kAppNotClosable
|
||||
kGameDashboardEnterTablet = 50,
|
||||
kMaxValue = kGameDashboardEnterTablet
|
||||
};
|
||||
|
||||
} // namespace ash
|
||||
|
@ -17,6 +17,9 @@ inline constexpr int kWelcomeDialogEdgePadding = 8;
|
||||
// Welcome dialog fixed width.
|
||||
inline constexpr int kWelcomeDialogFixedWidth = 360;
|
||||
|
||||
// Toast id when entring the tablet mode with any gaming window launched.
|
||||
inline constexpr char kTabletToastId[] = "GameDashboardTabletToast";
|
||||
|
||||
} // namespace ash::game_dashboard
|
||||
|
||||
#endif // ASH_GAME_DASHBOARD_GAME_DASHBOARD_CONSTANTS_H_
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include "ash/style/pill_button.h"
|
||||
#include "ash/style/switch.h"
|
||||
#include "ash/system/toast/anchored_nudge_manager_impl.h"
|
||||
#include "ash/system/toast/toast_manager_impl.h"
|
||||
#include "ash/system/unified/feature_tile.h"
|
||||
#include "ash/wm/overview/overview_controller.h"
|
||||
#include "ash/wm/overview/overview_observer.h"
|
||||
@ -1721,19 +1722,35 @@ TEST_P(GameTypeGameDashboardContextTest, TabletMode) {
|
||||
|
||||
// App is launched in desktop mode in Setup and switch to the tablet mode.
|
||||
ash::TabletModeControllerTestApi().EnterTabletMode();
|
||||
ASSERT_TRUE(display::Screen::GetScreen()->InTabletMode());
|
||||
VerifyFeaturesEnabled(/*expect_enabled=*/false);
|
||||
EXPECT_TRUE(
|
||||
ToastManager::Get()->IsToastShown(game_dashboard::kTabletToastId));
|
||||
// Switch back to the desktop mode and this feature is resumed.
|
||||
ash::TabletModeControllerTestApi().LeaveTabletMode();
|
||||
ASSERT_FALSE(display::Screen::GetScreen()->InTabletMode());
|
||||
VerifyFeaturesEnabled(/*expect_enabled=*/true, /*toolbar_visible=*/true);
|
||||
EXPECT_FALSE(
|
||||
ToastManager::Get()->IsToastShown(game_dashboard::kTabletToastId));
|
||||
CloseGameWindow();
|
||||
|
||||
// Launch app in the tablet mode and switch to the desktop mode.
|
||||
// No toast shown when there is no game window.
|
||||
ash::TabletModeControllerTestApi().EnterTabletMode();
|
||||
ASSERT_TRUE(display::Screen::GetScreen()->InTabletMode());
|
||||
EXPECT_FALSE(
|
||||
ToastManager::Get()->IsToastShown(game_dashboard::kTabletToastId));
|
||||
|
||||
// Launch app in the tablet mode and switch to the desktop mode.
|
||||
CreateGameWindow(IsArcGame());
|
||||
VerifyFeaturesEnabled(/*expect_enabled=*/false);
|
||||
EXPECT_FALSE(
|
||||
ToastManager::Get()->IsToastShown(game_dashboard::kTabletToastId));
|
||||
// Switch back to the desktop mode and this feature is resumed.
|
||||
ash::TabletModeControllerTestApi().LeaveTabletMode();
|
||||
ASSERT_FALSE(display::Screen::GetScreen()->InTabletMode());
|
||||
VerifyFeaturesEnabled(/*expect_enabled=*/true);
|
||||
EXPECT_FALSE(
|
||||
ToastManager::Get()->IsToastShown(game_dashboard::kTabletToastId));
|
||||
|
||||
// Start recording in the desktop mode and switch to the tablet mode.
|
||||
test_api_->OpenTheMainMenu();
|
||||
@ -1746,6 +1763,8 @@ TEST_P(GameTypeGameDashboardContextTest, TabletMode) {
|
||||
EXPECT_TRUE(CaptureModeController::Get()->is_recording_in_progress());
|
||||
ash::TabletModeControllerTestApi().EnterTabletMode();
|
||||
EXPECT_FALSE(CaptureModeController::Get()->is_recording_in_progress());
|
||||
EXPECT_TRUE(
|
||||
ToastManager::Get()->IsToastShown(game_dashboard::kTabletToastId));
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
@ -10,12 +10,17 @@
|
||||
|
||||
#include "ash/capture_mode/capture_mode_controller.h"
|
||||
#include "ash/constants/ash_pref_names.h"
|
||||
#include "ash/constants/notifier_catalogs.h"
|
||||
#include "ash/game_dashboard/game_dashboard_constants.h"
|
||||
#include "ash/game_dashboard/game_dashboard_context.h"
|
||||
#include "ash/game_dashboard/game_dashboard_metrics.h"
|
||||
#include "ash/game_dashboard/game_dashboard_utils.h"
|
||||
#include "ash/public/cpp/app_types_util.h"
|
||||
#include "ash/public/cpp/system/toast_data.h"
|
||||
#include "ash/public/cpp/window_properties.h"
|
||||
#include "ash/shell.h"
|
||||
#include "ash/strings/grit/ash_strings.h"
|
||||
#include "ash/system/toast/toast_manager_impl.h"
|
||||
#include "ash/wm/overview/overview_controller.h"
|
||||
#include "base/functional/bind.h"
|
||||
#include "chromeos/ui/base/window_properties.h"
|
||||
@ -23,6 +28,7 @@
|
||||
#include "extensions/common/constants.h"
|
||||
#include "ui/aura/window.h"
|
||||
#include "ui/aura/window_tracker.h"
|
||||
#include "ui/base/l10n/l10n_util.h"
|
||||
#include "ui/display/screen.h"
|
||||
#include "ui/display/tablet_state.h"
|
||||
|
||||
@ -188,10 +194,16 @@ void GameDashboardController::OnDisplayTabletStateChanged(
|
||||
display::TabletState state) {
|
||||
switch (state) {
|
||||
case display::TabletState::kInClamshellMode:
|
||||
// Cancel the tablet toast if it is still shown.
|
||||
Shell::Get()->toast_manager()->Cancel(game_dashboard::kTabletToastId);
|
||||
MaybeEnableFeatures(/*enable=*/true,
|
||||
GameDashboardMainMenuToggleMethod::kTabletMode);
|
||||
break;
|
||||
case display::TabletState::kEnteringTabletMode:
|
||||
case display::TabletState::kEnteringTabletMode: {
|
||||
const int toast_text_id =
|
||||
active_recording_context_
|
||||
? IDS_ASH_GAME_DASHBOARD_TABLET_STOP_RECORDING_TOAST
|
||||
: IDS_ASH_GAME_DASHBOARD_TABLET_TOAST;
|
||||
if (active_recording_context_) {
|
||||
auto* capture_mode_controller = CaptureModeController::Get();
|
||||
CHECK(capture_mode_controller->is_recording_in_progress());
|
||||
@ -202,9 +214,15 @@ void GameDashboardController::OnDisplayTabletStateChanged(
|
||||
}
|
||||
MaybeEnableFeatures(/*enable=*/false,
|
||||
GameDashboardMainMenuToggleMethod::kTabletMode);
|
||||
// TODO(b/316036118): Show the UI to notify users this is not available in
|
||||
// the tablet mode.
|
||||
// Show the toast to notify users when there is any game window open.
|
||||
if (!game_window_contexts_.empty()) {
|
||||
Shell::Get()->toast_manager()->Show(
|
||||
ToastData(game_dashboard::kTabletToastId,
|
||||
ToastCatalogName::kGameDashboardEnterTablet,
|
||||
l10n_util::GetStringUTF16(toast_text_id)));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case display::TabletState::kInTabletMode:
|
||||
case display::TabletState::kExitingTabletMode:
|
||||
break;
|
||||
|
@ -1987,6 +1987,7 @@ chromeos/ash/components/peripheral_notification/peripheral_notification_manager.
|
||||
<int value="46" label="Battery Saver Enabled"/>
|
||||
<int value="47" label="Dictation Mic Muted"/>
|
||||
<int value="48" label="Video Conference Speak On Mute Opt In Confirmation"/>
|
||||
<int value="50" label="Game Dashboard Disabled In Tablet Mode"/>
|
||||
</enum>
|
||||
|
||||
<enum name="TrayBackgroundViewCatalogName">
|
||||
|
Reference in New Issue
Block a user